slavas490 / v8-juice

code.google.com/p/v8-juice
Other
0 stars 0 forks source link

V8Convert JavaScript Inheritance #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Subclass a native class in JavaScript
2. Create an instance of the subclass
3. Call an inherited (at least I expected it to be inherited) method

What is the expected output? What do you see instead?
Expected: The method should run fine
Instead: "Uncaught Error: CastFromJS<T>() returned NULL! Cannot find 'this' 
pointer!"

What version of the product are you using? On what operating system?
Version: Revision 2206
OS: Mac OS X 10.7

Original issue reported on code.google.com by korz.nik...@gmail.com on 20 Feb 2012 at 11:58

GoogleCodeExporter commented 8 years ago
For this behaviour to work you also need to tell the class binding mechanism 
that it should check the JS prototype chain for the "this" object. In the 
ClassCreator you can do this by adding the following template:

namespace cvv8 {
    template <>
    struct ClassCreator_SearchPrototypeForThis<MyType> : Opt_Bool<true>
    {};
}

Actually... the default impl of this class uses "true", which implies that i 
might have broken this.

If i'm not mistaken, you also need the horribly ugly workaround described here:

http://code.google.com/p/v8-juice/wiki/ClassBinderPartTwo#Inheriting_Native_Clas
ses_from_JS

Original comment by sgbeal@googlemail.com on 20 Feb 2012 at 5:41

GoogleCodeExporter commented 8 years ago
It works with your 'horrible workaround'. Though that is incompatible to 
CoffeeScript, which is kind of said. Any chance of that getting fixed? :-/

Original comment by korz.nik...@gmail.com on 20 Feb 2012 at 5:56

GoogleCodeExporter commented 8 years ago
i don't know _how_ to fix it :/. The only workaround i've ever found which 
works (in the sense that (this instanceof TheNative) works) is that ugly 
workaround. If you've got any ideas on how to solve it i'd love to hear them.

Original comment by sgbeal@googlemail.com on 20 Feb 2012 at 6:04

GoogleCodeExporter commented 8 years ago

Original comment by sgbeal@googlemail.com on 29 Apr 2012 at 1:49