-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathzamlmodule.zig
58 lines (53 loc) · 1.34 KB
/
zamlmodule.zig
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
const py = @cImport({
@cDefine("Py_LIMITED_API", "3");
@cDefine("PY_SSIZE_T_CLEAN", {});
@cInclude("Python.h");
});
const PyObject = py.PyObject;
const PyMethodDef = py.PyMethodDef;
const PyModuleDef = py.PyModuleDef;
const PyModuleDef_Base = py.PyModuleDef_Base;
const Py_BuildValue = py.Py_BuildValue;
const PyModule_Create = py.PyModule_Create;
const METH_NOARGS = py.METH_NOARGS;
fn zaml_load(self: [*c]PyObject, args: [*c]PyObject) callconv(.C) [*]PyObject {
_ = self;
_ = args;
return Py_BuildValue("i", @as(c_int, 1));
}
var ZamlMethods = [_]PyMethodDef{
PyMethodDef{
.ml_name = "load",
.ml_meth = zaml_load,
.ml_flags = METH_NOARGS,
.ml_doc = "Load some tasty YAML.",
},
PyMethodDef{
.ml_name = null,
.ml_meth = null,
.ml_flags = 0,
.ml_doc = null,
},
};
var zamlmodule = PyModuleDef{
.m_base = PyModuleDef_Base{
.ob_base = PyObject{
.ob_refcnt = 1,
.ob_type = null,
},
.m_init = null,
.m_index = 0,
.m_copy = null,
},
.m_name = "zaml",
.m_doc = null,
.m_size = -1,
.m_methods = &ZamlMethods,
.m_slots = null,
.m_traverse = null,
.m_clear = null,
.m_free = null,
};
pub export fn PyInit_zaml() [*]PyObject {
return PyModule_Create(&zamlmodule);
}