77 PyObject* attr = PyType_Type.tp_getattro( pyclass, pyname );
92 PyObject* attr = PyObject_GetItem( dict, pyname );
100 inline Bool_t IsTemplatedSTLClass(
const std::string&
name,
const std::string& klass ) {
101 const int nsize = (int)name.size();
102 const int ksize = (int)klass.size();
104 return ( ( ksize < nsize && name.substr(0,ksize) == klass ) ||
105 ( ksize+5 < nsize && name.substr(5,ksize) == klass ) ) &&
106 name.find(
"::", name.find(
">" ) ) == std::string::npos;
114 PyObject* result = PyObject_CallMethod( obj, const_cast< char* >( meth ), const_cast< char* >(
"" ) );
125 PyObject* result = PyObject_CallMethod(
126 obj, const_cast< char* >( meth ), const_cast< char* >(
"O" ), arg1 );
138 PyObject* result = PyObject_CallMethod(
139 obj, const_cast< char* >( meth ), const_cast< char* >(
"OO" ), arg1, arg2 );
150 PyObject* result = PyObject_CallMethod(
151 obj, const_cast< char* >( meth ), const_cast< char* >(
"Oi" ), arg1, arg2 );
162 if ( idx == (
Py_ssize_t)-1 && PyErr_Occurred() )
166 if ( idx >= size || ( idx < 0 && idx < -size ) ) {
167 PyErr_SetString( PyExc_IndexError,
"index out of range" );
176 pyindex = PyLong_FromLong( size + idx );
194 Py_DECREF( pyindex );
204 if ( PyObject_IsTrue( value ) == 1 ) {
205 Py_INCREF( Py_False );
209 Py_INCREF( Py_True );
221 PyErr_SetString( PyExc_TypeError,
"getattr(): attribute name must be string" );
223 PyObject* pyptr = CallPyObjMethod(
self,
"__deref__" );
229 PyObject* val1 = PyObject_Str(
self );
230 PyObject* val2 = PyObject_Str( name );
231 PyErr_Format( PyExc_AttributeError,
"%s has no attribute \'%s\'",
240 PyObject* result = PyObject_GetAttr( pyptr, name );
252 PyErr_SetString( PyExc_TypeError,
"getattr(): attribute name must be string" );
254 PyObject* pyptr = CallPyObjMethod(
self,
"__follow__" );
258 PyObject* result = PyObject_GetAttr( pyptr, name );
268 return PyInt_FromLong( 0
l );
270 PyObject* found = CallPyObjMethod(
self,
"FindObject", obj );
271 PyObject* result = PyInt_FromLong( PyObject_IsTrue( found ) );
282 return PyInt_FromLong( -1
l );
284 return CallPyObjMethod(
self,
"Compare", obj );
295 return CallPyObjMethod(
self,
"IsEqual", obj );
306 return BoolNot( CallPyObjMethod(
self,
"IsEqual", obj ) );
317 PyObject* result = CallPyObjMethod(
self,
"__cpp_eq__", obj );
331 PyObject* result = CallPyObjMethod(
self,
"__cpp_ne__", obj );
346 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"O!O:StaticCast" ),
355 PyErr_SetString( PyExc_TypeError,
"unbound method TClass::StaticCast " 356 "must be called with a TClass instance as first argument" );
361 PyErr_SetString( PyExc_TypeError,
"could not convert argument 1 (TClass* expected)" );
368 else if ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) address = (
void*)PyLong_AsLong( pyobject );
372 PyErr_SetString( PyExc_TypeError,
"could not convert argument 2 (void* expected)" );
380 TClass* tmp = to; to = from; from = tmp;
385 PyErr_Format( PyExc_TypeError,
"unable to cast %s to %s", from->
GetName(), to->
GetName() );
405 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"O!O|l:DynamicCast" ),
411 PyObject* ptr = meth ? PyObject_Call( meth, args, 0 ) : 0;
421 else if ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) address = (
void*)PyLong_AsLong( pyobject );
424 if ( PyErr_Occurred() ) {
447 for (
Py_ssize_t i = 0; i < PySequence_Size( obj ); ++i ) {
448 PyObject* item = PySequence_GetItem( obj, i );
449 PyObject* result = CallPyObjMethod(
self,
"Add", item );
450 Py_XDECREF( result );
454 Py_INCREF( Py_None );
463 PyObject* result = CallPyObjMethod(
self,
"Remove", obj );
467 if ( ! PyObject_IsTrue( result ) ) {
469 PyErr_SetString( PyExc_ValueError,
"list.remove(x): x not in list" );
474 Py_INCREF( Py_None );
483 PyObject*
l = CallPyObjMethod(
self,
"Clone" );
487 PyObject* result = CallPyObjMethod( l,
"extend", other );
501 Long_t imul = PyLong_AsLong( pymul );
502 if ( imul == -1 && PyErr_Occurred() )
505 if ( ! self->GetObject() ) {
506 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
513 for (
Long_t i = 0; i < imul; ++i ) {
526 Long_t imul = PyLong_AsLong( pymul );
527 if ( imul == -1 && PyErr_Occurred() )
532 for (
Long_t i = 0; i < imul - 1; ++i ) {
533 CallPyObjMethod(
self,
"extend", l );
546 for (
Py_ssize_t i = 0; i < PySequence_Size(
self ); ++i ) {
547 PyObject* item = PySequence_GetItem(
self, i );
548 PyObject* found = PyObject_RichCompare( item, obj, Py_EQ );
555 if ( PyObject_IsTrue( found ) )
567 if ( ! self->GetObject() ) {
568 PyErr_SetString( PyExc_TypeError,
"iteration over non-sequence" );
585 if ( PySlice_Check( index ) ) {
586 if ( ! self->GetObject() ) {
587 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
599 for (
Py_ssize_t i = start; i < stop; i += step ) {
606 return CallSelfIndex(
self, (
PyObject*)index,
"At" );
615 if ( ! PyArg_ParseTuple( args,
616 const_cast< char* >(
"OO:__setitem__" ), &index, &obj ) )
619 if ( PySlice_Check( index ) ) {
620 if ( ! self->GetObject() ) {
621 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
630 for (
Py_ssize_t i = stop - step; i >= start; i -= step ) {
634 for (
Py_ssize_t i = 0; i < PySequence_Size( obj ); ++i ) {
641 Py_INCREF( Py_None );
651 Py_DECREF( pyindex );
656 result = CallPyObjMethod( (
PyObject*)
self,
"AddAt", obj, pyindex );
657 Py_DECREF( pyindex );
666 if ( PySlice_Check( index ) ) {
667 if ( ! self->GetObject() ) {
668 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
677 for (
Py_ssize_t i = stop - step; i >= start; i -= step ) {
681 Py_INCREF( Py_None );
690 Py_INCREF( Py_None );
700 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"lO:insert" ), &idx, &obj ) )
706 else if ( size < idx )
709 return CallPyObjMethod(
self,
"AddAt", obj, idx );
717 int nArgs = PyTuple_GET_SIZE( args );
721 PyObject* result = CallSelfIndex(
self, index,
"RemoveAt" );
724 }
else if ( nArgs != 1 ) {
725 PyErr_Format( PyExc_TypeError,
726 "pop() takes at most 1 argument (%d given)", nArgs );
730 return CallSelfIndex(
self, PyTuple_GET_ITEM( args, 0 ),
"RemoveAt" );
738 PyObject* tup = PySequence_Tuple(
self );
742 PyObject* result = CallPyObjMethod(
self,
"Clear" );
743 Py_XDECREF( result );
745 for (
Py_ssize_t i = 0; i < PySequence_Size( tup ); ++i ) {
746 PyObject* retval = CallPyObjMethod(
self,
"AddAt", PyTuple_GET_ITEM( tup, i ), 0 );
747 Py_XDECREF( retval );
750 Py_INCREF( Py_None );
759 if ( PyTuple_GET_SIZE( args ) == 0 && ! kw ) {
761 return CallPyObjMethod(
self,
"Sort" );
766 if ( PyTuple_GET_SIZE( args ) == 1 )
767 result = CallPyObjMethod( l,
"sort", PyTuple_GET_ITEM( args, 0 ) );
769 PyObject* pymeth = PyObject_GetAttrString( l, const_cast< char* >(
"sort" ) );
770 result = PyObject_Call( pymeth, args, kw );
774 Py_XDECREF( result );
775 if ( PyErr_Occurred() ) {
780 result = CallPyObjMethod(
self,
"Clear" );
781 Py_XDECREF( result );
782 result = CallPyObjMethod(
self,
"extend", l );
783 Py_XDECREF( result );
786 Py_INCREF( Py_None );
796 PyObject* index = CallPyObjMethod(
self,
"IndexOf", obj );
800 if ( PyLong_AsLong( index ) < 0 ) {
802 PyErr_SetString( PyExc_ValueError,
"list.index(x): x not in list" );
813 PyObject* size = CallPyObjMethod(
self,
"GetLast" );
817 long lsize = PyLong_AsLong( size );
818 if ( lsize == -1 && PyErr_Occurred() )
822 return PyInt_FromLong( lsize + 1 );
833 if ( ! PyArg_ParseTuple( args,
834 const_cast< char* >(
"OO!:__setitem__" ), &idx, &
ObjectProxy_Type, &pyobj ) )
837 if ( ! self->GetObject() ) {
838 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
845 int index = (int)PyLong_AsLong( pyindex );
846 Py_DECREF( pyindex );
853 PyErr_SetString( PyExc_TypeError,
"attempt to call with null object" );
858 PyErr_Format( PyExc_TypeError,
"require object of type %s, but %s given",
869 TObject*
object = (*cla)[index];
875 Py_INCREF( Py_None );
890 static void vectoriter_dealloc( vectoriterobject* vi ) {
891 Py_XDECREF( vi->vi_vector );
892 delete vi->vi_converter;
893 PyObject_GC_Del( vi );
896 static int vectoriter_traverse( vectoriterobject* vi, visitproc visit,
void* arg ) {
897 Py_VISIT( vi->vi_vector );
901 static PyObject* vectoriter_iternext( vectoriterobject* vi ) {
902 if ( vi->vi_pos >= vi->vi_len )
907 if ( vi->vi_data && vi->vi_converter ) {
908 void* location = (
void*)((ptrdiff_t)vi->vi_data + vi->vi_stride * vi->vi_pos );
909 result = vi->vi_converter->FromMemory( location );
911 PyObject* pyindex = PyLong_FromLong( vi->vi_pos );
912 result = CallPyObjMethod( (
PyObject*)vi->vi_vector,
"_vector__at", pyindex );
913 Py_DECREF( pyindex );
920 PyTypeObject VectorIter_Type = {
922 (
char*)
"ROOT.vectoriter",
923 sizeof(vectoriterobject),
925 (destructor)vectoriter_dealloc,
926 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
930 (traverseproc)vectoriter_traverse,
933 (iternextfunc)vectoriter_iternext,
935 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
936 #
if PY_VERSION_HEX >= 0x02030000
939 #
if PY_VERSION_HEX >= 0x02060000
942 #
if PY_VERSION_HEX >= 0x03040000
948 vectoriterobject* vi = PyObject_GC_New( vectoriterobject, &VectorIter_Type );
949 if ( ! vi )
return NULL;
957 if ( pyvalue_type && pyvalue_size ) {
958 PyObject* pydata = CallPyObjMethod( v,
"data" );
960 vi->vi_data =
nullptr;
961 Py_XDECREF( pydata );
964 vi->vi_stride = PyLong_AsLong( pyvalue_size );
967 vi->vi_data =
nullptr;
968 vi->vi_converter =
nullptr;
972 Py_XDECREF( pyvalue_size );
973 Py_XDECREF( pyvalue_type );
975 vi->vi_len = vi->vi_pos = 0;
976 vi->vi_len = PySequence_Size( v );
978 PyObject_GC_Track( vi );
986 if ( PySlice_Check( index ) ) {
987 if ( ! self->GetObject() ) {
988 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
993 PyObject* nseq = PyObject_CallObject( pyclass, NULL );
994 Py_DECREF( pyclass );
998 for (
Py_ssize_t i = start; i < stop; i += step ) {
1000 CallPyObjMethod( nseq,
"push_back", CallPyObjMethod( (
PyObject*)
self,
"_vector__at", pyidx ) );
1007 return CallSelfIndex(
self, (
PyObject*)index,
"_vector__at" );
1015 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"Oi:__setitem__" ), &idx, &bval ) )
1018 if ( ! self->GetObject() ) {
1019 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1026 int index = (int)PyLong_AsLong( pyindex );
1027 Py_DECREF( pyindex );
1030 std::string::size_type pos = clName.find(
"vector<bool" );
1031 if ( pos != 0 && pos != 5 ) {
1032 PyErr_Format( PyExc_TypeError,
1033 "require object of type std::vector<bool>, but %s given",
1039 std::vector<bool>* vb = (std::vector<bool>*)self->GetObject();
1042 (*vb)[ index ] = (bool)bval;
1044 Py_INCREF( Py_None );
1054 PyObject* iter = CallPyObjMethod(
self,
"find", obj );
1056 PyObject* end = CallPyObjMethod(
self,
"end" );
1058 if ( ! PyObject_RichCompareBool( iter, end, Py_EQ ) ) {
1059 Py_INCREF( Py_True );
1069 Py_INCREF( Py_False );
1080 PyObject* iter = CallPyObjMethod(
self,
"begin" );
1082 PyObject* end = CallPyObjMethod(
self,
"end" );
1088 PyObject_SetAttr( iter, PyUnicode_FromString(
"_collection"),
self );
1102 if ( 0 <= idx && 0 <= size && idx < size )
1106 return CallPyObjMethod(
self,
"_getitem__unchecked", obj );
1107 }
else if ( PyErr_Occurred() ) {
1110 return CallPyObjMethod(
self,
"_getitem__unchecked", obj );
1112 PyErr_SetString( PyExc_IndexError,
"index out of range" );
1122 Long_t idx = PyLong_AsLong( pyindex );
1123 if ( idx == -1 && PyErr_Occurred() )
1127 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1131 if ( (
int)idx == 0 )
1133 else if ( (
int)idx == 1 )
1137 PyErr_SetString( PyExc_IndexError,
"out of bounds" );
1142 #if PY_VERSION_HEX >= 0x03000000 1145 return ! PyObject_RichCompareBool( one, other, Py_EQ );
1148 static inline PyObject* PyROOT_PyString_FromCppString( std::string*
s ) {
1152 static inline PyObject* PyROOT_PyString_FromCppString( TString* s ) {
1160 #define PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \ 1161 inline PyObject* name##GetData( PyObject* self ) { \ 1162 if ( PyROOT::ObjectProxy_Check( self ) ) { \ 1163 type* obj = ((type*)((ObjectProxy*)self)->GetObject()); \ 1165 return PyROOT_PyString_FromCppString( obj ); \ 1167 return ObjectProxy_Type.tp_str( self ); \ 1170 PyErr_Format( PyExc_TypeError, "object mismatch (%s expected)", #type );\ 1174 PyObject* name##StringRepr( PyObject* self ) \ 1176 PyObject* data = name##GetData( self ); \ 1178 PyObject* repr = PyROOT_PyUnicode_FromFormat( "\'%s\'", PyROOT_PyUnicode_AsString( data ) ); \ 1179 Py_DECREF( data ); \ 1185 PyObject* name##StringIsEqual( PyObject* self, PyObject* obj ) \ 1187 PyObject* data = name##GetData( self ); \ 1189 PyObject* result = PyObject_RichCompare( data, obj, Py_EQ ); \ 1190 Py_DECREF( data ); \ 1196 PyObject* name##StringIsNotEqual( PyObject* self, PyObject* obj ) \ 1198 PyObject* data = name##GetData( self ); \ 1200 PyObject* result = PyObject_RichCompare( data, obj, Py_NE ); \ 1201 Py_DECREF( data ); \ 1209 #define PYROOT_IMPLEMENT_STRING_PYTHONIZATION_CMP( type, name ) \ 1210 PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \ 1211 PyObject* name##StringCompare( PyObject* self, PyObject* obj ) \ 1213 PyObject* data = name##GetData( self ); \ 1216 result = PyObject_Compare( data, obj ); \ 1217 Py_DECREF( data ); \ 1219 if ( PyErr_Occurred() ) \ 1221 return PyInt_FromLong( result ); \ 1247 PyObject* next = CallPyObjMethod(
self,
"Next" );
1252 if ( ! PyObject_IsTrue( next ) ) {
1254 PyErr_SetString( PyExc_StopIteration,
"" );
1271 if ( PyObject_RichCompareBool( last,
self, Py_EQ ) ) {
1272 PyErr_SetString( PyExc_StopIteration,
"" );
1275 PyObject* iter = CallPyObjMethod(
self,
"__postinc__", dummy );
1278 if ( PyObject_RichCompareBool( last, iter, Py_EQ ) )
1279 PyErr_SetString( PyExc_StopIteration,
"" );
1281 next = CallPyObjMethod( iter,
"__deref__" );
1283 PyErr_SetString( PyExc_StopIteration,
"" );
1288 PyErr_SetString( PyExc_StopIteration,
"" );
1301 return PyErr_Format( PyExc_LookupError,
1302 "No operator==(const %s&, const %s&) available in the dictionary!",
1312 return PyErr_Format( PyExc_LookupError,
1313 "No operator!=(const %s&, const %s&) available in the dictionary!",
1323 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"O!O!:TDirectory::GetObject" ),
1331 PyErr_SetString( PyExc_TypeError,
1332 "TDirectory::GetObject must be called with a TDirectory instance as first argument" );
1338 ptr->
Set( address );
1340 Py_INCREF( Py_None );
1356 if ( ! PyArg_ParseTuple( args, const_cast< char* >(
"O!O!|O!i:TDirectory::WriteObject" ),
1365 PyErr_SetString( PyExc_TypeError,
1366 "TDirectory::WriteObject must be called with a TDirectory instance as first argument" );
1371 if ( option != 0 ) {
1379 return PyInt_FromLong( (
Long_t)result );
1400 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
1405 const char*
name = tree->GetAlias( name1 );
1406 if ( ! name ) name = name1;
1409 TBranch* branch = tree->GetBranch( name );
1412 branch = tree->GetBranch( (std::string( name ) +
'.' ).c_str() );
1435 if ( klass && ! tree->GetLeaf( name ) &&
1442 TLeaf* leaf = tree->GetLeaf( name );
1443 if ( branch && ! leaf ) {
1444 leaf = branch->
GetLeaf( name );
1449 leaf = (
TLeaf*)leaves->
At( 0 );
1484 PyErr_Format( PyExc_AttributeError,
1485 "\'%s\' object has no attribute \'%s\'", tree->IsA()->GetName(),
name );
1491 class TTreeMemberFunction :
public PyCallable {
1494 TTreeMemberFunction(
const TTreeMemberFunction& t ) :
PyCallable( t )
1497 Py_INCREF( t.fOrg );
1500 TTreeMemberFunction&
operator=(
const TTreeMemberFunction& t )
1504 Py_INCREF( t.fOrg );
1510 ~TTreeMemberFunction() { Py_DECREF( fOrg ); fOrg = 0; }
1514 virtual PyObject* GetPrototype() {
return PyObject_GetAttrString( (
PyObject*)fOrg, (
char*)
"__doc__" ); }
1515 virtual Int_t GetPriority() {
return 100; }
1516 virtual PyObject* GetCoVarNames() {
1517 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1531 class TTreeBranch :
public TTreeMemberFunction {
1536 virtual Int_t GetMaxArgs() {
return 5; }
1537 virtual PyCallable* Clone() {
return new TTreeBranch( *
this ); }
1546 int argc = PyTuple_GET_SIZE( args );
1553 PyErr_SetString( PyExc_TypeError,
1554 "TTree::Branch must be called with a TTree instance as first argument" );
1560 PyObject *bufsize = 0, *splitlevel = 0;
1563 if ( PyArg_ParseTuple( args, const_cast< char* >(
"O!OO!|O!:Branch" ),
1565 &leaflist, &PyInt_Type, &bufsize ) ) {
1569 buf = (
void*)((
ObjectProxy*)address)->GetObject();
1592 if ( PyArg_ParseTuple( args, const_cast< char* >(
"O!O!O|O!O!:Branch" ),
1594 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1597 PyErr_Clear(); clName = 0;
1598 if ( PyArg_ParseTuple( args, const_cast< char* >(
"O!O|O!O!" ),
1600 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1606 if ( bIsMatch ==
kTRUE ) {
1623 if ( buf != 0 && klName !=
"" ) {
1627 }
else if ( argc == 4 ) {
1629 PyInt_AS_LONG( bufsize ) );
1630 }
else if ( argc == 5 ) {
1632 PyInt_AS_LONG( bufsize ), PyInt_AS_LONG( splitlevel ) );
1653 class TTreeSetBranchAddress :
public TTreeMemberFunction {
1655 TTreeSetBranchAddress(
MethodProxy*
org ) : TTreeMemberFunction( org ) {}
1663 virtual Int_t GetMaxArgs() {
return 2; }
1664 virtual PyCallable* Clone() {
return new TTreeSetBranchAddress( *
this ); }
1671 int argc = PyTuple_GET_SIZE( args );
1678 PyErr_SetString( PyExc_TypeError,
1679 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1686 if ( PyArg_ParseTuple( args, const_cast< char* >(
"SO:SetBranchAddress" ),
1687 &name, &address ) ) {
1701 Py_INCREF( Py_None );
1718 virtual PyObject* ReportTypeError()
1720 PyErr_SetString( PyExc_TypeError,
1721 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1729 class TChainSetBranchAddress :
public TTreeSetBranchAddress {
1731 TChainSetBranchAddress(
MethodProxy*
org ) : TTreeSetBranchAddress( org ) {}
1739 virtual Int_t GetMaxArgs() {
return 2; }
1740 virtual PyCallable* Clone() {
return new TChainSetBranchAddress( *
this ); }
1743 virtual PyObject* ReportTypeError()
1745 PyErr_SetString( PyExc_TypeError,
1746 "TChain::SetBranchAddress must be called with a TChain instance as first argument" );
1763 if ( ! (pya0 && pya1 && pya2 && pya3) ) {
1764 Py_XDECREF( pya3 ); Py_XDECREF( pya2 ); Py_XDECREF( pya1 ); Py_XDECREF( pya0 );
1769 PyObject* result = PyObject_CallFunction(
1770 pyfunc, (
char*)
"OOOOi", pya0, pya1, pya2, pya3, a4 );
1771 Py_DECREF( pya3 ); Py_DECREF( pya2 ); Py_DECREF( pya1 ); Py_DECREF( pya0 );
1775 throw std::runtime_error(
"TMinuit python fit function call failed" );
1778 Py_XDECREF( result );
1794 result = PyObject_CallFunction( pyfunc, (
char*)
"OO", pya0, pya1 );
1797 result = PyObject_CallFunction( pyfunc, (
char*)
"O", pya0 );
1805 throw std::runtime_error(
"TFN python function call failed" );
1807 d = PyFloat_AsDouble( result );
1808 Py_DECREF( result );
1826 PyObject* result = CallPyObjMethod(
self,
"Scale", scale );
1830 Py_DECREF( result );
1838 class TPretendInterpreted:
public PyCallable {
1840 TPretendInterpreted(
int nArgs ) : fNArgs( nArgs ) {}
1843 Int_t GetNArgs() {
return fNArgs; }
1844 virtual Int_t GetPriority() {
return 100; }
1845 virtual Int_t GetMaxArgs() {
return GetNArgs()+1; }
1846 virtual PyObject* GetCoVarNames() {
1847 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1857 if ( ! pyobject || ! PyCallable_Check( pyobject ) ) {
1859 PyErr_Format( PyExc_ValueError,
1874 class TF1InitWithPyFunc :
public TPretendInterpreted {
1876 TF1InitWithPyFunc(
int ntf = 1 ) : TPretendInterpreted( 2 + 2*ntf ) {}
1883 "TF1::TF1(const char* name, PyObject* callable, " 1884 "Double_t xmin, Double_t xmax, Int_t npar = 0)" );
1887 virtual PyCallable* Clone() {
return new TF1InitWithPyFunc( *
this ); }
1893 int argc = PyTuple_GET_SIZE( args );
1894 const int reqNArgs = GetNArgs();
1895 if ( ! ( argc == reqNArgs || argc == reqNArgs+1 ) ) {
1896 PyErr_Format( PyExc_TypeError,
1897 "TFN::TFN(const char*, PyObject* callable, ...) =>\n" 1898 " takes at least %d and at most %d arguments (%d given)",
1899 reqNArgs, reqNArgs+1, argc );
1903 PyObject* pyfunc = PyTuple_GET_ITEM( args, 1 );
1907 if ( argc == reqNArgs+1 )
1908 npar = PyInt_AsLong( PyTuple_GET_ITEM( args, reqNArgs ) );
1911 std::vector<std::string> signature; signature.reserve( 2 );
1912 signature.push_back(
"double*" );
1913 signature.push_back(
"double*" );
1917 pyfunc, npar,
"double", signature,
"TFNPyCallback" );
1926 PyObject* newArgs = PyTuple_New( reqNArgs + 1 );
1928 for (
int iarg = 0; iarg < argc; ++iarg ) {
1929 PyObject* item = PyTuple_GET_ITEM( args, iarg );
1932 PyTuple_SET_ITEM( newArgs, iarg, item );
1938 if ( argc == reqNArgs )
1939 PyTuple_SET_ITEM( newArgs, reqNArgs, PyInt_FromLong( 0
l ) );
1945 Py_DECREF( newArgs );
1946 Py_DECREF( method );
1953 class TF2InitWithPyFunc :
public TF1InitWithPyFunc {
1955 TF2InitWithPyFunc() : TF1InitWithPyFunc( 2 ) {}
1961 "TF2::TF2(const char* name, PyObject* callable, " 1962 "Double_t xmin, Double_t xmax, " 1963 "Double_t ymin, Double_t ymax, Int_t npar = 0)" );
1966 virtual PyCallable* Clone() {
return new TF2InitWithPyFunc( *
this ); }
1971 class TF3InitWithPyFunc :
public TF1InitWithPyFunc {
1973 TF3InitWithPyFunc() : TF1InitWithPyFunc( 3 ) {}
1979 "TF3::TF3(const char* name, PyObject* callable, " 1980 "Double_t xmin, Double_t xmax, " 1981 "Double_t ymin, Double_t ymax, " 1982 "Double_t zmin, Double_t zmax, Int_t npar = 0)" );
1985 virtual PyCallable* Clone() {
return new TF3InitWithPyFunc( *
this ); }
1995 class TMinuitSetFCN :
public TPretendInterpreted {
1997 TMinuitSetFCN(
int nArgs = 1 ) : TPretendInterpreted( nArgs ) {}
2004 "TMinuit::SetFCN(PyObject* callable)" );
2007 virtual PyCallable* Clone() {
return new TMinuitSetFCN( *
this ); }
2013 int argc = PyTuple_GET_SIZE( args );
2015 PyErr_Format( PyExc_TypeError,
2016 "TMinuit::SetFCN(PyObject* callable, ...) =>\n" 2017 " takes exactly 1 argument (%d given)", argc );
2021 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2022 if ( ! IsCallable( pyfunc ) )
2026 std::vector<std::string> signature; signature.reserve( 5 );
2027 signature.push_back(
"Int_t&" );
2028 signature.push_back(
"Double_t*" );
2029 signature.push_back(
"Double_t&" );
2030 signature.push_back(
"Double_t*" );
2031 signature.push_back(
"Int_t" );
2035 pyfunc, 5,
"void", signature,
"TMinuitPyCallback" );
2048 for ( MethodProxy::Methods_t::const_iterator im = methods.begin(); im != methods.end(); ++im ) {
2049 PyObject* sig = (*im)->GetSignature();
2063 PyObject* newArgs = PyTuple_New( 1 );
2069 PyObject* result = setFCN->
Call(
self, newArgs, kwds, ctxt );
2073 Py_DECREF( newArgs );
2074 Py_DECREF( method );
2079 class TMinuitFitterSetFCN :
public TMinuitSetFCN {
2081 TMinuitFitterSetFCN() : TMinuitSetFCN( 1 ) {}
2087 "TMinuitFitter::SetFCN(PyObject* callable)" );
2090 virtual PyCallable* Clone() {
return new TMinuitFitterSetFCN( *
this ); }
2096 int argc = PyTuple_GET_SIZE( args );
2098 PyErr_Format( PyExc_TypeError,
2099 "TMinuitFitter::SetFCN(PyObject* callable, ...) =>\n" 2100 " takes exactly 1 argument (%d given)", argc );
2104 return TMinuitSetFCN::Call(
self, args, kwds, ctxt );
2111 void FitterPyCallback(
int& npar,
double* gin,
double&
f,
double* u,
int flag )
2122 PyList_SetItem( arg3, 0, PyFloat_FromDouble( f ) );
2127 result = PyObject_CallFunction(
2128 gFitterPyCallback, (
char*)
"OOOOi", arg1, arg2, arg3, arg4, flag );
2129 f = PyFloat_AsDouble( PyList_GetItem( arg3, 0 ) );
2131 Py_DECREF( arg4 ); Py_DECREF( arg3 ); Py_DECREF( arg2 ); Py_DECREF( arg1 );
2135 throw std::runtime_error(
"TMinuit python fit function call failed" );
2138 Py_XDECREF( result );
2141 class TFitterFitFCN :
public TPretendInterpreted {
2143 TFitterFitFCN() : TPretendInterpreted( 2 ) {}
2149 "(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2154 "TFitter::FitFCN(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2157 virtual PyCallable* Clone() {
return new TFitterFitFCN( *
this ); }
2163 int argc = PyTuple_GET_SIZE( args );
2165 PyErr_Format( PyExc_TypeError,
2166 "TFitter::FitFCN(PyObject* callable, ...) =>\n" 2167 " takes at least 1 argument (%d given)", argc );
2171 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2172 if ( ! IsCallable( pyfunc ) )
2176 Py_XDECREF( gFitterPyCallback );
2177 Py_INCREF( pyfunc );
2178 gFitterPyCallback = pyfunc;
2185 PyObject* newArgs = PyTuple_New( argc );
2187 for (
int iarg = 1; iarg < argc; ++iarg ) {
2188 PyObject* pyarg = PyTuple_GET_ITEM( args, iarg );
2190 PyTuple_SET_ITEM( newArgs, iarg, pyarg );
2197 Py_DECREF( newArgs );
2198 Py_DECREF( method );
2208 PyObject* result = CallPyObjMethod(
self,
"Get", attr );
2212 if ( !PyObject_IsTrue( result ) ) {
2213 PyObject* astr = PyObject_Str( attr );
2214 PyErr_Format( PyExc_AttributeError,
"TFile object has no attribute \'%s\'",
2217 Py_DECREF( result );
2223 PyObject_SetAttr(
self, attr, result );
2235 PyErr_SetString( PyExc_TypeError,
2236 "TDirectoryFile::Get must be called with a TDirectoryFile instance as first argument" );
2243 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
2259 void* addr = dirf->
Get( namecycle );
2264 void AddArrayInterface(
PyObject *pyclass, PyCFunction func)
2269 template <
typename dtype>
2273 PyDict_SetItemString(dict,
"version", PyLong_FromLong(3));
2275 const char endianess =
'<';
2277 const char endianess =
'>';
2279 const UInt_t bytes =
sizeof(dtype);
2280 PyDict_SetItemString(dict,
"typestr",
2285 template <
typename dtype,
char typestr>
2288 std::vector<dtype> *cobj = (std::vector<dtype> *)(self->GetObject());
2290 PyObject *dict = FillArrayInterfaceDict<dtype>(typestr);
2291 PyDict_SetItemString(dict,
"shape", PyTuple_Pack(1, PyLong_FromLong(cobj->size())));
2292 PyDict_SetItemString(dict,
"data",
2293 PyTuple_Pack(2, PyLong_FromLong(reinterpret_cast<long>(cobj->data())), Py_False));
2298 template <
typename dtype,
char typestr>
2302 RVec<dtype> *cobj = (RVec<dtype> *)(self->GetObject());
2304 PyObject *dict = FillArrayInterfaceDict<dtype>(typestr);
2305 PyDict_SetItemString(dict,
"shape", PyTuple_Pack(1, PyLong_FromLong(cobj->size())));
2306 PyDict_SetItemString(dict,
"data",
2307 PyTuple_Pack(2, PyLong_FromLong(reinterpret_cast<long>(cobj->data())), Py_False));
2314 return PyInt_FromLong( 3 );
2318 return PyInt_FromLong( 2 );
2355 if ( ! pyfullname ) pyfullname = PyObject_GetAttr( pyclass,
PyStrings::gName );
2357 Py_DECREF( pyfullname );
2379 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)StlSequenceIter;
2412 if ( name ==
"TObject" ) {
2423 else if ( name ==
"TClass" ) {
2433 else if ( name ==
"TCollection" ) {
2444 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)TCollectionIter;
2449 else if ( name ==
"TSeqCollection" ) {
2450 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2452 Utility::AddToClass( pyclass,
"__delitem__", (PyCFunction) TSeqCollectionDelItem, METH_O );
2456 Utility::AddToClass( pyclass,
"reverse", (PyCFunction) TSeqCollectionReverse, METH_NOARGS );
2458 METH_VARARGS | METH_KEYWORDS );
2464 else if ( name ==
"TObjArray" ) {
2468 else if ( name ==
"TClonesArray" ) {
2472 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2479 else if ( IsTemplatedSTLClass( name,
"vector" ) ) {
2491 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)vector_iter;
2494 TypedefInfo_t* ti =
gInterpreter->TypedefInfo_Factory( (name+
"::value_type").c_str() );
2497 PyObject_SetAttrString( pyclass,
"value_size", pyvalue_size );
2498 Py_DECREF( pyvalue_size );
2501 PyObject_SetAttrString( pyclass,
"value_type", pyvalue_type );
2502 Py_DECREF( pyvalue_type );
2511 std::string::size_type pos = name.find(
"vector<bool" );
2512 if ( pos == 0 || pos == 5 ) {
2517 if (name.find(
"<float>") != std::string::npos) {
2518 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<float, 'f'>);
2519 }
else if (name.find(
"<double>") != std::string::npos) {
2520 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<double, 'f'>);
2521 }
else if (name.find(
"<int>") != std::string::npos) {
2522 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<int, 'i'>);
2523 }
else if (name.find(
"<unsigned int>") != std::string::npos) {
2524 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<unsigned int, 'u'>);
2525 }
else if (name.find(
"<long>") != std::string::npos) {
2526 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<long, 'i'>);
2527 }
else if (name.find(
"<unsigned long>") != std::string::npos) {
2528 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<unsigned long, 'u'>);
2533 else if ( IsTemplatedSTLClass( name,
"map" ) ) {
2538 else if ( IsTemplatedSTLClass( name,
"pair" ) ) {
2544 else if ( name.find(
"iterator" ) != std::string::npos ) {
2545 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)StlIterNext;
2556 else if ( name ==
"string" || name ==
"std::string" ) {
2565 else if ( name ==
"TString" ) {
2576 else if ( name ==
"TObjString" ) {
2587 else if ( name ==
"TIter" ) {
2588 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)PyObject_SelfIter;
2591 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)TIterNext;
2596 else if ( name ==
"TDirectory" ) {
2605 else if ( name ==
"TDirectoryFile" ) {
2612 else if ( name ==
"TTree" ) {
2620 Py_DECREF( original ); original = 0;
2622 PyObject_SetAttrString(
2623 pyclass, const_cast< char* >( method->
GetName().c_str() ), (
PyObject*)method );
2624 Py_DECREF( method ); method = 0;
2628 method =
MethodProxy_New(
"SetBranchAddress",
new TTreeSetBranchAddress( original ) );
2629 Py_DECREF( original ); original = 0;
2631 PyObject_SetAttrString(
2632 pyclass, const_cast< char* >( method->
GetName().c_str() ), (
PyObject*)method );
2633 Py_DECREF( method ); method = 0;
2637 else if ( name ==
"TChain" ) {
2642 Py_DECREF( original ); original = 0;
2644 PyObject_SetAttrString(
2645 pyclass, const_cast< char* >( method->
GetName().c_str() ), (
PyObject*)method );
2646 Py_DECREF( method ); method = 0;
2650 else if ( name ==
"TStyle" ) {
2656 else if ( name ==
"TH1" )
2659 else if ( name ==
"TF1" )
2662 else if ( name ==
"TF2" )
2665 else if ( name ==
"TF3" )
2668 else if ( name ==
"TFunction" )
2671 else if ( name ==
"TMinuit" )
2674 else if ( name ==
"TFitter" )
2677 else if ( name ==
"Fitter" )
2680 else if ( name ==
"TFile" ) {
2682 PyObject* attr = PyObject_GetAttrString( pyclass, (
char*)
"Open" );
2692 else if ( name.substr(0,8) ==
"TVector3" ) {
2699 else if ( name.substr(0,8) ==
"TVectorT" ) {
2706 else if ( name.substr(0,6) ==
"TArray" && name !=
"TArray" ) {
2713 else if ( name ==
"RooDataHist" )
2716 else if ( name ==
"RooSimultaneous" )
2719 else if (name.find(
"RVec<") != std::string::npos) {
2721 if (name.find(
"<float>") != std::string::npos) {
2722 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<float, 'f'>);
2723 }
else if (name.find(
"<double>") != std::string::npos) {
2724 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<double, 'f'>);
2725 }
else if (name.find(
"<int>") != std::string::npos) {
2726 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<int, 'i'>);
2727 }
else if (name.find(
"<unsigned int>") != std::string::npos) {
2728 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<unsigned int, 'u'>);
2729 }
else if (name.find(
"<long>") != std::string::npos) {
2730 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<long, 'i'>);
2731 }
else if (name.find(
"<unsigned long>") != std::string::npos) {
2732 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<unsigned long, 'u'>);
2738 PyObject* userPythonizations = PyObject_GetAttrString(
gRootModule,
"UserPythonizations" );
2739 PyObject* pythonizationScope = PyObject_GetAttrString(
gRootModule,
"PythonizationScope" );
2741 std::vector< std::string > pythonization_scopes;
2742 pythonization_scopes.push_back(
"__global__" );
2745 if ( user_scope !=
"__global__" ) {
2746 if ( PyDict_Contains( userPythonizations, pythonizationScope ) ) {
2747 pythonization_scopes.push_back( user_scope );
2753 for (
auto key = pythonization_scopes.cbegin(); key != pythonization_scopes.cend(); ++key ) {
2754 PyObject* tmp = PyDict_GetItemString( userPythonizations, key->c_str() );
2755 Py_ssize_t num_pythonizations = PyList_Size( tmp );
2757 if ( num_pythonizations )
2758 arglist = Py_BuildValue(
"O,s", pyclass, name.c_str() );
2759 for (
Py_ssize_t i = 0; i < num_pythonizations; ++i ) {
2760 PyObject* pythonizor = PyList_GetItem( tmp, i );
2762 PyObject* result = PyObject_CallObject( pythonizor, arglist );
2767 Py_DECREF( result );
2769 Py_XDECREF( arglist );
2772 Py_DECREF( userPythonizations );
2773 Py_DECREF( pythonizationScope );
R__EXTERN PyObject * gFirst
R__EXTERN PyObject * gCppEq
virtual const char * GetName() const
Returns name of object.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any. ...
virtual void Add(TObject *obj)
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Bool_t AddBinaryOperator(PyObject *left, PyObject *right, const char *op, const char *label, const char *alt_label=NULL)
Install the named operator (op) into the left object's class if such a function exists as a global ov...
R__EXTERN PyObject * gInit
#define PyROOT_PyUnicode_FromString
R__EXTERN PyObject * gIter
R__EXTERN PyObject * gDict
R__EXTERN PyObject * gGetSize
R__EXTERN Int_t gErrorIgnoreLevel
virtual TClass * GetTargetClass()
Collectable string class.
static Bool_t RegisterObject(ObjectProxy *pyobj, TObject *object)
start tracking <object> proxied by <pyobj>
R__EXTERN PyObject * gTClassDynCast
R__EXTERN PyObject * gSize
virtual const char * GetClassName() const
virtual TKey * GetKey(const char *name, Short_t cycle=9999) const
Return pointer to key with name,cycle.
virtual const char * GetTypeName() const
R__EXTERN PyObject * gFollow
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
MethodProxy * MethodProxy_New(const std::string &name, std::vector< PyCallable * > &methods)
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
R__EXTERN PyObject * gSetFCN
std::string GetFinalName(TCppType_t type)
R__EXTERN PyObject * gBranch
std::vector< PyCallable *> Methods_t
R__EXTERN PyObject * gFitFCN
R__EXTERN PyObject * gEnd
#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION(type, name)
R__EXTERN PyObject * gCppNe
PyObject * TTreeGetAttr(ObjectProxy *self, PyObject *pyname)
R__EXTERN PyObject * gVectorAt
TObject * At(Int_t idx) const
#define PyInt_FromSsize_t
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
R__EXTERN PyObject * gDeref
virtual TObject * RemoveAt(Int_t idx)
virtual void * GetObjectChecked(const char *namecycle, const char *classname)
See documentation of TDirectory::GetObjectCheck(const char *namecycle, const TClass *cl) ...
#define PyVarObject_HEAD_INIT(type, size)
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Sequenceable collection abstract base class.
MethodProxy::Methods_t fMethods
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
R__EXTERN PyObject * gRootModule
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
std::string GetReturnTypeNormalizedName() const
Get the normalized name of the return type.
virtual PyObject * FromMemory(void *address)
ClassInfo_t * GetClassInfo() const
virtual Int_t WriteObjectAny(const void *, const char *, const char *, Option_t *="", Int_t=0)
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class)...
#define PyROOT_PyUnicode_Type
#define PyROOT_PyUnicode_AsString
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual TObject * RemoveAt(Int_t idx)
Remove object at index idx.
#define PyROOT_PySliceCast
A "std::vector"-like collection of values implementing handy operation to analyse them...
TObject * First() const
Return the object in the first slot.
TConverter * CreateConverter(const std::string &fullType, Long_t size=-1)
PyTypeObject ObjectProxy_Type
const TString & GetString() const
Bool_t ObjectProxy_Check(T *object)
R__EXTERN PyObject * gClass
R__EXTERN PyObject * gBegin
A ROOT file is structured in Directories (like a file system).
char * GetObject() const
Return a pointer to our object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Collection abstract base class.
#define PyROOT_PyUnicode_FromStringAndSize
Int_t Size() const
Return size of object of this class.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TClass * GetCurrentClass()
Return a pointer to the current type of the data member corresponding to branch element.
virtual void * GetValuePointer() const
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)
The ROOT global object gROOT contains a list of all defined classes.
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
virtual Int_t GetLenStatic() const
Return the fixed length of this leaf.
PyObject * PyBuffer_FromMemory(Bool_t *buf, Py_ssize_t size=-1)
A Branch for the case of an object.
MethodInfo_t * fMethodInfo
virtual PyObject * Call(ObjectProxy *&self, PyObject *args, PyObject *kwds, TCallContext *ctxt=0)=0
PyObject * CreateScopeProxy(Cppyy::TCppScope_t)
Convenience function with a lookup first through the known existing proxies.
R__EXTERN PyObject * gGetItem
TCppScope_t GetScope(const std::string &scope_name)
const std::string & GetName() const
R__EXTERN PyObject * gName
Describe directory structure in memory.
static TClass * OP2TCLASS(PyROOT::ObjectProxy *pyobj)
static RooMathCoreReg dummy
R__EXTERN PyObject * gLen
Bool_t AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
Add the given function to the class under name 'label'.
static constexpr double s
#define PyROOT_PyUnicode_Check
TObjArray * GetListOfLeaves()
virtual void * GetObjectChecked(const char *namecycle, const char *classname)
See documentation of TDirectoryFile::GetObjectCheck(const char *namecycle, const TClass *cl) ...
virtual void AddAt(TObject *obj, Int_t idx)=0
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.
#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION_CMP(type, name)
Bool_t AddUsingToClass(PyObject *pyclass, const char *method)
Helper to add base class methods to the derived class one (this covers the 'using' cases...
R__EXTERN PyObject * gCppName
TClass * GetClass() const
Binding & operator=(OUT(*fun)(void))
virtual TObject * At(Int_t idx) const =0
#define org(otri, vertexptr)
Mother of all ROOT objects.
TObjArray * GetElements() const
An array of clone (identical) objects.
static TPyBufferFactory * Instance()
R__EXTERN PyObject * gSecond
int GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, Bool_t check=kTRUE)
Retrieve a linear buffer pointer from the given pyobject.
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
Retrieve scope proxy from the known ones.
Each ROOT class (see TClass) has a linked list of methods.
void * CreateWrapperMethod(PyObject *pyfunc, Long_t user, const char *retType, const std::vector< std::string > &signature, const char *callback)
Compile a function on the fly and return a function pointer for use on C-APIs.
Bool_t MethodProxy_Check(T *object)
virtual char * GetAddress() const
double TFNPyCallback(void *vpyfunc, Long_t npar, double *a0, double *a1)
R__EXTERN PyObject * ggetSize
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
TCppObject_t Construct(TCppType_t type)
static PyObject * PyROOT_PyCapsule_New(void *cobj, const char *, void(*destr)(void *))
R__EXTERN PyObject * gSetBranchAddress
TBranch * GetBranch() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A TTree is a list of TBranches.
void TMinuitPyCallback(void *vpyfunc, Long_t, Int_t &a0, Double_t *a1, Double_t &a2, Double_t *a3, Int_t a4)
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)
void Set(void *address, EFlags flags=kNone)
Cppyy::TCppType_t ObjectIsA() const
Bool_t Pythonize(PyObject *pyclass, const std::string &name)
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
virtual Int_t GetNdata() const