• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "node.h"
2 #include "v8.h"
3 
4 #include <assert.h>
5 
6 using v8::Function;
7 using v8::FunctionCallbackInfo;
8 using v8::Isolate;
9 using v8::Local;
10 using v8::Object;
11 using v8::Value;
12 
13 namespace {
14 
MakeCallback(const FunctionCallbackInfo<Value> & args)15 void MakeCallback(const FunctionCallbackInfo<Value>& args) {
16   assert(args[0]->IsObject());
17   assert(args[1]->IsFunction());
18   Isolate* isolate = args.GetIsolate();
19   Local<Object> recv = args[0].As<Object>();
20   Local<Function> method = args[1].As<Function>();
21 
22   node::MakeCallback(isolate, recv, method, 0, nullptr,
23                      node::async_context{0, 0});
24 }
25 
Initialize(Local<Object> exports)26 void Initialize(Local<Object> exports) {
27   NODE_SET_METHOD(exports, "makeCallback", MakeCallback);
28 }
29 
30 }  // anonymous namespace
31 
32 NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
33