102 inline Bool_t IsTemplatedSTLClass(
const std::string&
name,
const std::string& klass ) {
103 const int nsize = (int)
name.size();
104 const int ksize = (int)klass.size();
106 return ( ( ksize < nsize &&
name.substr(0,ksize) == klass ) ||
107 ( ksize+5 < nsize &&
name.substr(5,ksize) == klass ) ) &&
108 name.find(
"::",
name.find(
">" ) ) == std::string::npos;
116 PyObject* result = PyObject_CallMethod( obj,
const_cast< char*
>( meth ),
const_cast< char*
>(
"" ) );
127 PyObject* result = PyObject_CallMethod(
128 obj,
const_cast< char*
>( meth ),
const_cast< char*
>(
"O" ), arg1 );
140 PyObject* result = PyObject_CallMethod(
141 obj,
const_cast< char*
>( meth ),
const_cast< char*
>(
"OO" ), arg1, arg2 );
152 PyObject* result = PyObject_CallMethod(
153 obj,
const_cast< char*
>( meth ),
const_cast< char*
>(
"Oi" ), arg1, arg2 );
164 if ( idx == (
Py_ssize_t)-1 && PyErr_Occurred() )
168 if ( idx >= size || ( idx < 0 && idx < -size ) ) {
169 PyErr_SetString( PyExc_IndexError,
"index out of range" );
178 pyindex = PyLong_FromLong( size + idx );
196 Py_DECREF( pyindex );
206 if ( PyObject_IsTrue( value ) == 1 ) {
207 Py_INCREF( Py_False );
211 Py_INCREF( Py_True );
223 PyErr_SetString( PyExc_TypeError,
"getattr(): attribute name must be string" );
225 PyObject* pyptr = CallPyObjMethod( self,
"__deref__" );
231 PyObject* val1 = PyObject_Str( self );
233 PyErr_Format( PyExc_AttributeError,
"%s has no attribute \'%s\'",
254 PyErr_SetString( PyExc_TypeError,
"getattr(): attribute name must be string" );
256 PyObject* pyptr = CallPyObjMethod( self,
"__follow__" );
270 return PyInt_FromLong( 0
l );
272 PyObject* found = CallPyObjMethod( self,
"FindObject", obj );
273 PyObject* result = PyInt_FromLong( PyObject_IsTrue( found ) );
284 return PyInt_FromLong( -1l );
286 return CallPyObjMethod( self,
"Compare", obj );
297 return CallPyObjMethod( self,
"IsEqual", obj );
308 return BoolNot( CallPyObjMethod( self,
"IsEqual", obj ) );
319 PyObject* result = CallPyObjMethod( self,
"__cpp_eq__", obj );
333 PyObject* result = CallPyObjMethod( self,
"__cpp_ne__", obj );
348 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O:StaticCast" ),
357 PyErr_SetString( PyExc_TypeError,
"unbound method TClass::StaticCast "
358 "must be called with a TClass instance as first argument" );
363 PyErr_SetString( PyExc_TypeError,
"could not convert argument 1 (TClass* expected)" );
370 else if ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) address = (
void*)PyLong_AsLong( pyobject );
374 PyErr_SetString( PyExc_TypeError,
"could not convert argument 2 (void* expected)" );
382 TClass* tmp = to; to = from; from = tmp;
387 PyErr_Format( PyExc_TypeError,
"unable to cast %s to %s", from->
GetName(), to->
GetName() );
407 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O|l:DynamicCast" ),
413 PyObject* ptr = meth ? PyObject_Call( meth, args, 0 ) : 0;
423 else if ( PyInt_Check( pyobject ) || PyLong_Check( pyobject ) ) address = (
void*)PyLong_AsLong( pyobject );
426 if ( PyErr_Occurred() ) {
449 for (
Py_ssize_t i = 0; i < PySequence_Size( obj ); ++i ) {
450 PyObject* item = PySequence_GetItem( obj, i );
451 PyObject* result = CallPyObjMethod( self,
"Add", item );
452 Py_XDECREF( result );
456 Py_INCREF( Py_None );
465 PyObject* result = CallPyObjMethod( self,
"Remove", obj );
469 if ( ! PyObject_IsTrue( result ) ) {
471 PyErr_SetString( PyExc_ValueError,
"list.remove(x): x not in list" );
476 Py_INCREF( Py_None );
485 PyObject*
l = CallPyObjMethod( self,
"Clone" );
489 PyObject* result = CallPyObjMethod(
l,
"extend", other );
503 Long_t imul = PyLong_AsLong( pymul );
504 if ( imul == -1 && PyErr_Occurred() )
508 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
515 for (
Long_t i = 0; i < imul; ++i ) {
528 Long_t imul = PyLong_AsLong( pymul );
529 if ( imul == -1 && PyErr_Occurred() )
534 for (
Long_t i = 0; i < imul - 1; ++i ) {
535 CallPyObjMethod( self,
"extend",
l );
548 for (
Py_ssize_t i = 0; i < PySequence_Size( self ); ++i ) {
549 PyObject* item = PySequence_GetItem( self, i );
550 PyObject* found = PyObject_RichCompare( item, obj, Py_EQ );
557 if ( PyObject_IsTrue( found ) )
570 PyErr_SetString( PyExc_TypeError,
"iteration over non-sequence" );
587 if ( PySlice_Check( index ) ) {
589 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
601 for (
Py_ssize_t i = start; i < stop; i += step ) {
608 return CallSelfIndex( self, (
PyObject*)index,
"At" );
617 if ( ! PyArg_ParseTuple( args,
618 const_cast< char*
>(
"OO:__setitem__" ), &index, &obj ) )
621 if ( PySlice_Check( index ) ) {
623 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
632 for (
Py_ssize_t i = stop - step; i >= start; i -= step ) {
636 for (
Py_ssize_t i = 0; i < PySequence_Size( obj ); ++i ) {
643 Py_INCREF( Py_None );
653 Py_DECREF( pyindex );
658 result = CallPyObjMethod( (
PyObject*)self,
"AddAt", obj, pyindex );
659 Py_DECREF( pyindex );
668 if ( PySlice_Check( index ) ) {
670 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
679 for (
Py_ssize_t i = stop - step; i >= start; i -= step ) {
683 Py_INCREF( Py_None );
692 Py_INCREF( Py_None );
702 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"lO:insert" ), &idx, &obj ) )
708 else if ( size < idx )
711 return CallPyObjMethod( self,
"AddAt", obj, idx );
719 int nArgs = PyTuple_GET_SIZE( args );
723 PyObject* result = CallSelfIndex( self, index,
"RemoveAt" );
726 }
else if ( nArgs != 1 ) {
727 PyErr_Format( PyExc_TypeError,
728 "pop() takes at most 1 argument (%d given)", nArgs );
732 return CallSelfIndex( self, PyTuple_GET_ITEM( args, 0 ),
"RemoveAt" );
740 PyObject* tup = PySequence_Tuple( self );
744 PyObject* result = CallPyObjMethod( self,
"Clear" );
745 Py_XDECREF( result );
747 for (
Py_ssize_t i = 0; i < PySequence_Size( tup ); ++i ) {
748 PyObject* retval = CallPyObjMethod( self,
"AddAt", PyTuple_GET_ITEM( tup, i ), 0 );
749 Py_XDECREF( retval );
752 Py_INCREF( Py_None );
761 if ( PyTuple_GET_SIZE( args ) == 0 && ! kw ) {
763 return CallPyObjMethod( self,
"Sort" );
768 if ( PyTuple_GET_SIZE( args ) == 1 )
769 result = CallPyObjMethod(
l,
"sort", PyTuple_GET_ITEM( args, 0 ) );
771 PyObject* pymeth = PyObject_GetAttrString(
l,
const_cast< char*
>(
"sort" ) );
772 result = PyObject_Call( pymeth, args, kw );
776 Py_XDECREF( result );
777 if ( PyErr_Occurred() ) {
782 result = CallPyObjMethod( self,
"Clear" );
783 Py_XDECREF( result );
784 result = CallPyObjMethod( self,
"extend",
l );
785 Py_XDECREF( result );
788 Py_INCREF( Py_None );
798 PyObject* index = CallPyObjMethod( self,
"IndexOf", obj );
802 if ( PyLong_AsLong( index ) < 0 ) {
804 PyErr_SetString( PyExc_ValueError,
"list.index(x): x not in list" );
815 PyObject* size = CallPyObjMethod( self,
"GetLast" );
819 long lsize = PyLong_AsLong( size );
820 if ( lsize == -1 && PyErr_Occurred() )
824 return PyInt_FromLong( lsize + 1 );
835 if ( ! PyArg_ParseTuple( args,
836 const_cast< char*
>(
"OO!:__setitem__" ), &idx, &
ObjectProxy_Type, &pyobj ) )
840 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
847 int index = (int)PyLong_AsLong( pyindex );
848 Py_DECREF( pyindex );
855 PyErr_SetString( PyExc_TypeError,
"attempt to call with null object" );
860 PyErr_Format( PyExc_TypeError,
"require object of type %s, but %s given",
871 TObject*
object = (*cla)[index];
873 TMemoryRegulator::RegisterObject( pyobj,
object );
877 Py_INCREF( Py_None );
892 static void vectoriter_dealloc( vectoriterobject* vi ) {
893 Py_XDECREF( vi->vi_vector );
894 delete vi->vi_converter;
895 PyObject_GC_Del( vi );
898 static int vectoriter_traverse( vectoriterobject* vi, visitproc visit,
void* arg ) {
899 Py_VISIT( vi->vi_vector );
903 static PyObject* vectoriter_iternext( vectoriterobject* vi ) {
904 if ( vi->vi_pos >= vi->vi_len )
909 if ( vi->vi_data && vi->vi_converter ) {
910 void* location = (
void*)((ptrdiff_t)vi->vi_data + vi->vi_stride * vi->vi_pos );
911 result = vi->vi_converter->FromMemory( location );
913 PyObject* pyindex = PyLong_FromLong( vi->vi_pos );
914 result = CallPyObjMethod( (
PyObject*)vi->vi_vector,
"_vector__at", pyindex );
915 Py_DECREF( pyindex );
922#if !defined(_MSC_VER)
923#pragma GCC diagnostic push
924#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
927 PyTypeObject VectorIter_Type = {
929 (
char*)
"ROOT.vectoriter",
930 sizeof(vectoriterobject),
932 (destructor)vectoriter_dealloc,
933 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
937 (traverseproc)vectoriter_traverse,
940 (iternextfunc)vectoriter_iternext,
942 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
943#
if PY_VERSION_HEX >= 0x02030000
946#
if PY_VERSION_HEX >= 0x02060000
949#
if PY_VERSION_HEX >= 0x03040000
952#
if PY_VERSION_HEX >= 0x03080000
954#
if PY_VERSION_HEX < 0x03090000
960#if !defined(_MSC_VER)
961#pragma GCC diagnostic pop
965 vectoriterobject* vi = PyObject_GC_New( vectoriterobject, &VectorIter_Type );
966 if ( ! vi )
return NULL;
974 if ( pyvalue_type && pyvalue_size ) {
975 PyObject* pydata = CallPyObjMethod(
v,
"data" );
977 vi->vi_data =
nullptr;
978 Py_XDECREF( pydata );
981 vi->vi_stride = PyLong_AsLong( pyvalue_size );
984 vi->vi_data =
nullptr;
985 vi->vi_converter =
nullptr;
989 Py_XDECREF( pyvalue_size );
990 Py_XDECREF( pyvalue_type );
992 vi->vi_len = vi->vi_pos = 0;
993 vi->vi_len = PySequence_Size(
v );
995 PyObject_GC_Track( vi );
1003 if ( PySlice_Check( index ) ) {
1005 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1010 PyObject* nseq = PyObject_CallObject( pyclass, NULL );
1011 Py_DECREF( pyclass );
1015 for (
Py_ssize_t i = start; i < stop; i += step ) {
1017 CallPyObjMethod( nseq,
"push_back", CallPyObjMethod( (
PyObject*)self,
"_vector__at", pyidx ) );
1024 return CallSelfIndex( self, (
PyObject*)index,
"_vector__at" );
1032 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"Oi:__setitem__" ), &idx, &bval ) )
1036 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1043 int index = (int)PyLong_AsLong( pyindex );
1044 Py_DECREF( pyindex );
1047 std::string::size_type pos = clName.find(
"vector<bool" );
1048 if ( pos != 0 && pos != 5 ) {
1049 PyErr_Format( PyExc_TypeError,
1050 "require object of type std::vector<bool>, but %s given",
1056 std::vector<bool>* vb = (std::vector<bool>*)self->
GetObject();
1059 (*vb)[ index ] = (bool)bval;
1061 Py_INCREF( Py_None );
1071 PyObject* iter = CallPyObjMethod( self,
"find", obj );
1073 PyObject* end = CallPyObjMethod( self,
"end" );
1075 if ( ! PyObject_RichCompareBool( iter, end, Py_EQ ) ) {
1076 Py_INCREF( Py_True );
1086 Py_INCREF( Py_False );
1097 PyObject* iter = CallPyObjMethod( self,
"begin" );
1099 PyObject* end = CallPyObjMethod( self,
"end" );
1105 PyObject_SetAttr( iter, PyUnicode_FromString(
"_collection"), self );
1119 if ( 0 <= idx && 0 <= size && idx < size )
1123 return CallPyObjMethod( self,
"_getitem__unchecked", obj );
1124 }
else if ( PyErr_Occurred() ) {
1127 return CallPyObjMethod( self,
"_getitem__unchecked", obj );
1129 PyErr_SetString( PyExc_IndexError,
"index out of range" );
1139 Long_t idx = PyLong_AsLong( pyindex );
1140 if ( idx == -1 && PyErr_Occurred() )
1144 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1148 if ( (
int)idx == 0 )
1150 else if ( (
int)idx == 1 )
1154 PyErr_SetString( PyExc_IndexError,
"out of bounds" );
1159#if PY_VERSION_HEX >= 0x03000000
1162 return ! PyObject_RichCompareBool( one, other, Py_EQ );
1165 static inline PyObject* PyROOT_PyString_FromCppString( std::string*
s ) {
1177#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \
1178 inline PyObject* name##GetData( PyObject* self ) { \
1179 if ( PyROOT::ObjectProxy_Check( self ) ) { \
1180 type* obj = ((type*)((ObjectProxy*)self)->GetObject()); \
1182 return PyROOT_PyString_FromCppString( obj ); \
1184 return ObjectProxy_Type.tp_str( self ); \
1187 PyErr_Format( PyExc_TypeError, "object mismatch (%s expected)", #type );\
1191 PyObject* name##StringRepr( PyObject* self ) \
1193 PyObject* data = name##GetData( self ); \
1195 PyObject* repr = PyROOT_PyUnicode_FromFormat( "\'%s\'", PyROOT_PyUnicode_AsString( data ) ); \
1196 Py_DECREF( data ); \
1202 PyObject* name##StringIsEqual( PyObject* self, PyObject* obj ) \
1204 PyObject* data = name##GetData( self ); \
1206 PyObject* result = PyObject_RichCompare( data, obj, Py_EQ ); \
1207 Py_DECREF( data ); \
1213 PyObject* name##StringIsNotEqual( PyObject* self, PyObject* obj ) \
1215 PyObject* data = name##GetData( self ); \
1217 PyObject* result = PyObject_RichCompare( data, obj, Py_NE ); \
1218 Py_DECREF( data ); \
1226#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION_CMP( type, name ) \
1227 PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \
1228 PyObject* name##StringCompare( PyObject* self, PyObject* obj ) \
1230 PyObject* data = name##GetData( self ); \
1233 result = PyObject_Compare( data, obj ); \
1234 Py_DECREF( data ); \
1236 if ( PyErr_Occurred() ) \
1238 return PyInt_FromLong( result ); \
1253 PyObject* data = CallPyObjMethod( self,
"GetName" );
1264 PyObject* next = CallPyObjMethod( self,
"Next" );
1269 if ( ! PyObject_IsTrue( next ) ) {
1271 PyErr_SetString( PyExc_StopIteration,
"" );
1288 if ( PyObject_RichCompareBool( last, self, Py_EQ ) ) {
1289 PyErr_SetString( PyExc_StopIteration,
"" );
1292 PyObject* iter = CallPyObjMethod( self,
"__postinc__",
dummy );
1295 if ( PyObject_RichCompareBool( last, iter, Py_EQ ) )
1296 PyErr_SetString( PyExc_StopIteration,
"" );
1298 next = CallPyObjMethod( iter,
"__deref__" );
1300 PyErr_SetString( PyExc_StopIteration,
"" );
1305 PyErr_SetString( PyExc_StopIteration,
"" );
1318 if (other != Py_None) {
1320 return PyObject_CallMethodObjArgs(self,
PyStrings::gEq, other,
nullptr);
1323 return PyErr_Format( PyExc_LookupError,
1324 "No operator==(const %s&, const %s&) available in the dictionary!",
1334 if (other != Py_None) {
1336 return PyObject_CallMethodObjArgs(self,
PyStrings::gNe, other,
nullptr);
1339 return PyErr_Format( PyExc_LookupError,
1340 "No operator!=(const %s&, const %s&) available in the dictionary!",
1350 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!:TDirectory::GetObject" ),
1358 PyErr_SetString( PyExc_TypeError,
1359 "TDirectory::GetObject must be called with a TDirectory instance as first argument" );
1365 ptr->
Set( address );
1367 Py_INCREF( Py_None );
1383 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!|O!i:TDirectory::WriteObject" ),
1392 PyErr_SetString( PyExc_TypeError,
1393 "TDirectory::WriteObject must be called with a TDirectory instance as first argument" );
1398 if ( option != 0 ) {
1406 return PyInt_FromLong( (
Long_t)result );
1427 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
1432 const char*
name =
tree->GetAlias( name1 );
1439 branch =
tree->GetBranch( (std::string(
name ) +
'.' ).c_str() );
1462 if ( klass && !
tree->GetLeaf(
name ) &&
1470 if ( branch && ! leaf ) {
1476 leaf = (
TLeaf*)leaves->
At( 0 );
1511 PyErr_Format( PyExc_AttributeError,
1512 "\'%s\' object has no attribute \'%s\'",
tree->IsA()->GetName(),
name );
1518 class TTreeMemberFunction :
public PyCallable {
1521 TTreeMemberFunction(
const TTreeMemberFunction& t ) :
PyCallable( t )
1524 Py_INCREF( t.fOrg );
1527 TTreeMemberFunction&
operator=(
const TTreeMemberFunction& t )
1531 Py_INCREF( t.fOrg );
1537 ~TTreeMemberFunction() { Py_DECREF( fOrg ); fOrg = 0; }
1541 virtual PyObject* GetPrototype() {
return PyObject_GetAttrString( (
PyObject*)fOrg, (
char*)
"__doc__" ); }
1542 virtual Int_t GetPriority() {
return 100; }
1543 virtual PyObject* GetCoVarNames() {
1544 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1558 class TTreeBranch :
public TTreeMemberFunction {
1563 virtual Int_t GetMaxArgs() {
return 5; }
1564 virtual PyCallable* Clone() {
return new TTreeBranch( *
this ); }
1573 int argc = PyTuple_GET_SIZE( args );
1580 PyErr_SetString( PyExc_TypeError,
1581 "TTree::Branch must be called with a TTree instance as first argument" );
1587 PyObject *bufsize = 0, *splitlevel = 0;
1590 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!OO!|O!:Branch" ),
1592 &leaflist, &PyInt_Type, &bufsize ) ) {
1596 buf = (
void*)((
ObjectProxy*)address)->GetObject();
1619 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!O|O!O!:Branch" ),
1621 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1624 PyErr_Clear(); clName = 0;
1625 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O|O!O!" ),
1627 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1633 if ( bIsMatch ==
kTRUE ) {
1650 if ( buf != 0 && klName !=
"" ) {
1654 }
else if ( argc == 4 ) {
1656 PyInt_AS_LONG( bufsize ) );
1657 }
else if ( argc == 5 ) {
1659 PyInt_AS_LONG( bufsize ), PyInt_AS_LONG( splitlevel ) );
1680 class TTreeSetBranchAddress :
public TTreeMemberFunction {
1690 virtual Int_t GetMaxArgs() {
return 2; }
1691 virtual PyCallable* Clone() {
return new TTreeSetBranchAddress( *
this ); }
1698 int argc = PyTuple_GET_SIZE( args );
1705 PyErr_SetString( PyExc_TypeError,
1706 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1713 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"SO:SetBranchAddress" ),
1714 &
name, &address ) ) {
1728 Py_INCREF( Py_None );
1745 virtual PyObject* ReportTypeError()
1747 PyErr_SetString( PyExc_TypeError,
1748 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1756 class TChainSetBranchAddress :
public TTreeSetBranchAddress {
1766 virtual Int_t GetMaxArgs() {
return 2; }
1767 virtual PyCallable* Clone() {
return new TChainSetBranchAddress( *
this ); }
1770 virtual PyObject* ReportTypeError()
1772 PyErr_SetString( PyExc_TypeError,
1773 "TChain::SetBranchAddress must be called with a TChain instance as first argument" );
1790 if ( ! (pya0 && pya1 && pya2 && pya3) ) {
1791 Py_XDECREF( pya3 ); Py_XDECREF( pya2 ); Py_XDECREF( pya1 ); Py_XDECREF( pya0 );
1796 PyObject* result = PyObject_CallFunction(
1797 pyfunc, (
char*)
"OOOOi", pya0, pya1, pya2, pya3, a4 );
1798 Py_DECREF( pya3 ); Py_DECREF( pya2 ); Py_DECREF( pya1 ); Py_DECREF( pya0 );
1802 throw std::runtime_error(
"TMinuit python fit function call failed" );
1805 Py_XDECREF( result );
1821 result = PyObject_CallFunction( pyfunc, (
char*)
"OO", pya0, pya1 );
1824 result = PyObject_CallFunction( pyfunc, (
char*)
"O", pya0 );
1832 throw std::runtime_error(
"TFN python function call failed" );
1834 d = PyFloat_AsDouble( result );
1835 Py_DECREF( result );
1853 PyObject* result = CallPyObjMethod( self,
"Scale", scale );
1857 Py_DECREF( result );
1865 class TPretendInterpreted:
public PyCallable {
1867 TPretendInterpreted(
int nArgs ) : fNArgs( nArgs ) {}
1870 Int_t GetNArgs() {
return fNArgs; }
1874 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1884 if ( ! pyobject || ! PyCallable_Check( pyobject ) ) {
1886 PyErr_Format( PyExc_ValueError,
1901 class TF1InitWithPyFunc :
public TPretendInterpreted {
1903 TF1InitWithPyFunc(
int ntf = 1 ) : TPretendInterpreted( 2 + 2*ntf ) {}
1910 "TF1::TF1(const char* name, PyObject* callable, "
1911 "Double_t xmin, Double_t xmax, Int_t npar = 0)" );
1914 virtual PyCallable* Clone() {
return new TF1InitWithPyFunc( *
this ); }
1920 int argc = PyTuple_GET_SIZE( args );
1921 const int reqNArgs = GetNArgs();
1922 if ( ! ( argc == reqNArgs || argc == reqNArgs+1 ) ) {
1923 PyErr_Format( PyExc_TypeError,
1924 "TFN::TFN(const char*, PyObject* callable, ...) =>\n"
1925 " takes at least %d and at most %d arguments (%d given)",
1926 reqNArgs, reqNArgs+1, argc );
1930 PyObject* pyfunc = PyTuple_GET_ITEM( args, 1 );
1934 if ( argc == reqNArgs+1 )
1935 npar = PyInt_AsLong( PyTuple_GET_ITEM( args, reqNArgs ) );
1938 std::vector<std::string> signature; signature.reserve( 2 );
1939 signature.push_back(
"double*" );
1940 signature.push_back(
"double*" );
1944 pyfunc, npar,
"double", signature,
"TFNPyCallback" );
1953 PyObject* newArgs = PyTuple_New( reqNArgs + 1 );
1955 for (
int iarg = 0; iarg < argc; ++iarg ) {
1956 PyObject* item = PyTuple_GET_ITEM( args, iarg );
1959 PyTuple_SET_ITEM( newArgs, iarg, item );
1965 if ( argc == reqNArgs )
1966 PyTuple_SET_ITEM( newArgs, reqNArgs, PyInt_FromLong( 0
l ) );
1972 Py_DECREF( newArgs );
1973 Py_DECREF( method );
1980 class TF2InitWithPyFunc :
public TF1InitWithPyFunc {
1982 TF2InitWithPyFunc() : TF1InitWithPyFunc( 2 ) {}
1988 "TF2::TF2(const char* name, PyObject* callable, "
1989 "Double_t xmin, Double_t xmax, "
1990 "Double_t ymin, Double_t ymax, Int_t npar = 0)" );
1993 virtual PyCallable* Clone() {
return new TF2InitWithPyFunc( *
this ); }
1998 class TF3InitWithPyFunc :
public TF1InitWithPyFunc {
2000 TF3InitWithPyFunc() : TF1InitWithPyFunc( 3 ) {}
2006 "TF3::TF3(const char* name, PyObject* callable, "
2007 "Double_t xmin, Double_t xmax, "
2008 "Double_t ymin, Double_t ymax, "
2009 "Double_t zmin, Double_t zmax, Int_t npar = 0)" );
2012 virtual PyCallable* Clone() {
return new TF3InitWithPyFunc( *
this ); }
2022 class TMinuitSetFCN :
public TPretendInterpreted {
2024 TMinuitSetFCN(
int nArgs = 1 ) : TPretendInterpreted( nArgs ) {}
2031 "TMinuit::SetFCN(PyObject* callable)" );
2034 virtual PyCallable* Clone() {
return new TMinuitSetFCN( *
this ); }
2040 int argc = PyTuple_GET_SIZE( args );
2042 PyErr_Format( PyExc_TypeError,
2043 "TMinuit::SetFCN(PyObject* callable, ...) =>\n"
2044 " takes exactly 1 argument (%d given)", argc );
2048 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2049 if ( ! IsCallable( pyfunc ) )
2053 std::vector<std::string> signature; signature.reserve( 5 );
2054 signature.push_back(
"Int_t&" );
2055 signature.push_back(
"Double_t*" );
2056 signature.push_back(
"Double_t&" );
2057 signature.push_back(
"Double_t*" );
2058 signature.push_back(
"Int_t" );
2062 pyfunc, 5,
"void", signature,
"TMinuitPyCallback" );
2075 for ( MethodProxy::Methods_t::const_iterator im = methods.begin(); im != methods.end(); ++im ) {
2076 PyObject* sig = (*im)->GetSignature();
2090 PyObject* newArgs = PyTuple_New( 1 );
2096 PyObject* result = setFCN->
Call( self, newArgs, kwds, ctxt );
2100 Py_DECREF( newArgs );
2101 Py_DECREF( method );
2106 class TMinuitFitterSetFCN :
public TMinuitSetFCN {
2108 TMinuitFitterSetFCN() : TMinuitSetFCN( 1 ) {}
2114 "TMinuitFitter::SetFCN(PyObject* callable)" );
2117 virtual PyCallable* Clone() {
return new TMinuitFitterSetFCN( *
this ); }
2123 int argc = PyTuple_GET_SIZE( args );
2125 PyErr_Format( PyExc_TypeError,
2126 "TMinuitFitter::SetFCN(PyObject* callable, ...) =>\n"
2127 " takes exactly 1 argument (%d given)", argc );
2131 return TMinuitSetFCN::Call( self, args, kwds, ctxt );
2138 void FitterPyCallback(
int& npar,
double* gin,
double&
f,
double* u,
int flag )
2144 PyObject* arg1 = BufFac_t::Instance()->PyBuffer_FromMemory( &npar );
2146 PyObject* arg2 = BufFac_t::Instance()->PyBuffer_FromMemory( gin );
2149 PyList_SetItem( arg3, 0, PyFloat_FromDouble(
f ) );
2151 PyObject* arg4 = BufFac_t::Instance()->PyBuffer_FromMemory( u, npar *
sizeof(
double) );
2154 result = PyObject_CallFunction(
2155 gFitterPyCallback, (
char*)
"OOOOi", arg1, arg2, arg3, arg4, flag );
2156 f = PyFloat_AsDouble( PyList_GetItem( arg3, 0 ) );
2158 Py_DECREF( arg4 ); Py_DECREF( arg3 ); Py_DECREF( arg2 ); Py_DECREF( arg1 );
2162 throw std::runtime_error(
"TMinuit python fit function call failed" );
2165 Py_XDECREF( result );
2168 class TFitterFitFCN :
public TPretendInterpreted {
2170 TFitterFitFCN() : TPretendInterpreted( 2 ) {}
2176 "(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2181 "TFitter::FitFCN(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2184 virtual PyCallable* Clone() {
return new TFitterFitFCN( *
this ); }
2190 int argc = PyTuple_GET_SIZE( args );
2192 PyErr_Format( PyExc_TypeError,
2193 "TFitter::FitFCN(PyObject* callable, ...) =>\n"
2194 " takes at least 1 argument (%d given)", argc );
2198 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2199 if ( ! IsCallable( pyfunc ) )
2203 Py_XDECREF( gFitterPyCallback );
2204 Py_INCREF( pyfunc );
2205 gFitterPyCallback = pyfunc;
2212 PyObject* newArgs = PyTuple_New( argc );
2214 for (
int iarg = 1; iarg < argc; ++iarg ) {
2215 PyObject* pyarg = PyTuple_GET_ITEM( args, iarg );
2217 PyTuple_SET_ITEM( newArgs, iarg, pyarg );
2224 Py_DECREF( newArgs );
2225 Py_DECREF( method );
2235 PyObject* result = CallPyObjMethod( self,
"Get", attr );
2239 if ( !PyObject_IsTrue( result ) ) {
2240 PyObject* astr = PyObject_Str( attr );
2241 PyErr_Format( PyExc_AttributeError,
"TFile object has no attribute \'%s\'",
2244 Py_DECREF( result );
2250 PyObject_SetAttr( self, attr, result );
2262 PyErr_SetString( PyExc_TypeError,
2263 "TDirectoryFile::Get must be called with a TDirectoryFile instance as first argument" );
2270 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
2286 void* addr = dirf->
Get( namecycle );
2293 PyObject *cppname = PyObject_GetAttrString((
PyObject *)self,
"__cppname__");
2297 Py_XDECREF(cppname);
2300 if (printResult.find(
"@0x") == 0) {
2302 auto method = PyObject_GetAttrString((
PyObject*)self,
"__repr__");
2303 auto res = PyObject_CallObject(method,
nullptr);
2312 void AddArrayInterface(
PyObject *pyclass, PyCFunction func)
2321 if (!PyObject_HasAttrString(
gRootModule,
"_add__array_interface__"))
return;
2323 auto f = PyObject_GetAttrString(
gRootModule,
"_add__array_interface__");
2324 auto r = PyObject_CallFunction(
f, (
char*)
"O", pyclass);
2329 template <
typename T,
char typestr>
2332 T *cobj =
reinterpret_cast<T*
>(self->
GetObject());
2335 auto dict = PyDict_New();
2338 auto pyversion = PyLong_FromLong(3);
2339 PyDict_SetItemString(dict,
"version", pyversion);
2340 Py_DECREF(pyversion);
2344 const char endianess =
'<';
2346 const char endianess =
'>';
2348 const UInt_t bytes =
sizeof(
typename T::value_type);
2350 PyDict_SetItemString(dict,
"typestr", pytypestr);
2351 Py_DECREF(pytypestr);
2354 auto pysize = PyLong_FromLong(cobj->size());
2355 auto pyshape = PyTuple_Pack(1, pysize);
2356 PyDict_SetItemString(dict,
"shape", pyshape);
2361 auto ptr =
reinterpret_cast<unsigned long long>(cobj->data());
2364 if (cobj->empty()) ptr = 1;
2366 auto pydata = PyTuple_Pack(2, pyptr, Py_False);
2367 PyDict_SetItemString(dict,
"data", pydata);
2376 return PyInt_FromLong( 3 );
2380 return PyInt_FromLong( 2 );
2420 if ( ! pyfullname ) pyfullname = PyObject_GetAttr( pyclass,
PyStrings::gName );
2422 Py_DECREF( pyfullname );
2444 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)StlSequenceIter;
2477 if (
name ==
"TObject" ) {
2488 else if (
name ==
"TClass" ) {
2498 else if (
name ==
"TCollection" ) {
2509 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)TCollectionIter;
2514 else if (
name ==
"TSeqCollection" ) {
2515 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2517 Utility::AddToClass( pyclass,
"__delitem__", (PyCFunction) TSeqCollectionDelItem, METH_O );
2521 Utility::AddToClass( pyclass,
"reverse", (PyCFunction) TSeqCollectionReverse, METH_NOARGS );
2523 METH_VARARGS | METH_KEYWORDS );
2529 else if (
name ==
"TObjArray" ) {
2533 else if (
name ==
"TClonesArray" ) {
2537 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2544 else if ( IsTemplatedSTLClass(
name,
"vector" ) || (
name.find(
"ROOT::VecOps::RVec<") == 0) ) {
2557 if (
name.find(
"vector<bool>") == std::string::npos &&
name.find(
"RVec<bool>") == std::string::npos ) {
2558 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)vector_iter;
2562 TypedefInfo_t* ti =
gInterpreter->TypedefInfo_Factory( (
name+
"::value_type").c_str() );
2565 PyObject_SetAttrString( pyclass,
"value_size", pyvalue_size );
2566 Py_DECREF( pyvalue_size );
2569 PyObject_SetAttrString( pyclass,
"value_type", pyvalue_type );
2570 Py_DECREF( pyvalue_type );
2579 std::string::size_type pos =
name.find(
"vector<bool" );
2580 if ( pos == 0 || pos == 5 ) {
2585 if (
name.find(
"ROOT::VecOps::RVec<") == 0) {
2586 }
else if (
name ==
"vector<float>") {
2587 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<float>,
'f'>);
2588 }
else if (
name ==
"vector<double>") {
2589 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<double>,
'f'>);
2590 }
else if (
name ==
"vector<int>") {
2591 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<int>,
'i'>);
2592 }
else if (
name ==
"vector<unsigned int>") {
2593 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<unsigned int>,
'u'>);
2594 }
else if (
name ==
"vector<long>") {
2595 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<long>,
'i'>);
2596 }
else if (
name ==
"vector<unsigned long>") {
2597 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<unsigned long>,
'u'>);
2601 if (
name.find(
"ROOT::VecOps::RVec<") != 0) {
2602 }
else if (
name ==
"ROOT::VecOps::RVec<float>") {
2604 }
else if (
name ==
"ROOT::VecOps::RVec<double>") {
2606 }
else if (
name ==
"ROOT::VecOps::RVec<int>") {
2608 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned int>") {
2610 }
else if (
name ==
"ROOT::VecOps::RVec<long>") {
2612 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned long>") {
2617 else if ( IsTemplatedSTLClass(
name,
"map" ) ) {
2622 else if ( IsTemplatedSTLClass(
name,
"pair" ) ) {
2628 else if (
name.find(
"iterator" ) != std::string::npos ) {
2629 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)StlIterNext;
2640 else if (
name ==
"string" ||
name ==
"std::string" ) {
2649 else if (
name ==
"TString" ) {
2660 else if (
name ==
"TObjString" ) {
2671 else if (
name ==
"TIter" ) {
2672 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)PyObject_SelfIter;
2675 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)TIterNext;
2680 else if (
name ==
"TDirectory" ) {
2689 else if (
name ==
"TDirectoryFile" ) {
2699 else if (
name ==
"TTree" ) {
2707 Py_DECREF( original ); original = 0;
2709 PyObject_SetAttrString(
2710 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2711 Py_DECREF( method ); method = 0;
2715 method =
MethodProxy_New(
"SetBranchAddress",
new TTreeSetBranchAddress( original ) );
2716 Py_DECREF( original ); original = 0;
2718 PyObject_SetAttrString(
2719 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2720 Py_DECREF( method ); method = 0;
2724 else if (
name ==
"TChain" ) {
2729 Py_DECREF( original ); original = 0;
2731 PyObject_SetAttrString(
2732 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2733 Py_DECREF( method ); method = 0;
2737 else if (
name.find(
"ROOT::RDataFrame") == 0 ||
name.find(
"ROOT::RDF::RInterface<") == 0 ) {
2738 if (PyObject_HasAttrString(
gRootModule,
"_RDataFrameAsNumpy" )) {
2739 PyObject_SetAttrString(pyclass,
"AsNumpy",
2740 PyObject_GetAttrString(
gRootModule,
"_RDataFrameAsNumpy" ));
2744 else if (
name ==
"TStyle" ) {
2750 else if (
name ==
"TH1" )
2753 else if (
name ==
"TF1" )
2756 else if (
name ==
"TF2" )
2759 else if (
name ==
"TF3" )
2762 else if (
name ==
"TFunction" )
2765 else if (
name ==
"TMinuit" )
2768 else if (
name ==
"TFitter" )
2771 else if (
name ==
"Fitter" )
2774 else if (
name ==
"TFile" ) {
2776 PyObject* attr = PyObject_GetAttrString( pyclass, (
char*)
"Open" );
2778 ((
MethodProxy*)attr)->fMethodInfo->fFlags |= TCallContext::kIsCreator;
2785 else if (
name.substr(0,8) ==
"TVector3" ) {
2792 else if (
name.substr(0,8) ==
"TVectorT" ) {
2799 else if (
name.substr(0,6) ==
"TArray" &&
name !=
"TArray" ) {
2806 else if (
name ==
"RooDataHist" )
2809 else if (
name ==
"RooSimultaneous" )
2814 PyObject* userPythonizations = PyObject_GetAttrString(
gRootModule,
"UserPythonizations" );
2815 PyObject* pythonizationScope = PyObject_GetAttrString(
gRootModule,
"PythonizationScope" );
2817 std::vector< std::string > pythonization_scopes;
2818 pythonization_scopes.push_back(
"__global__" );
2821 if ( user_scope !=
"__global__" ) {
2822 if ( PyDict_Contains( userPythonizations, pythonizationScope ) ) {
2823 pythonization_scopes.push_back( user_scope );
2829 for (
auto key = pythonization_scopes.cbegin(); key != pythonization_scopes.cend(); ++key ) {
2830 PyObject* tmp = PyDict_GetItemString( userPythonizations, key->c_str() );
2831 Py_ssize_t num_pythonizations = PyList_Size( tmp );
2833 if ( num_pythonizations )
2834 arglist = Py_BuildValue(
"O,s", pyclass,
name.c_str() );
2835 for (
Py_ssize_t i = 0; i < num_pythonizations; ++i ) {
2836 PyObject* pythonizor = PyList_GetItem( tmp, i );
2838 PyObject* result = PyObject_CallObject( pythonizor, arglist );
2843 Py_DECREF( result );
2845 Py_XDECREF( arglist );
2848 Py_DECREF( userPythonizations );
2849 Py_DECREF( pythonizationScope );
PyLong_FromUnsignedLongLong
#define PyInt_FromSsize_t
#define PyROOT_PyUnicode_Check
#define PyROOT_PyUnicode_AsString
#define PyROOT_PySliceCast
static PyObject * PyROOT_PyCapsule_New(void *cobj, const char *, void(*destr)(void *))
#define PyROOT_PyUnicode_FromString
#define PyROOT_PyUnicode_FromStringAndSize
#define PyROOT_PyUnicode_Type
#define PyVarObject_HEAD_INIT(type, size)
#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION(type, name)
#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION_CMP(type, name)
static TClass * OP2TCLASS(PyROOT::ObjectProxy *pyobj)
static RooMathCoreReg dummy
R__EXTERN Int_t gErrorIgnoreLevel
Binding & operator=(OUT(*fun)(void))
const std::string & GetName() const
std::vector< PyCallable * > Methods_t
MethodInfo_t * fMethodInfo
Cppyy::TCppType_t ObjectIsA() const
void Set(void *address, EFlags flags=kNone)
virtual Int_t GetMaxArgs()=0
virtual Int_t GetPriority()=0
virtual PyObject * GetArgDefault(Int_t)=0
virtual PyObject * GetCoVarNames()=0
virtual PyObject * Call(ObjectProxy *&self, PyObject *args, PyObject *kwds, TCallContext *ctxt=0)=0
virtual PyObject * FromMemory(void *address)
virtual PyObject * Call(ObjectProxy *&, PyObject *args, PyObject *kwds, TCallContext *ctx=0)
preliminary check in case keywords are accidently used (they are ignored otherwise)
PyObject * PyBuffer_FromMemory(Bool_t *buf, Py_ssize_t size=-1)
static TPyBufferFactory * Instance()
A Branch for the case of an object.
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
TClass * GetCurrentClass()
Return a pointer to the current type of the data member corresponding to branch element.
virtual TClass * GetTargetClass()
char * GetObject() const
Return a pointer to our object.
A TTree is a list of TBranches.
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any.
virtual char * GetAddress() const
TObjArray * GetListOfLeaves()
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
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.
Int_t Size() const
Return size of object of this class.
ClassInfo_t * GetClassInfo() const
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
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.
An array of clone (identical) objects.
TClass * GetClass() const
virtual TObject * RemoveAt(Int_t idx)
Remove object at index idx.
Collection abstract base class.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A ROOT file is structured in Directories (like a file system).
TKey * GetKey(const char *name, Short_t cycle=9999) const override
Return pointer to key with name,cycle.
void * GetObjectChecked(const char *namecycle, const char *classname) override
See documentation of TDirectoryFile::GetObjectCheck(const char *namecycle, const TClass *cl)
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Describe directory structure in memory.
virtual Int_t WriteObjectAny(const void *, const char *, const char *, Option_t *="", Int_t=0)
virtual void * GetObjectChecked(const char *namecycle, const char *classname)
See documentation of TDirectory::GetObjectCheck(const char *namecycle, const TClass *cl)
std::string GetReturnTypeNormalizedName() const
Get the normalized name of the return type.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual const char * GetClassName() const
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual void * GetValuePointer() const
virtual const char * GetTypeName() const
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
virtual Int_t GetNdata() const
TBranch * GetBranch() const
virtual Int_t GetLenStatic() const
Return the fixed length of this leaf.
Each ROOT class (see TClass) has a linked list of methods.
virtual const char * GetName() const
Returns name of object.
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
TObject * First() const
Return the object in the first slot.
TObject * At(Int_t idx) const
Collectable string class.
Mother of all ROOT objects.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Sequenceable collection abstract base class.
virtual TObject * RemoveAt(Int_t idx)
virtual void AddAt(TObject *obj, Int_t idx)=0
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const =0
TObjArray * GetElements() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
A TTree represents a columnar dataset.
TCppScope_t GetScope(const std::string &scope_name)
std::string GetFinalName(TCppType_t type)
TCppObject_t Construct(TCppType_t type)
R__EXTERN PyObject * gIter
R__EXTERN PyObject * gSetFCN
R__EXTERN PyObject * gSecond
R__EXTERN PyObject * gClass
R__EXTERN PyObject * gCppEq
R__EXTERN PyObject * gName
R__EXTERN PyObject * gSize
R__EXTERN PyObject * gGetSize
R__EXTERN PyObject * gDict
R__EXTERN PyObject * gLen
R__EXTERN PyObject * gFitFCN
R__EXTERN PyObject * gTClassDynCast
R__EXTERN PyObject * gGetItem
R__EXTERN PyObject * gBegin
R__EXTERN PyObject * gFollow
R__EXTERN PyObject * gInit
R__EXTERN PyObject * gCppNe
R__EXTERN PyObject * gEnd
R__EXTERN PyObject * gDeref
R__EXTERN PyObject * gFirst
R__EXTERN PyObject * gSetBranchAddress
R__EXTERN PyObject * gVectorAt
R__EXTERN PyObject * gCppName
R__EXTERN PyObject * ggetSize
R__EXTERN PyObject * gBranch
Bool_t AddUsingToClass(PyObject *pyclass, const char *method)
Helper to add base class methods to the derived class one (this covers the 'using' cases,...
Bool_t AddBinaryOperator(PyObject *left, PyObject *right, const char *op, const char *label, const char *alt_label=NULL, bool lazy=false)
Install the named operator (op) into the left object's class if such a function exists as a global ov...
int GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, Bool_t check=kTRUE)
Retrieve a linear buffer pointer from the given pyobject.
Bool_t AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
Add the given function to the class under name 'label'.
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.
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class).
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)
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
Retrieve scope proxy from the known ones.
void TMinuitPyCallback(void *vpyfunc, Long_t, Int_t &a0, Double_t *a1, Double_t &a2, Double_t *a3, Int_t a4)
Bool_t ObjectProxy_Check(T *object)
PyTypeObject ObjectProxy_Type
MethodProxy * MethodProxy_New(const std::string &name, std::vector< PyCallable * > &methods)
Bool_t MethodProxy_Check(T *object)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t)
Convenience function with a lookup first through the known existing proxies.
TConverter * CreateConverter(const std::string &fullType, Long_t size=-1)
PyObject * TTreeGetAttr(ObjectProxy *self, PyObject *pyname)
R__EXTERN PyObject * gRootModule
double TFNPyCallback(void *vpyfunc, Long_t npar, double *a0, double *a1)
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)
Bool_t Pythonize(PyObject *pyclass, const std::string &name)
static constexpr double s
MethodProxy::Methods_t fMethods
#define org(otri, vertexptr)