summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeff Armstrong <jeffrey.armstrong@approximatrix.com>2011-07-13 22:31:36 -0400
committerJeff Armstrong <jeffrey.armstrong@approximatrix.com>2011-07-13 22:31:36 -0400
commit206bac5ec8a0faafc1e65c992b404f80a9d96daf (patch)
tree433f0b8cf10c799dbc4bdf46a79b1d28bce44e67 /lib
parent33346eaee2add1bf9c801cf92f19664ffaa71f2b (diff)
downloadgempy-206bac5ec8a0faafc1e65c992b404f80a9d96daf.tar.gz
gempy-206bac5ec8a0faafc1e65c992b404f80a9d96daf.zip
Added a number of AES Window library function wrappers.
Diffstat (limited to 'lib')
-rw-r--r--lib/gem.c19
-rw-r--r--lib/ldg_Python.h15
-rw-r--r--lib/py_aes.c134
-rw-r--r--lib/py_aes.h6
4 files changed, 163 insertions, 11 deletions
diff --git a/lib/gem.c b/lib/gem.c
index e4a1ba6..941d532 100644
--- a/lib/gem.c
+++ b/lib/gem.c
@@ -28,6 +28,14 @@ GemMethods[] = {
/* AES Resource Library */
{"rsrc_load", py_rsrc_load, METH_VARARGS, "Load a resource into memory"},
{"rsrc_gaddr", py_rsrc_gaddr, METH_VARARGS, "Return an encapsulated memory address of a resource component"},
+
+ /* AES Window Library */
+ {"wind_create", py_wind_create, METH_VARARGS, "Create a window"},
+ {"wind_open", py_wind_open, METH_VARARGS, "Open a window"},
+ {"wind_get", py_wind_get, METH_VARARGS, "Retrieve window information"},
+ {"wind_delete", py_wind_delete, METH_VARARGS, "Delete a window (after closing...)"},
+ {"wind_close", py_wind_close, METH_VARARGS, "Close a window"},
+
{NULL,NULL,0,NULL}
};
@@ -72,11 +80,18 @@ PROC LibFunc[] = {
/* AES Resource Library */
"py_rsrc_load", "Internal\n", py_rsrc_load,
- "py_rsrc_gaddr", "Internal\n", py_rsrc_gaddr
+ "py_rsrc_gaddr", "Internal\n", py_rsrc_gaddr,
+
+ /* AES Window Library */
+ "py_wind_create", "Internal\n", py_wind_create,
+ "py_wind_open", "Internal\n", py_wind_open,
+ "py_wind_get", "Internal\n", py_wind_get,
+ "py_wind_delete", "Internal\n", py_wind_delete,
+ "py_wind_close", "Internal\n", py_wind_close
};
LDGLIB LibLdg[] = {
- 0x0001, 8, LibFunc, "GEM Extensions for Python", 0
+ 0x0001, 13, LibFunc, "GEM Extensions for Python", 0
};
int main( void)
diff --git a/lib/ldg_Python.h b/lib/ldg_Python.h
index 0f21960..ca16e51 100644
--- a/lib/ldg_Python.h
+++ b/lib/ldg_Python.h
@@ -4,16 +4,12 @@
#include <Python.h>
#include <ldg.h>
-#define PY_API_FCOUNT 8
+#define PY_API_FCOUNT 11
#ifndef LDG_INTERNAL
extern void *pycallbacks[PY_API_FCOUNT];
#endif
-#ifdef Py_REF_DEBUG
-#error Cannot build LDG Python exceptions with reference debugging
-#endif
-
#define Py_InitModule(name,methods) ldg_callback(pycallbacks[0],name,methods,NULL,NULL)
#define PyArg_ParseTuple(tpl,...) ldg_callback(pycallbacks[1],tpl,##__VA_ARGS__)
#define Py_BuildValue(fmt,...) ldg_callback(pycallbacks[2],fmt,##__VA_ARGS__)
@@ -21,7 +17,12 @@ extern void *pycallbacks[PY_API_FCOUNT];
#define PyErr_SetString(obj,s) ldg_callback(pycallbacks[4],obj,s)
#define PyModule_AddObject(m,s,o) ldg_callback(pycallbacks[5],m,s,o)
#define PyCapsule_New(pt,s,de) ldg_callback(pycallbacks[6],pt,s,de)
-#define PyCapsule_GetPointer(c,s) ldg_callback(pycallbacks[7],c.s)
-//#define Py_INCREF(obj) ldg_callback(pycallbacks[4],obj)
+#define PyCapsule_GetPointer(c,s) ldg_callback(pycallbacks[7],c,s)
+#define Py_IncRef(obj) ldg_callback(pycallbacks[8],obj)
+#define Py_DecRef(obj) ldg_callback(pycallbacks[9],obj)
+#define Py_None pycallbacks[10]
+
+#define Py_INCREF(obj) ldg_callback(pycallbacks[8],obj)
+#define Py_DECREF(obj) ldg_callback(pycallbacks[9],obj)
#endif /*__LDG_PYTHON_HEADERS */ \ No newline at end of file
diff --git a/lib/py_aes.c b/lib/py_aes.c
index d4d315b..6f60a29 100644
--- a/lib/py_aes.c
+++ b/lib/py_aes.c
@@ -48,7 +48,7 @@ int x;
}
/* --- Resources Library --- */
-static void __CDECL py_rsrc_load(PyObject *self, PyObject *args)
+static PyObject* __CDECL py_rsrc_load(PyObject *self, PyObject *args)
{
char *file;
int x;
@@ -60,7 +60,9 @@ int x;
PyErr_SetString(GEMError,"Resource failed to load");
return NULL;
}
- return Py_BuildValue("i",x);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject* __CDECL py_rsrc_gaddr(PyObject *self, PyObject *args)
@@ -79,3 +81,131 @@ void *gaddr;
return PyCapsule_New(gaddr,NULL,NULL);
}
+
+/* --- Windows Library --- */
+static PyObject* __CDECL py_wind_create(PyObject *self, PyObject *args)
+{
+int type, x, y, w, h;
+int ret;
+
+ if(!PyArg_ParseTuple(args,"i(iiii)",&type,&x,&y,&w,&h))
+ return NULL;
+
+ return Py_BuildValue("i",wind_create(type,x,y,w,h));
+}
+
+static PyObject* __CDECL py_wind_close(PyObject *self, PyObject *args)
+{
+int id;
+
+ if(!PyArg_ParseTuple(args,"i",&id))
+ return NULL;
+
+ if(wind_close(id) == 0) {
+ PyErr_SetString(GEMError,"Window failed to close");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject* __CDECL py_wind_delete(PyObject *self, PyObject *args)
+{
+int id;
+
+ if(!PyArg_ParseTuple(args,"i",&id))
+ return NULL;
+
+ if(wind_delete(id) == 0) {
+ PyErr_SetString(GEMError,"Window was not deleted");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject* __CDECL py_wind_open(PyObject *self, PyObject *args)
+{
+int id, x, y, w, h;
+int ret;
+
+ if(!PyArg_ParseTuple(args,"i(iiii)",&id,&x,&y,&w,&h))
+ return NULL;
+
+ ret = wind_open(type,x,y,w,h);
+ if(ret == 0) {
+ PyErr_SetString(GEMError,"Window could not be opened");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject* __CDECL py_wind_get(PyObject *self, PyObject *args)
+{
+int id, gp;
+int w1, w2, w3, w4;
+int ret;
+
+ if(!PyArg_ParseTuple(args,"ii",&id,&gp))
+ return NULL;
+
+ ret = wind_get(id,gp,&w1,&w2,&w3,&w4);
+ if(ret == 0) {
+ PyErr_SetString(GEMError,"Window request failed");
+ return NULL;
+ }
+
+ switch(gp) {
+
+ case WF_WORKXYWH:
+ case WF_WINXCFG:
+ case WF_WINX:
+ case WF_WIDGETS:
+ case WF_UNICONIFY:
+ case WF_TOP:
+ case WF_PREVXYWH:
+ case WF_OWNER:
+ case WF_NTOOLBAR:
+ case WF_NEXTXYWH:
+ case WF_MINXYWH:
+ case WF_FULLXYWH:
+ case WF_FTOOLBAR:
+ case WF_FIRSTXYWH:
+ case WF_DDELAY:
+ case WF_CURRXYWH:
+ return Py_BuildValue("(iiii)", w1, w2, w3, w4);
+ break;
+ case WF_DCOLOR:
+ case WF_ICONIFY:
+ case WF_NEWDESK:
+ return Py_BuildValue("(iii)", w1, w2, w3);
+ break;
+ case WF_MENU:
+ case WF_TOOLBAR:
+ case WF_M_WINDLIST:
+ return Py_BuildValue("(ii)", w1, w2);
+ break;
+ case XA:
+ return Py_BuildValue("ii", ret, w1);
+ break;
+ case WF_BEVENT:
+ case WF_BOTTOM:
+ case WF_HSLIDE:
+ case WF_HSLSIZE:
+ case WF_KIND:
+ case WF_M_OWNER:
+ case WF_SHADE:
+ case WF_VSLIDE:
+ case WF_VSLSIZE:
+ default:
+ return Py_BuildValue("i", w1);
+ break;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
diff --git a/lib/py_aes.h b/lib/py_aes.h
index 921b82c..4603427 100644
--- a/lib/py_aes.h
+++ b/lib/py_aes.h
@@ -15,4 +15,10 @@ static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args);
static void __CDECL py_rsrc_load(PyObject *self, PyObject *args);
static PyObject* __CDECL py_rsrc_gaddr(PyObject *self, PyObject *args);
+static PyObject* __CDECL py_wind_create(PyObject *self, PyObject *args)
+static PyObject* __CDECL py_wind_open(PyObject *self, PyObject *args);
+static PyObject* __CDECL py_wind_get(PyObject *self, PyObject *args);
+static PyObject* __CDECL py_wind_delete(PyObject *self, PyObject *args);
+static PyObject* __CDECL py_wind_close(PyObject *self, PyObject *args);
+
#endif /* __PY_AES_HEADERS */