I am trying to associate some custom C++ data with a Local<Function> 
instance.

Currently I am able to achieve this only to instances created with this 
function:

Local<FunctionTemplate> tmpl = FunctionTemplate::New(isolate, [](const 
FunctionCallbackInfo<Value> &info) {
    Isolate* isolate = info.GetIsolate();
    // Associate some custom C++ data with the instance created through 
this function
    info.This()->SetInternalField(0, External::New(isolate, nullptr));
});
tmpl->InstanceTemplate()->SetInternalFieldCount(1);
Local<Function> func = tmpl->GetFunction(context).ToLocalChecked();

Local<Object> instance = func->NewInstance(context).ToLocalChecked();
// Getting back the C++ data associated with the instance
Local<External> extData = instance->GetInternalField(0).As<External>();

What I would like to achieve is to associate the function instance with 
custom data:

func->SetInternalField(0, External::New(isolate, nullptr));

But unfortunately this throws an "Internal field out of bounds error".

Is it possible to achieve this?

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/b2615053-d492-4a1b-813a-3d9882ac508f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to