forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclrmod.c
More file actions
70 lines (60 loc) · 1.49 KB
/
clrmod.c
File metadata and controls
70 lines (60 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "pynetclr.h"
/* List of functions defined in the module */
static PyMethodDef clr_methods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyDoc_STRVAR(clr_module_doc,
"clr facade module to initialize the CLR. It's later "
"replaced by the real clr module. This module has a facade "
"attribute to make it distinguishable from the real clr module."
);
static PyNet_Args *pn_args;
char **environ = NULL;
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef clrdef = {
PyModuleDef_HEAD_INIT,
"clr", /* m_name */
clr_module_doc, /* m_doc */
-1, /* m_size */
clr_methods, /* m_methods */
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
};
#endif
static PyObject *_initclr()
{
PyObject *m;
/* Create the module and add the functions */
#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&clrdef);
#else
m = Py_InitModule3("clr", clr_methods, clr_module_doc);
#endif
if (m == NULL)
return NULL;
PyModule_AddObject(m, "facade", Py_True);
Py_INCREF(Py_True);
pn_args = PyNet_Init(1);
if (pn_args->error)
{
return NULL;
}
if (NULL != pn_args->module)
return pn_args->module;
return m;
}
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC
PyInit_clr(void)
{
return _initclr();
}
#else
PyMODINIT_FUNC
initclr(void)
{
_initclr();
}
#endif