summaryrefslogtreecommitdiff
path: root/contrib/py-bindings/pygf.h
diff options
context:
space:
mode:
authorjordi.saludes <jordi.saludes@upc.edu>2010-07-22 13:23:27 +0000
committerjordi.saludes <jordi.saludes@upc.edu>2010-07-22 13:23:27 +0000
commitaff9f220c9427ebd0d4869cf72ec79f005b4970e (patch)
treee26441979ee2615e15b44cecb3c4988acfd07bdc /contrib/py-bindings/pygf.h
parentf715e053b9d3ab80fdb5cdd71ae972e07b145501 (diff)
Refactored py-bindings using Storable.
Diffstat (limited to 'contrib/py-bindings/pygf.h')
-rw-r--r--contrib/py-bindings/pygf.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/contrib/py-bindings/pygf.h b/contrib/py-bindings/pygf.h
index 3a63090ca..101674dfa 100644
--- a/contrib/py-bindings/pygf.h
+++ b/contrib/py-bindings/pygf.h
@@ -32,6 +32,7 @@ typedef struct {
HsStablePtr sp;
} PyGF;
+
#define NEWOBJECT(OBJ, GFTYPE) typedef struct {\
PyObject_HEAD \
GFTYPE obj; \
@@ -65,4 +66,27 @@ typedef struct {
NEWTYPE(TYPE,NAME,OBJ,DOC)
-NEWOBJECT(CID, GF_CId)
+// NEWOBJECT(CID, GF_CId)
+
+#ifdef DEBUG
+#define DEALLOCFN(delname,t,cb,cbname) static void \
+delname(t *self){ cb(self);\
+ printf("gf_%s has been called for stable pointer 0x%x\n", cbname, self->obj);\
+ self->ob_type->tp_free((PyObject*)self); }
+#else
+#define DEALLOCFN(delname,t,cb,cbname) static void \
+delname(t *self){ cb(self);\
+ self->ob_type->tp_free((PyObject*)self); }
+#endif
+
+#ifdef DEBUG
+#define REPRCB(cbid,t,gfcb) static PyObject* \
+cbid(t *self) { \
+ const char *str = gfcb(self); \
+ return PyString_FromFormat("0x%x: %s", self->obj, str); }
+#else
+#define REPRCB(cbid,t,gfcb) static PyObject* \
+cbid(t *self) { \
+ const char *str = gfcb(self); \
+ return PyString_FromString(str); }
+#endif