tree-sitter-bp/bindings/node/binding.cc

21 lines
567 B
C++
Raw Permalink Normal View History

#include <napi.h>
2024-04-07 20:59:34 +02:00
typedef struct TSLanguage TSLanguage;
2024-04-07 20:59:34 +02:00
extern "C" TSLanguage *tree_sitter_bp();
2024-04-07 20:59:34 +02:00
// "tree-sitter", "language" hashed with BLAKE2
const napi_type_tag LANGUAGE_TYPE_TAG = {
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
};
2024-04-07 20:59:34 +02:00
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports["name"] = Napi::String::New(env, "bp");
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_bp());
language.TypeTag(&LANGUAGE_TYPE_TAG);
exports["language"] = language;
return exports;
2024-04-07 20:59:34 +02:00
}
NODE_API_MODULE(tree_sitter_bp_binding, Init)