From 6c75b32a622ae3aca4fbe3065fc91c38abc39ef8 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Fri, 15 Mar 2024 19:22:53 +0200 Subject: [PATCH] feat: add language version constants --- .github/workflows/ci.yml | 1 + tree_sitter/__init__.py | 4 ++++ tree_sitter/binding/module.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb30408..c5a610f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: --with-assertions \ --with-address-sanitizer \ --with-undefined-behavior-sanitizer \ + --disable-test-modules \ --disable-shared \ --prefix="$PYTHON_PATH" make && make install diff --git a/tree_sitter/__init__.py b/tree_sitter/__init__.py index c77e629..243dfba 100644 --- a/tree_sitter/__init__.py +++ b/tree_sitter/__init__.py @@ -11,6 +11,8 @@ Range, Tree, TreeCursor, + LANGUAGE_VERSION, + MIN_COMPATIBLE_LANGUAGE_VERSION, ) __all__ = [ @@ -24,4 +26,6 @@ "Range", "Tree", "TreeCursor", + "LANGUAGE_VERSION", + "MIN_COMPATIBLE_LANGUAGE_VERSION", ] diff --git a/tree_sitter/binding/module.c b/tree_sitter/binding/module.c index 90a9722..5962f69 100644 --- a/tree_sitter/binding/module.c +++ b/tree_sitter/binding/module.c @@ -146,6 +146,10 @@ PyMODINIT_FUNC PyInit__binding(void) { goto cleanup; } + PyModule_AddIntConstant(module, "LANGUAGE_VERSION", TREE_SITTER_LANGUAGE_VERSION); + PyModule_AddIntConstant(module, "MIN_COMPATIBLE_LANGUAGE_VERSION", + TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION); + return module; cleanup: