Library of Assembled Shared Sources
 
Loading...
Searching...
No Matches
callback_python.h
Go to the documentation of this file.
1/*
2 * *** ATTENTION! DO NOT MODIFY THIS FILE DIRECTLY! ***
3 *
4 * It has automatically been generated from callback_python.tmpl.h
5 * by param_expander.py on Fri Aug 14 16:06:13 2026.
6 */
7
8/** @file
9 * @author Bram de Greve (bram@cocamware.com)
10 * @author Tom De Muer (tom@cocamware.com)
11 *
12 * *** BEGIN LICENSE INFORMATION ***
13 *
14 * The contents of this file are subject to the Common Public Attribution License
15 * Version 1.0 (the "License"); you may not use this file except in compliance with
16 * the License. You may obtain a copy of the License at
17 * http://lass.sourceforge.net/cpal-license. The License is based on the
18 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
19 * use of software over a computer network and provide for limited attribution for
20 * the Original Developer. In addition, Exhibit A has been modified to be consistent
21 * with Exhibit B.
22 *
23 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
24 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
25 * language governing rights and limitations under the License.
26 *
27 * The Original Code is LASS - Library of Assembled Shared Sources.
28 *
29 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
30 * The Original Developer is the Initial Developer.
31 *
32 * All portions of the code written by the Initial Developer are:
33 * Copyright (C) 2004-2026 the Initial Developer.
34 * All Rights Reserved.
35 *
36 * Contributor(s):
37 *
38 * Alternatively, the contents of this file may be used under the terms of the
39 * GNU General Public License Version 2 or later (the GPL), in which case the
40 * provisions of GPL are applicable instead of those above. If you wish to allow use
41 * of your version of this file only under the terms of the GPL and not to allow
42 * others to use your version of this file under the CPAL, indicate your decision by
43 * deleting the provisions above and replace them with the notice and other
44 * provisions required by the GPL License. If you do not delete the provisions above,
45 * a recipient may use your version of this file under either the CPAL or the GPL.
46 *
47 * *** END LICENSE INFORMATION ***
48 */
49
50
51#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H
52#define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H
53
54#include "python_common.h"
55#include "pyobject_plus.h"
56#include "py_tuple.h"
57#include "pyobject_call.inl"
58#include "exception.h"
59#include "_lass_module.h"
60
61namespace lass
62{
63namespace python
64{
65namespace impl
66{
67 /** Common implementation of a dispatcher to an python callback with void return type
68 * @internal
69 * @author Bramz
70 */
71 class FunctorPythonBase
72 {
73 public:
74 FunctorPythonBase(const TPyObjPtr& callable): callable_(callable) {}
75 bool operator==(const FunctorPythonBase& other) const
76 {
77 return callable_.get() == other.callable_.get();
78 }
79 bool operator!() const
80 {
81 return !callable_;
82 }
83 const TPyObjPtr& callable() const
84 {
85 return callable_;
86 }
87 protected:
88 void call(const TPyObjPtr& args) const
89 {
90 LockGIL lock;
91 LASS_ASSERT(callable_);
92 const TPyObjPtr result(PyObject_CallObject(callable_.get(), args.get()));
93 if (!result)
94 {
95 fetchAndThrowPythonException(LASS_PRETTY_FUNCTION);
96 }
97 }
98 private:
99 TPyObjPtr callable_;
100 };
101
102 /** Common implementation of a dispatcher to an python callback with non-void return type.
103 * @internal
104 * @author Bramz
105 */
106 template <typename R>
107 class FunctorPythonRBase
108 {
109 public:
110 FunctorPythonRBase(const TPyObjPtr& callable): callable_(callable) {}
111 bool operator==(const FunctorPythonRBase<R>& other) const
112 {
113 return callable_.get() == other.callable_.get();
114 }
115 bool operator!() const
116 {
117 return !callable_;
118 }
119 const TPyObjPtr& callable() const
120 {
121 return callable_;
122 }
123 protected:
124 R call(const TPyObjPtr& args) const
125 {
126 static_assert(!std::is_reference_v<R> && !std::is_pointer_v<R>, "Python callbacks must return by value, not by reference or pointer");
127 LockGIL lock;
128 LASS_ASSERT(callable_);
129 const TPyObjPtr result(PyObject_CallObject(callable_.get(), args.get()));
130 if (!result)
131 {
132 fetchAndThrowPythonException(LASS_PRETTY_FUNCTION);
133 }
134 typedef ArgumentTraits<R> TraitsR;
135 typename TraitsR::TStorage temp;
136 if (pyGetSimpleObject(result.get(), temp) != 0)
137 {
138 fetchAndThrowPythonException(LASS_PRETTY_FUNCTION);
139 }
140 return TraitsR::arg(temp);
141 }
142 private:
143 TPyObjPtr callable_;
144 };
145
146 class PyCallbackImplBase
147 {
148 public:
149 virtual ~PyCallbackImplBase() = default;
150 virtual PyObject* call(PyObject* args) const = 0;
151 };
152
153 class LASS_PYTHON_DLL PyCallback: public PyObjectPlus
154 {
156 public:
157 using TPimpl = std::unique_ptr<PyCallbackImplBase>;
158
159 PyCallback(TPimpl impl);
160
161 template <typename PyCallbackImplType>
162 bool get(typename PyCallbackImplType::TCallback& v) const
163 {
164 PyCallbackImplBase* p = pimpl_.get();
165 if (p && typeid(*p) == typeid(PyCallbackImplType))
166 {
167 v = static_cast<PyCallbackImplType*>(p)->callable();
168 return true;
169 }
170 return false;
171 }
172
173 static PyObject* _tp_call(PyObject* self, PyObject* args, PyObject* kwargs);
174 private:
175 TPimpl pimpl_;
176 };
177}
178
179/** Helper class to implement PyExportTraits for Callback types
180 *
181 * Only the `get()` method is implemented, which allows you to use callbacks as
182 * C++ function parameters, but not als return values. Returning a callback from C++
183 * to Python is not supported.
184 *
185 * For full bidirectional support, use std::function instead.
186 *
187 * @ingroup PyExportTraits
188 */
189template <typename CallbackType, typename PyCallbackImplType, typename ExportTraits>
191{
192 static int get(PyObject* value, CallbackType& callback)
193 {
194 if (value == Py_None)
195 {
196 callback.reset();
197 return 0;
198 }
199 impl::initLassModule(); // ensure the module is initialized
200 if (PyType_IsSubtype(Py_TYPE(value), impl::PyCallback::_lassPyClassDef.type()))
201 {
202 if (static_cast<impl::PyCallback*>(value)->get<PyCallbackImplType>(callback))
203 {
204 return 0;
205 }
206 }
207 TPyObjPtr callable;
208 if (pyGetSimpleObject(value, callable) != 0)
209 {
210 impl::addMessageHeader(ExportTraits::className());
211 return 1;
212 }
213 if (!callable) // null pointer
214 {
215 callback.reset();
216 return 0;
217 }
218 if (!PyCallable_Check(callable.get()))
219 {
220 std::ostringstream buffer;
221 buffer << ExportTraits::className() << ": not callable";
222 PyErr_SetString(PyExc_TypeError, buffer.str().c_str());
223 return 1;
224 }
225 using TFunctor = typename PyCallbackImplType::TFunctor;
226 callback = TFunctor(callable);
227 return 0;
228 }
229 static PyObject* build(const CallbackType& callback)
230 {
231 if (!callback)
232 {
233 Py_RETURN_NONE;
234 }
235
236 using TDispatcher = typename PyCallbackImplType::TDispatcher;
237 auto dispatcher = callback.dispatcher().get();
238 if (dispatcher && typeid(*dispatcher) == typeid(TDispatcher))
239 {
240 // already a FunctorType, return the original callable
241 return fromSharedPtrToNakedCast(static_cast<TDispatcher*>(dispatcher)->function().callable());
242 }
243 // wrap in a PyCallback object
244 impl::PyCallback::TPimpl pimpl(new PyCallbackImplType(callback));
245 return new impl::PyCallback(std::move(pimpl));
246 }
247};
248
249}
250}
251
252#endif
253
254#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_0)
255# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_0
256# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_0
257
258namespace lass
259{
260namespace python
261{
262namespace impl
263{
264 class Functor0Python: public FunctorPythonBase
265 {
266 public:
267 Functor0Python(const python::TPyObjPtr& callable): FunctorPythonBase(callable) {}
268 void operator()() const
269 {
270 LockGIL lock;
271 this->call(python::TPyObjPtr());
272 }
273 };
274
275 class PyCallback0Impl: public PyCallbackImplBase
276 {
277 public:
278 using TCallback = util::Callback0;
279 using TFunctor = Functor0Python;
280 using TDispatcher = util::impl::Dispatcher0Function<TFunctor>;
281
282 PyCallback0Impl(TCallback callback): callback_(std::move(callback)) {}
283 const TCallback& callable() const { return callback_; }
284
285 PyObject* call(PyObject* args) const override
286 {
287 if ( decodeTuple(args) != 0 )
288 {
289 return nullptr;
290 }
291 return Caller<void>::callFunction<const TCallback&>(callback_);
292 }
293 private:
294 TCallback callback_;
295 };
296}
297
298/** Bidirectional mapping between util::Callback0 and a Python callable object
299 *
300 * Accepts Callable objects and wraps them in a util::Callback0 without checking the
301 * parameter types or return type, allowing to call them from C++. The parameters
302 * and return type are only checked when the function is called, and an exception will
303 * be raised if the types do not match.
304 *
305 * From C++ to Python, the util::Callback0 is converted to a Callable object, so that
306 * it can be called from Python. Again, the parameter types and return type will be
307 * checked when the function is called.
308 *
309 * In both directions, unwrapping a previously wrapped function will be attempted.
310 * I.e. if the util::Callback0 passed to Python already wraps a Callable Python
311 * object, this will be unwrapped and the Callable object will be passed back to Python.
312 * In the other direction, if a Callable object that was passed to C++ already wraps a
313 * util::Callback0, *and* this util::Callback0 matches the correct signature, then
314 * the util::Callback0 will be unwrapped and passed to C++. In other words, both
315 * directions will guarantee a perfect round trip if possible. In all other cases, the
316 * Callable or util::Callback0 will be wrapped in a new util::Callback0 or Callable
317 * object.
318 *
319 * @ingroup PyExportTraits
320 */
321template <>
322struct PyExportTraits< util::Callback0 >:
324 util::Callback0,
325 impl::PyCallback0Impl,
326 PyExportTraits< util::Callback0 >
327 >
328{
329 static constexpr const char* py_typing = "Callable[[], None]";
330
331 static const char* className() { return "Callback0"; }
332};
333
334}
335}
336
337# endif
338#endif
339
340#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_1)
341# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_1
342# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_1
343
344namespace lass
345{
346namespace python
347{
348namespace impl
349{
350 template <typename P1>
351 class Functor1Python: public FunctorPythonBase
352 {
353 public:
354 Functor1Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
355 void operator()(typename util::CallTraits<P1>::TParam p1) const
356 {
357 LockGIL lock;
358 this->call(makeTuple(p1));
359 }
360 };
361
362 template <typename P1>
363 class PyCallback1Impl: public PyCallbackImplBase
364 {
365 public:
366 using TCallback = util::Callback1<P1>;
367 using TFunctor = Functor1Python<P1>;
368 using TDispatcher = util::impl::Dispatcher1Function<P1, TFunctor>;
369
370 PyCallback1Impl(TCallback callback): callback_(std::move(callback)) {}
371 const TCallback& callable() const { return callback_; }
372
373 PyObject* call(PyObject* args) const override
374 {
375 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
376
377 if ( decodeTuple<S1>(args, p1) != 0 )
378 {
379 return nullptr;
380 }
381 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1));
382 }
383 private:
384 TCallback callback_;
385 };
386}
387
388/** Bidirectional mapping between util::Callback1 and a Python callable object
389 *
390 * Accepts Callable objects and wraps them in a util::Callback1 without checking the
391 * parameter types or return type, allowing to call them from C++. The parameters
392 * and return type are only checked when the function is called, and an exception will
393 * be raised if the types do not match.
394 *
395 * From C++ to Python, the util::Callback1 is converted to a Callable object, so that
396 * it can be called from Python. Again, the parameter types and return type will be
397 * checked when the function is called.
398 *
399 * In both directions, unwrapping a previously wrapped function will be attempted.
400 * I.e. if the util::Callback1 passed to Python already wraps a Callable Python
401 * object, this will be unwrapped and the Callable object will be passed back to Python.
402 * In the other direction, if a Callable object that was passed to C++ already wraps a
403 * util::Callback1, *and* this util::Callback1 matches the correct signature, then
404 * the util::Callback1 will be unwrapped and passed to C++. In other words, both
405 * directions will guarantee a perfect round trip if possible. In all other cases, the
406 * Callable or util::Callback1 will be wrapped in a new util::Callback1 or Callable
407 * object.
408 *
409 * @ingroup PyExportTraits
410 */
411template <typename P1>
412struct PyExportTraits< util::Callback1<P1> >:
414 util::Callback1<P1>,
415 impl::PyCallback1Impl<P1>,
416 PyExportTraits< util::Callback1<P1> >
417 >
418{
419 static constexpr const char* py_typing = "Callable[[P1!], None]";
420
421 static const char* className() { return "Callback1"; }
422};
423
424}
425}
426
427# endif
428#endif
429
430#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_2)
431# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_2
432# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_2
433
434namespace lass
435{
436namespace python
437{
438namespace impl
439{
440 template <typename P1, typename P2>
441 class Functor2Python: public FunctorPythonBase
442 {
443 public:
444 Functor2Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
445 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2) const
446 {
447 LockGIL lock;
448 this->call(makeTuple(p1, p2));
449 }
450 };
451
452 template <typename P1, typename P2>
453 class PyCallback2Impl: public PyCallbackImplBase
454 {
455 public:
456 using TCallback = util::Callback2<P1, P2>;
457 using TFunctor = Functor2Python<P1, P2>;
458 using TDispatcher = util::impl::Dispatcher2Function<P1, P2, TFunctor>;
459
460 PyCallback2Impl(TCallback callback): callback_(std::move(callback)) {}
461 const TCallback& callable() const { return callback_; }
462
463 PyObject* call(PyObject* args) const override
464 {
465 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
466 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
467
468 if ( decodeTuple<S1, S2>(args, p1, p2) != 0 )
469 {
470 return nullptr;
471 }
472 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2));
473 }
474 private:
475 TCallback callback_;
476 };
477}
478
479/** Bidirectional mapping between util::Callback2 and a Python callable object
480 *
481 * Accepts Callable objects and wraps them in a util::Callback2 without checking the
482 * parameter types or return type, allowing to call them from C++. The parameters
483 * and return type are only checked when the function is called, and an exception will
484 * be raised if the types do not match.
485 *
486 * From C++ to Python, the util::Callback2 is converted to a Callable object, so that
487 * it can be called from Python. Again, the parameter types and return type will be
488 * checked when the function is called.
489 *
490 * In both directions, unwrapping a previously wrapped function will be attempted.
491 * I.e. if the util::Callback2 passed to Python already wraps a Callable Python
492 * object, this will be unwrapped and the Callable object will be passed back to Python.
493 * In the other direction, if a Callable object that was passed to C++ already wraps a
494 * util::Callback2, *and* this util::Callback2 matches the correct signature, then
495 * the util::Callback2 will be unwrapped and passed to C++. In other words, both
496 * directions will guarantee a perfect round trip if possible. In all other cases, the
497 * Callable or util::Callback2 will be wrapped in a new util::Callback2 or Callable
498 * object.
499 *
500 * @ingroup PyExportTraits
501 */
502template <typename P1, typename P2>
503struct PyExportTraits< util::Callback2<P1, P2> >:
505 util::Callback2<P1, P2>,
506 impl::PyCallback2Impl<P1, P2>,
507 PyExportTraits< util::Callback2<P1, P2> >
508 >
509{
510 static constexpr const char* py_typing = "Callable[[P1!, P2!], None]";
511
512 static const char* className() { return "Callback2"; }
513};
514
515}
516}
517
518# endif
519#endif
520
521#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_3)
522# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_3
523# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_3
524
525namespace lass
526{
527namespace python
528{
529namespace impl
530{
531 template <typename P1, typename P2, typename P3>
532 class Functor3Python: public FunctorPythonBase
533 {
534 public:
535 Functor3Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
536 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3) const
537 {
538 LockGIL lock;
539 this->call(makeTuple(p1, p2, p3));
540 }
541 };
542
543 template <typename P1, typename P2, typename P3>
544 class PyCallback3Impl: public PyCallbackImplBase
545 {
546 public:
547 using TCallback = util::Callback3<P1, P2, P3>;
548 using TFunctor = Functor3Python<P1, P2, P3>;
549 using TDispatcher = util::impl::Dispatcher3Function<P1, P2, P3, TFunctor>;
550
551 PyCallback3Impl(TCallback callback): callback_(std::move(callback)) {}
552 const TCallback& callable() const { return callback_; }
553
554 PyObject* call(PyObject* args) const override
555 {
556 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
557 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
558 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
559
560 if ( decodeTuple<S1, S2, S3>(args, p1, p2, p3) != 0 )
561 {
562 return nullptr;
563 }
564 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3));
565 }
566 private:
567 TCallback callback_;
568 };
569}
570
571/** Bidirectional mapping between util::Callback3 and a Python callable object
572 *
573 * Accepts Callable objects and wraps them in a util::Callback3 without checking the
574 * parameter types or return type, allowing to call them from C++. The parameters
575 * and return type are only checked when the function is called, and an exception will
576 * be raised if the types do not match.
577 *
578 * From C++ to Python, the util::Callback3 is converted to a Callable object, so that
579 * it can be called from Python. Again, the parameter types and return type will be
580 * checked when the function is called.
581 *
582 * In both directions, unwrapping a previously wrapped function will be attempted.
583 * I.e. if the util::Callback3 passed to Python already wraps a Callable Python
584 * object, this will be unwrapped and the Callable object will be passed back to Python.
585 * In the other direction, if a Callable object that was passed to C++ already wraps a
586 * util::Callback3, *and* this util::Callback3 matches the correct signature, then
587 * the util::Callback3 will be unwrapped and passed to C++. In other words, both
588 * directions will guarantee a perfect round trip if possible. In all other cases, the
589 * Callable or util::Callback3 will be wrapped in a new util::Callback3 or Callable
590 * object.
591 *
592 * @ingroup PyExportTraits
593 */
594template <typename P1, typename P2, typename P3>
595struct PyExportTraits< util::Callback3<P1, P2, P3> >:
597 util::Callback3<P1, P2, P3>,
598 impl::PyCallback3Impl<P1, P2, P3>,
599 PyExportTraits< util::Callback3<P1, P2, P3> >
600 >
601{
602 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!], None]";
603
604 static const char* className() { return "Callback3"; }
605};
606
607}
608}
609
610# endif
611#endif
612
613#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_4)
614# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_4
615# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_4
616
617namespace lass
618{
619namespace python
620{
621namespace impl
622{
623 template <typename P1, typename P2, typename P3, typename P4>
624 class Functor4Python: public FunctorPythonBase
625 {
626 public:
627 Functor4Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
628 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4) const
629 {
630 LockGIL lock;
631 this->call(makeTuple(p1, p2, p3, p4));
632 }
633 };
634
635 template <typename P1, typename P2, typename P3, typename P4>
636 class PyCallback4Impl: public PyCallbackImplBase
637 {
638 public:
639 using TCallback = util::Callback4<P1, P2, P3, P4>;
640 using TFunctor = Functor4Python<P1, P2, P3, P4>;
641 using TDispatcher = util::impl::Dispatcher4Function<P1, P2, P3, P4, TFunctor>;
642
643 PyCallback4Impl(TCallback callback): callback_(std::move(callback)) {}
644 const TCallback& callable() const { return callback_; }
645
646 PyObject* call(PyObject* args) const override
647 {
648 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
649 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
650 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
651 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
652
653 if ( decodeTuple<S1, S2, S3, S4>(args, p1, p2, p3, p4) != 0 )
654 {
655 return nullptr;
656 }
657 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4));
658 }
659 private:
660 TCallback callback_;
661 };
662}
663
664/** Bidirectional mapping between util::Callback4 and a Python callable object
665 *
666 * Accepts Callable objects and wraps them in a util::Callback4 without checking the
667 * parameter types or return type, allowing to call them from C++. The parameters
668 * and return type are only checked when the function is called, and an exception will
669 * be raised if the types do not match.
670 *
671 * From C++ to Python, the util::Callback4 is converted to a Callable object, so that
672 * it can be called from Python. Again, the parameter types and return type will be
673 * checked when the function is called.
674 *
675 * In both directions, unwrapping a previously wrapped function will be attempted.
676 * I.e. if the util::Callback4 passed to Python already wraps a Callable Python
677 * object, this will be unwrapped and the Callable object will be passed back to Python.
678 * In the other direction, if a Callable object that was passed to C++ already wraps a
679 * util::Callback4, *and* this util::Callback4 matches the correct signature, then
680 * the util::Callback4 will be unwrapped and passed to C++. In other words, both
681 * directions will guarantee a perfect round trip if possible. In all other cases, the
682 * Callable or util::Callback4 will be wrapped in a new util::Callback4 or Callable
683 * object.
684 *
685 * @ingroup PyExportTraits
686 */
687template <typename P1, typename P2, typename P3, typename P4>
688struct PyExportTraits< util::Callback4<P1, P2, P3, P4> >:
690 util::Callback4<P1, P2, P3, P4>,
691 impl::PyCallback4Impl<P1, P2, P3, P4>,
692 PyExportTraits< util::Callback4<P1, P2, P3, P4> >
693 >
694{
695 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!], None]";
696
697 static const char* className() { return "Callback4"; }
698};
699
700}
701}
702
703# endif
704#endif
705
706#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_5)
707# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_5
708# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_5
709
710namespace lass
711{
712namespace python
713{
714namespace impl
715{
716 template <typename P1, typename P2, typename P3, typename P4, typename P5>
717 class Functor5Python: public FunctorPythonBase
718 {
719 public:
720 Functor5Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
721 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5) const
722 {
723 LockGIL lock;
724 this->call(makeTuple(p1, p2, p3, p4, p5));
725 }
726 };
727
728 template <typename P1, typename P2, typename P3, typename P4, typename P5>
729 class PyCallback5Impl: public PyCallbackImplBase
730 {
731 public:
732 using TCallback = util::Callback5<P1, P2, P3, P4, P5>;
733 using TFunctor = Functor5Python<P1, P2, P3, P4, P5>;
734 using TDispatcher = util::impl::Dispatcher5Function<P1, P2, P3, P4, P5, TFunctor>;
735
736 PyCallback5Impl(TCallback callback): callback_(std::move(callback)) {}
737 const TCallback& callable() const { return callback_; }
738
739 PyObject* call(PyObject* args) const override
740 {
741 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
742 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
743 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
744 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
745 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
746
747 if ( decodeTuple<S1, S2, S3, S4, S5>(args, p1, p2, p3, p4, p5) != 0 )
748 {
749 return nullptr;
750 }
751 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5));
752 }
753 private:
754 TCallback callback_;
755 };
756}
757
758/** Bidirectional mapping between util::Callback5 and a Python callable object
759 *
760 * Accepts Callable objects and wraps them in a util::Callback5 without checking the
761 * parameter types or return type, allowing to call them from C++. The parameters
762 * and return type are only checked when the function is called, and an exception will
763 * be raised if the types do not match.
764 *
765 * From C++ to Python, the util::Callback5 is converted to a Callable object, so that
766 * it can be called from Python. Again, the parameter types and return type will be
767 * checked when the function is called.
768 *
769 * In both directions, unwrapping a previously wrapped function will be attempted.
770 * I.e. if the util::Callback5 passed to Python already wraps a Callable Python
771 * object, this will be unwrapped and the Callable object will be passed back to Python.
772 * In the other direction, if a Callable object that was passed to C++ already wraps a
773 * util::Callback5, *and* this util::Callback5 matches the correct signature, then
774 * the util::Callback5 will be unwrapped and passed to C++. In other words, both
775 * directions will guarantee a perfect round trip if possible. In all other cases, the
776 * Callable or util::Callback5 will be wrapped in a new util::Callback5 or Callable
777 * object.
778 *
779 * @ingroup PyExportTraits
780 */
781template <typename P1, typename P2, typename P3, typename P4, typename P5>
782struct PyExportTraits< util::Callback5<P1, P2, P3, P4, P5> >:
784 util::Callback5<P1, P2, P3, P4, P5>,
785 impl::PyCallback5Impl<P1, P2, P3, P4, P5>,
786 PyExportTraits< util::Callback5<P1, P2, P3, P4, P5> >
787 >
788{
789 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!], None]";
790
791 static const char* className() { return "Callback5"; }
792};
793
794}
795}
796
797# endif
798#endif
799
800#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_6)
801# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_6
802# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_6
803
804namespace lass
805{
806namespace python
807{
808namespace impl
809{
810 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
811 class Functor6Python: public FunctorPythonBase
812 {
813 public:
814 Functor6Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
815 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6) const
816 {
817 LockGIL lock;
818 this->call(makeTuple(p1, p2, p3, p4, p5, p6));
819 }
820 };
821
822 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
823 class PyCallback6Impl: public PyCallbackImplBase
824 {
825 public:
826 using TCallback = util::Callback6<P1, P2, P3, P4, P5, P6>;
827 using TFunctor = Functor6Python<P1, P2, P3, P4, P5, P6>;
828 using TDispatcher = util::impl::Dispatcher6Function<P1, P2, P3, P4, P5, P6, TFunctor>;
829
830 PyCallback6Impl(TCallback callback): callback_(std::move(callback)) {}
831 const TCallback& callable() const { return callback_; }
832
833 PyObject* call(PyObject* args) const override
834 {
835 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
836 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
837 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
838 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
839 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
840 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
841
842 if ( decodeTuple<S1, S2, S3, S4, S5, S6>(args, p1, p2, p3, p4, p5, p6) != 0 )
843 {
844 return nullptr;
845 }
846 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6));
847 }
848 private:
849 TCallback callback_;
850 };
851}
852
853/** Bidirectional mapping between util::Callback6 and a Python callable object
854 *
855 * Accepts Callable objects and wraps them in a util::Callback6 without checking the
856 * parameter types or return type, allowing to call them from C++. The parameters
857 * and return type are only checked when the function is called, and an exception will
858 * be raised if the types do not match.
859 *
860 * From C++ to Python, the util::Callback6 is converted to a Callable object, so that
861 * it can be called from Python. Again, the parameter types and return type will be
862 * checked when the function is called.
863 *
864 * In both directions, unwrapping a previously wrapped function will be attempted.
865 * I.e. if the util::Callback6 passed to Python already wraps a Callable Python
866 * object, this will be unwrapped and the Callable object will be passed back to Python.
867 * In the other direction, if a Callable object that was passed to C++ already wraps a
868 * util::Callback6, *and* this util::Callback6 matches the correct signature, then
869 * the util::Callback6 will be unwrapped and passed to C++. In other words, both
870 * directions will guarantee a perfect round trip if possible. In all other cases, the
871 * Callable or util::Callback6 will be wrapped in a new util::Callback6 or Callable
872 * object.
873 *
874 * @ingroup PyExportTraits
875 */
876template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
877struct PyExportTraits< util::Callback6<P1, P2, P3, P4, P5, P6> >:
879 util::Callback6<P1, P2, P3, P4, P5, P6>,
880 impl::PyCallback6Impl<P1, P2, P3, P4, P5, P6>,
881 PyExportTraits< util::Callback6<P1, P2, P3, P4, P5, P6> >
882 >
883{
884 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!], None]";
885
886 static const char* className() { return "Callback6"; }
887};
888
889}
890}
891
892# endif
893#endif
894
895#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_7)
896# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_7
897# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_7
898
899namespace lass
900{
901namespace python
902{
903namespace impl
904{
905 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
906 class Functor7Python: public FunctorPythonBase
907 {
908 public:
909 Functor7Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
910 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7) const
911 {
912 LockGIL lock;
913 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7));
914 }
915 };
916
917 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
918 class PyCallback7Impl: public PyCallbackImplBase
919 {
920 public:
921 using TCallback = util::Callback7<P1, P2, P3, P4, P5, P6, P7>;
922 using TFunctor = Functor7Python<P1, P2, P3, P4, P5, P6, P7>;
923 using TDispatcher = util::impl::Dispatcher7Function<P1, P2, P3, P4, P5, P6, P7, TFunctor>;
924
925 PyCallback7Impl(TCallback callback): callback_(std::move(callback)) {}
926 const TCallback& callable() const { return callback_; }
927
928 PyObject* call(PyObject* args) const override
929 {
930 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
931 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
932 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
933 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
934 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
935 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
936 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
937
938 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7>(args, p1, p2, p3, p4, p5, p6, p7) != 0 )
939 {
940 return nullptr;
941 }
942 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7));
943 }
944 private:
945 TCallback callback_;
946 };
947}
948
949/** Bidirectional mapping between util::Callback7 and a Python callable object
950 *
951 * Accepts Callable objects and wraps them in a util::Callback7 without checking the
952 * parameter types or return type, allowing to call them from C++. The parameters
953 * and return type are only checked when the function is called, and an exception will
954 * be raised if the types do not match.
955 *
956 * From C++ to Python, the util::Callback7 is converted to a Callable object, so that
957 * it can be called from Python. Again, the parameter types and return type will be
958 * checked when the function is called.
959 *
960 * In both directions, unwrapping a previously wrapped function will be attempted.
961 * I.e. if the util::Callback7 passed to Python already wraps a Callable Python
962 * object, this will be unwrapped and the Callable object will be passed back to Python.
963 * In the other direction, if a Callable object that was passed to C++ already wraps a
964 * util::Callback7, *and* this util::Callback7 matches the correct signature, then
965 * the util::Callback7 will be unwrapped and passed to C++. In other words, both
966 * directions will guarantee a perfect round trip if possible. In all other cases, the
967 * Callable or util::Callback7 will be wrapped in a new util::Callback7 or Callable
968 * object.
969 *
970 * @ingroup PyExportTraits
971 */
972template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
973struct PyExportTraits< util::Callback7<P1, P2, P3, P4, P5, P6, P7> >:
975 util::Callback7<P1, P2, P3, P4, P5, P6, P7>,
976 impl::PyCallback7Impl<P1, P2, P3, P4, P5, P6, P7>,
977 PyExportTraits< util::Callback7<P1, P2, P3, P4, P5, P6, P7> >
978 >
979{
980 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!], None]";
981
982 static const char* className() { return "Callback7"; }
983};
984
985}
986}
987
988# endif
989#endif
990
991#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_8)
992# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_8
993# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_8
994
995namespace lass
996{
997namespace python
998{
999namespace impl
1000{
1001 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
1002 class Functor8Python: public FunctorPythonBase
1003 {
1004 public:
1005 Functor8Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1006 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8) const
1007 {
1008 LockGIL lock;
1009 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8));
1010 }
1011 };
1012
1013 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
1014 class PyCallback8Impl: public PyCallbackImplBase
1015 {
1016 public:
1017 using TCallback = util::Callback8<P1, P2, P3, P4, P5, P6, P7, P8>;
1018 using TFunctor = Functor8Python<P1, P2, P3, P4, P5, P6, P7, P8>;
1019 using TDispatcher = util::impl::Dispatcher8Function<P1, P2, P3, P4, P5, P6, P7, P8, TFunctor>;
1020
1021 PyCallback8Impl(TCallback callback): callback_(std::move(callback)) {}
1022 const TCallback& callable() const { return callback_; }
1023
1024 PyObject* call(PyObject* args) const override
1025 {
1026 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1027 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1028 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1029 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1030 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1031 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1032 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1033 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1034
1035 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8>(args, p1, p2, p3, p4, p5, p6, p7, p8) != 0 )
1036 {
1037 return nullptr;
1038 }
1039 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8));
1040 }
1041 private:
1042 TCallback callback_;
1043 };
1044}
1045
1046/** Bidirectional mapping between util::Callback8 and a Python callable object
1047 *
1048 * Accepts Callable objects and wraps them in a util::Callback8 without checking the
1049 * parameter types or return type, allowing to call them from C++. The parameters
1050 * and return type are only checked when the function is called, and an exception will
1051 * be raised if the types do not match.
1052 *
1053 * From C++ to Python, the util::Callback8 is converted to a Callable object, so that
1054 * it can be called from Python. Again, the parameter types and return type will be
1055 * checked when the function is called.
1056 *
1057 * In both directions, unwrapping a previously wrapped function will be attempted.
1058 * I.e. if the util::Callback8 passed to Python already wraps a Callable Python
1059 * object, this will be unwrapped and the Callable object will be passed back to Python.
1060 * In the other direction, if a Callable object that was passed to C++ already wraps a
1061 * util::Callback8, *and* this util::Callback8 matches the correct signature, then
1062 * the util::Callback8 will be unwrapped and passed to C++. In other words, both
1063 * directions will guarantee a perfect round trip if possible. In all other cases, the
1064 * Callable or util::Callback8 will be wrapped in a new util::Callback8 or Callable
1065 * object.
1066 *
1067 * @ingroup PyExportTraits
1068 */
1069template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
1070struct PyExportTraits< util::Callback8<P1, P2, P3, P4, P5, P6, P7, P8> >:
1072 util::Callback8<P1, P2, P3, P4, P5, P6, P7, P8>,
1073 impl::PyCallback8Impl<P1, P2, P3, P4, P5, P6, P7, P8>,
1074 PyExportTraits< util::Callback8<P1, P2, P3, P4, P5, P6, P7, P8> >
1075 >
1076{
1077 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!], None]";
1078
1079 static const char* className() { return "Callback8"; }
1080};
1081
1082}
1083}
1084
1085# endif
1086#endif
1087
1088#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_9)
1089# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_9
1090# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_9
1091
1092namespace lass
1093{
1094namespace python
1095{
1096namespace impl
1097{
1098 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
1099 class Functor9Python: public FunctorPythonBase
1100 {
1101 public:
1102 Functor9Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1103 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9) const
1104 {
1105 LockGIL lock;
1106 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9));
1107 }
1108 };
1109
1110 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
1111 class PyCallback9Impl: public PyCallbackImplBase
1112 {
1113 public:
1114 using TCallback = util::Callback9<P1, P2, P3, P4, P5, P6, P7, P8, P9>;
1115 using TFunctor = Functor9Python<P1, P2, P3, P4, P5, P6, P7, P8, P9>;
1116 using TDispatcher = util::impl::Dispatcher9Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, TFunctor>;
1117
1118 PyCallback9Impl(TCallback callback): callback_(std::move(callback)) {}
1119 const TCallback& callable() const { return callback_; }
1120
1121 PyObject* call(PyObject* args) const override
1122 {
1123 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1124 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1125 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1126 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1127 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1128 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1129 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1130 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1131 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1132
1133 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9) != 0 )
1134 {
1135 return nullptr;
1136 }
1137 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9));
1138 }
1139 private:
1140 TCallback callback_;
1141 };
1142}
1143
1144/** Bidirectional mapping between util::Callback9 and a Python callable object
1145 *
1146 * Accepts Callable objects and wraps them in a util::Callback9 without checking the
1147 * parameter types or return type, allowing to call them from C++. The parameters
1148 * and return type are only checked when the function is called, and an exception will
1149 * be raised if the types do not match.
1150 *
1151 * From C++ to Python, the util::Callback9 is converted to a Callable object, so that
1152 * it can be called from Python. Again, the parameter types and return type will be
1153 * checked when the function is called.
1154 *
1155 * In both directions, unwrapping a previously wrapped function will be attempted.
1156 * I.e. if the util::Callback9 passed to Python already wraps a Callable Python
1157 * object, this will be unwrapped and the Callable object will be passed back to Python.
1158 * In the other direction, if a Callable object that was passed to C++ already wraps a
1159 * util::Callback9, *and* this util::Callback9 matches the correct signature, then
1160 * the util::Callback9 will be unwrapped and passed to C++. In other words, both
1161 * directions will guarantee a perfect round trip if possible. In all other cases, the
1162 * Callable or util::Callback9 will be wrapped in a new util::Callback9 or Callable
1163 * object.
1164 *
1165 * @ingroup PyExportTraits
1166 */
1167template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
1168struct PyExportTraits< util::Callback9<P1, P2, P3, P4, P5, P6, P7, P8, P9> >:
1170 util::Callback9<P1, P2, P3, P4, P5, P6, P7, P8, P9>,
1171 impl::PyCallback9Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9>,
1172 PyExportTraits< util::Callback9<P1, P2, P3, P4, P5, P6, P7, P8, P9> >
1173 >
1174{
1175 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!], None]";
1176
1177 static const char* className() { return "Callback9"; }
1178};
1179
1180}
1181}
1182
1183# endif
1184#endif
1185
1186#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_10)
1187# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_10
1188# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_10
1189
1190namespace lass
1191{
1192namespace python
1193{
1194namespace impl
1195{
1196 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
1197 class Functor10Python: public FunctorPythonBase
1198 {
1199 public:
1200 Functor10Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1201 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10) const
1202 {
1203 LockGIL lock;
1204 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10));
1205 }
1206 };
1207
1208 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
1209 class PyCallback10Impl: public PyCallbackImplBase
1210 {
1211 public:
1212 using TCallback = util::Callback10<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>;
1213 using TFunctor = Functor10Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>;
1214 using TDispatcher = util::impl::Dispatcher10Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, TFunctor>;
1215
1216 PyCallback10Impl(TCallback callback): callback_(std::move(callback)) {}
1217 const TCallback& callable() const { return callback_; }
1218
1219 PyObject* call(PyObject* args) const override
1220 {
1221 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1222 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1223 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1224 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1225 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1226 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1227 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1228 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1229 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1230 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1231
1232 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) != 0 )
1233 {
1234 return nullptr;
1235 }
1236 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10));
1237 }
1238 private:
1239 TCallback callback_;
1240 };
1241}
1242
1243/** Bidirectional mapping between util::Callback10 and a Python callable object
1244 *
1245 * Accepts Callable objects and wraps them in a util::Callback10 without checking the
1246 * parameter types or return type, allowing to call them from C++. The parameters
1247 * and return type are only checked when the function is called, and an exception will
1248 * be raised if the types do not match.
1249 *
1250 * From C++ to Python, the util::Callback10 is converted to a Callable object, so that
1251 * it can be called from Python. Again, the parameter types and return type will be
1252 * checked when the function is called.
1253 *
1254 * In both directions, unwrapping a previously wrapped function will be attempted.
1255 * I.e. if the util::Callback10 passed to Python already wraps a Callable Python
1256 * object, this will be unwrapped and the Callable object will be passed back to Python.
1257 * In the other direction, if a Callable object that was passed to C++ already wraps a
1258 * util::Callback10, *and* this util::Callback10 matches the correct signature, then
1259 * the util::Callback10 will be unwrapped and passed to C++. In other words, both
1260 * directions will guarantee a perfect round trip if possible. In all other cases, the
1261 * Callable or util::Callback10 will be wrapped in a new util::Callback10 or Callable
1262 * object.
1263 *
1264 * @ingroup PyExportTraits
1265 */
1266template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
1267struct PyExportTraits< util::Callback10<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >:
1269 util::Callback10<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
1270 impl::PyCallback10Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
1271 PyExportTraits< util::Callback10<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >
1272 >
1273{
1274 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!], None]";
1275
1276 static const char* className() { return "Callback10"; }
1277};
1278
1279}
1280}
1281
1282# endif
1283#endif
1284
1285#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_11)
1286# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_11
1287# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_11
1288
1289namespace lass
1290{
1291namespace python
1292{
1293namespace impl
1294{
1295 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
1296 class Functor11Python: public FunctorPythonBase
1297 {
1298 public:
1299 Functor11Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1300 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11) const
1301 {
1302 LockGIL lock;
1303 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11));
1304 }
1305 };
1306
1307 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
1308 class PyCallback11Impl: public PyCallbackImplBase
1309 {
1310 public:
1311 using TCallback = util::Callback11<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>;
1312 using TFunctor = Functor11Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>;
1313 using TDispatcher = util::impl::Dispatcher11Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, TFunctor>;
1314
1315 PyCallback11Impl(TCallback callback): callback_(std::move(callback)) {}
1316 const TCallback& callable() const { return callback_; }
1317
1318 PyObject* call(PyObject* args) const override
1319 {
1320 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1321 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1322 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1323 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1324 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1325 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1326 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1327 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1328 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1329 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1330 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
1331
1332 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) != 0 )
1333 {
1334 return nullptr;
1335 }
1336 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11));
1337 }
1338 private:
1339 TCallback callback_;
1340 };
1341}
1342
1343/** Bidirectional mapping between util::Callback11 and a Python callable object
1344 *
1345 * Accepts Callable objects and wraps them in a util::Callback11 without checking the
1346 * parameter types or return type, allowing to call them from C++. The parameters
1347 * and return type are only checked when the function is called, and an exception will
1348 * be raised if the types do not match.
1349 *
1350 * From C++ to Python, the util::Callback11 is converted to a Callable object, so that
1351 * it can be called from Python. Again, the parameter types and return type will be
1352 * checked when the function is called.
1353 *
1354 * In both directions, unwrapping a previously wrapped function will be attempted.
1355 * I.e. if the util::Callback11 passed to Python already wraps a Callable Python
1356 * object, this will be unwrapped and the Callable object will be passed back to Python.
1357 * In the other direction, if a Callable object that was passed to C++ already wraps a
1358 * util::Callback11, *and* this util::Callback11 matches the correct signature, then
1359 * the util::Callback11 will be unwrapped and passed to C++. In other words, both
1360 * directions will guarantee a perfect round trip if possible. In all other cases, the
1361 * Callable or util::Callback11 will be wrapped in a new util::Callback11 or Callable
1362 * object.
1363 *
1364 * @ingroup PyExportTraits
1365 */
1366template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
1367struct PyExportTraits< util::Callback11<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >:
1369 util::Callback11<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
1370 impl::PyCallback11Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
1371 PyExportTraits< util::Callback11<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >
1372 >
1373{
1374 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!], None]";
1375
1376 static const char* className() { return "Callback11"; }
1377};
1378
1379}
1380}
1381
1382# endif
1383#endif
1384
1385#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_12)
1386# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_12
1387# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_12
1388
1389namespace lass
1390{
1391namespace python
1392{
1393namespace impl
1394{
1395 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
1396 class Functor12Python: public FunctorPythonBase
1397 {
1398 public:
1399 Functor12Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1400 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12) const
1401 {
1402 LockGIL lock;
1403 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12));
1404 }
1405 };
1406
1407 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
1408 class PyCallback12Impl: public PyCallbackImplBase
1409 {
1410 public:
1411 using TCallback = util::Callback12<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>;
1412 using TFunctor = Functor12Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>;
1413 using TDispatcher = util::impl::Dispatcher12Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, TFunctor>;
1414
1415 PyCallback12Impl(TCallback callback): callback_(std::move(callback)) {}
1416 const TCallback& callable() const { return callback_; }
1417
1418 PyObject* call(PyObject* args) const override
1419 {
1420 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1421 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1422 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1423 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1424 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1425 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1426 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1427 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1428 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1429 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1430 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
1431 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
1432
1433 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) != 0 )
1434 {
1435 return nullptr;
1436 }
1437 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12));
1438 }
1439 private:
1440 TCallback callback_;
1441 };
1442}
1443
1444/** Bidirectional mapping between util::Callback12 and a Python callable object
1445 *
1446 * Accepts Callable objects and wraps them in a util::Callback12 without checking the
1447 * parameter types or return type, allowing to call them from C++. The parameters
1448 * and return type are only checked when the function is called, and an exception will
1449 * be raised if the types do not match.
1450 *
1451 * From C++ to Python, the util::Callback12 is converted to a Callable object, so that
1452 * it can be called from Python. Again, the parameter types and return type will be
1453 * checked when the function is called.
1454 *
1455 * In both directions, unwrapping a previously wrapped function will be attempted.
1456 * I.e. if the util::Callback12 passed to Python already wraps a Callable Python
1457 * object, this will be unwrapped and the Callable object will be passed back to Python.
1458 * In the other direction, if a Callable object that was passed to C++ already wraps a
1459 * util::Callback12, *and* this util::Callback12 matches the correct signature, then
1460 * the util::Callback12 will be unwrapped and passed to C++. In other words, both
1461 * directions will guarantee a perfect round trip if possible. In all other cases, the
1462 * Callable or util::Callback12 will be wrapped in a new util::Callback12 or Callable
1463 * object.
1464 *
1465 * @ingroup PyExportTraits
1466 */
1467template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
1468struct PyExportTraits< util::Callback12<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >:
1470 util::Callback12<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
1471 impl::PyCallback12Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
1472 PyExportTraits< util::Callback12<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >
1473 >
1474{
1475 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!], None]";
1476
1477 static const char* className() { return "Callback12"; }
1478};
1479
1480}
1481}
1482
1483# endif
1484#endif
1485
1486#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_13)
1487# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_13
1488# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_13
1489
1490namespace lass
1491{
1492namespace python
1493{
1494namespace impl
1495{
1496 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
1497 class Functor13Python: public FunctorPythonBase
1498 {
1499 public:
1500 Functor13Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1501 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13) const
1502 {
1503 LockGIL lock;
1504 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13));
1505 }
1506 };
1507
1508 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
1509 class PyCallback13Impl: public PyCallbackImplBase
1510 {
1511 public:
1512 using TCallback = util::Callback13<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>;
1513 using TFunctor = Functor13Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>;
1514 using TDispatcher = util::impl::Dispatcher13Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, TFunctor>;
1515
1516 PyCallback13Impl(TCallback callback): callback_(std::move(callback)) {}
1517 const TCallback& callable() const { return callback_; }
1518
1519 PyObject* call(PyObject* args) const override
1520 {
1521 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1522 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1523 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1524 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1525 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1526 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1527 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1528 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1529 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1530 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1531 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
1532 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
1533 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
1534
1535 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) != 0 )
1536 {
1537 return nullptr;
1538 }
1539 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13));
1540 }
1541 private:
1542 TCallback callback_;
1543 };
1544}
1545
1546/** Bidirectional mapping between util::Callback13 and a Python callable object
1547 *
1548 * Accepts Callable objects and wraps them in a util::Callback13 without checking the
1549 * parameter types or return type, allowing to call them from C++. The parameters
1550 * and return type are only checked when the function is called, and an exception will
1551 * be raised if the types do not match.
1552 *
1553 * From C++ to Python, the util::Callback13 is converted to a Callable object, so that
1554 * it can be called from Python. Again, the parameter types and return type will be
1555 * checked when the function is called.
1556 *
1557 * In both directions, unwrapping a previously wrapped function will be attempted.
1558 * I.e. if the util::Callback13 passed to Python already wraps a Callable Python
1559 * object, this will be unwrapped and the Callable object will be passed back to Python.
1560 * In the other direction, if a Callable object that was passed to C++ already wraps a
1561 * util::Callback13, *and* this util::Callback13 matches the correct signature, then
1562 * the util::Callback13 will be unwrapped and passed to C++. In other words, both
1563 * directions will guarantee a perfect round trip if possible. In all other cases, the
1564 * Callable or util::Callback13 will be wrapped in a new util::Callback13 or Callable
1565 * object.
1566 *
1567 * @ingroup PyExportTraits
1568 */
1569template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
1570struct PyExportTraits< util::Callback13<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >:
1572 util::Callback13<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
1573 impl::PyCallback13Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
1574 PyExportTraits< util::Callback13<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >
1575 >
1576{
1577 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!], None]";
1578
1579 static const char* className() { return "Callback13"; }
1580};
1581
1582}
1583}
1584
1585# endif
1586#endif
1587
1588#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_14)
1589# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_14
1590# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_14
1591
1592namespace lass
1593{
1594namespace python
1595{
1596namespace impl
1597{
1598 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
1599 class Functor14Python: public FunctorPythonBase
1600 {
1601 public:
1602 Functor14Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1603 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13, typename util::CallTraits<P14>::TParam p14) const
1604 {
1605 LockGIL lock;
1606 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14));
1607 }
1608 };
1609
1610 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
1611 class PyCallback14Impl: public PyCallbackImplBase
1612 {
1613 public:
1614 using TCallback = util::Callback14<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>;
1615 using TFunctor = Functor14Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>;
1616 using TDispatcher = util::impl::Dispatcher14Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, TFunctor>;
1617
1618 PyCallback14Impl(TCallback callback): callback_(std::move(callback)) {}
1619 const TCallback& callable() const { return callback_; }
1620
1621 PyObject* call(PyObject* args) const override
1622 {
1623 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1624 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1625 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1626 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1627 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1628 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1629 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1630 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1631 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1632 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1633 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
1634 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
1635 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
1636 typedef ArgumentTraits<P14> TArg14; typedef typename TArg14::TStorage S14; S14 p14 = S14();
1637
1638 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) != 0 )
1639 {
1640 return nullptr;
1641 }
1642 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13), TArg14::arg(p14));
1643 }
1644 private:
1645 TCallback callback_;
1646 };
1647}
1648
1649/** Bidirectional mapping between util::Callback14 and a Python callable object
1650 *
1651 * Accepts Callable objects and wraps them in a util::Callback14 without checking the
1652 * parameter types or return type, allowing to call them from C++. The parameters
1653 * and return type are only checked when the function is called, and an exception will
1654 * be raised if the types do not match.
1655 *
1656 * From C++ to Python, the util::Callback14 is converted to a Callable object, so that
1657 * it can be called from Python. Again, the parameter types and return type will be
1658 * checked when the function is called.
1659 *
1660 * In both directions, unwrapping a previously wrapped function will be attempted.
1661 * I.e. if the util::Callback14 passed to Python already wraps a Callable Python
1662 * object, this will be unwrapped and the Callable object will be passed back to Python.
1663 * In the other direction, if a Callable object that was passed to C++ already wraps a
1664 * util::Callback14, *and* this util::Callback14 matches the correct signature, then
1665 * the util::Callback14 will be unwrapped and passed to C++. In other words, both
1666 * directions will guarantee a perfect round trip if possible. In all other cases, the
1667 * Callable or util::Callback14 will be wrapped in a new util::Callback14 or Callable
1668 * object.
1669 *
1670 * @ingroup PyExportTraits
1671 */
1672template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
1673struct PyExportTraits< util::Callback14<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >:
1675 util::Callback14<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>,
1676 impl::PyCallback14Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>,
1677 PyExportTraits< util::Callback14<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >
1678 >
1679{
1680 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!, P14!], None]";
1681
1682 static const char* className() { return "Callback14"; }
1683};
1684
1685}
1686}
1687
1688# endif
1689#endif
1690
1691#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_15)
1692# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_15
1693# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_15
1694
1695namespace lass
1696{
1697namespace python
1698{
1699namespace impl
1700{
1701 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
1702 class Functor15Python: public FunctorPythonBase
1703 {
1704 public:
1705 Functor15Python(const TPyObjPtr& callable): FunctorPythonBase(callable) {}
1706 void operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13, typename util::CallTraits<P14>::TParam p14, typename util::CallTraits<P15>::TParam p15) const
1707 {
1708 LockGIL lock;
1709 this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15));
1710 }
1711 };
1712
1713 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
1714 class PyCallback15Impl: public PyCallbackImplBase
1715 {
1716 public:
1717 using TCallback = util::Callback15<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>;
1718 using TFunctor = Functor15Python<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>;
1719 using TDispatcher = util::impl::Dispatcher15Function<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, TFunctor>;
1720
1721 PyCallback15Impl(TCallback callback): callback_(std::move(callback)) {}
1722 const TCallback& callable() const { return callback_; }
1723
1724 PyObject* call(PyObject* args) const override
1725 {
1726 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1727 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
1728 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
1729 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
1730 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
1731 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
1732 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
1733 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
1734 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
1735 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
1736 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
1737 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
1738 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
1739 typedef ArgumentTraits<P14> TArg14; typedef typename TArg14::TStorage S14; S14 p14 = S14();
1740 typedef ArgumentTraits<P15> TArg15; typedef typename TArg15::TStorage S15; S15 p15 = S15();
1741
1742 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) != 0 )
1743 {
1744 return nullptr;
1745 }
1746 return Caller<void>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13), TArg14::arg(p14), TArg15::arg(p15));
1747 }
1748 private:
1749 TCallback callback_;
1750 };
1751}
1752
1753/** Bidirectional mapping between util::Callback15 and a Python callable object
1754 *
1755 * Accepts Callable objects and wraps them in a util::Callback15 without checking the
1756 * parameter types or return type, allowing to call them from C++. The parameters
1757 * and return type are only checked when the function is called, and an exception will
1758 * be raised if the types do not match.
1759 *
1760 * From C++ to Python, the util::Callback15 is converted to a Callable object, so that
1761 * it can be called from Python. Again, the parameter types and return type will be
1762 * checked when the function is called.
1763 *
1764 * In both directions, unwrapping a previously wrapped function will be attempted.
1765 * I.e. if the util::Callback15 passed to Python already wraps a Callable Python
1766 * object, this will be unwrapped and the Callable object will be passed back to Python.
1767 * In the other direction, if a Callable object that was passed to C++ already wraps a
1768 * util::Callback15, *and* this util::Callback15 matches the correct signature, then
1769 * the util::Callback15 will be unwrapped and passed to C++. In other words, both
1770 * directions will guarantee a perfect round trip if possible. In all other cases, the
1771 * Callable or util::Callback15 will be wrapped in a new util::Callback15 or Callable
1772 * object.
1773 *
1774 * @ingroup PyExportTraits
1775 */
1776template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
1777struct PyExportTraits< util::Callback15<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >:
1779 util::Callback15<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>,
1780 impl::PyCallback15Impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>,
1781 PyExportTraits< util::Callback15<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >
1782 >
1783{
1784 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!, P14!, P15!], None]";
1785
1786 static const char* className() { return "Callback15"; }
1787};
1788
1789}
1790}
1791
1792# endif
1793#endif
1794
1795
1796
1797
1798
1799#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R0)
1800# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R0
1801# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R0
1802
1803namespace lass
1804{
1805namespace python
1806{
1807namespace impl
1808{
1809 template <typename R>
1810 class FunctorPythonR0: public FunctorPythonRBase<R>
1811 {
1812 public:
1813 FunctorPythonR0(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
1814 R operator()() const
1815 {
1816 LockGIL lock;
1817 return this->call(TPyObjPtr());
1818 }
1819 };
1820
1821 template <typename R>
1822 class PyCallbackR0Impl: public PyCallbackImplBase
1823 {
1824 public:
1825 using TCallback = util::CallbackR0<R>;
1826 using TFunctor = FunctorPythonR0<R>;
1827 using TDispatcher = util::impl::DispatcherR0Function<R, TFunctor>;
1828
1829 PyCallbackR0Impl(TCallback callback): callback_(std::move(callback)) {}
1830 const TCallback& callable() const { return callback_; }
1831
1832 PyObject* call(PyObject* args) const override
1833 {
1834 if ( decodeTuple(args) != 0 )
1835 {
1836 return nullptr;
1837 }
1838 return Caller<R>::template callFunction<const TCallback&>(callback_);
1839 }
1840 private:
1841 TCallback callback_;
1842 };
1843}
1844
1845/** Bidirectional mapping between util::CallbackR0 and a Python callable object
1846 *
1847 * Accepts Callable objects and wraps them in a util::CallbackR0 without checking the
1848 * parameter types or return type, allowing to call them from C++. The parameters
1849 * and return type are only checked when the function is called, and an exception will
1850 * be raised if the types do not match.
1851 *
1852 * From C++ to Python, the util::CallbackR0 is converted to a Callable object, so that
1853 * it can be called from Python. Again, the parameter types and return type will be
1854 * checked when the function is called.
1855 *
1856 * In both directions, unwrapping a previously wrapped function will be attempted.
1857 * I.e. if the util::CallbackR0 passed to Python already wraps a Callable Python
1858 * object, this will be unwrapped and the Callable object will be passed back to Python.
1859 * In the other direction, if a Callable object that was passed to C++ already wraps a
1860 * util::CallbackR0, *and* this util::CallbackR0 matches the correct signature, then
1861 * the util::CallbackR0 will be unwrapped and passed to C++. In other words, both
1862 * directions will guarantee a perfect round trip if possible. In all other cases, the
1863 * Callable or util::CallbackR0 will be wrapped in a new util::CallbackR0 or Callable
1864 * object.
1865 *
1866 * @ingroup PyExportTraits
1867 */
1868template <typename R>
1869struct PyExportTraits< util::CallbackR0<R> >:
1871 util::CallbackR0<R>,
1872 impl::PyCallbackR0Impl<R>,
1873 PyExportTraits< util::CallbackR0<R> >
1874 >
1875{
1876 static constexpr const char* py_typing = "Callable[[], R!]";
1877
1878 static const char* className() { return "CallbackR0"; }
1879};
1880
1881}
1882}
1883
1884# endif
1885#endif
1886
1887#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R1)
1888# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R1
1889# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R1
1890
1891namespace lass
1892{
1893namespace python
1894{
1895namespace impl
1896{
1897 template <typename R, typename P1>
1898 class FunctorPythonR1: public FunctorPythonRBase<R>
1899 {
1900 public:
1901 FunctorPythonR1(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
1902 R operator()(typename util::CallTraits<P1>::TParam p1) const
1903 {
1904 LockGIL lock;
1905 return this->call(makeTuple(p1));
1906 }
1907 };
1908
1909 template <typename R, typename P1>
1910 class PyCallbackR1Impl: public PyCallbackImplBase
1911 {
1912 public:
1913 using TCallback = util::CallbackR1<R, P1>;
1914 using TFunctor = FunctorPythonR1<R, P1>;
1915 using TDispatcher = util::impl::DispatcherR1Function<R, P1, TFunctor>;
1916
1917 PyCallbackR1Impl(TCallback callback): callback_(std::move(callback)) {}
1918 const TCallback& callable() const { return callback_; }
1919
1920 PyObject* call(PyObject* args) const override
1921 {
1922 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
1923
1924 if ( decodeTuple<S1>(args, p1) != 0 )
1925 {
1926 return nullptr;
1927 }
1928 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1));
1929 }
1930 private:
1931 TCallback callback_;
1932 };
1933
1934}
1935
1936/** Bidirectional mapping between util::CallbackR1 and a Python callable object
1937 *
1938 * Accepts Callable objects and wraps them in a util::CallbackR1 without checking the
1939 * parameter types or return type, allowing to call them from C++. The parameters
1940 * and return type are only checked when the function is called, and an exception will
1941 * be raised if the types do not match.
1942 *
1943 * From C++ to Python, the util::CallbackR1 is converted to a Callable object, so that
1944 * it can be called from Python. Again, the parameter types and return type will be
1945 * checked when the function is called.
1946 *
1947 * In both directions, unwrapping a previously wrapped function will be attempted.
1948 * I.e. if the util::CallbackR1 passed to Python already wraps a Callable Python
1949 * object, this will be unwrapped and the Callable object will be passed back to Python.
1950 * In the other direction, if a Callable object that was passed to C++ already wraps a
1951 * util::CallbackR1, *and* this util::CallbackR1 matches the correct signature, then
1952 * the util::CallbackR1 will be unwrapped and passed to C++. In other words, both
1953 * directions will guarantee a perfect round trip if possible. In all other cases, the
1954 * Callable or util::CallbackR1 will be wrapped in a new util::CallbackR1 or Callable
1955 * object.
1956 *
1957 * @ingroup PyExportTraits
1958 */
1959template <typename R, typename P1>
1960struct PyExportTraits< util::CallbackR1<R, P1> >:
1962 util::CallbackR1<R, P1>,
1963 impl::PyCallbackR1Impl<R, P1>,
1964 PyExportTraits< util::CallbackR1<R, P1> >
1965 >
1966{
1967 static constexpr const char* py_typing = "Callable[[P1!], R!]";
1968
1969 static const char* className() { return "CallbackR1"; }
1970};
1971
1972}
1973}
1974
1975# endif
1976#endif
1977
1978#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R2)
1979# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R2
1980# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R2
1981
1982namespace lass
1983{
1984namespace python
1985{
1986namespace impl
1987{
1988 template <typename R, typename P1, typename P2>
1989 class FunctorPythonR2: public FunctorPythonRBase<R>
1990 {
1991 public:
1992 FunctorPythonR2(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
1993 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2) const
1994 {
1995 LockGIL lock;
1996 return this->call(makeTuple(p1, p2));
1997 }
1998 };
1999
2000 template <typename R, typename P1, typename P2>
2001 class PyCallbackR2Impl: public PyCallbackImplBase
2002 {
2003 public:
2004 using TCallback = util::CallbackR2<R, P1, P2>;
2005 using TFunctor = FunctorPythonR2<R, P1, P2>;
2006 using TDispatcher = util::impl::DispatcherR2Function<R, P1, P2, TFunctor>;
2007
2008 PyCallbackR2Impl(TCallback callback): callback_(std::move(callback)) {}
2009 const TCallback& callable() const { return callback_; }
2010
2011 PyObject* call(PyObject* args) const override
2012 {
2013 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2014 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2015
2016 if ( decodeTuple<S1, S2>(args, p1, p2) != 0 )
2017 {
2018 return nullptr;
2019 }
2020 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2));
2021 }
2022 private:
2023 TCallback callback_;
2024 };
2025
2026}
2027
2028/** Bidirectional mapping between util::CallbackR2 and a Python callable object
2029 *
2030 * Accepts Callable objects and wraps them in a util::CallbackR2 without checking the
2031 * parameter types or return type, allowing to call them from C++. The parameters
2032 * and return type are only checked when the function is called, and an exception will
2033 * be raised if the types do not match.
2034 *
2035 * From C++ to Python, the util::CallbackR2 is converted to a Callable object, so that
2036 * it can be called from Python. Again, the parameter types and return type will be
2037 * checked when the function is called.
2038 *
2039 * In both directions, unwrapping a previously wrapped function will be attempted.
2040 * I.e. if the util::CallbackR2 passed to Python already wraps a Callable Python
2041 * object, this will be unwrapped and the Callable object will be passed back to Python.
2042 * In the other direction, if a Callable object that was passed to C++ already wraps a
2043 * util::CallbackR2, *and* this util::CallbackR2 matches the correct signature, then
2044 * the util::CallbackR2 will be unwrapped and passed to C++. In other words, both
2045 * directions will guarantee a perfect round trip if possible. In all other cases, the
2046 * Callable or util::CallbackR2 will be wrapped in a new util::CallbackR2 or Callable
2047 * object.
2048 *
2049 * @ingroup PyExportTraits
2050 */
2051template <typename R, typename P1, typename P2>
2052struct PyExportTraits< util::CallbackR2<R, P1, P2> >:
2054 util::CallbackR2<R, P1, P2>,
2055 impl::PyCallbackR2Impl<R, P1, P2>,
2056 PyExportTraits< util::CallbackR2<R, P1, P2> >
2057 >
2058{
2059 static constexpr const char* py_typing = "Callable[[P1!, P2!], R!]";
2060
2061 static const char* className() { return "CallbackR2"; }
2062};
2063
2064}
2065}
2066
2067# endif
2068#endif
2069
2070#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R3)
2071# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R3
2072# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R3
2073
2074namespace lass
2075{
2076namespace python
2077{
2078namespace impl
2079{
2080 template <typename R, typename P1, typename P2, typename P3>
2081 class FunctorPythonR3: public FunctorPythonRBase<R>
2082 {
2083 public:
2084 FunctorPythonR3(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2085 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3) const
2086 {
2087 LockGIL lock;
2088 return this->call(makeTuple(p1, p2, p3));
2089 }
2090 };
2091
2092 template <typename R, typename P1, typename P2, typename P3>
2093 class PyCallbackR3Impl: public PyCallbackImplBase
2094 {
2095 public:
2096 using TCallback = util::CallbackR3<R, P1, P2, P3>;
2097 using TFunctor = FunctorPythonR3<R, P1, P2, P3>;
2098 using TDispatcher = util::impl::DispatcherR3Function<R, P1, P2, P3, TFunctor>;
2099
2100 PyCallbackR3Impl(TCallback callback): callback_(std::move(callback)) {}
2101 const TCallback& callable() const { return callback_; }
2102
2103 PyObject* call(PyObject* args) const override
2104 {
2105 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2106 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2107 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2108
2109 if ( decodeTuple<S1, S2, S3>(args, p1, p2, p3) != 0 )
2110 {
2111 return nullptr;
2112 }
2113 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3));
2114 }
2115 private:
2116 TCallback callback_;
2117 };
2118
2119}
2120
2121/** Bidirectional mapping between util::CallbackR3 and a Python callable object
2122 *
2123 * Accepts Callable objects and wraps them in a util::CallbackR3 without checking the
2124 * parameter types or return type, allowing to call them from C++. The parameters
2125 * and return type are only checked when the function is called, and an exception will
2126 * be raised if the types do not match.
2127 *
2128 * From C++ to Python, the util::CallbackR3 is converted to a Callable object, so that
2129 * it can be called from Python. Again, the parameter types and return type will be
2130 * checked when the function is called.
2131 *
2132 * In both directions, unwrapping a previously wrapped function will be attempted.
2133 * I.e. if the util::CallbackR3 passed to Python already wraps a Callable Python
2134 * object, this will be unwrapped and the Callable object will be passed back to Python.
2135 * In the other direction, if a Callable object that was passed to C++ already wraps a
2136 * util::CallbackR3, *and* this util::CallbackR3 matches the correct signature, then
2137 * the util::CallbackR3 will be unwrapped and passed to C++. In other words, both
2138 * directions will guarantee a perfect round trip if possible. In all other cases, the
2139 * Callable or util::CallbackR3 will be wrapped in a new util::CallbackR3 or Callable
2140 * object.
2141 *
2142 * @ingroup PyExportTraits
2143 */
2144template <typename R, typename P1, typename P2, typename P3>
2145struct PyExportTraits< util::CallbackR3<R, P1, P2, P3> >:
2147 util::CallbackR3<R, P1, P2, P3>,
2148 impl::PyCallbackR3Impl<R, P1, P2, P3>,
2149 PyExportTraits< util::CallbackR3<R, P1, P2, P3> >
2150 >
2151{
2152 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!], R!]";
2153
2154 static const char* className() { return "CallbackR3"; }
2155};
2156
2157}
2158}
2159
2160# endif
2161#endif
2162
2163#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R4)
2164# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R4
2165# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R4
2166
2167namespace lass
2168{
2169namespace python
2170{
2171namespace impl
2172{
2173 template <typename R, typename P1, typename P2, typename P3, typename P4>
2174 class FunctorPythonR4: public FunctorPythonRBase<R>
2175 {
2176 public:
2177 FunctorPythonR4(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2178 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4) const
2179 {
2180 LockGIL lock;
2181 return this->call(makeTuple(p1, p2, p3, p4));
2182 }
2183 };
2184
2185 template <typename R, typename P1, typename P2, typename P3, typename P4>
2186 class PyCallbackR4Impl: public PyCallbackImplBase
2187 {
2188 public:
2189 using TCallback = util::CallbackR4<R, P1, P2, P3, P4>;
2190 using TFunctor = FunctorPythonR4<R, P1, P2, P3, P4>;
2191 using TDispatcher = util::impl::DispatcherR4Function<R, P1, P2, P3, P4, TFunctor>;
2192
2193 PyCallbackR4Impl(TCallback callback): callback_(std::move(callback)) {}
2194 const TCallback& callable() const { return callback_; }
2195
2196 PyObject* call(PyObject* args) const override
2197 {
2198 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2199 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2200 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2201 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2202
2203 if ( decodeTuple<S1, S2, S3, S4>(args, p1, p2, p3, p4) != 0 )
2204 {
2205 return nullptr;
2206 }
2207 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4));
2208 }
2209 private:
2210 TCallback callback_;
2211 };
2212
2213}
2214
2215/** Bidirectional mapping between util::CallbackR4 and a Python callable object
2216 *
2217 * Accepts Callable objects and wraps them in a util::CallbackR4 without checking the
2218 * parameter types or return type, allowing to call them from C++. The parameters
2219 * and return type are only checked when the function is called, and an exception will
2220 * be raised if the types do not match.
2221 *
2222 * From C++ to Python, the util::CallbackR4 is converted to a Callable object, so that
2223 * it can be called from Python. Again, the parameter types and return type will be
2224 * checked when the function is called.
2225 *
2226 * In both directions, unwrapping a previously wrapped function will be attempted.
2227 * I.e. if the util::CallbackR4 passed to Python already wraps a Callable Python
2228 * object, this will be unwrapped and the Callable object will be passed back to Python.
2229 * In the other direction, if a Callable object that was passed to C++ already wraps a
2230 * util::CallbackR4, *and* this util::CallbackR4 matches the correct signature, then
2231 * the util::CallbackR4 will be unwrapped and passed to C++. In other words, both
2232 * directions will guarantee a perfect round trip if possible. In all other cases, the
2233 * Callable or util::CallbackR4 will be wrapped in a new util::CallbackR4 or Callable
2234 * object.
2235 *
2236 * @ingroup PyExportTraits
2237 */
2238template <typename R, typename P1, typename P2, typename P3, typename P4>
2239struct PyExportTraits< util::CallbackR4<R, P1, P2, P3, P4> >:
2241 util::CallbackR4<R, P1, P2, P3, P4>,
2242 impl::PyCallbackR4Impl<R, P1, P2, P3, P4>,
2243 PyExportTraits< util::CallbackR4<R, P1, P2, P3, P4> >
2244 >
2245{
2246 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!], R!]";
2247
2248 static const char* className() { return "CallbackR4"; }
2249};
2250
2251}
2252}
2253
2254# endif
2255#endif
2256
2257#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R5)
2258# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R5
2259# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R5
2260
2261namespace lass
2262{
2263namespace python
2264{
2265namespace impl
2266{
2267 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
2268 class FunctorPythonR5: public FunctorPythonRBase<R>
2269 {
2270 public:
2271 FunctorPythonR5(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2272 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5) const
2273 {
2274 LockGIL lock;
2275 return this->call(makeTuple(p1, p2, p3, p4, p5));
2276 }
2277 };
2278
2279 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
2280 class PyCallbackR5Impl: public PyCallbackImplBase
2281 {
2282 public:
2283 using TCallback = util::CallbackR5<R, P1, P2, P3, P4, P5>;
2284 using TFunctor = FunctorPythonR5<R, P1, P2, P3, P4, P5>;
2285 using TDispatcher = util::impl::DispatcherR5Function<R, P1, P2, P3, P4, P5, TFunctor>;
2286
2287 PyCallbackR5Impl(TCallback callback): callback_(std::move(callback)) {}
2288 const TCallback& callable() const { return callback_; }
2289
2290 PyObject* call(PyObject* args) const override
2291 {
2292 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2293 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2294 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2295 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2296 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2297
2298 if ( decodeTuple<S1, S2, S3, S4, S5>(args, p1, p2, p3, p4, p5) != 0 )
2299 {
2300 return nullptr;
2301 }
2302 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5));
2303 }
2304 private:
2305 TCallback callback_;
2306 };
2307
2308}
2309
2310/** Bidirectional mapping between util::CallbackR5 and a Python callable object
2311 *
2312 * Accepts Callable objects and wraps them in a util::CallbackR5 without checking the
2313 * parameter types or return type, allowing to call them from C++. The parameters
2314 * and return type are only checked when the function is called, and an exception will
2315 * be raised if the types do not match.
2316 *
2317 * From C++ to Python, the util::CallbackR5 is converted to a Callable object, so that
2318 * it can be called from Python. Again, the parameter types and return type will be
2319 * checked when the function is called.
2320 *
2321 * In both directions, unwrapping a previously wrapped function will be attempted.
2322 * I.e. if the util::CallbackR5 passed to Python already wraps a Callable Python
2323 * object, this will be unwrapped and the Callable object will be passed back to Python.
2324 * In the other direction, if a Callable object that was passed to C++ already wraps a
2325 * util::CallbackR5, *and* this util::CallbackR5 matches the correct signature, then
2326 * the util::CallbackR5 will be unwrapped and passed to C++. In other words, both
2327 * directions will guarantee a perfect round trip if possible. In all other cases, the
2328 * Callable or util::CallbackR5 will be wrapped in a new util::CallbackR5 or Callable
2329 * object.
2330 *
2331 * @ingroup PyExportTraits
2332 */
2333template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
2334struct PyExportTraits< util::CallbackR5<R, P1, P2, P3, P4, P5> >:
2336 util::CallbackR5<R, P1, P2, P3, P4, P5>,
2337 impl::PyCallbackR5Impl<R, P1, P2, P3, P4, P5>,
2338 PyExportTraits< util::CallbackR5<R, P1, P2, P3, P4, P5> >
2339 >
2340{
2341 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!], R!]";
2342
2343 static const char* className() { return "CallbackR5"; }
2344};
2345
2346}
2347}
2348
2349# endif
2350#endif
2351
2352#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R6)
2353# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R6
2354# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R6
2355
2356namespace lass
2357{
2358namespace python
2359{
2360namespace impl
2361{
2362 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
2363 class FunctorPythonR6: public FunctorPythonRBase<R>
2364 {
2365 public:
2366 FunctorPythonR6(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2367 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6) const
2368 {
2369 LockGIL lock;
2370 return this->call(makeTuple(p1, p2, p3, p4, p5, p6));
2371 }
2372 };
2373
2374 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
2375 class PyCallbackR6Impl: public PyCallbackImplBase
2376 {
2377 public:
2378 using TCallback = util::CallbackR6<R, P1, P2, P3, P4, P5, P6>;
2379 using TFunctor = FunctorPythonR6<R, P1, P2, P3, P4, P5, P6>;
2380 using TDispatcher = util::impl::DispatcherR6Function<R, P1, P2, P3, P4, P5, P6, TFunctor>;
2381
2382 PyCallbackR6Impl(TCallback callback): callback_(std::move(callback)) {}
2383 const TCallback& callable() const { return callback_; }
2384
2385 PyObject* call(PyObject* args) const override
2386 {
2387 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2388 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2389 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2390 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2391 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2392 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2393
2394 if ( decodeTuple<S1, S2, S3, S4, S5, S6>(args, p1, p2, p3, p4, p5, p6) != 0 )
2395 {
2396 return nullptr;
2397 }
2398 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6));
2399 }
2400 private:
2401 TCallback callback_;
2402 };
2403
2404}
2405
2406/** Bidirectional mapping between util::CallbackR6 and a Python callable object
2407 *
2408 * Accepts Callable objects and wraps them in a util::CallbackR6 without checking the
2409 * parameter types or return type, allowing to call them from C++. The parameters
2410 * and return type are only checked when the function is called, and an exception will
2411 * be raised if the types do not match.
2412 *
2413 * From C++ to Python, the util::CallbackR6 is converted to a Callable object, so that
2414 * it can be called from Python. Again, the parameter types and return type will be
2415 * checked when the function is called.
2416 *
2417 * In both directions, unwrapping a previously wrapped function will be attempted.
2418 * I.e. if the util::CallbackR6 passed to Python already wraps a Callable Python
2419 * object, this will be unwrapped and the Callable object will be passed back to Python.
2420 * In the other direction, if a Callable object that was passed to C++ already wraps a
2421 * util::CallbackR6, *and* this util::CallbackR6 matches the correct signature, then
2422 * the util::CallbackR6 will be unwrapped and passed to C++. In other words, both
2423 * directions will guarantee a perfect round trip if possible. In all other cases, the
2424 * Callable or util::CallbackR6 will be wrapped in a new util::CallbackR6 or Callable
2425 * object.
2426 *
2427 * @ingroup PyExportTraits
2428 */
2429template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
2430struct PyExportTraits< util::CallbackR6<R, P1, P2, P3, P4, P5, P6> >:
2432 util::CallbackR6<R, P1, P2, P3, P4, P5, P6>,
2433 impl::PyCallbackR6Impl<R, P1, P2, P3, P4, P5, P6>,
2434 PyExportTraits< util::CallbackR6<R, P1, P2, P3, P4, P5, P6> >
2435 >
2436{
2437 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!], R!]";
2438
2439 static const char* className() { return "CallbackR6"; }
2440};
2441
2442}
2443}
2444
2445# endif
2446#endif
2447
2448#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R7)
2449# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R7
2450# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R7
2451
2452namespace lass
2453{
2454namespace python
2455{
2456namespace impl
2457{
2458 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
2459 class FunctorPythonR7: public FunctorPythonRBase<R>
2460 {
2461 public:
2462 FunctorPythonR7(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2463 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7) const
2464 {
2465 LockGIL lock;
2466 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7));
2467 }
2468 };
2469
2470 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
2471 class PyCallbackR7Impl: public PyCallbackImplBase
2472 {
2473 public:
2474 using TCallback = util::CallbackR7<R, P1, P2, P3, P4, P5, P6, P7>;
2475 using TFunctor = FunctorPythonR7<R, P1, P2, P3, P4, P5, P6, P7>;
2476 using TDispatcher = util::impl::DispatcherR7Function<R, P1, P2, P3, P4, P5, P6, P7, TFunctor>;
2477
2478 PyCallbackR7Impl(TCallback callback): callback_(std::move(callback)) {}
2479 const TCallback& callable() const { return callback_; }
2480
2481 PyObject* call(PyObject* args) const override
2482 {
2483 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2484 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2485 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2486 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2487 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2488 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2489 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2490
2491 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7>(args, p1, p2, p3, p4, p5, p6, p7) != 0 )
2492 {
2493 return nullptr;
2494 }
2495 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7));
2496 }
2497 private:
2498 TCallback callback_;
2499 };
2500
2501}
2502
2503/** Bidirectional mapping between util::CallbackR7 and a Python callable object
2504 *
2505 * Accepts Callable objects and wraps them in a util::CallbackR7 without checking the
2506 * parameter types or return type, allowing to call them from C++. The parameters
2507 * and return type are only checked when the function is called, and an exception will
2508 * be raised if the types do not match.
2509 *
2510 * From C++ to Python, the util::CallbackR7 is converted to a Callable object, so that
2511 * it can be called from Python. Again, the parameter types and return type will be
2512 * checked when the function is called.
2513 *
2514 * In both directions, unwrapping a previously wrapped function will be attempted.
2515 * I.e. if the util::CallbackR7 passed to Python already wraps a Callable Python
2516 * object, this will be unwrapped and the Callable object will be passed back to Python.
2517 * In the other direction, if a Callable object that was passed to C++ already wraps a
2518 * util::CallbackR7, *and* this util::CallbackR7 matches the correct signature, then
2519 * the util::CallbackR7 will be unwrapped and passed to C++. In other words, both
2520 * directions will guarantee a perfect round trip if possible. In all other cases, the
2521 * Callable or util::CallbackR7 will be wrapped in a new util::CallbackR7 or Callable
2522 * object.
2523 *
2524 * @ingroup PyExportTraits
2525 */
2526template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
2527struct PyExportTraits< util::CallbackR7<R, P1, P2, P3, P4, P5, P6, P7> >:
2529 util::CallbackR7<R, P1, P2, P3, P4, P5, P6, P7>,
2530 impl::PyCallbackR7Impl<R, P1, P2, P3, P4, P5, P6, P7>,
2531 PyExportTraits< util::CallbackR7<R, P1, P2, P3, P4, P5, P6, P7> >
2532 >
2533{
2534 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!], R!]";
2535
2536 static const char* className() { return "CallbackR7"; }
2537};
2538
2539}
2540}
2541
2542# endif
2543#endif
2544
2545#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R8)
2546# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R8
2547# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R8
2548
2549namespace lass
2550{
2551namespace python
2552{
2553namespace impl
2554{
2555 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
2556 class FunctorPythonR8: public FunctorPythonRBase<R>
2557 {
2558 public:
2559 FunctorPythonR8(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2560 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8) const
2561 {
2562 LockGIL lock;
2563 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8));
2564 }
2565 };
2566
2567 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
2568 class PyCallbackR8Impl: public PyCallbackImplBase
2569 {
2570 public:
2571 using TCallback = util::CallbackR8<R, P1, P2, P3, P4, P5, P6, P7, P8>;
2572 using TFunctor = FunctorPythonR8<R, P1, P2, P3, P4, P5, P6, P7, P8>;
2573 using TDispatcher = util::impl::DispatcherR8Function<R, P1, P2, P3, P4, P5, P6, P7, P8, TFunctor>;
2574
2575 PyCallbackR8Impl(TCallback callback): callback_(std::move(callback)) {}
2576 const TCallback& callable() const { return callback_; }
2577
2578 PyObject* call(PyObject* args) const override
2579 {
2580 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2581 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2582 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2583 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2584 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2585 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2586 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2587 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
2588
2589 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8>(args, p1, p2, p3, p4, p5, p6, p7, p8) != 0 )
2590 {
2591 return nullptr;
2592 }
2593 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8));
2594 }
2595 private:
2596 TCallback callback_;
2597 };
2598
2599}
2600
2601/** Bidirectional mapping between util::CallbackR8 and a Python callable object
2602 *
2603 * Accepts Callable objects and wraps them in a util::CallbackR8 without checking the
2604 * parameter types or return type, allowing to call them from C++. The parameters
2605 * and return type are only checked when the function is called, and an exception will
2606 * be raised if the types do not match.
2607 *
2608 * From C++ to Python, the util::CallbackR8 is converted to a Callable object, so that
2609 * it can be called from Python. Again, the parameter types and return type will be
2610 * checked when the function is called.
2611 *
2612 * In both directions, unwrapping a previously wrapped function will be attempted.
2613 * I.e. if the util::CallbackR8 passed to Python already wraps a Callable Python
2614 * object, this will be unwrapped and the Callable object will be passed back to Python.
2615 * In the other direction, if a Callable object that was passed to C++ already wraps a
2616 * util::CallbackR8, *and* this util::CallbackR8 matches the correct signature, then
2617 * the util::CallbackR8 will be unwrapped and passed to C++. In other words, both
2618 * directions will guarantee a perfect round trip if possible. In all other cases, the
2619 * Callable or util::CallbackR8 will be wrapped in a new util::CallbackR8 or Callable
2620 * object.
2621 *
2622 * @ingroup PyExportTraits
2623 */
2624template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
2625struct PyExportTraits< util::CallbackR8<R, P1, P2, P3, P4, P5, P6, P7, P8> >:
2627 util::CallbackR8<R, P1, P2, P3, P4, P5, P6, P7, P8>,
2628 impl::PyCallbackR8Impl<R, P1, P2, P3, P4, P5, P6, P7, P8>,
2629 PyExportTraits< util::CallbackR8<R, P1, P2, P3, P4, P5, P6, P7, P8> >
2630 >
2631{
2632 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!], R!]";
2633
2634 static const char* className() { return "CallbackR8"; }
2635};
2636
2637}
2638}
2639
2640# endif
2641#endif
2642
2643#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R9)
2644# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R9
2645# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R9
2646
2647namespace lass
2648{
2649namespace python
2650{
2651namespace impl
2652{
2653 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
2654 class FunctorPythonR9: public FunctorPythonRBase<R>
2655 {
2656 public:
2657 FunctorPythonR9(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2658 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9) const
2659 {
2660 LockGIL lock;
2661 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9));
2662 }
2663 };
2664
2665 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
2666 class PyCallbackR9Impl: public PyCallbackImplBase
2667 {
2668 public:
2669 using TCallback = util::CallbackR9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9>;
2670 using TFunctor = FunctorPythonR9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9>;
2671 using TDispatcher = util::impl::DispatcherR9Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, TFunctor>;
2672
2673 PyCallbackR9Impl(TCallback callback): callback_(std::move(callback)) {}
2674 const TCallback& callable() const { return callback_; }
2675
2676 PyObject* call(PyObject* args) const override
2677 {
2678 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2679 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2680 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2681 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2682 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2683 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2684 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2685 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
2686 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
2687
2688 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9) != 0 )
2689 {
2690 return nullptr;
2691 }
2692 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9));
2693 }
2694 private:
2695 TCallback callback_;
2696 };
2697
2698}
2699
2700/** Bidirectional mapping between util::CallbackR9 and a Python callable object
2701 *
2702 * Accepts Callable objects and wraps them in a util::CallbackR9 without checking the
2703 * parameter types or return type, allowing to call them from C++. The parameters
2704 * and return type are only checked when the function is called, and an exception will
2705 * be raised if the types do not match.
2706 *
2707 * From C++ to Python, the util::CallbackR9 is converted to a Callable object, so that
2708 * it can be called from Python. Again, the parameter types and return type will be
2709 * checked when the function is called.
2710 *
2711 * In both directions, unwrapping a previously wrapped function will be attempted.
2712 * I.e. if the util::CallbackR9 passed to Python already wraps a Callable Python
2713 * object, this will be unwrapped and the Callable object will be passed back to Python.
2714 * In the other direction, if a Callable object that was passed to C++ already wraps a
2715 * util::CallbackR9, *and* this util::CallbackR9 matches the correct signature, then
2716 * the util::CallbackR9 will be unwrapped and passed to C++. In other words, both
2717 * directions will guarantee a perfect round trip if possible. In all other cases, the
2718 * Callable or util::CallbackR9 will be wrapped in a new util::CallbackR9 or Callable
2719 * object.
2720 *
2721 * @ingroup PyExportTraits
2722 */
2723template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
2724struct PyExportTraits< util::CallbackR9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >:
2726 util::CallbackR9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9>,
2727 impl::PyCallbackR9Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9>,
2728 PyExportTraits< util::CallbackR9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >
2729 >
2730{
2731 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!], R!]";
2732
2733 static const char* className() { return "CallbackR9"; }
2734};
2735
2736}
2737}
2738
2739# endif
2740#endif
2741
2742#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R10)
2743# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R10
2744# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R10
2745
2746namespace lass
2747{
2748namespace python
2749{
2750namespace impl
2751{
2752 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
2753 class FunctorPythonR10: public FunctorPythonRBase<R>
2754 {
2755 public:
2756 FunctorPythonR10(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2757 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10) const
2758 {
2759 LockGIL lock;
2760 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10));
2761 }
2762 };
2763
2764 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
2765 class PyCallbackR10Impl: public PyCallbackImplBase
2766 {
2767 public:
2768 using TCallback = util::CallbackR10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>;
2769 using TFunctor = FunctorPythonR10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>;
2770 using TDispatcher = util::impl::DispatcherR10Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, TFunctor>;
2771
2772 PyCallbackR10Impl(TCallback callback): callback_(std::move(callback)) {}
2773 const TCallback& callable() const { return callback_; }
2774
2775 PyObject* call(PyObject* args) const override
2776 {
2777 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2778 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2779 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2780 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2781 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2782 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2783 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2784 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
2785 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
2786 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
2787
2788 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) != 0 )
2789 {
2790 return nullptr;
2791 }
2792 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10));
2793 }
2794 private:
2795 TCallback callback_;
2796 };
2797
2798}
2799
2800/** Bidirectional mapping between util::CallbackR10 and a Python callable object
2801 *
2802 * Accepts Callable objects and wraps them in a util::CallbackR10 without checking the
2803 * parameter types or return type, allowing to call them from C++. The parameters
2804 * and return type are only checked when the function is called, and an exception will
2805 * be raised if the types do not match.
2806 *
2807 * From C++ to Python, the util::CallbackR10 is converted to a Callable object, so that
2808 * it can be called from Python. Again, the parameter types and return type will be
2809 * checked when the function is called.
2810 *
2811 * In both directions, unwrapping a previously wrapped function will be attempted.
2812 * I.e. if the util::CallbackR10 passed to Python already wraps a Callable Python
2813 * object, this will be unwrapped and the Callable object will be passed back to Python.
2814 * In the other direction, if a Callable object that was passed to C++ already wraps a
2815 * util::CallbackR10, *and* this util::CallbackR10 matches the correct signature, then
2816 * the util::CallbackR10 will be unwrapped and passed to C++. In other words, both
2817 * directions will guarantee a perfect round trip if possible. In all other cases, the
2818 * Callable or util::CallbackR10 will be wrapped in a new util::CallbackR10 or Callable
2819 * object.
2820 *
2821 * @ingroup PyExportTraits
2822 */
2823template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10>
2824struct PyExportTraits< util::CallbackR10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >:
2826 util::CallbackR10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
2827 impl::PyCallbackR10Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
2828 PyExportTraits< util::CallbackR10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >
2829 >
2830{
2831 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!], R!]";
2832
2833 static const char* className() { return "CallbackR10"; }
2834};
2835
2836}
2837}
2838
2839# endif
2840#endif
2841
2842#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R11)
2843# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R11
2844# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R11
2845
2846namespace lass
2847{
2848namespace python
2849{
2850namespace impl
2851{
2852 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
2853 class FunctorPythonR11: public FunctorPythonRBase<R>
2854 {
2855 public:
2856 FunctorPythonR11(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2857 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11) const
2858 {
2859 LockGIL lock;
2860 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11));
2861 }
2862 };
2863
2864 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
2865 class PyCallbackR11Impl: public PyCallbackImplBase
2866 {
2867 public:
2868 using TCallback = util::CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>;
2869 using TFunctor = FunctorPythonR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>;
2870 using TDispatcher = util::impl::DispatcherR11Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, TFunctor>;
2871
2872 PyCallbackR11Impl(TCallback callback): callback_(std::move(callback)) {}
2873 const TCallback& callable() const { return callback_; }
2874
2875 PyObject* call(PyObject* args) const override
2876 {
2877 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2878 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2879 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2880 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2881 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2882 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2883 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2884 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
2885 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
2886 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
2887 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
2888
2889 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) != 0 )
2890 {
2891 return nullptr;
2892 }
2893 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11));
2894 }
2895 private:
2896 TCallback callback_;
2897 };
2898
2899}
2900
2901/** Bidirectional mapping between util::CallbackR11 and a Python callable object
2902 *
2903 * Accepts Callable objects and wraps them in a util::CallbackR11 without checking the
2904 * parameter types or return type, allowing to call them from C++. The parameters
2905 * and return type are only checked when the function is called, and an exception will
2906 * be raised if the types do not match.
2907 *
2908 * From C++ to Python, the util::CallbackR11 is converted to a Callable object, so that
2909 * it can be called from Python. Again, the parameter types and return type will be
2910 * checked when the function is called.
2911 *
2912 * In both directions, unwrapping a previously wrapped function will be attempted.
2913 * I.e. if the util::CallbackR11 passed to Python already wraps a Callable Python
2914 * object, this will be unwrapped and the Callable object will be passed back to Python.
2915 * In the other direction, if a Callable object that was passed to C++ already wraps a
2916 * util::CallbackR11, *and* this util::CallbackR11 matches the correct signature, then
2917 * the util::CallbackR11 will be unwrapped and passed to C++. In other words, both
2918 * directions will guarantee a perfect round trip if possible. In all other cases, the
2919 * Callable or util::CallbackR11 will be wrapped in a new util::CallbackR11 or Callable
2920 * object.
2921 *
2922 * @ingroup PyExportTraits
2923 */
2924template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
2925struct PyExportTraits< util::CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >:
2927 util::CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
2928 impl::PyCallbackR11Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
2929 PyExportTraits< util::CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >
2930 >
2931{
2932 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!], R!]";
2933
2934 static const char* className() { return "CallbackR11"; }
2935};
2936
2937}
2938}
2939
2940# endif
2941#endif
2942
2943#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R12)
2944# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R12
2945# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R12
2946
2947namespace lass
2948{
2949namespace python
2950{
2951namespace impl
2952{
2953 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
2954 class FunctorPythonR12: public FunctorPythonRBase<R>
2955 {
2956 public:
2957 FunctorPythonR12(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
2958 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12) const
2959 {
2960 LockGIL lock;
2961 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12));
2962 }
2963 };
2964
2965 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
2966 class PyCallbackR12Impl: public PyCallbackImplBase
2967 {
2968 public:
2969 using TCallback = util::CallbackR12<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>;
2970 using TFunctor = FunctorPythonR12<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>;
2971 using TDispatcher = util::impl::DispatcherR12Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, TFunctor>;
2972
2973 PyCallbackR12Impl(TCallback callback): callback_(std::move(callback)) {}
2974 const TCallback& callable() const { return callback_; }
2975
2976 PyObject* call(PyObject* args) const override
2977 {
2978 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
2979 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
2980 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
2981 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
2982 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
2983 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
2984 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
2985 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
2986 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
2987 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
2988 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
2989 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
2990
2991 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) != 0 )
2992 {
2993 return nullptr;
2994 }
2995 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12));
2996 }
2997 private:
2998 TCallback callback_;
2999 };
3000
3001}
3002
3003/** Bidirectional mapping between util::CallbackR12 and a Python callable object
3004 *
3005 * Accepts Callable objects and wraps them in a util::CallbackR12 without checking the
3006 * parameter types or return type, allowing to call them from C++. The parameters
3007 * and return type are only checked when the function is called, and an exception will
3008 * be raised if the types do not match.
3009 *
3010 * From C++ to Python, the util::CallbackR12 is converted to a Callable object, so that
3011 * it can be called from Python. Again, the parameter types and return type will be
3012 * checked when the function is called.
3013 *
3014 * In both directions, unwrapping a previously wrapped function will be attempted.
3015 * I.e. if the util::CallbackR12 passed to Python already wraps a Callable Python
3016 * object, this will be unwrapped and the Callable object will be passed back to Python.
3017 * In the other direction, if a Callable object that was passed to C++ already wraps a
3018 * util::CallbackR12, *and* this util::CallbackR12 matches the correct signature, then
3019 * the util::CallbackR12 will be unwrapped and passed to C++. In other words, both
3020 * directions will guarantee a perfect round trip if possible. In all other cases, the
3021 * Callable or util::CallbackR12 will be wrapped in a new util::CallbackR12 or Callable
3022 * object.
3023 *
3024 * @ingroup PyExportTraits
3025 */
3026template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12>
3027struct PyExportTraits< util::CallbackR12<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >:
3029 util::CallbackR12<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
3030 impl::PyCallbackR12Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
3031 PyExportTraits< util::CallbackR12<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >
3032 >
3033{
3034 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!], R!]";
3035
3036 static const char* className() { return "CallbackR12"; }
3037};
3038
3039}
3040}
3041
3042# endif
3043#endif
3044
3045#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R13)
3046# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R13
3047# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R13
3048
3049namespace lass
3050{
3051namespace python
3052{
3053namespace impl
3054{
3055 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
3056 class FunctorPythonR13: public FunctorPythonRBase<R>
3057 {
3058 public:
3059 FunctorPythonR13(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
3060 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13) const
3061 {
3062 LockGIL lock;
3063 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13));
3064 }
3065 };
3066
3067 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
3068 class PyCallbackR13Impl: public PyCallbackImplBase
3069 {
3070 public:
3071 using TCallback = util::CallbackR13<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>;
3072 using TFunctor = FunctorPythonR13<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>;
3073 using TDispatcher = util::impl::DispatcherR13Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, TFunctor>;
3074
3075 PyCallbackR13Impl(TCallback callback): callback_(std::move(callback)) {}
3076 const TCallback& callable() const { return callback_; }
3077
3078 PyObject* call(PyObject* args) const override
3079 {
3080 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
3081 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
3082 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
3083 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
3084 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
3085 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
3086 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
3087 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
3088 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
3089 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
3090 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
3091 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
3092 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
3093
3094 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) != 0 )
3095 {
3096 return nullptr;
3097 }
3098 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13));
3099 }
3100 private:
3101 TCallback callback_;
3102 };
3103
3104}
3105
3106/** Bidirectional mapping between util::CallbackR13 and a Python callable object
3107 *
3108 * Accepts Callable objects and wraps them in a util::CallbackR13 without checking the
3109 * parameter types or return type, allowing to call them from C++. The parameters
3110 * and return type are only checked when the function is called, and an exception will
3111 * be raised if the types do not match.
3112 *
3113 * From C++ to Python, the util::CallbackR13 is converted to a Callable object, so that
3114 * it can be called from Python. Again, the parameter types and return type will be
3115 * checked when the function is called.
3116 *
3117 * In both directions, unwrapping a previously wrapped function will be attempted.
3118 * I.e. if the util::CallbackR13 passed to Python already wraps a Callable Python
3119 * object, this will be unwrapped and the Callable object will be passed back to Python.
3120 * In the other direction, if a Callable object that was passed to C++ already wraps a
3121 * util::CallbackR13, *and* this util::CallbackR13 matches the correct signature, then
3122 * the util::CallbackR13 will be unwrapped and passed to C++. In other words, both
3123 * directions will guarantee a perfect round trip if possible. In all other cases, the
3124 * Callable or util::CallbackR13 will be wrapped in a new util::CallbackR13 or Callable
3125 * object.
3126 *
3127 * @ingroup PyExportTraits
3128 */
3129template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13>
3130struct PyExportTraits< util::CallbackR13<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >:
3132 util::CallbackR13<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
3133 impl::PyCallbackR13Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
3134 PyExportTraits< util::CallbackR13<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >
3135 >
3136{
3137 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!], R!]";
3138
3139 static const char* className() { return "CallbackR13"; }
3140};
3141
3142}
3143}
3144
3145# endif
3146#endif
3147
3148#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R14)
3149# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R14
3150# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R14
3151
3152namespace lass
3153{
3154namespace python
3155{
3156namespace impl
3157{
3158 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
3159 class FunctorPythonR14: public FunctorPythonRBase<R>
3160 {
3161 public:
3162 FunctorPythonR14(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
3163 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13, typename util::CallTraits<P14>::TParam p14) const
3164 {
3165 LockGIL lock;
3166 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14));
3167 }
3168 };
3169
3170 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
3171 class PyCallbackR14Impl: public PyCallbackImplBase
3172 {
3173 public:
3174 using TCallback = util::CallbackR14<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>;
3175 using TFunctor = FunctorPythonR14<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>;
3176 using TDispatcher = util::impl::DispatcherR14Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, TFunctor>;
3177
3178 PyCallbackR14Impl(TCallback callback): callback_(std::move(callback)) {}
3179 const TCallback& callable() const { return callback_; }
3180
3181 PyObject* call(PyObject* args) const override
3182 {
3183 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
3184 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
3185 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
3186 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
3187 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
3188 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
3189 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
3190 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
3191 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
3192 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
3193 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
3194 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
3195 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
3196 typedef ArgumentTraits<P14> TArg14; typedef typename TArg14::TStorage S14; S14 p14 = S14();
3197
3198 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) != 0 )
3199 {
3200 return nullptr;
3201 }
3202 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13), TArg14::arg(p14));
3203 }
3204 private:
3205 TCallback callback_;
3206 };
3207
3208}
3209
3210/** Bidirectional mapping between util::CallbackR14 and a Python callable object
3211 *
3212 * Accepts Callable objects and wraps them in a util::CallbackR14 without checking the
3213 * parameter types or return type, allowing to call them from C++. The parameters
3214 * and return type are only checked when the function is called, and an exception will
3215 * be raised if the types do not match.
3216 *
3217 * From C++ to Python, the util::CallbackR14 is converted to a Callable object, so that
3218 * it can be called from Python. Again, the parameter types and return type will be
3219 * checked when the function is called.
3220 *
3221 * In both directions, unwrapping a previously wrapped function will be attempted.
3222 * I.e. if the util::CallbackR14 passed to Python already wraps a Callable Python
3223 * object, this will be unwrapped and the Callable object will be passed back to Python.
3224 * In the other direction, if a Callable object that was passed to C++ already wraps a
3225 * util::CallbackR14, *and* this util::CallbackR14 matches the correct signature, then
3226 * the util::CallbackR14 will be unwrapped and passed to C++. In other words, both
3227 * directions will guarantee a perfect round trip if possible. In all other cases, the
3228 * Callable or util::CallbackR14 will be wrapped in a new util::CallbackR14 or Callable
3229 * object.
3230 *
3231 * @ingroup PyExportTraits
3232 */
3233template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14>
3234struct PyExportTraits< util::CallbackR14<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >:
3236 util::CallbackR14<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>,
3237 impl::PyCallbackR14Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14>,
3238 PyExportTraits< util::CallbackR14<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >
3239 >
3240{
3241 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!, P14!], R!]";
3242
3243 static const char* className() { return "CallbackR14"; }
3244};
3245
3246}
3247}
3248
3249# endif
3250#endif
3251
3252#if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R15)
3253# ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R15
3254# define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H_CALLBACK_R15
3255
3256namespace lass
3257{
3258namespace python
3259{
3260namespace impl
3261{
3262 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
3263 class FunctorPythonR15: public FunctorPythonRBase<R>
3264 {
3265 public:
3266 FunctorPythonR15(const TPyObjPtr& callable): FunctorPythonRBase<R>(callable) {}
3267 R operator()(typename util::CallTraits<P1>::TParam p1, typename util::CallTraits<P2>::TParam p2, typename util::CallTraits<P3>::TParam p3, typename util::CallTraits<P4>::TParam p4, typename util::CallTraits<P5>::TParam p5, typename util::CallTraits<P6>::TParam p6, typename util::CallTraits<P7>::TParam p7, typename util::CallTraits<P8>::TParam p8, typename util::CallTraits<P9>::TParam p9, typename util::CallTraits<P10>::TParam p10, typename util::CallTraits<P11>::TParam p11, typename util::CallTraits<P12>::TParam p12, typename util::CallTraits<P13>::TParam p13, typename util::CallTraits<P14>::TParam p14, typename util::CallTraits<P15>::TParam p15) const
3268 {
3269 LockGIL lock;
3270 return this->call(makeTuple(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15));
3271 }
3272 };
3273
3274 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
3275 class PyCallbackR15Impl: public PyCallbackImplBase
3276 {
3277 public:
3278 using TCallback = util::CallbackR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>;
3279 using TFunctor = FunctorPythonR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>;
3280 using TDispatcher = util::impl::DispatcherR15Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, TFunctor>;
3281
3282 PyCallbackR15Impl(TCallback callback): callback_(std::move(callback)) {}
3283 const TCallback& callable() const { return callback_; }
3284
3285 PyObject* call(PyObject* args) const override
3286 {
3287 typedef ArgumentTraits<P1> TArg1; typedef typename TArg1::TStorage S1; S1 p1 = S1();
3288 typedef ArgumentTraits<P2> TArg2; typedef typename TArg2::TStorage S2; S2 p2 = S2();
3289 typedef ArgumentTraits<P3> TArg3; typedef typename TArg3::TStorage S3; S3 p3 = S3();
3290 typedef ArgumentTraits<P4> TArg4; typedef typename TArg4::TStorage S4; S4 p4 = S4();
3291 typedef ArgumentTraits<P5> TArg5; typedef typename TArg5::TStorage S5; S5 p5 = S5();
3292 typedef ArgumentTraits<P6> TArg6; typedef typename TArg6::TStorage S6; S6 p6 = S6();
3293 typedef ArgumentTraits<P7> TArg7; typedef typename TArg7::TStorage S7; S7 p7 = S7();
3294 typedef ArgumentTraits<P8> TArg8; typedef typename TArg8::TStorage S8; S8 p8 = S8();
3295 typedef ArgumentTraits<P9> TArg9; typedef typename TArg9::TStorage S9; S9 p9 = S9();
3296 typedef ArgumentTraits<P10> TArg10; typedef typename TArg10::TStorage S10; S10 p10 = S10();
3297 typedef ArgumentTraits<P11> TArg11; typedef typename TArg11::TStorage S11; S11 p11 = S11();
3298 typedef ArgumentTraits<P12> TArg12; typedef typename TArg12::TStorage S12; S12 p12 = S12();
3299 typedef ArgumentTraits<P13> TArg13; typedef typename TArg13::TStorage S13; S13 p13 = S13();
3300 typedef ArgumentTraits<P14> TArg14; typedef typename TArg14::TStorage S14; S14 p14 = S14();
3301 typedef ArgumentTraits<P15> TArg15; typedef typename TArg15::TStorage S15; S15 p15 = S15();
3302
3303 if ( decodeTuple<S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15>(args, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) != 0 )
3304 {
3305 return nullptr;
3306 }
3307 return Caller<R>::template callFunction<const TCallback&>(callback_, TArg1::arg(p1), TArg2::arg(p2), TArg3::arg(p3), TArg4::arg(p4), TArg5::arg(p5), TArg6::arg(p6), TArg7::arg(p7), TArg8::arg(p8), TArg9::arg(p9), TArg10::arg(p10), TArg11::arg(p11), TArg12::arg(p12), TArg13::arg(p13), TArg14::arg(p14), TArg15::arg(p15));
3308 }
3309 private:
3310 TCallback callback_;
3311 };
3312
3313}
3314
3315/** Bidirectional mapping between util::CallbackR15 and a Python callable object
3316 *
3317 * Accepts Callable objects and wraps them in a util::CallbackR15 without checking the
3318 * parameter types or return type, allowing to call them from C++. The parameters
3319 * and return type are only checked when the function is called, and an exception will
3320 * be raised if the types do not match.
3321 *
3322 * From C++ to Python, the util::CallbackR15 is converted to a Callable object, so that
3323 * it can be called from Python. Again, the parameter types and return type will be
3324 * checked when the function is called.
3325 *
3326 * In both directions, unwrapping a previously wrapped function will be attempted.
3327 * I.e. if the util::CallbackR15 passed to Python already wraps a Callable Python
3328 * object, this will be unwrapped and the Callable object will be passed back to Python.
3329 * In the other direction, if a Callable object that was passed to C++ already wraps a
3330 * util::CallbackR15, *and* this util::CallbackR15 matches the correct signature, then
3331 * the util::CallbackR15 will be unwrapped and passed to C++. In other words, both
3332 * directions will guarantee a perfect round trip if possible. In all other cases, the
3333 * Callable or util::CallbackR15 will be wrapped in a new util::CallbackR15 or Callable
3334 * object.
3335 *
3336 * @ingroup PyExportTraits
3337 */
3338template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15>
3339struct PyExportTraits< util::CallbackR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >:
3341 util::CallbackR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>,
3342 impl::PyCallbackR15Impl<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>,
3343 PyExportTraits< util::CallbackR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >
3344 >
3345{
3346 static constexpr const char* py_typing = "Callable[[P1!, P2!, P3!, P4!, P5!, P6!, P7!, P8!, P9!, P10!, P11!, P12!, P13!, P14!, P15!], R!]";
3347
3348 static const char* className() { return "CallbackR15"; }
3349};
3350
3351}
3352}
3353
3354# endif
3355#endif
3356
3357
3358// EOF
acquire the GIL for the current scope.
Definition gil.h:56
void addMessageHeader(const char *header)
Prepend a message to the current Python exception value.
void fetchAndThrowPythonException(std::string loc)
Fetch the current Python exception and throw it as a C++ PythonException.
PyObjectPtr< PyObject >::Type TPyObjPtr
PyObjectPtr to a PyObject.
#define PY_HEADER(t_parentClass)
Place as first line of your Pythonized class.
PyObject * fromSharedPtrToNakedCast(const util::SharedPtr< T, PyObjectStorage, PyObjectCounter > &object)
fromSharedPtrToNakedCast.
Comprehensive C++ to Python binding library.
general utility, debug facilities, ...
Library for Assembled Shared Sources.
Definition config.h:53
Helper class to implement PyExportTraits for Callback types.
by copy, general case assumes shadow type or PyObjectPlus based type.