Rizin
unix-like reverse engineering framework and cli tools
binding.cc
Go to the documentation of this file.
1 #include "tree_sitter/parser.h"
2 #include <node.h>
3 #include "nan.h"
4 
5 using namespace v8;
6 
8 
9 namespace {
10 
11 NAN_METHOD(New) {}
12 
13 void Init(Local<Object> exports, Local<Object> module) {
14  Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
15  tpl->SetClassName(Nan::New("Language").ToLocalChecked());
16  tpl->InstanceTemplate()->SetInternalFieldCount(1);
17 
18  Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
19  Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
20  Nan::SetInternalFieldPointer(instance, 0, tree_sitter_PARSER_NAME());
21 
22  Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("PARSER_NAME").ToLocalChecked());
23  Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
24 }
25 
26 NODE_MODULE(tree_sitter_PARSER_NAME_binding, Init)
27 
28 } // namespace
int Init(const char *driverPath)
#define v8
Definition: sparc-opc.c:58
Definition: sftypes.h:77
TSLanguage * tree_sitter_PARSER_NAME()