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 PyTypeObject VectorIter_Type = {
924 (
char*)
"ROOT.vectoriter",
925 sizeof(vectoriterobject),
927 (destructor)vectoriter_dealloc,
928 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
932 (traverseproc)vectoriter_traverse,
935 (iternextfunc)vectoriter_iternext,
937 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
938#
if PY_VERSION_HEX >= 0x02030000
941#
if PY_VERSION_HEX >= 0x02060000
944#
if PY_VERSION_HEX >= 0x03040000
950 vectoriterobject* vi = PyObject_GC_New( vectoriterobject, &VectorIter_Type );
951 if ( ! vi )
return NULL;
959 if ( pyvalue_type && pyvalue_size ) {
960 PyObject* pydata = CallPyObjMethod(
v,
"data" );
962 vi->vi_data =
nullptr;
963 Py_XDECREF( pydata );
966 vi->vi_stride = PyLong_AsLong( pyvalue_size );
969 vi->vi_data =
nullptr;
970 vi->vi_converter =
nullptr;
974 Py_XDECREF( pyvalue_size );
975 Py_XDECREF( pyvalue_type );
977 vi->vi_len = vi->vi_pos = 0;
978 vi->vi_len = PySequence_Size(
v );
980 PyObject_GC_Track( vi );
988 if ( PySlice_Check( index ) ) {
990 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
995 PyObject* nseq = PyObject_CallObject( pyclass, NULL );
996 Py_DECREF( pyclass );
1000 for (
Py_ssize_t i = start; i < stop; i += step ) {
1002 CallPyObjMethod( nseq,
"push_back", CallPyObjMethod( (
PyObject*)self,
"_vector__at", pyidx ) );
1009 return CallSelfIndex( self, (
PyObject*)index,
"_vector__at" );
1017 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"Oi:__setitem__" ), &idx, &bval ) )
1021 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1028 int index = (int)PyLong_AsLong( pyindex );
1029 Py_DECREF( pyindex );
1032 std::string::size_type pos = clName.find(
"vector<bool" );
1033 if ( pos != 0 && pos != 5 ) {
1034 PyErr_Format( PyExc_TypeError,
1035 "require object of type std::vector<bool>, but %s given",
1041 std::vector<bool>* vb = (std::vector<bool>*)self->
GetObject();
1044 (*vb)[ index ] = (bool)bval;
1046 Py_INCREF( Py_None );
1056 PyObject* iter = CallPyObjMethod( self,
"find", obj );
1058 PyObject* end = CallPyObjMethod( self,
"end" );
1060 if ( ! PyObject_RichCompareBool( iter, end, Py_EQ ) ) {
1061 Py_INCREF( Py_True );
1071 Py_INCREF( Py_False );
1082 PyObject* iter = CallPyObjMethod( self,
"begin" );
1084 PyObject* end = CallPyObjMethod( self,
"end" );
1090 PyObject_SetAttr( iter, PyUnicode_FromString(
"_collection"), self );
1104 if ( 0 <= idx && 0 <= size && idx < size )
1108 return CallPyObjMethod( self,
"_getitem__unchecked", obj );
1109 }
else if ( PyErr_Occurred() ) {
1112 return CallPyObjMethod( self,
"_getitem__unchecked", obj );
1114 PyErr_SetString( PyExc_IndexError,
"index out of range" );
1124 Long_t idx = PyLong_AsLong( pyindex );
1125 if ( idx == -1 && PyErr_Occurred() )
1129 PyErr_SetString( PyExc_TypeError,
"unsubscriptable object" );
1133 if ( (
int)idx == 0 )
1135 else if ( (
int)idx == 1 )
1139 PyErr_SetString( PyExc_IndexError,
"out of bounds" );
1144#if PY_VERSION_HEX >= 0x03000000
1147 return ! PyObject_RichCompareBool( one, other, Py_EQ );
1150 static inline PyObject* PyROOT_PyString_FromCppString( std::string*
s ) {
1154 static inline PyObject* PyROOT_PyString_FromCppString( TString*
s ) {
1162#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \
1163 inline PyObject* name##GetData( PyObject* self ) { \
1164 if ( PyROOT::ObjectProxy_Check( self ) ) { \
1165 type* obj = ((type*)((ObjectProxy*)self)->GetObject()); \
1167 return PyROOT_PyString_FromCppString( obj ); \
1169 return ObjectProxy_Type.tp_str( self ); \
1172 PyErr_Format( PyExc_TypeError, "object mismatch (%s expected)", #type );\
1176 PyObject* name##StringRepr( PyObject* self ) \
1178 PyObject* data = name##GetData( self ); \
1180 PyObject* repr = PyROOT_PyUnicode_FromFormat( "\'%s\'", PyROOT_PyUnicode_AsString( data ) ); \
1181 Py_DECREF( data ); \
1187 PyObject* name##StringIsEqual( PyObject* self, PyObject* obj ) \
1189 PyObject* data = name##GetData( self ); \
1191 PyObject* result = PyObject_RichCompare( data, obj, Py_EQ ); \
1192 Py_DECREF( data ); \
1198 PyObject* name##StringIsNotEqual( PyObject* self, PyObject* obj ) \
1200 PyObject* data = name##GetData( self ); \
1202 PyObject* result = PyObject_RichCompare( data, obj, Py_NE ); \
1203 Py_DECREF( data ); \
1211#define PYROOT_IMPLEMENT_STRING_PYTHONIZATION_CMP( type, name ) \
1212 PYROOT_IMPLEMENT_STRING_PYTHONIZATION( type, name ) \
1213 PyObject* name##StringCompare( PyObject* self, PyObject* obj ) \
1215 PyObject* data = name##GetData( self ); \
1218 result = PyObject_Compare( data, obj ); \
1219 Py_DECREF( data ); \
1221 if ( PyErr_Occurred() ) \
1223 return PyInt_FromLong( result ); \
1249 PyObject* next = CallPyObjMethod( self,
"Next" );
1254 if ( ! PyObject_IsTrue( next ) ) {
1256 PyErr_SetString( PyExc_StopIteration,
"" );
1273 if ( PyObject_RichCompareBool( last, self, Py_EQ ) ) {
1274 PyErr_SetString( PyExc_StopIteration,
"" );
1277 PyObject* iter = CallPyObjMethod( self,
"__postinc__",
dummy );
1280 if ( PyObject_RichCompareBool( last, iter, Py_EQ ) )
1281 PyErr_SetString( PyExc_StopIteration,
"" );
1283 next = CallPyObjMethod( iter,
"__deref__" );
1285 PyErr_SetString( PyExc_StopIteration,
"" );
1290 PyErr_SetString( PyExc_StopIteration,
"" );
1303 return PyErr_Format( PyExc_LookupError,
1304 "No operator==(const %s&, const %s&) available in the dictionary!",
1314 return PyErr_Format( PyExc_LookupError,
1315 "No operator!=(const %s&, const %s&) available in the dictionary!",
1325 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!:TDirectory::GetObject" ),
1333 PyErr_SetString( PyExc_TypeError,
1334 "TDirectory::GetObject must be called with a TDirectory instance as first argument" );
1340 ptr->
Set( address );
1342 Py_INCREF( Py_None );
1358 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!|O!i:TDirectory::WriteObject" ),
1367 PyErr_SetString( PyExc_TypeError,
1368 "TDirectory::WriteObject must be called with a TDirectory instance as first argument" );
1373 if ( option != 0 ) {
1381 return PyInt_FromLong( (
Long_t)result );
1402 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
1407 const char*
name =
tree->GetAlias( name1 );
1414 branch =
tree->GetBranch( (std::string(
name ) +
'.' ).c_str() );
1437 if ( klass && !
tree->GetLeaf(
name ) &&
1445 if ( branch && ! leaf ) {
1451 leaf = (
TLeaf*)leaves->
At( 0 );
1486 PyErr_Format( PyExc_AttributeError,
1487 "\'%s\' object has no attribute \'%s\'",
tree->IsA()->GetName(),
name );
1493 class TTreeMemberFunction :
public PyCallable {
1496 TTreeMemberFunction(
const TTreeMemberFunction& t ) :
PyCallable( t )
1499 Py_INCREF( t.fOrg );
1502 TTreeMemberFunction&
operator=(
const TTreeMemberFunction& t )
1506 Py_INCREF( t.fOrg );
1512 ~TTreeMemberFunction() { Py_DECREF( fOrg ); fOrg = 0; }
1516 virtual PyObject* GetPrototype() {
return PyObject_GetAttrString( (
PyObject*)fOrg, (
char*)
"__doc__" ); }
1517 virtual Int_t GetPriority() {
return 100; }
1518 virtual PyObject* GetCoVarNames() {
1519 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1533 class TTreeBranch :
public TTreeMemberFunction {
1538 virtual Int_t GetMaxArgs() {
return 5; }
1539 virtual PyCallable* Clone() {
return new TTreeBranch( *
this ); }
1548 int argc = PyTuple_GET_SIZE( args );
1555 PyErr_SetString( PyExc_TypeError,
1556 "TTree::Branch must be called with a TTree instance as first argument" );
1562 PyObject *bufsize = 0, *splitlevel = 0;
1565 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!OO!|O!:Branch" ),
1567 &leaflist, &PyInt_Type, &bufsize ) ) {
1571 buf = (
void*)((
ObjectProxy*)address)->GetObject();
1594 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!O|O!O!:Branch" ),
1596 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1599 PyErr_Clear(); clName = 0;
1600 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O|O!O!" ),
1602 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1608 if ( bIsMatch ==
kTRUE ) {
1625 if ( buf != 0 && klName !=
"" ) {
1629 }
else if ( argc == 4 ) {
1631 PyInt_AS_LONG( bufsize ) );
1632 }
else if ( argc == 5 ) {
1634 PyInt_AS_LONG( bufsize ), PyInt_AS_LONG( splitlevel ) );
1655 class TTreeSetBranchAddress :
public TTreeMemberFunction {
1665 virtual Int_t GetMaxArgs() {
return 2; }
1666 virtual PyCallable* Clone() {
return new TTreeSetBranchAddress( *
this ); }
1673 int argc = PyTuple_GET_SIZE( args );
1680 PyErr_SetString( PyExc_TypeError,
1681 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1688 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"SO:SetBranchAddress" ),
1689 &
name, &address ) ) {
1703 Py_INCREF( Py_None );
1720 virtual PyObject* ReportTypeError()
1722 PyErr_SetString( PyExc_TypeError,
1723 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1731 class TChainSetBranchAddress :
public TTreeSetBranchAddress {
1741 virtual Int_t GetMaxArgs() {
return 2; }
1742 virtual PyCallable* Clone() {
return new TChainSetBranchAddress( *
this ); }
1745 virtual PyObject* ReportTypeError()
1747 PyErr_SetString( PyExc_TypeError,
1748 "TChain::SetBranchAddress must be called with a TChain instance as first argument" );
1765 if ( ! (pya0 && pya1 && pya2 && pya3) ) {
1766 Py_XDECREF( pya3 ); Py_XDECREF( pya2 ); Py_XDECREF( pya1 ); Py_XDECREF( pya0 );
1771 PyObject* result = PyObject_CallFunction(
1772 pyfunc, (
char*)
"OOOOi", pya0, pya1, pya2, pya3, a4 );
1773 Py_DECREF( pya3 ); Py_DECREF( pya2 ); Py_DECREF( pya1 ); Py_DECREF( pya0 );
1777 throw std::runtime_error(
"TMinuit python fit function call failed" );
1780 Py_XDECREF( result );
1796 result = PyObject_CallFunction( pyfunc, (
char*)
"OO", pya0, pya1 );
1799 result = PyObject_CallFunction( pyfunc, (
char*)
"O", pya0 );
1807 throw std::runtime_error(
"TFN python function call failed" );
1809 d = PyFloat_AsDouble( result );
1810 Py_DECREF( result );
1828 PyObject* result = CallPyObjMethod( self,
"Scale", scale );
1832 Py_DECREF( result );
1840 class TPretendInterpreted:
public PyCallable {
1842 TPretendInterpreted(
int nArgs ) : fNArgs( nArgs ) {}
1845 Int_t GetNArgs() {
return fNArgs; }
1849 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1859 if ( ! pyobject || ! PyCallable_Check( pyobject ) ) {
1861 PyErr_Format( PyExc_ValueError,
1876 class TF1InitWithPyFunc :
public TPretendInterpreted {
1878 TF1InitWithPyFunc(
int ntf = 1 ) : TPretendInterpreted( 2 + 2*ntf ) {}
1885 "TF1::TF1(const char* name, PyObject* callable, "
1886 "Double_t xmin, Double_t xmax, Int_t npar = 0)" );
1889 virtual PyCallable* Clone() {
return new TF1InitWithPyFunc( *
this ); }
1895 int argc = PyTuple_GET_SIZE( args );
1896 const int reqNArgs = GetNArgs();
1897 if ( ! ( argc == reqNArgs || argc == reqNArgs+1 ) ) {
1898 PyErr_Format( PyExc_TypeError,
1899 "TFN::TFN(const char*, PyObject* callable, ...) =>\n"
1900 " takes at least %d and at most %d arguments (%d given)",
1901 reqNArgs, reqNArgs+1, argc );
1905 PyObject* pyfunc = PyTuple_GET_ITEM( args, 1 );
1909 if ( argc == reqNArgs+1 )
1910 npar = PyInt_AsLong( PyTuple_GET_ITEM( args, reqNArgs ) );
1913 std::vector<std::string> signature; signature.reserve( 2 );
1914 signature.push_back(
"double*" );
1915 signature.push_back(
"double*" );
1919 pyfunc, npar,
"double", signature,
"TFNPyCallback" );
1928 PyObject* newArgs = PyTuple_New( reqNArgs + 1 );
1930 for (
int iarg = 0; iarg < argc; ++iarg ) {
1931 PyObject* item = PyTuple_GET_ITEM( args, iarg );
1934 PyTuple_SET_ITEM( newArgs, iarg, item );
1940 if ( argc == reqNArgs )
1941 PyTuple_SET_ITEM( newArgs, reqNArgs, PyInt_FromLong( 0
l ) );
1947 Py_DECREF( newArgs );
1948 Py_DECREF( method );
1955 class TF2InitWithPyFunc :
public TF1InitWithPyFunc {
1957 TF2InitWithPyFunc() : TF1InitWithPyFunc( 2 ) {}
1963 "TF2::TF2(const char* name, PyObject* callable, "
1964 "Double_t xmin, Double_t xmax, "
1965 "Double_t ymin, Double_t ymax, Int_t npar = 0)" );
1968 virtual PyCallable* Clone() {
return new TF2InitWithPyFunc( *
this ); }
1973 class TF3InitWithPyFunc :
public TF1InitWithPyFunc {
1975 TF3InitWithPyFunc() : TF1InitWithPyFunc( 3 ) {}
1981 "TF3::TF3(const char* name, PyObject* callable, "
1982 "Double_t xmin, Double_t xmax, "
1983 "Double_t ymin, Double_t ymax, "
1984 "Double_t zmin, Double_t zmax, Int_t npar = 0)" );
1987 virtual PyCallable* Clone() {
return new TF3InitWithPyFunc( *
this ); }
1997 class TMinuitSetFCN :
public TPretendInterpreted {
1999 TMinuitSetFCN(
int nArgs = 1 ) : TPretendInterpreted( nArgs ) {}
2006 "TMinuit::SetFCN(PyObject* callable)" );
2009 virtual PyCallable* Clone() {
return new TMinuitSetFCN( *
this ); }
2015 int argc = PyTuple_GET_SIZE( args );
2017 PyErr_Format( PyExc_TypeError,
2018 "TMinuit::SetFCN(PyObject* callable, ...) =>\n"
2019 " takes exactly 1 argument (%d given)", argc );
2023 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2024 if ( ! IsCallable( pyfunc ) )
2028 std::vector<std::string> signature; signature.reserve( 5 );
2029 signature.push_back(
"Int_t&" );
2030 signature.push_back(
"Double_t*" );
2031 signature.push_back(
"Double_t&" );
2032 signature.push_back(
"Double_t*" );
2033 signature.push_back(
"Int_t" );
2037 pyfunc, 5,
"void", signature,
"TMinuitPyCallback" );
2050 for ( MethodProxy::Methods_t::const_iterator im = methods.begin(); im != methods.end(); ++im ) {
2051 PyObject* sig = (*im)->GetSignature();
2065 PyObject* newArgs = PyTuple_New( 1 );
2071 PyObject* result = setFCN->
Call( self, newArgs, kwds, ctxt );
2075 Py_DECREF( newArgs );
2076 Py_DECREF( method );
2081 class TMinuitFitterSetFCN :
public TMinuitSetFCN {
2083 TMinuitFitterSetFCN() : TMinuitSetFCN( 1 ) {}
2089 "TMinuitFitter::SetFCN(PyObject* callable)" );
2092 virtual PyCallable* Clone() {
return new TMinuitFitterSetFCN( *
this ); }
2098 int argc = PyTuple_GET_SIZE( args );
2100 PyErr_Format( PyExc_TypeError,
2101 "TMinuitFitter::SetFCN(PyObject* callable, ...) =>\n"
2102 " takes exactly 1 argument (%d given)", argc );
2106 return TMinuitSetFCN::Call( self, args, kwds, ctxt );
2113 void FitterPyCallback(
int& npar,
double* gin,
double&
f,
double* u,
int flag )
2119 PyObject* arg1 = BufFac_t::Instance()->PyBuffer_FromMemory( &npar );
2121 PyObject* arg2 = BufFac_t::Instance()->PyBuffer_FromMemory( gin );
2124 PyList_SetItem( arg3, 0, PyFloat_FromDouble(
f ) );
2126 PyObject* arg4 = BufFac_t::Instance()->PyBuffer_FromMemory( u, npar *
sizeof(
double) );
2129 result = PyObject_CallFunction(
2130 gFitterPyCallback, (
char*)
"OOOOi", arg1, arg2, arg3, arg4, flag );
2131 f = PyFloat_AsDouble( PyList_GetItem( arg3, 0 ) );
2133 Py_DECREF( arg4 ); Py_DECREF( arg3 ); Py_DECREF( arg2 ); Py_DECREF( arg1 );
2137 throw std::runtime_error(
"TMinuit python fit function call failed" );
2140 Py_XDECREF( result );
2143 class TFitterFitFCN :
public TPretendInterpreted {
2145 TFitterFitFCN() : TPretendInterpreted( 2 ) {}
2151 "(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2156 "TFitter::FitFCN(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2159 virtual PyCallable* Clone() {
return new TFitterFitFCN( *
this ); }
2165 int argc = PyTuple_GET_SIZE( args );
2167 PyErr_Format( PyExc_TypeError,
2168 "TFitter::FitFCN(PyObject* callable, ...) =>\n"
2169 " takes at least 1 argument (%d given)", argc );
2173 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2174 if ( ! IsCallable( pyfunc ) )
2178 Py_XDECREF( gFitterPyCallback );
2179 Py_INCREF( pyfunc );
2180 gFitterPyCallback = pyfunc;
2187 PyObject* newArgs = PyTuple_New( argc );
2189 for (
int iarg = 1; iarg < argc; ++iarg ) {
2190 PyObject* pyarg = PyTuple_GET_ITEM( args, iarg );
2192 PyTuple_SET_ITEM( newArgs, iarg, pyarg );
2199 Py_DECREF( newArgs );
2200 Py_DECREF( method );
2210 PyObject* result = CallPyObjMethod( self,
"Get", attr );
2214 if ( !PyObject_IsTrue( result ) ) {
2215 PyObject* astr = PyObject_Str( attr );
2216 PyErr_Format( PyExc_AttributeError,
"TFile object has no attribute \'%s\'",
2219 Py_DECREF( result );
2225 PyObject_SetAttr( self, attr, result );
2237 PyErr_SetString( PyExc_TypeError,
2238 "TDirectoryFile::Get must be called with a TDirectoryFile instance as first argument" );
2245 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
2261 void* addr = dirf->
Get( namecycle );
2268 PyObject *cppname = PyObject_GetAttrString((
PyObject *)self,
"__cppname__");
2272 Py_XDECREF(cppname);
2275 if (printResult.find(
"@0x") == 0) {
2277 auto method = PyObject_GetAttrString((
PyObject*)self,
"__repr__");
2278 auto res = PyObject_CallObject(method,
nullptr);
2287 void AddArrayInterface(
PyObject *pyclass, PyCFunction func)
2292 template <
typename dtype>
2296 PyDict_SetItemString(dict,
"version", PyLong_FromLong(3));
2298 const char endianess =
'<';
2300 const char endianess =
'>';
2302 const UInt_t bytes =
sizeof(dtype);
2303 PyDict_SetItemString(dict,
"typestr",
2308 template <
typename dtype,
char typestr>
2311 std::vector<dtype> *cobj = (std::vector<dtype> *)(self->
GetObject());
2313 PyObject *dict = FillArrayInterfaceDict<dtype>(typestr);
2314 PyDict_SetItemString(dict,
"shape", PyTuple_Pack(1, PyLong_FromLong(cobj->size())));
2315 PyDict_SetItemString(dict,
"data",
2316 PyTuple_Pack(2, PyLong_FromLong(
reinterpret_cast<long>(cobj->data())), Py_False));
2321 template <
typename dtype,
char typestr>
2325 RVec<dtype> *cobj = (RVec<dtype> *)(self->
GetObject());
2327 PyObject *dict = FillArrayInterfaceDict<dtype>(typestr);
2328 PyDict_SetItemString(dict,
"shape", PyTuple_Pack(1, PyLong_FromLong(cobj->size())));
2329 PyDict_SetItemString(dict,
"data",
2330 PyTuple_Pack(2, PyLong_FromLong(
reinterpret_cast<long>(cobj->data())), Py_False));
2337 return PyInt_FromLong( 3 );
2341 return PyInt_FromLong( 2 );
2381 if ( ! pyfullname ) pyfullname = PyObject_GetAttr( pyclass,
PyStrings::gName );
2383 Py_DECREF( pyfullname );
2405 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)StlSequenceIter;
2438 if (
name ==
"TObject" ) {
2449 else if (
name ==
"TClass" ) {
2459 else if (
name ==
"TCollection" ) {
2470 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)TCollectionIter;
2475 else if (
name ==
"TSeqCollection" ) {
2476 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2478 Utility::AddToClass( pyclass,
"__delitem__", (PyCFunction) TSeqCollectionDelItem, METH_O );
2482 Utility::AddToClass( pyclass,
"reverse", (PyCFunction) TSeqCollectionReverse, METH_NOARGS );
2484 METH_VARARGS | METH_KEYWORDS );
2490 else if (
name ==
"TObjArray" ) {
2494 else if (
name ==
"TClonesArray" ) {
2498 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2505 else if ( IsTemplatedSTLClass(
name,
"vector" ) || (
name.find(
"ROOT::VecOps::RVec<") == 0) ) {
2517 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)vector_iter;
2520 TypedefInfo_t* ti =
gInterpreter->TypedefInfo_Factory( (
name+
"::value_type").c_str() );
2523 PyObject_SetAttrString( pyclass,
"value_size", pyvalue_size );
2524 Py_DECREF( pyvalue_size );
2527 PyObject_SetAttrString( pyclass,
"value_type", pyvalue_type );
2528 Py_DECREF( pyvalue_type );
2537 std::string::size_type pos =
name.find(
"vector<bool" );
2538 if ( pos == 0 || pos == 5 ) {
2543 if (
name.find(
"ROOT::VecOps::RVec<") == 0) {
2544 }
else if (
name ==
"vector<float>") {
2545 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<float, 'f'>);
2546 }
else if (
name ==
"vector<double>") {
2547 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<double, 'f'>);
2548 }
else if (
name ==
"vector<int>") {
2549 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<int, 'i'>);
2550 }
else if (
name ==
"vector<unsigned int>") {
2551 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<unsigned int, 'u'>);
2552 }
else if (
name ==
"vector<long>") {
2553 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<long, 'i'>);
2554 }
else if (
name ==
"vector<unsigned long>") {
2555 AddArrayInterface(pyclass, (PyCFunction)STLVectorArrayInterface<unsigned long, 'u'>);
2559 if (
name.find(
"ROOT::VecOps::RVec<") != 0) {
2560 }
else if (
name ==
"ROOT::VecOps::RVec<float>") {
2561 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<float, 'f'>);
2562 }
else if (
name ==
"ROOT::VecOps::RVec<double>") {
2563 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<double, 'f'>);
2564 }
else if (
name ==
"ROOT::VecOps::RVec<int>") {
2565 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<int, 'i'>);
2566 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned int>") {
2567 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<unsigned int, 'u'>);
2568 }
else if (
name ==
"ROOT::VecOps::RVec<long>") {
2569 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<long, 'i'>);
2570 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned long>") {
2571 AddArrayInterface(pyclass, (PyCFunction)RVecArrayInterface<unsigned long, 'u'>);
2575 else if ( IsTemplatedSTLClass(
name,
"map" ) ) {
2580 else if ( IsTemplatedSTLClass(
name,
"pair" ) ) {
2586 else if (
name.find(
"iterator" ) != std::string::npos ) {
2587 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)StlIterNext;
2598 else if (
name ==
"string" ||
name ==
"std::string" ) {
2607 else if (
name ==
"TString" ) {
2618 else if (
name ==
"TObjString" ) {
2629 else if (
name ==
"TIter" ) {
2630 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)PyObject_SelfIter;
2633 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)TIterNext;
2638 else if (
name ==
"TDirectory" ) {
2647 else if (
name ==
"TDirectoryFile" ) {
2654 else if (
name ==
"TTree" ) {
2662 Py_DECREF( original ); original = 0;
2664 PyObject_SetAttrString(
2665 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2666 Py_DECREF( method ); method = 0;
2670 method =
MethodProxy_New(
"SetBranchAddress",
new TTreeSetBranchAddress( original ) );
2671 Py_DECREF( original ); original = 0;
2673 PyObject_SetAttrString(
2674 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2675 Py_DECREF( method ); method = 0;
2679 else if (
name ==
"TChain" ) {
2684 Py_DECREF( original ); original = 0;
2686 PyObject_SetAttrString(
2687 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2688 Py_DECREF( method ); method = 0;
2692 else if (
name ==
"TStyle" ) {
2698 else if (
name ==
"TH1" )
2701 else if (
name ==
"TF1" )
2704 else if (
name ==
"TF2" )
2707 else if (
name ==
"TF3" )
2710 else if (
name ==
"TFunction" )
2713 else if (
name ==
"TMinuit" )
2716 else if (
name ==
"TFitter" )
2719 else if (
name ==
"Fitter" )
2722 else if (
name ==
"TFile" ) {
2724 PyObject* attr = PyObject_GetAttrString( pyclass, (
char*)
"Open" );
2726 ((
MethodProxy*)attr)->fMethodInfo->fFlags |= TCallContext::kIsCreator;
2734 else if (
name.substr(0,8) ==
"TVector3" ) {
2741 else if (
name.substr(0,8) ==
"TVectorT" ) {
2748 else if (
name.substr(0,6) ==
"TArray" &&
name !=
"TArray" ) {
2755 else if (
name ==
"RooDataHist" )
2758 else if (
name ==
"RooSimultaneous" )
2763 PyObject* userPythonizations = PyObject_GetAttrString(
gRootModule,
"UserPythonizations" );
2764 PyObject* pythonizationScope = PyObject_GetAttrString(
gRootModule,
"PythonizationScope" );
2766 std::vector< std::string > pythonization_scopes;
2767 pythonization_scopes.push_back(
"__global__" );
2770 if ( user_scope !=
"__global__" ) {
2771 if ( PyDict_Contains( userPythonizations, pythonizationScope ) ) {
2772 pythonization_scopes.push_back( user_scope );
2778 for (
auto key = pythonization_scopes.cbegin(); key != pythonization_scopes.cend(); ++key ) {
2779 PyObject* tmp = PyDict_GetItemString( userPythonizations, key->c_str() );
2780 Py_ssize_t num_pythonizations = PyList_Size( tmp );
2782 if ( num_pythonizations )
2783 arglist = Py_BuildValue(
"O,s", pyclass,
name.c_str() );
2784 for (
Py_ssize_t i = 0; i < num_pythonizations; ++i ) {
2785 PyObject* pythonizor = PyList_GetItem( tmp, i );
2787 PyObject* result = PyObject_CallObject( pythonizor, arglist );
2792 Py_DECREF( result );
2794 Py_XDECREF( arglist );
2797 Py_DECREF( userPythonizations );
2798 Py_DECREF( pythonizationScope );
#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 "std::vector"-like collection of values implementing handy operation to analyse them.
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()
The ROOT global object gROOT contains a list of all defined classes.
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).
virtual void * GetObjectChecked(const char *namecycle, const char *classname)
See documentation of TDirectoryFile::GetObjectCheck(const char *namecycle, const TClass *cl)
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual TKey * GetKey(const char *name, Short_t cycle=9999) const
Return pointer to key with name,cycle.
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.
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 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...
Bool_t AddUsingToClass(PyObject *pyclass, const char *method)
Helper to add base class methods to the derived class one (this covers the 'using' cases,...
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)