17#include "TPyClassGenerator.h"
107 PyGILState_STATE m_GILState;
120using PyObjectRef = std::unique_ptr<PyObject, PyObjDeleter>;
131 const std::lock_guard<std::mutex> lock(
initMutex);
133 static Bool_t isInitialized =
false;
141#if PY_VERSION_HEX < 0x030b0000
152 std::cerr <<
"Error when setting command line arguments." << std::endl;
159 std::cerr <<
"Error when initializing Python." << std::endl;
164#if PY_VERSION_HEX < 0x03090000
171 std::cerr <<
"Error: python has not been intialized; returning." << std::endl;
175#if PY_VERSION_HEX < 0x030b0000
189 std::cerr <<
"Error: import ROOT failed, check your PYTHONPATH environmental variable." << std::endl;
208 isInitialized =
true;
241 for (
int i = 0; i <
PyList_Size(values.get()); ++i) {
288 Exec((std::string(
"__pyroot_f = open(\"") +
name +
290 "exec(__pyroot_f.read()); "
291 "__pyroot_f.close(); del __pyroot_f")
302 for (
int i = 0; i <
PyList_Size(current.get()); ++i) {
351 std::cerr <<
"Error: no file name specified." << std::endl;
355 std::vector<std::string> args(
argc);
356 for (
int i = 0; i <
argc; ++i) {
397 command <<
"; ROOT.Internal.SwapWithObjAtAddr['std::any'](" <<
resultName <<
", "
398 <<
reinterpret_cast<std::intptr_t
>(
result) <<
")";
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
static PyObject * gMainDict
TRObject operator()(const T1 &t1) const
TClass instances represent classes, structs and namespaces in the ROOT type system.
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.
Mother of all ROOT objects.
Accessing the Python interpreter from C++.
static void Prompt()
Enter an interactive python session (exit with ^D).
static Bool_t CPPOverload_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of CPPOverload type or any derived type.
static void * CPPInstance_AsVoidPtr(PyObject *pyobject)
Extract the object pointer held by the CPPInstance pyobject.
static void ExecScript(const char *name, int argc=0, const char **argv=nullptr)
Execute a python stand-alone script, with argv CLI arguments.
static Bool_t Import(const char *name)
Import the named python module and create Cling equivalents for its classes and methods.
static Bool_t CPPInstance_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is CPPinstance type.
static Bool_t Bind(TObject *object, const char *label)
Bind a ROOT object with, at the python side, the name "label".
static void LoadMacro(const char *name)
Execute the give python script as if it were a macro (effectively an execfile in main),...
static Bool_t Exec(const char *cmd, std::any *result=nullptr, std::string const &resultName="_anyresult")
Executes a Python command within the current Python environment.
static Bool_t CPPOverload_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is CPPOverload type.
static Bool_t Initialize()
Initialization method: setup the python interpreter and load the ROOT module.
static Bool_t CPPInstance_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of CPPInstance type or any derived type.
static PyObject * CPPInstance_FromVoidPtr(void *addr, const char *classname, Bool_t python_owns=kFALSE)
Bind the addr to a python object of class defined by classname.
CPYCPPYY_EXTERN bool Instance_CheckExact(PyObject *pyobject)
CPYCPPYY_EXTERN bool Overload_Check(PyObject *pyobject)
CPYCPPYY_EXTERN bool Overload_CheckExact(PyObject *pyobject)
CPYCPPYY_EXTERN bool Import(const std::string &name)
CPYCPPYY_EXTERN void ExecScript(const std::string &name, const std::vector< std::string > &args)
CPYCPPYY_EXTERN bool Instance_Check(PyObject *pyobject)
CPYCPPYY_EXTERN PyObject * Instance_FromVoidPtr(void *addr, const std::string &classname, bool python_owns=false)
CPYCPPYY_EXTERN void * Instance_AsVoidPtr(PyObject *pyobject)