about summary refs log tree commit diff stats
path: root/tree-sitter/dsk/dsk-cli/templates/js-addon/bindings/node.cc
blob: d0ba098a5407f0da2919412f674654c9611413c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "napi.h"

typedef struct TSLanguage TSLanguage;

extern "C" TSLanguage *tree_sitter___DSL_NAME__();

// "tree_sitter___DSL_NAME___binding" is the symbol that gets exported
// when this file is compiled as a Node.js addon.
Napi::Object Init(Napi::Env env, Napi::Object exports) {
  exports["name"] = Napi::String::New(env, "__DSL_NAME__");
  auto language = tree_sitter___DSL_NAME__();
  exports["language"] = Napi::External<TSLanguage>::New(env, language);
  return exports;
}

NODE_API_MODULE(tree_sitter___DSL_NAME___binding, Init)