From 4f359123327925e712be66eed36b1fd5368586c4 Mon Sep 17 00:00:00 2001 From: Artur Duque de Souza Date: Sun, 29 Nov 2009 04:38:33 +0000 Subject: [PATCH] Fix the GridLayout bindings as we do not have properties Now I figured it out: the c++ class has no properties because the setters need to get the row or the column and this is not a property. So now this commit fixes the problem of exporting it as properties in the binding. svn path=/trunk/KDE/kdebase/runtime/; revision=1055931 --- .../javascript/simplebindings/gridlayout.cpp | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/scriptengines/javascript/simplebindings/gridlayout.cpp b/scriptengines/javascript/simplebindings/gridlayout.cpp index 60061ee46..6a1bce6ca 100644 --- a/scriptengines/javascript/simplebindings/gridlayout.cpp +++ b/scriptengines/javascript/simplebindings/gridlayout.cpp @@ -142,28 +142,35 @@ public: { } }; -#define ADD_PROTO_PROPERTY(Property, __get__, __set__) \ - proto.setProperty(Property, eng->newFunction(__get__), QScriptValue::PropertyGetter); \ - proto.setProperty(Property, eng->newFunction(__set__), QScriptValue::PropertySetter); - QScriptValue constructGridLayoutClass(QScriptEngine *eng) { QScriptValue proto = QScript::wrapPointer(eng, new QGraphicsGridLayout(), QScript::UserOwnership); + const QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; + const QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; + proto.setProperty("horizontalSpacing", eng->newFunction(horizontalSpacing), getter); + proto.setProperty("horizontalSpacing", eng->newFunction(setHorizontalSpacing), setter); + proto.setProperty("verticalSpacing", eng->newFunction(verticalSpacing), getter); + proto.setProperty("verticalSpacing", eng->newFunction(setVerticalSpacing), setter); - ADD_PROTO_PROPERTY("horizontalSpacing", horizontalSpacing, setHorizontalSpacing); - ADD_PROTO_PROPERTY("verticalSpacing", verticalSpacing, setVerticalSpacing); + ADD_METHOD(proto, rowSpacing); + ADD_METHOD(proto, setRowSpacing); + ADD_METHOD(proto, columnSpacing); + ADD_METHOD(proto, setColumnSpacing); - ADD_PROTO_PROPERTY("rowSpacing", rowSpacing, setRowSpacing); - ADD_PROTO_PROPERTY("columnSpacing", columnSpacing, setColumnSpacing); - - ADD_PROTO_PROPERTY("rowMinimumHeight", rowMinimumHeight, setRowMinimumHeight); - ADD_PROTO_PROPERTY("rowPreferredHeight", rowPreferredHeight, setRowPreferredHeight); - ADD_PROTO_PROPERTY("rowMaximumHeight", rowMaximumHeight, setRowMaximumHeight); + ADD_METHOD(proto, rowMinimumHeight); + ADD_METHOD(proto, setRowMinimumHeight); + ADD_METHOD(proto, rowPreferredHeight); + ADD_METHOD(proto, setRowPreferredHeight); + ADD_METHOD(proto, rowMaximumHeight); + ADD_METHOD(proto, setRowMaximumHeight); ADD_METHOD(proto, setRowFixedHeight); - ADD_PROTO_PROPERTY("columnMinimumWidth", columnMinimumWidth, setColumnMinimumWidth); - ADD_PROTO_PROPERTY("columnPreferredWidth", columnPreferredWidth, setColumnPreferredWidth); - ADD_PROTO_PROPERTY("columnMaximumWidth", columnMaximumWidth, setColumnMaximumWidth); + ADD_METHOD(proto, columnMinimumWidth); + ADD_METHOD(proto, setColumnMinimumWidth); + ADD_METHOD(proto, columnPreferredWidth); + ADD_METHOD(proto, setColumnPreferredWidth); + ADD_METHOD(proto, columnMaximumWidth); + ADD_METHOD(proto, setColumnMaximumWidth); ADD_METHOD(proto, setColumnFixedWidth); ADD_METHOD(proto, removeAt);