Logo ROOT   6.18/05
Reference Guide
TMethodHolder.h
Go to the documentation of this file.
1// @(#)root/pyroot:$Id$
2// Author: Wim Lavrijsen, Apr 2004
3
4#ifndef PYROOT_TMETHODHOLDER_H
5#define PYROOT_TMETHODHOLDER_H
6
7// Bindings
8#include "PyCallable.h"
9
10// Standard
11#include <string>
12#include <vector>
13
14
15namespace PyROOT {
16
17 class TExecutor;
18 class TConverter;
19
20 class TMethodHolder : public PyCallable {
21 public:
25 virtual ~TMethodHolder();
26
27 public:
28 virtual PyObject* GetSignature();
29 virtual PyObject* GetPrototype();
30 virtual Int_t GetPriority();
31
32 virtual Int_t GetMaxArgs();
33 virtual PyObject* GetCoVarNames();
34 virtual PyObject* GetArgDefault( Int_t iarg );
35 virtual PyObject* GetScopeProxy();
36
37 virtual PyCallable* Clone() { return new TMethodHolder( *this ); }
38
39 public:
40 virtual PyObject* Call(
41 ObjectProxy*& self, PyObject* args, PyObject* kwds, TCallContext* ctxt = 0 );
42
43 virtual Bool_t Initialize( TCallContext* ctxt = 0 );
44 virtual PyObject* PreProcessArgs( ObjectProxy*& self, PyObject* args, PyObject* kwds );
45 virtual Bool_t ConvertAndSetArgs( PyObject* args, TCallContext* ctxt = 0 );
46 virtual PyObject* Execute( void* self, ptrdiff_t offset, TCallContext* ctxt = 0 );
47
48 protected:
52 std::string GetSignatureString();
53 std::string GetReturnTypeName();
54
55 virtual Bool_t InitExecutor_( TExecutor*&, TCallContext* ctxt = 0 );
56
57 private:
58 void Copy_( const TMethodHolder& );
59 void Destroy_() const;
60
61 PyObject* CallFast( void*, ptrdiff_t, TCallContext* );
62 PyObject* CallSafe( void*, ptrdiff_t, TCallContext* );
63
65
66 void SetPyError_( PyObject* msg );
67
68 private:
69 // representation
73
74 // call dispatch buffers
75 std::vector< TConverter* > fConverters;
76
77 // cached values
79
80 // admin
82 };
83
84} // namespace PyROOT
85
86#endif // !PYROOT_METHODHOLDER_H
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
_object PyObject
Definition: TPyArg.h:20
virtual Int_t GetPriority()
Method priorities exist (in lieu of true overloading) there to prevent void* or <unknown>* from usurp...
virtual Bool_t Initialize(TCallContext *ctxt=0)
done if cache is already setup
Cppyy::TCppMethod_t GetMethod()
Definition: TMethodHolder.h:49
virtual PyObject * GetCoVarNames()
Build a tuple of the argument types/names.
virtual PyObject * GetSignature()
std::vector< TConverter * > fConverters
Definition: TMethodHolder.h:75
virtual Int_t GetMaxArgs()
virtual ~TMethodHolder()
destructor
virtual PyObject * Execute(void *self, ptrdiff_t offset, TCallContext *ctxt=0)
call the interface method
Cppyy::TCppScope_t GetScope()
Definition: TMethodHolder.h:50
void Copy_(const TMethodHolder &)
void SetPyError_(PyObject *msg)
helper to report errors in a consistent format (derefs msg)
TMethodHolder & operator=(const TMethodHolder &)
assignment operator
TMethodHolder(Cppyy::TCppScope_t scope, Cppyy::TCppMethod_t method)
TExecutor * GetExecutor()
Definition: TMethodHolder.h:51
virtual PyObject * PreProcessArgs(ObjectProxy *&self, PyObject *args, PyObject *kwds)
verify existence of self, return if ok
virtual PyObject * Call(ObjectProxy *&self, PyObject *args, PyObject *kwds, TCallContext *ctxt=0)
preliminary check in case keywords are accidently used (they are ignored otherwise)
std::string GetSignatureString()
built a signature representation (used for doc strings)
Cppyy::TCppScope_t fScope
Definition: TMethodHolder.h:71
std::string GetReturnTypeName()
virtual PyObject * GetArgDefault(Int_t iarg)
get the default value (if any) of argument iarg of this method
virtual Bool_t ConvertAndSetArgs(PyObject *args, TCallContext *ctxt=0)
Cppyy::TCppMethod_t fMethod
Definition: TMethodHolder.h:70
void Destroy_() const
destroy executor and argument converters
virtual PyCallable * Clone()
Definition: TMethodHolder.h:37
PyObject * CallFast(void *, ptrdiff_t, TCallContext *)
Helper code to prevent some duplication; this is called from CallSafe() as well as directly from TMet...
Bool_t InitConverters_()
build buffers for argument dispatching
virtual PyObject * GetPrototype()
virtual Bool_t InitExecutor_(TExecutor *&, TCallContext *ctxt=0)
install executor conform to the return type
PyObject * CallSafe(void *, ptrdiff_t, TCallContext *)
Helper code to prevent some code duplication; this code embeds a ROOT "try/catch" block that saves th...
virtual PyObject * GetScopeProxy()
Get or build the scope of this method.
ptrdiff_t TCppScope_t
Definition: Cppyy.h:15
ptrdiff_t TCppMethod_t
Definition: Cppyy.h:18