Thanks Ben! Yes, I am aware of this but actually I need to retrieve this external data *before* creating an instance using the function. Here's an example:
var myFunc = MyCustomFunction; // Here MyCustomFunction is an instance of Local<Function> that I have registered on the global object someCustomMethod(myFunc); Here I am passing MyCustomFunction as parameter to the method. Inside the callback of this custom method I am able to retrieve its argument (which is a Local<Function>) and from this function I need to retrieve its external field. So the question is how do I register a custom external field to this Local<Function> instance? On Tuesday, March 19, 2019 at 12:07:28 PM UTC+2, Ben Noordhuis wrote: > > On Tue, Mar 19, 2019 at 9:41 AM Darin Dimitrov <darin.d...@gmail.com > <javascript:>> wrote: > > > > I am trying to associate an internal field with a Local<Function> > created from a Local<FunctionTemplate>: > > > > Local<FunctionTemplate> ctorFuncTemplate = > FunctionTemplate::New(isolate); > > > > Local<Function> ctorFunc = > ctorFuncTemplate->GetFunction(context).ToLocalChecked(); > > > > ctorFunc->SetInternalField(0, External::New(isolate, ptr)); > > > > > > This fails with "Internal field out of bounds". > > > > > > I am able to properly set the internal field count on object instances > created from this function: > > > > > > ctorFuncTemplate->InstanceTemplate()->SetInternalFieldCount(1); > > > > > > But what would be the proper way to set the internal field count for the > function instance itself? > > It sounds like you should pass the External as the `data` argument to > FunctionTemplate::New(). > > You'll be able to retrieve it in the callback as > FunctionCallbackInfo<Value>::Data(). > -- -- v8-users mailing list v8-users@googlegroups.com 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 v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.