32 typedef TConverter* (*ConverterFactory_t) ( Long_t size );
44 PyErr_SetString( PyExc_TypeError,
"C++ type can not be converted from memory" );
53 PyErr_SetString( PyExc_TypeError,
"C++ type can not be converted to memory" );
59 #define PYROOT_IMPLEMENT_BASIC_CONVERTER( name, type, stype, F1, F2 ) \
60 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \
62 return F1( (stype)*((type*)address) ); \
65 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \
67 type s = (type)F2( value ); \
68 if ( s == (type)-1 && PyErr_Occurred() ) \
70 *((type*)address) = (type)s; \
77 Long_t
l = PyLong_AsLong( pyobject );
79 if ( ! ( l == 0 || l == 1 ) || PyFloat_Check( pyobject ) ) {
80 PyErr_SetString( PyExc_ValueError,
"boolean value should be bool, or integer 1 or 0" );
96 if ( ! (PyLong_Check( pyobject ) || PyInt_Check( pyobject )) )
113 PyErr_Format( PyExc_TypeError,
"%s expected, got string of size " PY_SSIZE_T_FORMAT,
115 }
else if ( ! PyFloat_Check( pyobject ) ) {
116 lchar = PyLong_AsLong( pyobject );
117 if ( lchar == -1 && PyErr_Occurred() )
119 else if ( ! ( low <= lchar && lchar <= high ) ) {
120 PyErr_Format( PyExc_ValueError,
121 "integer to character: value %d not in range [%d,%d]", lchar, low, high );
125 PyErr_SetString( PyExc_TypeError,
"char or small int type expected" );
131 #define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER( name, type, F1, verifier )\
132 Bool_t PyROOT::TConst##name##RefConverter::SetArg( \
133 PyObject* pyobject, TParameter& para, TCallContext* ) \
135 if ( ! verifier( pyobject ) ) return kFALSE; \
136 type val = (type)F1( pyobject ); \
137 if ( val == (type)-1 && PyErr_Occurred() ) \
139 para.fValue.f##name = val; \
140 para.fRef = ¶.fValue.f##name; \
141 para.fTypeCode = 'r'; \
145 #define PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER( name, type, low, high )\
146 Bool_t PyROOT::TConst##name##RefConverter::SetArg( \
147 PyObject* pyobject, TParameter& para, TCallContext* ) \
150 type val = (type)ExtractChar( pyobject, #type, low, high ); \
151 if ( val == (type)-1 && PyErr_Occurred() ) \
153 para.fValue.fLong = val; \
154 para.fTypeCode = 'l'; \
161 #define PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER( name, type, low, high ) \
162 Bool_t PyROOT::T##name##Converter::SetArg( \
163 PyObject* pyobject, TParameter& para, TCallContext* ) \
166 Long_t val = ExtractChar( pyobject, #type, low, high ); \
167 if ( val == -1 && PyErr_Occurred() ) \
169 para.fValue.fLong = val; \
170 para.fTypeCode = 'l'; \
174 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \
176 return PyROOT_PyUnicode_FromFormat( "%c", *((type*)address) ); \
179 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \
181 if ( PyROOT_PyUnicode_Check( value ) ) { \
182 const char* buf = PyROOT_PyUnicode_AsString( value ); \
183 if ( PyErr_Occurred() ) \
185 int len = PyROOT_PyUnicode_GET_SIZE( value ); \
187 PyErr_Format( PyExc_TypeError, #type" expected, got string of size %d", len );\
190 *((type*)address) = (type)buf[0]; \
192 Long_t l = PyLong_AsLong( value ); \
193 if ( l == -1 && PyErr_Occurred() ) \
195 if ( ! ( low <= l && l <= high ) ) { \
196 PyErr_Format( PyExc_ValueError, \
197 "integer to character: value %ld not in range [%d,%d]", l, low, high );\
200 *((type*)address) = (type)l; \
207 Bool_t PyROOT::TLongConverter::SetArg(
212 Long_t val = PyLong_AsLong( pyobject );
213 if ( val == -1 && PyErr_Occurred() )
225 Bool_t
PyROOT::TLongRefConverter::SetArg(
229 if ( PyInt_Check( pyobject ) )
230 PyErr_SetString( PyExc_TypeError,
"use ROOT.Long for pass-by-ref of longs" );
234 #if PY_VERSION_HEX < 0x03000000
235 para.fValue.fVoidp = (
void*)&((PyIntObject*)pyobject)->ob_ival;
236 para.fTypeCode =
'V';
240 PyErr_SetString( PyExc_NotImplementedError,
"int pass-by-ref not implemented in p3" );
263 Bool_t
PyROOT::TIntRefConverter::SetArg(
267 #if PY_VERSION_HEX < 0x03000000
268 para.fValue.fVoidp = (
void*)&((PyIntObject*)pyobject)->ob_ival;
269 para.fTypeCode =
'V';
272 PyErr_SetString( PyExc_NotImplementedError,
"int pass-by-ref not implemented in p3" );
279 if ( para.fValue.fVoidp && buflen ) {
280 para.fTypeCode =
'V';
284 PyErr_SetString( PyExc_TypeError,
"use ROOT.Long for pass-by-ref of ints" );
291 Bool_t PyROOT::TBoolConverter::SetArg(
316 Bool_t
PyROOT::TULongConverter::SetArg(
320 if ( PyErr_Occurred() )
322 para.fTypeCode =
'U';
326 PyObject* PyROOT::TULongConverter::FromMemory(
void* address )
329 return PyLong_FromUnsignedLong( *((ULong_t*)address) );
332 Bool_t PyROOT::TULongConverter::ToMemory(
PyObject* value,
void* address )
336 if ( PyErr_Occurred() )
338 *((ULong_t*)address) = u;
345 PyObject* PyROOT::TUIntConverter::FromMemory(
void* address )
347 return PyLong_FromUnsignedLong( *((UInt_t*)address) );
350 Bool_t PyROOT::TUIntConverter::ToMemory(
PyObject* value,
void* address )
354 if ( PyErr_Occurred() )
357 if ( u > (ULong_t)UINT_MAX ) {
358 PyErr_SetString( PyExc_OverflowError,
"value too large for unsigned int" );
362 *((UInt_t*)address) = (
UInt_t)u;
369 Bool_t PyROOT::TFloatConverter::SetArg(
372 Double_t val = PyFloat_AsDouble( pyobject );
373 if ( val == -1.0 && PyErr_Occurred() )
385 Bool_t
PyROOT::TDoubleConverter::SetArg(
388 Double_t val = PyFloat_AsDouble( pyobject );
389 if ( val == -1.0 && PyErr_Occurred() )
391 para.fValue.fDouble = val;
392 para.fTypeCode =
'd';
401 Bool_t
PyROOT::TLongDoubleConverter::SetArg(
404 Double_t val = PyFloat_AsDouble( pyobject );
405 if ( val == -1.0 && PyErr_Occurred() )
407 para.fValue.fLongDouble = val;
408 para.fTypeCode =
'D';
417 Bool_t
PyROOT::TDoubleRefConverter::SetArg(
421 para.fValue.fVoidp = (
void*)&((PyFloatObject*)pyobject)->ob_fval;
422 para.fTypeCode =
'V';
428 if ( para.fValue.fVoidp && buflen ) {
429 para.fTypeCode =
'V';
433 PyErr_SetString( PyExc_TypeError,
"use ROOT.Double for pass-by-ref of doubles" );
448 PyErr_SetString( PyExc_SystemError,
"void/unknown arguments can\'t be set" );
455 Bool_t PyROOT::TLongLongConverter::SetArg(
458 if ( PyFloat_Check( pyobject ) ) {
461 PyErr_SetString( PyExc_ValueError,
"can not convert float to long long" );
466 if ( PyErr_Occurred() )
472 PyObject* PyROOT::TLongLongConverter::FromMemory(
void* address )
475 return PyLong_FromLongLong( *(Long64_t*)address );
478 Bool_t PyROOT::TLongLongConverter::ToMemory(
PyObject* value,
void* address )
481 Long64_t ll = PyLong_AsLongLong( value );
482 if ( ll == -1 && PyErr_Occurred() )
484 *((Long64_t*)address) = ll;
491 Bool_t PyROOT::TULongLongConverter::SetArg(
495 if ( PyErr_Occurred() )
501 PyObject* PyROOT::TULongLongConverter::FromMemory(
void* address )
507 Bool_t PyROOT::TULongLongConverter::ToMemory(
PyObject* value,
void* address )
511 if ( PyErr_Occurred() )
513 *((ULong64_t*)address) = ull;
524 if ( PyErr_Occurred() )
530 if ( fMaxSize < (UInt_t)fBuffer.size() )
531 PyErr_Warn( PyExc_RuntimeWarning, (
char*)
"string too long for char array (truncated)" );
532 else if ( fMaxSize != UINT_MAX )
533 fBuffer.resize( fMaxSize,
'\0' );
544 if ( address && *(
char**)address ) {
545 if ( fMaxSize != UINT_MAX ) {
546 std::string buf( *(
char**)address, fMaxSize );
562 if ( PyErr_Occurred() )
567 PyErr_Warn( PyExc_RuntimeWarning, (
char*)
"string too long for char array (truncated)" );
569 if ( fMaxSize != UINT_MAX )
570 strncpy( *(
char**)address, s, fMaxSize );
573 strcpy( *(
char**)address, s );
584 inline Bool_t CArraySetArg(
613 return CArraySetArg( pyobject, para,
'c',
sizeof(
char) );
621 if ( fMaxSize != UINT_MAX )
637 return CArraySetArg( pyobject, para,
'B',
sizeof(
unsigned char) );
651 if ( PyInt_CheckExact( pyobject ) || PyLong_CheckExact( pyobject ) ) {
652 Long_t val = (
Long_t)PyLong_AsLong( pyobject );
654 address = (
void*)val;
688 if ( GetAddressSpecialCase( pyobject, para.
fValue.
fVoidp ) ) {
711 if ( ! address || *(ptrdiff_t*)address == 0 ) {
735 if ( GetAddressSpecialCase( value, ptr ) ) {
736 *(
void**)address = ptr;
743 if ( ! buf || buflen == 0 )
746 *(
void**)address = buf;
752 #define PYROOT_IMPLEMENT_ARRAY_CONVERTER( name, type, code ) \
753 Bool_t PyROOT::T##name##ArrayConverter::SetArg( \
754 PyObject* pyobject, TParameter& para, TCallContext* ) \
756 return CArraySetArg( pyobject, para, code, sizeof(type) ); \
759 Bool_t PyROOT::T##name##ArrayRefConverter::SetArg( \
760 PyObject* pyobject, TParameter& para, TCallContext* ctxt ) \
762 Bool_t result = T##name##ArrayConverter::SetArg( pyobject, para, ctxt ); \
763 para.fTypeCode = 'V'; \
767 PyObject* PyROOT::T##name##ArrayConverter::FromMemory( void* address ) \
769 return BufFac_t::Instance()->PyBuffer_FromMemory( *(type**)address, fSize );\
772 Bool_t PyROOT::T##name##ArrayConverter::ToMemory( PyObject* value, void* address )\
775 int buflen = Utility::GetBuffer( value, code, sizeof(type), buf ); \
776 if ( ! buf || buflen == 0 ) \
778 if ( 0 <= fSize ) { \
779 if ( fSize < buflen/(int)sizeof(type) ) { \
780 PyErr_SetString( PyExc_ValueError, "buffer too large for value" ); \
783 memcpy( *(type**)address, buf, 0 < buflen ? ((size_t) buflen) : sizeof(type) );\
785 *(type**)address = (type*)buf; \
818 #define PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER( name, type, F1, F2 ) \
819 PyROOT::T##name##Converter::T##name##Converter( Bool_t keepControl ) : \
820 TCppObjectConverter( Cppyy::GetScope( #type ), keepControl ) {} \
822 Bool_t PyROOT::T##name##Converter::SetArg( \
823 PyObject* pyobject, TParameter& para, TCallContext* ctxt ) \
825 if ( PyROOT_PyUnicode_Check( pyobject ) ) { \
826 fBuffer = type( PyROOT_PyUnicode_AsString( pyobject ), \
827 PyROOT_PyUnicode_GET_SIZE( pyobject ) ); \
828 para.fValue.fVoidp = &fBuffer; \
829 para.fTypeCode = 'V'; \
833 if ( ! ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) ) { \
834 Bool_t result = TCppObjectConverter::SetArg( pyobject, para, ctxt ); \
835 para.fTypeCode = 'V'; \
841 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \
844 return PyROOT_PyUnicode_FromStringAndSize( ((type*)address)->F1(), ((type*)address)->F2() );\
845 Py_INCREF( PyStrings::gEmptyString ); \
846 return PyStrings::gEmptyString; \
849 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \
851 if ( PyROOT_PyUnicode_Check( value ) ) { \
852 *((type*)address) = PyROOT_PyUnicode_AsString( value ); \
856 return TCppObjectConverter::ToMemory( value, address ); \
869 if ( GetAddressSpecialCase( pyobject, para.fValue.fVoidp ) ) {
870 para.fTypeCode =
'p';
892 para.fTypeCode =
'p';
898 para.fTypeCode =
'p';
920 if ( GetAddressSpecialCase( value, ptr ) ) {
921 *(
void**)address = ptr;
937 PyObject*
result = PyObject_CallMethod( pyobj, (
char*)
"__assign__", (
char*)
"O", value );
1011 template <
bool ISREFERENCE>
1025 para.
fTypeCode = ISREFERENCE ?
'V' :
'p';
1035 template <
bool ISREFERENCE>
1044 template <
bool ISREFERENCE>
1083 if ( PyTuple_Size( pyobject ) < 1 )
1086 PyObject* first = PyTuple_GetItem( pyobject, 0 );
1117 PyErr_SetString( PyExc_NotImplementedError,
1118 "access to C-arrays of objects not yet implemented!" );
1184 if ( ! address || *(ptrdiff_t*)address == 0 ) {
1194 Bool_t PyROOT::TPyObjectConverter::SetArg(
1202 PyObject* PyROOT::TPyObjectConverter::FromMemory(
void* address )
1208 Py_INCREF( Py_None );
1212 Py_INCREF( pyobject );
1216 Bool_t PyROOT::TPyObjectConverter::ToMemory(
PyObject* value,
void* address )
1231 char typeCode = fHandlePtr ?
'p' :
'V';
1234 if ( fHandlePtr && GetAddressSpecialCase( pyobject, para.
fValue.
fVoidp ) ) {
1281 if ( !address || !
fClass )
1285 std::vector<TParameter> args;
1300 PyErr_SetString( PyExc_NotImplementedError,
"this method can not (yet) be called" );
1320 return (h->second)( size );
1328 return (h->second)( size );
1337 return (h->second)( size );
1347 if ( cpd ==
"[]" ) {
1350 return (h->second)( size );
1354 Bool_t isConst = resolvedType.substr(0, 5) ==
"const";
1355 Bool_t control = cpd ==
"&" || isConst;
1362 if ( ! methods.empty() ) {
1368 }
else if ( cpd ==
"&" ) {
1370 }
else if ( cpd ==
"*" && size <= 0 ) {
1382 if ( realType.find(
"__gnu_cxx::__normal_iterator", 0 ) == 0 )
1386 if ( cpd ==
"**" || cpd ==
"&*" )
1388 else if ( cpd ==
"*&" )
1390 else if ( cpd ==
"*" && size <= 0 )
1392 else if ( cpd ==
"&" )
1394 else if ( cpd ==
"[]" || size > 0 )
1396 else if ( cpd ==
"" )
1405 }
else if ( realType.find(
"(*)" ) != std::string::npos ||
1406 ( realType.find(
"::*)" ) != std::string::npos ) ) {
1413 if ( ! result && cpd ==
"&&" )
1418 result = (h->second)( size );
1419 else if ( ! result ) {
1421 std::stringstream s;
1422 s <<
"creating converter for unknown type \"" << fullType <<
"\"" << std::ends;
1423 PyErr_Warn( PyExc_RuntimeWarning, (
char*)s.str().c_str() );
1434 #define PYROOT_BASIC_CONVERTER_FACTORY( name ) \
1435 TConverter* Create##name##Converter( Long_t ) \
1437 return new T##name##Converter(); \
1440 #define PYROOT_ARRAY_CONVERTER_FACTORY( name ) \
1441 TConverter* Create##name##Converter( Long_t size ) \
1443 return new T##name##Converter( size ); \
1511 typedef std::pair< const char*, ConverterFactory_t > NFp_t;
1513 NFp_t factories_[] = {
1515 NFp_t(
"bool", &CreateBoolConverter ),
1516 NFp_t(
"const bool&", &CreateConstBoolRefConverter ),
1517 NFp_t(
"char", &CreateCharConverter ),
1518 NFp_t(
"const char&", &CreateConstCharRefConverter ),
1519 NFp_t(
"signed char", &CreateCharConverter ),
1520 NFp_t(
"const signed char&", &CreateConstCharRefConverter ),
1521 NFp_t(
"unsigned char", &CreateUCharConverter ),
1522 NFp_t(
"const unsigned char&", &CreateConstUCharRefConverter ),
1523 NFp_t(
"short", &CreateShortConverter ),
1524 NFp_t(
"const short&", &CreateConstShortRefConverter ),
1525 NFp_t(
"unsigned short", &CreateUShortConverter ),
1526 NFp_t(
"const unsigned short&", &CreateConstUShortRefConverter ),
1527 NFp_t(
"int", &CreateIntConverter ),
1528 NFp_t(
"int&", &CreateIntRefConverter ),
1529 NFp_t(
"const int&", &CreateConstIntRefConverter ),
1530 NFp_t(
"unsigned int", &CreateUIntConverter ),
1531 NFp_t(
"const unsigned int&", &CreateConstUIntRefConverter ),
1532 NFp_t(
"UInt_t", &CreateIntConverter ),
1533 NFp_t(
"long", &CreateLongConverter ),
1534 NFp_t(
"long&", &CreateLongRefConverter ),
1535 NFp_t(
"const long&", &CreateConstLongRefConverter ),
1536 NFp_t(
"unsigned long", &CreateULongConverter ),
1537 NFp_t(
"const unsigned long&", &CreateConstULongRefConverter ),
1538 NFp_t(
"long long", &CreateLongLongConverter ),
1539 NFp_t(
"const long long&", &CreateConstLongLongRefConverter ),
1540 NFp_t(
"Long64_t", &CreateLongLongConverter ),
1541 NFp_t(
"const Long64_t&", &CreateConstLongLongRefConverter ),
1542 NFp_t(
"unsigned long long", &CreateULongLongConverter ),
1543 NFp_t(
"const unsigned long long&", &CreateConstULongLongRefConverter ),
1544 NFp_t(
"ULong64_t", &CreateULongLongConverter ),
1545 NFp_t(
"const ULong64_t&", &CreateConstULongLongRefConverter ),
1547 NFp_t(
"float", &CreateFloatConverter ),
1548 NFp_t(
"const float&", &CreateConstFloatRefConverter ),
1549 NFp_t(
"double", &CreateDoubleConverter ),
1550 NFp_t(
"double&", &CreateDoubleRefConverter ),
1551 NFp_t(
"const double&", &CreateConstDoubleRefConverter ),
1552 NFp_t(
"long double", &CreateLongDoubleConverter ),
1553 NFp_t(
"const long double&", &CreateConstLongDoubleRefConverter ),
1554 NFp_t(
"void", &CreateVoidConverter ),
1557 NFp_t(
"bool*", &CreateBoolArrayConverter ),
1558 NFp_t(
"bool&", &CreateBoolArrayRefConverter ),
1559 NFp_t(
"const unsigned char*", &CreateCStringConverter ),
1560 NFp_t(
"unsigned char*", &CreateNonConstUCStringConverter ),
1561 NFp_t(
"short*", &CreateShortArrayConverter ),
1562 NFp_t(
"short&", &CreateShortArrayRefConverter ),
1563 NFp_t(
"unsigned short*", &CreateUShortArrayConverter ),
1564 NFp_t(
"unsigned short&", &CreateUShortArrayRefConverter ),
1565 NFp_t(
"int*", &CreateIntArrayConverter ),
1566 NFp_t(
"unsigned int*", &CreateUIntArrayConverter ),
1567 NFp_t(
"unsigned int&", &CreateUIntArrayRefConverter ),
1568 NFp_t(
"long*", &CreateLongArrayConverter ),
1569 NFp_t(
"unsigned long*", &CreateULongArrayConverter ),
1570 NFp_t(
"unsigned long&", &CreateULongArrayRefConverter ),
1571 NFp_t(
"float*", &CreateFloatArrayConverter ),
1572 NFp_t(
"float&", &CreateFloatArrayRefConverter ),
1573 NFp_t(
"double*", &CreateDoubleArrayConverter ),
1574 NFp_t(
"long long*", &CreateLongLongArrayConverter ),
1575 NFp_t(
"Long64_t*", &CreateLongLongArrayConverter ),
1576 NFp_t(
"unsigned long long*", &CreateLongLongArrayConverter ),
1577 NFp_t(
"ULong64_t*", &CreateLongLongArrayConverter ),
1578 NFp_t(
"void*", &CreateVoidArrayConverter ),
1581 NFp_t(
"const char*", &CreateCStringConverter ),
1582 NFp_t(
"char*", &CreateNonConstCStringConverter ),
1583 NFp_t(
"TString", &CreateTStringConverter ),
1584 NFp_t(
"const TString&", &CreateTStringConverter ),
1585 NFp_t(
"std::string", &CreateSTLStringConverter ),
1586 NFp_t(
"string", &CreateSTLStringConverter ),
1587 NFp_t(
"const std::string&", &CreateSTLStringConverter ),
1588 NFp_t(
"const string&", &CreateSTLStringConverter ),
1589 NFp_t(
"void*&", &CreateVoidPtrRefConverter ),
1590 NFp_t(
"void**", &CreateVoidPtrPtrConverter ),
1591 NFp_t(
"PyObject*", &CreatePyObjectConverter ),
1592 NFp_t(
"_object*", &CreatePyObjectConverter ),
1593 NFp_t(
"FILE*", &CreateVoidArrayConverter )
1596 struct InitConvFactories_t {
1598 InitConvFactories_t()
1601 int nf =
sizeof( factories_ ) /
sizeof( factories_[ 0 ] );
1602 for (
int i = 0; i < nf; ++i ) {
1603 gConvFactories[ factories_[ i ].first ] = factories_[ i ].second;
1606 } initConvFactories_;
virtual Bool_t ToMemory(PyObject *value, void *address)
could happen if no derived class override
#define PyROOT_PyUnicode_FromString
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
construct a new string and copy it in new memory
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
#define PyROOT_PyUnicode_GET_SIZE
Cppyy::TCppType_t fSmartPtrType
RooArgList L(const RooAbsArg &v1)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ instance**, set arg for call
virtual Bool_t ToMemory(PyObject *value, void *address)
just convert pointer if it is a ROOT object
virtual PyObject * FromMemory(void *address)
nothing sensible can be done, just return
as pylong
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
#define PyROOT_PyCapsule_CheckExact
std::string GetFinalName(TCppType_t type)
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
#define PYROOT_BASIC_CONVERTER_FACTORY(name)
PyObject * BindCppObjectArray(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, Int_t size)
TODO: this function exists for symmetry; need to figure out if it's useful.
virtual Bool_t ToMemory(PyObject *value, void *address)
could happen if no derived class override
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
smart pointer converter
Bool_t UseStrictOwnership(TCallContext *ctxt)
#define PY_SSIZE_T_FORMAT
virtual PyObject * FromMemory(void *address)
#define PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER(name, type, low, high)
#define PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER(name, type, low, high)
std::string ResolveName(const std::string &cppitem_name)
PyLong_FromUnsignedLongLong
union PyROOT::TParameter::Value fValue
virtual PyObject * FromMemory(void *address)
std::vector< std::vector< double > > Data
void SetSmartPtr(void *address, Cppyy::TCppType_t ptrType)
TClass * fClass
pointer to the foreign object
#define PyROOT_PyUnicode_AsStringChecked
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ array of instances, write it at
#define PyROOT_PyUnicode_AsString
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *=0)
raise a NotImplemented exception to take a method out of overload resolution
virtual PyObject * FromMemory(void *address)
Cppyy::TCppType_t ObjectIsA() const
R__EXTERN PyObject * gNullPtrObject
static Bool_t VerifyPyLong(PyObject *pyobject)
ULong_t PyLongOrInt_AsULong(PyObject *pyobject)
#define PYROOT_ARRAY_CONVERTER_FACTORY(name)
TConverter * CreateConverter(const std::string &fullType, Long_t size=-1)
static Bool_t VerifyPyBool(PyObject *pyobject)
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ instance*, write it at
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ instance**, set arg for call
Bool_t ObjectProxy_Check(T *object)
virtual Bool_t GetAddressSpecialCase(PyObject *pyobject, void *&address)
(1): "null pointer" or C++11 style nullptr
static char PyROOT_PyUnicode_AsChar(PyObject *pyobject)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
attempt base class first (i.e. passing a string), but if that fails, try a buffer ...
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ instance, write it at
Bool_t TTupleOfInstances_CheckExact(T *object)
ClassInfo_t * GetClassInfo() const
#define PyROOT_PyUnicode_FromStringAndSize
virtual PyObject * FromMemory(void *address)
assume this is a buffer access if the size is known; otherwise assume string
#define PYROOT_IMPLEMENT_ARRAY_CONVERTER(name, type, code)
ULong64_t PyLongOrInt_AsULong64(PyObject *pyobject)
Convert
to C++ unsigned long long, with bounds checking.
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, Bool_t isRef=kFALSE, Bool_t isValue=kFALSE)
only known or knowable objects will be bound (null object is ok)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ void*&, set arg for call
static Bool_t VerifyPyFloat(PyObject *)
virtual PyObject * FromMemory(void *address)
construct python object from C++ instance* read at
PyObject * PyBuffer_FromMemory(Bool_t *buf, Py_ssize_t size=-1)
virtual PyObject * FromMemory(void *address)
construct python tuple of instances from C++ array read at
Bool_t TCustomFloat_CheckExact(T *object)
void * CallR(TCppMethod_t method, TCppObject_t self, void *args)
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
TCppScope_t GetScope(const std::string &scope_name)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
attempt base class first (i.e. passing a string), but if that fails, try a buffer ...
std::string GetMethodResultType(TCppMethod_t)
#define PYROOT_IMPLEMENT_BASIC_CONVERTER(name, type, stype, F1, F2)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
just convert pointer if it is a ROOT object
virtual PyObject * FromMemory(void *address)
construct python object from C++ instance read at
R__EXTERN PyObject * gTypeCode
#define PyROOT_PyUnicode_Check
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual PyObject * FromMemory(void *address)
read a void** from address; since this is unknown, long is used (user can cast)
static Int_t ExtractChar(PyObject *pyobject, const char *tname, Int_t low, Int_t high)
static void * PyROOT_PyCapsule_GetPointer(PyObject *capsule, const char *)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ instance, set arg for call
Bool_t IsSmartPtr(const std::string &)
typedef void((*Func_t)())
static TPyBufferFactory * Instance()
int GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, Bool_t check=kTRUE)
Retrieve a linear buffer pointer from the given pyobject.
std::map< std::string, ConverterFactory_t > ConvFactories_t
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
#define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER(name, type, F1, verifier)
PyObject * BindCppObject(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, Bool_t isRef=kFALSE)
if the object is a null pointer, return a typed one (as needed for overloading)
Bool_t IsEnum(const std::string &type_name)
Bool_t TCustomInt_CheckExact(T *object)
static ECallFlags sMemoryPolicy
ConvFactories_t gConvFactories
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ void**, set arg for call
#define PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert
to C++ instance&, set arg for call
R__EXTERN PyObject * gEmptyString
const std::string Compound(const std::string &name)
Break down the compound of a fully qualified type name.