Sorry guys, this works like a charm.
I was my own stupidity.
Thanks!!
Em quinta-feira, 10 de outubro de 2013 20h00min01s UTC-3, Thiago Moura
escreveu:
>
> Hi guys!
>
> In the following scenario of a JS implementation:
>
> function f() {
> var v = new WrappedObject();
> return v.getMethodResult();
> }
>
> How can I Intercept the "getMethodResult" in the ObjectTemplate
> "getMethodResult" property callback and explicitly call another function?
>
> What I'm doing right now:
>
> Handle<FunctionTemplate> class_template =
> Handle<FunctionTemplate>::New(isolate,
> FunctionTemplate::New(ConstructorCallback));
>
> Handle<String> class_str = String::New(class_name);
> class_template->SetClassName(class_str);
>
> Handle<ObjectTemplate> obj_template = class_template->InstanceTemplate();
> obj_template->SetInternalFieldCount(1);
> obj_template->SetNamedPropertyHandler(PropertyGet, PropertySet);
>
> Local<Context> context = Local<Context>::New(isolate, __context);
>
> context->Global()->Set(String::New(class_name),
> class_template->GetFunction());
>
> --
>
> And my GetProperty Callback:
>
> void PropertyGet(Local<String> name, const PropertyCallbackInfo<Value>
> &info) {
> char* value = UnwrapStringObject(info.Holder());
>
> info.GetReturnValue().Set(String::New(value));
> }
>
>
> This works and I know that JS will see my method as a property, so, ok.
> but I didn't figured out how to tell to JS that the result needs to be a
> new function to evaluate.
>
> I've tried something like:
>
>
>
> info.GetReturnValue().Set(FunctionTemplate::New(GenericFunctionCallback)->GetFunction());
>
> But this does not work.
>
> Ps: This needs to be a generic handler for all functions. I cannot name a
> function previously, because this information will be retrieved by a JNI
> call.
>
> Anyone can help me with it?
>
> Thanks!
>
--
--
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/groups/opt_out.