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_();
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:42
std::string GetReturnTypeName()
Definition: CPPMethod.cxx:805
virtual ~CPPMethod()
Definition: CPPMethod.cxx:324
bool Initialize(CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:533
void SetPyError_(PyObject *msg)
Definition: CPPMethod.cxx:234
virtual PyObject * GetSignature(bool show_formalargs=true)
Definition: CPPMethod.cxx:798
Cppyy::TCppScope_t fScope
Definition: CPPMethod.h:76
virtual bool InitExecutor_(Executor *&, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:193
virtual PyObject * GetArgDefault(int iarg)
Definition: CPPMethod.cxx:493
virtual PyObject * GetPrototype(bool show_formalargs=true)
Definition: CPPMethod.cxx:331
std::string GetSignatureString(bool show_formalargs=true)
Definition: CPPMethod.cxx:207
PyObject * ExecuteProtected(void *, ptrdiff_t, CallContext *)
Definition: CPPMethod.cxx:140
std::map< std::string, int > * fArgIndices
Definition: CPPMethod.h:81
virtual PyObject * GetCoVarNames()
Definition: CPPMethod.cxx:469
std::vector< Converter * > fConverters
Definition: CPPMethod.h:80
virtual PyObject * GetScopeProxy()
Definition: CPPMethod.cxx:517
PyObject * ExecuteFast(void *, ptrdiff_t, CallContext *)
Definition: CPPMethod.cxx:66
PyObject * Execute(void *self, ptrdiff_t offset, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:717
void Copy_(const CPPMethod &)
Definition: CPPMethod.cxx:37
virtual int GetPriority()
Definition: CPPMethod.cxx:342
PyObject * ProcessKeywords(PyObject *self, PyObject *args, PyObject *kwds)
Definition: CPPMethod.cxx:552
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:745
virtual PyCallable * Clone()
Definition: CPPMethod.h:37
void SetMethod(Cppyy::TCppMethod_t m)
Definition: CPPMethod.h:54
virtual bool IsGreedy()
Definition: CPPMethod.cxx:444
bool ConvertAndSetArgs(PyObject *args, CallContext *ctxt=nullptr)
Definition: CPPMethod.cxx:678
CPPMethod & operator=(const CPPMethod &)
Definition: CPPMethod.cxx:311
virtual PyObject * PreProcessArgs(CPPInstance *&self, PyObject *args, PyObject *kwds)
Definition: CPPMethod.cxx:631
virtual int GetMaxArgs()
Definition: CPPMethod.cxx:463
Cppyy::TCppMethod_t GetMethod()
Definition: CPPMethod.h:51
CPPMethod(Cppyy::TCppScope_t scope, Cppyy::TCppMethod_t method)
Definition: CPPMethod.cxx:295
Executor * GetExecutor()
Definition: CPPMethod.h:56
virtual Cppyy::TCppFuncAddr_t GetFunctionAddress()
Definition: CPPMethod.cxx:525
Set of helper functions that are invoked from the pythonizors, on the Python side.
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