Yes, it works for me also, but the problem is that this also calls the 
constructor invocation callback, which I want to avoid in this case.


12 март 2012, понеделник 17:55:17 UTC+2, Stephan Beal написа:
>
> On Mon, Mar 12, 2012 at 4:39 PM, avasilev <[email protected]> wrote:
>
>> Basically I would like to be able to have instanceof working on objects 
>> that implement native bindings. If I create the object in C++ via 
>> Function::NewInstance(), then this works as expected. However, I want to be 
>> able to create an object both via the js constructor, and in C++ code 
>> without the C++ code calling the js constructor (which happend if I use 
>> Function::NewInstance()).
>
>
> If you want v8 to know about the object, the native ctor must tell it. Or 
> you can...
>  
>
>> Is it possible to do that? I tried to instantiate the object from the 
>> constructor's prototype template, via 
>> ctorFunc->PrototypeTemplate()->NewIsntance(), but this does not do the job 
>> and instanceof does not recognize the object as created by this 
>> constructor. Any ideas?
>>
>
> NewInstance() works for me. Here's an example of how i'm using it:
>
>
> http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp?r=2173#894
>
> The CastFromJS() call there essentially needs to be replaced with your 
> extract-native-from-JS-Object routine.
>
> If you want to be able to destroy such object from C++ code (don't use 
> delete - it will leave the v8 bits pointing at dead objects), there's an 
> example of that here:
>
>
> http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp?r=2173#971
>
> i hope that helps.
>
> -- 
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
> http://gplus.to/sgbeal
>
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to