Mercurial > projects > qtd
changeset 35:5917a613d118
wrapping of QtXml
author | eldar |
---|---|
date | Sat, 16 May 2009 20:47:44 +0000 |
parents | 17cc45b32686 |
children | 0f7c514f076e |
files | CMakeLists.txt Makefile generator/build_xml.txt generator/containergenerator.cpp generator/cppimplgenerator.cpp generator/dgenerator.cpp generator/typesystem_xml-common.xml generator/typesystem_xml-java.java generator/typesystem_xml-java.xml generator/typesystem_xml.xml include/ArrayOpsPrimitive.h include/qtd_core.h |
diffstat | 12 files changed, 154 insertions(+), 85 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Sat May 16 18:06:25 2009 +0000 +++ b/CMakeLists.txt Sat May 16 20:47:44 2009 +0000 @@ -12,7 +12,7 @@ option(BUILD_EXAMPLES "Build examples" "ON") option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") -set(all_packages Core Gui OpenGL) ## TODO: Loading. +set(all_packages Core Xml) ## TODO: Loading. ## Strip utility.
--- a/Makefile Sat May 16 18:06:25 2009 +0000 +++ b/Makefile Sat May 16 20:47:44 2009 +0000 @@ -53,7 +53,7 @@ NAME_PREFIX = qtd endif ifndef $(PACKAGES) -PACKAGES = core gui opengl +PACKAGES = core gui opengl xml endif LIB_PREFIX = lib CC_INCLUDE += include $(QTDIR_INC) $(QTDIR_INC)$(SL)Qt $(QTDIR_INC)$(SL)QtCore $(QTDIR_INC)$(SL)QtGui $(QTDIR_INC)$(SL)QtOpenGL $(QTDIR_INC)$(SL)QtSvg @@ -135,7 +135,7 @@ cd generator && qmake && $(MAKE) dgen: make_gen - cd generator && $(GEN) $(GEN_OPT) --d-target=$(D_TARGET) --output-directory=../ qtjambi_masterinclude.h build_opengl.txt + cd generator && $(GEN) $(GEN_OPT) --d-target=$(D_TARGET) --output-directory=../ qtjambi_masterinclude.h build_xml.txt ## DGenerator ## end mkdir:
--- a/generator/build_xml.txt Sat May 16 18:06:25 2009 +0000 +++ b/generator/build_xml.txt Sat May 16 20:47:44 2009 +0000 @@ -1,4 +1,6 @@ <typesystem> - <load-typesystem name="typesystem_core.xml" generate="no" /> + <load-typesystem name="typesystem_core.xml" generate="yes" /> <load-typesystem name="typesystem_xml.xml" generate="yes" /> + <load-typesystem name="typesystem_gui.xml" generate="yes" /> + <load-typesystem name="typesystem_opengl.xml" generate="yes" /> </typesystem>
--- a/generator/containergenerator.cpp Sat May 16 18:06:25 2009 +0000 +++ b/generator/containergenerator.cpp Sat May 16 20:47:44 2009 +0000 @@ -232,7 +232,11 @@ void ContainerGenerator::writeHeaderContent(QTextStream &s, AbstractMetaClass *cls) { - s << "#include <cstring>" << endl + QString file_upper = "ArrayOps_" + QString(cls->package()).replace(".", "_") + "_h"; + file_upper = file_upper.toUpper(); + s << "#ifndef " << file_upper << endl + << "#define " << file_upper << endl << endl + << "#include <cstring>" << endl << "#include \"qtd_core.h\"" << endl << endl; foreach (const TypeEntry *te, containerTypes) { @@ -244,6 +248,8 @@ writeHeaderArrayFunctions(s, typeEntry); } } + + s << "#endif // " << file_upper << endl; } void ContainerGenerator::setFuncNames(const QString& cls_name)
--- a/generator/cppimplgenerator.cpp Sat May 16 18:06:25 2009 +0000 +++ b/generator/cppimplgenerator.cpp Sat May 16 20:47:44 2009 +0000 @@ -598,6 +598,9 @@ if (java_class->package() == "qt.gui") s << "#include \"ArrayOps_qt_gui.h\"" << endl; + QString pkg_name = QString(java_class->package()).replace(".", "_"); + s << QString("#include \"ArrayOps_%1.h\"").arg(pkg_name) << endl; + s << endl; writeInterfaceCasts(s, java_class); @@ -1921,9 +1924,12 @@ if (nativeArgCount > 0) s << "," << endl << " "; // if QString argument we have to pass DArrat - if ((te && te->qualifiedCppName() == "QString") || d_type->isTargetLangString()) - s << "string " << arg_name; - else if (d_type->isContainer()) { + if ((te && te->qualifiedCppName() == "QString") || d_type->isTargetLangString()) { + if (d_export) + s << "string " << arg_name; + else + s << "DArray " << arg_name; + } else if (d_type->isContainer()) { const ContainerTypeEntry *cte = static_cast<const ContainerTypeEntry *>(te); if(isLinearContainer(cte)) @@ -3023,11 +3029,17 @@ << " = new QVariant(" << qt_name << ");" << endl; } else if (java_type->isTargetLangString()) { - -// if (option & BoxedPrimitive) - s << INDENT << "_d_toUtf8(" << qt_name << ".utf16(), " - << qt_name << ".size(), " << java_name << ");" << endl; - + if(java_type->typeEntry()->qualifiedCppName() == "QStringRef") { + s << INDENT << "const QString *str_ref = " << qt_name << ".string();" << endl + << INDENT << "if(str_ref)" << endl + << INDENT << " _d_toUtf8(str_ref->utf16(), str_ref->size(), " << java_name << ");" << endl + << INDENT << "else {" << endl + << INDENT << " QString empty_str;" << endl + << INDENT << " _d_toUtf8(empty_str.utf16(), empty_str.size(), " << java_name << ");" << endl + << INDENT << "}" << endl; + } else { + s << INDENT << QString("_d_toUtf8(%1.utf16(), %1.size(), %2);").arg(qt_name, java_name) << endl; + } } else if (java_type->isTargetLangChar()) { s << INDENT << "jchar " << java_name << " = " << qt_name << ".unicode();" << endl; @@ -3381,7 +3393,7 @@ { Indentation indent(INDENT); if(targ->isTargetLangString()) - s << INDENT << "string __d_element;" << endl + s << INDENT << "DArray __d_element;" << endl << INDENT << "qtd_get_string_from_array(" << java_name << ", i, &__d_element);" << endl; else { s << INDENT;
--- a/generator/dgenerator.cpp Sat May 16 18:06:25 2009 +0000 +++ b/generator/dgenerator.cpp Sat May 16 20:47:44 2009 +0000 @@ -72,7 +72,7 @@ << "signed short" << "Array" << "GLuint" << "GLenum" << "GLint" << "unsigned long" << "ulong" << "long" << "QByteRef" << "QStringList" << "QList" << "QVector" << "QPair" - << "QSet"; + << "QSet" << "QStringRef"; } QString DGenerator::fileNameForClass(const AbstractMetaClass *d_class) const @@ -3238,7 +3238,7 @@ } } else - s << INDENT << "super(__qt_return_value);" << endl; + s << INDENT << "this(__qt_return_value);" << endl; } s << INDENT << "}" << endl << endl;
--- a/generator/typesystem_xml-common.xml Sat May 16 18:06:25 2009 +0000 +++ b/generator/typesystem_xml-common.xml Sat May 16 20:47:44 2009 +0000 @@ -41,12 +41,17 @@ </modify-argument> </modify-function> - <modify-function signature="setContent(QXmlInputSource*,QXmlReader*,QString*,int*,int*)"> <modify-argument index="1"> <reference-count action="set" variable-name="__rcContent" /> </modify-argument> </modify-function> + + <modify-function signature="setContent(QXmlInputSource*,bool,QString*,int*,int*)"> + <modify-argument index="1"> + <reference-count action="set" variable-name="__rcContent" /> + </modify-argument> + </modify-function> <modify-function signature="setContent(QIODevice*,QString*,int*,int*)"> <modify-argument index="1"> @@ -132,6 +137,9 @@ <modify-function signature="value(const QLatin1String &)const"> <remove /> </modify-function> + <modify-function signature="hasAttribute(const QLatin1String &)const"> + <remove /> + </modify-function> </value-type> <value-type name="QXmlStreamNamespaceDeclaration">
--- a/generator/typesystem_xml-java.java Sat May 16 18:06:25 2009 +0000 +++ b/generator/typesystem_xml-java.java Sat May 16 20:47:44 2009 +0000 @@ -1,37 +1,38 @@ /**************************************************************************** ** -** Copyright (C) 1992-2008 Nokia. All rights reserved. +** Copyright (C) 1992-2009 Nokia. All rights reserved. ** ** This file is part of Qt Jambi. ** -** * Commercial Usage -* Licensees holding valid Qt Commercial licenses may use this file in -* accordance with the Qt Commercial License Agreement provided with the -* Software or, alternatively, in accordance with the terms contained in -* a written agreement between you and Nokia. -* -* -* GNU General Public License Usage -* Alternatively, this file may be used under the terms of the GNU -* General Public License versions 2.0 or 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 GNU General Public Licensing requirements will be met: -* http://www.fsf.org/licensing/licenses/info/GPLv2.html and -* http://www.gnu.org/copyleft/gpl.html. In addition, as a special -* exception, Nokia gives you certain additional rights. These rights -* are described in the Nokia Qt GPL Exception version 1.2, included in -* the file GPL_EXCEPTION.txt in this package. -* -* Qt for Windows(R) Licensees -* As a special exception, Nokia, as the sole copyright holder for Qt -* Designer, grants users of the Qt/Eclipse Integration plug-in the -* right for the Qt/Eclipse Integration to link to functionality -* provided by Qt Designer and its related libraries. -* -* -* If you are unsure which license is appropriate for your use, please -* contact the sales department at qt-sales@nokia.com. +** Commercial Usage +Licensees holding valid Qt Commercial licenses may use this file in +accordance with the Qt Commercial License Agreement provided with the +Software or, alternatively, in accordance with the terms contained in +a written agreement between you and Nokia. + +GNU Lesser General Public License Usage +Alternatively, 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.0, 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. + +If you are unsure which license is appropriate for your use, please +contact the sales department at qt-sales@nokia.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE @@ -41,8 +42,8 @@ package generator; -import qt.*; -import qt.xml.*; +import com.trolltech.qt.*; +import com.trolltech.qt.xml.*; class QDomDocument___ extends QDomDocument { @@ -61,6 +62,17 @@ } + public final Result setContent(QXmlInputSource source, boolean namespaceProcessing) + { + QNativePointer errorStr = new QNativePointer(QNativePointer.Type.String); + QNativePointer errorLine = new QNativePointer(QNativePointer.Type.Int); + QNativePointer errorColumn = new QNativePointer(QNativePointer.Type.Int); + + boolean success = setContent(source, namespaceProcessing, errorStr, errorLine, errorColumn); + + return new Result(success, errorStr, errorLine, errorColumn); + } + }// class class QXmlNamespaceSupport___ extends QXmlNamespaceSupport { @@ -105,7 +117,7 @@ class QXmlStreamWriter___ extends QXmlStreamWriter { - public QXmlStreamWriter(qt.core.QByteArray array) { + public QXmlStreamWriter(com.trolltech.qt.core.QByteArray array) { this(array.nativePointer()); __rcDevice = array; } @@ -134,3 +146,5 @@ } }// class + +
--- a/generator/typesystem_xml-java.xml Sat May 16 18:06:25 2009 +0000 +++ b/generator/typesystem_xml-java.xml Sat May 16 20:47:44 2009 +0000 @@ -1,7 +1,7 @@ <?xml version="1.0"?> -<typesystem package="qt.xml" default-superclass="qt.QtJambiObject"> +<typesystem package="com.trolltech.qt.xml" default-superclass="com.trolltech.qt.QtJambiObject"> <inject-code> - qt.Utilities.loadQtLibrary("QtXml"); + com.trolltech.qt.Utilities.loadQtLibrary("QtXml"); </inject-code> @@ -10,9 +10,9 @@ <import-file name="typesystem_xml-java.java" quote-after-line="class QDomDocument___" quote-before-line="}// class"/> </inject-code> <extra-includes> - <include file-name="qt.QNativePointer.Type" location="java"/> - <include file-name="qt.core.QIODevice" location="java"/> - <include file-name="qt.core.QByteArray" location="java"/> + <include file-name="com.trolltech.qt.QNativePointer.Type" location="java"/> + <include file-name="com.trolltech.qt.core.QIODevice" location="java"/> + <include file-name="com.trolltech.qt.core.QByteArray" location="java"/> </extra-includes> @@ -28,6 +28,20 @@ } </template> + + <modify-function signature="setContent(QXmlInputSource*,bool,QString*,int*,int*)"> + <access modifier="private" /> + <modify-argument index="3"> + <remove-default-expression /> + </modify-argument> + <modify-argument index="4"> + <remove-default-expression /> + </modify-argument> + <modify-argument index="5"> + <remove-default-expression /> + </modify-argument> + </modify-function> + <!--bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 ); --> <modify-function signature="setContent(QIODevice*, bool, QString*, int*, int*)"> <access modifier="private"/> @@ -174,7 +188,7 @@ <import-file name="typesystem_xml-java.java" quote-after-line="class QXmlNamespaceSupport___" quote-before-line="}// class"/> </inject-code> <extra-includes> - <include file-name="qt.QNativePointer" location="java"/> + <include file-name="com.trolltech.qt.QNativePointer" location="java"/> </extra-includes> <modify-function signature="processName(QString,bool,QString&,QString&)const"> <access modifier="private"/> @@ -329,7 +343,7 @@ </conversion-rule> </modify-argument> <modify-argument index="return"> - <replace-type modified-type="qt.xml.QXmlEntityResolver$ResolvedEntity" /> + <replace-type modified-type="com.trolltech.qt.xml.QXmlEntityResolver$ResolvedEntity" /> <conversion-rule class="native"> jobject %out = qtjambi_to_resolvedentity(__jni_env, %in, inputSourceHolder); </conversion-rule>
--- a/generator/typesystem_xml.xml Sat May 16 18:06:25 2009 +0000 +++ b/generator/typesystem_xml.xml Sat May 16 20:47:44 2009 +0000 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="merge.xsl"?> -<typesystem package="qt.xml" default-superclass="qt.QtJambiObject"> +<typesystem package="qt.xml" default-superclass="QtDObject"> <inject-code> - qt.Utilities.loadQtLibrary("QtXml"); + com.trolltech.qt.Utilities.loadQtLibrary("QtXml"); </inject-code> <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QDomNodeList' has equals operators but no qHash() function"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamNamespaceDeclaration' has equals operators but no qHash() function"/> @@ -55,12 +55,17 @@ </modify-argument> </modify-function> - <modify-function signature="setContent(QXmlInputSource*,QXmlReader*,QString*,int*,int*)"> <modify-argument index="1"> <reference-count action="set" variable-name="__rcContent"/> </modify-argument> </modify-function> + + <modify-function signature="setContent(QXmlInputSource*,bool,QString*,int*,int*)"> + <modify-argument index="1"> + <reference-count action="set" variable-name="__rcContent"/> + </modify-argument> + </modify-function> <modify-function signature="setContent(QIODevice*,QString*,int*,int*)"> <modify-argument index="1"> @@ -68,16 +73,10 @@ </modify-argument> </modify-function> - +<!-- <inject-code> <import-file name="typesystem_xml-java.java" quote-after-line="class QDomDocument___" quote-before-line="}// class"/> </inject-code> - <extra-includes> - <include file-name="qt.QNativePointer.Type" location="java"/> - <include file-name="qt.core.QIODevice" location="java"/> - <include file-name="qt.core.QByteArray" location="java"/> - </extra-includes> - <template name="xml.domdocument_setContent"> @@ -91,8 +90,22 @@ } </template> + + <modify-function signature="setContent(QXmlInputSource*,bool,QString*,int*,int*)"> + <access modifier="private"/> + <modify-argument index="3"> + <remove-default-expression/> + </modify-argument> + <modify-argument index="4"> + <remove-default-expression/> + </modify-argument> + <modify-argument index="5"> + <remove-default-expression/> + </modify-argument> + </modify-function> +--> <!--bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 ); --> - <modify-function signature="setContent(QIODevice*, bool, QString*, int*, int*)"> +<!-- <modify-function signature="setContent(QIODevice*, bool, QString*, int*, int*)"> <access modifier="private"/> <modify-argument index="3"> <remove-default-expression/> @@ -110,9 +123,9 @@ <replace from="%CALL_ARGUMENTS" to="dev, namespaceProcessing"/> </insert-template> </inject-code> - +--> <!--bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 ); --> - <modify-function signature="setContent(QByteArray, bool, QString*, int*, int*)"> +<!-- <modify-function signature="setContent(QByteArray, bool, QString*, int*, int*)"> <access modifier="private"/> <modify-argument index="3"> <remove-default-expression/> @@ -131,9 +144,9 @@ <replace from="%CALL_ARGUMENTS" to="text, namespaceProcessing"/> </insert-template> </inject-code> - +--> <!--bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 );--> - <modify-function signature="setContent(QString, bool, QString*, int*, int*)"> +<!-- <modify-function signature="setContent(QString, bool, QString*, int*, int*)"> <access modifier="private"/> <modify-argument index="3"> <remove-default-expression/> @@ -227,7 +240,7 @@ <replace from="%CALL_ARGUMENTS" to="dev"/> </insert-template> </inject-code> - +--> </value-type> <value-type name="QDomDocumentFragment"> @@ -306,6 +319,9 @@ <modify-function signature="value(const QLatin1String &)const"> <remove/> </modify-function> + <modify-function signature="hasAttribute(const QLatin1String &)const"> + <remove/> + </modify-function> </value-type> <value-type name="QXmlStreamNamespaceDeclaration"> @@ -330,7 +346,7 @@ </value-type> <value-type name="QXmlNamespaceSupport"> - <custom-constructor> +<!-- <custom-constructor> QXmlNamespaceSupport *clone = new QXmlNamespaceSupport; clone->setPrefix("", copy->uri("")); @@ -349,9 +365,6 @@ <inject-code> <import-file name="typesystem_xml-java.java" quote-after-line="class QXmlNamespaceSupport___" quote-before-line="}// class"/> </inject-code> - <extra-includes> - <include file-name="qt.QNativePointer" location="java"/> - </extra-includes> <modify-function signature="processName(QString,bool,QString&,QString&)const"> <access modifier="private"/> </modify-function> @@ -360,7 +373,7 @@ <modify-function signature="splitName(QString,QString&,QString&)const"> <access modifier="private"/> </modify-function> - +--> </value-type> <value-type name="QDomElement"> @@ -381,7 +394,7 @@ </modify-function> - +<!-- <template name="xml.constQString_to_constQStringRef"> QString %out = qtjambi_to_qstring(__jni_env, (jstring) %in); </template> @@ -435,7 +448,7 @@ </conversion-rule> </modify-argument> </modify-function> - +--> </value-type> <interface-type name="QXmlContentHandler"> @@ -448,7 +461,7 @@ <interface-type name="QXmlDTDHandler"/> <interface-type name="QXmlDeclHandler"/> <interface-type name="QXmlEntityResolver"> - <inject-code> +<!-- <inject-code> <import-file name="typesystem_xml-java.java" quote-after-line="interface QXmlEntityResolver___" quote-before-line="}// class"/> </inject-code> <modify-function signature="resolveEntity(QString,QString,QXmlInputSource&*)"> @@ -463,7 +476,7 @@ </conversion-rule> </modify-argument> <modify-argument index="return"> - <replace-type modified-type="qt.xml.QXmlEntityResolver$ResolvedEntity"/> + <replace-type modified-type="com.trolltech.qt.xml.QXmlEntityResolver$ResolvedEntity"/> <conversion-rule class="native"> jobject %out = qtjambi_to_resolvedentity(__jni_env, %in, inputSourceHolder); </conversion-rule> @@ -472,7 +485,7 @@ </conversion-rule> </modify-argument> </modify-function> - +--> </interface-type> <interface-type name="QXmlErrorHandler"/> <interface-type name="QXmlLexicalHandler"/> @@ -547,7 +560,7 @@ <modify-function signature="QXmlStreamWriter(QString *)"> <remove/> </modify-function> - +<!-- <inject-code> <import-file name="typesystem_xml-java.java" quote-after-line="class QXmlStreamWriter___" quote-before-line="}// class"/> </inject-code> @@ -569,6 +582,7 @@ <reference-count action="set" variable-name="__rcDevice"/> </modify-argument> </modify-function> + --> </object-type> <object-type name="QXmlReader">
--- a/include/ArrayOpsPrimitive.h Sat May 16 18:06:25 2009 +0000 +++ b/include/ArrayOpsPrimitive.h Sat May 16 20:47:44 2009 +0000 @@ -33,7 +33,7 @@ QTD_EXPORT(void, qtd_allocate_string_array, (void* arr, size_t len)) QTD_EXPORT(void, qtd_assign_string_array_element, (void* arr, size_t pos, void* elem)) QTD_EXPORT(void*, qtd_string_from_array, (void* arr, size_t pos)) -QTD_EXPORT(void, qtd_get_string_from_array, (void* arr, size_t pos, string* elem)) +QTD_EXPORT(void, qtd_get_string_from_array, (void* arr, size_t pos, DArray* elem)) #ifdef CPP_SHARED