File: binding.c

package info (click to toggle)
tree-sitter-markdown 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,688 kB
  • sloc: ansic: 137,646; javascript: 951; lisp: 79; python: 70; makefile: 46; cpp: 21; sh: 18
file content (35 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download
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
#include <Python.h>

typedef struct TSLanguage TSLanguage;

TSLanguage *tree_sitter_markdown(void);

TSLanguage *tree_sitter_markdown_inline(void);

static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
    return PyCapsule_New(tree_sitter_markdown(), "tree_sitter.Language", NULL);
}

static PyObject* _binding_inline_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
    return PyCapsule_New(tree_sitter_markdown_inline(), "tree_sitter.Language", NULL);
}

static PyMethodDef methods[] = {
    {"language", _binding_language, METH_NOARGS,
     "Get the tree-sitter language for the block grammar."},
    {"inline_language", _binding_inline_language, METH_NOARGS,
     "Get the tree-sitter language for the inline grammar."},
    {NULL, NULL, 0, NULL}
};

static struct PyModuleDef module = {
    .m_base = PyModuleDef_HEAD_INIT,
    .m_name = "_binding",
    .m_doc = NULL,
    .m_size = -1,
    .m_methods = methods
};

PyMODINIT_FUNC PyInit__binding(void) {
    return PyModule_Create(&module);
}