File indexing completed on 2025-09-14 09:08:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TPython
0013 #define ROOT_TPython
0014
0015
0016 #include "TObject.h"
0017
0018 #include <any>
0019 #include <cstdint>
0020
0021
0022 struct _object;
0023 typedef _object PyObject;
0024
0025 namespace ROOT {
0026 namespace Internal {
0027
0028
0029 template<class T>
0030 inline void SwapWithObjAtAddr(T &a, std::intptr_t b) { std::swap(a, *reinterpret_cast<T*>(b)); }
0031
0032 }
0033 }
0034
0035
0036 class TPython {
0037
0038 private:
0039 static Bool_t Initialize();
0040
0041 public:
0042
0043 static Bool_t Import(const char *name);
0044
0045
0046 static void LoadMacro(const char *name);
0047
0048
0049 static void ExecScript(const char *name, int argc = 0, const char **argv = nullptr);
0050
0051
0052 static Bool_t Exec(const char *cmd, std::any *result = nullptr, std::string const& resultName="_anyresult");
0053
0054
0055 static Bool_t Bind(TObject *object, const char *label);
0056
0057
0058 static void Prompt();
0059
0060
0061 static Bool_t CPPInstance_Check(PyObject *pyobject);
0062 static Bool_t CPPInstance_CheckExact(PyObject *pyobject);
0063
0064
0065 static Bool_t CPPOverload_Check(PyObject *pyobject);
0066 static Bool_t CPPOverload_CheckExact(PyObject *pyobject);
0067
0068
0069 static void *CPPInstance_AsVoidPtr(PyObject *pyobject);
0070
0071
0072 static PyObject *CPPInstance_FromVoidPtr(void *addr, const char *classname, Bool_t python_owns = kFALSE);
0073
0074 virtual ~TPython() {}
0075 ClassDef(TPython, 0)
0076 };
0077
0078 #endif