23 #include "TNotifyLink.h"
68 :
public TNotifyLinkBase
84 virtual Bool_t Notify()
override;
87 virtual void Clear (Option_t* =
"")
override;
110 TreeNotifier::TreeNotifier (TTree*
tree,
112 : m_treeobj_ref (treeobj_ref),
113 m_chain (
tree->GetNotify()),
142 if (pynotify_str == 0)
143 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
146 #if PY_VERSION_HEX >= 0x030d0000
153 PyObject** dictptr = _PyObject_GetDictPtr (treeobj);
154 if (dictptr && *dictptr) {
155 PyObject* notobj = PyObject_GetItem (*dictptr, pynotify_str);
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" ),
200 if (pynotify_str == 0) {
201 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
203 if (notifier_str == 0) {
204 notifier_str = PyUnicode_InternFromString(
"__notifier__");
208 if (!PyObject_HasAttr (
self, notifier_str)) {
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);
228 int stat = PyObject_SetAttr (
self, pynotify_str,
obj);
245 if ( ! PyArg_ParseTuple(
args,
const_cast< char*
>(
"O:SetNotify" ),
250 if (pynotify_str == 0)
251 pynotify_str = PyUnicode_InternFromString(
"__pynotify__");
254 PyObject* ret = PyObject_GetAttr (
self, pynotify_str);
273 if ( ! PyArg_ParseTuple(
args,
const_cast< char*
>(
"OO:SetBranchAddress" ),
279 if (TPython::CPPInstance_Check (
self)) {
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 ) ) {
296 if ( inst->fFlags & CPPInstance::kIsReference )
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);
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); \
360 #undef INSTALL_METHOD