3#ifndef PYROOT_CONVERTERS_H
4#define PYROOT_CONVERTERS_H
31#define PYROOT_DECLARE_BASIC_CONVERTER( name ) \
32 class T##name##Converter : public TConverter { \
34 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
35 virtual PyObject* FromMemory( void* ); \
36 virtual Bool_t ToMemory( PyObject*, void* ); \
39 class TConst##name##RefConverter : public TConverter { \
41 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
45#define PYROOT_DECLARE_BASIC_CONVERTER2( name, base ) \
46 class T##name##Converter : public T##base##Converter { \
48 virtual PyObject* FromMemory( void* ); \
49 virtual Bool_t ToMemory( PyObject*, void* ); \
52 class TConst##name##RefConverter : public TConverter { \
54 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
57#define PYROOT_DECLARE_REF_CONVERTER( name ) \
58 class T##name##RefConverter : public TConverter { \
60 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
63#define PYROOT_DECLARE_ARRAY_CONVERTER( name ) \
64 class T##name##Converter : public TConverter { \
66 T##name##Converter( Py_ssize_t size = -1 ) { fSize = size; } \
67 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
68 virtual PyObject* FromMemory( void* ); \
69 virtual Bool_t ToMemory( PyObject*, void* ); \
74 class T##name##RefConverter : public T##name##Converter { \
76 using T##name##Converter::T##name##Converter; \
77 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
195 using TStrictCppObjectConverter::TStrictCppObjectConverter;
213 template <
bool ISREFERENCE>
234 virtual PyObject* FromMemory(
void* address );
257 virtual PyObject* FromMemory(
void* address );
262#define PYROOT_DECLARE_STRING_CONVERTER( name, strtype ) \
263 class T##name##Converter : public TCppObjectConverter { \
265 T##name##Converter( Bool_t keepControl = kTRUE ); \
267 virtual Bool_t SetArg( PyObject*, TParameter&, TCallContext* ctxt = 0 );\
268 virtual PyObject* FromMemory( void* address ); \
269 virtual Bool_t ToMemory( PyObject* value, void* address ); \
291 : fClass( klass ), fRawPtrType( rawPtrType ), fDereferencer( deref ),
292 fKeepControl( keepControl ), fHandlePtr( handlePtr ) {}
296 virtual PyObject* FromMemory(
void* address );
virtual Bool_t ToMemory(PyObject *value, void *address)
could happen if no derived class override
virtual PyObject * FromMemory(void *address)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
construct a new string and copy it in new memory
TCStringConverter(UInt_t maxSize=UINT_MAX)
virtual Bool_t ToMemory(PyObject *value, void *address)
could happen if no derived class override
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)=0
virtual PyObject * FromMemory(void *address)
TCppObjectArrayConverter(Cppyy::TCppType_t klass, size_t size, Bool_t keepControl=kFALSE)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert pyobject to C++ instance*, set arg for call
virtual PyObject * FromMemory(void *address)
construct python object from C++ instance read at <address>
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ instance, write it at <address>
TCppObjectConverter(Cppyy::TCppType_t klass, Bool_t keepControl=kFALSE)
virtual Bool_t ToMemory(PyObject *value, void *address)
convert to C++ instance*, write it at <address>
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert pyobject to C++ instance**, set arg for call
virtual PyObject * FromMemory(void *address)
construct python object from C++ instance* read at <address>
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
just convert pointer if it is a ROOT object
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
attempt base class first (i.e. passing a string), but if that fails, try a buffer
TNonConstCStringConverter(UInt_t maxSize=UINT_MAX)
virtual PyObject * FromMemory(void *address)
assume this is a buffer access if the size is known; otherwise assume string
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
attempt base class first (i.e. passing a string), but if that fails, try a buffer
TNonConstUCStringConverter(UInt_t maxSize=UINT_MAX)
TRefCppObjectConverter(Cppyy::TCppType_t klass)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert pyobject to C++ instance&, set arg for call
Cppyy::TCppMethod_t fDereferencer
Cppyy::TCppType_t fRawPtrType
TSmartPtrCppObjectConverter(Cppyy::TCppType_t klass, Cppyy::TCppType_t rawPtrType, Cppyy::TCppMethod_t deref, Bool_t keepControl=kFALSE, Bool_t handlePtr=kFALSE)
virtual Bool_t GetAddressSpecialCase(PyObject *, void *&)
virtual Bool_t GetAddressSpecialCase(PyObject *, void *&)
(1): "null pointer" or C++11 style nullptr
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
convert pyobject to C++ instance, set arg for call
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
just convert pointer if it is a ROOT object
virtual Bool_t GetAddressSpecialCase(PyObject *pyobject, void *&address)
(1): "null pointer" or C++11 style nullptr
virtual Bool_t ToMemory(PyObject *value, void *address)
just convert pointer if it is a ROOT object
virtual PyObject * FromMemory(void *address)
nothing sensible can be done, just return <address> as pylong
TVoidArrayConverter(Bool_t keepControl=kTRUE)
virtual Bool_t SetArg(PyObject *, TParameter &, TCallContext *ctxt=0)
can't happen (unless a type is mapped wrongly), but implemented for completeness
Named parameter, streamable and storable.
basic_string_view< char > string_view
PYROOT_DECLARE_STRING_CONVERTER(TString, TString)
PYROOT_DECLARE_ARRAY_CONVERTER(BoolArray)
TConverter * CreateConverter(const std::string &fullType, Long_t size=-1)
PYROOT_DECLARE_BASIC_CONVERTER(Long)
PYROOT_DECLARE_REF_CONVERTER(Int)
PYROOT_DECLARE_BASIC_CONVERTER2(UInt, ULong)