Logo ROOT   6.16/01
Reference Guide
TPython.h
Go to the documentation of this file.
1// @(#)root/pyroot:$Id$
2// Author: Wim Lavrijsen April 2004
3
4#ifndef ROOT_TPython
5#define ROOT_TPython
6
7//////////////////////////////////////////////////////////////////////////////
8// //
9// TPython //
10// //
11// Access to the python interpreter and API onto PyROOT. //
12// //
13//////////////////////////////////////////////////////////////////////////////
14
15
16// Bindings
17#include "TPyReturn.h"
18
19// ROOT
20#include "TObject.h"
21
22
23class TPython {
24
25private:
26 static Bool_t Initialize();
27
28public:
29// import a python module, making its classes available
30 static Bool_t Import( const char* name );
31
32// load a python script as if it were a macro
33 static void LoadMacro( const char* name );
34
35// execute a python stand-alone script, with argv CLI arguments
36 static void ExecScript( const char* name, int argc = 0, const char** argv = 0 );
37
38// execute a python statement (e.g. "import ROOT" )
39 static Bool_t Exec( const char* cmd );
40
41// evaluate a python expression (e.g. "1+1")
42 static const TPyReturn Eval( const char* expr );
43
44// bind a ROOT object with, at the python side, the name "label"
45 static Bool_t Bind( TObject* object, const char* label );
46
47// enter an interactive python session (exit with ^D)
48 static void Prompt();
49
50// type verifiers for ObjectProxy
51 static Bool_t ObjectProxy_Check( PyObject* pyobject );
52 static Bool_t ObjectProxy_CheckExact( PyObject* pyobject );
53
54// type verifiers for MethodProxy
55 static Bool_t MethodProxy_Check( PyObject* pyobject );
56 static Bool_t MethodProxy_CheckExact( PyObject* pyobject );
57
58// object proxy to void* conversion
59 static void* ObjectProxy_AsVoidPtr( PyObject* pyobject );
60
61// void* to object proxy conversion, returns a new reference
63 void* addr, const char* classname, Bool_t python_owns = kFALSE );
64
65 virtual ~TPython() { }
66 ClassDef(TPython,0) //Access to the python interpreter
67};
68
69#endif
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:324
_object PyObject
Definition: TPyArg.h:20
Mother of all ROOT objects.
Definition: TObject.h:37
static void Prompt()
Enter an interactive python session (exit with ^D).
Definition: TPython.cxx:460
static Bool_t Import(const char *name)
Import the named python module and create Cling equivalents for its classes and methods.
Definition: TPython.cxx:150
static Bool_t MethodProxy_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is MethodProxy type.
Definition: TPython.cxx:514
static Bool_t MethodProxy_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of MethodProxy type or any derived type.
Definition: TPython.cxx:501
static Bool_t Bind(TObject *object, const char *label)
Bind a ROOT object with, at the python side, the name "label".
Definition: TPython.cxx:434
static void LoadMacro(const char *name)
Execute the give python script as if it were a macro (effectively an execfile in main),...
Definition: TPython.cxx:215
static void * ObjectProxy_AsVoidPtr(PyObject *pyobject)
Extract the object pointer held by the ObjectProxy pyobject.
Definition: TPython.cxx:527
static PyObject * ObjectProxy_FromVoidPtr(void *addr, const char *classname, Bool_t python_owns=kFALSE)
Bind the addr to a python object of class defined by classname.
Definition: TPython.cxx:544
static Bool_t Initialize()
Definition: TPython.cxx:93
static Bool_t Exec(const char *cmd)
Execute a python statement (e.g. "import ROOT").
Definition: TPython.cxx:353
static void ExecScript(const char *name, int argc=0, const char **argv=0)
Execute a python stand-alone script, with argv CLI arguments.
Definition: TPython.cxx:285
static Bool_t ObjectProxy_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is ObjectProxy type.
Definition: TPython.cxx:487
static Bool_t ObjectProxy_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of ObjectProxy type or any derived type.
Definition: TPython.cxx:474
virtual ~TPython()
Definition: TPython.h:65
static const TPyReturn Eval(const char *expr)
Evaluate a python expression (e.g.
Definition: TPython.cxx:381