On Wed, Jul 9, 2014 at 9:01 PM, Jane Chen <[email protected]> wrote: > Ben, > > How am I supposed to expose the class to the global object? > > I have this: > > // create and bind XMLBuilder function > v8::Local<v8::FunctionTemplate> bldrTemp = > v8::FunctionTemplate::New(isolate,createBuilder); > v8::Local<v8::String> bldrLabel = > v8::String::NewFromUtf8(isolate, "XMLBuilder"); > bldrTemp->SetClassName(bldrLabel); > global->Set(bldrLabel,bldrTemp); > >> var b = new XMLBuilder(); >> b instanceof XMLBuilder; > false >> Object.prototype.toString.call(b); > [object XMLBuilder]
In pseudo-code: Local<Context> context = /* ... */; Local<String> name = /* ... */; Local<FunctionTemplate> t = FunctionTemplate::New(...); t->SetClassName(name); context->Global()->Set(name, t->GetFunction()); Note that you don't need to expose the constructor on the actual global object, as long as it's in scope when you call `instanceof`. HTH. -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
