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