class A {
local<object> CreateObject( callback) {
if(!p->isEmpty()){
auto tmp = Object::New(Isolate, objTemplate
); //get from cache.
return tmp->newInstance(); //we have a template, create a instance.
}
/* create object here and assign callback {x:callback[function]} */
objTemplate
.Reset(Isolate, obj); //cache here.
return obj->newInstance();.
}
~A(){
objTemplate
.Reset();
}
private:
Persistent<ObjectTemplate> objTemplate;
}
/* NativeFunction declared here will be linked to obj methods created by A */
A a;
void MakeObject(functionCallbackInfo args){
args->GetReturn().Set(a.CreateObject(NativeFunction))
}
Enter code here...
(function(){
for(var i=0; i<1000; i++) {
// this call MakeObject in C++.
var tmp = make_object(); // tmp => {n:[function],....};
}
})
Thank you
--
--
v8-users mailing list
v8-u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.