diff options
| author | jordi.saludes <jordi.saludes@upc.edu> | 2010-07-15 08:15:41 +0000 |
|---|---|---|
| committer | jordi.saludes <jordi.saludes@upc.edu> | 2010-07-15 08:15:41 +0000 |
| commit | 9608af8423cbb924141d976e8d280aa25319f85c (patch) | |
| tree | cd987c59d6734e4e9c10734386265c117ae02017 /contrib/py-bindings/pygf.h | |
| parent | b128872e2d3af3fcf83e4cc4b7d56799e40904cf (diff) | |
New interface to gf based in Storable.
Diffstat (limited to 'contrib/py-bindings/pygf.h')
| -rw-r--r-- | contrib/py-bindings/pygf.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/contrib/py-bindings/pygf.h b/contrib/py-bindings/pygf.h new file mode 100644 index 000000000..3a63090ca --- /dev/null +++ b/contrib/py-bindings/pygf.h @@ -0,0 +1,68 @@ +#include <Python.h> +//#include "pgf.h" +#include "HsFFI.h" + +#ifdef __GLASGOW_HASKELL__ +#include "PyGF_stub.h" + +extern void __stginit_PyGF ( void ); +#endif + +static inline void gf_init(int *argc, char ***argv) +{ + hs_init(argc, argv); +#ifdef __GLASGOW_HASKELL__ + hs_add_root(__stginit_PyGF); +#endif +} + +static inline void gf_exit(void) +{ + hs_exit(); +} + +typedef HsStablePtr GF_PGF; +typedef HsStablePtr GF_CId; +typedef HsStablePtr GF_Language; +typedef HsStablePtr GF_Type; +typedef HsStablePtr GF_Tree; +typedef HsStablePtr GF_Expr; +typedef struct { + PyObject_HEAD; + HsStablePtr sp; +} PyGF; + +#define NEWOBJECT(OBJ, GFTYPE) typedef struct {\ + PyObject_HEAD \ + GFTYPE obj; \ + } OBJ; + +#define NEWTYPE(TYPE,NAME,OBJECT,DOC) static PyTypeObject TYPE = {\ + PyObject_HEAD_INIT(NULL)\ + 0, /*ob_size*/\ + NAME, /*tp_name*/\ + sizeof(OBJECT), /*tp_basicsize*/\ + 0, /*tp_itemsize*/\ + 0, /*tp_dealloc*/\ + 0, /*tp_print*/\ + 0, /*tp_getattr*/\ + 0, /*tp_setattr*/\ + 0, /*tp_compare*/\ + 0, /*tp_repr*/\ + 0, /*tp_as_number*/\ + 0, /*tp_as_sequence*/\ + 0, /*tp_as_mapping*/\ + 0, /*tp_hash */\ + 0, /*tp_call*/\ + 0, /*tp_str*/\ + 0, /*tp_getattro*/\ + 0, /*tp_setattro*/\ + 0, /*tp_as_buffer*/\ + Py_TPFLAGS_DEFAULT, /*tp_flags*/\ + DOC, /* tp_doc */\ + }; +#define NEWGF(OBJ,GFTYPE,TYPE,NAME,DOC) NEWOBJECT(OBJ,GFTYPE) \ + NEWTYPE(TYPE,NAME,OBJ,DOC) + + +NEWOBJECT(CID, GF_CId) |
