1 #include <node.h> 2 #include <v8.h> 3 4 namespace { 5 NewClass(const v8::FunctionCallbackInfo<v8::Value> & args)6inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) { 7 // this != new.target since we are being invoked through super(). 8 assert(args.IsConstructCall()); 9 assert(!args.This()->StrictEquals(args.NewTarget())); 10 } 11 Initialize(v8::Local<v8::Object> binding)12inline void Initialize(v8::Local<v8::Object> binding) { 13 auto isolate = binding->GetIsolate(); 14 auto context = isolate->GetCurrentContext(); 15 binding->Set(context, v8::String::NewFromUtf8( 16 isolate, "Class").ToLocalChecked(), 17 v8::FunctionTemplate::New(isolate, NewClass) 18 ->GetFunction(context) 19 .ToLocalChecked()).FromJust(); 20 } 21 22 NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) 23 24 } // anonymous namespace 25