4 #ifndef PYROOT_UTILITY_H
5 #define PYROOT_UTILITY_H
17 R__EXTERN dict_lookup_func gDictLookupOrg;
18 R__EXTERN Bool_t gDictLookupActive;
21 ULong_t PyLongOrInt_AsULong( PyObject* pyobject );
22 ULong64_t PyLongOrInt_AsULong64( PyObject* pyobject );
27 Bool_t AddToClass( PyObject* pyclass,
const char* label, PyCFunction cfunc,
28 int flags = METH_VARARGS );
29 Bool_t AddToClass( PyObject* pyclass,
const char* label,
const char* func );
30 Bool_t AddToClass( PyObject* pyclass,
const char* label, PyCallable* pyfunc );
32 Bool_t AddUsingToClass( PyObject* pyclass,
const char* method );
35 Bool_t AddBinaryOperator( PyObject* left, PyObject* right,
36 const char* op,
const char* label,
const char* alt_label = NULL,
bool lazy =
false );
37 Bool_t AddBinaryOperator( PyObject* pyclass,
38 const char* op,
const char* label,
const char* alt_label = NULL,
bool lazy =
false );
39 Bool_t AddBinaryOperator( PyObject* pyclass,
const std::string& lcname,
const std::string& rcname,
40 const char* op,
const char* label,
const char* alt_label = NULL,
bool lazy =
false );
43 enum ArgPreference { kNone, kPointer, kReference, kValue };
44 PyObject* BuildTemplateName( PyObject* pyname, PyObject* tpArgs,
int argoff,
45 PyObject* args =
nullptr, ArgPreference = kNone,
int* pcnt =
nullptr,
bool inferredTypes =
false );
48 Bool_t InitProxy( PyObject* module, PyTypeObject* pytype,
const char* name );
53 int GetBuffer( PyObject* pyobject,
char tc,
int size,
void*& buf, Bool_t check = kTRUE );
56 std::string MapOperatorName(
const std::string& name, Bool_t bTakesParames );
59 const std::string Compound(
const std::string& name );
60 Py_ssize_t ArraySize(
const std::string& name );
61 const std::string ClassName( PyObject* pyobj );
64 void ErrMsgCallback(
char* msg );
65 void ErrMsgHandler(
int level, Bool_t abort,
const char* location,
const char* msg );
68 void* CreateWrapperMethod( PyObject* pyfunc, Long_t user,
69 const char* retType,
const std::vector<std::string>& signature,
const char* callback );
72 PyObject* PyErr_Occurred_WithGIL();
75 PyObject* InstallGUIEventInputHook();
76 PyObject* RemoveGUIEventInputHook();
81 PyGILState_STATE m_GILState;
83 PyGILRAII():m_GILState(PyGILState_Ensure()){}
84 ~PyGILRAII(){PyGILState_Release(m_GILState);}
89 #endif // !PYROOT_UTILITY_H