m_instances.insert( std::make_pair( object, js_object ) );
// Set the internal field value to the C++ object
js_object->SetInternalField( 0, v8::External::New( object ) );
return js_object;
...
However a returned object has no class name set, so the "instanceof"
operator does not work. From what I've learned, the "instanceof"
operator works using the object.prototype.constructor property, though
I'm not sure how to correctly set it up in this wrap function.
Thanks Stephan. I've already looked at your v8-juice. But I was slightly afraid of it's experimental state and few comments inside.
Though before I jump to something as clever as v8-juice and v8, I'd really love to know how the thing works and what it does for me. Therefore I'm trying to put together something simple myself.
I looked into juice to see how you do this particular thingie, but was unable to find it. That fact proves that I'm not ready to use it. :)
Can you, please, point me where to look?
On 7 Jun 2010 22:08, "Stephan Beal" <sgb...@googlemail.com> wrote:
On Mon, Jun 7, 2010 at 4:45 PM, Martin Cohen <martin....@gmail.com> wrote:
>
> m_instance...
If you want to skip a lot of trial and error, and jump right into your coding, i strongly recommend using one of the several 3rd-party libs which take care of those bits for you.A partial list (the ones i know about):http://code.google.com/p/v8-juice (that one's mine! :)
Slapping a single class binding together isn't too much work (once you've done it a few times), but if you want to bind more than a couple classes, a generic framework for doing so is in order. The above libraries provide such features, each with varying strengths and weaknesses.
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
Thanks Stephan. I've already looked at your v8-juice. But I was slightly afraid of it's experimental state and few comments inside.
Though before I jump to something as clever as v8-juice and v8, I'd really love to know how the thing works and what it does for me.
I looked into juice to see how you do this particular thingie, but was unable to find it. That fact proves that I'm not ready to use it. :)
Can you, please, point me where to look?
instanceof should work out of the box. instanceof(object, function) is
defined in terms of searching for "function.prototype" along the
object's prototype chain, not in terms of class name. Have you
exported "m_t_object->GetFunction()" to javascript, used it in the
instanceof expression and it is broken for you?
In any case, you can set the class name on the function:
FunctionTemplate::SetClassName(). In V8, this only influences
toString, though.
Matthias
>
> Any ideas?
--