git.cweiske.de
/
enigma2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
72f38fa
)
add wrapper class for auto Py_INCREF/Py_DECREF ... i.e. usable for STL containers
author
ghost
<andreas.monzner@multimedia-labs.de>
Fri, 25 Sep 2009 14:54:43 +0000
(16:54 +0200)
committer
ghost
<andreas.monzner@multimedia-labs.de>
Fri, 25 Sep 2009 14:54:43 +0000
(16:54 +0200)
lib/python/python.h
patch
|
blob
|
history
diff --git
a/lib/python/python.h
b/lib/python/python.h
index 52ec6c1eaba64b86ad37e2a5137c1669063f4746..18fdac78fe2def9040669138cc60020cce9ca3c2 100644
(file)
--- a/
lib/python/python.h
+++ b/
lib/python/python.h
@@
-155,6
+155,41
@@
inline void ePyObject::decref()
Py_DECREF(m_ob);
}
Py_DECREF(m_ob);
}
+class ePyObjectWrapper
+{
+ ePyObject m_obj;
+public:
+ ePyObjectWrapper(const ePyObjectWrapper &wrapper)
+ :m_obj(wrapper.m_obj)
+ {
+ Py_INCREF(m_obj);
+ }
+ ePyObjectWrapper(const ePyObject &obj)
+ :m_obj(obj)
+ {
+ Py_INCREF(m_obj);
+ }
+ ~ePyObjectWrapper()
+ {
+ Py_DECREF(m_obj);
+ }
+ ePyObjectWrapper &operator=(const ePyObjectWrapper &wrapper)
+ {
+ Py_DECREF(m_obj);
+ m_obj = wrapper.m_obj;
+ Py_INCREF(m_obj);
+ return *this;
+ }
+ operator PyObject*()
+ {
+ return m_obj;
+ }
+ operator ePyObject()
+ {
+ return m_obj;
+ }
+};
+
#endif // ! PYTHON_REFCOUNT_DEBUG
#endif // !SWIG && !SKIP_PART1
#endif // ! PYTHON_REFCOUNT_DEBUG
#endif // !SWIG && !SKIP_PART1
@@
-390,5
+425,4
@@
private:
#endif // SWIG
#endif // SKIP_PART2
#endif // SWIG
#endif // SKIP_PART2
-
#endif // __lib_python_python_class_h
#endif // __lib_python_python_class_h