Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Executors.cxx
Go to the documentation of this file.
1// Bindings
2#include "CPyCppyy.h"
3#include "DeclareExecutors.h"
4#include "CPPInstance.h"
5#include "LowLevelViews.h"
6#include "ProxyWrappers.h"
7#include "PyStrings.h"
8#include "TypeManip.h"
9#include "Utility.h"
10
11// Standard
12#include <cstring>
13#include <map>
14#include <new>
15#include <sstream>
16#include <utility>
17#include <sys/types.h>
18
19
20//- data _____________________________________________________________________
21namespace CPyCppyy {
22 typedef Executor* (*ef_t) ();
23 typedef std::map<std::string, ef_t> ExecFactories_t;
25
27
28 extern std::set<std::string> gIteratorTypes;
29}
30
31
32//- helpers ------------------------------------------------------------------
33namespace {
34
35#ifdef WITH_THREAD
36 class GILControl {
37 public:
38 GILControl() : fSave(PyEval_SaveThread()) { }
39 ~GILControl() {
40 PyEval_RestoreThread(fSave);
41 }
42 private:
43 PyThreadState* fSave;
44 };
45#endif
46
47} // unnamed namespace
48
49#ifdef WITH_THREAD
50#define CPPYY_IMPL_GILCALL(rtype, tcode) \
51static inline rtype GILCall##tcode( \
52 Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext* ctxt)\
53{ \
54 if (!ReleasesGIL(ctxt)) \
55 return Cppyy::Call##tcode(method, self, ctxt->GetSize(), ctxt->GetArgs());\
56 GILControl gc{}; \
57 return Cppyy::Call##tcode(method, self, ctxt->GetSize(), ctxt->GetArgs());\
58}
59#else
60#define CPPYY_IMPL_GILCALL(rtype, tcode) \
61static inline rtype GILCall##tcode( \
62 Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext* ctxt)\
63{ \
64 return Cppyy::Call##tcode(method, self, ctxt->GetSize(), ctxt->GetArgs());\
65}
66#endif
67
69CPPYY_IMPL_GILCALL(unsigned char, B)
79
80static inline Cppyy::TCppObject_t GILCallO(Cppyy::TCppMethod_t method,
81 Cppyy::TCppObject_t self, CPyCppyy::CallContext* ctxt, Cppyy::TCppType_t klass)
82{
83#ifdef WITH_THREAD
84 if (!ReleasesGIL(ctxt))
85#endif
86 return Cppyy::CallO(method, self, ctxt->GetSize(), ctxt->GetArgs(), klass);
87#ifdef WITH_THREAD
88 GILControl gc{};
89 return Cppyy::CallO(method, self, ctxt->GetSize(), ctxt->GetArgs(), klass);
90#endif
91}
92
95{
96#ifdef WITH_THREAD
97 if (!ReleasesGIL(ctxt))
98#endif
99 return Cppyy::CallConstructor(method, klass, ctxt->GetSize(), ctxt->GetArgs());
100#ifdef WITH_THREAD
101 GILControl gc{};
102 return Cppyy::CallConstructor(method, klass, ctxt->GetSize(), ctxt->GetArgs());
103#endif
104}
105
106static inline PyObject* CPyCppyy_PyText_FromLong(long cl)
107{
108// python chars are range(256)
109 if (cl < -256 || cl > 255) {
110 PyErr_SetString(PyExc_ValueError, "char conversion out of range");
111 return nullptr;
112 }
113 int c = (int)cl;
114 if (c < 0) return CPyCppyy_PyText_FromFormat("%c", 256 - std::abs(c));
115 return CPyCppyy_PyText_FromFormat("%c", c);
116}
117
118static inline PyObject* CPyCppyy_PyText_FromULong(unsigned long uc)
119{
120// TODO: range check here?
121 if (255 < uc) {
122 PyErr_SetString(PyExc_ValueError, "char conversion out of range");
123 return nullptr;
124 }
125 int c = (int)uc;
126 return CPyCppyy_PyText_FromFormat("%c", c);
127}
128
130{
131 PyObject* result = (bool)b ? Py_True : Py_False;
132 Py_INCREF(result);
133 return result;
134}
135
136
137//- base executor implementation ---------------------------------------------
139{
140 /* empty */
141}
142
143//- executors for built-ins --------------------------------------------------
144PyObject* CPyCppyy::BoolExecutor::Execute(
146{
147// execute <method> with argument <self, ctxt>, construct python bool return value
148 bool retval = GILCallB(method, self, ctxt);
149 PyObject* result = retval ? Py_True : Py_False;
150 Py_INCREF(result);
151 return result;
152}
153
154//----------------------------------------------------------------------------
155PyObject* CPyCppyy::BoolConstRefExecutor::Execute(
157{
158// execute <method> with argument <self, ctxt>, construct python bool return value
159 return CPyCppyy_PyBool_FromLong(*((bool*)GILCallR(method, self, ctxt)));
160}
161
162//----------------------------------------------------------------------------
163PyObject* CPyCppyy::CharExecutor::Execute(
165{
166// execute <method with argument <self, ctxt>, construct python string return value
167// with the single char
168 return CPyCppyy_PyText_FromLong((int)GILCallC(method, self, ctxt));
169}
170
171//----------------------------------------------------------------------------
172PyObject* CPyCppyy::CharConstRefExecutor::Execute(
174{
175// execute <method> with argument <self, ctxt>, construct python string return value
176// with the single char
177 return CPyCppyy_PyText_FromLong(*((char*)GILCallR(method, self, ctxt)));
178}
179
180//----------------------------------------------------------------------------
181PyObject* CPyCppyy::UCharExecutor::Execute(
183{
184// execute <method> with argument <self, args>, construct python string return value
185// with the single char
186 return CPyCppyy_PyText_FromLong((unsigned char)GILCallB(method, self, ctxt));
187}
188
189//----------------------------------------------------------------------------
190PyObject* CPyCppyy::UCharConstRefExecutor::Execute(
192{
193// execute <method> with argument <self, ctxt>, construct python string return value
194// with the single char from the pointer return
195 return CPyCppyy_PyText_FromLong(*((unsigned char*)GILCallR(method, self, ctxt)));
196}
197
198//----------------------------------------------------------------------------
199PyObject* CPyCppyy::WCharExecutor::Execute(
201{
202// execute <method> with argument <self, args>, construct python string return value
203// with the single wide char
204 wchar_t res = (wchar_t)GILCallL(method, self, ctxt);
205 return PyUnicode_FromWideChar(&res, 1);
206}
207
208//----------------------------------------------------------------------------
209PyObject* CPyCppyy::Char16Executor::Execute(
211{
212// execute <method> with argument <self, args>, construct python string return value
213// with the single char16
214 char16_t res = (char16_t)GILCallL(method, self, ctxt);
215 return PyUnicode_DecodeUTF16((const char*)&res, sizeof(char16_t), nullptr, nullptr);
216}
217
218//----------------------------------------------------------------------------
219PyObject* CPyCppyy::Char32Executor::Execute(
221{
222// execute <method> with argument <self, args>, construct python string return value
223// with the single char32
224 char32_t res = (char32_t)GILCallL(method, self, ctxt);
225 return PyUnicode_DecodeUTF32((const char*)&res, sizeof(char32_t), nullptr, nullptr);
226}
227
228//----------------------------------------------------------------------------
229PyObject* CPyCppyy::IntExecutor::Execute(
231{
232// execute <method> with argument <self, ctxt>, construct python int return value
233 return PyInt_FromLong((int)GILCallI(method, self, ctxt));
234}
235
236//----------------------------------------------------------------------------
237PyObject* CPyCppyy::Int8Executor::Execute(
239{
240// execute <method> with argument <self, ctxt>, construct python int return value
241 return PyInt_FromLong((int8_t)GILCallC(method, self, ctxt));
242}
243
244//----------------------------------------------------------------------------
245PyObject* CPyCppyy::UInt8Executor::Execute(
247{
248// execute <method> with argument <self, ctxt>, construct python int return value
249 return PyInt_FromLong((uint8_t)GILCallB(method, self, ctxt));
250}
251
252//----------------------------------------------------------------------------
253PyObject* CPyCppyy::ShortExecutor::Execute(
255{
256// execute <method> with argument <self, ctxt>, construct python int return value
257 return PyInt_FromLong((short)GILCallH(method, self, ctxt));
258}
259
260//----------------------------------------------------------------------------
261PyObject* CPyCppyy::LongExecutor::Execute(
263{
264// execute <method> with argument <self, ctxt>, construct python long return value
265 return PyLong_FromLong((Long_t)GILCallL(method, self, ctxt));
266}
267
268//----------------------------------------------------------------------------
269PyObject* CPyCppyy::ULongExecutor::Execute(
271{
272// execute <method> with argument <self, ctxt>, construct python unsigned long return value
273 return PyLong_FromUnsignedLong((ULong_t)GILCallLL(method, self, ctxt));
274}
275
276//----------------------------------------------------------------------------
277PyObject* CPyCppyy::LongLongExecutor::Execute(
279{
280// execute <method> with argument <self, ctxt>, construct python long long return value
281 Long64_t result = GILCallLL(method, self, ctxt);
282 return PyLong_FromLongLong(result);
283}
284
285//----------------------------------------------------------------------------
286PyObject* CPyCppyy::ULongLongExecutor::Execute(
288{
289// execute <method> with argument <self, ctxt>, construct python unsigned long long return value
290 ULong64_t result = (ULong64_t)GILCallLL(method, self, ctxt);
291 return PyLong_FromUnsignedLongLong(result);
292}
293
294//----------------------------------------------------------------------------
295PyObject* CPyCppyy::FloatExecutor::Execute(
297{
298// execute <method> with argument <self, ctxt>, construct python float return value
299 return PyFloat_FromDouble((double)GILCallF(method, self, ctxt));
300}
301
302//----------------------------------------------------------------------------
303PyObject* CPyCppyy::DoubleExecutor::Execute(
305{
306// execute <method> with argument <self, ctxt>, construct python float return value
307 return PyFloat_FromDouble((double)GILCallD(method, self, ctxt));
308}
309
310//----------------------------------------------------------------------------
311PyObject* CPyCppyy::LongDoubleExecutor::Execute(
313{
314// execute <method> with argument <self, ctxt>, construct python float return value
315 return PyFloat_FromDouble((double)GILCallLD(method, self, ctxt));
316}
317
318//----------------------------------------------------------------------------
320{
321// prepare "buffer" for by-ref returns, used with __setitem__
322 if (pyobject) {
323 Py_INCREF(pyobject);
324 fAssignable = pyobject;
325 return true;
326 }
327
328 fAssignable = nullptr;
329 return false;
330}
331
332//----------------------------------------------------------------------------
333#define CPPYY_IMPL_REFEXEC(name, type, stype, F1, F2) \
334PyObject* CPyCppyy::name##RefExecutor::Execute( \
335 Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CallContext* ctxt) \
336{ \
337 type* ref = (type*)GILCallR(method, self, ctxt); \
338 if (!ref) { /* can happen if wrapper compilation fails */ \
339 PyErr_SetString(PyExc_ReferenceError, "attempt to access a null-pointer");\
340 return nullptr; \
341 } \
342 if (!fAssignable) \
343 return F1((stype)*ref); \
344 else { \
345 *ref = (type)F2(fAssignable); \
346 Py_DECREF(fAssignable); \
347 fAssignable = nullptr; \
348 if (*ref == (type)-1 && PyErr_Occurred()) \
349 return nullptr; \
350 Py_INCREF(Py_None); \
351 return Py_None; \
352 } \
353}
354
355CPPYY_IMPL_REFEXEC(Bool, bool, Long_t, CPyCppyy_PyBool_FromLong, PyLong_AsLong)
356CPPYY_IMPL_REFEXEC(Char, char, Long_t, CPyCppyy_PyText_FromLong, PyLong_AsLong)
358CPPYY_IMPL_REFEXEC(Int8, int8_t, Long_t, PyInt_FromLong, PyLong_AsLong)
359CPPYY_IMPL_REFEXEC(UInt8, uint8_t, ULong_t, PyInt_FromLong, PyLongOrInt_AsULong)
360CPPYY_IMPL_REFEXEC(Short, short, Long_t, PyInt_FromLong, PyLong_AsLong)
361CPPYY_IMPL_REFEXEC(UShort, unsigned short, ULong_t, PyInt_FromLong, PyLongOrInt_AsULong)
362CPPYY_IMPL_REFEXEC(Int, Int_t, Long_t, PyInt_FromLong, PyLong_AsLong)
363CPPYY_IMPL_REFEXEC(UInt, UInt_t, ULong_t, PyLong_FromUnsignedLong, PyLongOrInt_AsULong)
364CPPYY_IMPL_REFEXEC(Long, Long_t, Long_t, PyLong_FromLong, PyLong_AsLong)
365CPPYY_IMPL_REFEXEC(ULong, ULong_t, ULong_t, PyLong_FromUnsignedLong, PyLongOrInt_AsULong)
366CPPYY_IMPL_REFEXEC(LongLong, Long64_t, Long64_t, PyLong_FromLongLong, PyLong_AsLongLong)
367CPPYY_IMPL_REFEXEC(ULongLong, ULong64_t, ULong64_t, PyLong_FromUnsignedLongLong, PyLongOrInt_AsULong64)
368CPPYY_IMPL_REFEXEC(Float, float, double, PyFloat_FromDouble, PyFloat_AsDouble)
369CPPYY_IMPL_REFEXEC(Double, double, double, PyFloat_FromDouble, PyFloat_AsDouble)
370CPPYY_IMPL_REFEXEC(LongDouble, LongDouble_t, LongDouble_t, PyFloat_FromDouble, PyFloat_AsDouble)
371
372template<typename T>
373static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
374 return PyComplex_FromDoubles(c.real(), c.imag());
375}
376
377template<typename T>
378static inline std::complex<T> PyComplex_AsComplex(PyObject* pycplx) {
379 Py_complex cplx = PyComplex_AsCComplex(pycplx);
380 return std::complex<T>(cplx.real, cplx.imag);
381}
382
383CPPYY_IMPL_REFEXEC(ComplexD, std::complex<double>,
384 std::complex<double>, PyComplex_FromComplex<double>, PyComplex_AsComplex<double>)
385
386
387//----------------------------------------------------------------------------
388PyObject* CPyCppyy::STLStringRefExecutor::Execute(
390{
391// execute <method> with argument <self, ctxt>, return python string return value
392 std::string* result = (std::string*)GILCallR(method, self, ctxt);
393 if (!fAssignable)
394 return CPyCppyy_PyText_FromStringAndSize(result->c_str(), result->size());
395
396 *result = std::string(
397 CPyCppyy_PyText_AsString(fAssignable), CPyCppyy_PyText_GET_SIZE(fAssignable));
398
399 Py_DECREF(fAssignable);
400 fAssignable = nullptr;
401
403}
404
405//----------------------------------------------------------------------------
406PyObject* CPyCppyy::VoidExecutor::Execute(
408{
409// execute <method> with argument <self, ctxt>, return None
410 GILCallV(method, self, ctxt);
412}
413
414//----------------------------------------------------------------------------
415PyObject* CPyCppyy::CStringExecutor::Execute(
417{
418// execute <method> with argument <self, ctxt>, construct python string return value
419 char* result = (char*)GILCallR(method, self, ctxt);
420 if (!result) {
421 Py_INCREF(PyStrings::gEmptyString);
423 }
424
426}
427
428//----------------------------------------------------------------------------
429PyObject* CPyCppyy::WCStringExecutor::Execute(
431{
432// execute <method> with argument <self, ctxt>, construct python unicode return value
433 wchar_t* result = (wchar_t*)GILCallR(method, self, ctxt);
434 if (!result) {
435 wchar_t w = L'\0';
436 return PyUnicode_FromWideChar(&w, 0);
437 }
438
439 return PyUnicode_FromWideChar(result, wcslen(result));
440}
441
442//----------------------------------------------------------------------------
443PyObject* CPyCppyy::CString16Executor::Execute(
445{
446// execute <method> with argument <self, ctxt>, construct python unicode return value
447 char16_t* result = (char16_t*)GILCallR(method, self, ctxt);
448 if (!result) {
449 char16_t w = u'\0';
450 return PyUnicode_DecodeUTF16((const char*)&w, 0, nullptr, nullptr);
451 }
452
453 return PyUnicode_DecodeUTF16((const char*)result,
454 std::char_traits<char16_t>::length(result)*sizeof(char16_t), nullptr, nullptr);
455}
456
457//----------------------------------------------------------------------------
458PyObject* CPyCppyy::CString32Executor::Execute(
460{
461// execute <method> with argument <self, ctxt>, construct python unicode return value
462 char32_t* result = (char32_t*)GILCallR(method, self, ctxt);
463 if (!result) {
464 char32_t w = U'\0';
465 return PyUnicode_DecodeUTF32((const char*)&w, 0, nullptr, nullptr);
466 }
467
468 return PyUnicode_DecodeUTF32((const char*)result,
469 std::char_traits<char32_t>::length(result)*sizeof(char32_t), nullptr, nullptr);
470}
471
472
473//- pointer/array executors --------------------------------------------------
474PyObject* CPyCppyy::VoidArrayExecutor::Execute(
476{
477// execute <method> with argument <self, ctxt>, construct python long return value
478 Long_t* result = (Long_t*)GILCallR(method, self, ctxt);
479 if (!result) {
480 Py_INCREF(gNullPtrObject);
481 return gNullPtrObject;
482 }
484}
485
486//----------------------------------------------------------------------------
487#define CPPYY_IMPL_ARRAY_EXEC(name, type) \
488PyObject* CPyCppyy::name##ArrayExecutor::Execute( \
489 Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CallContext* ctxt) \
490{ \
491 return CreateLowLevelView((type*)GILCallR(method, self, ctxt)); \
492}
493
494CPPYY_IMPL_ARRAY_EXEC(Bool, bool)
495CPPYY_IMPL_ARRAY_EXEC(UChar, unsigned char)
496#if __cplusplus > 201402L
497CPPYY_IMPL_ARRAY_EXEC(Byte, std::byte)
498#endif
499CPPYY_IMPL_ARRAY_EXEC(Short, short)
500CPPYY_IMPL_ARRAY_EXEC(UShort, unsigned short)
501CPPYY_IMPL_ARRAY_EXEC(Int, int)
502CPPYY_IMPL_ARRAY_EXEC(UInt, unsigned int)
503CPPYY_IMPL_ARRAY_EXEC(Long, long)
504CPPYY_IMPL_ARRAY_EXEC(ULong, unsigned long)
505CPPYY_IMPL_ARRAY_EXEC(LLong, long long)
506CPPYY_IMPL_ARRAY_EXEC(ULLong, unsigned long long)
507CPPYY_IMPL_ARRAY_EXEC(Float, float)
508CPPYY_IMPL_ARRAY_EXEC(Double, double)
509CPPYY_IMPL_ARRAY_EXEC(ComplexF, std::complex<float>)
510CPPYY_IMPL_ARRAY_EXEC(ComplexD, std::complex<double>)
511CPPYY_IMPL_ARRAY_EXEC(ComplexI, std::complex<int>)
512CPPYY_IMPL_ARRAY_EXEC(ComplexL, std::complex<long>)
513
514
515//- special cases ------------------------------------------------------------
516#define CPPYY_COMPLEX_EXEC(code, type) \
517PyObject* CPyCppyy::Complex##code##Executor::Execute( \
518 Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CallContext* ctxt) \
519{ \
520 static Cppyy::TCppScope_t scopeid = Cppyy::GetScope("std::complex<"#type">");\
521 std::complex<type>* result = \
522 (std::complex<type>*)GILCallO(method, self, ctxt, scopeid); \
523 if (!result) { \
524 PyErr_SetString(PyExc_ValueError, "NULL result where temporary expected");\
525 return nullptr; \
526 } \
527 \
528 PyObject* pyres = PyComplex_FromDoubles(result->real(), result->imag()); \
529 ::operator delete(result); /* Cppyy::CallO calls ::operator new */ \
530 return pyres; \
531}
532
533CPPYY_COMPLEX_EXEC(D, double)
534
535//----------------------------------------------------------------------------
536PyObject* CPyCppyy::STLStringExecutor::Execute(
538{
539// execute <method> with argument <self, ctxt>, construct python string return value
540
541// TODO: make use of GILLCallS (?!)
542 static Cppyy::TCppScope_t sSTLStringScope = Cppyy::GetScope("std::string");
543 std::string* result = (std::string*)GILCallO(method, self, ctxt, sSTLStringScope);
544 if (!result) {
545 Py_INCREF(PyStrings::gEmptyString);
547 }
548
549 PyObject* pyresult =
551 ::operator delete(result); // calls Cppyy::CallO which calls ::operator new
552
553 return pyresult;
554}
555
556//----------------------------------------------------------------------------
557PyObject* CPyCppyy::STLWStringExecutor::Execute(
559{
560// execute <method> with argument <self, ctxt>, construct python string return value
561 static Cppyy::TCppScope_t sSTLWStringScope = Cppyy::GetScope("std::wstring");
562 std::wstring* result = (std::wstring*)GILCallO(method, self, ctxt, sSTLWStringScope);
563 if (!result) {
564 wchar_t w = L'\0';
565 return PyUnicode_FromWideChar(&w, 0);
566 }
567
568 PyObject* pyresult = PyUnicode_FromWideChar(result->c_str(), result->size());
569 ::operator delete(result); // calls Cppyy::CallO which calls ::operator new
570
571 return pyresult;
572}
573
574//----------------------------------------------------------------------------
575PyObject* CPyCppyy::InstancePtrExecutor::Execute(
577{
578// execute <method> with argument <self, ctxt>, construct python proxy object return value
579 return BindCppObject((void*)GILCallR(method, self, ctxt), fClass);
580}
581
582//----------------------------------------------------------------------------
583CPyCppyy::InstanceExecutor::InstanceExecutor(Cppyy::TCppType_t klass) :
584 fClass(klass), fFlags(CPPInstance::kIsValue | CPPInstance::kIsOwner)
585{
586 /* empty */
587}
588
589//----------------------------------------------------------------------------
590PyObject* CPyCppyy::InstanceExecutor::Execute(
592{
593// execution will bring a temporary in existence
594 Cppyy::TCppObject_t value = GILCallO(method, self, ctxt, fClass);
595
596 if (!value) {
597 if (!PyErr_Occurred()) // callee may have set a python error itself
598 PyErr_SetString(PyExc_ValueError, "nullptr result where temporary expected");
599 return nullptr;
600 }
601
602// the result can then be bound
604 if (!pyobj)
605 return nullptr;
606
607// python ref counting will now control this object's life span; it will be
608// deleted b/c it is marked as a by-value object (unless C++ ownership is set)
609 return pyobj;
610}
611
612
613//----------------------------------------------------------------------------
614CPyCppyy::IteratorExecutor::IteratorExecutor(Cppyy::TCppType_t klass) :
615 InstanceExecutor(klass)
616{
617 fFlags |= CPPInstance::kNoWrapConv; // adds to flags from base class
618}
619
620
621//----------------------------------------------------------------------------
622PyObject* CPyCppyy::InstanceRefExecutor::Execute(
624{
625// executor binds the result to the left-hand side, overwriting if an old object
626 PyObject* result = BindCppObject((void*)GILCallR(method, self, ctxt), fClass);
627 if (!result || !fAssignable)
628 return result;
629 else {
630 // this generic code is quite slow compared to its C++ equivalent ...
631 PyObject* assign = PyObject_GetAttr(result, PyStrings::gAssign);
632 if (!assign) {
633 PyErr_Clear();
634 PyObject* descr = PyObject_Str(result);
635 if (descr && CPyCppyy_PyText_CheckExact(descr)) {
636 PyErr_Format(PyExc_TypeError, "cannot assign to return object (%s)",
638 } else {
639 PyErr_SetString(PyExc_TypeError, "cannot assign to result");
640 }
641 Py_XDECREF(descr);
642 Py_DECREF(result);
643 Py_DECREF(fAssignable); fAssignable = nullptr;
644 return nullptr;
645 }
646
647 PyObject* res2 = PyObject_CallFunction(assign, const_cast<char*>("O"), fAssignable);
648
649 Py_DECREF(assign);
650 Py_DECREF(result);
651 Py_DECREF(fAssignable); fAssignable = nullptr;
652
653 if (res2) {
654 Py_DECREF(res2); // typically, *this from operator=()
656 }
657
658 return nullptr;
659 }
660}
661
662//----------------------------------------------------------------------------
664 PyObject* pystr = PyObject_Str(pyobj);
665 if (pystr) {
666 PyErr_Format(PyExc_TypeError,
667 "C++ object expected, got %s", CPyCppyy_PyText_AsString(pystr));
668 Py_DECREF(pystr);
669 } else
670 PyErr_SetString(PyExc_TypeError, "C++ object expected");
671 return nullptr;
672}
673
674PyObject* CPyCppyy::InstancePtrPtrExecutor::Execute(
676{
677// execute <method> with argument <self, ctxt>, construct python C++ proxy object
678// return ptr value
679 if (fAssignable && !CPPInstance_Check(fAssignable))
680 return SetInstanceCheckError(fAssignable);
681
682 void** result = (void**)GILCallR(method, self, ctxt);
683 if (!fAssignable)
684 return BindCppObject((void*)result, fClass,
686
687 CPPInstance* cppinst = (CPPInstance*)fAssignable;
688 *result = cppinst->GetObject();
689
690 Py_DECREF(fAssignable);
691 fAssignable = nullptr;
692
694}
695
696//----------------------------------------------------------------------------
697PyObject* CPyCppyy::InstancePtrRefExecutor::Execute(
699{
700// execute <method> with argument <self, ctxt>, construct python C++ proxy object
701// ignoring ref) return ptr value
702 if (fAssignable && !CPPInstance_Check(fAssignable))
703 return SetInstanceCheckError(fAssignable);
704
705 void** result = (void**)GILCallR(method, self, ctxt);
706 if (!fAssignable)
707 return BindCppObject(*result, fClass);
708
709 CPPInstance* cppinst = (CPPInstance*)fAssignable;
710 *result = cppinst->GetObject();;
711
712 Py_DECREF(fAssignable);
713 fAssignable = nullptr;
714
716}
717
718
719//----------------------------------------------------------------------------
720PyObject* CPyCppyy::InstanceArrayExecutor::Execute(
722{
723// execute <method> with argument <self, ctxt>, construct TupleOfInstances from
724// return value
725 dim_t dims[] = {1, (dim_t)fArraySize};
726 return BindCppObjectArray((void*)GILCallR(method, self, ctxt), fClass, dims);
727}
728
729//----------------------------------------------------------------------------
730PyObject* CPyCppyy::ConstructorExecutor::Execute(
732{
733// package return address in PyObject* for caller to handle appropriately (see
734// CPPConstructor for the actual build of the PyObject)
735 return (PyObject*)GILCallConstructor(method, (Cppyy::TCppType_t)klass, ctxt);
736}
737
738//----------------------------------------------------------------------------
739PyObject* CPyCppyy::PyObjectExecutor::Execute(
741{
742// execute <method> with argument <self, ctxt>, return python object
743 return (PyObject*)GILCallR(method, self, ctxt);
744}
745
746//----------------------------------------------------------------------------
747PyObject* CPyCppyy::FunctionPointerExecutor::Execute(
749{
750// execute <method> with argument <self, ctxt>, return std::function from func ptr
751
752// A function pointer in clang is represented by a Type, not a FunctionDecl and it's
753// not possible to get the latter from the former: the backend will need to support
754// both. Since that is far in the future, we'll use a std::function instead.
755 void* address = (void*)GILCallR(method, self, ctxt);
756 if (address)
758 PyErr_SetString(PyExc_TypeError, "can not convert null function pointer");
759 return nullptr;
760}
761
762//- factories ----------------------------------------------------------------
763CPyCppyy::Executor* CPyCppyy::CreateExecutor(const std::string& fullType)
764{
765// The matching of the fulltype to an executor factory goes through up to 4 levels:
766// 1) full, qualified match
767// 2) drop '&' as by ref/full type is often pretty much the same python-wise
768// 3) C++ classes, either by ref/ptr or by value
769// 4) additional special case for enums
770//
771// If all fails, void is used, which will cause the return type to be ignored on use
772
773// an exactly matching executor is best
774 ExecFactories_t::iterator h = gExecFactories.find(fullType);
775 if (h != gExecFactories.end())
776 return (h->second)();
777
778// resolve typedefs etc.
779 const std::string& resolvedType = Cppyy::ResolveName(fullType);
780
781// a full, qualified matching executor is preferred
782 if (resolvedType != fullType) {
783 h = gExecFactories.find(resolvedType);
784 if (h != gExecFactories.end())
785 return (h->second)();
786 }
787
788//-- nothing? ok, collect information about the type and possible qualifiers/decorators
789 bool isConst = strncmp(resolvedType.c_str(), "const", 5) == 0;
790 const std::string& cpd = Utility::Compound(resolvedType);
791 std::string realType = TypeManip::clean_type(resolvedType, false);
792
793// accept unqualified type (as python does not know about qualifiers)
794 h = gExecFactories.find(realType + cpd);
795 if (h != gExecFactories.end())
796 return (h->second)();
797
798// drop const, as that is mostly meaningless to python (with the exception
799// of c-strings, but those are specialized in the converter map)
800 if (isConst) {
801 realType = TypeManip::remove_const(realType);
802 h = gExecFactories.find(realType + cpd);
803 if (h != gExecFactories.end())
804 return (h->second)();
805 }
806
807//-- still nothing? try pointer instead of array (for builtins)
808 if (cpd == "[]") {
809 h = gExecFactories.find(realType + "*");
810 if (h != gExecFactories.end())
811 return (h->second)(); // TODO: use array size
812 }
813
814// C++ classes and special cases
815 Executor* result = 0;
816 if (Cppyy::TCppType_t klass = Cppyy::GetScope(realType)) {
817 if (resolvedType.find("iterator") != std::string::npos || gIteratorTypes.find(fullType) != gIteratorTypes.end()) {
818 if (cpd == "")
819 return new IteratorExecutor(klass);
820 }
821
822 if (cpd == "")
823 result = new InstanceExecutor(klass);
824 else if (cpd == "&")
825 result = new InstanceRefExecutor(klass);
826 else if (cpd == "**" || cpd == "*[]" || cpd == "&*")
827 result = new InstancePtrPtrExecutor(klass);
828 else if (cpd == "*&")
829 result = new InstancePtrRefExecutor(klass);
830 else if (cpd == "[]") {
831 Py_ssize_t asize = Utility::ArraySize(resolvedType);
832 if (0 < asize)
833 result = new InstanceArrayExecutor(klass, asize);
834 else
835 result = new InstancePtrRefExecutor(klass);
836 } else
837 result = new InstancePtrExecutor(klass);
838 } else if (resolvedType.find("(*)") != std::string::npos ||
839 (resolvedType.find("::*)") != std::string::npos)) {
840 // this is a function pointer
841 // TODO: find better way of finding the type
842 auto pos1 = resolvedType.find('(');
843 auto pos2 = resolvedType.find("*)");
844 auto pos3 = resolvedType.rfind(')');
845 result = new FunctionPointerExecutor(
846 resolvedType.substr(0, pos1), resolvedType.substr(pos2+2, pos3-pos2-1));
847 } else {
848 // unknown: void* may work ("user knows best"), void will fail on use of return value
849 h = (cpd == "") ? gExecFactories.find("void") : gExecFactories.find("void*");
850 }
851
852 if (!result && h != gExecFactories.end())
853 // executor factory available, use it to create executor
854 result = (h->second)();
855
856 return result; // may still be null
857}
858
859//----------------------------------------------------------------------------
862{
863 if (p && p->HasState())
864 delete p; // state-less executors are always shared
865}
866
867//----------------------------------------------------------------------------
869bool CPyCppyy::RegisterExecutor(const std::string& name, ef_t fac)
870{
871// register a custom executor
872 auto f = gExecFactories.find(name);
873 if (f != gExecFactories.end())
874 return false;
875
876 gExecFactories[name] = fac;
877 return true;
878}
879
880//----------------------------------------------------------------------------
882bool CPyCppyy::UnregisterExecutor(const std::string& name)
883{
884// remove a custom executor
885 auto f = gExecFactories.find(name);
886 if (f != gExecFactories.end()) {
887 gExecFactories.erase(f);
888 return true;
889 }
890 return false;
891}
892
893//----------------------------------------------------------------------------
896{
897 return GILCallR(meth, obj, ctxt);
898}
899
900
901//----------------------------------------------------------------------------
902namespace {
903
904using namespace CPyCppyy;
905
906#define WSTRING "basic_string<wchar_t,char_traits<wchar_t>,allocator<wchar_t> >"
907
908struct InitExecFactories_t {
909public:
910 InitExecFactories_t() {
911 // load all executor factories in the global map 'gExecFactories'
913
914 // factories for built-ins
915 gf["bool"] = (ef_t)+[]() { static BoolExecutor e{}; return &e; };
916 gf["bool&"] = (ef_t)+[]() { return new BoolRefExecutor{}; };
917 gf["const bool&"] = (ef_t)+[]() { static BoolConstRefExecutor e{}; return &e; };
918 gf["char"] = (ef_t)+[]() { static CharExecutor e{}; return &e; };
919 gf["signed char"] = gf["char"];
920 gf["unsigned char"] = (ef_t)+[]() { static UCharExecutor e{}; return &e; };
921 gf["char&"] = (ef_t)+[]() { return new CharRefExecutor{}; };
922 gf["signed char&"] = gf["char&"];
923 gf["unsigned char&"] = (ef_t)+[]() { return new UCharRefExecutor{}; };
924 gf["const char&"] = (ef_t)+[]() { static CharConstRefExecutor e{}; return &e; };
925 gf["const signed char&"] = gf["const char&"];
926 gf["const unsigned char&"] = (ef_t)+[]() { static UCharConstRefExecutor e{}; return &e; };
927 gf["wchar_t"] = (ef_t)+[]() { static WCharExecutor e{}; return &e; };
928 gf["char16_t"] = (ef_t)+[]() { static Char16Executor e{}; return &e; };
929 gf["char32_t"] = (ef_t)+[]() { static Char32Executor e{}; return &e; };
930 gf["int8_t"] = (ef_t)+[]() { static Int8Executor e{}; return &e; };
931 gf["int8_t&"] = (ef_t)+[]() { return new Int8RefExecutor{}; };
932 gf["const int8_t&"] = (ef_t)+[]() { static Int8RefExecutor e{}; return &e; };
933 gf["uint8_t"] = (ef_t)+[]() { static UInt8Executor e{}; return &e; };
934 gf["uint8_t&"] = (ef_t)+[]() { return new UInt8RefExecutor{}; };
935 gf["const uint8_t&"] = (ef_t)+[]() { static UInt8RefExecutor e{}; return &e; };
936 gf["short"] = (ef_t)+[]() { static ShortExecutor e{}; return &e; };
937 gf["short&"] = (ef_t)+[]() { return new ShortRefExecutor{}; };
938 gf["int"] = (ef_t)+[]() { static IntExecutor e{}; return &e; };
939 gf["int&"] = (ef_t)+[]() { return new IntRefExecutor{}; };
940 gf["unsigned short"] = gf["int"];
941 gf["unsigned short&"] = (ef_t)+[]() { return new UShortRefExecutor{}; };
942 gf["unsigned long"] = (ef_t)+[]() { static ULongExecutor e{}; return &e; };
943 gf["unsigned long&"] = (ef_t)+[]() { return new ULongRefExecutor{}; };
944 gf["unsigned int"] = gf["unsigned long"];
945 gf["unsigned int&"] = (ef_t)+[]() { return new UIntRefExecutor{}; };
946 gf["long"] = (ef_t)+[]() { static LongExecutor e{}; return &e; };
947 gf["long&"] = (ef_t)+[]() { return new LongRefExecutor{}; };
948 gf["unsigned long"] = (ef_t)+[]() { static ULongExecutor e{}; return &e; };
949 gf["unsigned long&"] = (ef_t)+[]() { return new ULongRefExecutor{}; };
950 gf["long long"] = (ef_t)+[]() { static LongLongExecutor e{}; return &e; };
951 gf["long long&"] = (ef_t)+[]() { return new LongLongRefExecutor{}; };
952 gf["unsigned long long"] = (ef_t)+[]() { static ULongLongExecutor e{}; return &e; };
953 gf["unsigned long long&"] = (ef_t)+[]() { return new ULongLongRefExecutor{}; };
954
955 gf["float"] = (ef_t)+[]() { static FloatExecutor e{}; return &e; };
956 gf["float&"] = (ef_t)+[]() { return new FloatRefExecutor{}; };
957 gf["double"] = (ef_t)+[]() { static DoubleExecutor e{}; return &e; };
958 gf["double&"] = (ef_t)+[]() { return new DoubleRefExecutor{}; };
959 gf["long double"] = (ef_t)+[]() { static LongDoubleExecutor e{}; return &e; }; // TODO: lost precision
960 gf["long double&"] = (ef_t)+[]() { return new LongDoubleRefExecutor{}; };
961 gf["void"] = (ef_t)+[]() { static VoidExecutor e{}; return &e; };
962
963 // pointer/array factories
964 gf["void*"] = (ef_t)+[]() { static VoidArrayExecutor e{}; return &e; };
965 gf["bool*"] = (ef_t)+[]() { static BoolArrayExecutor e{}; return &e; };
966 gf["unsigned char*"] = (ef_t)+[]() { static UCharArrayExecutor e{}; return &e; };
967 gf["const unsigned char*"] = gf["unsigned char*"];
968#if __cplusplus > 201402L
969 gf["byte*"] = (ef_t)+[]() { static ByteArrayExecutor e{}; return &e; };
970 gf["const byte*"] = gf["byte*"];
971#endif
972 gf["short*"] = (ef_t)+[]() { static ShortArrayExecutor e{}; return &e; };
973 gf["unsigned short*"] = (ef_t)+[]() { static UShortArrayExecutor e{}; return &e; };
974 gf["int*"] = (ef_t)+[]() { static IntArrayExecutor e{}; return &e; };
975 gf["unsigned int*"] = (ef_t)+[]() { static UIntArrayExecutor e{}; return &e; };
976 gf["long*"] = (ef_t)+[]() { static LongArrayExecutor e{}; return &e; };
977 gf["unsigned long*"] = (ef_t)+[]() { static ULongArrayExecutor e{}; return &e; };
978 gf["long long*"] = (ef_t)+[]() { static LLongArrayExecutor e{}; return &e; };
979 gf["unsigned long long*"] = (ef_t)+[]() { static ULLongArrayExecutor e{}; return &e; };
980 gf["float*"] = (ef_t)+[]() { static FloatArrayExecutor e{}; return &e; };
981 gf["double*"] = (ef_t)+[]() { static DoubleArrayExecutor e{}; return &e; };
982 gf["complex<float>*"] = (ef_t)+[]() { static ComplexFArrayExecutor e{}; return &e; };
983 gf["complex<double>*"] = (ef_t)+[]() { static ComplexDArrayExecutor e{}; return &e; };
984 gf["complex<int>*"] = (ef_t)+[]() { static ComplexIArrayExecutor e{}; return &e; };
985 gf["complex<long>*"] = (ef_t)+[]() { static ComplexLArrayExecutor e{}; return &e; };
986
987 // aliases
988 gf["internal_enum_type_t"] = gf["int"];
989 gf["internal_enum_type_t&"] = gf["int&"];
990 gf["internal_enum_type_t*"] = gf["int*"];
991#if __cplusplus > 201402L
992 gf["byte"] = gf["uint8_t"];
993 gf["byte&"] = gf["uint8_t&"];
994 gf["const byte&"] = gf["const uint8_t&"];
995#endif
996 gf["Long64_t"] = gf["long long"];
997 gf["Long64_t&"] = gf["long long&"];
998 gf["Long64_t*"] = gf["long long*"];
999 gf["ULong64_t"] = gf["unsigned long long"];
1000 gf["ULong64_t&"] = gf["unsigned long long&"];
1001 gf["ULong64_t*"] = gf["unsigned long long*"];
1002 gf["Float16_t"] = gf["float"];
1003 gf["Float16_t&"] = gf["float&"];
1004 gf["Double32_t"] = gf["double"];
1005 gf["Double32_t&"] = gf["double&"];
1006
1007 // factories for special cases
1008 gf["const char*"] = (ef_t)+[]() { static CStringExecutor e{}; return &e; };
1009 gf["char*"] = gf["const char*"];
1010 gf["const signed char*"] = gf["const char*"];
1011 gf["signed char*"] = gf["char*"];
1012 gf["wchar_t*"] = (ef_t)+[]() { static WCStringExecutor e{}; return &e;};
1013 gf["char16_t*"] = (ef_t)+[]() { static CString16Executor e{}; return &e;};
1014 gf["char32_t*"] = (ef_t)+[]() { static CString32Executor e{}; return &e;};
1015 gf["std::string"] = (ef_t)+[]() { static STLStringExecutor e{}; return &e; };
1016 gf["string"] = gf["std::string"];
1017 gf["std::string&"] = (ef_t)+[]() { return new STLStringRefExecutor{}; };
1018 gf["string&"] = gf["std::string&"];
1019 gf["std::wstring"] = (ef_t)+[]() { static STLWStringExecutor e{}; return &e; };
1020 gf["std::" WSTRING] = gf["std::wstring"];
1021 gf[WSTRING] = gf["std::wstring"];
1022 gf["complex<double>"] = (ef_t)+[]() { static ComplexDExecutor e{}; return &e; };
1023 gf["complex<double>&"] = (ef_t)+[]() { return new ComplexDRefExecutor{}; };
1024 gf["__init__"] = (ef_t)+[]() { static ConstructorExecutor e{}; return &e; };
1025 gf["PyObject*"] = (ef_t)+[]() { static PyObjectExecutor e{}; return &e; };
1026 gf["_object*"] = gf["PyObject*"];
1027 gf["FILE*"] = gf["void*"];
1028 }
1029} initExecvFactories_;
1030
1031} // unnamed namespace
#define CPyCppyy_PyText_FromStringAndSize
Definition CPyCppyy.h:106
#define CPyCppyy_PyText_AsString
Definition CPyCppyy.h:97
#define CPyCppyy_PyText_GET_SIZE
Definition CPyCppyy.h:99
#define CPyCppyy_PyText_FromFormat
Definition CPyCppyy.h:101
Py_ssize_t dim_t
Definition CPyCppyy.h:64
#define Py_RETURN_NONE
Definition CPyCppyy.h:289
#define CPyCppyy_PyText_CheckExact
Definition CPyCppyy.h:96
#define CPyCppyy_PyText_FromString
Definition CPyCppyy.h:102
std::string fRetType
Cppyy::TCppType_t fClass
std::string fSignature
Py_ssize_t fArraySize
static PyObject * PyComplex_FromComplex(const std::complex< T > &c)
static Int_t GILCallI(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:72
static char GILCallC(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:70
static float GILCallF(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:75
static PyObject * CPyCppyy_PyText_FromLong(long cl)
static PyObject * SetInstanceCheckError(PyObject *pyobj)
static std::complex< T > PyComplex_AsComplex(PyObject *pycplx)
static Cppyy::TCppObject_t GILCallO(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt, Cppyy::TCppType_t klass)
Definition Executors.cxx:80
#define CPPYY_IMPL_GILCALL(rtype, tcode)
Definition Executors.cxx:60
static Cppyy::TCppObject_t GILCallConstructor(Cppyy::TCppMethod_t method, Cppyy::TCppType_t klass, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:93
static Long64_t GILCallLL(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:74
#define CPPYY_COMPLEX_EXEC(code, type)
static short GILCallH(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:71
static LongDouble_t GILCallLD(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:77
static PyObject * CPyCppyy_PyText_FromULong(unsigned long uc)
static PyObject * CPyCppyy_PyBool_FromLong(long b)
static void GILCallV(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:68
static void * GILCallR(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:78
#define CPPYY_IMPL_REFEXEC(name, type, stype, F1, F2)
static unsigned char GILCallB(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:69
#define CPPYY_IMPL_ARRAY_EXEC(name, type)
#define WSTRING
static Long_t GILCallL(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:73
static double GILCallD(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, CPyCppyy::CallContext *ctxt)
Definition Executors.cxx:76
_object PyObject
std::ios_base::fmtflags fFlags
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
long double LongDouble_t
Definition RtypesCore.h:61
long long Long64_t
Definition RtypesCore.h:80
unsigned long long ULong64_t
Definition RtypesCore.h:81
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
char name[80]
Definition TGX11.cxx:110
#define CPYCPPYY_EXPORT
Definition CommonDefs.h:25
virtual bool SetAssignable(PyObject *)
#define I(x, y, z)
#define H(x, y, z)
PyObject * gAssign
Definition PyStrings.cxx:7
PyObject * gEmptyString
Definition PyStrings.cxx:16
std::string remove_const(const std::string &cppname)
Definition TypeManip.cxx:71
std::string clean_type(const std::string &cppname, bool template_strip=true, bool const_strip=true)
Definition TypeManip.cxx:98
PyObject * FuncPtr2StdFunction(const std::string &retType, const std::string &signature, void *address)
Definition Utility.cxx:598
Py_ssize_t ArraySize(const std::string &name)
Definition Utility.cxx:872
const std::string Compound(const std::string &name)
Definition Utility.cxx:848
Set of helper functions that are invoked from the pythonizors, on the Python side.
unsigned long PyLongOrInt_AsULong(PyObject *pyobject)
Definition Utility.cxx:131
CPYCPPYY_EXTERN bool UnregisterExecutor(const std::string &name)
PyObject * CreatePointerView(void *ptr, size_t size=(size_t) -1)
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
CPYCPPYY_EXPORT void DestroyExecutor(Executor *p)
CPYCPPYY_EXTERN bool RegisterExecutor(const std::string &name, ExecutorFactory_t)
CPYCPPYY_EXTERN Executor * CreateExecutor(const std::string &name)
std::map< std::string, ef_t > ExecFactories_t
Definition Executors.cxx:23
bool CPPInstance_Check(T *object)
PyObject * gNullPtrObject
static ExecFactories_t gExecFactories
Definition Executors.cxx:24
std::set< std::string > gIteratorTypes
PyObject * BindCppObject(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
Executor *(* ef_t)()
Definition Executors.cxx:22
CPYCPPYY_EXTERN void * CallVoidP(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, CallContext *)
ULong64_t PyLongOrInt_AsULong64(PyObject *pyobject)
Definition Utility.cxx:151
bool ReleasesGIL(CallContext *ctxt)
PyObject * BindCppObjectArray(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, Py_ssize_t *dims)
RPY_EXPORTED TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args, TCppType_t result_type)
RPY_EXPORTED TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, size_t nargs, void *args)
intptr_t TCppMethod_t
Definition cpp_cppyy.h:22
void * TCppObject_t
Definition cpp_cppyy.h:21
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
size_t TCppScope_t
Definition cpp_cppyy.h:18
RooArgList L(Args_t &&... args)
Definition RooArgList.h:156
Parameter * GetArgs(size_t sz)
Definition CallContext.h:81