Issue 31 in v8-juice: V8Convert JavaScript Inheritance

9 views
Skip to first unread message

v8-j...@googlecode.com

unread,
Feb 20, 2012, 6:58:34 AM2/20/12
to v8-juic...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 31 by korz.nik...@gmail.com: V8Convert JavaScript Inheritance
http://code.google.com/p/v8-juice/issues/detail?id=31

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

v8-j...@googlecode.com

unread,
Feb 20, 2012, 12:42:32 PM2/20/12
to v8-juic...@googlegroups.com

Comment #1 on issue 31 by sgb...@gmail.com: V8Convert JavaScript Inheritance
http://code.google.com/p/v8-juice/issues/detail?id=31

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_Classes_from_JS

v8-j...@googlecode.com

unread,
Feb 20, 2012, 12:57:35 PM2/20/12
to v8-juic...@googlegroups.com

Comment #2 on issue 31 by korz.nik...@gmail.com: V8Convert JavaScript
Inheritance
http://code.google.com/p/v8-juice/issues/detail?id=31

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

v8-j...@googlecode.com

unread,
Feb 20, 2012, 1:04:40 PM2/20/12
to v8-juic...@googlegroups.com

Comment #3 on issue 31 by sgb...@gmail.com: V8Convert JavaScript Inheritance
http://code.google.com/p/v8-juice/issues/detail?id=31

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.

v8-j...@googlecode.com

unread,
Apr 29, 2012, 9:50:03 AM4/29/12
to v8-juic...@googlegroups.com
Updates:
Status: SeemsToBeImpossible
Labels: Severity-NiceToHave Component-ClassBinding

Comment #4 on issue 31 by sgb...@gmail.com: V8Convert JavaScript Inheritance
http://code.google.com/p/v8-juice/issues/detail?id=31

(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages