diff options
| author | Jeff Armstrong <jeffrey.armstrong@approximatrix.com> | 2011-07-11 22:47:19 -0400 |
|---|---|---|
| committer | Jeff Armstrong <jeffrey.armstrong@approximatrix.com> | 2011-07-11 22:47:19 -0400 |
| commit | 020592344c70c1b287e52729086a493211daea5a (patch) | |
| tree | f787f919f6aadba044f93030718e6827f21e76c1 /lib | |
| parent | d89bc67baf8e8f77de9240a4c991a6a98ff950c4 (diff) | |
| download | gempy-020592344c70c1b287e52729086a493211daea5a.tar.gz gempy-020592344c70c1b287e52729086a493211daea5a.zip | |
Starting logical reorg of the native GEM calls.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gem.c | 152 | ||||
| -rw-r--r-- | lib/ldg_Python.h | 16 | ||||
| -rw-r--r-- | lib/py_aes.c | 32 | ||||
| -rw-r--r-- | lib/py_aes.h | 12 |
4 files changed, 123 insertions, 89 deletions
@@ -1,90 +1,64 @@ -#include <Python.h>
-#include <gem.h>
-#include <ldg.h>
-
-#define PY_API_FCOUNT 3
-static void *pycallbacks[PY_API_FCOUNT];
-
-#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__)
-
-//PyObject* (*LPy_InitModule)(char *, PyMethodDef *, char *, PyObject *) = NULL;
-
-
-static PyObject* __CDECL py_appl_init(PyObject *self, PyObject *args)
-{
-int ret;
-
- ret = appl_init();
- return Py_BuildValue("i",ret);
-}
-
-static PyObject* __CDECL py_appl_exit(PyObject *self, PyObject *args)
-{
-int ret;
-
- ret = appl_exit();
- return Py_BuildValue("i",ret);
-}
-
-static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args)
-{
-char *text;
-int x;
-
- if(!PyArg_ParseTuple(args,"is",&x,&text))
- return NULL;
-
- x = form_alert(x,text);
- return Py_BuildValue("i",x);
-}
-
-static PyMethodDef
-GemMethods[] = {
- {"appl_init", py_appl_init, METH_VARARGS, "Initialize a GEM application"},
- {"appl_exit", py_appl_exit, METH_VARARGS, "Exit a GEM application"},
- {"form_alert", py_form_alert, METH_VARARGS, "Display a GEM alert dialog"},
- {NULL,NULL,0,NULL}
-};
-
-PyMODINIT_FUNC __CDECL initgem(void)
-{
-
- printf("Welcome to shared init.\nStandby...\n");
- //LPy_InitModule("gem",GemMethods,NULL,NULL);
- ldg_callback(pycallbacks[0],"gem",GemMethods,NULL,NULL);
- return;
-}
-
-
-
-void __CDECL assign_pycalls(void **calls)
-{
-int i;
-
- for(i=0;i<PY_API_FCOUNT;i++)
- pycallbacks[i] = calls[i];
-}
-
-PROC LibFunc[] = {
- "assign_pycalls", "Assigns Python callbacks", assign_pycalls,
- "initgem", "Internal\n", initgem,
- "py_form_alert", "Internal\n", py_form_alert,
- "py_appl_exit", "Internal\n", py_appl_exit,
- "py_appl_init", "Internal\n", py_appl_init
-};
-
-LDGLIB LibLdg[] = {
- 0x0001, 5, LibFunc, "GEM Extensions for Python", 0
-};
-
-int main( void) {
- if( ldg_init( LibLdg) == -1) {
- printf("This program is a shared library.\n");
- }
- return 0;
-}
-
-
+ +/* Need to define an internal flag to avoid an extern */ +#define LDG_INTERNAL +#include "ldg_Python.h" + +#include <gem.h> +#include <ldg.h> + +#include "py_aes.h" + +/* --- Python-C API Calls --- */ +static void *pycallbacks[PY_API_FCOUNT]; + +/* --- Python API Bookkeeping --- */ +static PyMethodDef +GemMethods[] = { + {"appl_init", py_appl_init, METH_VARARGS, "Initialize a GEM application"}, + {"appl_exit", py_appl_exit, METH_VARARGS, "Exit a GEM application"}, + {"form_alert", py_form_alert, METH_VARARGS, "Display a GEM alert dialog"}, + {NULL,NULL,0,NULL} +}; + +PyMODINIT_FUNC __CDECL initgem(void) +{ + + printf("Welcome to shared init.\nStandby...\n"); + //LPy_InitModule("gem",GemMethods,NULL,NULL); + ldg_callback(pycallbacks[0],"gem",GemMethods,NULL,NULL); + return; +} +/* --- End Python API Bookkeeping --- */ + + +/* --- LDG Bookkeeping --- */ +void __CDECL assign_pycalls(void **calls) +{ +int i; + + for(i=0;i<PY_API_FCOUNT;i++) + pycallbacks[i] = calls[i]; +} + +PROC LibFunc[] = { + "assign_pycalls", "Assigns Python callbacks", assign_pycalls, + "initgem", "Internal\n", initgem, + "py_form_alert", "Internal\n", py_form_alert, + "py_appl_exit", "Internal\n", py_appl_exit, + "py_appl_init", "Internal\n", py_appl_init +}; + +LDGLIB LibLdg[] = { + 0x0001, 5, LibFunc, "GEM Extensions for Python", 0 +}; + +int main( void) +{ + if( ldg_init( LibLdg) == -1) { + printf("This program is a shared library.\n"); + } + return 0; +} +/* --- End LDG Bookkeeping --- */ +
\ No newline at end of file diff --git a/lib/ldg_Python.h b/lib/ldg_Python.h new file mode 100644 index 0000000..1a79e18 --- /dev/null +++ b/lib/ldg_Python.h @@ -0,0 +1,16 @@ +#ifndef __LDG_PYTHON_HEADERS
+#define __LDG_PYTHON_HEADERS
+
+#include <Python.h>
+
+#define PY_API_FCOUNT 3
+
+#ifndef LDG_INTERNAL
+extern void *pycallbacks[PY_API_FCOUNT];
+#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__)
+
+#endif /*__LDG_PYTHON_HEADERS */
\ No newline at end of file diff --git a/lib/py_aes.c b/lib/py_aes.c new file mode 100644 index 0000000..e97f4d5 --- /dev/null +++ b/lib/py_aes.c @@ -0,0 +1,32 @@ +#include "ldg_Python.h" +#include <gem.h> + +/* --- Application Library --- */ +static PyObject* __CDECL py_appl_init(PyObject *self, PyObject *args) +{ +int ret; + + ret = appl_init(); + return Py_BuildValue("i",ret); +} + +static PyObject* __CDECL py_appl_exit(PyObject *self, PyObject *args) +{ +int ret; + + ret = appl_exit(); + return Py_BuildValue("i",ret); +} + +/* --- Forms Library --- */ +static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args) +{ +char *text; +int x; + + if(!PyArg_ParseTuple(args,"is",&x,&text)) + return NULL; + + x = form_alert(x,text); + return Py_BuildValue("i",x); +} diff --git a/lib/py_aes.h b/lib/py_aes.h new file mode 100644 index 0000000..9336169 --- /dev/null +++ b/lib/py_aes.h @@ -0,0 +1,12 @@ +#ifndef __PY_AES_HEADERS
+#define __PY_AES_HEADERS
+
+#include "ldg_Python.h"
+
+static PyObject* __CDECL py_appl_init(PyObject *self, PyObject *args);
+
+static PyObject* __CDECL py_appl_exit(PyObject *self, PyObject *args);
+
+static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args);
+
+#endif /* __PY_AES_HEADERS */
|
