tree-sitter-omega
aien-dev/tree-sitter-omega
Brought by drakestapleton
tree-sitter-omega / bindings / python / tree_sitter_omega / binding.c
| 1 | #include <Python.h> |
| 2 | |
| 3 | typedef struct TSLanguage TSLanguage; |
| 4 | |
| 5 | TSLanguage *tree_sitter_omega(void); |
| 6 | |
| 7 | static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { |
| 8 | return PyCapsule_New(tree_sitter_omega(), "tree_sitter.Language", NULL); |
| 9 | } |
| 10 | |
| 11 | static struct PyModuleDef_Slot slots[] = { |
| 12 | #ifdef Py_GIL_DISABLED |
| 13 | {Py_mod_gil, Py_MOD_GIL_NOT_USED}, |
| 14 | #endif |
| 15 | {0, NULL} |
| 16 | }; |
| 17 | |
| 18 | static PyMethodDef methods[] = { |
| 19 | {"language", _binding_language, METH_NOARGS, |
| 20 | "Get the tree-sitter language for this grammar."}, |
| 21 | {NULL, NULL, 0, NULL} |
| 22 | }; |
| 23 | |
| 24 | static struct PyModuleDef module = { |
| 25 | .m_base = PyModuleDef_HEAD_INIT, |
| 26 | .m_name = "_binding", |
| 27 | .m_doc = NULL, |
| 28 | .m_size = 0, |
| 29 | .m_methods = methods, |
| 30 | .m_slots = slots, |
| 31 | }; |
| 32 | |
| 33 | PyMODINIT_FUNC PyInit__binding(void) { |
| 34 | return PyModuleDef_Init(&module); |
| 35 | } |