diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-14 19:59:18 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-14 19:59:33 +0100 |
| commit | 9b7bda28db0200b628e5f6eb7021a5a717db2e73 (patch) | |
| tree | 2f477b0fe308da3554fbd0ab807c4c4725715311 /bindings/python/tree_sitter_wmap/binding.c | |
Initial grammar
Diffstat (limited to 'bindings/python/tree_sitter_wmap/binding.c')
| -rw-r--r-- | bindings/python/tree_sitter_wmap/binding.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bindings/python/tree_sitter_wmap/binding.c b/bindings/python/tree_sitter_wmap/binding.c new file mode 100644 index 0000000..bbc4012 --- /dev/null +++ b/bindings/python/tree_sitter_wmap/binding.c @@ -0,0 +1,35 @@ +#include <Python.h> + +typedef struct TSLanguage TSLanguage; + +TSLanguage *tree_sitter_wmap(void); + +static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { + return PyCapsule_New(tree_sitter_wmap(), "tree_sitter.Language", NULL); +} + +static struct PyModuleDef_Slot slots[] = { +#ifdef Py_GIL_DISABLED + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, +#endif + {0, NULL} +}; + +static PyMethodDef methods[] = { + {"language", _binding_language, METH_NOARGS, + "Get the tree-sitter language for this grammar."}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef module = { + .m_base = PyModuleDef_HEAD_INIT, + .m_name = "_binding", + .m_doc = NULL, + .m_size = 0, + .m_methods = methods, + .m_slots = slots, +}; + +PyMODINIT_FUNC PyInit__binding(void) { + return PyModuleDef_Init(&module); +} |