[Kde-bindings] smoke (non-q)object ownership proposal/question
Petr Vanek
petr at scribus.info
Mon Jul 12 06:51:29 UTC 2010
here is my initial draft of a question/proposal for smoke:
Meta Information in Smoke
The following is about the QT4 smoke bindings but is applicable to any
smoke binding.
libsmoke provides sufficient information for making mechanical
bindings for QT4, but needs to provide more information in order to
allow language bindings to use the library safely. For example,
ownership of objects is not always clear. It is not enough to know if
an object has been created by smoke or directly by the QT4 library;
instead, to manage memory properly, the ownership of the object must
be known, and this can only be known from how the object is used by
the API.
With objects descended from QObject, ownership is generally clear, but
with objects of other classes it's not always clear. For example,
when you call QLayout::addItem(QLayoutItem *item) - the ownership of
item is transferred to the QLayout.
Qore's "qt4" module currently uses special argument and return value
handlers added onto methods to handle such cases - mostly to tag
objects as being externally owned or managed by the qore module (i.e.
safe to delete).
Is there any idea or plan to provide this kind of information in a
generic way in smoke (somehow in a per-library way) so that it could
be used by any client of the binding?
If not, from my not very deep knowledge of smoke, I was imagining that
the best way would be to provide a mechanism in smoke itself to track
ownership of objects and then to provide a way in smoke itself to
manage the ownership status of the object based on some simple rules
(i.e. QLayout::addItem() called on the object - object externally
owned, QLayout::removeItem() called on the object, object not
externally owned).
all the best,
petr
More information about the Kde-bindings
mailing list