26 Py_XINCREF( pyclass );
29 std::vector< PyCallable* >
dummy;
66 PyObject_GC_Track( pytmpl );
77 Py_CLEAR( pytmpl->
fSelf );
89 PyObject_GC_UnTrack( pytmpl );
91 PyObject_GC_Del( pytmpl );
107 }
else if ( !doc && doc2 ) {
121 int tpp_traverse(
TemplateProxy* pytmpl, visitproc visit,
void* arg )
125 Py_VISIT( pytmpl->
fSelf );
176 PyObject* result = MethodProxy_Type.tp_call( pymeth, args, kwds );
177 Py_DECREF( pymeth ); pymeth = 0;
184 Py_XDECREF( pymeth ); pymeth = 0;
190 PyErr_Format( PyExc_TypeError,
"template method \'%s\' with no arguments must be explicit",
201 pymeth = PyObject_GetAttr( pytmpl->
fSelf ? pytmpl->
fSelf : pytmpl->
fPyClass, pyname_v1 );
203 Py_DECREF( pyname_v1 );
210 pymeth = MethodProxy_Type.tp_descr_get(
214 PyObject* result = MethodProxy_Type.tp_call( pymeth, args, kwds );
215 Py_DECREF( pymeth ); pymeth = 0;
217 Py_XDECREF( pyname_v1 );
224 Py_XDECREF( pymeth ); pymeth = 0;
231 PyObject* tpArgs = PyTuple_New( nArgs );
232 for (
Int_t i = 0; i < nArgs; ++i ) {
233 PyObject* itemi = PyTuple_GET_ITEM( args, i );
234 if ( PyType_Check( itemi ) ) isType =
kTRUE;
235 #if PY_VERSION_HEX >= 0x03000000 236 else if ( ! isType && PyUnicode_Check( itemi ) ) nStrings += 1;
238 else if ( ! isType &&
PyBytes_Check( itemi ) ) nStrings += 1;
247 PyTuple_SET_ITEM( tpArgs, i, tp );
251 const char* ptrname = 0;
253 case 'b': ptrname =
"char*";
break;
254 case 'h': ptrname =
"short*";
break;
255 case 'H': ptrname =
"unsigned short*";
break;
256 case 'i': ptrname =
"int*";
break;
257 case 'I': ptrname =
"unsigned int*";
break;
258 case 'l': ptrname =
"long*";
break;
259 case 'L': ptrname =
"unsigned long*";
break;
260 case 'f': ptrname =
"float*";
break;
261 case 'd': ptrname =
"double*";
break;
262 default: ptrname =
"void*";
266 PyTuple_SET_ITEM( tpArgs, i, pyptrname );
271 PyTuple_SET_ITEM( tpArgs, i, pytc );
284 if ( ! isType && ! ( nStrings == nArgs ) ) {
288 Py_DECREF( pyname_v2 );
289 std::string
proto = mname.substr( 1, mname.size() - 2 );
293 Py_XDECREF( pyname_v1 );
306 pymeth = PyObject_GetAttrString(
308 PyObject* result = MethodProxy_Type.tp_call( pymeth, args, kwds );
324 if ( mname != cppmeth->
GetName() )
325 PyObject_SetAttrString( pytmpl->
fPyClass, (
char*)mname.c_str(), (
PyObject*)pymeth );
327 pymeth = PyObject_GetAttr( pytmpl->
fSelf ? pytmpl->
fSelf : pytmpl->
fPyClass, pyname_v1 );
328 Py_DECREF( pyname_v1 );
331 Py_DECREF( pyname_v1 );
335 PyErr_Format( PyExc_TypeError,
"can not resolve method template call for \'%s\'",
364 newPyTmpl->
fSelf = pyobj;
371 PyGetSetDef tpp_getset[] = {
372 { (
char*)
"__doc__", (getter)tpp_doc, NULL, NULL, NULL },
373 { (
char*)NULL, NULL, NULL, NULL, NULL }
382 (
char*)
"ROOT.TemplateProxy",
385 (destructor)tpp_dealloc,
395 (ternaryfunc)tpp_call,
400 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
401 (
char*)
"PyROOT template proxy (internal)",
402 (traverseproc)tpp_traverse,
413 (descrgetfunc)tpp_descrget,
426 #
if PY_VERSION_HEX >= 0x02030000
429 #
if PY_VERSION_HEX >= 0x02060000
432 #
if PY_VERSION_HEX >= 0x03040000
virtual const char * GetName() const
Returns name of object.
#define PyBytes_FromString
#define PyROOT_PyUnicode_FromString
void AddOverload(MethodProxy *mp)
Store overloads of this templated method.
MethodProxy * fNonTemplated
MethodProxy * MethodProxy_New(const std::string &name, std::vector< PyCallable * > &methods)
PyObject * BuildTemplateName(PyObject *pyname, PyObject *args, int argoff)
Helper to construct the "< type, type, ... >" part of a templated name (either for a class as in Make...
#define PyVarObject_HEAD_INIT(type, size)
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
#define PyROOT_PyUnicode_AsString
PyObject_HEAD PyObject * fSelf
The ROOT global object gROOT contains a list of all defined classes.
void AddTemplate(PyCallable *pc)
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
PyTypeObject MethodProxy_Type
PyTypeObject TemplateProxy_Type
void Set(const std::string &name, PyObject *pyclass)
Initialize the proxy for the given 'pyclass.'.
MethodInfo_t * fMethodInfo
#define PyROOT_PyUnicode_AppendAndDel
TCppScope_t GetScope(const std::string &scope_name)
R__EXTERN PyObject * gName
void AddMethod(PyCallable *pc)
Fill in the data of a freshly created method proxy.
R__EXTERN PyObject * gTypeCode
static RooMathCoreReg dummy
#define PyROOT_PyUnicode_Check
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
R__EXTERN PyObject * gCppName
Each ROOT class (see TClass) has a linked list of methods.
Bool_t MethodProxy_Check(T *object)
static constexpr double pc
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Template proxy object to return functions and methods.