@@@ mLib-python Pyke wip
[mLib-python] / mLib.c
diff --git a/mLib.c b/mLib.c
new file mode 100644 (file)
index 0000000..2acb4c6
--- /dev/null
+++ b/mLib.c
@@ -0,0 +1,88 @@
+/* -*-c-*-
+ *
+ * Where the fun begins
+ *
+ * (c) 2019 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of the Python interface to mLib.
+ *
+ * mLib/Python is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * mLib/Python is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with mLib/Python.  If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include "mLib-python.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+static PyObject *meth__ready(PyObject *me, PyObject *arg)
+{
+  PyObject *mod;
+
+  if (!PyArg_ParseTuple(arg, "O!:_ready", &PyModule_Type, &mod))
+    goto end;
+  Py_XDECREF(home_module); home_module = mod; Py_INCREF(home_module);
+  if (ui_pyready()) goto end;
+  RETURN_NONE;
+end:
+  return (0);
+}
+
+static const PyMethodDef methods[] = {
+#define METHNAME(name) meth_##name
+  METH (_ready,        0)
+#undef METHNAME
+  { 0 }
+};
+
+#ifdef PY3
+static PyModuleDef moddef = {
+  PyModuleDef_HEAD_INIT,
+  "mLib._base",                                /* @m_name@ */
+  "Low-level module for mLib bindings.  Use `mLib' instead.",
+                                       /* @m_doc@ */
+  0,                                   /* @m_size@ */
+  0,                                   /* @m_methods@ */
+  0,                                   /* @m_slots@ */
+  0,                                   /* @m_traverse@ */
+  0,                                   /* @m_clear@ */
+  0                                    /* @m_free@ */
+};
+#endif
+
+EXPORT PyMODINIT_FUNC PY23(init_base, PyInit__base)(void)
+{
+  PyObject *mod;
+
+  modname = TEXT_FROMSTR("mLib");
+  addmethods(methods);
+  INIT_MODULES;
+#ifdef PY3
+  moddef.m_methods = donemethods();
+  mod = PyModule_Create(&moddef);
+#else
+  mod = Py_InitModule("mLib._base", donemethods());
+#endif
+  INSERT_MODULES;
+#ifdef PY3
+  return (mod);
+#endif
+}
+
+/*----- That's all, folks -------------------------------------------------*/