1#ifndef CPYCPPYY_DECLARECONVERTERS_H
2#define CPYCPPYY_DECLARECONVERTERS_H
20#define CPPYY_DECLARE_BASIC_CONVERTER(name) \
21class name##Converter : public Converter { \
23 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
24 virtual PyObject* FromMemory(void*); \
25 virtual bool ToMemory(PyObject*, void*, PyObject* = nullptr); \
28class Const##name##RefConverter : public Converter { \
30 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
31 virtual PyObject* FromMemory(void*); \
35#define CPPYY_DECLARE_BASIC_CONVERTER2(name, base) \
36class name##Converter : public base##Converter { \
38 virtual PyObject* FromMemory(void*); \
39 virtual bool ToMemory(PyObject*, void*, PyObject* = nullptr); \
42class Const##name##RefConverter : public Converter { \
44 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
45 virtual PyObject* FromMemory(void*); \
48#define CPPYY_DECLARE_REFCONVERTER(name) \
49class name##RefConverter : public Converter { \
51 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
52 virtual PyObject* FromMemory(void*); \
55#define CPPYY_DECLARE_ARRAY_CONVERTER(name) \
56class name##ArrayConverter : public Converter { \
58 name##ArrayConverter(dims_t shape, bool init = true); \
59 name##ArrayConverter(const name##ArrayConverter&) = delete; \
60 name##ArrayConverter& operator=(const name##ArrayConverter&) = delete; \
61 virtual ~name##ArrayConverter() { delete [] fShape; } \
62 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
63 virtual PyObject* FromMemory(void*); \
64 virtual bool ToMemory(PyObject*, void*, PyObject* = nullptr); \
65 virtual bool HasState() { return true; } \
71class name##ArrayPtrConverter : public name##ArrayConverter { \
73 using name##ArrayConverter::name##ArrayConverter; \
74 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
83class UCharAsIntConverter :
public UCharConverter {
85 using UCharConverter::UCharConverter;
125class VoidConverter :
public Converter {
130class CStringConverter :
public Converter {
132 CStringConverter(
long maxSize = -1) :
fMaxSize(maxSize) {}
136 virtual PyObject* FromMemory(
void* address);
138 virtual bool HasState() {
return true; }
145class NonConstCStringConverter :
public CStringConverter {
147 NonConstCStringConverter(
long maxSize = -1) : CStringConverter(maxSize) {}
151 virtual PyObject* FromMemory(
void* address);
154class WCStringConverter :
public Converter {
156 WCStringConverter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
157 WCStringConverter(
const WCStringConverter&) =
delete;
158 WCStringConverter&
operator=(
const WCStringConverter&) =
delete;
159 virtual ~WCStringConverter() {
free(fBuffer); }
163 virtual PyObject* FromMemory(
void* address);
165 virtual bool HasState() {
return true; }
172class CString16Converter :
public Converter {
174 CString16Converter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
175 CString16Converter(
const CString16Converter&) =
delete;
176 CString16Converter&
operator=(
const CString16Converter&) =
delete;
177 virtual ~CString16Converter() {
free(fBuffer); }
181 virtual PyObject* FromMemory(
void* address);
183 virtual bool HasState() {
return true; }
190class CString32Converter :
public Converter {
192 CString32Converter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
193 CString32Converter(
const CString32Converter&) =
delete;
194 CString32Converter&
operator=(
const CString32Converter&) =
delete;
195 virtual ~CString32Converter() {
free(fBuffer); }
199 virtual PyObject* FromMemory(
void* address);
201 virtual bool HasState() {
return true; }
212#if __cplusplus > 201402L
228class CStringArrayConverter :
public SCharArrayPtrConverter {
230 using SCharArrayPtrConverter::SCharArrayPtrConverter;
231 virtual PyObject* FromMemory(
void* address);
236class NullptrConverter :
public Converter {
241class InstanceConverter :
public StrictInstancePtrConverter {
243 using StrictInstancePtrConverter::StrictInstancePtrConverter;
245 virtual PyObject* FromMemory(
void*);
249class InstanceRefConverter :
public Converter {
256 virtual PyObject* FromMemory(
void* address);
257 virtual bool HasState() {
return true; }
264class InstanceMoveConverter :
public InstanceRefConverter {
266 InstanceMoveConverter(
Cppyy::TCppType_t klass) : InstanceRefConverter(klass,
true) {}
270template <
bool ISREFERENCE>
271class InstancePtrPtrConverter :
public InstancePtrConverter {
277 virtual PyObject* FromMemory(
void* address);
281class InstanceArrayConverter :
public InstancePtrConverter {
284 InstancePtrConverter(klass, keepControl) {
285 dim_t size = (dims && 0 < dims[0]) ? dims[0]+1: 1;
288 for (
int i = 0; i <
size; ++i) m_dims[i] = dims[i];
293 InstanceArrayConverter(
const InstanceArrayConverter&) =
delete;
294 InstanceArrayConverter&
operator=(
const InstanceArrayConverter&) =
delete;
295 virtual ~InstanceArrayConverter() {
delete []
m_dims; }
299 virtual PyObject* FromMemory(
void* address);
307class ComplexDConverter:
public InstanceConverter {
309 ComplexDConverter(
bool keepControl =
false);
313 virtual PyObject* FromMemory(
void* address);
323class STLIteratorConverter :
public Converter {
330class VoidPtrRefConverter :
public Converter {
335class VoidPtrPtrConverter :
public Converter {
339 virtual PyObject* FromMemory(
void* address);
340 virtual bool HasState() {
return true; }
349#define CPPYY_DECLARE_STRING_CONVERTER(name, strtype) \
350class name##Converter : public InstanceConverter { \
352 name##Converter(bool keepControl = true); \
354 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
355 virtual PyObject* FromMemory(void* address); \
356 virtual bool ToMemory(PyObject*, void*, PyObject* = nullptr); \
364class STLStringViewConverter :
public STLStringViewBaseConverter {
370class STLStringMoveConverter :
public STLStringConverter {
372 using STLStringConverter::STLStringConverter;
380class FunctionPointerConverter :
public Converter {
382 FunctionPointerConverter(
const std::string& ret,
const std::string& sig) :
387 virtual PyObject* FromMemory(
void* address);
389 virtual bool HasState() {
return true; }
397class StdFunctionConverter :
public FunctionPointerConverter {
399 StdFunctionConverter(Converter* cnv,
const std::string& ret,
const std::string& sig) :
401 StdFunctionConverter(
const StdFunctionConverter&) =
delete;
402 StdFunctionConverter&
operator=(
const StdFunctionConverter&) =
delete;
403 virtual ~StdFunctionConverter() { Py_XDECREF(fFuncWrap);
delete fConverter; }
407 virtual PyObject* FromMemory(
void* address);
417class SmartPtrConverter :
public Converter {
421 bool keepControl =
false,
428 virtual PyObject* FromMemory(
void* address);
430 virtual bool HasState() {
return true; }
433 virtual bool GetAddressSpecialCase(
PyObject*,
void*&) {
return false; }
443class InitializerListConverter :
public Converter {
445 InitializerListConverter(Converter* cnv,
size_t sz) :
447 InitializerListConverter(
const InitializerListConverter&) =
delete;
448 InitializerListConverter&
operator=(
const InitializerListConverter&) =
delete;
449 virtual ~InitializerListConverter();
453 virtual bool HasState() {
return true; }
462class NotImplementedConverter :
public Converter {
#define CPPYY_DECLARE_ARRAY_CONVERTER(name)
#define CPPYY_DECLARE_STRING_CONVERTER(name, strtype)
#define CPPYY_DECLARE_BASIC_CONVERTER(name)
#define CPPYY_DECLARE_REFCONVERTER(name)
Cppyy::TCppType_t fSmartPtrType
Cppyy::TCppType_t fUnderlyingType
#define CPPYY_DECLARE_BASIC_CONVERTER2(name, base)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Binding & operator=(OUT(*fun)(void))
InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl=false)
Set of helper functions that are invoked from the pythonizors, on the Python side.