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 return PyErr_Format( PyExc_LookupError,
1319 "No operator==(const %s&, const %s&) available in the dictionary!",
1329 return PyErr_Format( PyExc_LookupError,
1330 "No operator!=(const %s&, const %s&) available in the dictionary!",
1340 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!:TDirectory::GetObject" ),
1348 PyErr_SetString( PyExc_TypeError,
1349 "TDirectory::GetObject must be called with a TDirectory instance as first argument" );
1355 ptr->
Set( address );
1357 Py_INCREF( Py_None );
1373 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!|O!i:TDirectory::WriteObject" ),
1382 PyErr_SetString( PyExc_TypeError,
1383 "TDirectory::WriteObject must be called with a TDirectory instance as first argument" );
1388 if ( option != 0 ) {
1396 return PyInt_FromLong( (
Long_t)result );
1417 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
1422 const char*
name =
tree->GetAlias( name1 );
1429 branch =
tree->GetBranch( (std::string(
name ) +
'.' ).c_str() );
1452 if ( klass && !
tree->GetLeaf(
name ) &&
1460 if ( branch && ! leaf ) {
1466 leaf = (
TLeaf*)leaves->
At( 0 );
1501 PyErr_Format( PyExc_AttributeError,
1502 "\'%s\' object has no attribute \'%s\'",
tree->IsA()->GetName(),
name );
1508 class TTreeMemberFunction :
public PyCallable {
1511 TTreeMemberFunction(
const TTreeMemberFunction& t ) :
PyCallable( t )
1514 Py_INCREF( t.fOrg );
1517 TTreeMemberFunction&
operator=(
const TTreeMemberFunction& t )
1521 Py_INCREF( t.fOrg );
1527 ~TTreeMemberFunction() { Py_DECREF( fOrg ); fOrg = 0; }
1531 virtual PyObject* GetPrototype() {
return PyObject_GetAttrString( (
PyObject*)fOrg, (
char*)
"__doc__" ); }
1532 virtual Int_t GetPriority() {
return 100; }
1533 virtual PyObject* GetCoVarNames() {
1534 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1548 class TTreeBranch :
public TTreeMemberFunction {
1553 virtual Int_t GetMaxArgs() {
return 5; }
1554 virtual PyCallable* Clone() {
return new TTreeBranch( *
this ); }
1563 int argc = PyTuple_GET_SIZE( args );
1570 PyErr_SetString( PyExc_TypeError,
1571 "TTree::Branch must be called with a TTree instance as first argument" );
1577 PyObject *bufsize = 0, *splitlevel = 0;
1580 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!OO!|O!:Branch" ),
1582 &leaflist, &PyInt_Type, &bufsize ) ) {
1586 buf = (
void*)((
ObjectProxy*)address)->GetObject();
1609 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O!O|O!O!:Branch" ),
1611 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1614 PyErr_Clear(); clName = 0;
1615 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"O!O|O!O!" ),
1617 &PyInt_Type, &bufsize, &PyInt_Type, &splitlevel ) ) {
1623 if ( bIsMatch ==
kTRUE ) {
1640 if ( buf != 0 && klName !=
"" ) {
1644 }
else if ( argc == 4 ) {
1646 PyInt_AS_LONG( bufsize ) );
1647 }
else if ( argc == 5 ) {
1649 PyInt_AS_LONG( bufsize ), PyInt_AS_LONG( splitlevel ) );
1670 class TTreeSetBranchAddress :
public TTreeMemberFunction {
1680 virtual Int_t GetMaxArgs() {
return 2; }
1681 virtual PyCallable* Clone() {
return new TTreeSetBranchAddress( *
this ); }
1688 int argc = PyTuple_GET_SIZE( args );
1695 PyErr_SetString( PyExc_TypeError,
1696 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1703 if ( PyArg_ParseTuple( args,
const_cast< char*
>(
"SO:SetBranchAddress" ),
1704 &
name, &address ) ) {
1718 Py_INCREF( Py_None );
1735 virtual PyObject* ReportTypeError()
1737 PyErr_SetString( PyExc_TypeError,
1738 "TTree::SetBranchAddress must be called with a TTree instance as first argument" );
1746 class TChainSetBranchAddress :
public TTreeSetBranchAddress {
1756 virtual Int_t GetMaxArgs() {
return 2; }
1757 virtual PyCallable* Clone() {
return new TChainSetBranchAddress( *
this ); }
1760 virtual PyObject* ReportTypeError()
1762 PyErr_SetString( PyExc_TypeError,
1763 "TChain::SetBranchAddress must be called with a TChain instance as first argument" );
1780 if ( ! (pya0 && pya1 && pya2 && pya3) ) {
1781 Py_XDECREF( pya3 ); Py_XDECREF( pya2 ); Py_XDECREF( pya1 ); Py_XDECREF( pya0 );
1786 PyObject* result = PyObject_CallFunction(
1787 pyfunc, (
char*)
"OOOOi", pya0, pya1, pya2, pya3, a4 );
1788 Py_DECREF( pya3 ); Py_DECREF( pya2 ); Py_DECREF( pya1 ); Py_DECREF( pya0 );
1792 throw std::runtime_error(
"TMinuit python fit function call failed" );
1795 Py_XDECREF( result );
1811 result = PyObject_CallFunction( pyfunc, (
char*)
"OO", pya0, pya1 );
1814 result = PyObject_CallFunction( pyfunc, (
char*)
"O", pya0 );
1822 throw std::runtime_error(
"TFN python function call failed" );
1824 d = PyFloat_AsDouble( result );
1825 Py_DECREF( result );
1843 PyObject* result = CallPyObjMethod( self,
"Scale", scale );
1847 Py_DECREF( result );
1855 class TPretendInterpreted:
public PyCallable {
1857 TPretendInterpreted(
int nArgs ) : fNArgs( nArgs ) {}
1860 Int_t GetNArgs() {
return fNArgs; }
1864 PyObject* co_varnames = PyTuple_New( 1 + 1 );
1874 if ( ! pyobject || ! PyCallable_Check( pyobject ) ) {
1876 PyErr_Format( PyExc_ValueError,
1891 class TF1InitWithPyFunc :
public TPretendInterpreted {
1893 TF1InitWithPyFunc(
int ntf = 1 ) : TPretendInterpreted( 2 + 2*ntf ) {}
1900 "TF1::TF1(const char* name, PyObject* callable, "
1901 "Double_t xmin, Double_t xmax, Int_t npar = 0)" );
1904 virtual PyCallable* Clone() {
return new TF1InitWithPyFunc( *
this ); }
1910 int argc = PyTuple_GET_SIZE( args );
1911 const int reqNArgs = GetNArgs();
1912 if ( ! ( argc == reqNArgs || argc == reqNArgs+1 ) ) {
1913 PyErr_Format( PyExc_TypeError,
1914 "TFN::TFN(const char*, PyObject* callable, ...) =>\n"
1915 " takes at least %d and at most %d arguments (%d given)",
1916 reqNArgs, reqNArgs+1, argc );
1920 PyObject* pyfunc = PyTuple_GET_ITEM( args, 1 );
1924 if ( argc == reqNArgs+1 )
1925 npar = PyInt_AsLong( PyTuple_GET_ITEM( args, reqNArgs ) );
1928 std::vector<std::string> signature; signature.reserve( 2 );
1929 signature.push_back(
"double*" );
1930 signature.push_back(
"double*" );
1934 pyfunc, npar,
"double", signature,
"TFNPyCallback" );
1943 PyObject* newArgs = PyTuple_New( reqNArgs + 1 );
1945 for (
int iarg = 0; iarg < argc; ++iarg ) {
1946 PyObject* item = PyTuple_GET_ITEM( args, iarg );
1949 PyTuple_SET_ITEM( newArgs, iarg, item );
1955 if ( argc == reqNArgs )
1956 PyTuple_SET_ITEM( newArgs, reqNArgs, PyInt_FromLong( 0
l ) );
1962 Py_DECREF( newArgs );
1963 Py_DECREF( method );
1970 class TF2InitWithPyFunc :
public TF1InitWithPyFunc {
1972 TF2InitWithPyFunc() : TF1InitWithPyFunc( 2 ) {}
1978 "TF2::TF2(const char* name, PyObject* callable, "
1979 "Double_t xmin, Double_t xmax, "
1980 "Double_t ymin, Double_t ymax, Int_t npar = 0)" );
1983 virtual PyCallable* Clone() {
return new TF2InitWithPyFunc( *
this ); }
1988 class TF3InitWithPyFunc :
public TF1InitWithPyFunc {
1990 TF3InitWithPyFunc() : TF1InitWithPyFunc( 3 ) {}
1996 "TF3::TF3(const char* name, PyObject* callable, "
1997 "Double_t xmin, Double_t xmax, "
1998 "Double_t ymin, Double_t ymax, "
1999 "Double_t zmin, Double_t zmax, Int_t npar = 0)" );
2002 virtual PyCallable* Clone() {
return new TF3InitWithPyFunc( *
this ); }
2012 class TMinuitSetFCN :
public TPretendInterpreted {
2014 TMinuitSetFCN(
int nArgs = 1 ) : TPretendInterpreted( nArgs ) {}
2021 "TMinuit::SetFCN(PyObject* callable)" );
2024 virtual PyCallable* Clone() {
return new TMinuitSetFCN( *
this ); }
2030 int argc = PyTuple_GET_SIZE( args );
2032 PyErr_Format( PyExc_TypeError,
2033 "TMinuit::SetFCN(PyObject* callable, ...) =>\n"
2034 " takes exactly 1 argument (%d given)", argc );
2038 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2039 if ( ! IsCallable( pyfunc ) )
2043 std::vector<std::string> signature; signature.reserve( 5 );
2044 signature.push_back(
"Int_t&" );
2045 signature.push_back(
"Double_t*" );
2046 signature.push_back(
"Double_t&" );
2047 signature.push_back(
"Double_t*" );
2048 signature.push_back(
"Int_t" );
2052 pyfunc, 5,
"void", signature,
"TMinuitPyCallback" );
2065 for ( MethodProxy::Methods_t::const_iterator im = methods.begin(); im != methods.end(); ++im ) {
2066 PyObject* sig = (*im)->GetSignature();
2080 PyObject* newArgs = PyTuple_New( 1 );
2086 PyObject* result = setFCN->
Call( self, newArgs, kwds, ctxt );
2090 Py_DECREF( newArgs );
2091 Py_DECREF( method );
2096 class TMinuitFitterSetFCN :
public TMinuitSetFCN {
2098 TMinuitFitterSetFCN() : TMinuitSetFCN( 1 ) {}
2104 "TMinuitFitter::SetFCN(PyObject* callable)" );
2107 virtual PyCallable* Clone() {
return new TMinuitFitterSetFCN( *
this ); }
2113 int argc = PyTuple_GET_SIZE( args );
2115 PyErr_Format( PyExc_TypeError,
2116 "TMinuitFitter::SetFCN(PyObject* callable, ...) =>\n"
2117 " takes exactly 1 argument (%d given)", argc );
2121 return TMinuitSetFCN::Call( self, args, kwds, ctxt );
2128 void FitterPyCallback(
int& npar,
double* gin,
double&
f,
double* u,
int flag )
2134 PyObject* arg1 = BufFac_t::Instance()->PyBuffer_FromMemory( &npar );
2136 PyObject* arg2 = BufFac_t::Instance()->PyBuffer_FromMemory( gin );
2139 PyList_SetItem( arg3, 0, PyFloat_FromDouble(
f ) );
2141 PyObject* arg4 = BufFac_t::Instance()->PyBuffer_FromMemory( u, npar *
sizeof(
double) );
2144 result = PyObject_CallFunction(
2145 gFitterPyCallback, (
char*)
"OOOOi", arg1, arg2, arg3, arg4, flag );
2146 f = PyFloat_AsDouble( PyList_GetItem( arg3, 0 ) );
2148 Py_DECREF( arg4 ); Py_DECREF( arg3 ); Py_DECREF( arg2 ); Py_DECREF( arg1 );
2152 throw std::runtime_error(
"TMinuit python fit function call failed" );
2155 Py_XDECREF( result );
2158 class TFitterFitFCN :
public TPretendInterpreted {
2160 TFitterFitFCN() : TPretendInterpreted( 2 ) {}
2166 "(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2171 "TFitter::FitFCN(PyObject* callable, int npar = 0, const double* params = 0, unsigned int dataSize = 0, bool chi2fit = false)" );
2174 virtual PyCallable* Clone() {
return new TFitterFitFCN( *
this ); }
2180 int argc = PyTuple_GET_SIZE( args );
2182 PyErr_Format( PyExc_TypeError,
2183 "TFitter::FitFCN(PyObject* callable, ...) =>\n"
2184 " takes at least 1 argument (%d given)", argc );
2188 PyObject* pyfunc = PyTuple_GET_ITEM( args, 0 );
2189 if ( ! IsCallable( pyfunc ) )
2193 Py_XDECREF( gFitterPyCallback );
2194 Py_INCREF( pyfunc );
2195 gFitterPyCallback = pyfunc;
2202 PyObject* newArgs = PyTuple_New( argc );
2204 for (
int iarg = 1; iarg < argc; ++iarg ) {
2205 PyObject* pyarg = PyTuple_GET_ITEM( args, iarg );
2207 PyTuple_SET_ITEM( newArgs, iarg, pyarg );
2214 Py_DECREF( newArgs );
2215 Py_DECREF( method );
2225 PyObject* result = CallPyObjMethod( self,
"Get", attr );
2229 if ( !PyObject_IsTrue( result ) ) {
2230 PyObject* astr = PyObject_Str( attr );
2231 PyErr_Format( PyExc_AttributeError,
"TFile object has no attribute \'%s\'",
2234 Py_DECREF( result );
2240 PyObject_SetAttr( self, attr, result );
2252 PyErr_SetString( PyExc_TypeError,
2253 "TDirectoryFile::Get must be called with a TDirectoryFile instance as first argument" );
2260 PyErr_SetString( PyExc_ReferenceError,
"attempt to access a null-pointer" );
2276 void* addr = dirf->
Get( namecycle );
2283 PyObject *cppname = PyObject_GetAttrString((
PyObject *)self,
"__cppname__");
2287 Py_XDECREF(cppname);
2290 if (printResult.find(
"@0x") == 0) {
2292 auto method = PyObject_GetAttrString((
PyObject*)self,
"__repr__");
2293 auto res = PyObject_CallObject(method,
nullptr);
2302 void AddArrayInterface(
PyObject *pyclass, PyCFunction func)
2311 if (!PyObject_HasAttrString(
gRootModule,
"_add__array_interface__"))
return;
2313 auto f = PyObject_GetAttrString(
gRootModule,
"_add__array_interface__");
2314 auto r = PyObject_CallFunction(
f, (
char*)
"O", pyclass);
2319 template <
typename T,
char typestr>
2322 T *cobj =
reinterpret_cast<T*
>(self->
GetObject());
2325 auto dict = PyDict_New();
2328 auto pyversion = PyLong_FromLong(3);
2329 PyDict_SetItemString(dict,
"version", pyversion);
2330 Py_DECREF(pyversion);
2334 const char endianess =
'<';
2336 const char endianess =
'>';
2338 const UInt_t bytes =
sizeof(
typename T::value_type);
2340 PyDict_SetItemString(dict,
"typestr", pytypestr);
2341 Py_DECREF(pytypestr);
2344 auto pysize = PyLong_FromLong(cobj->size());
2345 auto pyshape = PyTuple_Pack(1, pysize);
2346 PyDict_SetItemString(dict,
"shape", pyshape);
2351 auto ptr =
reinterpret_cast<unsigned long long>(cobj->data());
2354 if (cobj->empty()) ptr = 1;
2356 auto pydata = PyTuple_Pack(2, pyptr, Py_False);
2357 PyDict_SetItemString(dict,
"data", pydata);
2366 return PyInt_FromLong( 3 );
2370 return PyInt_FromLong( 2 );
2410 if ( ! pyfullname ) pyfullname = PyObject_GetAttr( pyclass,
PyStrings::gName );
2412 Py_DECREF( pyfullname );
2434 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)StlSequenceIter;
2467 if (
name ==
"TObject" ) {
2478 else if (
name ==
"TClass" ) {
2488 else if (
name ==
"TCollection" ) {
2499 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)TCollectionIter;
2504 else if (
name ==
"TSeqCollection" ) {
2505 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2507 Utility::AddToClass( pyclass,
"__delitem__", (PyCFunction) TSeqCollectionDelItem, METH_O );
2511 Utility::AddToClass( pyclass,
"reverse", (PyCFunction) TSeqCollectionReverse, METH_NOARGS );
2513 METH_VARARGS | METH_KEYWORDS );
2519 else if (
name ==
"TObjArray" ) {
2523 else if (
name ==
"TClonesArray" ) {
2527 Utility::AddToClass( pyclass,
"__getitem__", (PyCFunction) TSeqCollectionGetItem, METH_O );
2534 else if ( IsTemplatedSTLClass(
name,
"vector" ) || (
name.find(
"ROOT::VecOps::RVec<") == 0) ) {
2546 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)vector_iter;
2549 TypedefInfo_t* ti =
gInterpreter->TypedefInfo_Factory( (
name+
"::value_type").c_str() );
2552 PyObject_SetAttrString( pyclass,
"value_size", pyvalue_size );
2553 Py_DECREF( pyvalue_size );
2556 PyObject_SetAttrString( pyclass,
"value_type", pyvalue_type );
2557 Py_DECREF( pyvalue_type );
2566 std::string::size_type pos =
name.find(
"vector<bool" );
2567 if ( pos == 0 || pos == 5 ) {
2572 if (
name.find(
"ROOT::VecOps::RVec<") == 0) {
2573 }
else if (
name ==
"vector<float>") {
2574 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<float>,
'f'>);
2575 }
else if (
name ==
"vector<double>") {
2576 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<double>,
'f'>);
2577 }
else if (
name ==
"vector<int>") {
2578 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<int>,
'i'>);
2579 }
else if (
name ==
"vector<unsigned int>") {
2580 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<unsigned int>,
'u'>);
2581 }
else if (
name ==
"vector<long>") {
2582 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<long>,
'i'>);
2583 }
else if (
name ==
"vector<unsigned long>") {
2584 AddArrayInterface(pyclass, (PyCFunction)ArrayInterface<std::vector<unsigned long>,
'u'>);
2588 if (
name.find(
"ROOT::VecOps::RVec<") != 0) {
2589 }
else if (
name ==
"ROOT::VecOps::RVec<float>") {
2591 }
else if (
name ==
"ROOT::VecOps::RVec<double>") {
2593 }
else if (
name ==
"ROOT::VecOps::RVec<int>") {
2595 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned int>") {
2597 }
else if (
name ==
"ROOT::VecOps::RVec<long>") {
2599 }
else if (
name ==
"ROOT::VecOps::RVec<unsigned long>") {
2604 else if ( IsTemplatedSTLClass(
name,
"map" ) ) {
2609 else if ( IsTemplatedSTLClass(
name,
"pair" ) ) {
2615 else if (
name.find(
"iterator" ) != std::string::npos ) {
2616 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)StlIterNext;
2627 else if (
name ==
"string" ||
name ==
"std::string" ) {
2636 else if (
name ==
"TString" ) {
2647 else if (
name ==
"TObjString" ) {
2658 else if (
name ==
"TIter" ) {
2659 ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)PyObject_SelfIter;
2662 ((PyTypeObject*)pyclass)->tp_iternext = (iternextfunc)TIterNext;
2667 else if (
name ==
"TDirectory" ) {
2676 else if (
name ==
"TDirectoryFile" ) {
2686 else if (
name ==
"TTree" ) {
2694 Py_DECREF( original ); original = 0;
2696 PyObject_SetAttrString(
2697 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2698 Py_DECREF( method ); method = 0;
2702 method =
MethodProxy_New(
"SetBranchAddress",
new TTreeSetBranchAddress( original ) );
2703 Py_DECREF( original ); original = 0;
2705 PyObject_SetAttrString(
2706 pyclass,
const_cast< char*
>( method->
GetName().c_str() ), (
PyObject*)method );
2707 Py_DECREF( method ); method = 0;
2711 else if (
name ==
"TChain" ) {
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.find(
"ROOT::RDataFrame") == 0 ||
name.find(
"ROOT::RDF::RInterface<") == 0 ) {
2725 PyObject_SetAttrString(pyclass,
"AsNumpy",
2726 PyObject_GetAttrString(
gRootModule,
"_RDataFrameAsNumpy" ));
2729 else if (
name ==
"TStyle" ) {
2735 else if (
name ==
"TH1" )
2738 else if (
name ==
"TF1" )
2741 else if (
name ==
"TF2" )
2744 else if (
name ==
"TF3" )
2747 else if (
name ==
"TFunction" )
2750 else if (
name ==
"TMinuit" )
2753 else if (
name ==
"TFitter" )
2756 else if (
name ==
"Fitter" )
2759 else if (
name ==
"TFile" ) {
2761 PyObject* attr = PyObject_GetAttrString( pyclass, (
char*)
"Open" );
2763 ((
MethodProxy*)attr)->fMethodInfo->fFlags |= TCallContext::kIsCreator;
2770 else if (
name.substr(0,8) ==
"TVector3" ) {
2777 else if (
name.substr(0,8) ==
"TVectorT" ) {
2784 else if (
name.substr(0,6) ==
"TArray" &&
name !=
"TArray" ) {
2791 else if (
name ==
"RooDataHist" )
2794 else if (
name ==
"RooSimultaneous" )
2799 PyObject* userPythonizations = PyObject_GetAttrString(
gRootModule,
"UserPythonizations" );
2800 PyObject* pythonizationScope = PyObject_GetAttrString(
gRootModule,
"PythonizationScope" );
2802 std::vector< std::string > pythonization_scopes;
2803 pythonization_scopes.push_back(
"__global__" );
2806 if ( user_scope !=
"__global__" ) {
2807 if ( PyDict_Contains( userPythonizations, pythonizationScope ) ) {
2808 pythonization_scopes.push_back( user_scope );
2814 for (
auto key = pythonization_scopes.cbegin(); key != pythonization_scopes.cend(); ++key ) {
2815 PyObject* tmp = PyDict_GetItemString( userPythonizations, key->c_str() );
2816 Py_ssize_t num_pythonizations = PyList_Size( tmp );
2818 if ( num_pythonizations )
2819 arglist = Py_BuildValue(
"O,s", pyclass,
name.c_str() );
2820 for (
Py_ssize_t i = 0; i < num_pythonizations; ++i ) {
2821 PyObject* pythonizor = PyList_GetItem( tmp, i );
2823 PyObject* result = PyObject_CallObject( pythonizor, arglist );
2828 Py_DECREF( result );
2830 Py_XDECREF( arglist );
2833 Py_DECREF( userPythonizations );
2834 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).
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.
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 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)