[Kde-bindings] Qt bindings to D programming language.
Eldar Insafutdinov
e.insafutdinov at gmail.com
Sun Oct 26 23:34:57 UTC 2008
Yeah, I also thought about inheritance. But I can't understand one. For
example I subclass a QWidget in my C++ part of wrapper:
class QWidget_Proxy: public QWidget
{
Q_OBJECT
public:
QWidget_Proxy(QWidget* parent = 0);
void ancestor_mousePressEvent(QMouseEvent* qme);
virtual void mousePressEvent(QMouseEvent* qme);
}
void QWidget_Proxy::QWidget_Proxy(QWidget* parent)
{
}
//default implementation
void QWidget_Proxy::ancestor_mousePressEvent(QMouseEvent* qme)
{
QWidget::mousePressEvent(qme);
}
void QWidget_Proxy::mousePressEvent(QMouseEvent* qme)
{
Dispatch_QWidget_MousePressEvent(this, qme);
}
extern "C" void QWidget_mousePressEvent(Qwidget* qwidget, QMouseEvent qme)
{
qwidget.ancestor_mousePressEvent(QMouseEvent* qme)
}
And my D wrapper
class QWidget : QObject
{
private void* qwidgetPtr;
//constructor of D class
this()
{
qwidgetPtr = QWidget_new();
}
static extern (C) void Dispatch_QWidget_MousePressEvent(void* classPtr,
QMouseEvent *qme);
{
classPtr.mousePressEvent(qme);
}
void mousePressEvent(QMouseEvent qme)
{
QWidget_mousePressEvent(this.qwidgetPtr,qme)
}
}
Okey and I have the QPushButton which inherirts from QWidget (not directly
but it doesn't matter). C++ wrapper:
extern "C" void* QPushButton_new()
{
return new QPushButton_proxy();
}
D wrapper:
class QPushButton : QWidget
{
private void* qpushbuttonPtr;
//constructor of D class
this()
{
qpushbuttonPtr = QPushButton_new();
}
}
This is not 100% accurate - but the rough idea is that QPushButton_proxy is
inherited from QPushButton and QPushButton in its turn is inherited from
QWidget, not from QWidget_proxy. so when we create an instance of
QPushButton - all this virtual functions will not be implemented, because
they are implemented only in QWidget_proxy - and nothing is derived from
this class.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20081026/ba518779/attachment.html>
More information about the Kde-bindings
mailing list