Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <python3.4m/Python.h>
- static PyObject *
- metest_thing(PyObject *self, PyObject *args)
- {
- int a, b;
- int ret;
- if (!PyArg_ParseTuple(args, "ii", &a, &b))
- return NULL;
- Py_XDECREF(args)
- ret = a + b;
- return PyLong_FromLong(ret);
- }
- static PyMethodDef TestMethods[] = {
- {"thing", metest_thing, METH_VARARGS,
- "Add 2 PyNumbers"},
- {NULL, NULL, 0, NULL}
- };
- static struct PyModuleDef metestmodule = {
- PyModuleDef_HEAD_INIT,
- "metest", /* Name of module */
- NULL, /* documentation */
- -1, /* global state */
- TestMethods
- };
- PyMODINIT_FUNC
- PyInit_metest(void)
- {
- PyObject *mod;
- mod = PyModule_Create(&metestmodule);
- if (mod == NULL)
- return NULL;
- return mod;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement