11 #include "interfaces/legacy/AddonClass.h" 12 #include "interfaces/legacy/Exception.h" 13 #include "interfaces/legacy/Window.h" 33 void PyXBMCGetUnicodeString(std::string& buf, PyObject* pObject,
bool coerceToString =
false,
34 const char*
pos =
"unknown",
35 const char* methodname =
"unknown");
41 PyTypeObject pythonType;
42 const std::type_index typeIndex;
44 explicit TypeInfo(
const std::type_info& ti);
56 #define XBMC_PYTHON_TYPE_MAGIC_NUMBER 0x58626D63 65 const char* methodNameForErrorString,
66 const char* typenameForErrorString)
68 if (pythonObj == NULL || pythonObj == Py_None)
70 if (reinterpret_cast<PyHolder*>(pythonObj)->magicNumber != XBMC_PYTHON_TYPE_MAGIC_NUMBER || !PyObject_TypeCheck(pythonObj, const_cast<PyTypeObject*>((&(typeToCheck->pythonType)))))
71 throw XBMCAddon::WrongTypeException(
"Incorrect type passed to \"%s\", was expecting a \"%s\".",methodNameForErrorString,typenameForErrorString);
72 return reinterpret_cast<PyHolder*
>(pythonObj)->pSelf;
75 bool isParameterRightType(
const char* passedType,
const char* expectedType,
const char* methodNamespacePrefix,
bool tryReverse =
true);
78 const char* methodNamespacePrefix,
const char* methodNameForErrorString);
89 inline XBMCAddon::AddonClass* retrieveApiInstance(
const PyObject* pythonObj,
const char* expectedType,
const char* methodNamespacePrefix,
90 const char* methodNameForErrorString)
92 return (pythonObj == NULL || pythonObj == Py_None) ? NULL :
93 doretrieveApiInstance(reinterpret_cast<const PyHolder*>(pythonObj),reinterpret_cast<const PyHolder*>(pythonObj)->typeInfo, expectedType, methodNamespacePrefix, methodNameForErrorString);
130 PyObject* makePythonInstance(
XBMCAddon::AddonClass* api, PyTypeObject* pythonType,
bool incrementRefCount);
143 return makePythonInstance(api,NULL,incrementRefCount);
146 void registerAddonClassTypeInformation(
const TypeInfo* classInfo);
149 int dummy_tp_init(PyObject*
self, PyObject* args, PyObject* kwds);
157 inline void setPyObjectForDirector(PyObject* pyargself) {
self = pyargself; }
173 PythonToCppException(
const std::string &exceptionType,
const std::string &exceptionValue,
const std::string &exceptionTraceback);
175 static bool ParsePythonException(std::string &exceptionType, std::string &exceptionValue, std::string &exceptionTraceback);
178 void SetMessage(
const std::string &exceptionType,
const std::string &exceptionValue,
const std::string &exceptionTraceback);
183 static inline int compare(PyObject* obj1, PyObject* obj2,
const char* swigType,
const char* methodNamespacePrefix,
const char* methodNameForErrorString)
188 T* o1 = (T*)retrieveApiInstance(obj1, swigType, methodNamespacePrefix, methodNameForErrorString);
189 T* o2 = (T*)retrieveApiInstance(obj2, swigType, methodNamespacePrefix, methodNameForErrorString);
191 return ((*o1) < (*o2) ? -1 :
192 ((*o1) > (*o2) ? 1 : 0));
194 catch (
const XBMCAddon::WrongTypeException& e)
196 CLog::Log(LOGERROR,
"EXCEPTION: {}", e.GetExMessage());
197 PyErr_SetString(PyExc_RuntimeError, e.GetExMessage());
Definition: AddonPythonInvoker.cpp:76
Definition: LibInputPointer.h:13
This exception is thrown from Director calls that call into python when the Python error is...
Definition: swig.h:164
This class is the superclass for all reference counted classes in the api.
Definition: AddonClass.h:57