Tried a lot of things and basically I'm doing what you have described. BUT, depending how you publish it - as an Obj or Function behavior is different. If I publish as an object, cannot call a method() - complains that it is not a function, if as a Obj - accessors are not called. In the example I can do both - invoke callbacks and prop accessors.BUT, object passed as a parameter is not a function. And I do need to call it... I kind of know way around, but I think if there is a way to tell objectTemplate to SetCallAsFunctionHandler, then should be a way to deduce the Function from such object...unless I'm missing something.
Thanks VLad On Tue, Jun 1, 2010 at 2:47 PM, Stephan Beal <[email protected]> wrote: > On Tue, Jun 1, 2010 at 11:40 PM, vlad vladbph <[email protected]> wrote: > >> As I said it is artificial example :) The key is how original object is >> created... >> >> I need an object that can be called as a function and at the same time >> have properties which I can set getters for... I didn't find the way doing >> so besides: >> > > looking over the API, i _think_ you might be able to do the following: > > - Create a Function instead of an Object, using > FunctionTemplate::New(func). We'll call that funcTmpl. > - Use funcTmpl->InstanceTemplate() or PrototypeTemplate() (not sure which) > to get an ObjectTemplate, which you can then (theoretically) apply the > accessors to. > - Instantiate that function using funcTmpl->GetFunction(), or possibly > InstanceTemplate()->NewInstance(). (???) > > (Warning: i am largely speculating here - the API docs are fairly lean.) > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
