Logo ROOT  
Reference Guide
PyROOT::Utility Namespace Reference

Enumerations

enum  ArgPreference { kNone , kPointer , kReference , kValue }
 

Functions

Bool_t AddBinaryOperator (PyObject *left, PyObject *right, const char *op, const char *label, const char *alt_label=NULL, bool lazy=false)
 Install the named operator (op) into the left object's class if such a function exists as a global overload; a label must be given if the operator is not in gC2POperatorMapping (i.e. More...
 
Bool_t AddBinaryOperator (PyObject *pyclass, const char *op, const char *label, const char *alt_label=NULL, bool lazy=false)
 Install binary operator op in pyclass, working on two instances of pyclass. More...
 
Bool_t AddBinaryOperator (PyObject *pyclass, const std::string &lcname, const std::string &rcname, const char *op, const char *label, const char *alt_label=NULL, bool lazy=false)
 
Bool_t AddToClass (PyObject *pyclass, const char *label, const char *func)
 Add the given function to the class under name 'label'. More...
 
Bool_t AddToClass (PyObject *pyclass, const char *label, PyCallable *pyfunc)
 Add the given function to the class under name 'label'. More...
 
Bool_t AddToClass (PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
 Add the given function to the class under name 'label'. More...
 
Bool_t AddUsingToClass (PyObject *pyclass, const char *method)
 Helper to add base class methods to the derived class one (this covers the 'using' cases, which the dictionary does not provide). More...
 
Py_ssize_t ArraySize (const std::string &name)
 Extract size from an array type, if available. More...
 
PyObjectBuildTemplateName (PyObject *pyname, PyObject *tpArgs, int argoff, PyObject *args=nullptr, ArgPreference=kNone, int *pcnt=nullptr, bool inferredTypes=false)
 Helper to construct the "< type, type, ... >" part of a templated name (either for a class as in MakeRootTemplateClass in RootModule.cxx) or for method lookup (as in TemplatedMemberHook, below). More...
 
const std::string ClassName (PyObject *pyobj)
 Retrieve the class name from the given python object (which may be just an instance of the class). More...
 
const std::string Compound (const std::string &name)
 Break down the compound of a fully qualified type name. More...
 
voidCreateWrapperMethod (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. More...
 
void ErrMsgCallback (char *msg)
 Translate CINT error/warning into python equivalent. More...
 
void ErrMsgHandler (int level, Bool_t abort, const char *location, const char *msg)
 Translate ROOT error/warning to python. More...
 
int GetBuffer (PyObject *pyobject, char tc, int size, void *&buf, Bool_t check=kTRUE)
 Retrieve a linear buffer pointer from the given pyobject. More...
 
Bool_t InitProxy (PyObject *module, PyTypeObject *pytype, const char *name)
 Initialize a proxy class for use by python, and add it to the ROOT module. More...
 
PyObjectInstallGUIEventInputHook ()
 
std::string MapOperatorName (const std::string &name, Bool_t bTakesParames)
 Map the given C++ operator name on the python equivalent. More...
 
PyObjectPyErr_Occurred_WithGIL ()
 Re-acquire the GIL before calling PyErr_Occurred() in case it has been released; note that the p2.2 code assumes that there are no callbacks in C++ to python (or at least none returning errors). More...
 
PyObjectRemoveGUIEventInputHook ()
 

Enumeration Type Documentation

◆ ArgPreference

Enumerator
kNone 
kPointer 
kReference 
kValue 

Definition at line 43 of file Utility.h.

Function Documentation

◆ AddBinaryOperator() [1/3]

Bool_t PyROOT::Utility::AddBinaryOperator ( PyObject left,
PyObject right,
const char *  op,
const char *  label,
const char *  alt = NULL,
bool  lazy = false 
)

Install the named operator (op) into the left object's class if such a function exists as a global overload; a label must be given if the operator is not in gC2POperatorMapping (i.e.

if it is ambiguous at the member level).

Definition at line 315 of file Utility.cxx.

◆ AddBinaryOperator() [2/3]

Bool_t PyROOT::Utility::AddBinaryOperator ( PyObject pyclass,
const char *  op,
const char *  label,
const char *  alt_label = NULL,
bool  lazy = false 
)

Install binary operator op in pyclass, working on two instances of pyclass.

Definition at line 336 of file Utility.cxx.

◆ AddBinaryOperator() [3/3]

Bool_t PyROOT::Utility::AddBinaryOperator ( PyObject pyclass,
const std::string &  lcname,
const std::string &  rcname,
const char *  op,
const char *  label,
const char *  alt_label = NULL,
bool  lazy = false 
)

Definition at line 364 of file Utility.cxx.

◆ AddToClass() [1/3]

Bool_t PyROOT::Utility::AddToClass ( PyObject pyclass,
const char *  label,
const char *  func 
)

Add the given function to the class under name 'label'.

Definition at line 219 of file Utility.cxx.

◆ AddToClass() [2/3]

Bool_t PyROOT::Utility::AddToClass ( PyObject pyclass,
const char *  label,
PyCallable pyfunc 
)

Add the given function to the class under name 'label'.

Definition at line 234 of file Utility.cxx.

◆ AddToClass() [3/3]

Bool_t PyROOT::Utility::AddToClass ( PyObject pyclass,
const char *  label,
PyCFunction  cfunc,
int  flags = METH_VARARGS 
)

Add the given function to the class under name 'label'.

Definition at line 186 of file Utility.cxx.

◆ AddUsingToClass()

Bool_t PyROOT::Utility::AddUsingToClass ( PyObject pyclass,
const char *  method 
)

Helper to add base class methods to the derived class one (this covers the 'using' cases, which the dictionary does not provide).

Definition at line 261 of file Utility.cxx.

◆ ArraySize()

Py_ssize_t PyROOT::Utility::ArraySize ( const std::string &  name)

Extract size from an array type, if available.

Definition at line 705 of file Utility.cxx.

◆ BuildTemplateName()

PyObject * PyROOT::Utility::BuildTemplateName ( PyObject pyname,
PyObject tpArgs,
int  argoff,
PyObject args = nullptr,
ArgPreference  pref = kNone,
int *  pcnt = nullptr,
bool  inferredTypes = false 
)

Helper to construct the "< type, type, ... >" part of a templated name (either for a class as in MakeRootTemplateClass in RootModule.cxx) or for method lookup (as in TemplatedMemberHook, below).

Definition at line 463 of file Utility.cxx.

◆ ClassName()

const std::string PyROOT::Utility::ClassName ( PyObject pyobj)

Retrieve the class name from the given python object (which may be just an instance of the class).

Definition at line 725 of file Utility.cxx.

◆ Compound()

const std::string PyROOT::Utility::Compound ( const std::string &  name)

Break down the compound of a fully qualified type name.

Definition at line 681 of file Utility.cxx.

◆ CreateWrapperMethod()

void * PyROOT::Utility::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.

The callback should take a (void*)pyfunc and the (Long_t)user as well as the rest of the declare signature. It should also live in namespace PyROOT

Definition at line 870 of file Utility.cxx.

◆ ErrMsgCallback()

void PyROOT::Utility::ErrMsgCallback ( char *  msg)

Translate CINT error/warning into python equivalent.

Definition at line 756 of file Utility.cxx.

◆ ErrMsgHandler()

void PyROOT::Utility::ErrMsgHandler ( int  level,
Bool_t  abort,
const char *  location,
const char *  msg 
)

Translate ROOT error/warning to python.

Definition at line 833 of file Utility.cxx.

◆ GetBuffer()

int PyROOT::Utility::GetBuffer ( PyObject pyobject,
char  tc,
int  size,
void *&  buf,
Bool_t  check = kTRUE 
)

Retrieve a linear buffer pointer from the given pyobject.

Definition at line 562 of file Utility.cxx.

◆ InitProxy()

Bool_t PyROOT::Utility::InitProxy ( PyObject module,
PyTypeObject *  pytype,
const char *  name 
)

Initialize a proxy class for use by python, and add it to the ROOT module.

Definition at line 542 of file Utility.cxx.

◆ InstallGUIEventInputHook()

PyObject * PyROOT::Utility::InstallGUIEventInputHook ( )

Definition at line 960 of file Utility.cxx.

◆ MapOperatorName()

std::string PyROOT::Utility::MapOperatorName ( const std::string &  name,
Bool_t  bTakesParames 
)

Map the given C++ operator name on the python equivalent.

Definition at line 635 of file Utility.cxx.

◆ PyErr_Occurred_WithGIL()

PyObject * PyROOT::Utility::PyErr_Occurred_WithGIL ( )

Re-acquire the GIL before calling PyErr_Occurred() in case it has been released; note that the p2.2 code assumes that there are no callbacks in C++ to python (or at least none returning errors).

Definition at line 925 of file Utility.cxx.

◆ RemoveGUIEventInputHook()

PyObject * PyROOT::Utility::RemoveGUIEventInputHook ( )

Definition at line 973 of file Utility.cxx.