![]() |
|
|||
File indexing completed on 2025-07-11 08:46:25
0001 // Author: Enric Tejedor CERN 08/2019 0002 // Original PyROOT code by Wim Lavrijsen, LBL 0003 0004 /************************************************************************* 0005 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. * 0006 * All rights reserved. * 0007 * * 0008 * For the licensing terms see $ROOTSYS/LICENSE. * 0009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 0010 *************************************************************************/ 0011 0012 #ifndef ROOT_TPython 0013 #define ROOT_TPython 0014 0015 ////////////////////////////////////////////////////////////////////////////// 0016 // // 0017 // TPython // 0018 // // 0019 // Access to the python interpreter and API onto PyROOT. // 0020 // // 0021 ////////////////////////////////////////////////////////////////////////////// 0022 0023 // Bindings 0024 #include "TPyReturn.h" 0025 0026 // ROOT 0027 #include "TObject.h" 0028 0029 class TPython { 0030 0031 private: 0032 static Bool_t Initialize(); 0033 0034 public: 0035 // import a python module, making its classes available 0036 static Bool_t Import(const char *name); 0037 0038 // load a python script as if it were a macro 0039 static void LoadMacro(const char *name); 0040 0041 // execute a python stand-alone script, with argv CLI arguments 0042 static void ExecScript(const char *name, int argc = 0, const char **argv = nullptr); 0043 0044 // execute a python statement (e.g. "import ROOT" ) 0045 static Bool_t Exec(const char *cmd); 0046 0047 // evaluate a python expression (e.g. "1+1") 0048 static const TPyReturn Eval(const char *expr); 0049 0050 // bind a ROOT object with, at the python side, the name "label" 0051 static Bool_t Bind(TObject *object, const char *label); 0052 0053 // enter an interactive python session (exit with ^D) 0054 static void Prompt(); 0055 0056 // type verifiers for CPPInstance 0057 static Bool_t CPPInstance_Check(PyObject *pyobject); 0058 static Bool_t CPPInstance_CheckExact(PyObject *pyobject); 0059 0060 // type verifiers for CPPOverload 0061 static Bool_t CPPOverload_Check(PyObject *pyobject); 0062 static Bool_t CPPOverload_CheckExact(PyObject *pyobject); 0063 0064 // CPPInstance to void* conversion 0065 static void *CPPInstance_AsVoidPtr(PyObject *pyobject); 0066 0067 // void* to CPPInstance conversion, returns a new reference 0068 static PyObject *CPPInstance_FromVoidPtr(void *addr, const char *classname, Bool_t python_owns = kFALSE); 0069 0070 virtual ~TPython() {} 0071 ClassDef(TPython, 0) // Access to the python interpreter 0072 }; 0073 0074 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |