File: binding.cc

package info (click to toggle)
tree-sitter-php 0.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,144 kB
  • sloc: ansic: 374,265; javascript: 1,464; lisp: 204; php: 158; python: 116; makefile: 49; cpp: 23; sh: 9
file content (31 lines) | stat: -rw-r--r-- 1,018 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
#include <napi.h>

typedef struct TSLanguage TSLanguage;

extern "C" TSLanguage *tree_sitter_php();
extern "C" TSLanguage *tree_sitter_php_only();

// "tree-sitter", "language" hashed with BLAKE2
const napi_type_tag LANGUAGE_TYPE_TAG = {
    0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
};

Napi::Object Init(Napi::Env env, Napi::Object exports) {
    auto php = Napi::Object::New(env);
    php["name"] = Napi::String::New(env, "php");
    auto php_language = Napi::External<TSLanguage>::New(env, tree_sitter_php());
    php_language.TypeTag(&LANGUAGE_TYPE_TAG);
    php["language"] = php_language;

    auto php_only = Napi::Object::New(env);
    php_only["name"] = Napi::String::New(env, "php_only");
    auto php_only_language = Napi::External<TSLanguage>::New(env, tree_sitter_php_only());
    php_only_language.TypeTag(&LANGUAGE_TYPE_TAG);
    php_only["language"] = php_only_language;

    exports["php"] = php;
    exports["php_only"] = php_only;
    return exports;
}

NODE_API_MODULE(tree_sitter_php_binding, Init)