Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2000

Bindings generator: Improve support for multiple inheritance

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Moved
    • P2: Important
    • Some future release
    • None
    • Qt Script
    • None

    Description

      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.

      There is no way currently to specify a custom [[HasInstance]]. This would have to be an extension to QScriptClass.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kenthans Kent Hansen (Inactive)
            ezf ezf
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes