1 #ifndef __lib_python_python_class_h
4 #define __lib_python_python_class_h
9 #if PY_VERSION_HEX >= 0x030a0000
10 #define PY_SSIZE_T_CLEAN 1
14 #if !defined(SKIP_PART1) && !defined(SWIG)
16 #if PY_MAJOR_VERSION >= 3
17 #define PyStringObject PyUnicodeObject
18 #define PyString_FromStringAndSize PyUnicode_FromStringAndSize
19 #define PyString_AS_STRING PyUnicode_AsUTF8
20 #define PyString_AsString PyUnicode_AsUTF8
21 #define PyString_Check PyUnicode_Check
23 #define PyInt_AsLong PyLong_AsLong
24 #define PyInt_Check PyLong_Check
25 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
27 #define PyExc_StandardError PyExc_Exception
33 #ifdef PYTHON_REFCOUNT_DEBUG
35 int m_line, m_from, m_to;
42 #ifdef PYTHON_REFCOUNT_DEBUG
50 operator bool()
const {
return !!m_ob; }
51 operator bool() {
return !!m_ob; }
60 operator PyVarObject*() {
return (PyVarObject*)
operator PyVarObject*(); }
61 operator PyTupleObject*() {
return (PyTupleObject*)
operator PyObject*(); }
62 operator PyListObject*() {
return (PyListObject*)
operator PyObject*(); }
63 operator PyStringObject*() {
return (PyStringObject*)
operator PyObject*(); }
64 operator PyDictObject*() {
return (PyDictObject*)
operator PyObject*(); }
66 #ifdef PYTHON_REFCOUNT_DEBUG
77 #ifdef PYTHON_REFCOUNT_DEBUG
78 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
85 #ifdef PYTHON_REFCOUNT_DEBUG
86 ,m_file(ob.m_file), m_line(ob.m_line)
87 ,m_from(ob.m_from), m_to(ob.m_to), m_erased(ob.m_erased)
94 #ifdef PYTHON_REFCOUNT_DEBUG
95 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
100 #ifdef PYTHON_REFCOUNT_DEBUG
103 ,m_file(
file), m_line(
line), m_from(ob->ob_refcnt), m_to(ob->ob_refcnt), m_erased(false)
110 #ifdef PYTHON_REFCOUNT_DEBUG
111 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
118 #ifdef PYTHON_REFCOUNT_DEBUG
119 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
126 #ifdef PYTHON_REFCOUNT_DEBUG
127 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
134 #ifdef PYTHON_REFCOUNT_DEBUG
135 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
142 #ifdef PYTHON_REFCOUNT_DEBUG
143 ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
148 #ifndef PYTHON_REFCOUNT_DEBUG
161 inline ePyObject::operator PyObject*()
181 :m_obj(wrapper.m_obj)
197 m_obj = wrapper.m_obj;
217 #ifdef PYTHON_REFCOUNT_DEBUG
242 #if PY_VERSION_HEX >= 0x030a0000
251 #if PY_VERSION_HEX >= 0x030a0000
272 PyObject *ob = PyUnicode_FromFormatV(fmt, ap);
299 #if PY_VERSION_HEX >= 0x030a0000
308 #if PY_VERSION_HEX >= 0x030a0000
339 #if PY_VERSION_HEX >= 0x030a0000
348 #if PY_VERSION_HEX >= 0x030a0000
362 return PyUnicode_FromString(
str);
369 PyObject *ob = PyUnicode_FromFormatV(fmt, ap);
396 #if PY_VERSION_HEX >= 0x030a0000
405 #if PY_VERSION_HEX >= 0x030a0000
422 #define Org_Py_INCREF(obj) Impl_INCREF(obj)
423 #define Org_Py_DECREF(obj) Impl_DECREF(obj)
428 #undef PyList_GET_ITEM
429 #undef PyTuple_GET_ITEM
430 #ifdef PYTHON_REFCOUNT_DEBUG
431 #define Py_DECREF(obj) Impl_Py_DECREF(__FILE__, __LINE__, obj)
432 #define Py_XDECREF(obj) Impl_Py_XDECREF(__FILE__, __LINE__, obj)
433 #define Py_INCREF(obj) Impl_Py_INCREF(__FILE__, __LINE__, obj)
434 #define Py_XINCREF(obj) Impl_Py_XINCREF(__FILE__, __LINE__, obj)
435 #define PyList_New(args...) Impl_PyList_New(__FILE__, __LINE__, args)
436 #define PyTuple_New(args...) Impl_PyTuple_New(__FILE__, __LINE__, args)
437 #define PyDict_New(...) Impl_PyDict_New(__FILE__, __LINE__)
438 #define PyString_FromString(str) Impl_PyString_FromString(__FILE__, __LINE__, str)
439 #define PyString_FromFormat(str, args...) Impl_PyString_FromFormat(__FILE__, __LINE__, str, args)
440 #define PyInt_FromLong(val) Impl_PyInt_FromLong(__FILE__, __LINE__, val)
441 #define PyLong_FromLong(val) Impl_PyLong_FromLong(__FILE__, __LINE__, val)
442 #define PyLong_FromUnsignedLong(val) Impl_PyLong_FromUnsignedLong(__FILE__, __LINE__, val)
443 #define PyLong_FromLongLong(val) Impl_PyLong_FromLongLong(__FILE__, __LINE__, val)
444 #define PyList_GET_ITEM(list, pos) Impl_PyList_GET_ITEM(__FILE__, __LINE__, list, pos)
445 #define PyTuple_GET_ITEM(list, pos) Impl_PyTuple_GET_ITEM(__FILE__, __LINE__, list, pos)
447 #define Py_DECREF(obj) Impl_Py_DECREF(obj)
448 #define Py_XDECREF(obj) Impl_Py_XDECREF(obj)
449 #define Py_INCREF(obj) Impl_Py_INCREF(obj)
450 #define Py_XINCREF(obj) Impl_Py_XINCREF(obj)
451 #define PyList_New(args...) Impl_PyList_New(args)
452 #define PyTuple_New(args...) Impl_PyTuple_New(args)
453 #define PyDict_New(...) Impl_PyDict_New()
454 #define PyString_FromString(str) Impl_PyString_FromString(str)
455 #define PyString_FromFormat(str, args...) Impl_PyString_FromFormat(str, args)
456 #define PyInt_FromLong(val) Impl_PyInt_FromLong(val)
457 #define PyLong_FromLong(val) Impl_PyLong_FromLong(val)
458 #define PyLong_FromUnsignedLong(val) Impl_PyLong_FromUnsignedLong(val)
459 #define PyLong_FromLongLong(val) Impl_PyLong_FromLongLong(val)
460 #define PyList_GET_ITEM(list, pos) Impl_PyList_GET_ITEM(list, pos)
461 #define PyTuple_GET_ITEM(list, pos) Impl_PyTuple_GET_ITEM(list, pos)
470 int execute(
const std::string &pythonfile,
const std::string &funcname);
472 static ePyObject resolve(
const std::string &pythonfile,
const std::string &funcname);
ePyObject & operator=(PyListObject *ob)
Definition: python.h:57
ePyObject & operator=(PyTupleObject *ob)
Definition: python.h:56
ePyObject()
Definition: python.h:75
void incref()
Definition: python.h:166
ePyObject & operator=(PyVarObject *ob)
Definition: python.h:54
ePyObject & operator=(const ePyObject &)
Definition: python.h:155
PyObject * operator->()
Definition: python.h:65
ePyObject & operator=(PyStringObject *ob)
Definition: python.h:58
void decref()
Definition: python.h:171
ePyObject & operator=(PyDictObject *ob)
Definition: python.h:55
ePyObjectWrapper(const ePyObject &obj)
Definition: python.h:185
ePyObjectWrapper & operator=(const ePyObjectWrapper &wrapper)
Definition: python.h:194
ePyObjectWrapper(const ePyObjectWrapper &wrapper)
Definition: python.h:180
~ePyObjectWrapper()
Definition: python.h:190
static ePyObject resolve(const std::string &pythonfile, const std::string &funcname)
Definition: python.cpp:223
static int call(ePyObject pFunc, ePyObject args)
Definition: python.cpp:191
ePython()
Definition: python.cpp:121
int execute(const std::string &pythonfile, const std::string &funcname)
Definition: python.cpp:151
int execFile(const char *file)
Definition: python.cpp:141
~ePython()
Definition: python.cpp:135
line
Definition: newplugin.py:87
file
Definition: newplugin.py:100
pos
Definition: enigma_py_patcher.py:16
str
Definition: enigma_py_patcher.py:14
list list
Definition: main.py:25
void Impl_Py_DECREF(const ePyObject &obj)
Definition: python.h:315
ePyObject Impl_PyInt_FromLong(long val)
Definition: python.h:374
ePyObject Impl_PyList_GET_ITEM(ePyObject list, unsigned int pos)
Definition: python.h:394
void Impl_Py_INCREF(const ePyObject &obj)
Definition: python.h:320
ePyObject Impl_PyTuple_GET_ITEM(ePyObject list, unsigned int pos)
Definition: python.h:403
#define PyTuple_New(args...)
Definition: python.h:452
#define PyDict_New(...)
Definition: python.h:453
void Impl_Py_XDECREF(const ePyObject &obj)
Definition: python.h:325
#define PyTuple_GET_ITEM(list, pos)
Definition: python.h:461
#define PyLong_FromLong(val)
Definition: python.h:457
ePyObject Impl_PyDict_New()
Definition: python.h:355
ePyObject Impl_PyList_New(int elements=0)
Definition: python.h:346
ePyObject Impl_PyLong_FromLong(long val)
Definition: python.h:379
ePyObject Impl_PyLong_FromUnsignedLong(unsigned long val)
Definition: python.h:384
#define PyLong_FromLongLong(val)
Definition: python.h:459
ePyObject Impl_PyLong_FromLongLong(long long val)
Definition: python.h:389
void Impl_Py_XINCREF(const ePyObject &obj)
Definition: python.h:331
void Impl_DECREF(PyObject *ob)
Definition: python.h:418
#define PyLong_FromUnsignedLong(val)
Definition: python.h:458
#define PyList_New(args...)
Definition: python.h:451
#define PyList_GET_ITEM(list, pos)
Definition: python.h:460
ePyObject Impl_PyString_FromFormat(const char *fmt,...)
Definition: python.h:365
#define Py_DECREF(obj)
Definition: python.h:447
ePyObject Impl_PyTuple_New(int elements=0)
Definition: python.h:337
#define Py_INCREF(obj)
Definition: python.h:449
void Impl_INCREF(PyObject *ob)
Definition: python.h:413
ePyObject Impl_PyString_FromString(const char *str)
Definition: python.h:360