Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Converters.h
Go to the documentation of this file.
1#ifndef CPYCPPYY_CONVERTERS_H
2#define CPYCPPYY_CONVERTERS_H
3
4// Bindings
5#include "Dimensions.h"
6
7// Standard
8#include <string>
9
10
11namespace CPyCppyy {
12
13struct Parameter;
14struct CallContext;
15
16class CPYCPPYY_CLASS_EXPORT Converter {
17public:
18 virtual ~Converter();
19
20 Converter() = default;
21
22 Converter(Converter const& other) = delete;
23 Converter(Converter && other) = delete;
24 Converter& operator=(Converter const& other) = delete;
25 Converter& operator=(Converter && other) = delete;
26
27public:
28 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr) = 0;
29 virtual PyObject* FromMemory(void* address);
30 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
31 virtual bool HasState() { return false; }
32};
33
34// create/destroy converter from fully qualified type (public API)
35CPYCPPYY_EXPORT Converter* CreateConverter(const std::string& fullType, cdims_t dims = 0);
36CPYCPPYY_EXPORT void DestroyConverter(Converter* p);
37typedef Converter* (*cf_t)(cdims_t d);
38CPYCPPYY_EXPORT bool RegisterConverter(const std::string& name, cf_t fac);
39CPYCPPYY_EXPORT bool RegisterConverterAlias(const std::string& name, const std::string& target);
40CPYCPPYY_EXPORT bool UnregisterConverter(const std::string& name);
41
42
43// converters for special cases (only here b/c of external use of StrictInstancePtrConverter)
45public:
46 VoidArrayConverter(bool keepControl = true) { fKeepControl = keepControl; }
47
48public:
49 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr);
50 virtual PyObject* FromMemory(void* address);
51 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
52 virtual bool HasState() { return true; }
53
54protected:
55 virtual bool GetAddressSpecialCase(PyObject* pyobject, void*& address);
56 bool KeepControl() { return fKeepControl; }
57
58private:
60};
61
62template <bool ISCONST>
64public:
65 InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl = false) :
66 VoidArrayConverter(keepControl), fClass(klass) {}
67
68public:
69 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr);
70 virtual PyObject* FromMemory(void* address);
71 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
72
73protected:
75};
76
78public:
79 using InstancePtrConverter<false>::InstancePtrConverter;
80
81protected:
82 virtual bool GetAddressSpecialCase(PyObject*, void*&) { return false; }
83};
84
85} // namespace CPyCppyy
86
87#endif // !CPYCPPYY_CONVERTERS_H
_object PyObject
#define d(i)
Definition RSha256.hxx:102
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
#define CPYCPPYY_CLASS_EXPORT
Definition CommonDefs.h:27
#define CPYCPPYY_EXPORT
Definition CommonDefs.h:25
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)=0
Converter & operator=(Converter &&other)=delete
virtual bool HasState()
Definition Converters.h:31
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
Converter(Converter &&other)=delete
Converter & operator=(Converter const &other)=delete
Converter(Converter const &other)=delete
virtual PyObject * FromMemory(void *address)
InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl=false)
Definition Converters.h:65
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual bool GetAddressSpecialCase(PyObject *, void *&)
Definition Converters.h:82
VoidArrayConverter(bool keepControl=true)
Definition Converters.h:46
virtual bool GetAddressSpecialCase(PyObject *pyobject, void *&address)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
Converter *(* cf_t)(cdims_t d)
Definition Converters.h:37
CPYCPPYY_EXTERN bool RegisterConverter(const std::string &name, ConverterFactory_t)
const dims_t & cdims_t
Definition API.h:104
CPYCPPYY_EXTERN bool RegisterConverterAlias(const std::string &name, const std::string &target)
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
CPYCPPYY_EXTERN void DestroyConverter(Converter *p)
CPYCPPYY_EXTERN bool UnregisterConverter(const std::string &name)
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19