# HG changeset patch # User eldar1@eldar1-laptop # Date 1265557566 0 # Node ID ed7018b63aa7a6fca012d167b2d6d8535af4eb56 # Parent 307af59d8bd83212ee8e1c016c298042fb5b541c# Parent 70f64e5b594216c82fb4788ab894c4b3427517d5 merge 2 diff -r 70f64e5b5942 -r ed7018b63aa7 CMakeLists.txt --- a/CMakeLists.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/CMakeLists.txt Sun Feb 07 15:46:06 2010 +0000 @@ -123,14 +123,14 @@ make_native_path(cd_path) add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build - COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} + COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} COMMENT "" ) ## "Make install" command. set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) add_custom_target(install - COMMAND cd ARGS ${cd_path} && ${make_util} install + COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install COMMENT "" ) add_dependencies(install preinstall) @@ -319,10 +319,10 @@ else(NOT is_founded) set(qtd_libs ${${package}_lib_param} ${qtd_libs}) endif(NOT is_founded) - endforeach(package ${PACKAGES_tmp}) + endforeach(package ${PACKAGES_tmp}) add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} - LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib LIBS ${qtd_libs}) + LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib ${QT_LIBRARY_DIR} LIBS ${qtd_libs}) ## TODO: Uncomment. #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") @@ -581,4 +581,4 @@ set(SECOND_RUN 0 CACHE INTERNAL "") -endif(NOT SECOND_RUN) \ No newline at end of file +endif(NOT SECOND_RUN) diff -r 70f64e5b5942 -r ed7018b63aa7 build/core.makefile --- a/build/core.makefile Sat Dec 19 18:43:32 2009 +0300 +++ b/build/core.makefile Sun Feb 07 15:46:06 2010 +0000 @@ -79,4 +79,5 @@ QBuffer \ QMetaType \ QLibraryInfo \ + QFileSystemWatcher \ QXmlStreamEntityResolver \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 build/core.txt --- a/build/core.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/build/core.txt Sun Feb 07 15:46:06 2010 +0000 @@ -17,7 +17,19 @@ qtd/Traits core/QString core/QMetaType - core/QMetaObject) + core/QMetaObject + + core/QTypeInfo + core/QList + qtd/Atomic + qtd/MetaMarshall + qtd/MOC + qtd/Meta + qtd/util/Tuple + qtd/ctfe/Integer + qtd/ctfe/String + qtd/ctfe/Format + ) set (d_version_files QtdObject Signal qtd/Str @@ -68,5 +80,6 @@ QBuffer QLibraryInfo QXmlStreamEntityResolver + QFileSystemWatcher ) diff -r 70f64e5b5942 -r ed7018b63aa7 build/gui.txt --- a/build/gui.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/build/gui.txt Sun Feb 07 15:46:06 2010 +0000 @@ -1,10 +1,4 @@ set(required Core) -qt4_generate_moc(cpp/qt_gui/UrlHandler_shell.h - ${CMAKE_BINARY_DIR}/cpp/qt_gui/UrlHandler_shell_moc.cpp - ) -set (cpp_files qt_gui/UrlHandler_shell ) -set (cpp_generated_files qt_gui/UrlHandler_shell_moc) -#set (d_files gui/UrlHandler) set(classes QPushButton QFileIconProvider @@ -352,4 +346,6 @@ QSizeGrip QSortFilterProxyModel QSound + + QGraphicsObject ) diff -r 70f64e5b5942 -r ed7018b63aa7 changelog.txt --- a/changelog.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/changelog.txt Sun Feb 07 15:46:06 2010 +0000 @@ -15,4 +15,5 @@ * D2 port * new CMake module for D - * support for MSVC \ No newline at end of file + * support for MSVC + * Rewritten signals and slots implementation. Now integrates nicely into Qt metasystem diff -r 70f64e5b5942 -r ed7018b63aa7 cpp/qt_core/QMetaObject_shell.cpp --- a/cpp/qt_core/QMetaObject_shell.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/cpp/qt_core/QMetaObject_shell.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -1,6 +1,9 @@ #include "qtd_core.h" #include + +#include + extern "C" DLL_PUBLIC void* qtd_QMetaObject_superClass(void *nativeId) { return (void*)((QMetaObject*)nativeId)->superClass(); @@ -10,3 +13,58 @@ { QMetaObject::activate(sender, signal_index, argv); } + +extern "C" DLL_PUBLIC void qtd_QMetaObject_activate_3(QObject *sender, const QMetaObject *m, int local_signal_index, void **argv) +{ + QMetaObject::activate(sender, m, local_signal_index, argv); +} + +extern "C" DLL_PUBLIC void qtd_QMetaObject_activate_4(QObject *sender, const QMetaObject *m, int from_local_signal_index, int to_local_signal_index, void **argv) +{ + QMetaObject::activate(sender, m, from_local_signal_index, to_local_signal_index, argv); +} + +extern "C" DLL_PUBLIC bool qtd_QMetaObject_connect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index, + int type, int *types) +{ + return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types); +} + +extern "C" DLL_PUBLIC int qtd_QMetaObject_indexOfMethod(void *nativeId, const char *method) +{ + return ((QMetaObject*)nativeId)->indexOfMethod(method); +} + +extern "C" DLL_PUBLIC int qtd_QMetaObject_methodCount(void *nativeId) +{ + return ((QMetaObject*)nativeId)->methodCount(); +} + +extern "C" DLL_PUBLIC void qtd_create_QList(void *nativeId) +{ + QList & list = (*(QList *)nativeId); + list.append(54); + list.append(45); +} + +extern "C" DLL_PUBLIC void qtd_create_QList_double(void *nativeId) +{ + QList & list = (*(QList *)nativeId); + list.append(54.44); + list.append(45.55); +} + +extern "C" DLL_PUBLIC void qtd_create_QList_QObject(void *nativeId) +{ + QList & list2 = (*(QList *)nativeId); + + QList list; + QObject* a1 = new QObject(); + a1->setObjectName("a1"); + list.append(a1); + QObject* a2 = new QObject(); + a2->setObjectName("a2"); + list.append(a2); + list2 = list; +} diff -r 70f64e5b5942 -r ed7018b63aa7 cpp/qt_core/QString_shell.cpp --- a/cpp/qt_core/QString_shell.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/cpp/qt_core/QString_shell.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -1,24 +1,67 @@ #include #include "qtd_core.h" -extern "C" DLL_PUBLIC const ushort* __qtd_QString_utf16 +extern "C" DLL_PUBLIC const ushort* qtd_QString_utf16 (void* __this_nativeId) { QString *__qt_this = (QString *) __this_nativeId; return __qt_this->utf16(); } -extern "C" DLL_PUBLIC int __qtd_QString_size +extern "C" DLL_PUBLIC int qtd_QString_size (void* __this_nativeId) { QString *__qt_this = (QString *) __this_nativeId; return __qt_this->size(); } -extern "C" DLL_PUBLIC void __qtd_QString_operatorAssign +extern "C" DLL_PUBLIC void qtd_QString_operatorAssign (void* __this_nativeId, DArray text) { QString *__qt_this = (QString *) __this_nativeId; *__qt_this = QString::fromUtf8((const char *)text.ptr, text.length); } + +extern "C" DLL_PUBLIC void qtd_QString_destructor(void *ptr) +{ + delete (QString *)ptr; +} + +extern "C" DLL_PUBLIC void qtd_QString_call_destructor(QString *ptr) +{ + ptr->~QString(); +} + + +extern "C" DLL_PUBLIC void* qtd_QString_QString_QString +(void* string0) +{ + const QString& __qt_string0 = (const QString& ) *(QString *)string0; + QString *__qt_this = new QString((const QString& )__qt_string0); + return (void *) __qt_this; +} + +extern "C" DLL_PUBLIC void* qtd_QString_new_fromUtf8_at +(void* place, DArray text) +{ + QString *__qt_this = new(place) QString; + *__qt_this = QString::fromUtf8((const char *)text.ptr, text.length); + return __qt_this; +} + +extern "C" DLL_PUBLIC void* qtd_QString_placed_copy(void* string0, void* place) { + const QString& __qt_string0 = (const QString& ) *(QString *)string0; + QString *result = new (place)QString((const QString& )__qt_string0); + return (void *) result; +} + +extern "C" DLL_PUBLIC void qtd_QString_placed_ctor(void* place) { + new (place) QString(); +} + +extern "C" DLL_PUBLIC void qtd_QString_assign_fromUtf8 +(QString *__qt_this, DArray text) +{ + *__qt_this = QString::fromUtf8((const char *)text.ptr, text.length); +} \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 cpp/qt_core/QVariant_shell.cpp --- a/cpp/qt_core/QVariant_shell.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/cpp/qt_core/QVariant_shell.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -22,6 +22,11 @@ delete (QVariant *)ptr; } +extern "C" DLL_PUBLIC void qtd_QVariant_call_destructor(QVariant *ptr) +{ + ptr->~QVariant(); +} + QVariant_QtDShell::QVariant_QtDShell() : QVariant() { @@ -961,3 +966,8 @@ +extern "C" DLL_PUBLIC void* qtd_QVariant_placed_copy(void* variant0, void* place) { + const QVariant& __qt_variant0 = (const QVariant& ) *(QVariant *)variant0; + QVariant *result = new (place)QVariant((const QVariant& )__qt_variant0); + return (void *) result; +} \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 cpp/qt_gui/UrlHandler_shell.cpp --- a/cpp/qt_gui/UrlHandler_shell.cpp Sat Dec 19 18:43:32 2009 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -#include "UrlHandler_shell.h" - -#include "qtd_core.h" - -UrlHandler::UrlHandler(void *d_ptr, QObject* parent0) - : QObject(parent0), - QtD_QObjectEntity(this, d_ptr) -{ -} - -#ifdef CPP_SHARED -extern "C" typedef void (*pfqtd_UrlHandler_handleUrl_QUrl_dispatch)(void *dId, void* arg__1); -pfqtd_UrlHandler_handleUrl_QUrl_dispatch qtd_UrlHandler_handleUrl_QUrl_dispatch; -#else -extern "C" void qtd_UrlHandler_handleUrl_QUrl_dispatch(void *dId, void* name1); -#endif -void UrlHandler::handleUrl(const QUrl &url) -{ - qtd_UrlHandler_handleUrl_QUrl_dispatch(this->dId, &(QUrl& )url); -} - -extern "C" DLL_PUBLIC void qtd_UrlHandler_destructor(void *ptr) -{ - delete (UrlHandler *)ptr; -} - -extern "C" DLL_PUBLIC void* qtd_UrlHandler_UrlHandler_QObject -(void *d_ptr, - void* parent0) -{ - QObject* __qt_parent0 = (QObject* ) parent0; - UrlHandler *__qt_this = new UrlHandler(d_ptr, (QObject* )__qt_parent0); - return (void *) __qt_this; -} - -#ifdef CPP_SHARED -extern "C" DLL_PUBLIC void qtd_UrlHandler_initCallBacks(pfunc_abstr *virts, pfunc_abstr qobj_del) { - qtd_UrlHandler_handleUrl_QUrl_dispatch = (pfqtd_UrlHandler_handleUrl_QUrl_dispatch) virts[0]; -// qtd_D_QWidget_delete = (qtd_pf_D_QWidget_delete)qobj_del; -} -#endif diff -r 70f64e5b5942 -r ed7018b63aa7 cpp/qt_gui/UrlHandler_shell.h --- a/cpp/qt_gui/UrlHandler_shell.h Sat Dec 19 18:43:32 2009 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -#include -#include - -class UrlHandler : public QObject, public QtD_QObjectEntity -{ - Q_OBJECT - -public: - UrlHandler(void *d_ptr, QObject *parent = 0); - -public slots: - void handleUrl(const QUrl &url); -}; diff -r 70f64e5b5942 -r ed7018b63aa7 demos/interview/model.d --- a/demos/interview/model.d Sat Dec 19 18:43:32 2009 +0300 +++ b/demos/interview/model.d Sun Feb 07 15:46:06 2010 +0000 @@ -59,7 +59,7 @@ Node[] children; } -size_t find(Node[] arr, Node elem) +size_t find(const Node[] arr, const Node elem) { size_t res = arr.length; for(size_t i = 0; i < arr.length; i++) @@ -89,18 +89,18 @@ } - override QModelIndex index(int row, int column, const QModelIndex parent) + override QModelIndex index(int row, int column, const QModelIndex parent) const { if (row < rc && row >= 0 && column < cc && column >= 0) { - Node p = cast(Node) parent.internalPointer(); - Node n = getNode(row, p); + auto p = cast(Node) parent.internalPointer(); + auto n = getNode(row, p); if (n !is null) return createIndex(row, column, cast(void*)n); } return QModelIndex(); } - override QModelIndex parent(const QModelIndex child) + override QModelIndex parent(const QModelIndex child) const { if (child.isValid()) { Node n = cast(Node) child.internalPointer(); @@ -111,17 +111,17 @@ return QModelIndex(); } - override int rowCount(const QModelIndex parent) + override int rowCount(const QModelIndex parent) const { return (parent.isValid() && parent.column() != 0) ? 0 : rc; } - override int columnCount(const QModelIndex parent) + override int columnCount(const QModelIndex parent) const { return cc; } - override QVariant data(const QModelIndex index, int role) + override QVariant data(const QModelIndex index, int role) const { if (!index.isValid) return new QVariant; @@ -136,7 +136,7 @@ return new QVariant; } - override QVariant headerData(int section, Qt.Orientation orientation, int role) + override QVariant headerData(int section, Qt.Orientation orientation, int role) const { if (role == Qt.DisplayRole) return new QVariant(to!string(section)); @@ -145,39 +145,39 @@ return QAbstractItemModel.headerData(section, orientation, role); } - override bool hasChildren(const QModelIndex parent) + override bool hasChildren(const QModelIndex parent) const { if (parent.isValid && parent.column != 0) return false; return rc > 0 && cc > 0; } - override int flags(const QModelIndex index) + override int flags(const QModelIndex index) const { if (!index.isValid) return 0; return (Qt.ItemIsDragEnabled | Qt.ItemIsSelectable | Qt.ItemIsEnabled); } - Node getNode(int row, Node parent) + const (Node) getNode(int row, Node parent) const { if(parent !is null && parent.children.length == 0) { for(int i = 0; i < rc; i++) parent.children ~= new Node(parent); } - Node[] v = parent !is null ? parent.children : tree; + auto v = parent !is null ? parent.children : tree; return v[row]; } - Node parent(Node child) + Node parent(Node child) const { return child !is null ? child.parent : null; } - int row(Node node) + int row(Node node) const { - Node[] v = node.parent !is null ? node.parent.children : tree; + auto v = node.parent !is null ? node.parent.children : tree; return find(v, node); } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/desktop/systray/window.d --- a/examples/desktop/systray/window.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/desktop/systray/window.d Sun Feb 07 15:46:06 2010 +0000 @@ -72,11 +72,11 @@ createActions(); createTrayIcon(); - connect!("clicked")(showMessageButton, &this.showMessage); - connect!("toggled")(showIconCheckBox, &trayIcon.setVisible); - connect!("currentIndexChanged")(iconComboBox, &this.setIcon); - connect!("messageClicked")(trayIcon, &this.messageClicked); - connect!("activated")(trayIcon, &this.iconActivated); + connect(showMessageButton, "clicked", this, "showMessage"); + connect(showIconCheckBox, "toggled", trayIcon, "setVisible"); + connect(iconComboBox, "currentIndexChanged", this, "setIcon"); + connect(trayIcon, "messageClicked", this, "messageClicked"); + connect(trayIcon, "activated", this, "iconActivated"); QVBoxLayout mainLayout = new QVBoxLayout; mainLayout.addWidget(iconGroupBox); @@ -111,9 +111,9 @@ } } -private: +private: // slots - void setIcon(int index) + void slot_setIcon(int index) { QIcon icon = iconComboBox.itemIcon(index); trayIcon.setIcon(icon); @@ -122,7 +122,7 @@ trayIcon.setToolTip(iconComboBox.itemText(index)); } - void iconActivated(QSystemTrayIcon.ActivationReason reason) + void slot_iconActivated(QSystemTrayIcon.ActivationReason reason) { switch (reason) { case QSystemTrayIcon.Trigger: @@ -136,14 +136,14 @@ } } - void showMessage() + void slot_showMessage() { QSystemTrayIcon.MessageIcon icon = cast(QSystemTrayIcon.MessageIcon) typeComboBox.itemData(typeComboBox.currentIndex()).toInt(); trayIcon.showMessage(titleEdit.text(), bodyEdit.toPlainText(), icon, durationSpinBox.value() * 1000); } - void messageClicked() + void slot_messageClicked() { QMessageBox.information(null, tr("Systray"), tr("Sorry, I already gave what help I could.\nMaybe you should try asking a human?")); @@ -233,16 +233,16 @@ void createActions() { minimizeAction = new QAction(tr("Mi&nimize"), this); - connect!("triggered")(minimizeAction, &this.hide); + connect(minimizeAction, "activated", this, "hide"); maximizeAction = new QAction(tr("Ma&ximize"), this); - connect!("triggered")(maximizeAction, &this.showMaximized); + connect(maximizeAction, "activated", this, "showMaximized"); restoreAction = new QAction(tr("&Restore"), this); - connect!("triggered")(restoreAction, &this.showNormal); + connect(restoreAction, "activated", this, "showNormal"); quitAction = new QAction(tr("&Quit"), this); - connect!("triggered")(quitAction, &QApplication.quit); + connect(quitAction, "triggered", qApp(), "quit"); } void createTrayIcon() @@ -282,4 +282,6 @@ QSystemTrayIcon trayIcon; QMenu trayIconMenu; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/dialogs/classwizard/classwizard.d --- a/examples/dialogs/classwizard/classwizard.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/dialogs/classwizard/classwizard.d Sun Feb 07 15:46:06 2010 +0000 @@ -54,7 +54,7 @@ import qt.core.QDir; import qt.core.QRegExp; -import std.string; +import std.string : format, tolower, toupper; class ClassWizard : public QWizard @@ -263,7 +263,7 @@ copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and operator=")); defaultCtorRadioButton.setChecked(true); - connect!("toggled")(defaultCtorRadioButton, ©CtorCheckBox.setEnabled); + connect(defaultCtorRadioButton, "toggled", copyCtorCheckBox, "setEnabled"); registerField("className*", classNameLineEdit); registerField("baseClass", baseClassLineEdit); @@ -331,10 +331,8 @@ baseIncludeLineEdit = new QLineEdit; baseIncludeLabel.setBuddy(baseIncludeLineEdit); - connect!("toggled")(protectCheckBox, ¯oNameLabel.setEnabled); -// ? connect!("toggled")(protectCheckBox, ¯oNameLabel.setEnabled); - connect!("toggled")(includeBaseCheckBox, ¯oNameLabel.setEnabled); -// ? connect!("toggled")(includeBaseCheckBox, ¯oNameLabel.setEnabled); + connect(protectCheckBox, "toggled", macroNameLabel, "setEnabled"); + connect(includeBaseCheckBox, "toggled", macroNameLabel, "setEnabled"); registerField("comment", commentCheckBox); registerField("protect", protectCheckBox); diff -r 70f64e5b5942 -r ed7018b63aa7 examples/dialogs/standarddialogs/dialog.d --- a/examples/dialogs/standarddialogs/dialog.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/dialogs/standarddialogs/dialog.d Sun Feb 07 15:46:06 2010 +0000 @@ -135,21 +135,21 @@ errorLabel.setFrameStyle(frameStyle); QPushButton errorButton = new QPushButton(tr("QErrorMessage.show&M&essage()")); - connect!("clicked")(integerButton, &this.setInteger); - connect!("clicked")(doubleButton, &this.setDouble); - connect!("clicked")(itemButton, &this.setItem); - connect!("clicked")(textButton, &this.setText); - connect!("clicked")(colorButton, &this.setColor); - connect!("clicked")(fontButton, &this.setFont); - connect!("clicked")(directoryButton, &this.setExistingDirectory); - connect!("clicked")(openFileNameButton, &this.setOpenFileName); - connect!("clicked")(openFileNamesButton, &this.setOpenFileNames); - connect!("clicked")(saveFileNameButton, &this.setSaveFileName); - connect!("clicked")(criticalButton, &this.criticalMessage); - connect!("clicked")(informationButton, &this.informationMessage); - connect!("clicked")(questionButton, &this.questionMessage); - connect!("clicked")(warningButton, &this.warningMessage); - connect!("clicked")(errorButton, &this.errorMessage); + connect(integerButton, "clicked", this, "setInteger"); + connect(doubleButton, "clicked", this, "setDouble"); + connect(itemButton, "clicked", this, "setItem"); + connect(textButton, "clicked", this, "setText"); + connect(colorButton, "clicked", this, "setColor"); + connect(fontButton, "clicked", this, "setFont"); + connect(directoryButton, "clicked", this, "setExistingDirectory"); + connect(openFileNameButton, "clicked", this, "setOpenFileName"); + connect(openFileNamesButton, "clicked", this, "setOpenFileNames"); + connect(saveFileNameButton, "clicked", this, "setSaveFileName"); + connect(criticalButton, "clicked", this, "criticalMessage"); + connect(informationButton, "clicked", this, "informationMessage"); + connect(questionButton, "clicked", this, "questionMessage"); + connect(warningButton, "clicked", this, "warningMessage"); + connect(errorButton, "clicked", this, "errorMessage"); native = new QCheckBox(this); native.setText("Use native file dialog."); @@ -202,9 +202,9 @@ setWindowTitle(tr("Standard Dialogs")); } -private: +private: // slots - void setInteger() + void slot_setInteger() { bool ok; int i = QInputDialog.getInt(this, tr("QInputgetInteger()"), tr("Percentage:"), 25, 0, 100, 1, ok); @@ -212,27 +212,27 @@ integerLabel.setText(format("%d", i)); } - void setDouble() + void slot_setDouble() { bool ok; double d = QInputDialog.getDouble(this, tr("QInputgetDouble()"), tr("Amount:"), 37.56, -10000, 10000, 2, ok); if (ok) - integerLabel.setText(format("%g", d)); + doubleLabel.setText(format("%g", d)); } - void setItem() + void slot_setItem() { string[] items = [tr("Spring"), tr("Summer"), tr("Fall"), tr("Winter")]; bool ok; string item = QInputDialog.getItem(this, tr("QInputgetItem()"), - tr("Season:"), items, 0, false, ok); + tr("Season:"), items.toQList, 0, false, ok); if (ok && item.length) itemLabel.setText(item); } - void setText() + void slot_setText() { bool ok; string text = QInputDialog.getText(this, tr("QInputgetText()"), @@ -242,7 +242,7 @@ textLabel.setText(text); } - void setColor() + void slot_setColor() { QColor color = QColorDialog.getColor(QColor.Green, this); if (color.isValid()) { @@ -252,7 +252,7 @@ } } - void setFont() + void slot_setFont() { bool ok; QFont font = QFontDialog.getFont(&ok, new QFont(fontLabel.text()), this); @@ -262,7 +262,7 @@ } } - void setExistingDirectory() + void slot_setExistingDirectory() { int options = QFileDialog_Option.DontResolveSymlinks | QFileDialog_Option.ShowDirsOnly; if (!native.isChecked()) @@ -275,7 +275,7 @@ directoryLabel.setText(directory); } - void setOpenFileName() + void slot_setOpenFileName() { int options; if (!native.isChecked()) @@ -291,13 +291,13 @@ openFileNameLabel.setText(fileName); } - void setOpenFileNames() + void slot_setOpenFileNames() { int options; if (!native.isChecked()) options |= QFileDialog_Option.DontUseNativeDialog; string selectedFilter; - string[] files = QFileDialog.getOpenFileNames( + auto files = QFileDialog.getOpenFileNames( this, tr("QFilegetOpenFileNames()"), openFilesPath, tr("All Files (*);;Text Files (*.txt)"), @@ -305,11 +305,11 @@ options); if (files.length) { openFilesPath = files[0]; - openFileNamesLabel.setText(join(files, "; ")); + openFileNamesLabel.setText(join(files.toArray, "; ")); } } - void setSaveFileName() + void slot_setSaveFileName() { int options; if (!native.isChecked()) @@ -325,7 +325,7 @@ saveFileNameLabel.setText(fileName); } - void criticalMessage() + void slot_criticalMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.critical(this, tr("QMessageBox.critical()"), @@ -339,7 +339,7 @@ criticalLabel.setText(tr("Ignore")); } - void informationMessage() + void slot_informationMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.information(this, tr("QMessageBox.information()"), MESSAGE); @@ -349,7 +349,7 @@ informationLabel.setText(tr("Escape")); } - void questionMessage() + void slot_questionMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.question(this, tr("QMessageBox.question()"), @@ -363,7 +363,7 @@ questionLabel.setText(tr("Cancel")); } - void warningMessage() + void slot_warningMessage() { auto msgBox = new QMessageBox(QMessageBox.Warning, tr("QMessageBox.warning()"), MESSAGE, 0, this); msgBox.addButton(tr("Save &Again"), QMessageBox.AcceptRole); @@ -374,7 +374,7 @@ warningLabel.setText(tr("Continue")); } - void errorMessage() + void slot_errorMessage() { errorMessageDialog.showMessage( tr("This dialog shows and remembers error messages. " @@ -407,4 +407,6 @@ QErrorMessage errorMessageDialog; string openFilesPath; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/draganddrop/dropsite/droparea.d --- a/examples/draganddrop/dropsite/droparea.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/draganddrop/dropsite/droparea.d Sun Feb 07 15:46:06 2010 +0000 @@ -58,7 +58,7 @@ clearArea(); } - void clearArea() + void slot_clearArea() { setText(tr("")); setBackgroundRole(QPalette.Dark); @@ -66,10 +66,9 @@ changed(null); } - mixin Signal!("changed", QMimeData); + final void signal_changed(QMimeData); protected: - void dragEnterEvent(QDragEnterEvent event) { setText(tr("")); @@ -103,7 +102,7 @@ setText(mimeData.text()); setTextFormat(Qt.PlainText); } else if (mimeData.hasUrls()) { - QUrl[] urlList = mimeData.urls(); + auto urlList = mimeData.urls(); string text; for (int i = 0; i < urlList.length && i < 32; ++i) { text ~= urlList[i].path() ~ "\n"; @@ -119,5 +118,7 @@ private: QLabel label; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/draganddrop/dropsite/dropsitewindow.d --- a/examples/draganddrop/dropsite/dropsitewindow.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/draganddrop/dropsite/dropsitewindow.d Sun Feb 07 15:46:06 2010 +0000 @@ -67,7 +67,7 @@ abstractLabel.adjustSize(); dropArea = new DropArea; - connect!("changed")(dropArea, &updateFormatsTable); + connect(dropArea, "changed", this, "updateFormatsTable"); string[] labels; labels ~= tr("Format"); @@ -76,7 +76,7 @@ formatsTable = new QTableWidget; formatsTable.setColumnCount(2); formatsTable.setEditTriggers(QAbstractItemView.NoEditTriggers); - formatsTable.setHorizontalHeaderLabels(labels); + formatsTable.setHorizontalHeaderLabels(labels.toQList()); formatsTable.horizontalHeader().setStretchLastSection(true); clearButton = new QPushButton(tr("Clear")); @@ -86,8 +86,8 @@ buttonBox.addButton(clearButton, QDialogButtonBox.ActionRole); buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole); - connect!("pressed")(quitButton, &close); - connect!("pressed")(clearButton, &dropArea.clearArea); + connect(quitButton, "pressed", this, "close"); + connect(clearButton, "pressed", dropArea, "clearArea"); QVBoxLayout mainLayout = new QVBoxLayout; mainLayout.addWidget(abstractLabel); @@ -100,7 +100,7 @@ setMinimumSize(350, 500); } - void updateFormatsTable(QMimeData mimeData) + void slot_updateFormatsTable(QMimeData mimeData) { formatsTable.setRowCount(0); if (!mimeData) @@ -117,7 +117,7 @@ } else if (format == "text/html") { text = strip(mimeData.html()); } else if (format == "text/uri-list") { - QUrl[] urlList = mimeData.urls(); + auto urlList = mimeData.urls(); for (int i = 0; i < urlList.length && i < 32; ++i) { string url = urlList[i].path(); text ~= url ~ " "; @@ -148,4 +148,6 @@ QPushButton clearButton; QPushButton quitButton; QDialogButtonBox buttonBox; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d --- a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d Sun Feb 07 15:46:06 2010 +0000 @@ -82,7 +82,7 @@ protected: - override bool filterAcceptsRow(int sourceRow, const QModelIndex sourceParent) + override bool filterAcceptsRow(int sourceRow, const QModelIndex sourceParent) const { QModelIndex index0 = sourceModel().index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel().index(sourceRow, 1, sourceParent); @@ -96,10 +96,10 @@ return (contains(sourceModel().data(index0).toString(), filterRegExp()) || contains(sourceModel().data(index1).toString(), filterRegExp())) - && dateInRange(sourceModel().data(index2).toDate()); + /* && dateInRange(sourceModel().data(index2).toDate())*/; } - override bool lessThan(const QModelIndex left, const QModelIndex right) + override bool lessThan(const QModelIndex left, const QModelIndex right) const { QVariant leftData = sourceModel().data(left); QVariant rightData = sourceModel().data(right); @@ -122,12 +122,12 @@ } private: - - bool dateInRange(QDate date) +/* + bool dateInRange(const QDate date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); } - +*/ QDate minDate; QDate maxDate; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/itemviews/customsortfiltermodel/window.d --- a/examples/itemviews/customsortfiltermodel/window.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/itemviews/customsortfiltermodel/window.d Sun Feb 07 15:46:06 2010 +0000 @@ -102,11 +102,11 @@ toLabel = new QLabel(tr("&To:")); toLabel.setBuddy(toDateEdit); - connect!("textChanged")(filterPatternLineEdit, &this.textFilterChanged); - connect!("currentIndexChanged")(filterSyntaxComboBox, &this.textFilterChanged); - connect!("toggled")(filterCaseSensitivityCheckBox, &this.textFilterChanged); - connect!("dateChanged")(fromDateEdit, &this.dateFilterChanged); - connect!("dateChanged")(toDateEdit, &this.dateFilterChanged); + connect(filterPatternLineEdit, "textChanged", this, "textFilterChanged"); + connect(filterSyntaxComboBox, "currentIndexChanged", this, "textFilterChanged"); + connect(filterCaseSensitivityCheckBox, "toggled", this, "textFilterChanged"); + connect(fromDateEdit, "dateChanged", this, "dateFilterChanged"); + connect(toDateEdit, "dateChanged", this, "dateFilterChanged"); proxyView = new QTreeView; proxyView.setRootIsDecorated(false); @@ -144,9 +144,9 @@ sourceView.setModel(model); } -private: +private: // slots - void textFilterChanged() + void slot_textFilterChanged() { QRegExp.PatternSyntax syntax = cast(QRegExp.PatternSyntax) filterSyntaxComboBox.itemData( filterSyntaxComboBox.currentIndex()).toInt(); @@ -158,11 +158,13 @@ proxyModel.setFilterRegExp(regExp); } - void dateFilterChanged() + void slot_dateFilterChanged() { proxyModel.setFilterMinimumDate(fromDateEdit.date()); proxyModel.setFilterMaximumDate(toDateEdit.date()); } + + mixin Q_OBJECT; private: diff -r 70f64e5b5942 -r ed7018b63aa7 examples/layouts/basiclayouts/dialog.d --- a/examples/layouts/basiclayouts/dialog.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/layouts/basiclayouts/dialog.d Sun Feb 07 15:46:06 2010 +0000 @@ -61,6 +61,8 @@ else import std.string; +import std.stdio; + class Dialog : public QDialog { this() @@ -75,8 +77,8 @@ buttonBox = new QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel); - connect!("accepted")(buttonBox, &this.accept); - connect!("rejected")(buttonBox, &this.reject); + connect(buttonBox, "accepted", this, "accept"); + connect(buttonBox, "rejected", this, "reject"); QVBoxLayout mainLayout = new QVBoxLayout; @@ -101,7 +103,7 @@ exitAction = fileMenu.addAction(tr("E&xit")); menuBar.addMenu(fileMenu); - connect!("triggered")(exitAction, &this.accept); + connect(exitAction, "triggered", this, "accept"); } void createHorizontalGroupBox() @@ -155,6 +157,8 @@ formGroupBox.setLayout(layout); } + mixin Q_OBJECT; + enum { NumGridRows = 3, NumButtons = 4 }; QMenuBar menuBar; diff -r 70f64e5b5942 -r ed7018b63aa7 examples/layouts/borderlayout/borderlayout.d --- a/examples/layouts/borderlayout/borderlayout.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/layouts/borderlayout/borderlayout.d Sun Feb 07 15:46:06 2010 +0000 @@ -75,40 +75,47 @@ } } - void addItem(IQLayoutItem item) - { - add(item, Position.West); - } - void addWidget(QWidget widget, Position position) { add(cast(IQLayoutItem) new QWidgetItem(widget), position); } - int expandingDirections() + void add(IQLayoutItem item, Position position) + { + list ~= new ItemWrapper(item, position); + } + +override +{ + void addItem(IQLayoutItem item) + { + add(item, Position.West); + } + + int expandingDirections() const { return Qt.Horizontal | Qt.Vertical; } - bool hasHeightForWidth() + bool hasHeightForWidth() const { return false; } - int count() + int count() const { return list.length; } - QLayoutItem itemAt(int index) + IQLayoutItem itemAt(int index) const { if(index >= 0 && index < list.length) - return list[index].item; + return cast(IQLayoutItem) list[index].item; else return null; } - QSize minimumSize() + QSize minimumSize() const { return calculateSize(SizeType.MinimumSize); } @@ -182,7 +189,7 @@ centerHeight)); } - QSize sizeHint() + QSize sizeHint() const { return calculateSize(SizeType.SizeHint); } @@ -195,11 +202,7 @@ } return null; } - - void add(IQLayoutItem item, Position position) - { - list ~= new ItemWrapper(item, position); - } +} private: @@ -217,12 +220,12 @@ enum SizeType { MinimumSize, SizeHint }; - QSize calculateSize(SizeType sizeType) + QSize calculateSize(SizeType sizeType) const { QSize totalSize; for (int i = 0; i < list.length; ++i) { - ItemWrapper wrapper = list[i]; + const ItemWrapper wrapper = list[i]; Position position = wrapper.position; QSize itemSize; diff -r 70f64e5b5942 -r ed7018b63aa7 examples/layouts/dynamiclayouts/dialog.d --- a/examples/layouts/dynamiclayouts/dialog.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/layouts/dynamiclayouts/dialog.d Sun Feb 07 15:46:06 2010 +0000 @@ -76,9 +76,9 @@ setWindowTitle(tr("Dynamic Layouts")); } -private: +private: // slots - void buttonsOrientationChanged(int index) + void slot_buttonsOrientationChanged(int index) { mainLayout.setSizeConstraint(QLayout.SetNoConstraint); setMinimumSize(0, 0); @@ -107,7 +107,7 @@ mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint); } - void rotateWidgets() + void slot_rotateWidgets() { assert(rotableWidgets.length % 2 == 0); @@ -123,7 +123,7 @@ } } - void help() + void slot_help() { QMessageBox.information(this, tr("Dynamic Layouts Help"), tr("This example shows how to change layouts dynamically.")); @@ -145,17 +145,11 @@ rotableWidgets ~= a2; rotableWidgets ~= a3; - connect!("valueChanged")(a0, &a1.setValue); - connect!("valueChanged")(a1, &a2.setValue); - connect!("valueChanged")(a2, &a3.setValue); - connect!("valueChanged")(a3, &a0.setValue); + int n = rotableWidgets.length; + for (int i = 0; i < n; ++i) + connect(rotableWidgets[i], "valueChanged", rotableWidgets[(i + 1) % n], "setValue"); - /* - int n = rotableWidgets.length; - for (int i = 0; i < n; ++i) { - rotableWidgets[i].valueChanged.connect(&rotableWidgets[(i + 1) % n].setValue); - }*/ - + rotableLayout = new QGridLayout; rotableGroupBox.setLayout(rotableLayout); @@ -172,8 +166,8 @@ buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal)); buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical)); - connect!("currentIndexChanged")(buttonsOrientationComboBox, &this.buttonsOrientationChanged); - + connect(buttonsOrientationComboBox, "currentIndexChanged", this, "buttonsOrientationChanged"); + optionsLayout = new QGridLayout; optionsLayout.addWidget(buttonsOrientationLabel, 0, 0); optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1); @@ -189,9 +183,9 @@ helpButton = buttonBox.addButton(QDialogButtonBox.Help); rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole); - connect!("clicked")(rotateWidgetsButton, &this.rotateWidgets); - connect!("clicked")(closeButton, &this.close); - connect!("clicked")(helpButton, &this.help); + connect(rotateWidgetsButton, "clicked", this, "rotateWidgets"); + connect(closeButton, "clicked", this, "close"); + connect(helpButton, "clicked", this, "help"); } QGroupBox rotableGroupBox; @@ -209,4 +203,6 @@ QGridLayout mainLayout; QGridLayout rotableLayout; QGridLayout optionsLayout; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/mainwindows/dockwidgets/mainwindow.d --- a/examples/mainwindows/dockwidgets/mainwindow.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/mainwindows/dockwidgets/mainwindow.d Sun Feb 07 15:46:06 2010 +0000 @@ -82,7 +82,7 @@ } private : //slots: - void newLetter() + void slot_newLetter() { textEdit.clear(); @@ -128,7 +128,7 @@ cursor.insertText("ADDRESS", italicFormat); } /* - void save() + void slot_save() { char[] fileName = QFileDialog.getSaveFileName(this, tr("Choose a file name"), ".", @@ -150,14 +150,14 @@ statusBar.showMessage(layout("Saved '%1'", fileName), 2000); }*/ - void print() { } + void slot_print() { } - void undo() { + void slot_undo() { auto document = textEdit.document(); document.undo(); } - void insertCustomer(string customer) + void slot_insertCustomer(string customer) { if (customer == "") return; @@ -182,7 +182,7 @@ } } - void addParagraph(string paragraph) + void slot_addParagraph(string paragraph) { if (paragraph == "") return; @@ -199,7 +199,7 @@ } - void about() + void slot_about() { QMessageBox.about(this, "About Dock Widgets", "The Dock Widgets example demonstrates how to " @@ -214,7 +214,7 @@ newLetterAct = new QAction(new QIcon(":images/new.png"), tr("&New Letter"), this); newLetterAct.setShortcut(tr("Ctrl+N")); newLetterAct.setStatusTip(tr("Create a new form letter")); - connect!("triggered")(newLetterAct, &this.newLetter); + connect(newLetterAct, "triggered", this, "newLetter"); saveAct = new QAction(new QIcon(":images/save.png"), tr("&Save..."), this); saveAct.setShortcut(tr("Ctrl+S")); @@ -229,20 +229,20 @@ undoAct = new QAction(new QIcon(":images/undo.png"), tr("&Undo"), this); undoAct.setShortcut(tr("Ctrl+Z")); undoAct.setStatusTip(tr("Undo the last editing action")); - connect!("triggered")(undoAct, &undo); + connect(undoAct, "triggered", this, "undo"); quitAct = new QAction(tr("&Quit"), this); quitAct.setShortcut(tr("Ctrl+Q")); quitAct.setStatusTip(tr("Quit the application")); - connect!("triggered")(quitAct, &this.close); + connect(quitAct, "triggered", this, "close"); aboutAct = new QAction(tr("&About"), this); aboutAct.setStatusTip(tr("Show the application's About box")); - connect!("triggered")(aboutAct, &about); + connect(aboutAct, "triggered", this, "about"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); - // aboutQtAct.triggered(&aboutQt); + connect(aboutQtAct, "triggered", qApp, "aboutQt"); } void createMenus() @@ -327,8 +327,8 @@ addDockWidget(Qt.RightDockWidgetArea, dock); viewMenu.addAction(dock.toggleViewAction()); - connect!("currentTextChanged")(customerList, &this.insertCustomer); - connect!("currentTextChanged")(paragraphsList, &this.addParagraph); + connect(customerList, "currentTextChanged", this, "insertCustomer"); + connect(paragraphsList, "currentTextChanged", this, "addParagraph"); } QTextEdit textEdit; @@ -348,7 +348,6 @@ QAction aboutAct; QAction aboutQtAct; QAction quitAct; + + mixin Q_OBJECT; } - - -//! [9] diff -r 70f64e5b5942 -r ed7018b63aa7 examples/mainwindows/sdi/mainwindow.d --- a/examples/mainwindows/sdi/mainwindow.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/mainwindows/sdi/mainwindow.d Sun Feb 07 15:46:06 2010 +0000 @@ -98,14 +98,14 @@ private: // slots - void newFile() + void slot_newFile() { MainWindow other = new MainWindow; other.move(x() + 40, y() + 40); other.show(); } - void open() + void slot_open() { scope fileName = QFileDialog.getOpenFileName(this); if (fileName) { @@ -131,7 +131,7 @@ } } - bool save() + bool slot_save() { if (isUntitled) { return saveAs(); @@ -140,7 +140,7 @@ } } - bool saveAs() + bool slot_saveAs() { string fileName = QFileDialog.getSaveFileName(this, tr("Save As"), curFile); @@ -150,14 +150,14 @@ return saveFile(fileName); } - void about() + void slot_about() { QMessageBox.about(this, tr("About SDI"), tr("The SDI example demonstrates how to write single " ~ "document interface applications using Qt.")); } - void documentWasModified() + void slot_documentWasModified() { setWindowModified(true); } @@ -180,7 +180,7 @@ readSettings(); - connect!("contentsChanged")(textEdit.document(), &this.documentWasModified); + connect(textEdit.document(), "contentsChanged", this, "documentWasModified"); setUnifiedTitleAndToolBarOnMac(true); } @@ -190,64 +190,64 @@ newAct = new QAction(new QIcon(":/images/new.png"), tr("&New"), this); newAct.setShortcuts(QKeySequence.New); newAct.setStatusTip(tr("Create a new file")); - connect!("triggered")(newAct, &this.newFile); + connect(newAct, "triggered", this, "newFile"); openAct = new QAction(new QIcon(":/images/open.png"), tr("&Open..."), this); openAct.setShortcuts(QKeySequence.Open); openAct.setStatusTip(tr("Open an existing file")); - connect!("triggered")(openAct, &this.open); + connect(openAct, "triggered", this, "open"); saveAct = new QAction(new QIcon(":/images/save.png"), tr("&Save"), this); saveAct.setShortcuts(QKeySequence.Save); saveAct.setStatusTip(tr("Save the document to disk")); - connect!("triggered")(saveAct, &this.save); + connect(saveAct, "triggered", this, "save"); saveAsAct = new QAction(tr("Save &As..."), this); saveAsAct.setShortcuts(QKeySequence.SaveAs); saveAsAct.setStatusTip(tr("Save the document under a new name")); - connect!("triggered")(saveAsAct, &this.saveAs); + connect(saveAsAct, "triggered", this, "saveAs"); closeAct = new QAction(tr("&Close"), this); closeAct.setShortcut(tr("Ctrl+W")); closeAct.setStatusTip(tr("Close this window")); - connect!("triggered")(closeAct, &this.close); + connect(closeAct, "triggered", this, "close"); exitAct = new QAction(tr("E&xit"), this); exitAct.setShortcut(tr("Ctrl+Q")); exitAct.setStatusTip(tr("Exit the application")); - connect!("triggered")(exitAct, &QApplication.closeAllWindows); + connect(exitAct, "triggered", qApp(), "closeAllWindows"); cutAct = new QAction(new QIcon(":/images/cut.png"), tr("Cu&t"), this); cutAct.setShortcuts(QKeySequence.Cut); cutAct.setStatusTip(tr("Cut the current selection's contents to the " ~ "clipboard")); - connect!("triggered")(cutAct, &textEdit.cut); + connect(cutAct, "triggered", textEdit, "cut"); copyAct = new QAction(new QIcon(":/images/copy.png"), tr("&Copy"), this); copyAct.setShortcuts(QKeySequence.Copy); copyAct.setStatusTip(tr("Copy the current selection's contents to the " ~ "clipboard")); - connect!("triggered")(copyAct, &textEdit.copy); + connect(copyAct, "triggered", textEdit, "copy"); pasteAct = new QAction(new QIcon(":/images/paste.png"), tr("&Paste"), this); pasteAct.setShortcuts(QKeySequence.Paste); pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " ~ "selection")); - connect!("triggered")(pasteAct, &textEdit.paste); + connect(pasteAct, "triggered", textEdit, "paste"); aboutAct = new QAction(tr("&About"), this); aboutAct.setStatusTip(tr("Show the application's About box")); - connect!("triggered")(aboutAct, &this.about); + connect(aboutAct, "triggered", this, "about"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); - connect!("triggered")(aboutQtAct, &QApplication.aboutQt); + connect(aboutQtAct, "triggered", qApp, "aboutQt"); cutAct.setEnabled(false); copyAct.setEnabled(false); - connect!("copyAvailable")(textEdit, &cutAct.setEnabled); - connect!("copyAvailable")(textEdit, ©Act.setEnabled); + connect(textEdit, "copyAvailable", cutAct, "setEnabled"); + connect(textEdit, "copyAvailable", copyAct, "setEnabled"); } void createMenus() @@ -426,4 +426,6 @@ QAction pasteAct; QAction aboutAct; QAction aboutQtAct; + + mixin Q_OBJECT; }; diff -r 70f64e5b5942 -r ed7018b63aa7 examples/opengl/hellogl/CMakeLists.txt --- a/examples/opengl/hellogl/CMakeLists.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/opengl/hellogl/CMakeLists.txt Sun Feb 07 15:46:06 2010 +0000 @@ -1,2 +1,1 @@ -build_example(hellogl PACKAGES QtCore QtGui QtOpenGL - SOURCES main.d) \ No newline at end of file +build_example(hellogl main.d PACKAGES QtCore QtGui QtOpenGL) \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 examples/opengl/hellogl/glwidget.d --- a/examples/opengl/hellogl/glwidget.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/opengl/hellogl/glwidget.d Sun Feb 07 15:46:06 2010 +0000 @@ -69,19 +69,19 @@ glDeleteLists(object, 1); } - QSize minimumSizeHint() + QSize minimumSizeHint() const { return QSize(50, 50); } - QSize sizeHint() + QSize sizeHint() const { return QSize(400, 400); } public: // slots: - void setXRotation(int angle) + void slot_setXRotation(int angle) { normalizeAngle(&angle); if (angle != xRot) { @@ -91,7 +91,7 @@ } } - void setYRotation(int angle) + void slot_setYRotation(int angle) { normalizeAngle(&angle); if (angle != yRot) { @@ -101,7 +101,7 @@ } } - void setZRotation(int angle) + void slot_setZRotation(int angle) { normalizeAngle(&angle); if (angle != zRot) { @@ -110,11 +110,13 @@ updateGL(); } } - - mixin Signal!("xRotationChanged", int); - mixin Signal!("yRotationChanged", int); - mixin Signal!("zRotationChanged", int); - + + final // signals + { + void signal_xRotationChanged(int); + void signal_yRotationChanged(int); + void signal_zRotationChanged(int); + } protected: void initializeGL() @@ -264,4 +266,6 @@ QPoint lastPos; QColor trolltechGreen; QColor trolltechPurple; + + mixin Q_OBJECT; } \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 examples/opengl/hellogl/window.d --- a/examples/opengl/hellogl/window.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/opengl/hellogl/window.d Sun Feb 07 15:46:06 2010 +0000 @@ -39,58 +39,55 @@ import qt.gui.QSlider; import qt.gui.QHBoxLayout; -version(D_Version2) - import glwidget; -else - import glwidget_d1; +import glwidget; class Window : public QWidget { -// Q_OBJECT - - public: - this() - { - glWidget = new GLWidget; - - xSlider = createSlider(); - ySlider = createSlider(); - zSlider = createSlider(); - - connect!("valueChanged")(xSlider, &glWidget.setXRotation); - connect!("xRotationChanged")(glWidget, &xSlider.setValue); - connect!("valueChanged")(ySlider, &glWidget.setYRotation); - connect!("yRotationChanged")(glWidget, &ySlider.setValue); - connect!("valueChanged")(zSlider,&glWidget.setZRotation); - connect!("zRotationChanged")(glWidget, &zSlider.setValue); - - QHBoxLayout mainLayout = new QHBoxLayout; - mainLayout.addWidget(glWidget); - mainLayout.addWidget(xSlider); - mainLayout.addWidget(ySlider); - mainLayout.addWidget(zSlider); - setLayout(mainLayout); - - xSlider.setValue(15 * 16); - ySlider.setValue(345 * 16); - zSlider.setValue(0 * 16); - setWindowTitle(tr("Hello GL")); - } - - private: - QSlider createSlider() - { - auto slider = new QSlider(Qt.Vertical); - slider.setRange(0, 360 * 16); - slider.setSingleStep(16); - slider.setPageStep(15 * 16); - slider.setTickInterval(15 * 16); - slider.setTickPosition(QSlider.TicksRight); - return slider; - } - - GLWidget glWidget; - QSlider xSlider; - QSlider ySlider; - QSlider zSlider; + public: + this() + { + glWidget = new GLWidget; + + xSlider = createSlider(); + ySlider = createSlider(); + zSlider = createSlider(); + + connect(xSlider, "valueChanged", glWidget, "setXRotation"); + connect(glWidget, "xRotationChanged", xSlider, "setValue"); + connect(ySlider, "valueChanged", glWidget, "setYRotation"); + connect(glWidget, "yRotationChanged", ySlider, "setValue"); + connect(zSlider, "valueChanged", glWidget, "setZRotation"); + connect(glWidget, "zRotationChanged", zSlider, "setValue"); + + QHBoxLayout mainLayout = new QHBoxLayout; + mainLayout.addWidget(glWidget); + mainLayout.addWidget(xSlider); + mainLayout.addWidget(ySlider); + mainLayout.addWidget(zSlider); + setLayout(mainLayout); + + xSlider.setValue(15 * 16); + ySlider.setValue(345 * 16); + zSlider.setValue(0 * 16); + setWindowTitle(tr("Hello GL")); + } + + private: + QSlider createSlider() + { + auto slider = new QSlider(Qt.Vertical); + slider.setRange(0, 360 * 16); + slider.setSingleStep(16); + slider.setPageStep(15 * 16); + slider.setTickInterval(15 * 16); + slider.setTickPosition(QSlider.TicksRight); + return slider; + } + + GLWidget glWidget; + QSlider xSlider; + QSlider ySlider; + QSlider zSlider; + + mixin Q_OBJECT; } \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 examples/tutorials/tutorial/t2/main.d --- a/examples/tutorials/tutorial/t2/main.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/tutorials/tutorial/t2/main.d Sun Feb 07 15:46:06 2010 +0000 @@ -47,7 +47,7 @@ quit.resize(75, 30); quit.setFont(new QFont("Times", 18, QFont.Bold)); - QObject.connect!("clicked")(quit, &QApplication.quit); + QObject.connect(quit, "clicked", app, "quit"); quit.show(); return app.exec(); diff -r 70f64e5b5942 -r ed7018b63aa7 examples/tutorials/tutorial/t3/main.d --- a/examples/tutorials/tutorial/t3/main.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/tutorials/tutorial/t3/main.d Sun Feb 07 15:46:06 2010 +0000 @@ -51,7 +51,7 @@ quit.setFont(new QFont("Times", 18, QFont.Light)); quit.setGeometry(10, 40, 180, 40); - QObject.connect!("clicked")(quit, &QApplication.quit); + QObject.connect(quit, "clicked", app, "quit"); window.show(); return app.exec(); diff -r 70f64e5b5942 -r ed7018b63aa7 examples/tutorials/tutorial/t4/main.d --- a/examples/tutorials/tutorial/t4/main.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/tutorials/tutorial/t4/main.d Sun Feb 07 15:46:06 2010 +0000 @@ -51,7 +51,7 @@ auto quit = new QPushButton("Quit", this); quit.setGeometry(62, 40, 75, 30); quit.setFont(new QFont("Times", 18, QFont.Bold)); - connect!("clicked")(quit, &QApplication.quit); + connect(quit, "clicked", qApp(), "quit"); } } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/tutorials/tutorial/t5/main.d --- a/examples/tutorials/tutorial/t5/main.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/tutorials/tutorial/t5/main.d Sun Feb 07 15:46:06 2010 +0000 @@ -60,8 +60,8 @@ slider.setRange(0, 99); slider.setValue(0); - connect!("clicked")(quit, &QApplication.quit); - connect!("valueChanged")(slider, cast(void delegate(int)) &lcd.display); + connect(quit, "clicked", qApp(), "quit"); + connect(slider, "valueChanged", lcd, "display"); auto layout = new QVBoxLayout; layout.addWidget(quit); diff -r 70f64e5b5942 -r ed7018b63aa7 examples/tutorials/tutorial/t6/main.d --- a/examples/tutorials/tutorial/t6/main.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/tutorials/tutorial/t6/main.d Sun Feb 07 15:46:06 2010 +0000 @@ -58,7 +58,7 @@ auto slider = new QSlider(Qt.Horizontal); slider.setRange(0, 99); slider.setValue(0); - connect!("valueChanged")(slider, cast(void delegate(int)) &lcd.display); + connect(slider, "valueChanged", lcd, "display"); auto layout = new QVBoxLayout; layout.addWidget(lcd); @@ -76,7 +76,7 @@ auto quit = new QPushButton("Quit"); quit.setFont(new QFont("Times", 18, QFont.Bold)); - connect!("clicked")(quit, &QApplication.quit); + connect(quit, "clicked", qApp(), "quit"); auto grid = new QGridLayout; for (int row = 0; row < 3; ++row) { diff -r 70f64e5b5942 -r ed7018b63aa7 examples/widgets/analogclock/AnalogClock.d --- a/examples/widgets/analogclock/AnalogClock.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/widgets/analogclock/AnalogClock.d Sun Feb 07 15:46:06 2010 +0000 @@ -55,7 +55,7 @@ { super(parent); auto timer = new QTimer(this); - connect!("timeout")(timer, &this.update); + connect(timer, "timeout", this, "update"); timer.start(1000); setWindowTitle("Analog Clock"); resize(200, 200); @@ -119,4 +119,6 @@ painter.rotate(6.0); } } + + mixin Q_OBJECT; } \ No newline at end of file diff -r 70f64e5b5942 -r ed7018b63aa7 examples/widgets/calculator/button.d --- a/examples/widgets/calculator/button.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/widgets/calculator/button.d Sun Feb 07 15:46:06 2010 +0000 @@ -57,11 +57,13 @@ setText(text); } - QSize sizeHint() + QSize sizeHint() const { QSize size = super.sizeHint(); size.height = size.height + 20; size.width= qMax(size.width(), size.height()); return size; } + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 examples/widgets/calculator/calculator.d --- a/examples/widgets/calculator/calculator.d Sat Dec 19 18:43:32 2009 +0300 +++ b/examples/widgets/calculator/calculator.d Sun Feb 07 15:46:06 2010 +0000 @@ -75,30 +75,30 @@ display.setFont(font); for (int i = 0; i < NumDigitButtons; ++i) { - digitButtons[i] = createButton(format("%d", i), &digitClicked); + digitButtons[i] = createButton(format("%d", i), "digitClicked"); } - Button pointButton = createButton(tr("."), &pointClicked); - Button changeSignButton = createButton(tr("+/-"), &changeSignClicked); + Button pointButton = createButton(tr("."), "pointClicked"); + Button changeSignButton = createButton(tr("+/-"), "changeSignClicked"); - Button backspaceButton = createButton(tr("Backspace"), &backspaceClicked); - Button clearButton = createButton(tr("Clear"), &clear); - Button clearAllButton = createButton(tr("Clear All"), &clearAll); + Button backspaceButton = createButton(tr("Backspace"), "backspaceClicked"); + Button clearButton = createButton(tr("Clear"), "clear"); + Button clearAllButton = createButton(tr("Clear All"), "clearAll"); - Button clearMemoryButton = createButton(tr("MC"), &clearMemory); - Button readMemoryButton = createButton(tr("MR"), &readMemory); - Button setMemoryButton = createButton(tr("MS"), &setMemory); - Button addToMemoryButton = createButton(tr("M+"), &addToMemory); + Button clearMemoryButton = createButton(tr("MC"), "clearMemory"); + Button readMemoryButton = createButton(tr("MR"), "readMemory"); + Button setMemoryButton = createButton(tr("MS"), "setMemory"); + Button addToMemoryButton = createButton(tr("M+"), "addToMemory"); - Button divisionButton = createButton(tr("/"), &multiplicativeOperatorClicked); - Button timesButton = createButton(tr("*"), &multiplicativeOperatorClicked); - Button minusButton = createButton(tr("-"), &additiveOperatorClicked); - Button plusButton = createButton(tr("+"), &additiveOperatorClicked); + Button divisionButton = createButton(tr("/"), "multiplicativeOperatorClicked"); + Button timesButton = createButton(tr("*"), "multiplicativeOperatorClicked"); + Button minusButton = createButton(tr("-"), "additiveOperatorClicked"); + Button plusButton = createButton(tr("+"), "additiveOperatorClicked"); - Button squareRootButton = createButton(tr("Sqrt"), &unaryOperatorClicked); - Button powerButton = createButton(tr("x^2"), &unaryOperatorClicked); - Button reciprocalButton = createButton(tr("1/x"), &unaryOperatorClicked); - Button equalButton = createButton(tr("="), &equalClicked); + Button squareRootButton = createButton(tr("Sqrt"), "unaryOperatorClicked"); + Button powerButton = createButton(tr("x^2"), "unaryOperatorClicked"); + Button reciprocalButton = createButton(tr("1/x"), "unaryOperatorClicked"); + Button equalButton = createButton(tr("="), "equalClicked"); QGridLayout mainLayout = new QGridLayout(); @@ -139,9 +139,9 @@ } //private slots: - void digitClicked() + void slot_digitClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); int digitValue = to!int(clickedButton.text); if (display.text() == "0" && digitValue == 0.0) return; @@ -153,9 +153,9 @@ display.setText(display.text() ~ format("%g", digitValue)); } - void unaryOperatorClicked() + void slot_unaryOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); double result = 0.0; @@ -179,9 +179,9 @@ waitingForOperand = true; } - void additiveOperatorClicked() + void slot_additiveOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); @@ -210,9 +210,9 @@ waitingForOperand = true; } - void multiplicativeOperatorClicked() + void slot_multiplicativeOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); @@ -230,7 +230,7 @@ waitingForOperand = true; } - void equalClicked() + void slot_equalClicked() { double operand = to!float(display.text); @@ -258,7 +258,7 @@ waitingForOperand = true; } - void pointClicked() + void slot_pointClicked() { string text = display.text; @@ -271,7 +271,7 @@ waitingForOperand = false; } - void changeSignClicked() + void slot_changeSignClicked() { string text = display.text(); double value = to!float(text); @@ -284,7 +284,7 @@ display.setText(text); } - void backspaceClicked() + void slot_backspaceClicked() { if (waitingForOperand) return; @@ -299,7 +299,7 @@ } - void clear() + void slot_clear() { if (waitingForOperand) return; @@ -308,7 +308,7 @@ waitingForOperand = true; } - void clearAll() + void slot_clearAll() { sumSoFar = 0.0; factorSoFar = 0.0; @@ -318,24 +318,24 @@ waitingForOperand = true; } - void clearMemory() + void slot_clearMemory() { sumInMemory = 0.0; } - void readMemory() + void slot_readMemory() { display.setText(format("%g", sumInMemory)); waitingForOperand = true; } - void setMemory() + void slot_setMemory() { equalClicked(); sumInMemory = to!float(display.text); } - void addToMemory() + void slot_addToMemory() { equalClicked(); sumInMemory += to!float(display.text); @@ -343,10 +343,10 @@ private: - Button createButton(string text, void delegate() member) + Button createButton(string text, string member) { Button button = new Button(text); - connect!("clicked")(button, member); + connect(button, "clicked", this, member); return button; } @@ -383,4 +383,6 @@ enum { NumDigitButtons = 10 }; Button[NumDigitButtons] digitButtons; + + mixin Q_OBJECT; } diff -r 70f64e5b5942 -r ed7018b63aa7 generator/CMakeLists.txt --- a/generator/CMakeLists.txt Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/CMakeLists.txt Sun Feb 07 15:46:06 2010 +0000 @@ -139,21 +139,6 @@ generator.qrc ) -#win32-msvc2005:{ -# QMAKE_CXXFLAGS += -wd4996 -# QMAKE_CFLAGS += -wd4996 -#} - -#if(MSVC) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm500 /Zc:wchar_t-") -#endif(MSVC) - -#win32-msvc.net { -# QMAKE_CXXFLAGS += /Zm500 -# QMAKE_CXXFLAGS -= -Zm200 -# QMAKE_CFLAGS -= -Zm200 -#} - ## Includes path. set(inc_paths ${CMAKE_CURRENT_SOURCE_DIR}/../common diff -r 70f64e5b5942 -r ed7018b63aa7 generator/abstractmetalang.cpp --- a/generator/abstractmetalang.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/abstractmetalang.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -42,6 +42,7 @@ #include "abstractmetalang.h" #include "reporthandler.h" #include "jumptable.h" +#include /******************************************************************************* * AbstractMetaType @@ -225,6 +226,10 @@ returned += arg->type()->name().replace("[]", "_3").replace(".", "_"); } } + + if(this->isConstant()) + returned += "_const"; + return returned; } @@ -253,6 +258,11 @@ result |= EqualAttributes; } + // Constness + if (isConstant() == other->isConstant()) { + result |= EqualConstness; + } + // Compare types AbstractMetaType *t = type(); AbstractMetaType *ot = other->type(); @@ -668,15 +678,15 @@ return QString(); } -QString AbstractMetaFunction::minimalSignature() const +QString AbstractMetaFunction::minimalSignature(int reduce) const { - if (!m_cached_minimal_signature.isEmpty()) + if (!m_cached_minimal_signature.isEmpty() && !reduce) return m_cached_minimal_signature; QString minimalSignature = originalName() + "("; AbstractMetaArgumentList arguments = this->arguments(); - - for (int i=0; itype(); if (i > 0) @@ -689,7 +699,8 @@ minimalSignature += "const"; minimalSignature = QMetaObject::normalizedSignature(minimalSignature.toLocal8Bit().constData()); - m_cached_minimal_signature = minimalSignature; + if(!reduce) + m_cached_minimal_signature = minimalSignature; return minimalSignature; } @@ -1192,7 +1203,19 @@ return 0; } +AbstractMetaFunction* AbstractMetaClass::copyConstructor() const +{ + AbstractMetaFunctionList ctors = queryFunctions(Constructors); + for(int i = 0; i < ctors.size(); i++) + { + AbstractMetaFunction *ctor = ctors.at(i); + if (ctor->arguments().size() > 0) + if(ctor->arguments().at(0)->type()->typeEntry() == typeEntry()) + return ctor; + } + return NULL; +} static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func) { @@ -1891,10 +1914,13 @@ if (isConstant()) minimalSignature += "const "; minimalSignature += typeEntry()->qualifiedCppName(); - if (hasInstantiations()) { + if (hasInstantiations() && + (static_cast(typeEntry()))->type() != ContainerTypeEntry::StringListContainer) + { QList instantiations = this->instantiations(); minimalSignature += "<"; - for (int i=0;i 0) minimalSignature += ","; minimalSignature += instantiations.at(i)->minimalSignature(); diff -r 70f64e5b5942 -r ed7018b63aa7 generator/abstractmetalang.h --- a/generator/abstractmetalang.h Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/abstractmetalang.h Sun Feb 07 15:46:06 2010 +0000 @@ -406,10 +406,11 @@ EqualReturnType = 0x00000010, EqualDefaultValueOverload = 0x00000020, EqualModifiedName = 0x00000040, + EqualConstness = 0x00000080, NameLessThan = 0x00001000, - PrettySimilar = EqualName | EqualArguments, + PrettySimilar = EqualName | EqualArguments | EqualConstness, Equal = 0x0000001f, NotEqual = 0x00001000 }; @@ -440,7 +441,7 @@ QString modifiedName() const; - QString minimalSignature() const; + QString minimalSignature(int reduce = 0) const; QStringList possibleIntrospectionCompatibleSignatures() const; QString marshalledName(bool classIsOwner = true) const; @@ -713,6 +714,7 @@ bool hasSignal(const AbstractMetaFunction *f) const; bool hasConstructors() const; + AbstractMetaFunction *copyConstructor() const; void addDefaultConstructor(); @@ -845,6 +847,7 @@ bool isTypeAlias() const { return m_is_type_alias; } const QStringList &depends() { return m_type_entry->depends(); } + AbstractMetaFunctionList allFunctions() const { return m_functions; } bool needsConversionFunc; private: @@ -969,4 +972,12 @@ | NotRemovedFromTargetLang); } +inline bool isNativeContainer(AbstractMetaType *argumentType) +{ + if (argumentType && argumentType->isContainer()) + if (((const ContainerTypeEntry *)argumentType->typeEntry())->isQList()) + return true; + return false; +} + #endif // ABSTRACTMETALANG_H diff -r 70f64e5b5942 -r ed7018b63aa7 generator/cppheadergenerator.cpp --- a/generator/cppheadergenerator.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/cppheadergenerator.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -197,6 +197,9 @@ // << " void *qt_metacast(const char *);" << endl // << " QT_TR_FUNCTIONS" << end << " virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl + << " int __override_qt_metacall(QMetaObject::Call _c, int _id, void **_a);" << endl + << " virtual const QMetaObject *metaObject() const;" << endl + << "private:" << endl; } diff -r 70f64e5b5942 -r ed7018b63aa7 generator/cppimplgenerator.cpp --- a/generator/cppimplgenerator.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/cppimplgenerator.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -505,13 +505,11 @@ "(pf" << function->marshalledName() << "_dispatch) virts[" << pos << "];" << endl; } } - // D-side signal callbacks - AbstractMetaFunctionList signal_funcs = signalFunctions(java_class); - for(int i = 0; i < signal_funcs.size(); i++) - s << " emit_callbacks_" << java_class->name() << "[" << i << "] = (EmitCallback)" - "sigs[" << i << "];" << endl; - + if (java_class->isQObject()) { + s << " qtd_" << java_class->name() << "_qt_metacall_dispatch = (QtMetacallCallback)sigs[0];" << endl + << " qtd_" << java_class->name() << "_metaObject_dispatch = (MetaObjectCallback)sigs[1];" << endl; + } s << "}" << endl; } @@ -592,9 +590,10 @@ if (!java_class->isQObject()) writeFinalDestructor(s, java_class); - if (java_class->isQObject()) + if (java_class->isQObject()) { + writeQObjectEntity(s, java_class); writeSignalsHandling(s, java_class); - + } if (shellClass) { foreach (AbstractMetaFunction *function, java_class->functions()) { if (function->isConstructor() && !function->isPrivate()) @@ -709,6 +708,9 @@ */ // qtd writeJavaLangObjectOverrideFunctions(s, java_class); + if (java_class->typeEntry()->isValue()) + writeValueFunctions(s, java_class); + if (java_class->isQObject()) { s << endl << endl @@ -717,11 +719,42 @@ << "}" << endl; } + if (java_class->typeEntry()->isValue()) + { + if (!java_class->typeEntry()->hasPrivateCopyConstructor()) // can do a copy if we have a public ctor or don't have any + { + QString argName = "orig"; + s << endl << endl + << "extern \"C\" DLL_PUBLIC void qtd_" << java_class->name() << "_placed_copy(void* " + << argName << ", void* place) {" << endl + << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl + << QString(" %1 *result = new (place) %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl; +// writeFinalConstructor(s, ctor, "result", "original", "(place)"); + s << "}"; + + s << endl << endl + << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_native_copy(void* " << argName << ") {" << endl + << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl + << QString(" %1 *result = new %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl + << " return result;" << endl; + s << "}"; + } + } + s << endl << endl; priGenerator->addSource(java_class->package(), fileNameForClass(java_class)); } +void CppImplGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class) +{ + s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isComplex() { return (bool) QTypeInfo<%2>::isComplex; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); + s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isStatic() { return (bool) QTypeInfo<%2>::isStatic; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); + s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isLarge() { return (bool) QTypeInfo<%2>::isLarge; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); + s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isPointer() { return (bool) QTypeInfo<%2>::isPointer; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); + s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isDummy() { return (bool) QTypeInfo<%2>::isDummy; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); +} + void CppImplGenerator::writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, bool d_export) { uint options2 = ReturnType | ExternC; @@ -782,27 +815,35 @@ s << INDENT << f_type->typeEntry()->qualifiedCppName() << " __d_return_value;" << endl; if (f_type->isContainer()) - s << INDENT << "void* __d_return_value;" << endl - << INDENT << "size_t __d_return_value_size;" << endl; + { + if (isNativeContainer(f_type)) + { + s << INDENT; + writeTypeInfo(s, f_type, ForceValueType); + s << "__d_return_value;" << endl; + } + else + s << INDENT << "void* __d_return_value;" << endl + << INDENT << "size_t __d_return_value_size;" << endl; + } } AbstractMetaArgumentList arguments = function->arguments(); foreach (AbstractMetaArgument *argument, arguments) { if (!function->argumentRemoved(argument->argumentIndex()+1)) { - if (!argument->type()->isPrimitive() + AbstractMetaType *atype = argument->type(); + if (!atype->isPrimitive() || !function->conversionRule(TypeSystem::NativeCode, argument->argumentIndex()+1).isEmpty()) { - if(argument->type()->isContainer()) { + if(atype->isContainer()) { QString arg_name = argument->indexedName(); - s << INDENT << QString("DArray %1_arr;").arg(arg_name) << endl - << INDENT << QString("DArray *__d_%1 = &%1_arr;").arg(arg_name); - - writeQtToJava(s, - argument->type(), - arg_name, - "__d_" + arg_name, - function, - argument->argumentIndex() + 1, - Option(VirtualDispatch)); + if(!isNativeContainer(atype)) + writeQtToJava(s, + argument->type(), + arg_name, + "__d_" + arg_name, + function, + argument->argumentIndex() + 1, + Option(VirtualDispatch)); } } } @@ -838,9 +879,13 @@ if (f_type->isTargetLangString()) s << ", &ret_str"; if (f_type->name() == "QModelIndex" || f_type->typeEntry()->isStructInD()) - s << ", &__d_return_value"; - if (f_type->isContainer()) - s << ", &__d_return_value, &__d_return_value_size"; + s << ", &__d_return_value"; // TODO should both be refactored into isNativeType function + if (f_type->isContainer()) { + if ( ((const ContainerTypeEntry *)f_type->typeEntry())->isQList() ) + s << ", &__d_return_value"; + else + s << ", &__d_return_value, &__d_return_value_size"; + } } if (function->arguments().size() > 0) @@ -862,9 +907,14 @@ s << INDENT << "return __d_return_value;" << endl; if (f_type->isContainer()) { - writeJavaToQt(s, f_type, "__qt_return_value", "__d_return_value", - function, 0, GlobalRefJObject); - s << INDENT << "return __qt_return_value;" << endl; + if (isNativeContainer(f_type)) + s << INDENT << "return __d_return_value;" << endl; + else + { + writeJavaToQt(s, f_type, "__qt_return_value", "__d_return_value", + function, 0, GlobalRefJObject); + s << INDENT << "return __qt_return_value;" << endl; + } } if (f_type->isTargetLangString()) @@ -898,8 +948,16 @@ else if(ret_type->typeEntry()->isStructInD()) s << ", " << ret_type->typeEntry()->qualifiedCppName() << " *__d_return_value"; - if (ret_type->isContainer()) - s << ", void** __d_arr_ptr, size_t* __d_arr_size"; + if (ret_type->isContainer()) { + if(isNativeContainer(ret_type)) { + if(d_export) + s << ", " << DGenerator::translateType(ret_type, d_function->ownerClass(), NoOption) << "* __d_arr"; + else + s << ", void * __d_arr"; + } + else + s << ", void** __d_arr_ptr, size_t* __d_arr_size"; + } } if (d_function->arguments().size() > 0) @@ -919,9 +977,11 @@ if (d_type->name() == "QModelIndex") s << "QModelIndexAccessor" << QString(d_type->actualIndirections(), '*') << " " << arg_name; else if (d_type->isContainer()) { - if (d_export) { + if ( isNativeContainer(d_type) ) + s << "void* "; + else if (d_export) s << DGenerator::translateType(d_type, d_function->ownerClass(), NoOption) << "* "; - } else + else s << "DArray* "; s << arg_name; } else if (d_type->typeEntry()->isStructInD()) @@ -1217,22 +1277,21 @@ << "{" << endl << "public:" << endl << " Q_OBJECT_CHECK" << endl - << " virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl << endl + << "// virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl << endl << " " << entityName << "(QObject *qObject, void *dId) : QObject(), QtD_QObjectEntity(qObject, dId) {}" << endl << "};" << endl << endl; - // QObject_Link::qt_metacall() +/* // QObject_Link::qt_metacall() s << "int " << entityName << "::qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl << "{" << endl << " _id = QObject::qt_metacall(_c, _id, _a);" << endl << " if (_id < 0 || _c != QMetaObject::InvokeMetaMethod)" << endl << " return _id;" << endl -// << " Q_ASSERT(_id < 2);" << endl << " emit_callbacks_" << java_class->name() << "[_id](dId, _a);" << endl << " return -1;" << endl << "}" << endl << endl; - +*/ s << "extern \"C\" DLL_PUBLIC void qtd_" << className << "_createEntity(void *nativeId, void* dId)" << endl << "{" << endl << " new " << entityName << "((QObject*)nativeId, dId);" << endl @@ -1282,16 +1341,44 @@ << " return " << java_class->qualifiedCppName() << "::qt_metacast(_clname);" << endl << "}" << endl << endl; */ - +/* s << "int " << shellClassName(java_class) << "::qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl - << "{" << endl; - - s << " _id = " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" << endl + << "{" << endl + << " _id = " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" << endl << " if (_id < 0 || _c != QMetaObject::InvokeMetaMethod)" << endl << " return _id;" << endl << " emit_callbacks_" << java_class->name() << "[_id](this->dId, _a);" << endl << " return -1;" << endl << "}" << endl << endl; + */ + + if(cpp_shared) + s << "MetaObjectCallback qtd_" << java_class->name() << "_metaObject_dispatch;" << endl + << "QtMetacallCallback qtd_" << java_class->name() << "_qt_metacall_dispatch;" << endl; + else + s << "extern \"C\" const QMetaObject* qtd_" << java_class->name() << "_metaObject_dispatch(void *d_entity);" << endl + << "extern \"C\" int qtd_" << java_class->name() << "_qt_metacall_dispatch(void *d_entity, QMetaObject::Call _c, int _id, void **_a);" << endl; + + s << endl + << "const QMetaObject * " << shellClassName(java_class) << "::metaObject() const" << endl + << "{" << endl + << " return qtd_" << java_class->name() << "_metaObject_dispatch(this->dId);" << endl + << "}" << endl << endl + << "int " << shellClassName(java_class) << "::qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl + << "{" << endl + << " return qtd_" << java_class->name() << "_qt_metacall_dispatch(this->dId, _c, _id, _a);" << endl + << "}" << endl << endl + + << "int " << shellClassName(java_class) << "::__override_qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl + << "{" << endl + << " return " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" + << "}" << endl << endl + + << "extern \"C\" DLL_PUBLIC int qtd_" << java_class->name() << "_qt_metacall(void* __this_nativeId, QMetaObject::Call _c, int _id, void **_a)" + << "{" << endl + << " " << shellClassName(java_class) << " *__qt_this = (" << shellClassName(java_class) << " *) __this_nativeId;" << endl + << " return __qt_this->__override_qt_metacall(_c, _id, _a);" << endl + << "}" << endl << endl; } void CppImplGenerator::writeSignalEmitter(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunction *function) @@ -1341,6 +1428,8 @@ void CppImplGenerator::writeSignalsHandling(QTextStream &s, const AbstractMetaClass *java_class) { + return; // #TODO probably don't need this function at all + s << "extern \"C\" typedef void (*EmitCallback)(void*, void**);" << endl; AbstractMetaFunctionList signal_funcs = signalFunctions(java_class); @@ -1369,8 +1458,6 @@ } s << endl << "};" << endl << endl; } - - writeQObjectEntity(s, java_class); } @@ -1934,8 +2021,10 @@ } else if (d_type->isContainer()) { const ContainerTypeEntry *cte = static_cast(te); - if(isLinearContainer(cte)) - s << QString("void *%1, size_t %1_size").arg(arg_name); + if(cte->isQList()) + s << "void* " << arg_name; + else if(isLinearContainer(cte)) + s << "DArray* " << arg_name; } else { if (!d_type->hasNativeId()) { if(d_type->isVariant()) { @@ -2298,19 +2387,22 @@ { if (cls->hasConstructors()) { s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_destructor(void *ptr)" << endl - << INDENT << "{" << endl; - { - s << INDENT << "delete (" << shellClassName(cls) << " *)ptr;" << endl; - } - - s << INDENT << "}" << endl << endl; + << INDENT << "{" << endl + << INDENT << " delete (" << shellClassName(cls) << " *)ptr;" << endl + << INDENT << "}" << endl << endl; + + s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_call_destructor(" << shellClassName(cls) << " *ptr)" << endl + << INDENT << "{" << endl + << INDENT << " call_destructor(ptr);" << endl + << INDENT << "}" << endl << endl; } } void CppImplGenerator::writeFinalConstructor(QTextStream &s, const AbstractMetaFunction *java_function, const QString &qt_object_name, - const QString &java_object_name) + const QString &java_object_name, + const QString &place) { const AbstractMetaClass *cls = java_function->ownerClass(); AbstractMetaArgumentList arguments = java_function->arguments(); @@ -2319,7 +2411,7 @@ bool hasShellClass = cls->generateShellClass(); s << INDENT << shellClassName(cls) << " *" << qt_object_name - << " = new " << shellClassName(cls) + << " = new " << place << shellClassName(cls) << "("; writeFunctionCallArguments(s, java_function, "__qt_"); s << ");" << endl; @@ -3139,9 +3231,7 @@ const ContainerTypeEntry *type = static_cast(java_type->typeEntry()); - if (type->type() == ContainerTypeEntry::ListContainer - || type->type() == ContainerTypeEntry::VectorContainer - || type->type() == ContainerTypeEntry::StringListContainer + if (type->type() == ContainerTypeEntry::VectorContainer || type->type() == ContainerTypeEntry::LinkedListContainer || type->type() == ContainerTypeEntry::StackContainer || type->type() == ContainerTypeEntry::SetContainer @@ -3154,7 +3244,6 @@ cls_name.remove("_ConcreteWrapper"); s << endl -// << INDENT << "{" << endl // qtd2 hack, additional scope for avoiding duplicating of "i" << INDENT; switch (type->type()) { @@ -3202,7 +3291,14 @@ s << INDENT << "++" << index << ";" << endl; } s << INDENT << "}" << endl; -// << INDENT << "}" << endl; + + } else if (type->isQList()) { +// QList & list2 = (*(QList *)nativeId); + writeTypeInfo(s, java_type, ForceValueType); + s << "&" << java_name << "_tmp = (*("; + writeTypeInfo(s, java_type, ForceValueType); + s << "*)" << java_name << ");" << endl + << INDENT << java_name << "_tmp = " << qt_name << ";" << endl; } else if (type->type() == ContainerTypeEntry::PairContainer) { QList args = java_type->instantiations(); @@ -3329,9 +3425,7 @@ const ContainerTypeEntry *type = static_cast(java_type->typeEntry()); - if (type->type() == ContainerTypeEntry::ListContainer - || type->type() == ContainerTypeEntry::VectorContainer - || type->type() == ContainerTypeEntry::StringListContainer + if (type->type() == ContainerTypeEntry::VectorContainer || type->type() == ContainerTypeEntry::LinkedListContainer || type->type() == ContainerTypeEntry::StackContainer || type->type() == ContainerTypeEntry::SetContainer @@ -3345,23 +3439,17 @@ writeTypeInfo(s, java_type, ForceValueType); s << qt_name << ";" << endl; -// qtd s << INDENT << "if (" << java_name << " != 0) {" << endl; { -/* qtd Indentation indent(INDENT); - s << INDENT << "jobjectArray __qt__array = qtjambi_collection_toArray(__jni_env, " - << java_name << ");" << endl - << INDENT << "jsize __qt__size = __jni_env->GetArrayLength(__qt__array);" << endl; -*/ if (type->type() == ContainerTypeEntry::VectorContainer || type->type() == ContainerTypeEntry::StackContainer) - s << INDENT << qt_name << ".reserve(" << java_name << "_size);" << endl; - - s << INDENT << "for (int i=0; i<" << java_name << "_size; ++i) {" << endl; + s << INDENT << qt_name << ".reserve(" << java_name << "->length);" << endl; + + s << INDENT << "for (int i=0; i<" << java_name << "->length; ++i) {" << endl; { Indentation indent(INDENT); if(targ->isTargetLangString()) s << INDENT << "DArray __d_element;" << endl - << INDENT << "qtd_get_string_from_array(" << java_name << ", i, &__d_element);" << endl; + << INDENT << "qtd_get_string_from_array(" << java_name << "->ptr, i, &__d_element);" << endl; else { s << INDENT; writeTypeInfo(s, targ, Option(VirtualDispatch | ForcePointer | EnumAsInts)); @@ -3372,8 +3460,6 @@ s << "__d_element;" << endl << INDENT << "qtd_get_" << elem_type << "_from_array(" << java_name << ", i, &__d_element);" << endl; } -/* qtd s << INDENT << "jobject __d_element = " - << "__jni_env->GetObjectArrayElement(__qt__array, i);" << endl;*/ writeJavaToQt(s, targ, "__qt_element", "__d_element", 0, -1, BoxedPrimitive); QString cont_element = "__qt_element"; if(targ->typeEntry()->isStructInD() && targ->name() != "QModelIndex") @@ -3383,6 +3469,11 @@ // qtd s << INDENT << "}" << endl; } s << INDENT << "}" << endl; + } else if (type->isQList()) { + writeTypeInfo(s, java_type, ForceValueType); + s << qt_name << " = (*("; + writeTypeInfo(s, java_type, ForceValueType); + s << "*)" << java_name << ");" << endl; } else if (type->type() == ContainerTypeEntry::PairContainer) { QList targs = java_type->instantiations(); Q_ASSERT(targs.size() == 2); @@ -3548,7 +3639,10 @@ if ( (options & VirtualDispatch) && a_type->isContainer()) { - s << "__d_" << argument->indexedName(); + if ( ((const ContainerTypeEntry *)a_type->typeEntry())->isQList() ) + s << "(void*)&" << argument->indexedName(); + else + s << "__d_" << argument->indexedName(); continue; } @@ -3722,3 +3816,4 @@ s << endl << endl; } } + diff -r 70f64e5b5942 -r ed7018b63aa7 generator/cppimplgenerator.h --- a/generator/cppimplgenerator.h Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/cppimplgenerator.h Sun Feb 07 15:46:06 2010 +0000 @@ -109,7 +109,8 @@ void writeFinalConstructor(QTextStream &s, const AbstractMetaFunction *java_function, const QString &qt_object_name, - const QString &java_object_name); + const QString &java_object_name, + const QString &place = ""); void writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *java_class); void writeFunctionCall(QTextStream &s, const QString &variable_name, @@ -215,6 +216,7 @@ static void writeInitCallbacks(QTextStream &s, const AbstractMetaClass *java_class); static void writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class); void writeRefArguments(QTextStream &s, const AbstractMetaFunction *java_function); + void writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class); private: void writeDefaultConstructedValues_helper(QSet &values, diff -r 70f64e5b5942 -r ed7018b63aa7 generator/dgenerator.cpp --- a/generator/dgenerator.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/dgenerator.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -63,14 +63,14 @@ m_recursive(0), m_isRecursive(false) { - excludedTypes << "long long" << "bool" << "int" << "QString" << "char" << "WId" + excludedTypes << "qint64" << "bool" << "int" << "QString" << "char" << "WId" << "unsigned char" << "uint" << "double" << "short" << "float" << "signed char" << "unsigned short" << "QBool" << "unsigned int" << "Qt::HANDLE" << "QChar" << "java.lang.JObjectWrapper" << "void" << "QLatin1String" << "unsigned long long" << "signed int" << "signed short" << "Array" << "GLuint" << "GLenum" << "GLint" << "unsigned long" << "ulong" << "long" << "QByteRef" - << "QStringList" << "QList" << "QVector" << "QPair" + << "QStringList" << "QVector" << "QPair" << "QSet" << "QStringRef" << "quintptr"; } @@ -126,7 +126,7 @@ QString constPrefix, constPostfix; if (d_type && d_type->isConstant() && dVersion == 2) { constPrefix = "const("; - constPostfix = ") "; + constPostfix = ")"; } if (!d_type) { @@ -176,9 +176,14 @@ if ((option & SkipTemplateParameters) == 0) { QList args = d_type->instantiations(); - - if (args.size() == 1) // QVector or QList - s = translateType(args.at(0), context, BoxedPrimitive) + "[]"; + const ContainerTypeEntry *cte = + static_cast(d_type->typeEntry()); + if (args.size() == 1) { // QVector or QList + if(cte->isQList()) + s = "QList!(" + translateType(args.at(0), context, BoxedPrimitive) + ")"; + else + s = translateType(args.at(0), context, BoxedPrimitive) + "[]"; + } else if(args.size() == 2) { // all sorts of maps s = translateType(args.at(1), context, BoxedPrimitive); // value bool isMultiMap = static_cast(d_type->typeEntry())->type() == ContainerTypeEntry::MultiMapContainer; @@ -230,7 +235,7 @@ QString arg; AbstractMetaType *type = d_argument->type(); - // if argument is "QString &" ref attribute needed + // qtd2 if argument is "QString &" ref attribute needed FIXME maybe we need this not only for QString, but for other Value types?? if (type->typeEntry()->isValue() && type->isNativePointer() && type->typeEntry()->name() == "QString") arg = "ref "; @@ -589,7 +594,10 @@ if (!d_function->argumentRemoved(i+1)) { TypeSystem::Ownership owner = d_function->ownership(d_function->implementingClass(), TypeSystem::TargetLangCode, i+1); if (owner != TypeSystem::InvalidOwnership) { - s << INDENT << "if (" << arg->argumentName() << " !is null) {" << endl; + QString empty_condition = " !is null"; + if (arg->type()->isContainer()) + empty_condition = ".length != 0"; + s << INDENT << "if (" << arg->argumentName() << empty_condition << ") {" << endl; { Indentation indent(INDENT); if (arg->type()->isContainer()) @@ -645,7 +653,7 @@ i == 0 ? -1 : i); foreach (ReferenceCount refCount, referenceCounts) - writeReferenceCount(s, refCount, i == 0 ? "this" : arguments.at(i-1)->argumentName()); + writeReferenceCount(s, refCount, i == 0 ? "this" : arguments.at(i-1)->argumentName(), arguments.at(i-1)->type()); } referenceCounts = d_function->referenceCounts(d_function->implementingClass(), 0); @@ -679,7 +687,14 @@ s << INDENT << return_type->name() << " res;" << endl; if(return_type->isContainer()) - s << INDENT << this->translateType(d_function->type(), d_function->ownerClass(), NoOption) << " res;" << endl; + { + const ContainerTypeEntry *type = + static_cast(return_type->typeEntry()); + if(type->isQList()) // QList is a native type now + s << INDENT << "auto res = " << this->translateType(d_function->type(), d_function->ownerClass(), NoOption) << ".opCall();" << endl; + else + s << INDENT << this->translateType(d_function->type(), d_function->ownerClass(), NoOption) << " res;" << endl; + } } // returning string or a struct @@ -812,7 +827,7 @@ const ContainerTypeEntry *cte = static_cast(te); if(isLinearContainer(cte)) - s << QString("%1.ptr, %1.length").arg(arg_name); + s << QString("&%1").arg(arg_name); } else if (type->typeEntry()->qualifiedCppName() == "QChar") { s << arg_name; } else if (type->isTargetLangString() || (te && te->qualifiedCppName() == "QString")) { @@ -882,7 +897,7 @@ // return value marschalling if(return_type) { - if (!returnImmediately && !d_function->storeResult()) { + if (!returnImmediately) { s << INDENT; QString modified_type = d_function->typeReplaced(0); if (modified_type.isEmpty()) @@ -908,12 +923,7 @@ s << "new " << return_type->name() << "(ret, QtdObjectFlags.nativeOwnership);" << endl; if (return_type->isObject()) { - if(d_function->storeResult()) - s << INDENT << QString("__m_%1.__nativeId = ret;").arg(d_function->name()) << endl - << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl; - else - s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl; - s << endl; + s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl << endl; } if (return_type->isArray()) { @@ -921,10 +931,10 @@ } foreach (ReferenceCount referenceCount, referenceCounts) { - writeReferenceCount(s, referenceCount, "__d_return_value"); + writeReferenceCount(s, referenceCount, "__d_return_value", return_type); } - if (!returnImmediately && !d_function->storeResult()) + if (!returnImmediately) s << INDENT << "return __d_return_value;" << endl; } writeInjectedCode(s, d_function, CodeSnip::End); @@ -983,14 +993,14 @@ if (!(d_function->isEmptyFunction() || d_function->isNormal() || d_function->isSignal())) option = Option(option | SkipReturnType); writeFunctionAttributes(s, d_function, included_attributes, excluded_attributes, option); -/* - if(d_function->isSignal()) - functionName += "_emit"; -*/ + s << functionName << "("; writeFunctionArguments(s, d_function, argument_count, option); s << ")"; + if(d_function->isConstant()) + s << " const"; + return result; } @@ -1011,7 +1021,7 @@ } void DGenerator::writeReferenceCount(QTextStream &s, const ReferenceCount &refCount, - const QString &argumentName) + const QString &argumentName, AbstractMetaType *argumentType) { if (refCount.action == ReferenceCount::Ignore) return; @@ -1021,9 +1031,13 @@ s << INDENT << "auto __rcTmp = " << refCountVariableName << ";" << endl; refCountVariableName = "__rcTmp"; } + QString empty_condition = " !is null"; + if (argumentType && argumentType->isContainer()) +// if (((const ContainerTypeEntry *)argumentType->typeEntry())->isQList()) + empty_condition = ".length != 0"; if (refCount.action != ReferenceCount::Set) { - s << INDENT << "if (" << argumentName << " !is null"; + s << INDENT << "if (" << argumentName << empty_condition; if (!refCount.conditional.isEmpty()) s << " && " << refCount.conditional; @@ -1037,12 +1051,15 @@ { Indentation indent(INDENT); + QString summand = argumentName; switch (refCount.action) { case ReferenceCount::Add: s << INDENT << refCountVariableName << " ~= cast(Object) " << argumentName << ";" << endl; break; case ReferenceCount::AddAll: - s << INDENT << refCountVariableName << " ~= " << argumentName << ";" << endl; + if(isNativeContainer(argumentType)) + summand = argumentName + ".toArray()"; + s << INDENT << refCountVariableName << " ~= " << summand << ";" << endl; break; case ReferenceCount::Remove: s << INDENT << "remove(" << refCountVariableName @@ -1697,6 +1714,20 @@ } s << INDENT << "}" << endl << endl; } + + if (d_class->typeEntry()->isValue()) + { + s << INDENT << "public static void __deleteNativeObject(void* ptr) {" << endl + << INDENT << " qtd_" << d_class->name() << "_destructor(ptr);" << endl + << INDENT << "}" << endl << endl; + } + + if (d_class->typeEntry()->isValue()) + { + s << INDENT << "public static void __callNativeDestructor(void* ptr) {" << endl + << INDENT << " qtd_" << d_class->name() << "_call_destructor(ptr);" << endl + << INDENT << "}" << endl << endl; + } } void DGenerator::writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class) @@ -1713,12 +1744,12 @@ QString attr; +// return; // #TODO Don't need handlers for now. Restore in conversion functions later + s << "// signal handlers" << endl; foreach(AbstractMetaFunction *signal, signal_funcs) { QString sigExternName = signalExternName(d_class, signal); - s << "private " << attr << "extern(C) void " << sigExternName << "_connect(void* native_id);" << endl; - s << "private " << attr << "extern(C) void " << sigExternName << "_disconnect(void* native_id);" << endl; /* QString extra_args; @@ -1733,7 +1764,7 @@ */ AbstractMetaArgumentList arguments = signal->arguments(); - s << "private extern(C) void " << sigExternName << "_handle(void* d_entity, void** args) {" << endl; + s << "/*private extern(C) void " << sigExternName << "_handle(void* d_entity, void** args) {" << endl; { Indentation indent(INDENT); s << INDENT << "auto d_object = cast(" << d_class->name() << ") d_entity;" << endl; @@ -1752,7 +1783,7 @@ << INDENT << cppContainerConversionName(d_class, type, FromCpp) << "(" << arg_ptr << ", &" << arg_name << ");" << endl; } else if (type->isTargetLangString()) { s << INDENT << "auto " << arg_name << "_ptr = " << arg_ptr << ";" << endl - << INDENT << "string " << arg_name << " = QString.toNativeString(" << arg_name << "_ptr);"; + << INDENT << "string " << arg_name << " = QStringUtil.toNativeString(" << arg_name << "_ptr);"; } else if(type->isPrimitive() || type->isEnum() || type->isFlags() || type->typeEntry()->isStructInD()) { QString type_name = argument->type()->typeEntry()->qualifiedTargetLangName(); if (type->isFlags()) @@ -1771,7 +1802,7 @@ s << endl; } // s << INDENT << "Stdout(\"" << d_class->name() << "\", \"" << signal->name() << "\").newline;" << endl; - s << INDENT << "d_object." << signal->name() << "_emit("; + s << INDENT << "//d_object." << signal->name() << "_emit("; for (int j = 0; jindexedName(); @@ -1782,10 +1813,33 @@ s << ");" << endl; } - s << "}" << endl; + s << "}*/" << endl; } } +AbstractMetaFunctionList DGenerator::generatedClassFunctions(const AbstractMetaClass *d_class) +{ + AbstractMetaFunctionList r; + AbstractMetaFunctionList d_funcs = d_class->functionsInTargetLang(); + for (int i=0; iisInterface()) { + uint includedAttributes = 0; + uint excludedAttributes = 0; + retrieveModifications(function, d_class, &excludedAttributes, &includedAttributes); + if (includedAttributes & AbstractMetaAttributes::Private) + continue; + } + + if (!notWrappedYet(function)) // qtd2 + r += function; + } + return r; +} + void DGenerator::write(QTextStream &s, const AbstractMetaClass *d_class) { ReportHandler::debugSparse("Generating class: " + d_class->fullName()); @@ -1798,12 +1852,12 @@ auxFile.isDone = true; auxFile.stream << "module " << auxModName << ";" << endl << endl; - bool staticInit = d_class->isQObject() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface()); + bool staticInit = d_class->isQObject() || d_class->typeEntry()->isValue() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface()); if (staticInit) { auxFile.isDone = false; auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl; - auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl; + auxFile.stream << "shared static this() { static_init_" << d_class->name() << "; }" << endl << endl; } if (m_docs_enabled) { @@ -1906,9 +1960,11 @@ << "public import qt.core.Qt;" << endl << "private import qt.QtdObject;" << endl << "private import qt.core.QString;" << endl - << "private import qt.qtd.Array;" << endl; + << "private import qt.qtd.Array;" << endl + << "private import qt.core.QList;" << endl; if (d_class->isQObject()) { s << "public import qt.Signal;" << endl + << "public import qt.qtd.MOC;" << endl << "public import qt.core.QMetaObject;" << endl << "public import qt.qtd.Traits;" << endl; @@ -1937,7 +1993,7 @@ if (dPhobos) { s << "import std.stdio;" << endl - << "import std.string;" << endl + << "import std.string : toStringz;" << endl << "import std.utf;" << endl << "import core.memory;" << endl; } @@ -2144,11 +2200,11 @@ } */ - // Enums aliaases + // Enums aliases foreach (AbstractMetaEnum *d_enum, d_class->enums()) writeEnumAlias(s, d_enum); - // Signals + // Signals if (d_class->isQObject()) { AbstractMetaFunctionList signal_funcs = signalFunctions(d_class, false); @@ -2181,22 +2237,13 @@ // Functions AbstractMetaFunctionList d_funcs = d_class->functionsInTargetLang(); - for (int i=0; iisInterface()) { - uint includedAttributes = 0; - uint excludedAttributes = 0; - retrieveModifications(function, d_class, &excludedAttributes, &includedAttributes); - if (includedAttributes & AbstractMetaAttributes::Private) - continue; - } - - if (!notWrappedYet(function)) // qtd2 - writeFunction(s, function); -// s << function->minimalSignature() << endl; + AbstractMetaFunctionList d_funcs_gen = generatedClassFunctions(d_class); + for (int i=0; iisSlot()) +// writeSlot(s, function); + writeFunction(s, function); +// qtd s << function->minimalSignature() << endl; } if(d_class->isInterface()) s << endl << INDENT << "public void* __ptr_" << d_class->name() << "();" << endl << endl; @@ -2210,39 +2257,47 @@ writeFieldAccessors(s, field); } -/* qtd - - // the static fromNativePointer function... - if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { - s << endl - << INDENT << "public static native " << d_class->name() << " fromNativePointer(" - << "QNativePointer nativePointer);" << endl; - } - - if (d_class->isQObject()) { - s << endl; - if (TypeDatabase::instance()->includeEclipseWarnings()) - s << INDENT << "@SuppressWarnings(\"unused\")" << endl; - - s << INDENT << "private static native long originalMetaObject();" << endl; - } - - // The __qt_signalInitialization() function - if (signal_funcs.size() > 0) { - s << endl - << INDENT << "@Override" << endl - << INDENT << "@QtBlockedSlot protected boolean __qt_signalInitialization(String name) {" << endl - << INDENT << " return (__qt_signalInitialization(nativeId(), name)" << endl - << INDENT << " || super.__qt_signalInitialization(name));" << endl - << INDENT << "}" << endl - << endl - << INDENT << "@QtBlockedSlot" << endl - << INDENT << "private native boolean __qt_signalInitialization(long ptr, String name);" << endl; - } -*/ if (d_class->isQObject()) writeQObjectFunctions(s, d_class); + if (ctype->isObject() && !ctype->isQObject()) // conversion function wrapper to be consistent with QObject + { // some code duplication, remove when there is a better mechanism for Object type conversions + QString class_name = ctype->name(); + QString return_type_name = class_name; + if(ctype->designatedInterface()) + return_type_name = ctype->designatedInterface()->name(); + s << " static " << return_type_name << " __getObject(void* nativeId) {" << endl + << " return qtd_" << class_name << "_from_ptr(nativeId);" << endl + << " }" << endl << endl; + } + + // flag to mark the type of class (to use in templates to convert arguments) + if (d_class->baseClassName().isEmpty()) + { + if (d_class->typeEntry()->isQObject()) + s << INDENT << "public alias void __isQObjectType;" << endl << endl; + else if (d_class->typeEntry()->isObject()) + s << INDENT << "public alias void __isObjectType;" << endl << endl; + else if (d_class->typeEntry()->isValue()) + s << INDENT << "public alias void __isValueType;" << endl << endl; + } + + s << INDENT << "public alias void __isQtType_" << d_class->name() << ";" << endl << endl; + + // construction of a native copy of a Value + if (d_class->typeEntry()->isValue()) + { + AbstractMetaFunction *copy_ctor = d_class->copyConstructor(); + if (!d_class->typeEntry()->hasPrivateCopyConstructor()) // can do a copy if we have a public ctor or don't have any + s << INDENT << "static void* __constructNativeCopy(const void* orig) {" << endl + << INDENT << " return qtd_" << d_class->name() << "_native_copy(orig);" << endl + << INDENT << "}" << endl << endl + + << INDENT << "static void __constructPlacedNativeCopy(const void* orig, void* place) {" << endl + << INDENT << " qtd_" << d_class->name() << "_placed_copy(orig, place);" << endl + << INDENT << "}" << endl << endl; + } + // Add dummy constructor for use when constructing subclasses if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { s << endl @@ -2273,31 +2328,6 @@ } */ - // customized store-result instances - d_funcs = d_class->functionsInTargetLang(); - for (int i=0; iattributes() & (~excluded_attributes) | included_attributes; - bool isStatic = (attr & AbstractMetaAttributes::Static); - - if (!isStatic && (attr & AbstractMetaAttributes::Abstract)) - continue; - - if(d_function->storeResult()) { - QString type_name = d_function->type()->name(); - const ComplexTypeEntry *ctype = static_cast(d_function->type()->typeEntry()); - if(ctype->isAbstract()) - type_name = type_name + "_ConcreteWrapper"; - - s << INDENT << " __m_" << d_function->name() << " = new " - << type_name << "(cast(void*)null);" << endl; - if (d_function->type()->isQObject()) - s << INDENT << " __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl; - } - } // pointers to native interface objects for classes that implement interfaces // initializing @@ -2314,29 +2344,6 @@ s << INDENT << "}" << endl << endl; -/******************!!!DUPLICATE OF ABOVE!!!*********************/ - for (int i=0; iattributes() & (~excluded_attributes) | included_attributes; - bool isStatic = (attr & AbstractMetaAttributes::Static); - - if (!isStatic && (attr & AbstractMetaAttributes::Abstract)) - continue; - - if(d_function->storeResult()) { - QString type_name = d_function->type()->name(); - const ComplexTypeEntry *ctype = static_cast(d_function->type()->typeEntry()); - if(ctype->isAbstract()) - type_name = type_name + "_ConcreteWrapper"; - - s << INDENT << type_name << " __m_" << d_function->name() << ";" << endl; - } - } -/***************************************************************/ - // pointers to native interface objects for classes that implement interfaces // initializing interfaces = d_class->interfaces(); @@ -2352,6 +2359,8 @@ writeDestructor(s, d_class); } + if (d_class->typeEntry()->isValue()) + writeValueFunctions(s, d_class); /* qtd // Add a function that converts an array of the value type to a QNativePointer if (d_class->typeEntry()->isValue() && !fakeClass) { @@ -2387,7 +2396,7 @@ writeCloneFunction(s, d_class); } */ - s << "}" << endl; + s << "}" << endl; // end of class scope /* ---------------- injected free code ----------------*/ const ComplexTypeEntry *class_type = d_class->typeEntry(); @@ -2423,54 +2432,8 @@ s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl << INDENT << " super(native_id, flags);" << endl << endl; - /******************!!!DUPLICATE!!!*********************/ - d_funcs = d_class->functionsInTargetLang(); - for (int i=0; iattributes() & (~excluded_attributes) | included_attributes; -// qtd bool isStatic = (attr & AbstractMetaAttributes::Static); - - if(d_function->storeResult()) { - QString type_name = d_function->type()->name(); - const ComplexTypeEntry *ctype = static_cast(d_function->type()->typeEntry()); - if(ctype->isAbstract()) - type_name = type_name + "_ConcreteWrapper"; - s << INDENT << " __m_" << d_function->name() << " = new " - << type_name << "(cast(void*)null);" << endl; - if (d_function->type()->isQObject()) - s << INDENT << " __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl; - } - } - s << INDENT << "}" << endl << endl; - for (int i=0; iattributes() & (~excluded_attributes) | included_attributes; -// qtd bool isStatic = (attr & AbstractMetaAttributes::Static); - - if(d_function->storeResult()) { - QString type_name = d_function->type()->name(); - const ComplexTypeEntry *ctype = static_cast(d_function->type()->typeEntry()); - if(ctype->isAbstract()) - type_name = type_name + "_ConcreteWrapper"; - - s << INDENT << d_function->type()->name() << " __m_" << d_function->name() << ";" << endl; - } - } - /***************************************************************/ - - - - - - uint exclude_attributes = AbstractMetaAttributes::Native | AbstractMetaAttributes::Abstract; uint include_attributes = 0; AbstractMetaFunctionList functions = d_class->queryFunctions(AbstractMetaClass::NormalFunctions | AbstractMetaClass::AbstractFunctions | AbstractMetaClass::NonEmptyFunctions | AbstractMetaClass::NotRemovedFromTargetLang); @@ -2478,14 +2441,19 @@ retrieveModifications(d_function, d_class, &exclude_attributes, &include_attributes); if (notWrappedYet(d_function)) continue; - /* qtd s << endl - << INDENT << "@Override" << endl; */ + s << endl + << INDENT << "override "; writeFunctionAttributes(s, d_function, include_attributes, exclude_attributes, d_function->isNormal() || d_function->isSignal() ? 0 : SkipReturnType); s << d_function->name() << "("; writeFunctionArguments(s, d_function, d_function->arguments().count()); - s << ") {" << endl; + s << ")"; + + if(d_function->isConstant()) + s << " const"; + + s << " {" << endl; { Indentation indent(INDENT); writeJavaCallThroughContents(s, d_function, SuperCall); @@ -2502,12 +2470,22 @@ s << endl << "extern (C) void *__" << d_class->name() << "_entity(void *q_ptr);" << endl << endl; } + if (d_class->typeEntry()->isValue()) + { + AbstractMetaFunction *copy_ctor = d_class->copyConstructor(); + if (!d_class->typeEntry()->hasPrivateCopyConstructor()) // can do a copy if we have a public ctor or don't have any + { + s << "private extern(C) void qtd_" << d_class->name() << "_placed_copy(const void* orig, void* place);" << endl + << "private extern(C) void* qtd_" << d_class->name() << "_native_copy(const void* orig);" << endl; + } + } // if (d_class->needsConversionFunc) writeConversionFunction(s, d_class); if (d_class->hasConstructors() && !d_class->isQObject()) - s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl << endl; + s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl + << "extern (C) void qtd_" << d_class->name() << "_call_destructor(void *ptr);" << endl << endl; // qtd @@ -2577,6 +2555,9 @@ s << "extern(C) void static_init_" << d_class->name() << "() {" << endl; + if (d_class->typeEntry()->isValue()) + s << INDENT << d_class->name() << ".QTypeInfo.init();" << endl; + if (d_class->isQObject()) { s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl << INDENT << " " << d_class->name() << ".createStaticMetaObject;" << endl << endl; @@ -2596,18 +2577,11 @@ initArgs = "virt_arr.ptr"; if (d_class->isQObject()) { - - // signals - AbstractMetaFunctionList signal_funcs = signalFunctions(d_class); - s << endl << INDENT << "void*[" << signal_funcs.size() << "] sign_arr;" << endl; - for(int i = 0; i < signal_funcs.size(); i++) { - AbstractMetaFunction *signal = signal_funcs.at(i); - s << INDENT << "sign_arr[" << i << "] = &" << signalExternName(d_class, signal) << "_handle;" << endl; - } - if(signal_funcs.size() == 0) - initArgs += ", null"; - else - initArgs += ", sign_arr.ptr"; + // qt_metacall, metaObject + s << endl << INDENT << "void*[2] sign_arr;" << endl; + s << INDENT << "sign_arr[0] = &qtd_" << d_class->name() << "_qt_metacall_dispatch;" << endl; + s << INDENT << "sign_arr[1] = &qtd_" << d_class->name() << "_metaObject_dispatch;" << endl; + initArgs += ", sign_arr.ptr"; } s << INDENT << "qtd_" << d_class->name() << QString("_initCallBacks(%1);").arg(initArgs) << endl; @@ -2633,10 +2607,39 @@ if (d_class->isQObject()) - { - s << "private extern(C) void* qtd_" << d_class->name() << "_staticMetaObject();" << endl << endl - << "private extern(C) void qtd_" << d_class->name() << "_createEntity(void* nativeId, void* dId);" << endl << endl; - } + writeQObjectFreeFunctions(s, d_class); + + if (d_class->typeEntry()->isValue()) + writeValueFreeFunctions(s, d_class); +} + +void DGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *d_class) +{ + s << INDENT << "struct QTypeInfo {" << endl; + s << INDENT << " static __gshared bool isComplex;" << endl; + s << INDENT << " static __gshared bool isStatic;" << endl; + s << INDENT << " static __gshared bool isLarge;" << endl; + s << INDENT << " static __gshared bool isPointer;" << endl; + s << INDENT << " static __gshared bool isDummy;" << endl << endl; + + s << INDENT << " static init() {" << endl; + + s << QString(" isComplex = qtd_%1_QTypeInfo_isComplex();\n" + " isStatic = qtd_%1_QTypeInfo_isStatic();\n" + " isLarge = qtd_%1_QTypeInfo_isLarge();\n" + " isPointer = qtd_%1_QTypeInfo_isPointer();\n" + " isDummy = qtd_%1_QTypeInfo_isDummy();\n").arg(d_class->name()) + << " }" << endl + << " }" << endl << endl; +} + +void DGenerator::writeValueFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class) +{ + s << QString("private extern (C) bool qtd_%1_QTypeInfo_isComplex();\n").arg(d_class->name()); + s << QString("private extern (C) bool qtd_%1_QTypeInfo_isStatic();\n").arg(d_class->name()); + s << QString("private extern (C) bool qtd_%1_QTypeInfo_isLarge();\n").arg(d_class->name()); + s << QString("private extern (C) bool qtd_%1_QTypeInfo_isPointer();\n").arg(d_class->name()); + s << QString("private extern (C) bool qtd_%1_QTypeInfo_isDummy();\n").arg(d_class->name()); } void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) @@ -2674,13 +2677,73 @@ s << "}" << endl << endl; } +void DGenerator::writeQObjectFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class) +{ + s << "private extern(C) QMetaObjectNative* qtd_" << d_class->name() << "_staticMetaObject();" << endl << endl + << "private extern(C) void qtd_" << d_class->name() << "_createEntity(void* nativeId, void* dId);" << endl << endl; + + if (!d_class->isFinal()) + s << "private extern(C) int qtd_" << d_class->name() << "_qt_metacall(void* __this_nativeId, QMetaObject.Call _c, int _id, void **_a);" + << "private extern(C) int qtd_" << d_class->name() << "_qt_metacall_dispatch(void *d_entity, QMetaObject.Call _c, int _id, void **_a) {" + << " auto d_object = cast(" << d_class->name() << ") d_entity;" + << " return d_object.qt_metacall(_c, _id, _a);" + << "}" << endl << endl + + << "private extern(C) void* qtd_" << d_class->name() << "_metaObject_dispatch(void *d_entity) {" + << " auto d_object = cast(" << d_class->name() << ") d_entity;" + << " return d_object.metaObject().nativeId();" + << "}" << endl << endl; + } + +void writeMetaMethodSignatures(QTextStream &s, const QString &var_name, AbstractMetaFunctionList meta_funcs) +{ + s << INDENT << "private static const string[] " << var_name << " = ["; + { + Indentation indent(INDENT); + for (int i = 0; i < meta_funcs.size(); ++i) + { + if (i) + s << ", "; + int j = 0; + bool hasDefault = false; + do // need this to look for default arguments and generate extra signatures + { + if (j) + s << ", "; + s << endl << INDENT << " \"" << meta_funcs.at(i)->minimalSignature(j) << "\""; + AbstractMetaArgumentList args = meta_funcs.at(i)->arguments(); + if(args.size() && jdefaultValueExpression().isEmpty(); + else + hasDefault = false; + j++; + } while (hasDefault); + } + } + s << INDENT << "];" << endl << endl; +} + void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class) { - QString concreteArg; + AbstractMetaFunctionList d_funcs_gen = generatedClassFunctions(d_class); + AbstractMetaFunctionList slot_funcs; + for (int i=0; iisSlot()) + slot_funcs += function; + } + writeMetaMethodSignatures(s, "__slotSignatures", slot_funcs); + + QString concreteArg; if (d_class->isAbstract()) concreteArg += ", " + d_class->name() + "_ConcreteWrapper"; - s << " private static QMetaObject _staticMetaObject;" << endl + if (!d_class->isFinal()) + s << " int qt_metacall(QMetaObject.Call _c, int _id, void **_a) {" << endl + << " return qtd_" << d_class->name() << "_qt_metacall(__nativeId, _c, _id, _a);" << endl + << " }" << endl << endl; + + s << " private static __gshared QMetaObject _staticMetaObject;" << endl << " protected static void createStaticMetaObject() {" << endl << " assert(!_staticMetaObject);" << endl << " QMetaObject base;" << endl; @@ -2695,6 +2758,7 @@ s << " _staticMetaObject = new QMetaObject(qtd_" << d_class->name() << "_staticMetaObject, base);" << endl << " _staticMetaObject.construct!(" << d_class->name() << concreteArg << ");" << endl + << " _populateMetaInfo();" << endl << " }" << endl << endl << " QMetaObject metaObject() {" << endl @@ -2711,7 +2775,60 @@ << " static void __createEntity(void* nativeId, void* dId) {" << endl << " return qtd_" << d_class->name() << "_createEntity(nativeId, dId);" << endl - << " }" << endl << endl; + << " }" << endl << endl + + << " private static void _populateMetaInfo() {" << endl + << " int index;" << endl << endl; + + AbstractMetaFunctionList signal_funcs = signalFunctions(d_class, false); + + int staticId = 0; + for (int i = 0; i < signal_funcs.size(); ++i) + { + int j = 0; + bool hasDefault = false; + do // need this to look for default arguments and generate extra signatures + { + AbstractMetaFunction *fn = signal_funcs.at(i); + s << " index = _staticMetaObject.indexOfMethod_Cpp(__signalSignatures[" << staticId << "]);" << endl + << " _staticMetaObject.addMethod(new QMetaSignal(signature!("; + writeMetaMethodArguments(s, fn, j); + s << ")(\"" << fn->name() << "\"), index));" << endl << endl; + AbstractMetaArgumentList args = fn->arguments(); + if(args.size() && jdefaultValueExpression().isEmpty(); + else + hasDefault = false; + j++; + staticId++; + } while (hasDefault); + } + + staticId = 0; + for (int i = 0; i < slot_funcs.size(); ++i) + { + int j = 0; + bool hasDefault = false; + do // need this to look for default arguments and generate extra signatures + { + AbstractMetaFunction *fn = slot_funcs.at(i); + s << " index = _staticMetaObject.indexOfMethod_Cpp(__slotSignatures[" << staticId << "]);" << endl + << " _staticMetaObject.addMethod(new QMetaSlot(signature!("; + writeMetaMethodArguments(s, fn, j); + s << ")(\"" << fn->name() << "\"), index));" << endl << endl; + AbstractMetaArgumentList args = fn->arguments(); + if(args.size() && jdefaultValueExpression().isEmpty(); + else + hasDefault = false; + j++; + staticId++; + } while (hasDefault); + } + + s << " }" << endl << endl; + + s << INDENT << "mixin Q_OBJECT_BIND;" << endl << endl; } /* @@ -2778,17 +2895,7 @@ void DGenerator::writeSignalSignatures(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunctionList signal_funcs) { - s << INDENT << "private const string[" << signal_funcs.size() << "] __signalSignatures = ["; - { - Indentation indent(INDENT); - for (int i = 0; i < signal_funcs.size(); ++i) - { - if (i) - s << ", "; - s << endl << INDENT << " \"" << signal_funcs.at(i)->minimalSignature() << "\""; - } - } - s << INDENT << "];" << endl << endl; + writeMetaMethodSignatures(s, "__signalSignatures", signal_funcs); s << INDENT << "int signalSignature(int signalId, ref stringz signature) {" << endl; { @@ -2810,29 +2917,43 @@ s << INDENT << "}" << endl; } +void DGenerator::writeMetaMethodArguments(QTextStream &s, const AbstractMetaFunction *d_function, int reduce) +{ + bool withDefArgs = false; + if(reduce == -1) { + reduce = 0; + withDefArgs = true; + } + + AbstractMetaArgumentList arguments = d_function->arguments(); + int sz = arguments.count() - reduce; + + for (int i=0; itypeReplaced(i+1); + + if (modifiedType.isEmpty()) + s << translateType(arguments.at(i)->type(), d_function->implementingClass(), BoxedPrimitive); + else + s << modifiedType; + + if (!arguments.at(i)->defaultValueExpression().isEmpty() && withDefArgs) // qtd + s << " = " + arguments.at(i)->defaultValueExpression(); + } +} + void DGenerator::writeSignal(QTextStream &s, const AbstractMetaFunction *d_function) { Q_ASSERT(d_function->isSignal()); - - AbstractMetaArgumentList arguments = d_function->arguments(); - int sz = arguments.count(); - - s << INDENT << "mixin BindQtSignal!(\"" << d_function->name() << "\""; - - if (sz > 0) { - for (int i=0; itypeReplaced(i+1); - - if (modifiedType.isEmpty()) - s << translateType(arguments.at(i)->type(), d_function->implementingClass(), BoxedPrimitive); - else - s << modifiedType; - } - } - - s << ");" << endl; +/* + s << INDENT << "mixin BindQtSignal!(\"" << d_function->name() << "("; + + writeMetaMethodArguments(s, d_function); + + s << ")\");" << endl; + */ } void DGenerator::writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *d_function, @@ -2857,7 +2978,13 @@ AbstractMetaType *type = argument->type(); // if has QString argument we have to pass char* and str.length to QString constructor { - if(type->isEnum()) + if (type->isContainer()) + { + if ( ((const ContainerTypeEntry *)type->typeEntry())->isQList() ) { + s << INDENT; + s << "auto " << arg_name << "_d_ref = cast(" << translateType(type, implementor) << "*)" << arg_name << ";" << endl; + } + } else if(type->isEnum()) s << INDENT << "auto " << arg_name << "_enum = cast(" << type->typeEntry()->qualifiedTargetLangName() << ") " << arg_name << ";"; else if (type->typeEntry()->qualifiedCppName() == "QChar") @@ -2867,7 +2994,7 @@ s << INDENT << "string " << arg_name << "_d_ref = toUTF8(" << arg_name << "[0.." << arg_name << "_size]);"; else if (type->typeEntry()->isValue() && type->isNativePointer() && type->typeEntry()->name() == "QString") { - s << INDENT << "auto " << arg_name << "_d_qstr = QString(" << arg_name << ", true);" << endl + s << INDENT << "auto " << arg_name << "_d_qstr = QStringUtil(" << arg_name << ", true);" << endl << INDENT << "string " << arg_name << "_d_ref = " << arg_name << "_d_qstr.toNativeString();"; } else if(type->isVariant()) s << INDENT << "scope " << arg_name << "_d_ref = new QVariant(" << arg_name << ", QtdObjectFlags.nativeOwnership);"; @@ -2935,11 +3062,14 @@ if (modified_type == "string" /* && type->fullName() == "char" */) s << "fromStringz(" << arg_name << ")"; - else { + else + { if(type->isContainer() || (type->isReference() && type->typeEntry()->isStructInD())) s << "*"; s << arg_name; + if (type->isContainer() && ((const ContainerTypeEntry *)type->typeEntry())->isQList() ) + s << "_d_ref"; } if (type->typeEntry()->isStructInD()) ; else if (type->isQObject() || type->isObject() @@ -2975,10 +3105,13 @@ s << INDENT << "return ret_value is null? null : ret_value." << native_id << ";" << endl; } else if (f_type->isTargetLangString()) s << INDENT << "*ret_str = _d_str;" << endl; - else if (f_type->isContainer()) - s << INDENT << "*__d_arr_ptr = return_value.ptr;" << endl - << INDENT << "*__d_arr_size = return_value.length;" << endl; - else if (f_type->name() == "QModelIndex" || f_type->typeEntry()->isStructInD()) + else if (f_type->isContainer()) { + if (isNativeContainer(f_type)) + s << INDENT << "*__d_arr = return_value;" << endl; + else + s << INDENT << "*__d_arr_ptr = return_value.ptr;" << endl + << INDENT << "*__d_arr_size = return_value.length;" << endl; + } else if (f_type->name() == "QModelIndex" || f_type->typeEntry()->isStructInD()) ; else s << INDENT << "return return_value;" << endl; @@ -3007,8 +3140,6 @@ ctype_child->addedTo = cls->name(); } - foreach (AbstractMetaFunction *function, cls->functions()) - function->checkStoreResult(); /* we don't need this anymore // generate QObject conversion functions only those that are required AbstractMetaFunctionList d_funcs = cls->functionsInTargetLang(); diff -r 70f64e5b5942 -r ed7018b63aa7 generator/dgenerator.h --- a/generator/dgenerator.h Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/dgenerator.h Sun Feb 07 15:46:06 2010 +0000 @@ -98,7 +98,7 @@ const QString &arg_name); void writePrivateNativeFunction(QTextStream &s, const AbstractMetaFunction *d_function); void writeJavaLangObjectOverrideFunctions(QTextStream &s, const AbstractMetaClass *cls); - void writeReferenceCount(QTextStream &s, const ReferenceCount &refCount, const QString &argumentName); + void writeReferenceCount(QTextStream &s, const ReferenceCount &refCount, const QString &argumentName, AbstractMetaType *argumentType = 0); void retrieveModifications(const AbstractMetaFunction *f, const AbstractMetaClass *d_class, uint *exclude_attributes, uint *include_attributes) const; QString functionSignature(const AbstractMetaFunction *d_function, @@ -149,14 +149,19 @@ void addInstantiations(const AbstractMetaType* d_type); void writeRequiredImports(QTextStream &s, const AbstractMetaClass *d_class); const TypeEntry* fixedTypeEntry(const TypeEntry *type); + AbstractMetaFunctionList generatedClassFunctions(const AbstractMetaClass *d_class); void writeDestructor(QTextStream &s, const AbstractMetaClass *d_class); void writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class); void writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class); void writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum); void writeSignalSignatures(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunctionList signal_funcs); + void writeMetaMethodArguments(QTextStream &s, const AbstractMetaFunction *d_function, int reduce = -1); void writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class); + void writeQObjectFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class); void writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class); + void writeValueFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class); + void writeValueFunctions(QTextStream &s, const AbstractMetaClass *d_class); // void writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class); diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem.cpp --- a/generator/typesystem.cpp Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem.cpp Sun Feb 07 15:46:06 2010 +0000 @@ -96,6 +96,7 @@ // qtd stuff AddClass = 0x1100, PackageDepend = 0x1200, + PrivateCopyConstructor = 0x1300, // Code snip tags (0x1000, 0x2000, ... , 0xf000) InjectCode = 0x1000, @@ -163,6 +164,7 @@ tagNames["rename"] = StackElement::Rename; tagNames["typesystem"] = StackElement::Root; tagNames["custom-constructor"] = StackElement::CustomMetaConstructor; + tagNames["private-copy-constructor"] = StackElement::PrivateCopyConstructor; tagNames["custom-destructor"] = StackElement::CustomMetaDestructor; tagNames["argument-map"] = StackElement::ArgumentMap; tagNames["suppress-warning"] = StackElement::SuppressedWarning; @@ -299,6 +301,11 @@ delete current->value.customFunction; } break; + case StackElement::PrivateCopyConstructor: + { + current->entry->setHasPrivateCopyConstructor(true); + } + break; case StackElement::CustomMetaDestructor: { current->entry->setCustomDestructor(*current->value.customFunction); @@ -1677,19 +1684,17 @@ QString ContainerTypeEntry::javaPackage() const { - if (m_type == PairContainer) - return "qt"; - return "java.util"; + return "qt.core"; } QString ContainerTypeEntry::targetLangName() const { switch (m_type) { - case StringListContainer: return "List"; - case ListContainer: return "List"; - case LinkedListContainer: return "LinkedList"; - case VectorContainer: return "List"; + case StringListContainer: return "QList"; + case ListContainer: return "QList"; + case LinkedListContainer: return "QLinkedList"; + case VectorContainer: return "QVector"; case StackContainer: return "Stack"; case QueueContainer: return "Queue"; case SetContainer: return "Set"; diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem.h --- a/generator/typesystem.h Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem.h Sun Feb 07 15:46:06 2010 +0000 @@ -436,9 +436,10 @@ : m_name(name), m_type(t), m_code_generation(GenerateAll), - m_preferred_conversion(true) + m_preferred_conversion(true), + m_has_copy_constructor(false) { - }; + } virtual ~TypeEntry() { } @@ -508,6 +509,8 @@ // qtd virtual bool isStructInD() const { return false; } + bool hasPrivateCopyConstructor() const { return m_has_copy_constructor; } + void setHasPrivateCopyConstructor(bool has_copy_constructor) { m_has_copy_constructor = has_copy_constructor; } private: QString m_name; @@ -516,6 +519,7 @@ CustomFunction m_customConstructor; CustomFunction m_customDestructor; bool m_preferred_conversion; + bool m_has_copy_constructor; }; typedef QHash > TypeEntryHash; typedef QHash SingleTypeEntryHash; @@ -950,6 +954,8 @@ QString javaPackage() const; QString qualifiedCppName() const; + bool isQList() const { return type() == ListContainer || type() == StringListContainer; } + private: Type m_type; }; diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_core-java.java --- a/generator/typesystem_core-java.java Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_core-java.java Sun Feb 07 15:46:06 2010 +0000 @@ -79,7 +79,7 @@ QObject __next; QObject __prev; } - +/* override void onSignalHandlerCreated(ref SignalHandler sh) { sh.signalEvent = &onSignalEvent; @@ -104,7 +104,7 @@ } } } - +*/ ~this() { if (__prev) @@ -154,6 +154,11 @@ find(children); return result; } + + static void connect(QObject sender, string signal, QObject receiver, string method, int type = 0) + { + QMetaObject.connectImpl(sender, signal, receiver, method, type); + } }// class abstract class QAbstractItemModel___ extends QAbstractItemModel { diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_core.xml --- a/generator/typesystem_core.xml Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_core.xml Sun Feb 07 15:46:06 2010 +0000 @@ -103,7 +103,7 @@ - + @@ -558,8 +558,7 @@ - - + @@ -2282,15 +2281,16 @@ - + - @@ -2477,11 +2477,11 @@ --> - + @@ -2655,7 +2655,7 @@ - + @@ -2691,7 +2691,7 @@ - + diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_gui-java.java --- a/generator/typesystem_gui-java.java Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_gui-java.java Sun Feb 07 15:46:06 2010 +0000 @@ -1694,15 +1694,13 @@ static if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) { - public static int getInt(QWidget _parent, string title, string label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, ref bool ok = false, int flags = 0) { + public static int getInt(QWidget _parent, string title, string label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, ref bool ok = false, int flags = 0) { return qtd_QInputDialog_getInt_private_QWidget_string_string_int_int_int_int_nativepointerbool_WindowFlags(_parent is null ? null : _parent.__nativeId, title, label, value, minValue, maxValue, step, &ok, flags); - } + } } - public static string getItem(QWidget _parent, string title, string label, string[] items, int current = 0, bool editable = true, ref bool ok = false, int flags = 0) { - string res; - qtd_QInputDialog_getItem_private_QWidget_string_string_List_int_bool_nativepointerbool_WindowFlags(&res, _parent is null ? null : _parent.__nativeId, title, label, items.ptr, items.length, current, editable, &ok, flags); - return res; + public static string getItem(QWidget _parent, string title, string label, QList!(string) items, int current = 0, bool editable = true, ref bool ok = false, int flags = 0) { + return getItem_private(_parent, title, label, items, current, editable, &ok, flags); } public static string getText(QWidget _parent, string title, string label, QLineEdit_EchoMode echo = QLineEdit_EchoMode.Normal, string text = null, ref bool ok = false, int flags = 0) { diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_gui.xml --- a/generator/typesystem_gui.xml Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_gui.xml Sun Feb 07 15:46:06 2010 +0000 @@ -1298,7 +1298,7 @@ - public final QVariant toVariant() { + public final QVariant toVariant() const { return operator_cast_QVariant(); } @@ -2202,7 +2202,9 @@ - + - + - + + + + + @@ -5330,12 +5336,12 @@ - + @@ -5375,7 +5381,7 @@ - + @@ -5390,7 +5396,7 @@ - + @@ -5509,9 +5515,9 @@ - + - + @@ -6815,25 +6821,25 @@ - + - + - + - + @@ -7235,7 +7241,7 @@ - > + @@ -7586,6 +7592,13 @@ return %FUNCTION_NAME(%PRE_CALL_ARGUMENTS %COMMA className == null ? null : className.data()); } + + + QApplication qApp() + { + return cast(QApplication) QCoreApplication.instance(); + } + diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_network.xml --- a/generator/typesystem_network.xml Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_network.xml Sun Feb 07 15:46:06 2010 +0000 @@ -102,7 +102,7 @@ - + diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_phonon.xml --- a/generator/typesystem_phonon.xml Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_phonon.xml Sun Feb 07 15:46:06 2010 +0000 @@ -75,7 +75,7 @@ - + diff -r 70f64e5b5942 -r ed7018b63aa7 generator/typesystem_xml.xml --- a/generator/typesystem_xml.xml Sat Dec 19 18:43:32 2009 +0300 +++ b/generator/typesystem_xml.xml Sun Feb 07 15:46:06 2010 +0000 @@ -346,6 +346,7 @@ +