Background: ECMAScript can't mimic multiple inheritance "out of the box", since
an object
has only a single prototype link. When binding a class like QWidget, which
inherits from
QObject and QPaintDevice, this leads to the following issues:
1. Methods in the secondary base class are not available. The current solution
is that the
QWidget prototype has a property _QPaintDevice_, so you have to do something
like
widget._QPaintDevice_.numColors.call(widget);
Another solution would be to copy all the properties in the QPaintDevice
prototype that
don't conflict with QWidget's prototype over to the QWidget prototype, but this
is
suboptimal.
2. The expression "widget instanceof QPaintDevice" evaluates to false, since
this will use
the standard Function [[HasInstance]] (which follows the single-prototype
chain).
Maybe we can use a scheme similar to the one described here:
http://www.w3.org/TR/DOM-Bindings/#interface-prototype-object
In QtScript, this could be done by subclassing QScriptClass and keep a list of
prototype
objects that are looked up when a property is resolved, and reimplement
[[HasInstance]]
(using the QScriptClass::HasInstance extension).
Original issue reported on code.google.com by kentm...@gmail.com on 18 Nov 2009 at 12:28
Original issue reported on code.google.com by
kentm...@gmail.com
on 18 Nov 2009 at 12:28