chiark / gitweb /
@@@ mLib-python Pyke wip
[mLib-python] / mLib.c
1 /* -*-c-*-
2  *
3  * Where the fun begins
4  *
5  * (c) 2019 Straylight/Edgeware
6  */
7
8 /*----- Licensing notice --------------------------------------------------*
9  *
10  * This file is part of the Python interface to mLib.
11  *
12  * mLib/Python is free software: you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation; either version 2 of the License, or (at your
15  * option) any later version.
16  *
17  * mLib/Python is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with mLib/Python.  If not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25  * USA.
26  */
27
28 /*----- Header files ------------------------------------------------------*/
29
30 #include "mLib-python.h"
31
32 /*----- Main code ---------------------------------------------------------*/
33
34 static PyObject *meth__ready(PyObject *me, PyObject *arg)
35 {
36   PyObject *mod;
37
38   if (!PyArg_ParseTuple(arg, "O!:_ready", &PyModule_Type, &mod))
39     goto end;
40   Py_XDECREF(home_module); home_module = mod; Py_INCREF(home_module);
41   if (ui_pyready()) goto end;
42   RETURN_NONE;
43 end:
44   return (0);
45 }
46
47 static const PyMethodDef methods[] = {
48 #define METHNAME(name) meth_##name
49   METH  (_ready,        0)
50 #undef METHNAME
51   { 0 }
52 };
53
54 #ifdef PY3
55 static PyModuleDef moddef = {
56   PyModuleDef_HEAD_INIT,
57   "mLib._base",                         /* @m_name@ */
58   "Low-level module for mLib bindings.  Use `mLib' instead.",
59                                         /* @m_doc@ */
60   0,                                    /* @m_size@ */
61   0,                                    /* @m_methods@ */
62   0,                                    /* @m_slots@ */
63   0,                                    /* @m_traverse@ */
64   0,                                    /* @m_clear@ */
65   0                                     /* @m_free@ */
66 };
67 #endif
68
69 EXPORT PyMODINIT_FUNC PY23(init_base, PyInit__base)(void)
70 {
71   PyObject *mod;
72
73   modname = TEXT_FROMSTR("mLib");
74   addmethods(methods);
75   INIT_MODULES;
76 #ifdef PY3
77   moddef.m_methods = donemethods();
78   mod = PyModule_Create(&moddef);
79 #else
80   mod = Py_InitModule("mLib._base", donemethods());
81 #endif
82   INSERT_MODULES;
83 #ifdef PY3
84   return (mod);
85 #endif
86 }
87
88 /*----- That's all, folks -------------------------------------------------*/