summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qdbus/Qt5DBusToolsConfig.cmake.in12
-rw-r--r--src/qdbus/Qt5DBusToolsMacros.cmake153
-rw-r--r--src/qdbus/qdbus.pro32
-rw-r--r--src/qdbus/qdbuscpp2xml/qdbuscpp2xml.cpp446
-rw-r--r--src/qdbus/qdbuscpp2xml/qdbuscpp2xml.pro10
-rw-r--r--src/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp1148
-rw-r--r--src/qdbus/qdbusxml2cpp/qdbusxml2cpp.pro9
-rw-r--r--tests/manual/cmake/CMakeLists.txt1
-rw-r--r--tests/manual/cmake/pass1/CMakeLists.txt35
-rw-r--r--tests/manual/cmake/pass1/mydbusobject.cpp56
-rw-r--r--tests/manual/cmake/pass1/mydbusobject.h58
11 files changed, 1 insertions, 1959 deletions
diff --git a/src/qdbus/Qt5DBusToolsConfig.cmake.in b/src/qdbus/Qt5DBusToolsConfig.cmake.in
deleted file mode 100644
index 913f63d47..000000000
--- a/src/qdbus/Qt5DBusToolsConfig.cmake.in
+++ /dev/null
@@ -1,12 +0,0 @@
-
-get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
-
-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
-set(QT_DBUSCPP2XML_EXECUTABLE \"${_qt5_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-set(QT_DBUSXML2CPP_EXECUTABLE \"${_qt5_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-!!ELSE
-set(QT_DBUSCPP2XML_EXECUTABLE \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-set(QT_DBUSXML2CPP_EXECUTABLE \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-!!ENDIF
-
-include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5DBusToolsMacros.cmake\")
diff --git a/src/qdbus/Qt5DBusToolsMacros.cmake b/src/qdbus/Qt5DBusToolsMacros.cmake
deleted file mode 100644
index 6617d370a..000000000
--- a/src/qdbus/Qt5DBusToolsMacros.cmake
+++ /dev/null
@@ -1,153 +0,0 @@
-#=============================================================================
-# Copyright 2005-2011 Kitware, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# * Neither the name of Kitware, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#=============================================================================
-
-include(MacroAddFileDependencies)
-
-
-function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
- get_filename_component(_infile ${_interface} ABSOLUTE)
- set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- set(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
-
- get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE)
- if(_nonamespace)
- set(_params -N -m)
- else()
- set(_params -m)
- endif()
-
- get_source_file_property(_classname ${_interface} CLASSNAME)
- if(_classname)
- set(_params ${_params} -c ${_classname})
- endif()
-
- get_source_file_property(_include ${_interface} INCLUDE)
- if(_include)
- set(_params ${_params} -i ${_include})
- endif()
-
- add_custom_command(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
- DEPENDS ${_infile} VERBATIM)
-
- set_source_files_properties(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
-
- qt5_generate_moc(${_header} ${_moc})
-
- list(APPEND ${_sources} ${_impl} ${_header} ${_moc})
- macro_add_file_dependencies(${_impl} ${_moc})
- set(${_sources} ${${_sources}} PARENT_SCOPE)
-endfunction()
-
-
-function(QT5_ADD_DBUS_INTERFACES _sources)
- foreach(_current_FILE ${ARGN})
- get_filename_component(_infile ${_current_FILE} ABSOLUTE)
- # get the part before the ".xml" suffix
- string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
- string(TOLOWER ${_basename} _basename)
- qt5_add_dbus_interface(${_sources} ${_infile} ${_basename}interface)
- endforeach()
- set(${_sources} ${${_sources}} PARENT_SCOPE)
-endfunction()
-
-
-function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_DBUS_INTERFACE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(_customName ${_DBUS_INTERFACE_UNPARSED_ARGUMENTS})
- set(_qt4_dbus_options ${_DBUS_INTERFACE_OPTIONS})
-
- get_filename_component(_in_file ${_header} ABSOLUTE)
- get_filename_component(_basename ${_header} NAME_WE)
-
- if(_customName)
- if(IS_ABSOLUTE ${_customName})
- get_filename_component(_containingDir ${_customName} PATH)
- if(NOT EXISTS ${_containingDir})
- file(MAKE_DIRECTORY "${_containingDir}")
- endif()
- set(_target ${_customName})
- else()
- set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
- endif()
- else()
- set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
- endif()
-
- add_custom_command(OUTPUT ${_target}
- COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
- DEPENDS ${_in_file} VERBATIM
- )
-endfunction()
-
-
-function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
- get_filename_component(_infile ${_xml_file} ABSOLUTE)
-
- set(_optionalBasename "${ARGV4}")
- if(_optionalBasename)
- set(_basename ${_optionalBasename} )
- else()
- string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
- string(TOLOWER ${_basename} _basename)
- endif()
-
- set(_optionalClassName "${ARGV5}")
- set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- set(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
-
- if(_optionalClassName)
- add_custom_command(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
- DEPENDS ${_infile} VERBATIM
- )
- else()
- add_custom_command(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
- DEPENDS ${_infile} VERBATIM
- )
- endif()
-
- qt5_generate_moc(${_header} ${_moc})
- set_source_files_properties(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
- macro_add_file_dependencies(${_impl} ${_moc})
-
- list(APPEND ${_sources} ${_impl} ${_header} ${_moc})
- set(${_sources} ${${_sources}} PARENT_SCOPE)
-endfunction()
diff --git a/src/qdbus/qdbus.pro b/src/qdbus/qdbus.pro
index 038de51f1..abb1b2d8b 100644
--- a/src/qdbus/qdbus.pro
+++ b/src/qdbus/qdbus.pro
@@ -1,33 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = qdbus qdbusxml2cpp qdbuscpp2xml
+SUBDIRS = qdbus
!contains(QT_CONFIG, no-gui): SUBDIRS += qdbusviewer
-
-win32:CMAKE_BIN_SUFFIX = ".exe"
-
-CMAKE_QT_INSTALL_PREFIX = $$replace($$list($$[QT_INSTALL_PREFIX]), \\\\, /)/
-CMAKE_QT_INSTALL_PREFIX_ESCAPED = "^$$re_escape($$CMAKE_QT_INSTALL_PREFIX)"
-
-CMAKE_LIB_DIR = $$replace($$list($$[QT_INSTALL_LIBS]), \\\\, /)/
-contains(CMAKE_LIB_DIR, "$${CMAKE_QT_INSTALL_PREFIX_ESCAPED}.*") {
- CMAKE_LIB_DIR = $$replace(CMAKE_LIB_DIR, "$$CMAKE_QT_INSTALL_PREFIX_ESCAPED", )
- CMAKE_RELATIVE_INSTALL_DIR = $$replace(CMAKE_LIB_DIR, "[^/]+", ..)
- # We need to go up another two levels because the CMake files are
- # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
- CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_DIR}/../../"
-}
-
-CMAKE_BIN_DIR = $$replace($$list($$[QT_INSTALL_BINS]), \\\\, /)/
-contains(CMAKE_BIN_DIR, "$${CMAKE_QT_INSTALL_PREFIX_ESCAPED}.*") {
- CMAKE_BIN_DIR = $$replace(CMAKE_BIN_DIR, "$$CMAKE_QT_INSTALL_PREFIX_ESCAPED", )
-} else {
- CMAKE_BIN_DIR_IS_ABSOLUTE = True
-}
-
-cmake_dbus_config_file.input = $$PWD/Qt5DBusToolsConfig.cmake.in
-cmake_dbus_config_file.output = $$OUT_PWD/Qt5DBusToolsConfig.cmake
-QMAKE_SUBSTITUTES += cmake_dbus_config_file
-
-cmake_dbus_tools_files.files += $$cmake_dbus_config_file.output $$PWD/Qt5DBusToolsMacros.cmake
-cmake_dbus_tools_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5DBusTools
-cmake_dbus_tools_files.CONFIG = no_check_exists
-INSTALLS += cmake_dbus_tools_files
diff --git a/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.cpp
deleted file mode 100644
index 5814dc740..000000000
--- a/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ /dev/null
@@ -1,446 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QByteArray>
-#include <QString>
-#include <QVarLengthArray>
-#include <QFile>
-#include <QProcess>
-#include <QMetaObject>
-#include <QList>
-#include <QRegExp>
-#include <QCoreApplication>
-#include <QLibraryInfo>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "qdbusconnection.h" // for the Export* flags
-
-// copied from dbus-protocol.h:
-static const char docTypeHeader[] =
- "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n";
-
-// in qdbusxmlgenerator.cpp
-QT_BEGIN_NAMESPACE
-extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
- const QMetaObject *base, int flags);
-QT_END_NAMESPACE
-
-#define PROGRAMNAME "qdbuscpp2xml"
-#define PROGRAMVERSION "0.1"
-#define PROGRAMCOPYRIGHT "Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)."
-
-static QString outputFile;
-static int flags;
-
-static const char help[] =
- "Usage: " PROGRAMNAME " [options...] [files...]\n"
- "Parses the C++ source or header file containing a QObject-derived class and\n"
- "produces the D-Bus Introspection XML."
- "\n"
- "Options:\n"
- " -p|-s|-m Only parse scriptable Properties, Signals and Methods (slots)\n"
- " -P|-S|-M Parse all Properties, Signals and Methods (slots)\n"
- " -a Output all scriptable contents (equivalent to -psm)\n"
- " -A Output all contents (equivalent to -PSM)\n"
- " -o <filename> Write the output to file <filename>\n"
- " -h Show this information\n"
- " -V Show the program version and quit.\n"
- "\n";
-
-class MocParser
-{
- void parseError();
- QByteArray readLine();
- void loadIntData(uint *&data);
- void loadStringData(char *&stringdata);
-
- QIODevice *input;
- const char *filename;
- int lineNumber;
-public:
- ~MocParser();
- void parse(const char *filename, QIODevice *input, int lineNumber = 0);
-
- QList<QMetaObject> objects;
-};
-
-void MocParser::parseError()
-{
- fprintf(stderr, PROGRAMNAME ": error parsing input file '%s' line %d \n", filename, lineNumber);
- exit(1);
-}
-
-QByteArray MocParser::readLine()
-{
- ++lineNumber;
- return input->readLine();
-}
-
-void MocParser::loadIntData(uint *&data)
-{
- data = 0; // initialise
- QVarLengthArray<uint> array;
- QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive);
-
- while (!input->atEnd()) {
- QString line = QLatin1String(readLine());
- int pos = line.indexOf(QLatin1String("//"));
- if (pos != -1)
- line.truncate(pos); // drop comments
-
- if (line == QLatin1String("};\n")) {
- // end of data
- data = new uint[array.count()];
- memcpy(data, array.data(), array.count() * sizeof(*data));
- return;
- }
-
- pos = 0;
- while ((pos = rx.indexIn(line, pos)) != -1) {
- QString num = rx.cap(1);
- if (num.startsWith(QLatin1String("0x")))
- array.append(num.mid(2).toUInt(0, 16));
- else
- array.append(num.toUInt());
- pos += rx.matchedLength();
- }
- }
-
- parseError();
-}
-
-void MocParser::loadStringData(char *&stringdata)
-{
- stringdata = 0;
- QVarLengthArray<char, 1024> array;
-
- while (!input->atEnd()) {
- QByteArray line = readLine();
- if (line == "};\n") {
- // end of data
- stringdata = new char[array.count()];
- memcpy(stringdata, array.data(), array.count() * sizeof(*stringdata));
- return;
- }
-
- int start = line.indexOf('"');
- if (start == -1)
- parseError();
-
- int len = line.length() - 1;
- line.truncate(len); // drop ending \n
- if (line.at(len - 1) != '"')
- parseError();
-
- --len;
- ++start;
- for ( ; start < len; ++start)
- if (line.at(start) == '\\') {
- // parse escaped sequence
- ++start;
- if (start == len)
- parseError();
-
- QChar c(QLatin1Char(line.at(start)));
- if (!c.isDigit()) {
- switch (c.toLatin1()) {
- case 'a':
- array.append('\a');
- break;
- case 'b':
- array.append('\b');
- break;
- case 'f':
- array.append('\f');
- break;
- case 'n':
- array.append('\n');
- break;
- case 'r':
- array.append('\r');
- break;
- case 't':
- array.append('\t');
- break;
- case 'v':
- array.append('\v');
- break;
- case '\\':
- case '?':
- case '\'':
- case '"':
- array.append(c.toLatin1());
- break;
-
- case 'x':
- if (start + 2 <= len)
- parseError();
- array.append(char(line.mid(start + 1, 2).toInt(0, 16)));
- break;
-
- default:
- array.append(c.toLatin1());
- fprintf(stderr, PROGRAMNAME ": warning: invalid escape sequence '\\%c' found in input",
- c.toLatin1());
- }
- } else {
- // octal
- QRegExp octal(QLatin1String("([0-7]+)"));
- if (octal.indexIn(QLatin1String(line), start) == -1)
- parseError();
- array.append(char(octal.cap(1).toInt(0, 8)));
- }
- } else {
- array.append(line.at(start));
- }
- }
-
- parseError();
-}
-
-void MocParser::parse(const char *fname, QIODevice *io, int lineNum)
-{
- filename = fname;
- input = io;
- lineNumber = lineNum;
-
- while (!input->atEnd()) {
- QByteArray line = readLine();
- if (line.startsWith("static const uint qt_meta_data_")) {
- // start of new class data
- uint *data;
- loadIntData(data);
-
- // find the start of the string data
- do {
- line = readLine();
- if (input->atEnd())
- parseError();
- } while (!line.startsWith("static const char qt_meta_stringdata_"));
-
- char *stringdata;
- loadStringData(stringdata);
-
- QMetaObject mo;
- mo.d.superdata = &QObject::staticMetaObject;
- mo.d.stringdata = stringdata;
- mo.d.data = data;
- mo.d.extradata = 0;
- objects.append(mo);
- }
- }
-
- fname = 0;
- input = 0;
-}
-
-MocParser::~MocParser()
-{
- foreach (QMetaObject mo, objects) {
- delete const_cast<char *>(mo.d.stringdata);
- delete const_cast<uint *>(mo.d.data);
- }
-}
-
-static void showHelp()
-{
- printf("%s", help);
- exit(0);
-}
-
-static void showVersion()
-{
- printf("%s version %s\n", PROGRAMNAME, PROGRAMVERSION);
- printf("D-Bus QObject-to-XML converter\n");
- exit(0);
-}
-
-static void parseCmdLine(QStringList &arguments)
-{
- for (int i = 1; i < arguments.count(); ++i) {
- const QString arg = arguments.at(i);
-
- if (arg == QLatin1String("--help"))
- showHelp();
-
- if (!arg.startsWith(QLatin1Char('-')))
- continue;
-
- char c = arg.count() == 2 ? arg.at(1).toLatin1() : char(0);
- switch (c) {
- case 'P':
- flags |= QDBusConnection::ExportNonScriptableProperties;
- // fall through
- case 'p':
- flags |= QDBusConnection::ExportScriptableProperties;
- break;
-
- case 'S':
- flags |= QDBusConnection::ExportNonScriptableSignals;
- // fall through
- case 's':
- flags |= QDBusConnection::ExportScriptableSignals;
- break;
-
- case 'M':
- flags |= QDBusConnection::ExportNonScriptableSlots;
- // fall through
- case 'm':
- flags |= QDBusConnection::ExportScriptableSlots;
- break;
-
- case 'A':
- flags |= QDBusConnection::ExportNonScriptableContents;
- // fall through
- case 'a':
- flags |= QDBusConnection::ExportScriptableContents;
- break;
-
- case 'o':
- if (arguments.count() < i + 2 || arguments.at(i + 1).startsWith(QLatin1Char('-'))) {
- printf("-o expects a filename\n");
- exit(1);
- }
- outputFile = arguments.takeAt(i + 1);
- break;
-
- case 'h':
- case '?':
- showHelp();
- break;
-
- case 'V':
- showVersion();
- break;
-
- default:
- printf("unknown option: \"%s\"\n", qPrintable(arg));
- exit(1);
- }
- }
-
- if (flags == 0)
- flags = QDBusConnection::ExportScriptableContents
- | QDBusConnection::ExportNonScriptableContents;
-}
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
- QStringList args = app.arguments();
-
- MocParser parser;
- parseCmdLine(args);
-
- for (int i = 1; i < args.count(); ++i) {
- const QString arg = args.at(i);
- if (arg.startsWith(QLatin1Char('-')))
- continue;
-
- QFile f(arg);
- if (!f.open(QIODevice::ReadOnly|QIODevice::Text)) {
- fprintf(stderr, PROGRAMNAME ": could not open '%s': %s\n",
- qPrintable(arg), qPrintable(f.errorString()));
- return 1;
- }
-
- f.readLine();
-
- QByteArray line = f.readLine();
- if (line.contains("Meta object code from reading C++ file"))
- // this is a moc-generated file
- parser.parse(argv[i], &f, 3);
- else {
- // run moc on this file
- QProcess proc;
- proc.start(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/moc"), QStringList() << QFile::decodeName(argv[i]), QIODevice::ReadOnly | QIODevice::Text);
-
- if (!proc.waitForStarted()) {
- fprintf(stderr, PROGRAMNAME ": could not execute moc! Aborting.\n");
- return 1;
- }
-
- proc.closeWriteChannel();
-
- if (!proc.waitForFinished() || proc.exitStatus() != QProcess::NormalExit ||
- proc.exitCode() != 0) {
- // output the moc errors:
- fprintf(stderr, "%s", proc.readAllStandardError().constData());
- fprintf(stderr, PROGRAMNAME ": exit code %d from moc. Aborting\n", proc.exitCode());
- return 1;
- }
- fprintf(stderr, "%s", proc.readAllStandardError().constData());
-
- parser.parse(argv[i], &proc, 1);
- }
-
- f.close();
- }
-
- QFile output;
- if (outputFile.isEmpty()) {
- output.open(stdout, QIODevice::WriteOnly);
- } else {
- output.setFileName(outputFile);
- if (!output.open(QIODevice::WriteOnly)) {
- fprintf(stderr, PROGRAMNAME ": could not open output file '%s': %s",
- qPrintable(outputFile), qPrintable(output.errorString()));
- return 1;
- }
- }
-
- output.write(docTypeHeader);
- output.write("<node>\n");
- foreach (QMetaObject mo, parser.objects) {
- QString xml = qDBusGenerateMetaObjectXml(QString(), &mo, &QObject::staticMetaObject,
- flags);
- output.write(xml.toLocal8Bit());
- }
- output.write("</node>\n");
-
- return 0;
-}
-
diff --git a/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.pro b/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.pro
deleted file mode 100644
index 4f5f826ce..000000000
--- a/src/qdbus/qdbuscpp2xml/qdbuscpp2xml.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-SOURCES = qdbuscpp2xml.cpp
-DESTDIR = $$QT.designer.bins
-TARGET = qdbuscpp2xml
-QT = core
-CONFIG += qdbus
-CONFIG -= app_bundle
-win32:CONFIG += console
-
-target.path=$$[QT_INSTALL_BINS]
-INSTALLS += target
diff --git a/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp
deleted file mode 100644
index 26a0f2044..000000000
--- a/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp
+++ /dev/null
@@ -1,1148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qtextstream.h>
-#include <QtCore/qset.h>
-
-#include <QtDBus/QtDBus>
-#include "private/qdbusmetaobject_p.h"
-#include "private/qdbusintrospection_p.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define PROGRAMNAME "qdbusxml2cpp"
-#define PROGRAMVERSION "0.7"
-#define PROGRAMCOPYRIGHT "Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)."
-
-#define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply"
-
-static QString globalClassName;
-static QString parentClassName;
-static QString proxyFile;
-static QString adaptorFile;
-static QString inputFile;
-static bool skipNamespaces;
-static bool verbose;
-static bool includeMocs;
-static QString commandLine;
-static QStringList includes;
-static QStringList wantedInterfaces;
-
-static const char help[] =
- "Usage: " PROGRAMNAME " [options...] [xml-or-xml-file] [interfaces...]\n"
- "Produces the C++ code to implement the interfaces defined in the input file.\n"
- "\n"
- "Options:\n"
- " -a <filename> Write the adaptor code to <filename>\n"
- " -c <classname> Use <classname> as the class name for the generated classes\n"
- " -h Show this information\n"
- " -i <filename> Add #include to the output\n"
- " -l <classname> When generating an adaptor, use <classname> as the parent class\n"
- " -m Generate #include \"filename.moc\" statements in the .cpp files\n"
- " -N Don't use namespaces\n"
- " -p <filename> Write the proxy code to <filename>\n"
- " -v Be verbose.\n"
- " -V Show the program version and quit.\n"
- "\n"
- "If the file name given to the options -a and -p does not end in .cpp or .h, the\n"
- "program will automatically append the suffixes and produce both files.\n"
- "You can also use a colon (:) to separate the header name from the source file\n"
- "name, as in '-a filename_p.h:filename.cpp'.\n"
- "\n"
- "If you pass a dash (-) as the argument to either -p or -a, the output is written\n"
- "to the standard output\n";
-
-static const char includeList[] =
- "#include <QtCore/QByteArray>\n"
- "#include <QtCore/QList>\n"
- "#include <QtCore/QMap>\n"
- "#include <QtCore/QString>\n"
- "#include <QtCore/QStringList>\n"
- "#include <QtCore/QVariant>\n";
-
-static const char forwardDeclarations[] =
- "QT_BEGIN_NAMESPACE\n"
- "class QByteArray;\n"
- "template<class T> class QList;\n"
- "template<class Key, class Value> class QMap;\n"
- "class QString;\n"
- "class QStringList;\n"
- "class QVariant;\n"
- "QT_END_NAMESPACE\n";
-
-static void showHelp()
-{
- printf("%s", help);
- exit(0);
-}
-
-static void showVersion()
-{
- printf("%s version %s\n", PROGRAMNAME, PROGRAMVERSION);
- printf("D-Bus binding tool for Qt\n");
- exit(0);
-}
-
-static QString nextArg(QStringList &args, int i, char opt)
-{
- QString arg = args.value(i);
- if (arg.isEmpty()) {
- printf("-%c needs at least one argument\n", opt);
- exit(1);
- }
- return args.takeAt(i);
-}
-
-static void parseCmdLine(QStringList args)
-{
- args.takeFirst();
-
- commandLine = QLatin1String(PROGRAMNAME " ");
- commandLine += args.join(QLatin1String(" "));
-
- int i = 0;
- while (i < args.count()) {
-
- if (!args.at(i).startsWith(QLatin1Char('-'))) {
- ++i;
- continue;
- }
- QString arg = args.takeAt(i);
-
- char c = '\0';
- if (arg.length() == 2)
- c = arg.at(1).toLatin1();
- else if (arg == QLatin1String("--help"))
- c = 'h';
-
- switch (c) {
- case 'a':
- adaptorFile = nextArg(args, i, 'a');
- break;
-
- case 'c':
- globalClassName = nextArg(args, i, 'c');
- break;
-
- case 'v':
- verbose = true;
- break;
-
- case 'i':
- includes << nextArg(args, i, 'i');
- break;
-
- case 'l':
- parentClassName = nextArg(args, i, 'l');
- break;
-
- case 'm':
- includeMocs = true;
- break;
-
- case 'N':
- skipNamespaces = true;
- break;
-
- case '?':
- case 'h':
- showHelp();
- break;
-
- case 'V':
- showVersion();
- break;
-
- case 'p':
- proxyFile = nextArg(args, i, 'p');
- break;
-
- default:
- printf("unknown option: '%s'\n", qPrintable(arg));
- exit(1);
- }
- }
-
- if (!args.isEmpty())
- inputFile = args.takeFirst();
-
- wantedInterfaces << args;
-}
-
-static QDBusIntrospection::Interfaces readInput()
-{
- QFile input(inputFile);
- if (inputFile.isEmpty() || inputFile == QLatin1String("-"))
- input.open(stdin, QIODevice::ReadOnly);
- else
- input.open(QIODevice::ReadOnly);
-
- QByteArray data = input.readAll();
-
- // check if the input is already XML
- data = data.trimmed();
- if (data.startsWith("<!DOCTYPE ") || data.startsWith("<?xml") ||
- data.startsWith("<node") || data.startsWith("<interface"))
- // already XML
- return QDBusIntrospection::parseInterfaces(QString::fromUtf8(data));
-
- fprintf(stderr, "Cannot process input: '%s'. Stop.\n", qPrintable(inputFile));
- exit(1);
-}
-
-static void cleanInterfaces(QDBusIntrospection::Interfaces &interfaces)
-{
- if (!wantedInterfaces.isEmpty()) {
- QDBusIntrospection::Interfaces::Iterator it = interfaces.begin();
- while (it != interfaces.end())
- if (!wantedInterfaces.contains(it.key()))
- it = interfaces.erase(it);
- else
- ++it;
- }
-}
-
-// produce a header name from the file name
-static QString header(const QString &name)
-{
- QStringList parts = name.split(QLatin1Char(':'));
- QString retval = parts.first();
-
- if (retval.isEmpty() || retval == QLatin1String("-"))
- return retval;
-
- if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
- !retval.endsWith(QLatin1String(".cc")))
- retval.append(QLatin1String(".h"));
-
- return retval;
-}
-
-// produce a cpp name from the file name
-static QString cpp(const QString &name)
-{
- QStringList parts = name.split(QLatin1Char(':'));
- QString retval = parts.last();
-
- if (retval.isEmpty() || retval == QLatin1String("-"))
- return retval;
-
- if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
- !retval.endsWith(QLatin1String(".cc")))
- retval.append(QLatin1String(".cpp"));
-
- return retval;
-}
-
-// produce a moc name from the file name
-static QString moc(const QString &name)
-{
- QString retval = header(name);
- if (retval.isEmpty())
- return retval;
-
- retval.truncate(retval.length() - 1); // drop the h in .h
- retval += QLatin1String("moc");
- return retval;
-}
-
-static QTextStream &writeHeader(QTextStream &ts, bool changesWillBeLost)
-{
- ts << "/*" << endl
- << " * This file was generated by " PROGRAMNAME " version " PROGRAMVERSION << endl
- << " * Command line was: " << commandLine << endl
- << " *" << endl
- << " * " PROGRAMNAME " is " PROGRAMCOPYRIGHT << endl
- << " *" << endl
- << " * This is an auto-generated file." << endl;
-
- if (changesWillBeLost)
- ts << " * Do not edit! All changes made to it will be lost." << endl;
- else
- ts << " * This file may have been hand-edited. Look for HAND-EDIT comments" << endl
- << " * before re-generating it." << endl;
-
- ts << " */" << endl
- << endl;
-
- return ts;
-}
-
-enum ClassType { Proxy, Adaptor };
-static QString classNameForInterface(const QString &interface, ClassType classType)
-{
- if (!globalClassName.isEmpty())
- return globalClassName;
-
- QStringList parts = interface.split(QLatin1Char('.'));
-
- QString retval;
- if (classType == Proxy)
- foreach (QString part, parts) {
- part[0] = part[0].toUpper();
- retval += part;
- }
- else {
- retval = parts.last();
- retval[0] = retval[0].toUpper();
- }
-
- if (classType == Proxy)
- retval += QLatin1String("Interface");
- else
- retval += QLatin1String("Adaptor");
-
- return retval;
-}
-
-static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out")
-{
- int type = QDBusMetaType::signatureToType(signature.toLatin1());
- if (type == QVariant::Invalid) {
- QString annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
- if (paramId >= 0)
- annotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId);
- QString qttype = annotations.value(annotationName);
- if (!qttype.isEmpty())
- return qttype.toLatin1();
-
- fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature));
- fprintf(stderr, "You should add <annotation name=\"%s\" value=\"<type>\"/> to the XML description\n",
- qPrintable(annotationName));
- exit(1);
- }
-
- return QVariant::typeToName(QVariant::Type(type));
-}
-
-static QString nonConstRefArg(const QByteArray &arg)
-{
- return QLatin1String(arg + " &");
-}
-
-static QString templateArg(const QByteArray &arg)
-{
- if (!arg.endsWith('>'))
- return QLatin1String(arg);
-
- return QLatin1String(arg + ' ');
-}
-
-static QString constRefArg(const QByteArray &arg)
-{
- if (!arg.startsWith('Q'))
- return QLatin1String(arg + ' ');
- else
- return QString( QLatin1String("const %1 &") ).arg( QLatin1String(arg) );
-}
-
-static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
- const QDBusIntrospection::Arguments &outputArgs =
- QDBusIntrospection::Arguments())
-{
- QStringList retval;
- for (int i = 0; i < inputArgs.count(); ++i) {
- const QDBusIntrospection::Argument &arg = inputArgs.at(i);
- QString name = arg.name;
- if (name.isEmpty())
- name = QString( QLatin1String("in%1") ).arg(i);
- while (retval.contains(name))
- name += QLatin1String("_");
- retval << name;
- }
- for (int i = 0; i < outputArgs.count(); ++i) {
- const QDBusIntrospection::Argument &arg = outputArgs.at(i);
- QString name = arg.name;
- if (name.isEmpty())
- name = QString( QLatin1String("out%1") ).arg(i);
- while (retval.contains(name))
- name += QLatin1String("_");
- retval << name;
- }
- return retval;
-}
-
-static void writeArgList(QTextStream &ts, const QStringList &argNames,
- const QDBusIntrospection::Annotations &annotations,
- const QDBusIntrospection::Arguments &inputArgs,
- const QDBusIntrospection::Arguments &outputArgs = QDBusIntrospection::Arguments())
-{
- // input args:
- bool first = true;
- int argPos = 0;
- for (int i = 0; i < inputArgs.count(); ++i) {
- const QDBusIntrospection::Argument &arg = inputArgs.at(i);
- QString type = constRefArg(qtTypeName(arg.type, annotations, i, "In"));
-
- if (!first)
- ts << ", ";
- ts << type << argNames.at(argPos++);
- first = false;
- }
-
- argPos++;
-
- // output args
- // yes, starting from 1
- for (int i = 1; i < outputArgs.count(); ++i) {
- const QDBusIntrospection::Argument &arg = outputArgs.at(i);
- QString name = arg.name;
-
- if (!first)
- ts << ", ";
- ts << nonConstRefArg(qtTypeName(arg.type, annotations, i, "Out"))
- << argNames.at(argPos++);
- first = false;
- }
-}
-
-static QString propertyGetter(const QDBusIntrospection::Property &property)
-{
- QString getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
- if (getter.isEmpty()) {
- getter = property.name;
- getter[0] = getter[0].toLower();
- }
- return getter;
-}
-
-static QString propertySetter(const QDBusIntrospection::Property &property)
-{
- QString setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
- if (setter.isEmpty()) {
- setter = QLatin1String("set") + property.name;
- setter[3] = setter[3].toUpper();
- }
- return setter;
-}
-
-static QString stringify(const QString &data)
-{
- QString retval;
- int i;
- for (i = 0; i < data.length(); ++i) {
- retval += QLatin1Char('\"');
- for ( ; i < data.length() && data[i] != QLatin1Char('\n') && data[i] != QLatin1Char('\r'); ++i)
- if (data[i] == QLatin1Char('\"'))
- retval += QLatin1String("\\\"");
- else
- retval += data[i];
- if (data[i] == QLatin1Char('\r') && data[i+1] == QLatin1Char('\n'))
- i++;
- retval += QLatin1String("\\n\"\n");
- }
- return retval;
-}
-
-static void openFile(const QString &fileName, QFile &file)
-{
- if (fileName.isEmpty())
- return;
-
- bool isOk = false;
- if (fileName == QLatin1String("-")) {
- isOk = file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
- } else {
- file.setFileName(fileName);
- isOk = file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
- }
-
- if (!isOk)
- fprintf(stderr, "Unable to open '%s': %s\n", qPrintable(fileName),
- qPrintable(file.errorString()));
-}
-
-static void writeProxy(const QString &filename, const QDBusIntrospection::Interfaces &interfaces)
-{
- // open the file
- QString headerName = header(filename);
- QByteArray headerData;
- QTextStream hs(&headerData);
-
- QString cppName = cpp(filename);
- QByteArray cppData;
- QTextStream cs(&cppData);
-
- // write the header:
- writeHeader(hs, true);
- if (cppName != headerName)
- writeHeader(cs, false);
-
- // include guards:
- QString includeGuard;
- if (!headerName.isEmpty() && headerName != QLatin1String("-")) {
- includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
- int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
- if (pos != -1)
- includeGuard = includeGuard.mid(pos + 1);
- } else {
- includeGuard = QLatin1String("QDBUSXML2CPP_PROXY");
- }
- includeGuard = QString(QLatin1String("%1_%2"))
- .arg(includeGuard)
- .arg(QDateTime::currentDateTime().toTime_t());
- hs << "#ifndef " << includeGuard << endl
- << "#define " << includeGuard << endl
- << endl;
-
- // include our stuff:
- hs << "#include <QtCore/QObject>" << endl
- << includeList
- << "#include <QtDBus/QtDBus>" << endl;
-
- foreach (QString include, includes) {
- hs << "#include \"" << include << "\"" << endl;
- if (headerName.isEmpty())
- cs << "#include \"" << include << "\"" << endl;
- }
-
- hs << endl;
-
- if (cppName != headerName) {
- if (!headerName.isEmpty() && headerName != QLatin1String("-"))
- cs << "#include \"" << headerName << "\"" << endl << endl;
- }
-
- foreach (const QDBusIntrospection::Interface *interface, interfaces) {
- QString className = classNameForInterface(interface->name, Proxy);
-
- // comment:
- hs << "/*" << endl
- << " * Proxy class for interface " << interface->name << endl
- << " */" << endl;
- cs << "/*" << endl
- << " * Implementation of interface class " << className << endl
- << " */" << endl
- << endl;
-
- // class header:
- hs << "class " << className << ": public QDBusAbstractInterface" << endl
- << "{" << endl
- << " Q_OBJECT" << endl;
-
- // the interface name
- hs << "public:" << endl
- << " static inline const char *staticInterfaceName()" << endl
- << " { return \"" << interface->name << "\"; }" << endl
- << endl;
-
- // constructors/destructors:
- hs << "public:" << endl
- << " " << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);" << endl
- << endl
- << " ~" << className << "();" << endl
- << endl;
- cs << className << "::" << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)" << endl
- << " : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)" << endl
- << "{" << endl
- << "}" << endl
- << endl
- << className << "::~" << className << "()" << endl
- << "{" << endl
- << "}" << endl
- << endl;
-
- // properties:
- foreach (const QDBusIntrospection::Property &property, interface->properties) {
- QByteArray type = qtTypeName(property.type, property.annotations);
- QString templateType = templateArg(type);
- QString constRefType = constRefArg(type);
- QString getter = propertyGetter(property);
- QString setter = propertySetter(property);
-
- hs << " Q_PROPERTY(" << type << " " << property.name;
-
- // getter:
- if (property.access != QDBusIntrospection::Property::Write)
- // it's readble
- hs << " READ " << getter;
-
- // setter
- if (property.access != QDBusIntrospection::Property::Read)
- // it's writeable
- hs << " WRITE " << setter;
-
- hs << ")" << endl;
-
- // getter:
- if (property.access != QDBusIntrospection::Property::Write) {
- hs << " inline " << type << " " << getter << "() const" << endl
- << " { return qvariant_cast< " << type << " >(property(\""
- << property.name << "\")); }" << endl;
- }
-
- // setter:
- if (property.access != QDBusIntrospection::Property::Read) {
- hs << " inline void " << setter << "(" << constRefArg(type) << "value)" << endl
- << " { setProperty(\"" << property.name
- << "\", QVariant::fromValue(value)); }" << endl;
- }
-
- hs << endl;
- }
-
- // methods:
- hs << "public Q_SLOTS: // METHODS" << endl;
- foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isDeprecated = method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true");
- bool isNoReply =
- method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
- if (isNoReply && !method.outputArgs.isEmpty()) {
- fprintf(stderr, "warning: method %s in interface %s is marked 'no-reply' but has output arguments.\n",
- qPrintable(method.name), qPrintable(interface->name));
- continue;
- }
-
- hs << " inline "
- << (isDeprecated ? "Q_DECL_DEPRECATED " : "");
-
- if (isNoReply) {
- hs << "Q_NOREPLY void ";
- } else {
- hs << "QDBusPendingReply<";
- for (int i = 0; i < method.outputArgs.count(); ++i)
- hs << (i > 0 ? ", " : "")
- << templateArg(qtTypeName(method.outputArgs.at(i).type, method.annotations, i, "Out"));
- hs << "> ";
- }
-
- hs << method.name << "(";
-
- QStringList argNames = makeArgNames(method.inputArgs);
- writeArgList(hs, argNames, method.annotations, method.inputArgs);
-
- hs << ")" << endl
- << " {" << endl
- << " QList<QVariant> argumentList;" << endl;
-
- if (!method.inputArgs.isEmpty()) {
- hs << " argumentList";
- for (int argPos = 0; argPos < method.inputArgs.count(); ++argPos)
- hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')';
- hs << ";" << endl;
- }
-
- if (isNoReply)
- hs << " callWithArgumentList(QDBus::NoBlock, "
- << "QLatin1String(\"" << method.name << "\"), argumentList);" << endl;
- else
- hs << " return asyncCallWithArgumentList(QLatin1String(\""
- << method.name << "\"), argumentList);" << endl;
-
- // close the function:
- hs << " }" << endl;
-
- if (method.outputArgs.count() > 1) {
- // generate the old-form QDBusReply methods with multiple incoming parameters
- hs << " inline "
- << (isDeprecated ? "Q_DECL_DEPRECATED " : "")
- << "QDBusReply<"
- << templateArg(qtTypeName(method.outputArgs.first().type, method.annotations, 0, "Out")) << "> ";
- hs << method.name << "(";
-
- QStringList argNames = makeArgNames(method.inputArgs, method.outputArgs);
- writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs);
-
- hs << ")" << endl
- << " {" << endl
- << " QList<QVariant> argumentList;" << endl;
-
- int argPos = 0;
- if (!method.inputArgs.isEmpty()) {
- hs << " argumentList";
- for (argPos = 0; argPos < method.inputArgs.count(); ++argPos)
- hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')';
- hs << ";" << endl;
- }
-
- hs << " QDBusMessage reply = callWithArgumentList(QDBus::Block, "
- << "QLatin1String(\"" << method.name << "\"), argumentList);" << endl;
-
- argPos++;
- hs << " if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == "
- << method.outputArgs.count() << ") {" << endl;
-
- // yes, starting from 1
- for (int i = 1; i < method.outputArgs.count(); ++i)
- hs << " " << argNames.at(argPos++) << " = qdbus_cast<"
- << templateArg(qtTypeName(method.outputArgs.at(i).type, method.annotations, i, "Out"))
- << ">(reply.arguments().at(" << i << "));" << endl;
- hs << " }" << endl
- << " return reply;" << endl
- << " }" << endl;
- }
-
- hs << endl;
- }
-
- hs << "Q_SIGNALS: // SIGNALS" << endl;
- foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
- hs << " ";
- if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
- QLatin1String("true"))
- hs << "Q_DECL_DEPRECATED ";
-
- hs << "void " << signal.name << "(";
-
- QStringList argNames = makeArgNames(signal.outputArgs);
- writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
-
- hs << ");" << endl; // finished for header
- }
-
- // close the class:
- hs << "};" << endl
- << endl;
- }
-
- if (!skipNamespaces) {
- QStringList last;
- QDBusIntrospection::Interfaces::ConstIterator it = interfaces.constBegin();
- do
- {
- QStringList current;
- QString name;
- if (it != interfaces.constEnd()) {
- current = it->constData()->name.split(QLatin1Char('.'));
- name = current.takeLast();
- }
-
- int i = 0;
- while (i < current.count() && i < last.count() && current.at(i) == last.at(i))
- ++i;
-
- // i parts matched
- // close last.arguments().count() - i namespaces:
- for (int j = i; j < last.count(); ++j)
- hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << endl;
-
- // open current.arguments().count() - i namespaces
- for (int j = i; j < current.count(); ++j)
- hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << endl;
-
- // add this class:
- if (!name.isEmpty()) {
- hs << QString(current.count() * 2, QLatin1Char(' '))
- << "typedef ::" << classNameForInterface(it->constData()->name, Proxy)
- << " " << name << ";" << endl;
- }
-
- if (it == interfaces.constEnd())
- break;
- ++it;
- last = current;
- } while (true);
- }
-
- // close the include guard
- hs << "#endif" << endl;
-
- QString mocName = moc(filename);
- if (includeMocs && !mocName.isEmpty())
- cs << endl
- << "#include \"" << mocName << "\"" << endl;
-
- cs.flush();
- hs.flush();
-
- QFile file;
- openFile(headerName, file);
- file.write(headerData);
-
- if (headerName == cppName) {
- file.write(cppData);
- } else {
- QFile cppFile;
- openFile(cppName, cppFile);
- cppFile.write(cppData);
- }
-}
-
-static void writeAdaptor(const QString &filename, const QDBusIntrospection::Interfaces &interfaces)
-{
- // open the file
- QString headerName = header(filename);
- QByteArray headerData;
- QTextStream hs(&headerData);
-
- QString cppName = cpp(filename);
- QByteArray cppData;
- QTextStream cs(&cppData);
-
- // write the headers
- writeHeader(hs, false);
- if (cppName != headerName)
- writeHeader(cs, true);
-
- // include guards:
- QString includeGuard;
- if (!headerName.isEmpty() && headerName != QLatin1String("-")) {
- includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
- int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
- if (pos != -1)
- includeGuard = includeGuard.mid(pos + 1);
- } else {
- includeGuard = QLatin1String("QDBUSXML2CPP_ADAPTOR");
- }
- includeGuard = QString(QLatin1String("%1_%2"))
- .arg(includeGuard)
- .arg(QDateTime::currentDateTime().toTime_t());
- hs << "#ifndef " << includeGuard << endl
- << "#define " << includeGuard << endl
- << endl;
-
- // include our stuff:
- hs << "#include <QtCore/QObject>" << endl;
- if (cppName == headerName)
- hs << "#include <QtCore/QMetaObject>" << endl
- << "#include <QtCore/QVariant>" << endl;
- hs << "#include <QtDBus/QtDBus>" << endl;
-
- foreach (QString include, includes) {
- hs << "#include \"" << include << "\"" << endl;
- if (headerName.isEmpty())
- cs << "#include \"" << include << "\"" << endl;
- }
-
- if (cppName != headerName) {
- if (!headerName.isEmpty() && headerName != QLatin1String("-"))
- cs << "#include \"" << headerName << "\"" << endl;
-
- cs << "#include <QtCore/QMetaObject>" << endl
- << includeList
- << endl;
- hs << forwardDeclarations;
- } else {
- hs << includeList;
- }
-
- hs << endl;
-
- QString parent = parentClassName;
- if (parentClassName.isEmpty())
- parent = QLatin1String("QObject");
-
- foreach (const QDBusIntrospection::Interface *interface, interfaces) {
- QString className = classNameForInterface(interface->name, Adaptor);
-
- // comment:
- hs << "/*" << endl
- << " * Adaptor class for interface " << interface->name << endl
- << " */" << endl;
- cs << "/*" << endl
- << " * Implementation of adaptor class " << className << endl
- << " */" << endl
- << endl;
-
- // class header:
- hs << "class " << className << ": public QDBusAbstractAdaptor" << endl
- << "{" << endl
- << " Q_OBJECT" << endl
- << " Q_CLASSINFO(\"D-Bus Interface\", \"" << interface->name << "\")" << endl
- << " Q_CLASSINFO(\"D-Bus Introspection\", \"\"" << endl
- << stringify(interface->introspection)
- << " \"\")" << endl
- << "public:" << endl
- << " " << className << "(" << parent << " *parent);" << endl
- << " virtual ~" << className << "();" << endl
- << endl;
-
- if (!parentClassName.isEmpty())
- hs << " inline " << parent << " *parent() const" << endl
- << " { return static_cast<" << parent << " *>(QObject::parent()); }" << endl
- << endl;
-
- // constructor/destructor
- cs << className << "::" << className << "(" << parent << " *parent)" << endl
- << " : QDBusAbstractAdaptor(parent)" << endl
- << "{" << endl
- << " // constructor" << endl
- << " setAutoRelaySignals(true);" << endl
- << "}" << endl
- << endl
- << className << "::~" << className << "()" << endl
- << "{" << endl
- << " // destructor" << endl
- << "}" << endl
- << endl;
-
- hs << "public: // PROPERTIES" << endl;
- foreach (const QDBusIntrospection::Property &property, interface->properties) {
- QByteArray type = qtTypeName(property.type, property.annotations);
- QString constRefType = constRefArg(type);
- QString getter = propertyGetter(property);
- QString setter = propertySetter(property);
-
- hs << " Q_PROPERTY(" << type << " " << property.name;
- if (property.access != QDBusIntrospection::Property::Write)
- hs << " READ " << getter;
- if (property.access != QDBusIntrospection::Property::Read)
- hs << " WRITE " << setter;
- hs << ")" << endl;
-
- // getter:
- if (property.access != QDBusIntrospection::Property::Write) {
- hs << " " << type << " " << getter << "() const;" << endl;
- cs << type << " "
- << className << "::" << getter << "() const" << endl
- << "{" << endl
- << " // get the value of property " << property.name << endl
- << " return qvariant_cast< " << type <<" >(parent()->property(\"" << property.name << "\"));" << endl
- << "}" << endl
- << endl;
- }
-
- // setter
- if (property.access != QDBusIntrospection::Property::Read) {
- hs << " void " << setter << "(" << constRefType << "value);" << endl;
- cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << endl
- << "{" << endl
- << " // set the value of property " << property.name << endl
- << " parent()->setProperty(\"" << property.name << "\", QVariant::fromValue(value";
- if (constRefType.contains(QLatin1String("QDBusVariant")))
- cs << ".variant()";
- cs << "));" << endl
- << "}" << endl
- << endl;
- }
-
- hs << endl;
- }
-
- hs << "public Q_SLOTS: // METHODS" << endl;
- foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isNoReply =
- method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
- if (isNoReply && !method.outputArgs.isEmpty()) {
- fprintf(stderr, "warning: method %s in interface %s is marked 'no-reply' but has output arguments.\n",
- qPrintable(method.name), qPrintable(interface->name));
- continue;
- }
-
- hs << " ";
- if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
- QLatin1String("true"))
- hs << "Q_DECL_DEPRECATED ";
-
- QByteArray returnType;
- if (isNoReply) {
- hs << "Q_NOREPLY void ";
- cs << "void ";
- } else if (method.outputArgs.isEmpty()) {
- hs << "void ";
- cs << "void ";
- } else {
- returnType = qtTypeName(method.outputArgs.first().type, method.annotations, 0, "Out");
- hs << returnType << " ";
- cs << returnType << " ";
- }
-
- QString name = method.name;
- hs << name << "(";
- cs << className << "::" << name << "(";
-
- QStringList argNames = makeArgNames(method.inputArgs, method.outputArgs);
- writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs);
- writeArgList(cs, argNames, method.annotations, method.inputArgs, method.outputArgs);
-
- hs << ");" << endl; // finished for header
- cs << ")" << endl
- << "{" << endl
- << " // handle method call " << interface->name << "." << method.name << endl;
-
- // make the call
- bool usingInvokeMethod = false;
- if (parentClassName.isEmpty() && method.inputArgs.count() <= 10
- && method.outputArgs.count() <= 1)
- usingInvokeMethod = true;
-
- if (usingInvokeMethod) {
- // we are using QMetaObject::invokeMethod
- if (!returnType.isEmpty())
- cs << " " << returnType << " " << argNames.at(method.inputArgs.count())
- << ";" << endl;
-
- static const char invoke[] = " QMetaObject::invokeMethod(parent(), \"";
- cs << invoke << name << "\"";
-
- if (!method.outputArgs.isEmpty())
- cs << ", Q_RETURN_ARG("
- << qtTypeName(method.outputArgs.at(0).type, method.annotations,
- 0, "Out")
- << ", "
- << argNames.at(method.inputArgs.count())
- << ")";
-
- for (int i = 0; i < method.inputArgs.count(); ++i)
- cs << ", Q_ARG("
- << qtTypeName(method.inputArgs.at(i).type, method.annotations,
- i, "In")
- << ", "
- << argNames.at(i)
- << ")";
-
- cs << ");" << endl;
-
- if (!returnType.isEmpty())
- cs << " return " << argNames.at(method.inputArgs.count()) << ";" << endl;
- } else {
- if (parentClassName.isEmpty())
- cs << " //";
- else
- cs << " ";
-
- if (!method.outputArgs.isEmpty())
- cs << "return ";
-
- if (parentClassName.isEmpty())
- cs << "static_cast<YourObjectType *>(parent())->";
- else
- cs << "parent()->";
- cs << name << "(";
-
- int argPos = 0;
- bool first = true;
- for (int i = 0; i < method.inputArgs.count(); ++i) {
- cs << (first ? "" : ", ") << argNames.at(argPos++);
- first = false;
- }
- ++argPos; // skip retval, if any
- for (int i = 1; i < method.outputArgs.count(); ++i) {
- cs << (first ? "" : ", ") << argNames.at(argPos++);
- first = false;
- }
-
- cs << ");" << endl;
- }
- cs << "}" << endl
- << endl;
- }
-
- hs << "Q_SIGNALS: // SIGNALS" << endl;
- foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
- hs << " ";
- if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
- QLatin1String("true"))
- hs << "Q_DECL_DEPRECATED ";
-
- hs << "void " << signal.name << "(";
-
- QStringList argNames = makeArgNames(signal.outputArgs);
- writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
-
- hs << ");" << endl; // finished for header
- }
-
- // close the class:
- hs << "};" << endl
- << endl;
- }
-
- // close the include guard
- hs << "#endif" << endl;
-
- QString mocName = moc(filename);
- if (includeMocs && !mocName.isEmpty())
- cs << endl
- << "#include \"" << mocName << "\"" << endl;
-
- cs.flush();
- hs.flush();
-
- QFile file;
- openFile(headerName, file);
- file.write(headerData);
-
- if (headerName == cppName) {
- file.write(cppData);
- } else {
- QFile cppFile;
- openFile(cppName, cppFile);
- cppFile.write(cppData);
- }
-}
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
- parseCmdLine(app.arguments());
-
- QDBusIntrospection::Interfaces interfaces = readInput();
- cleanInterfaces(interfaces);
-
- if (!proxyFile.isEmpty() || adaptorFile.isEmpty())
- writeProxy(proxyFile, interfaces);
-
- if (!adaptorFile.isEmpty())
- writeAdaptor(adaptorFile, interfaces);
-
- return 0;
-}
-
-/*!
- \page qdbusxml2cpp.html
- \title QtDBus XML compiler (qdbusxml2cpp)
- \keyword qdbusxml2cpp
-
- The QtDBus XML compiler is a tool that can be used to parse interface descriptions and produce
- static code representing those interfaces, which can then be used to make calls to remote
- objects or implement said interfaces.
-
- \c qdbusxml2cpp has two modes of operation, that correspond to the two possible outputs it can
- produce: the interface (proxy) class or the adaptor class. The latter consists of both a C++
- header and a source file, which are meant to be edited and adapted to your needs.
-
- The \c qdbusxml2cpp tool is not meant to be run every time you compile your
- application. Instead, it's meant to be used when developing the code or when the interface
- changes.
-
- The adaptor classes generated by \c qdbusxml2cpp are just a skeleton that must be completed. It
- generates, by default, calls to slots with the same name on the object the adaptor is attached
- to. However, you may modify those slots or the property accessor functions to suit your needs.
-*/
diff --git a/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.pro b/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.pro
deleted file mode 100644
index 2324e2d59..000000000
--- a/src/qdbus/qdbusxml2cpp/qdbusxml2cpp.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-SOURCES = qdbusxml2cpp.cpp
-DESTDIR = $$QT.designer.bins
-TARGET = qdbusxml2cpp
-QT = core dbus-private
-CONFIG -= app_bundle
-win32:CONFIG += console
-
-target.path=$$[QT_INSTALL_BINS]
-INSTALLS += target
diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt
index 28019680b..b7e11d64b 100644
--- a/tests/manual/cmake/CMakeLists.txt
+++ b/tests/manual/cmake/CMakeLists.txt
@@ -66,6 +66,5 @@ macro(expect_fail _dir)
)
endmacro()
-expect_pass(pass1)
expect_pass(pass2)
diff --git a/tests/manual/cmake/pass1/CMakeLists.txt b/tests/manual/cmake/pass1/CMakeLists.txt
deleted file mode 100644
index 2220db484..000000000
--- a/tests/manual/cmake/pass1/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-
-cmake_minimum_required(VERSION 2.8)
-
-project(pass1)
-
-find_package(Qt5Core REQUIRED)
-find_package(Qt5DBus REQUIRED)
-find_package(Qt5DBusTools REQUIRED)
-
-include_directories(
- ${Qt5Core_INCLUDE_DIRS}
- ${Qt5DBus_INCLUDE_DIRS}
-)
-
-add_definitions(${Qt5DBus_DEFINITIONS})
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(my_srcs mydbusobject.cpp)
-
-qt5_wrap_cpp(moc_files mydbusobject.h)
-
-qt5_generate_dbus_interface(
- mydbusobject.h
- ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml
-)
-
-qt5_add_dbus_adaptor(my_srcs
- ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml
- mydbusobject.h
- MyDBusObject
-)
-
-add_executable(myobject ${my_srcs} ${moc_files})
-target_link_libraries(myobject ${Qt5DBus_LIBRARIES})
diff --git a/tests/manual/cmake/pass1/mydbusobject.cpp b/tests/manual/cmake/pass1/mydbusobject.cpp
deleted file mode 100644
index ee211bbe9..000000000
--- a/tests/manual/cmake/pass1/mydbusobject.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mydbusobject.h"
-#include "mydbusobjectadaptor.h"
-
-MyDBusObject::MyDBusObject(QObject *parent)
- : QObject(parent)
-{
- new MyDBusObjectAdaptor(this);
- emit someSignal();
-}
-
-int main(int argc, char **argv)
-{
- MyDBusObject myDBusObject;
- return 0;
-}
diff --git a/tests/manual/cmake/pass1/mydbusobject.h b/tests/manual/cmake/pass1/mydbusobject.h
deleted file mode 100644
index dd9a023ff..000000000
--- a/tests/manual/cmake/pass1/mydbusobject.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MYDBUSOBJECT_H
-#define MYDBUSOBJECT_H
-
-#include <QObject>
-
-class MyDBusObject : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.qtProject.Tests.MyDBusObject")
-public:
- MyDBusObject(QObject *parent = 0);
-
-signals:
- void someSignal();
-};
-
-#endif