18 #include "TClassEdit.h" 29 #define TParameter PyROOT::TParameter 44 #if PY_VERSION_HEX >= 0x02050000 46 struct PyROOT_tagCDataObject {
51 static inline PyTypeObject* GetCTypesType(
const char*
name ) {
52 PyObject* ct = PyImport_ImportModule(
"ctypes" );
53 if ( ! ct )
return nullptr;
54 PyTypeObject* ct_t = (PyTypeObject*)PyObject_GetAttrString( ct, name );
67 Long_t l = PyLong_AsLong( pyobject );
69 if ( ! ( l == 0 || l == 1 ) || PyFloat_Check( pyobject ) ) {
70 PyErr_SetString( PyExc_ValueError,
"boolean value should be bool, or integer 1 or 0" );
87 if ( ! (PyLong_Check( pyobject ) || PyInt_Check( pyobject )) ) {
88 PyErr_SetString( PyExc_TypeError,
"unsigned short converion expects an integer object" );
91 Long_t l = PyLong_AsLong( pyobject );
92 if ( l < 0 || USHRT_MAX < l ) {
93 PyErr_Format( PyExc_ValueError,
"integer %ld out of range for unsigned short", l );
105 if ( ! (PyLong_Check( pyobject ) || PyInt_Check( pyobject )) ) {
106 PyErr_SetString( PyExc_TypeError,
"short int converion expects an integer object" );
109 Long_t l = PyLong_AsLong( pyobject );
110 if ( l < SHRT_MIN || SHRT_MAX < l ) {
111 PyErr_Format( PyExc_ValueError,
"integer %ld out of range for short int", l );
126 if ( ! (PyLong_Check( pyobject ) || PyInt_Check( pyobject )) ) {
127 PyErr_SetString( PyExc_TypeError,
"int/long converion expects an integer object" );
130 return (
Long_t)PyLong_AsLong( pyobject );
138 PyErr_SetString( PyExc_TypeError,
"C++ type can not be converted from memory" );
147 PyErr_SetString( PyExc_TypeError,
"C++ type can not be converted to memory" );
153 #define PYROOT_IMPLEMENT_BASIC_CONVERTER( name, type, stype, F1, F2, tc ) \ 154 Bool_t PyROOT::T##name##Converter::SetArg( \ 155 PyObject* pyobject, TParameter& para, TCallContext* ) \ 158 type val = (type)F2( pyobject ); \ 159 if ( val == (type)-1 && PyErr_Occurred() ) \ 161 para.fValue.f##name = val; \ 162 para.fTypeCode = tc; \ 166 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \ 168 return F1( (stype)*((type*)address) ); \ 171 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \ 173 type s = (type)F2( value ); \ 174 if ( s == (type)-1 && PyErr_Occurred() ) \ 176 *((type*)address) = (type)s; \ 188 PyErr_Format( PyExc_TypeError,
"%s expected, got string of size " PY_SSIZE_T_FORMAT,
190 }
else if ( ! PyFloat_Check( pyobject ) ) {
191 lchar = PyLong_AsLong( pyobject );
192 if ( lchar == -1 && PyErr_Occurred() )
194 else if ( ! ( low <= lchar && lchar <= high ) ) {
195 PyErr_Format( PyExc_ValueError,
196 "integer to character: value %d not in range [%d,%d]", lchar, low, high );
200 PyErr_SetString( PyExc_TypeError,
"char or small int type expected" );
206 #define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER( name, type, F1 )\ 207 Bool_t PyROOT::TConst##name##RefConverter::SetArg( \ 208 PyObject* pyobject, TParameter& para, TCallContext* ) \ 210 type val = (type)F1( pyobject ); \ 211 if ( val == (type)-1 && PyErr_Occurred() ) \ 213 para.fValue.f##name = val; \ 214 para.fRef = ¶.fValue.f##name; \ 215 para.fTypeCode = 'r'; \ 219 #define PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER( name, type, low, high )\ 220 Bool_t PyROOT::TConst##name##RefConverter::SetArg( \ 221 PyObject* pyobject, TParameter& para, TCallContext* ) \ 224 type val = (type)ExtractChar( pyobject, #type, low, high ); \ 225 if ( val == (type)-1 && PyErr_Occurred() ) \ 227 para.fValue.fLong = val; \ 228 para.fTypeCode = 'l'; \ 235 #define PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER( name, type, low, high ) \ 236 Bool_t PyROOT::T##name##Converter::SetArg( \ 237 PyObject* pyobject, TParameter& para, TCallContext* ) \ 240 Long_t val = ExtractChar( pyobject, #type, low, high ); \ 241 if ( val == -1 && PyErr_Occurred() ) \ 243 para.fValue.fLong = val; \ 244 para.fTypeCode = 'l'; \ 248 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \ 250 return PyROOT_PyUnicode_FromFormat( "%c", *((type*)address) ); \ 253 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \ 255 if ( PyROOT_PyUnicode_Check( value ) ) { \ 256 const char* buf = PyROOT_PyUnicode_AsString( value ); \ 257 if ( PyErr_Occurred() ) \ 259 int len = PyROOT_PyUnicode_GET_SIZE( value ); \ 261 PyErr_Format( PyExc_TypeError, #type" expected, got string of size %d", len );\ 264 *((type*)address) = (type)buf[0]; \ 266 Long_t l = PyLong_AsLong( value ); \ 267 if ( l == -1 && PyErr_Occurred() ) \ 269 if ( ! ( low <= l && l <= high ) ) { \ 270 PyErr_Format( PyExc_ValueError, \ 271 "integer to character: value %ld not in range [%d,%d]", l, low, high );\ 274 *((type*)address) = (type)l; \ 289 #if PY_VERSION_HEX < 0x03000000 291 para.fValue.fVoidp = (
void*)&((PyIntObject*)pyobject)->ob_ival;
292 para.fTypeCode =
'V';
297 #if PY_VERSION_HEX < 0x02050000 298 PyErr_SetString( PyExc_TypeError,
"use ROOT.Long for pass-by-ref of longs" );
303 static PyTypeObject* c_long_type = GetCTypesType(
"c_long" );
304 if (
Py_TYPE( pyobject ) == c_long_type ) {
305 para.fValue.fVoidp = (
void*)((PyROOT_tagCDataObject*)pyobject)->b_ptr;
306 para.fTypeCode =
'V';
310 PyErr_SetString( PyExc_TypeError,
"use ctypes.c_long for pass-by-ref of longs" );
332 Bool_t PyROOT::TIntRefConverter::SetArg(
335 #if PY_VERSION_HEX < 0x03000000 337 para.
fValue.
fVoidp = (
void*)&((PyIntObject*)pyobject)->ob_ival;
343 #if PY_VERSION_HEX >= 0x02050000 345 static PyTypeObject* c_int_type = GetCTypesType(
"c_int" );
346 if (
Py_TYPE( pyobject ) == c_int_type ) {
347 para.
fValue.
fVoidp = (
void*)((PyROOT_tagCDataObject*)pyobject)->b_ptr;
360 #if PY_VERSION_HEX < 0x02050000 361 PyErr_SetString( PyExc_TypeError,
"use ROOT.Long for pass-by-ref of ints" );
363 PyErr_SetString( PyExc_TypeError,
"use ctypes.c_int for pass-by-ref of ints" );
387 Bool_t PyROOT::TULongConverter::SetArg(
391 if ( PyErr_Occurred() )
397 PyObject* PyROOT::TULongConverter::FromMemory(
void* address )
400 return PyLong_FromUnsignedLong( *((
ULong_t*)address) );
403 Bool_t PyROOT::TULongConverter::ToMemory(
PyObject* value,
void* address )
407 if ( PyErr_Occurred() )
416 PyObject* PyROOT::TUIntConverter::FromMemory(
void* address )
418 return PyLong_FromUnsignedLong( *((
UInt_t*)address) );
421 Bool_t PyROOT::TUIntConverter::ToMemory(
PyObject* value,
void* address )
425 if ( PyErr_Occurred() )
429 PyErr_SetString( PyExc_OverflowError,
"value too large for unsigned int" );
448 Bool_t PyROOT::TDoubleRefConverter::SetArg(
452 para.
fValue.
fVoidp = (
void*)&((PyFloatObject*)pyobject)->ob_fval;
464 PyErr_SetString( PyExc_TypeError,
"use ROOT.Double for pass-by-ref of doubles" );
479 PyErr_SetString( PyExc_SystemError,
"void/unknown arguments can\'t be set" );
486 Bool_t PyROOT::TLongLongConverter::SetArg(
489 if ( PyFloat_Check( pyobject ) ) {
492 PyErr_SetString( PyExc_ValueError,
"can not convert float to long long" );
497 if ( PyErr_Occurred() )
503 PyObject* PyROOT::TLongLongConverter::FromMemory(
void* address )
506 return PyLong_FromLongLong( *(
Long64_t*)address );
509 Bool_t PyROOT::TLongLongConverter::ToMemory(
PyObject* value,
void* address )
512 Long64_t ll = PyLong_AsLongLong( value );
513 if ( ll == -1 && PyErr_Occurred() )
522 Bool_t PyROOT::TULongLongConverter::SetArg(
526 if ( PyErr_Occurred() )
532 PyObject* PyROOT::TULongLongConverter::FromMemory(
void* address )
538 Bool_t PyROOT::TULongLongConverter::ToMemory(
PyObject* value,
void* address )
542 if ( PyErr_Occurred() )
555 if ( PyErr_Occurred() )
561 if ( fMaxSize < (
UInt_t)fBuffer.size() )
562 PyErr_Warn( PyExc_RuntimeWarning, (
char*)
"string too long for char array (truncated)" );
563 else if ( fMaxSize != UINT_MAX )
564 fBuffer.resize( fMaxSize,
'\0' );
575 if ( address && *(
char**)address ) {
576 if ( fMaxSize != UINT_MAX ) {
577 std::string buf( *(
char**)address, fMaxSize );
593 if ( PyErr_Occurred() )
598 PyErr_Warn( PyExc_RuntimeWarning, (
char*)
"string too long for char array (truncated)" );
600 if ( fMaxSize != UINT_MAX )
601 strncpy( *(
char**)address, s, fMaxSize );
604 strcpy( *(
char**)address, s );
615 inline Bool_t CArraySetArg(
644 return CArraySetArg( pyobject, para,
'c',
sizeof(
char) );
652 if ( fMaxSize != UINT_MAX )
668 return CArraySetArg( pyobject, para,
'B',
sizeof(
unsigned char) );
682 if ( PyInt_CheckExact( pyobject ) || PyLong_CheckExact( pyobject ) ) {
685 address = (
void*)val;
719 if ( GetAddressSpecialCase( pyobject, para.
fValue.
fVoidp ) ) {
742 if ( ! address || *(ptrdiff_t*)address == 0 ) {
760 *(
void**)address = ((
ObjectProxy*)value)->GetObject();
766 if ( GetAddressSpecialCase( value, ptr ) ) {
767 *(
void**)address = ptr;
774 if ( ! buf || buflen == 0 )
777 *(
void**)address = buf;
783 #define PYROOT_IMPLEMENT_ARRAY_CONVERTER( name, type, code ) \ 784 Bool_t PyROOT::T##name##ArrayConverter::SetArg( \ 785 PyObject* pyobject, TParameter& para, TCallContext* ) \ 787 return CArraySetArg( pyobject, para, code, sizeof(type) ); \ 790 Bool_t PyROOT::T##name##ArrayRefConverter::SetArg( \ 791 PyObject* pyobject, TParameter& para, TCallContext* ctxt ) \ 793 Bool_t result = T##name##ArrayConverter::SetArg( pyobject, para, ctxt ); \ 794 para.fTypeCode = 'V'; \ 798 PyObject* PyROOT::T##name##ArrayConverter::FromMemory( void* address ) \ 800 return BufFac_t::Instance()->PyBuffer_FromMemory( *(type**)address, fSize );\ 803 Bool_t PyROOT::T##name##ArrayConverter::ToMemory( PyObject* value, void* address )\ 806 int buflen = Utility::GetBuffer( value, code, sizeof(type), buf ); \ 807 if ( ! buf || buflen == 0 ) \ 809 if ( 0 <= fSize ) { \ 810 if ( fSize < buflen/(int)sizeof(type) ) { \ 811 PyErr_SetString( PyExc_ValueError, "buffer too large for value" ); \ 814 memcpy( *(type**)address, buf, 0 < buflen ? ((size_t) buflen) : sizeof(type) );\ 816 *(type**)address = (type*)buf; \ 849 #define PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER( name, type, F1, F2 ) \ 850 PyROOT::T##name##Converter::T##name##Converter( Bool_t keepControl ) : \ 851 TCppObjectConverter( Cppyy::GetScope( #type ), keepControl ) {} \ 853 Bool_t PyROOT::T##name##Converter::SetArg( \ 854 PyObject* pyobject, TParameter& para, TCallContext* ctxt ) \ 856 if ( PyROOT_PyUnicode_Check( pyobject ) ) { \ 857 fBuffer = type( PyROOT_PyUnicode_AsString( pyobject ), \ 858 PyROOT_PyUnicode_GET_SIZE( pyobject ) ); \ 859 para.fValue.fVoidp = &fBuffer; \ 860 para.fTypeCode = 'V'; \ 864 if ( ! ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) ) { \ 865 Bool_t result = TCppObjectConverter::SetArg( pyobject, para, ctxt ); \ 866 para.fTypeCode = 'V'; \ 872 PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \ 875 return PyROOT_PyUnicode_FromStringAndSize( ((type*)address)->F1(), ((type*)address)->F2() );\ 876 Py_INCREF( PyStrings::gEmptyString ); \ 877 return PyStrings::gEmptyString; \ 880 Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \ 882 if ( PyROOT_PyUnicode_Check( value ) ) { \ 883 *((type*)address) = PyROOT_PyUnicode_AsString( value ); \ 887 return TCppObjectConverter::ToMemory( value, address ); \ 901 if ( GetAddressSpecialCase( pyobject, para.fValue.fVoidp ) ) {
902 para.fTypeCode =
'p';
920 pyobj->
ObjectIsA(), fClass, para.fValue.fVoidp, 1 );
924 para.fTypeCode =
'p';
930 para.fTypeCode =
'p';
952 if ( GetAddressSpecialCase( value, ptr ) ) {
953 *(
void**)address = ptr;
969 PyObject*
result = PyObject_CallMethod( pyobj, (
char*)
"__assign__", (
char*)
"O", value );
1043 template <
bool ISREFERENCE>
1061 para.
fTypeCode = ISREFERENCE ?
'V' :
'p';
1071 template <
bool ISREFERENCE>
1080 template <
bool ISREFERENCE>
1092 *(
void**)address = ((
ObjectProxy*)value)->GetObject();
1119 if ( PyTuple_Size( pyobject ) < 1 )
1153 PyErr_SetString( PyExc_NotImplementedError,
1154 "access to C-arrays of objects not yet implemented!" );
1220 if ( ! address || *(ptrdiff_t*)address == 0 ) {
1230 Bool_t PyROOT::TPyObjectConverter::SetArg(
1238 PyObject* PyROOT::TPyObjectConverter::FromMemory(
void* address )
1244 Py_INCREF( Py_None );
1248 Py_INCREF( pyobject );
1252 Bool_t PyROOT::TPyObjectConverter::ToMemory(
PyObject* value,
void* address )
1267 char typeCode = fHandlePtr ?
'p' :
'V';
1270 if ( fHandlePtr && GetAddressSpecialCase( pyobject, para.
fValue.
fVoidp ) ) {
1317 if ( !address || !fClass )
1321 std::vector<TParameter> args;
1336 PyErr_SetString( PyExc_NotImplementedError,
"this method can not (yet) be called" );
1356 return (h->second)( size );
1364 return (h->second)( size );
1368 std::string realType = TClassEdit::ShortType( resolvedType.c_str(), 1 );
1373 return (h->second)( size );
1379 realType = TClassEdit::CleanType( realType.substr( 0, realType.rfind(
"(") ).c_str(), 1 );
1383 if ( cpd ==
"[]" ) {
1386 return (h->second)( size );
1390 Bool_t isConst = resolvedType.substr(0, 5) ==
"const";
1391 Bool_t control = cpd ==
"&" || isConst;
1398 if ( ! methods.empty() ) {
1404 }
else if ( cpd ==
"&" ) {
1406 }
else if ( cpd ==
"*" && size <= 0 ) {
1418 if ( realType.find(
"__gnu_cxx::__normal_iterator", 0 ) == 0 )
1422 if ( cpd ==
"**" || cpd ==
"&*" )
1424 else if ( cpd ==
"*&" )
1426 else if ( cpd ==
"*" && size <= 0 )
1428 else if ( cpd ==
"&" )
1430 else if ( cpd ==
"[]" || size > 0 )
1432 else if ( cpd ==
"" )
1441 }
else if ( realType.find(
"(*)" ) != std::string::npos ||
1442 ( realType.find(
"::*)" ) != std::string::npos ) ) {
1449 if ( ! result && cpd ==
"&&" )
1454 result = (h->second)( size );
1455 else if ( ! result ) {
1457 std::stringstream s;
1458 s <<
"creating converter for unknown type \"" << fullType <<
"\"" << std::ends;
1459 PyErr_Warn( PyExc_RuntimeWarning, (
char*)s.str().c_str() );
1470 #define PYROOT_BASIC_CONVERTER_FACTORY( name ) \ 1471 TConverter* Create##name##Converter( Long_t ) \ 1473 return new T##name##Converter(); \ 1476 #define PYROOT_ARRAY_CONVERTER_FACTORY( name ) \ 1477 TConverter* Create##name##Converter( Long_t size ) \ 1479 return new T##name##Converter( size ); \ 1548 typedef std::pair< const char*, ConverterFactory_t > NFp_t;
1551 NFp_t factories_[] = {
1553 NFp_t(
"bool", &CreateBoolConverter ),
1554 NFp_t(
"const bool&", &CreateConstBoolRefConverter ),
1555 NFp_t(
"char", &CreateCharConverter ),
1556 NFp_t(
"const char&", &CreateConstCharRefConverter ),
1557 NFp_t(
"signed char", &CreateCharConverter ),
1558 NFp_t(
"const signed char&", &CreateConstCharRefConverter ),
1559 NFp_t(
"unsigned char", &CreateUCharConverter ),
1560 NFp_t(
"const unsigned char&", &CreateConstUCharRefConverter ),
1561 NFp_t(
"short", &CreateShortConverter ),
1562 NFp_t(
"const short&", &CreateConstShortRefConverter ),
1563 NFp_t(
"unsigned short", &CreateUShortConverter ),
1564 NFp_t(
"const unsigned short&", &CreateConstUShortRefConverter ),
1565 NFp_t(
"int", &CreateIntConverter ),
1566 NFp_t(
"int&", &CreateIntRefConverter ),
1567 NFp_t(
"const int&", &CreateConstIntRefConverter ),
1568 NFp_t(
"unsigned int", &CreateUIntConverter ),
1569 NFp_t(
"const unsigned int&", &CreateConstUIntRefConverter ),
1570 NFp_t(
"UInt_t", &CreateIntConverter ),
1571 NFp_t(
"long", &CreateLongConverter ),
1572 NFp_t(
"long&", &CreateLongRefConverter ),
1573 NFp_t(
"const long&", &CreateConstLongRefConverter ),
1574 NFp_t(
"unsigned long", &CreateULongConverter ),
1575 NFp_t(
"const unsigned long&", &CreateConstULongRefConverter ),
1576 NFp_t(
"long long", &CreateLongLongConverter ),
1577 NFp_t(
"const long long&", &CreateConstLongLongRefConverter ),
1578 NFp_t(
"Long64_t", &CreateLongLongConverter ),
1579 NFp_t(
"const Long64_t&", &CreateConstLongLongRefConverter ),
1580 NFp_t(
"unsigned long long", &CreateULongLongConverter ),
1581 NFp_t(
"const unsigned long long&", &CreateConstULongLongRefConverter ),
1582 NFp_t(
"ULong64_t", &CreateULongLongConverter ),
1583 NFp_t(
"const ULong64_t&", &CreateConstULongLongRefConverter ),
1585 NFp_t(
"float", &CreateFloatConverter ),
1586 NFp_t(
"const float&", &CreateConstFloatRefConverter ),
1587 NFp_t(
"double", &CreateDoubleConverter ),
1588 NFp_t(
"double&", &CreateDoubleRefConverter ),
1589 NFp_t(
"const double&", &CreateConstDoubleRefConverter ),
1590 NFp_t(
"long double", &CreateLongDoubleConverter ),
1591 NFp_t(
"const long double&", &CreateConstLongDoubleRefConverter ),
1592 NFp_t(
"void", &CreateVoidConverter ),
1595 NFp_t(
"bool*", &CreateBoolArrayConverter ),
1596 NFp_t(
"bool&", &CreateBoolArrayRefConverter ),
1597 NFp_t(
"const unsigned char*", &CreateCStringConverter ),
1598 NFp_t(
"unsigned char*", &CreateNonConstUCStringConverter ),
1599 NFp_t(
"short*", &CreateShortArrayConverter ),
1600 NFp_t(
"short&", &CreateShortArrayRefConverter ),
1601 NFp_t(
"unsigned short*", &CreateUShortArrayConverter ),
1602 NFp_t(
"unsigned short&", &CreateUShortArrayRefConverter ),
1603 NFp_t(
"int*", &CreateIntArrayConverter ),
1604 NFp_t(
"unsigned int*", &CreateUIntArrayConverter ),
1605 NFp_t(
"unsigned int&", &CreateUIntArrayRefConverter ),
1606 NFp_t(
"long*", &CreateLongArrayConverter ),
1607 NFp_t(
"unsigned long*", &CreateULongArrayConverter ),
1608 NFp_t(
"unsigned long&", &CreateULongArrayRefConverter ),
1609 NFp_t(
"float*", &CreateFloatArrayConverter ),
1610 NFp_t(
"float&", &CreateFloatArrayRefConverter ),
1611 NFp_t(
"double*", &CreateDoubleArrayConverter ),
1612 NFp_t(
"long long*", &CreateLongLongArrayConverter ),
1613 NFp_t(
"Long64_t*", &CreateLongLongArrayConverter ),
1614 NFp_t(
"unsigned long long*", &CreateLongLongArrayConverter ),
1615 NFp_t(
"ULong64_t*", &CreateLongLongArrayConverter ),
1616 NFp_t(
"void*", &CreateVoidArrayConverter ),
1619 NFp_t(
"const char*", &CreateCStringConverter ),
1620 NFp_t(
"char*", &CreateNonConstCStringConverter ),
1621 NFp_t(
"TString", &CreateTStringConverter ),
1622 NFp_t(
"const TString&", &CreateTStringConverter ),
1623 NFp_t(
"std::string", &CreateSTLStringConverter ),
1624 NFp_t(
"string", &CreateSTLStringConverter ),
1625 NFp_t(
"const std::string&", &CreateSTLStringConverter ),
1626 NFp_t(
"const string&", &CreateSTLStringConverter ),
1627 NFp_t(
"std::string_view", &CreateSTLStringViewConverter ),
1628 NFp_t(
"string_view", &CreateSTLStringViewConverter ),
1629 NFp_t(
"experimental::basic_string_view<char,char_traits<char> >",&CreateSTLStringViewConverter),
1630 NFp_t(
"basic_string_view<char,char_traits<char> >",&CreateSTLStringViewConverter),
1631 NFp_t(
"void*&", &CreateVoidPtrRefConverter ),
1632 NFp_t(
"void**", &CreateVoidPtrPtrConverter ),
1633 NFp_t(
"PyObject*", &CreatePyObjectConverter ),
1634 NFp_t(
"_object*", &CreatePyObjectConverter ),
1635 NFp_t(
"FILE*", &CreateVoidArrayConverter ),
1636 NFp_t(
"Float16_t", &CreateFloatConverter ),
1637 NFp_t(
"const Float16_t&", &CreateConstFloatRefConverter ),
1638 NFp_t(
"Double32_t", &CreateDoubleConverter ),
1639 NFp_t(
"Double32_t&", &CreateDoubleRefConverter ),
1640 NFp_t(
"const Double32_t&", &CreateConstDoubleRefConverter )
1644 struct InitConvFactories_t {
1646 InitConvFactories_t()
1649 int nf =
sizeof( factories_ ) /
sizeof( factories_[ 0 ] );
1650 for (
int i = 0; i < nf; ++i ) {
1651 gConvFactories[ factories_[ i ].first ] = factories_[ i ].second;
1654 } 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 <pyobject> 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 <address> as pylong
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
static Long_t PyROOT_PyLong_AsStrictLong(PyObject *pyobject)
strict python integer to C++ integer conversion
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
#define PyROOT_PyCapsule_CheckExact
std::string GetFinalName(TCppType_t type)
#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
static UShort_t PyROOT_PyLong_AsUShort(PyObject *pyobject)
range-checking python integer to C++ unsigend short int conversion
virtual PyObject * FromMemory(void *address)
void SetSmartPtr(void *address, Cppyy::TCppType_t ptrType)
ClassInfo_t * GetClassInfo() const
#define PyROOT_PyUnicode_AsStringChecked
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ array of instances, write it at <address>
#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)
R__EXTERN PyObject * gNullPtrObject
ULong_t PyLongOrInt_AsULong(PyObject *pyobject)
#define PYROOT_ARRAY_CONVERTER_FACTORY(name)
TConverter * CreateConverter(const std::string &fullType, Long_t size=-1)
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ instance*, write it at <address>
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert <pyobject> 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
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 <address>
Bool_t TTupleOfInstances_CheckExact(T *object)
#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 <pyobject> 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 <pyobject> to C++ void*&, set arg for call
virtual PyObject * FromMemory(void *address)
construct python object from C++ instance* read at <address>
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 <address>
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)
static Bool_t PyROOT_PyLong_AsBool(PyObject *pyobject)
range-checking python integer to C++ bool conversion
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)
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 <address>
R__EXTERN PyObject * gTypeCode
unsigned long long ULong64_t
#define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER(name, type, F1)
#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 <pyobject> to C++ instance, set arg for call
static Short_t PyROOT_PyLong_AsShort(PyObject *pyobject)
range-checking python integer to C++ short int conversion
Bool_t IsSmartPtr(const std::string &)
static TPyBufferFactory * Instance()
static Char_t PyROOT_PyUnicode_AsChar(PyObject *pyobject)
python string to C++ char conversion
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
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 <pyobject> 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 <pyobject> to C++ instance&, set arg for call
R__EXTERN PyObject * gEmptyString
Cppyy::TCppType_t ObjectIsA() const
#define PYROOT_IMPLEMENT_BASIC_CONVERTER(name, type, stype, F1, F2, tc)
const std::string Compound(const std::string &name)
Break down the compound of a fully qualified type name.