-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmain.cc
More file actions
38 lines (33 loc) · 1.31 KB
/
main.cc
File metadata and controls
38 lines (33 loc) · 1.31 KB
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
32
33
34
35
36
37
38
#include <node.h>
#include "cjson.h"
#include "common.h"
#include "fromjs.h"
#include "tojs.h"
void InitToBinding(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
isolate->ThrowException(v8::Exception::TypeError(
skbinding::FromUtf8(isolate, "Must have one parameters.")));
return;
};
if (!args[0]->IsObject()) {
isolate->ThrowException(v8::Exception::TypeError(
skbinding::FromUtf8(isolate, "The parameter must be an object.")));
return;
}
v8::Local<v8::Object> binding = args[0].As<v8::Object>();
skipruntime::SetFromJSBinding(isolate, binding);
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> module,
void* context) {
NODE_SET_METHOD(exports, "runWithGC", skbinding::RunWithGC);
NODE_SET_METHOD(exports, "unsafeAsyncRunWithGC",
skbinding::UnsafeAsyncRunWithGC);
NODE_SET_METHOD(exports, "getErrorObject", skbinding::GetErrorObject);
NODE_SET_METHOD(exports, "getJsonBinding", skjson::GetBinding);
NODE_SET_METHOD(exports, "getSkipRuntimeFromBinding",
skipruntime::GetToJSBinding);
NODE_SET_METHOD(exports, "initSkipRuntimeToBinding", InitToBinding);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)