add a dummy class to debug python refcounting (add entrys of TestObj to your tuple...
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 10 Jan 2006 14:23:28 +0000 (14:23 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 10 Jan 2006 14:23:28 +0000 (14:23 +0000)
include <lib/python/python.h> and use New_TestObj to create a testobject..

lib/python/enigma_python.i
lib/python/python.cpp
lib/python/python.h

index 16ca40cf2faf54352730678b098ac5172bbc7b01..5a6f126ecba41c3c0fe84c262639fbcbad85b647 100644 (file)
@@ -79,6 +79,7 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/driver/etimezone.h>
 #include <lib/gdi/lcd.h>
 #include <lib/dvb_ci/dvbci_ui.h>
 #include <lib/driver/etimezone.h>
 #include <lib/gdi/lcd.h>
 #include <lib/dvb_ci/dvbci_ui.h>
+#include <lib/python/python.h>
 
 extern void runMainloop();
 extern void quitMainloop(int exit_code);
 
 extern void runMainloop();
 extern void quitMainloop(int exit_code);
@@ -182,6 +183,7 @@ typedef long time_t;
 %include <lib/gdi/lcd.h>
 %include <lib/dvb_ci/dvbci_ui.h>
 %include <lib/dvb/db.h>
 %include <lib/gdi/lcd.h>
 %include <lib/dvb_ci/dvbci_ui.h>
 %include <lib/dvb/db.h>
+%include <lib/python/python.h>
 /**************  eptr  **************/
 
 %template(eActionMapPtr) ePtr<eActionMap>;
 /**************  eptr  **************/
 
 %template(eActionMapPtr) ePtr<eActionMap>;
@@ -243,4 +245,9 @@ RESULT SwigFromPython(ePtr<gPixmap> &result, PyObject *obj)
        result = *res;
        return 0;
 }
        result = *res;
        return 0;
 }
+PyObject *New_TestObj()
+{
+    TestObj *result = (TestObj *)new TestObj();
+    return SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_TestObj, 1);
+}
 %}
 %}
index 642d70ba9f3072f26e4773dbc8151453abb7b7f0..f467bc86dc7d1a63a4827e72d38c4e5901a7f715 100644 (file)
@@ -4,6 +4,18 @@
 
 extern "C" void init_enigma();
 
 
 extern "C" void init_enigma();
 
+DEFINE_REF(TestObj);
+
+TestObj::TestObj()
+{
+       eDebug("create %p", this);
+}
+
+TestObj::~TestObj()
+{
+       eDebug("destroy %p", this);
+}
+
 #if 0
 ePyObject::ePyObject(void *ptr): m_object(ptr)
 {
 #if 0
 ePyObject::ePyObject(void *ptr): m_object(ptr)
 {
index e9a2b8db558a643cf46b8bc629ae7de73d07d902..46e1a03db9bbada306900df78dc738508268f8d4 100644 (file)
@@ -2,7 +2,24 @@
 #define __lib_python_python_h
 
 #include <string>
 #define __lib_python_python_h
 
 #include <string>
+#include <lib/base/object.h>
 
 
+typedef struct _object PyObject;
+
+// useable for debugging python refcounting
+
+extern PyObject *New_TestObj();
+
+class TestObj
+{
+DECLARE_REF(TestObj);
+public:
+       TestObj();
+       ~TestObj();
+};
+TEMPLATE_TYPEDEF(ePtr<TestObj>, TestObjPtr);
+
+#ifndef SWIG
 /* class ePyObject
 {
        void *m_object;
 /* class ePyObject
 {
        void *m_object;
@@ -16,8 +33,6 @@ public:
        void *get() { return m_object; }
 }; */
 
        void *get() { return m_object; }
 }; */
 
-typedef struct _object PyObject;
-
 class ePython
 {
 public:
 class ePython
 {
 public:
@@ -28,5 +43,6 @@ public:
        static PyObject *resolve(const std::string &pythonfile, const std::string &funcname);
 private:
 };
        static PyObject *resolve(const std::string &pythonfile, const std::string &funcname);
 private:
 };
+#endif // SWIG
 
 #endif
 
 #endif