You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make AtomWindow inherit from BrowserWindow but run into the error "require constructor call" which is thrown from atom-shell. Is it possible to do this?
After some experiments, I decided to make BrowserWindow not inheritable again, here are my reasons:
Internal fields are not inheritable
Because BrowserWindow is a wrap of native C++ class, I need to store C++ object in V8 object's internal fields, however since internal fields are not inherited via prototype inheritance, I can not get the wrapped C++ object from derived class's this object without hacks.
Performance
In order to be able to get the wrapped C++ object from JS object, I have to store the native this object in the JS object somewhere, and then manually find it when I need to lookup the C++ object, which hurts the performance.
And generated JS code of Coffee Script doesn't work well with these hacks.
Two this object
Distinguished from inheritance of pure JS class, which just calls base class's constructor as plain function, inheriting native class requires calling the native class's constructor with new, and also remembering the created native this object, which means we have to work with two this objects, this just make things a mess.
So my conclusion is, making inheritance of native class from JS work would cause too much troubles and we should not support it.
Activity
zcbenz commentedon Jun 18, 2013
A typical example of inheriting native class is:
To make it work, the generated constructor should return the result of base class's constructor, like this:
But somehow coffeescript generated constructor like this:
There seems to be tons of related issues in coffeescript's github page, I'm still investigating it.
zcbenz commentedon Jun 18, 2013
Hmm, coffeescript is doing the right thing, my problem is now that the native class's internal fields are not inherited via prototype inheritance, this is a limitation of V8 or JavaScript, but v8-juice does have a workaround of it:
http://code.google.com/p/v8-juice/source/browse/trunk/src/include/v8/juice/ClassWrap.h#480
Revert "Make BrowserWindow inheritable. Fixed #23."
zcbenz commentedon Jun 18, 2013
After some experiments, I decided to make BrowserWindow not inheritable again, here are my reasons:
Internal fields are not inheritable
Because BrowserWindow is a wrap of native C++ class, I need to store C++ object in V8 object's internal fields, however since internal fields are not inherited via prototype inheritance, I can not get the wrapped C++ object from derived class's
thisobject without hacks.Performance
In order to be able to get the wrapped C++ object from JS object, I have to store the native
thisobject in the JS object somewhere, and then manually find it when I need to lookup the C++ object, which hurts the performance.Too many hacks in JS
To make inheritance of native class work as expected, many hacks have to be used, the v8-juice's Wiki explains this very well:
http://code.google.com/p/v8-juice/wiki/ClassBinderPartTwo#Inheriting_Native_Classes_from_JS
And generated JS code of Coffee Script doesn't work well with these hacks.
Two
thisobjectDistinguished from inheritance of pure JS class, which just calls base class's constructor as plain function, inheriting native class requires calling the native class's constructor with
new, and also remembering the created nativethisobject, which means we have to work with twothisobjects, this just make things a mess.So my conclusion is, making inheritance of native class from JS work would cause too much troubles and we should not support it.
Add attributes directly to BrowserWindow
Merge pull request #23 from brightray/ninja
Update libchromiumcontent to get ICU headers
Merge pull request #23 from brightray/ninja
Update libchromiumcontent to get ICU headers
Merge pull request #23 from electron/promise
fix(wexond) circumvent security measures from Google
fix(wexond) circumvent security measures from Google (#56)