sbkconverter.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. // Copyright (C) 2016 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. #ifndef SBK_CONVERTER_H
  4. #define SBK_CONVERTER_H
  5. #include "sbkpython.h"
  6. #include "sbkmodule.h"
  7. #include "shibokenmacros.h"
  8. #include "sbkenum.h"
  9. #include "basewrapper_p.h"
  10. #include <limits>
  11. #include <string>
  12. struct SbkObject;
  13. /**
  14. * This is a convenience macro identical to Python's PyObject_TypeCheck,
  15. * except that the arguments have swapped places, for the great convenience
  16. * of generator.
  17. */
  18. #define SbkObject_TypeCheck(tp, ob) \
  19. (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
  20. extern "C"
  21. {
  22. /**
  23. * SbkConverter is used to perform type conversions from C++
  24. * to Python and vice-versa;.and it is also used for type checking.
  25. * SbkConverter is a private structure that must be accessed
  26. * using the functions provided by the converter API.
  27. */
  28. struct SbkConverter;
  29. struct SbkArrayConverter;
  30. /**
  31. * Given a void pointer to a C++ object, this function must return
  32. * the proper Python object. It may be either an existing wrapper
  33. * for the C++ object, or a newly create one. Or even the Python
  34. * equivalent of the C++ value passed in the argument.
  35. *
  36. * C++ -> Python
  37. */
  38. using CppToPythonFunc = PyObject *(*)(const void *);
  39. /** Same as CppToPythonFunc, but additionally receives the 'PyTypeObject *'.
  40. * This is handy for some converters, namely enumeration converters or
  41. * dynamic user-defined converters that invoke the type object. */
  42. using CppToPythonWithTypeFunc = PyObject *(*)(PyTypeObject *, const void *);
  43. /**
  44. * This function converts a Python object to a C++ value, it may be
  45. * a pointer, value, class, container or primitive type, passed via
  46. * a void pointer, that will be cast properly inside the function.
  47. * This function is usually returned by an IsConvertibleToCppFunc
  48. * function, or obtained knowing the type of the Python object input,
  49. * thus it will not check the Python object type, and will expect
  50. * the void pointer to be pointing to a proper variable.
  51. *
  52. * Python -> C++
  53. */
  54. using PythonToCppFunc = void (*)(PyObject *,void *);
  55. /**
  56. * Checks if the Python object passed in the argument is convertible to a
  57. * C++ type defined inside the function, it returns the converter function
  58. * that will transform a Python argument into a C++ value.
  59. * It returns NULL if the Python object is not convertible to the C++ type
  60. * that the function represents.
  61. *
  62. * Python -> C++ ?
  63. */
  64. using IsConvertibleToCppFunc = PythonToCppFunc (*)(PyObject *);
  65. } // extern "C"
  66. namespace Shiboken {
  67. namespace Conversions {
  68. class LIBSHIBOKEN_API SpecificConverter
  69. {
  70. public:
  71. enum Type
  72. {
  73. InvalidConversion,
  74. CopyConversion,
  75. PointerConversion,
  76. ReferenceConversion
  77. };
  78. explicit SpecificConverter(const char *typeName);
  79. SbkConverter *converter() { return m_converter; }
  80. operator SbkConverter *() const { return m_converter; }
  81. bool isValid() { return m_type != InvalidConversion; }
  82. operator bool() const { return m_type != InvalidConversion; }
  83. Type conversionType() { return m_type; }
  84. PyObject *toPython(const void *cppIn);
  85. void toCpp(PyObject *pyIn, void *cppOut);
  86. private:
  87. SbkConverter *m_converter;
  88. Type m_type;
  89. };
  90. /**
  91. * Creates a converter for a wrapper type.
  92. * \param type A Shiboken.ObjectType that will receive the new converter.
  93. * \param toCppPointerConvFunc Function to retrieve the C++ pointer held by a Python wrapper.
  94. * \param toCppPointerCheckFunc Check and return the retriever function of the C++ pointer held by a Python wrapper.
  95. * \param pointerToPythonFunc Function to convert a C++ object to a Python \p type wrapper, keeping their identity.
  96. * \param copyToPythonFunc Function to convert a C++ object to a Python \p type, copying the object.
  97. * \returns The new converter referred by the wrapper \p type.
  98. */
  99. LIBSHIBOKEN_API SbkConverter *createConverter(PyTypeObject *type,
  100. PythonToCppFunc toCppPointerConvFunc,
  101. IsConvertibleToCppFunc toCppPointerCheckFunc,
  102. CppToPythonFunc pointerToPythonFunc,
  103. CppToPythonFunc copyToPythonFunc = nullptr);
  104. /**
  105. * Creates a converter for a non wrapper type (primitive or container type).
  106. * \param type Python type representing to the new converter.
  107. * \param toPythonFunc Function to convert a C++ object to a Python \p type.
  108. * \returns A new type converter.
  109. */
  110. LIBSHIBOKEN_API SbkConverter *createConverter(PyTypeObject *type, CppToPythonFunc toPythonFunc);
  111. LIBSHIBOKEN_API SbkConverter *createConverter(PyTypeObject *type, CppToPythonWithTypeFunc toPythonFunc);
  112. LIBSHIBOKEN_API void deleteConverter(SbkConverter *converter);
  113. /// Sets the Python object to C++ pointer conversion function.
  114. LIBSHIBOKEN_API void setCppPointerToPythonFunction(SbkConverter *converter, CppToPythonFunc pointerToPythonFunc);
  115. /// Sets the C++ pointer to Python object conversion functions.
  116. LIBSHIBOKEN_API void setPythonToCppPointerFunctions(SbkConverter *converter,
  117. PythonToCppFunc toCppPointerConvFunc,
  118. IsConvertibleToCppFunc toCppPointerCheckFunc);
  119. /**
  120. * Adds a new conversion of a Python object to a C++ value.
  121. * This is used in copy and implicit conversions.
  122. */
  123. LIBSHIBOKEN_API void addPythonToCppValueConversion(SbkConverter *converter,
  124. PythonToCppFunc pythonToCppFunc,
  125. IsConvertibleToCppFunc isConvertibleToCppFunc);
  126. LIBSHIBOKEN_API void prependPythonToCppValueConversion(SbkConverter *converter,
  127. PythonToCppFunc pythonToCppFunc,
  128. IsConvertibleToCppFunc isConvertibleToCppFunc);
  129. LIBSHIBOKEN_API void addPythonToCppValueConversion(PyTypeObject *type,
  130. PythonToCppFunc pythonToCppFunc,
  131. IsConvertibleToCppFunc isConvertibleToCppFunc);
  132. LIBSHIBOKEN_API void addPythonToCppValueConversion(Shiboken::Module::TypeInitStruct typeStruct,
  133. PythonToCppFunc pythonToCppFunc,
  134. IsConvertibleToCppFunc isConvertibleToCppFunc);
  135. // C++ -> Python ---------------------------------------------------------------------------
  136. /**
  137. * Retrieves the Python wrapper object for the given \p cppIn C++ pointer object.
  138. * This function is used only for Value and Object Types.
  139. * Example usage:
  140. * TYPE *var;
  141. * PyObject *pyVar = pointerToPython(SBKTYPE, &var);
  142. */
  143. LIBSHIBOKEN_API PyObject *pointerToPython(PyTypeObject *type, const void *cppIn);
  144. LIBSHIBOKEN_API PyObject *pointerToPython(const SbkConverter *converter, const void *cppIn);
  145. /**
  146. * For the given \p cppIn C++ reference it returns the Python wrapper object,
  147. * always for Object Types, and when they already exist for reference types;
  148. * for when the latter doesn't have an existing wrapper type, the C++ object
  149. * is copied to Python.
  150. * Example usage:
  151. * TYPE &var = SOMETHING;
  152. * PyObject *pyVar = referenceToPython(SBKTYPE, &var);
  153. */
  154. LIBSHIBOKEN_API PyObject *referenceToPython(PyTypeObject *type, const void *cppIn);
  155. LIBSHIBOKEN_API PyObject *referenceToPython(const SbkConverter *converter, const void *cppIn);
  156. /**
  157. * Retrieves the Python wrapper object for the given C++ value pointed by \p cppIn.
  158. * This function is used only for Value Types.
  159. * Example usage:
  160. * TYPE var;
  161. * PyObject *pyVar = copyToPython(SBKTYPE, &var);
  162. */
  163. LIBSHIBOKEN_API PyObject *copyToPython(PyTypeObject *type, const void *cppIn);
  164. LIBSHIBOKEN_API PyObject *copyToPython(const SbkConverter *converter, const void *cppIn);
  165. // Python -> C++ ---------------------------------------------------------------------------
  166. struct PythonToCppConversion
  167. {
  168. enum Type {Invalid, Pointer, Value};
  169. operator bool() const { return type != Invalid; }
  170. void operator()(PyObject *po,void *cpp) const { function(po, cpp); }
  171. bool isValue() const { return type == Value; }
  172. PythonToCppFunc function = nullptr;
  173. Type type = Invalid;
  174. };
  175. /**
  176. * Returns a Python to C++ conversion function if the Python object is convertible to a C++ pointer.
  177. * It returns NULL if the Python object is not convertible to \p type.
  178. */
  179. LIBSHIBOKEN_API PythonToCppFunc isPythonToCppPointerConvertible(PyTypeObject *type, PyObject *pyIn);
  180. LIBSHIBOKEN_API PythonToCppConversion pythonToCppPointerConversion(PyTypeObject *type, PyObject *pyIn);
  181. LIBSHIBOKEN_API PythonToCppConversion pythonToCppPointerConversion(Module::TypeInitStruct typeStruct, PyObject *pyIn);
  182. /**
  183. * Returns a Python to C++ conversion function if the Python object is convertible to a C++ value.
  184. * The resulting converter function will create a copy of the Python object in C++, or implicitly
  185. * convert the object to the expected \p type.
  186. * It returns NULL if the Python object is not convertible to \p type.
  187. */
  188. LIBSHIBOKEN_API PythonToCppFunc isPythonToCppValueConvertible(PyTypeObject *type, PyObject *pyIn);
  189. LIBSHIBOKEN_API PythonToCppConversion pythonToCppValueConversion(PyTypeObject *type, PyObject *pyIn);
  190. /**
  191. * Returns a Python to C++ conversion function if the Python object is convertible to a C++ reference.
  192. * The resulting converter function will return the underlying C++ object held by the Python wrapper,
  193. * or a new C++ value if it must be a implicit conversion.
  194. * It returns NULL if the Python object is not convertible to \p type.
  195. */
  196. LIBSHIBOKEN_API PythonToCppFunc isPythonToCppReferenceConvertible(PyTypeObject *type, PyObject *pyIn);
  197. LIBSHIBOKEN_API PythonToCppConversion pythonToCppReferenceConversion(PyTypeObject *type, PyObject *pyIn);
  198. /// This is the same as isPythonToCppValueConvertible function.
  199. LIBSHIBOKEN_API PythonToCppFunc isPythonToCppConvertible(const SbkConverter *converter, PyObject *pyIn);
  200. LIBSHIBOKEN_API PythonToCppConversion pythonToCppReferenceConversion(const SbkConverter *converter, PyObject *pyIn);
  201. LIBSHIBOKEN_API PythonToCppConversion pythonToCppConversion(const SbkConverter *converter, PyObject *pyIn);
  202. LIBSHIBOKEN_API PythonToCppFunc isPythonToCppConvertible(const SbkArrayConverter *converter,
  203. int dim1, int dim2, PyObject *pyIn);
  204. LIBSHIBOKEN_API PythonToCppConversion pythonToCppConversion(const SbkArrayConverter *converter,
  205. int dim1, int dim2, PyObject *pyIn);
  206. /**
  207. * Returns the C++ pointer for the \p pyIn object cast to the type passed via \p desiredType.
  208. * It differs from Shiboken::Object::cppPointer because it casts the pointer to a proper
  209. * memory offset depending on the desired type.
  210. */
  211. LIBSHIBOKEN_API void *cppPointer(PyTypeObject *desiredType, SbkObject *pyIn);
  212. /// Converts a Python object \p pyIn to C++ and stores the result in the C++ pointer passed in \p cppOut.
  213. LIBSHIBOKEN_API void pythonToCppPointer(PyTypeObject *type, PyObject *pyIn, void *cppOut);
  214. LIBSHIBOKEN_API void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cppOut);
  215. /// Converts a Python object \p pyIn to C++, and copies the result in the C++ variable passed in \p cppOut.
  216. LIBSHIBOKEN_API void pythonToCppCopy(PyTypeObject *type, PyObject *pyIn, void *cppOut);
  217. LIBSHIBOKEN_API void pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void *cppOut);
  218. /**
  219. * Helper function returned by generated convertible checking functions
  220. * that returns a C++ NULL when the input Python object is None.
  221. */
  222. LIBSHIBOKEN_API void nonePythonToCppNullPtr(PyObject *, void *cppOut);
  223. /**
  224. * Returns true if the \p toCpp function passed is an implicit conversion of Python \p type.
  225. * It is used when C++ expects a reference argument, so it may be the same object received
  226. * from Python, or another created through implicit conversion.
  227. */
  228. [[deprecated]] LIBSHIBOKEN_API bool isImplicitConversion(PyTypeObject *type, PythonToCppFunc toCpp);
  229. /// Registers a converter with a type name that may be used to retrieve the converter.
  230. /// Use for fully qualified names (main type). This will overwrite existing converters
  231. /// of the same name.
  232. LIBSHIBOKEN_API void registerConverterName(SbkConverter *converter, const char *typeName);
  233. /// Registers a converter with a type name that may be used to retrieve the converter
  234. /// unless there is already a converter for the name. Use for partially qualified names.
  235. LIBSHIBOKEN_API void registerConverterAlias(SbkConverter *converter, const char *typeName);
  236. /// Returns the converter for a given type name, or NULL if it wasn't registered before.
  237. LIBSHIBOKEN_API SbkConverter *getConverter(const char *typeName);
  238. /// Returns the converter for a primitive type.
  239. LIBSHIBOKEN_API SbkConverter *primitiveTypeConverter(int index);
  240. /// Returns true if a Python sequence is comprised of objects of the given \p type.
  241. LIBSHIBOKEN_API bool checkSequenceTypes(PyTypeObject *type, PyObject *pyIn);
  242. /// Returns true if a Python type is iterable and comprised of objects of the
  243. /// given \p type.
  244. LIBSHIBOKEN_API bool checkIterableTypes(PyTypeObject *type, PyObject *pyIn);
  245. /// Returns true if a Python sequence is comprised of objects of a type convertible to the one represented by the given \p converter.
  246. LIBSHIBOKEN_API bool convertibleSequenceTypes(const SbkConverter *converter, PyObject *pyIn);
  247. /// Returns true if a Python sequence is comprised of objects of a type convertible to \p type.
  248. LIBSHIBOKEN_API bool convertibleSequenceTypes(PyTypeObject *type, PyObject *pyIn);
  249. /// Returns true if a Python type is iterable and comprised of objects of a
  250. /// type convertible to the one represented by the given \p converter.
  251. LIBSHIBOKEN_API bool convertibleIterableTypes(const SbkConverter *converter, PyObject *pyIn);
  252. /// Returns true if a Python type is iterable and comprised of objects of a
  253. /// type convertible to \p type.
  254. LIBSHIBOKEN_API bool convertibleIterableTypes(PyTypeObject *type, PyObject *pyIn);
  255. /// Returns true if a Python sequence can be converted to a C++ pair.
  256. LIBSHIBOKEN_API bool checkPairTypes(PyTypeObject *firstType, PyTypeObject *secondType, PyObject *pyIn);
  257. /// Returns true if a Python sequence can be converted to a C++ pair.
  258. LIBSHIBOKEN_API bool convertiblePairTypes(const SbkConverter *firstConverter, bool firstCheckExact,
  259. const SbkConverter *secondConverter, bool secondCheckExact,
  260. PyObject *pyIn);
  261. /// Returns true if a Python dictionary can be converted to a C++ hash or map.
  262. LIBSHIBOKEN_API bool checkDictTypes(PyTypeObject *keyType, PyTypeObject *valueType, PyObject *pyIn);
  263. /// Returns true if a Python dictionary can be converted to a C++ multi hash/map.
  264. /// The Python dictionary is expected to contain lists of values
  265. bool checkMultiDictTypes(PyTypeObject *keyType, PyTypeObject *valueType,
  266. PyObject *pyIn);
  267. /// Returns true if a Python dictionary can be converted to a C++ hash or map.
  268. LIBSHIBOKEN_API bool convertibleDictTypes(const SbkConverter *keyConverter, bool keyCheckExact,
  269. const SbkConverter *valueConverter, bool valueCheckExact,
  270. PyObject *pyIn);
  271. /// Returns true if a Python dictionary can be converted to a C++ multi hash/map.
  272. /// The Python dictionary is expected to contain lists of values
  273. LIBSHIBOKEN_API bool convertibleMultiDictTypes(const SbkConverter *keyConverter,
  274. bool keyCheckExact,
  275. const SbkConverter *valueConverter,
  276. bool valueCheckExact,
  277. PyObject *pyIn);
  278. /// Returns the Python type object associated with the given \p converter.
  279. LIBSHIBOKEN_API PyTypeObject *getPythonTypeObject(const SbkConverter *converter);
  280. /// Returns the Python type object for the given \p typeName.
  281. LIBSHIBOKEN_API PyTypeObject *getPythonTypeObject(const char *typeName);
  282. /// Returns true if the Python type associated with the converter is a value type.
  283. LIBSHIBOKEN_API bool pythonTypeIsValueType(const SbkConverter *converter);
  284. /// Returns true if the Python type associated with the converter is an object type.
  285. LIBSHIBOKEN_API bool pythonTypeIsObjectType(const SbkConverter *converter);
  286. /// Returns true if the Python type associated with the converter is a wrapper type.
  287. LIBSHIBOKEN_API bool pythonTypeIsWrapperType(const SbkConverter *converter);
  288. enum : int {
  289. SBK_PY_LONG_LONG_IDX = 0,
  290. // Qt5: name collision in QtCore after QBool is replaced by bool
  291. SBK_BOOL_IDX_1 = 1,
  292. SBK_CHAR_IDX = 2,
  293. SBK_CONSTCHARPTR_IDX = 3,
  294. SBK_DOUBLE_IDX = 4,
  295. SBK_FLOAT_IDX = 5,
  296. SBK_INT_IDX = 6,
  297. SBK_SIGNEDINT_IDX = 6,
  298. SBK_LONG_IDX = 7,
  299. SBK_SHORT_IDX = 8,
  300. SBK_SIGNEDCHAR_IDX = 9,
  301. SBK_STD_STRING_IDX = 10,
  302. SBK_STD_WSTRING_IDX = 11,
  303. SBK_UNSIGNEDPY_LONG_LONG_IDX = 12,
  304. SBK_UNSIGNEDCHAR_IDX = 13,
  305. SBK_UNSIGNEDINT_IDX = 14,
  306. SBK_UNSIGNEDLONG_IDX = 15,
  307. SBK_UNSIGNEDSHORT_IDX = 16,
  308. SBK_VOIDPTR_IDX = 17,
  309. SBK_NULLPTR_T_IDX = 18
  310. };
  311. template<typename T> SbkConverter *PrimitiveTypeConverter() { return nullptr; }
  312. template<> inline SbkConverter *PrimitiveTypeConverter<PY_LONG_LONG>() { return primitiveTypeConverter(SBK_PY_LONG_LONG_IDX); }
  313. template<> inline SbkConverter *PrimitiveTypeConverter<bool>() { return primitiveTypeConverter(SBK_BOOL_IDX_1); }
  314. template<> inline SbkConverter *PrimitiveTypeConverter<char>() { return primitiveTypeConverter(SBK_CHAR_IDX); }
  315. template<> inline SbkConverter *PrimitiveTypeConverter<const char *>() { return primitiveTypeConverter(SBK_CONSTCHARPTR_IDX); }
  316. template<> inline SbkConverter *PrimitiveTypeConverter<double>() { return primitiveTypeConverter(SBK_DOUBLE_IDX); }
  317. template<> inline SbkConverter *PrimitiveTypeConverter<float>() { return primitiveTypeConverter(SBK_FLOAT_IDX); }
  318. template<> inline SbkConverter *PrimitiveTypeConverter<int>() { return primitiveTypeConverter(SBK_INT_IDX); }
  319. template<> inline SbkConverter *PrimitiveTypeConverter<long>() { return primitiveTypeConverter(SBK_LONG_IDX); }
  320. template<> inline SbkConverter *PrimitiveTypeConverter<short>() { return primitiveTypeConverter(SBK_SHORT_IDX); }
  321. template<> inline SbkConverter *PrimitiveTypeConverter<signed char>() { return primitiveTypeConverter(SBK_SIGNEDCHAR_IDX); }
  322. template<> inline SbkConverter *PrimitiveTypeConverter<std::string>() { return primitiveTypeConverter(SBK_STD_STRING_IDX); }
  323. template<> inline SbkConverter *PrimitiveTypeConverter<std::wstring>() { return primitiveTypeConverter(SBK_STD_WSTRING_IDX); }
  324. template<> inline SbkConverter *PrimitiveTypeConverter<unsigned PY_LONG_LONG>() { return primitiveTypeConverter(SBK_UNSIGNEDPY_LONG_LONG_IDX); }
  325. template<> inline SbkConverter *PrimitiveTypeConverter<unsigned char>() { return primitiveTypeConverter(SBK_UNSIGNEDCHAR_IDX); }
  326. template<> inline SbkConverter *PrimitiveTypeConverter<unsigned int>() { return primitiveTypeConverter(SBK_UNSIGNEDINT_IDX); }
  327. template<> inline SbkConverter *PrimitiveTypeConverter<unsigned long>() { return primitiveTypeConverter(SBK_UNSIGNEDLONG_IDX); }
  328. template<> inline SbkConverter *PrimitiveTypeConverter<unsigned short>() { return primitiveTypeConverter(SBK_UNSIGNEDSHORT_IDX); }
  329. template<> inline SbkConverter *PrimitiveTypeConverter<void *>() { return primitiveTypeConverter(SBK_VOIDPTR_IDX); }
  330. template<> inline SbkConverter *PrimitiveTypeConverter<std::nullptr_t>() { return primitiveTypeConverter(SBK_NULLPTR_T_IDX); }
  331. } // namespace Shiboken::Conversions
  332. /**
  333. * This function template is used to get the PyTypeObject of a C++ type T.
  334. * All implementations should be provided by template specializations generated by the generator when
  335. * T isn't a C++ primitive type.
  336. * \see SpecialCastFunction
  337. */
  338. template<typename T> PyTypeObject *SbkType() { return nullptr; }
  339. // Below are the template specializations for C++ primitive types.
  340. template<> inline PyTypeObject *SbkType<PY_LONG_LONG>() { return &PyLong_Type; }
  341. template<> inline PyTypeObject *SbkType<bool>() { return &PyBool_Type; }
  342. template<> inline PyTypeObject *SbkType<char>() { return &PyLong_Type; }
  343. template<> inline PyTypeObject *SbkType<double>() { return &PyFloat_Type; }
  344. template<> inline PyTypeObject *SbkType<float>() { return &PyFloat_Type; }
  345. template<> inline PyTypeObject *SbkType<int>() { return &PyLong_Type; }
  346. template<> inline PyTypeObject *SbkType<long>() { return &PyLong_Type; }
  347. template<> inline PyTypeObject *SbkType<short>() { return &PyLong_Type; }
  348. template<> inline PyTypeObject *SbkType<signed char>() { return &PyLong_Type; }
  349. template<> inline PyTypeObject *SbkType<unsigned PY_LONG_LONG>() { return &PyLong_Type; }
  350. template<> inline PyTypeObject *SbkType<unsigned char>() { return &PyLong_Type; }
  351. template<> inline PyTypeObject *SbkType<unsigned int>() { return &PyLong_Type; }
  352. template<> inline PyTypeObject *SbkType<unsigned long>() { return &PyLong_Type; }
  353. template<> inline PyTypeObject *SbkType<unsigned short>() { return &PyLong_Type; }
  354. template<> inline PyTypeObject *SbkType<std::nullptr_t>() { return Py_TYPE(&_Py_NoneStruct); }
  355. } // namespace Shiboken
  356. #define SbkChar_Check(X) (PyNumber_Check(X) || Shiboken::String::checkChar(X))
  357. struct PySideQFlagsType;
  358. struct SbkQFlagsTypePrivate
  359. {
  360. SbkConverter *converter;
  361. };
  362. #endif // SBK_CONVERTER_H