2022-11-14 21:18:44 +00:00
|
|
|
#include "nan.h"
|
2021-03-10 02:32:51 +00:00
|
|
|
#include "tree_sitter/parser.h"
|
|
|
|
#include <node.h>
|
|
|
|
|
|
|
|
using namespace v8;
|
|
|
|
|
2022-11-14 21:18:44 +00:00
|
|
|
extern "C" TSLanguage *tree_sitter_context_predicate();
|
2021-03-10 02:32:51 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
NAN_METHOD(New) {}
|
|
|
|
|
|
|
|
void Init(Local<Object> exports, Local<Object> module) {
|
|
|
|
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
|
|
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
|
|
|
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
|
|
|
|
|
|
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
2022-11-14 21:18:44 +00:00
|
|
|
Local<Object> instance =
|
|
|
|
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
2021-03-10 02:32:51 +00:00
|
|
|
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_context_predicate());
|
|
|
|
|
2022-11-14 21:18:44 +00:00
|
|
|
Nan::Set(instance, Nan::New("name").ToLocalChecked(),
|
|
|
|
Nan::New("context_predicate").ToLocalChecked());
|
2021-03-10 02:32:51 +00:00
|
|
|
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
NODE_MODULE(tree_sitter_context_predicate_binding, Init)
|
|
|
|
|
2022-11-14 21:18:44 +00:00
|
|
|
} // namespace
|