Logo ROOT  
Reference Guide
CPPMethod.h
Go to the documentation of this file.
1#ifndef CPYCPPYY_CPPMETHOD_H
2#define CPYCPPYY_CPPMETHOD_H
3
4// Bindings
5#include "PyCallable.h"
6
7// Standard
8#include <map>
9#include <string>
10#include <vector>
11
12
13namespace CPyCppyy {
14
15class Executor;
16class Converter;
17
18class CPPMethod : public PyCallable {
19public:
21 CPPMethod(const CPPMethod&);
23 virtual ~CPPMethod();
24
25public:
26 virtual PyObject* GetSignature(bool show_formalargs = true);
27 virtual PyObject* GetPrototype(bool show_formalargs = true);
28 virtual int GetPriority();
29 virtual bool IsGreedy();
30
31 virtual int GetMaxArgs();
32 virtual PyObject* GetCoVarNames();
33 virtual PyObject* GetArgDefault(int iarg);
34 virtual PyObject* GetScopeProxy();
36
37 virtual PyCallable* Clone() { return new CPPMethod(*this); }
38
39public:
40 virtual PyObject* Call(
41 CPPInstance*& self, PyObject* args, PyObject* kwds, CallContext* ctxt = nullptr);
42
43protected:
44 virtual PyObject* PreProcessArgs(CPPInstance*& self, PyObject* args, PyObject* kwds);
45
46 bool Initialize(CallContext* ctxt = nullptr);
48 bool ConvertAndSetArgs(PyObject* args, CallContext* ctxt = nullptr);
49 PyObject* Execute(void* self, ptrdiff_t offset, CallContext* ctxt = nullptr);
50
52// TODO: the following is a special case to allow shimming of the
53// constructor; there's probably a better way ...
57 std::string GetSignatureString(bool show_formalargs = true);
58 std::string GetReturnTypeName();
59
60 virtual bool InitExecutor_(Executor*&, CallContext* ctxt = nullptr);
61
62private:
63 void Copy_(const CPPMethod&);
64 void Destroy_() const;
65
66 PyObject* ExecuteFast(void*, ptrdiff_t, CallContext*);
67 PyObject* ExecuteProtected(void*, ptrdiff_t, CallContext*);
68
69 bool InitConverters_();
70
71 void SetPyError_(PyObject* msg);
72
73private:
74// representation
78
79// call dispatch buffers
80 std::vector<Converter*> fConverters;
81 std::map<std::string, int>* fArgIndices;
82
83protected:
84// cached value that doubles as initialized flag (uninitialized if -1)
86};
87
88} // namespace CPyCppyy
89
90#endif // !CPYCPPYY_CPPMETHOD_H
_object PyObject
Definition: PyMethodBase.h:41
std::string GetReturnTypeName()
Definition: CPPMethod.cxx:800
virtual ~CPPMethod()
Definition: CPPMethod.cxx:319
bool Initialize(CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:528
void SetPyError_(PyObject *msg)
Definition: CPPMethod.cxx:229
virtual PyObject * GetSignature(bool show_formalargs=true)
Definition: CPPMethod.cxx:793
Cppyy::TCppScope_t fScope
Definition: CPPMethod.h:76
virtual bool InitExecutor_(Executor *&, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:188
void Destroy_() const
Definition: CPPMethod.cxx:48
virtual PyObject * GetArgDefault(int iarg)
Definition: CPPMethod.cxx:488
virtual PyObject * GetPrototype(bool show_formalargs=true)
Definition: CPPMethod.cxx:326
std::string GetSignatureString(bool show_formalargs=true)
Definition: CPPMethod.cxx:202
PyObject * ExecuteProtected(void *, ptrdiff_t, CallContext *)
Definition: CPPMethod.cxx:135
std::map< std::string, int > * fArgIndices
Definition: CPPMethod.h:81
virtual PyObject * GetCoVarNames()
Definition: CPPMethod.cxx:464
std::vector< Converter * > fConverters
Definition: CPPMethod.h:80
virtual PyObject * GetScopeProxy()
Definition: CPPMethod.cxx:512
PyObject * ExecuteFast(void *, ptrdiff_t, CallContext *)
Definition: CPPMethod.cxx:61
PyObject * Execute(void *self, ptrdiff_t offset, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:712
void Copy_(const CPPMethod &)
Definition: CPPMethod.cxx:37
virtual int GetPriority()
Definition: CPPMethod.cxx:337
PyObject * ProcessKeywords(PyObject *self, PyObject *args, PyObject *kwds)
Definition: CPPMethod.cxx:547
Executor * fExecutor
Definition: CPPMethod.h:77
Cppyy::TCppMethod_t fMethod
Definition: CPPMethod.h:75
Cppyy::TCppScope_t GetScope()
Definition: CPPMethod.h:55
virtual PyObject * Call(CPPInstance *&self, PyObject *args, PyObject *kwds, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:740
virtual PyCallable * Clone()
Definition: CPPMethod.h:37
void SetMethod(Cppyy::TCppMethod_t m)
Definition: CPPMethod.h:54
virtual bool IsGreedy()
Definition: CPPMethod.cxx:439
bool ConvertAndSetArgs(PyObject *args, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:673
CPPMethod & operator=(const CPPMethod &)
Definition: CPPMethod.cxx:306
virtual PyObject * PreProcessArgs(CPPInstance *&self, PyObject *args, PyObject *kwds)
Definition: CPPMethod.cxx:626
virtual int GetMaxArgs()
Definition: CPPMethod.cxx:458
Cppyy::TCppMethod_t GetMethod()
Definition: CPPMethod.h:51
CPPMethod(Cppyy::TCppScope_t scope, Cppyy::TCppMethod_t method)
Definition: CPPMethod.cxx:290
Executor * GetExecutor()
Definition: CPPMethod.h:56
virtual Cppyy::TCppFuncAddr_t GetFunctionAddress()
Definition: CPPMethod.cxx:520
intptr_t TCppMethod_t
Definition: cpp_cppyy.h:22
size_t TCppScope_t
Definition: cpp_cppyy.h:18
void * TCppFuncAddr_t
Definition: cpp_cppyy.h:25
auto * m
Definition: textangle.C:8