23#include "TNotifyLink.h"
68 :
public TNotifyLinkBase
84 virtual Bool_t
Notify()
override;
87 virtual void Clear (Option_t* =
"")
override;
143 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
146#if PY_VERSION_HEX >= 0x030d0000
153 PyObject** dictptr = _PyObject_GetDictPtr (treeobj);
154 if (dictptr && *dictptr) {
156#if PY_VERSION_HEX >= 0x030d0000
162 PyObject_CallMethod (notobj,
const_cast<char*
> (
"Notify"), NULL);
163#if PY_VERSION_HEX >= 0x030d0000
195 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"OO:SetNotify" ),
201 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
204 notifier_str = PyUnicode_InternFromString(
"__notifier__");
210 void* vp = TPython::CPPInstance_AsVoidPtr (self);
212 (TTree*)
objectIsA(self)->DynamicCast ( TTree::Class(), vp );
214 PyObject* treeobj_ref = PyWeakref_NewRef (self, 0);
218 PyObject* notobj = TPython::CPPInstance_FromVoidPtr (notifier,
"TObject");
220 int stat = PyObject_SetAttr (self,
notifier_str, notobj);
224 tree->SetNotify (notifier);
245 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"O:SetNotify" ),
251 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
273 if ( ! PyArg_ParseTuple( args,
const_cast< char*
>(
"OO:SetBranchAddress" ),
279 if (TPython::CPPInstance_Check (self)) {
280 branch = (TBranch*)
objectIsA(self)->DynamicCast
282 TPython::CPPInstance_AsVoidPtr(self) );
286 PyErr_SetString( PyExc_TypeError,
287 "TBranch::SetAddress must be called with a "
288 "TBranch instance as first argument" );
294 if ( TPython::CPPInstance_Check( address ) ) {
295 auto* inst =
reinterpret_cast<CPPInstance*
>(address);
299 buf = &inst->fObject;
306 branch->SetAddress( buf );
308 Py_INCREF( Py_None );
325 pdef.ml_name =
const_cast<char*
> (name);
326 pdef.ml_meth = cfunc;
327 pdef.ml_flags = METH_VARARGS;
330 PyObject* func = PyCFunction_New (&pdef, 0);
331 PyObject* method = PyInstanceMethod_New (func);
332 Bool_t isOK = PyObject_SetAttrString (pyclass, pdef.ml_name, method) == 0;
334 if (PyErr_Occurred())
335 fprintf (stderr,
"Py error");
337 fprintf (stderr,
"Could not add method %s\n", name);
352# define INSTALL_METHOD(pyclass, name, func) do { \
353 static PyMethodDef pdef; \
354 installMethod (pyclass, pdef, name, (PyCFunction)func); \
#define INSTALL_METHOD(pyclass, name, func)
Additions to root's pythonized TTree.
Utility code originally from pyroot.
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
PyObject_HEAD void * fObject
static void Initialize(PyObject *tree_pyclass, PyObject *chain_pyclass, PyObject *branch_pyclass)
Install the PyROOT patches.
Tree notification handler.
virtual ~TreeNotifier()
Destructor.
virtual Bool_t Notify() override
Root notification hook.
TObject * m_chain
Notification tree.
TTree * m_tree
The tree to which we're attached.
virtual void Clear(Option_t *="") override
Called when the tree we're attached to is deleted.
TreeNotifier(TTree *tree, PyObject *treeobj_ref)
Constructor.
PyObject * m_treeobj_ref
A weak reference to the Python object for the tree.
PyObject * treeGetNotify(PyObject *, PyObject *args)
Implementation for pythonization of TTree::SetNotify.
static PyObject * pynotify_str
void installMethod(PyObject *pyclass, PyMethodDef &pdef, const char *name, PyCFunction cfunc)
Helper to install a method in a Python class.
bool setOwnership(PyObject *obj, bool flag)
PyObject * treeSetNotify(PyObject *, PyObject *args)
Implementation for pythonization of TTree::SetNotify.
static PyObject * notifier_str
int GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, Bool_t check)
TClass * objectIsA(PyObject *obj)
PyObject * branchSetAddress(PyObject *, PyObject *args)
Pythonization of TBranch::SetAddress.