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*); \
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*); \
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); \
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*); \
65 virtual bool HasState() { return true; } \
70class name##ArrayPtrConverter : public name##ArrayConverter { \
72 using name##ArrayConverter::name##ArrayConverter; \
73 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
82class UCharAsIntConverter :
public UCharConverter {
84 using UCharConverter::UCharConverter;
124class VoidConverter :
public Converter {
129class CStringConverter :
public Converter {
131 CStringConverter(
long maxSize = -1) :
fMaxSize(maxSize) {}
135 virtual PyObject* FromMemory(
void* address);
136 virtual bool ToMemory(
PyObject* value,
void* address);
137 virtual bool HasState() {
return true; }
144class NonConstCStringConverter :
public CStringConverter {
146 NonConstCStringConverter(
long maxSize = -1) : CStringConverter(maxSize) {}
150 virtual PyObject* FromMemory(
void* address);
153class WCStringConverter :
public Converter {
155 WCStringConverter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
156 WCStringConverter(
const WCStringConverter&) =
delete;
157 WCStringConverter&
operator=(
const WCStringConverter&) =
delete;
162 virtual PyObject* FromMemory(
void* address);
163 virtual bool ToMemory(
PyObject* value,
void* address);
164 virtual bool HasState() {
return true; }
171class CString16Converter :
public Converter {
173 CString16Converter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
174 CString16Converter(
const CString16Converter&) =
delete;
175 CString16Converter&
operator=(
const CString16Converter&) =
delete;
180 virtual PyObject* FromMemory(
void* address);
181 virtual bool ToMemory(
PyObject* value,
void* address);
182 virtual bool HasState() {
return true; }
189class CString32Converter :
public Converter {
191 CString32Converter(
long maxSize = -1) :
fBuffer(nullptr),
fMaxSize(maxSize) {}
192 CString32Converter(
const CString32Converter&) =
delete;
193 CString32Converter&
operator=(
const CString32Converter&) =
delete;
198 virtual PyObject* FromMemory(
void* address);
199 virtual bool ToMemory(
PyObject* value,
void* address);
200 virtual bool HasState() {
return true; }
211#if __cplusplus > 201402L
227class CStringArrayConverter :
public SCharArrayPtrConverter {
229 using SCharArrayPtrConverter::SCharArrayPtrConverter;
230 virtual PyObject* FromMemory(
void* address);
235class NullptrConverter :
public Converter {
240class InstanceConverter :
public StrictInstancePtrConverter {
242 using StrictInstancePtrConverter::StrictInstancePtrConverter;
244 virtual PyObject* FromMemory(
void*);
245 virtual bool ToMemory(
PyObject*,
void*);
248class InstanceRefConverter :
public Converter {
255 virtual PyObject* FromMemory(
void* address);
256 virtual bool HasState() {
return true; }
263class InstanceMoveConverter :
public InstanceRefConverter {
265 InstanceMoveConverter(
Cppyy::TCppType_t klass) : InstanceRefConverter(klass,
true) {}
269template <
bool ISREFERENCE>
270class InstancePtrPtrConverter :
public InstancePtrConverter {
276 virtual PyObject* FromMemory(
void* address);
277 virtual bool ToMemory(
PyObject* value,
void* address);
280class InstanceArrayConverter :
public InstancePtrConverter {
283 InstancePtrConverter(klass, keepControl) {
284 dim_t size = (dims && 0 < dims[0]) ? dims[0]+1: 1;
287 for (
int i = 0; i < size; ++i)
m_dims[i] = dims[i];
292 InstanceArrayConverter(
const InstanceArrayConverter&) =
delete;
293 InstanceArrayConverter&
operator=(
const InstanceArrayConverter&) =
delete;
294 virtual ~InstanceArrayConverter() {
delete []
m_dims; }
298 virtual PyObject* FromMemory(
void* address);
299 virtual bool ToMemory(
PyObject* value,
void* address);
306class ComplexDConverter:
public InstanceConverter {
308 ComplexDConverter(
bool keepControl =
false);
312 virtual PyObject* FromMemory(
void* address);
313 virtual bool ToMemory(
PyObject* value,
void* address);
322class STLIteratorConverter :
public Converter {
329class VoidPtrRefConverter :
public Converter {
334class VoidPtrPtrConverter :
public Converter {
336 VoidPtrPtrConverter(
size_t size) {
fSize = size; }
338 virtual PyObject* FromMemory(
void* address);
339 virtual bool HasState() {
return true; }
348#define CPPYY_DECLARE_STRING_CONVERTER(name, strtype) \
349class name##Converter : public InstanceConverter { \
351 name##Converter(bool keepControl = true); \
353 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr); \
354 virtual PyObject* FromMemory(void* address); \
355 virtual bool ToMemory(PyObject* value, void* address); \
363class STLStringViewConverter :
public STLStringViewBaseConverter {
369class STLStringMoveConverter :
public STLStringConverter {
371 using STLStringConverter::STLStringConverter;
379class FunctionPointerConverter :
public Converter {
381 FunctionPointerConverter(
const std::string& ret,
const std::string& sig) :
386 virtual PyObject* FromMemory(
void* address);
387 virtual bool ToMemory(
PyObject*,
void*);
388 virtual bool HasState() {
return true; }
396class StdFunctionConverter :
public FunctionPointerConverter {
398 StdFunctionConverter(Converter* cnv,
const std::string& ret,
const std::string& sig) :
400 StdFunctionConverter(
const StdFunctionConverter&) =
delete;
401 StdFunctionConverter&
operator=(
const StdFunctionConverter&) =
delete;
406 virtual PyObject* FromMemory(
void* address);
407 virtual bool ToMemory(
PyObject* value,
void* address);
416class SmartPtrConverter :
public Converter {
420 bool keepControl =
false,
427 virtual PyObject* FromMemory(
void* address);
429 virtual bool HasState() {
return true; }
432 virtual bool GetAddressSpecialCase(
PyObject*,
void*&) {
return false; }
442class InitializerListConverter :
public Converter {
444 InitializerListConverter(Converter* cnv,
size_t sz) :
446 InitializerListConverter(
const InitializerListConverter&) =
delete;
447 InitializerListConverter&
operator=(
const InitializerListConverter&) =
delete;
448 virtual ~InitializerListConverter();
452 virtual bool HasState() {
return true; }
461class 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)
Binding & operator=(OUT(*fun)(void))
InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl=false)
basic_string_view< char > string_view