Logo ROOT   master
Reference Guide
Executors.h
Go to the documentation of this file.
1 // @(#)root/pyroot:$Id$
2 // Author: Wim Lavrijsen, Jan 2005
3 #ifndef PYROOT_EXECUTORS_H
4 #define PYROOT_EXECUTORS_H
5 
6 // Bindings
7 #include "TCallContext.h"
8 
9 // Standard
10 #include <string>
11 
12 
13 namespace PyROOT {
14 
15  class TExecutor {
16  public:
17  virtual ~TExecutor() {}
18  virtual PyObject* Execute(
20  };
21 
22 #define PYROOT_DECLARE_BASIC_EXECUTOR( name ) \
23  class T##name##Executor : public TExecutor { \
24  public: \
25  virtual PyObject* Execute( \
26  Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext* ); \
27  }
28 
29 // executors for built-ins
31  PYROOT_DECLARE_BASIC_EXECUTOR( BoolConstRef );
33  PYROOT_DECLARE_BASIC_EXECUTOR( CharConstRef );
35  PYROOT_DECLARE_BASIC_EXECUTOR( UCharConstRef );
41  PYROOT_DECLARE_BASIC_EXECUTOR( ULongLong );
44  PYROOT_DECLARE_BASIC_EXECUTOR( LongDouble );
47 
48 // pointer/array executors
49  PYROOT_DECLARE_BASIC_EXECUTOR( VoidArray );
50  PYROOT_DECLARE_BASIC_EXECUTOR( BoolArray );
51  PYROOT_DECLARE_BASIC_EXECUTOR( ShortArray );
52  PYROOT_DECLARE_BASIC_EXECUTOR( UShortArray );
53  PYROOT_DECLARE_BASIC_EXECUTOR( CharArray );
54  PYROOT_DECLARE_BASIC_EXECUTOR( UCharArray );
56  PYROOT_DECLARE_BASIC_EXECUTOR( UIntArray );
57  PYROOT_DECLARE_BASIC_EXECUTOR( LongArray );
58  PYROOT_DECLARE_BASIC_EXECUTOR( ULongArray );
59  PYROOT_DECLARE_BASIC_EXECUTOR( FloatArray );
60  PYROOT_DECLARE_BASIC_EXECUTOR( DoubleArray );
61 
62 // special cases
63  PYROOT_DECLARE_BASIC_EXECUTOR( STLString );
65 
66  class TCppObjectExecutor : public TExecutor {
67  public:
69  virtual PyObject* Execute(
71 
72  protected:
74  };
75 
77  public:
79  virtual PyObject* Execute(
81  };
82 
83  class TRefExecutor : public TExecutor {
84  public:
86 
87  public:
88  virtual Bool_t SetAssignable( PyObject* );
89 
90  protected:
92  };
93 
94  PYROOT_DECLARE_BASIC_EXECUTOR( Constructor );
96 
97 #define PYROOT_DECLARE_BASIC_REFEXECUTOR( name ) \
98  class T##name##RefExecutor : public TRefExecutor { \
99  public: \
100  virtual PyObject* Execute( \
101  Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext* ); \
102  }
103 
117  PYROOT_DECLARE_BASIC_REFEXECUTOR( LongDouble );
119 
120 // special cases
122  public:
124  virtual PyObject* Execute(
126 
127  protected:
129  };
130 
132  public:
134  virtual PyObject* Execute(
136  };
137 
139  public:
141  virtual PyObject* Execute(
143  };
144 
146  public:
148  : TCppObjectExecutor ( klass ), fArraySize( array_size ) {}
149  virtual PyObject* Execute(
151 
152  protected:
154  };
155 
156 // smart pointer executors
158  public:
160  Cppyy::TCppMethod_t deref ) : fClass( klass ), fRawPtrType( rawPtrType ), fDereferencer( deref ) {}
161 
162  virtual PyObject* Execute(
164 
165  protected:
169  };
170 
172  public:
174 
175  virtual PyObject* Execute(
177  };
178 
180  public:
182  Cppyy::TCppMethod_t deref ) : fClass( klass ), fRawPtrType( rawPtrType ), fDereferencer( deref ) {}
183 
184  virtual PyObject* Execute(
186 
187  protected:
191  };
192 
193 // create executor from fully qualified type
194  TExecutor* CreateExecutor( const std::string& fullType,
195  Bool_t manage_smart_ptr = kTRUE );
196 
197 } // namespace PyROOT
198 
199 #endif // !PYROOT_EXECUTORS_H
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
Definition: Executors.cxx:548
PyObject * fAssignable
Definition: Executors.h:91
virtual ~TExecutor()
Definition: Executors.h:17
PYROOT_DECLARE_BASIC_REFEXECUTOR(Bool)
TCppScope_t TCppType_t
Definition: Cppyy.h:16
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
execute <method> with argument <self, ctxt>, construct python ROOT object (ignoring ref) return ptr v...
Definition: Executors.cxx:498
const char * Int
TCppObjectArrayExecutor(Cppyy::TCppType_t klass, Py_ssize_t array_size)
Definition: Executors.h:147
PYROOT_DECLARE_BASIC_EXECUTOR(Bool)
TExecutor * CreateExecutor(const std::string &fullType, Bool_t manage_smart_ptr=kTRUE)
Definition: Executors.cxx:638
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)=0
const char * Long
const char * Char
const char * UShort
Cppyy::TCppType_t fClass
Definition: Executors.h:73
const char * UInt
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
execute <method> with argument <self, ctxt>, construct python ROOT object return ptr value ...
Definition: Executors.cxx:489
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
execute <method> with argument <self, ctxt>, construct TTupleOfInstances from return value ...
Definition: Executors.cxx:611
TCppObjectBySmartPtrRefExecutor(Cppyy::TCppType_t klass, Cppyy::TCppType_t rawPtrType, Cppyy::TCppMethod_t deref)
Definition: Executors.h:181
const char * UChar
const char * Float
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
smart pointer excutor
Definition: Executors.cxx:508
ptrdiff_t TCppMethod_t
Definition: Cppyy.h:18
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
execute <method> with argument <self, ctxt>, construct python proxy object return value ...
Definition: Executors.cxx:412
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
execution will bring a temporary in existence
Definition: Executors.cxx:421
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
smart pointer excutor
Definition: Executors.cxx:531
const char * ULong
const char * Double
virtual Bool_t SetAssignable(PyObject *)
prepare "buffer" for by-ref returns, used with setitem
Definition: Executors.cxx:248
Cppyy::TCppType_t fClass
Definition: Executors.h:128
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:28
void * TCppObject_t
Definition: Cppyy.h:17
const char * Bool
TCppObjectRefExecutor(Cppyy::TCppType_t klass)
Definition: Executors.h:123
TCppObjectBySmartPtrExecutor(Cppyy::TCppType_t klass, Cppyy::TCppType_t rawPtrType, Cppyy::TCppMethod_t deref)
Definition: Executors.h:159
virtual PyObject * Execute(Cppyy::TCppMethod_t, Cppyy::TCppObject_t, TCallContext *)
executor binds the result to the left-hand side, overwriting if an old object
Definition: Executors.cxx:446
Cppyy::TCppMethod_t fDereferencer
Definition: Executors.h:168
TCppObjectExecutor(Cppyy::TCppType_t klass)
Definition: Executors.h:68
const Bool_t kTRUE
Definition: RtypesCore.h:87
_object PyObject
Definition: TPyArg.h:20
const char * Short