-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbinding.c
More file actions
40 lines (33 loc) · 1021 Bytes
/
binding.c
File metadata and controls
40 lines (33 loc) · 1021 Bytes
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
#include <Python.h>
typedef struct TSLanguage TSLanguage;
TSLanguage *tree_sitter_vb_dotnet(void);
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
TSLanguage *language = tree_sitter_vb_dotnet();
if (language == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Failed to load VB.NET language grammar");
return NULL;
}
return PyCapsule_New(language, "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);
}