chiark / gitweb /
General reorganization.
[mLib-python] / array.c
diff --git a/array.c b/array.c
index 37850d9..6f8048a 100644 (file)
--- a/array.c
+++ b/array.c
@@ -36,6 +36,7 @@
 #include <mLib/dstr.h>
 #include <mLib/exc.h>
 
+#include "array.h"
 #include "grim.h"
 
 /*----- Data structures ---------------------------------------------------*/
@@ -58,8 +59,6 @@ typedef struct daiter_pyobj {
 #define DAITER_V(obj) DA_V(DAITER_DA(obj))
 #define DAITER_I(obj) (((daiter_pyobj *)(obj))->i)
 
-static PyTypeObject da_pytype, daiter_pytype;
-
 static int getseq(PyObject **pseq, PyObject ***v, size_t *n)
 {
   PyObject *seq = *pseq;
@@ -118,7 +117,7 @@ static PyObject *daiter_pynext(PyObject *me)
 static void daiter_pydealloc(PyObject *me)
   { Py_DECREF(DAITER_DA(me)); PyObject_DEL(me); }
 
-static PyTypeObject daiter_pytype = {
+PyTypeObject daiter_pytype = {
   PyObject_HEAD_INIT(0) 0,             /* Header */
   "array.ArrayIter",                   /* @tp_name@ */
   sizeof(daiter_pyobj),                        /* @tp_basicsize@ */
@@ -600,7 +599,7 @@ static PyMappingMethods da_pymapping = {
   da_pyput                             /* @mp_ass_subscript@ */
 };
 
-static PyTypeObject da_pytype = {
+PyTypeObject da_pytype = {
   PyObject_HEAD_INIT(0) 0,             /* Header */
   "array.Array",                       /* @tp_name@ */
   sizeof(da_pyobj),                    /* @tp_basicsize@ */
@@ -650,14 +649,7 @@ static PyTypeObject da_pytype = {
 
 /*----- Initialization ----------------------------------------------------*/
 
-static PyMethodDef emptymethods[] = { { 0 } };
-
-void initarray(void)
-{
-  PyObject *mod = Py_InitModule("array", emptymethods);
-  PyType_Ready(&da_pytype); PyType_Ready(&daiter_pytype);
-  PyModule_AddObject(mod, "Array", (PyObject *)&da_pytype);
-  PyModule_AddObject(mod, "ArrayIter", (PyObject *)&daiter_pytype);
-}
+void da_pysetup(void)
+  { PyType_Ready(&da_pytype); PyType_Ready(&daiter_pytype); }
 
 /*----- That's all, folks -------------------------------------------------*/