void Bindings::info(const Args& args) { Isolate* isolate(args.GetIsolate()); HandleScope scope(isolate); Bindings* obj = ObjectWrap::Unwrap<Bindings>(args.Holder()); const std::string info(obj->m_session->info()); args.GetReturnValue().Set(String::NewFromUtf8(isolate, info.c_str())); }
void Bindings::construct(const Args& args) { Isolate* isolate(args.GetIsolate()); HandleScope scope(isolate); if (args.IsConstructCall()) { // Invoked as constructor with 'new'. Bindings* obj = new Bindings(); obj->Wrap(args.Holder()); args.GetReturnValue().Set(args.Holder()); } else { // Invoked as a function, turn into construct call. Local<Function> ctor(Local<Function>::New(isolate, constructor)); args.GetReturnValue().Set(ctor->NewInstance()); } }