summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-08-28 07:11:38 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-08-28 12:10:19 +0200
commitb1ed95b6672c68c518d26c8f87235d2b79aac979 (patch)
treea286a2eac0af5a7fac23c23540692d4b2dfff5cf /scripts
parent6b1e101afe6398472b135529436024eed8a4cd19 (diff)
Add new generation templates
Change-Id: Icb6f345e488e512a62d36d1f7c49331daa4ac7a5 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-class.pl15
-rw-r--r--scripts/templates/class.cpp54
-rw-r--r--scripts/templates/class_p.h (renamed from scripts/templates/class.h)58
-rw-r--r--scripts/templates/common.tmpl4
-rw-r--r--scripts/templates/module.pri7
-rw-r--r--scripts/templates/module.pro2
-rw-r--r--scripts/templates/qclass.cpp156
-rw-r--r--scripts/templates/qclass.h148
-rwxr-xr-xscripts/xmi2qt.pl2
9 files changed, 366 insertions, 80 deletions
diff --git a/scripts/generate-class.pl b/scripts/generate-class.pl
index a9ab7a86..51b81627 100755
--- a/scripts/generate-class.pl
+++ b/scripts/generate-class.pl
@@ -62,13 +62,26 @@ binmode STDOUT, ':utf8';
foreach my $class ($classset->get_nodelist) {
my $className = $class->findvalue('@name');
open STDOUT, '>', $options{o}."/".$namespace."/q".lc($namespace).lc($className).".h";
- if ($tt->process('class.h', {
+ if ($tt->process('qclass.h', {
xmi => $options{i},
namespace => $namespace,
className => $className
}) ne 1) { print $tt->error(); }
close STDOUT;
open STDOUT, '>', $options{o}."/".$namespace."/q".lc($namespace).lc($className).".cpp";
+ if ($tt->process('qclass.cpp', {
+ xmi => $options{i},
+ namespace => $namespace,
+ className => $className
+ }) ne 1) { print $tt->error(); }
+ open STDOUT, '>', $options{o}."/".$namespace."/internal/".lc($namespace).lc($className)."_p.h";
+ if ($tt->process('class_p.h', {
+ xmi => $options{i},
+ namespace => $namespace,
+ className => $className
+ }) ne 1) { print $tt->error(); }
+ close STDOUT;
+ open STDOUT, '>', $options{o}."/".$namespace."/internal/".lc($namespace).lc($className).".cpp";
if ($tt->process('class.cpp', {
xmi => $options{i},
namespace => $namespace,
diff --git a/scripts/templates/class.cpp b/scripts/templates/class.cpp
index e1609a13..3e0f1b61 100644
--- a/scripts/templates/class.cpp
+++ b/scripts/templates/class.cpp
@@ -39,37 +39,34 @@
** \$QT_END_LICENSE\$
**
****************************************************************************/
-#include "q${namespace.lower}${className.lower}.h"
-#include "private/qmodelingobject_p.h"
+#include "${namespace.lower}${className.lower}_p.h"
[%- superclasses = [] -%]
[%- SET generalization = class.findnodes("generalization") -%]
[%- FOREACH superclass IN generalization -%]
-[%- superclasses.push("Q${namespace}${superclass.findvalue('@general')}") -%]
+[%- superclasses.push("${namespace}${superclass.findvalue('@general')}") -%]
[%- END -%]
[%- forwards = [] -%]
[%- FOREACH forward = class.findnodes("ownedAttribute[@type] | ownedOperation/ownedParameter[@type]") -%]
[%- SET forwardName = forward.findvalue('@type') -%]
[%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$forwardName']").findvalue("@name") == "" -%]
-[%- IF forwardName != className && superclasses.grep("^Q${namespace}${forwardName}\$").size == 0 -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%]
+[%- IF forwardName != className && superclasses.grep("^${namespace}${forwardName}\$").size == 0 -%][%- forwards.push("${namespace}${forwardName}") -%][%- END -%]
[%- END -%]
[%- END -%]
[%- FOREACH forward = forwards.unique.sort -%]
[%- IF loop.first %]
[% END %]
-#include <Qt${namespace}/${forward}>
+#include "private/${forward.lower}_p.h"
[%- END %]
-QT_BEGIN_NAMESPACE
-
/*!
- \class Q${namespace}${className}
+ \class ${namespace}${className}
\inmodule Qt${namespace}
\brief ${class.findvalue("ownedComment/body/text()")}
*/
-Q${namespace}${className}::Q${namespace}${className}()
+${namespace}${className}::${namespace}${className}()
[%- SET found = "false" -%]
[%- FOREACH attribute = class.findnodes("ownedAttribute[(@isDerived=\"false\" or not(@isDerived)) or (@isDerivedUnion and @isDerivedUnion=\"true\")]") -%]
[%- SET defaultType = attribute.findvalue("defaultValue/@xmi:type") -%]
@@ -109,23 +106,6 @@ Q${namespace}${className}::Q${namespace}${className}()
[%- END -%]
[%- END %]
{
-[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
- [%- SET defaultValue = attribute.findvalue("defaultValue/@value") -%]
- [%- SET defaultInstance = attribute.findvalue("defaultValue/@instance") -%]
- [%- SET type = QT_TYPE(namespace, attribute) -%]
- [%- SET derived = attribute.findvalue("@isDerived") -%]
- [%- SET derivedUnion = attribute.findvalue("@isDerivedUnion") %]
- d_ptr->object.setProperty("${attribute.findvalue("@name").remove("^Is").lcfirst}", QVariant::fromValue(
-[%- IF type.match("QList|QSet") -%][% IF derived == "true" && (derivedUnion == "" || derivedUnion == "false") %]${type.trim}()[% ELSE %]&_[% QT_ATTRIBUTE(attribute) %][% END %]
-[%- ELSIF type.match('\*$') -%](${type})(0)
-[%- ELSIF type == "QString " -%]QString()
-[%- ELSIF type.match("::") -%][% IF defaultInstance != "" %]Qt${namespace}::${defaultInstance.split("-").0}${defaultInstance.split("-").1.ucfirst}[% ELSE %]${type.trim}None[% END -%]
-[%- ELSIF type.match("int") -%](int)([% IF defaultValue != "" %]${defaultValue}[% ELSE %]0[% END %])
-[%- ELSIF type.match("double") -%](double)(0.0)
-[%- ELSIF type.match("bool") -%][% IF defaultValue != "" %]${defaultValue}[% ELSE %]false[% END -%]
-[%- END -%]
-));
-[%- END %]
}
[%- FOREACH attribute = class.findnodes("ownedAttribute") %]
[%- IF loop.first %]
@@ -146,12 +126,12 @@ Q${namespace}${className}::Q${namespace}${className}()
[%- SET derivedUnion = attribute.findvalue("@isDerivedUnion") -%]
[%- SET association = attribute.findvalue("@association") %]
[% IF qtType.match("QList|QSet") %]const [% END %][% QT_TYPE(namespace, attribute) -%]
-Q${namespace}${className}::${qtAttribute}() const
+${namespace}${className}::${qtAttribute}() const
{
// This is a [% IF readOnly == "" || readOnly == "false" %]read-write[% ELSE %]read-only[% END %][% IF derived == "true" %] derived[% END %][% IF derivedUnion == "true" %] union[% END %] [% IF association != "" %]association end[% ELSE %]property[% END %]
[%- IF derived == "true" && (derivedUnion == "false" || derivedUnion == "") %]
- qWarning("Q${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
+ qWarning("${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
[%- IF qtType.match('\*$') %]
return 0;
@@ -165,12 +145,12 @@ Q${namespace}${className}::${qtAttribute}() const
[%- SET attributeName = attribute.findvalue("@name").ucfirst %]
[%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
-void Q${namespace}${className}::add${attributeName}(${QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*')}${qtAttribute})
+void ${namespace}${className}::add${attributeName}(${QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*')}${qtAttribute})
{
// This is a [% IF readOnly == "" || readOnly == "false" %]read-write[% ELSE %]read-only[% END %][% IF derived == "true" %] derived[% END %][% IF derivedUnion == "true" %] union[% END %] [% IF association != "" %]association end[% ELSE %]property[% END %]
[%- IF derived == "true" && (derivedUnion == "false" || derivedUnion == "") %]
- qWarning("Q${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
+ qWarning("${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
Q_UNUSED(${qtAttribute});
if (false /* <derivedexclusion-criteria> */) {
@@ -219,12 +199,12 @@ void Q${namespace}${className}::add${attributeName}(${QT_TYPE(namespace, attribu
}
}
-void Q${namespace}${className}::remove${attributeName}(${QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*')}${qtAttribute})
+void ${namespace}${className}::remove${attributeName}(${QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*')}${qtAttribute})
{
// This is a [% IF readOnly == "" || readOnly == "false" %]read-write[% ELSE %]read-only[% END %][% IF derived == "true" %] derived[% END %][% IF derivedUnion == "true" %] union[% END %] [% IF association != "" %]association end[% ELSE %]property[% END %]
[%- IF derived == "true" && (derivedUnion == "false" || derivedUnion == "") %]
- qWarning("Q${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
+ qWarning("${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
Q_UNUSED(${qtAttribute});
if (false /* <derivedexclusion-criteria> */) {
@@ -274,12 +254,12 @@ void Q${namespace}${className}::remove${attributeName}(${QT_TYPE(namespace, attr
}
[%- ELSE %]
-void Q${namespace}${className}::set${attributeName.remove("^Is")}(${QT_TYPE(namespace, attribute)}${qtAttribute})
+void ${namespace}${className}::set${attributeName.remove("^Is")}(${QT_TYPE(namespace, attribute)}${qtAttribute})
{
// This is a [% IF readOnly == "" || readOnly == "false" %]read-write[% ELSE %]read-only[% END %][% IF derived == "true" %] derived[% END %][% IF derivedUnion == "true" %] union[% END %] [% IF association != "" %]association end[% ELSE %]property[% END %]
[%- IF derived == "true" && (derivedUnion == "false" || derivedUnion == "") %]
- qWarning("Q${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
+ qWarning("${namespace}${className}::${qtAttribute}(): to be implemented (this is a derived [% IF association != "" %]association end[% ELSE %]property[% END %])");
Q_UNUSED(${qtAttribute});
if (false /* <derivedexclusion-criteria> */) {
@@ -343,7 +323,7 @@ void Q${namespace}${className}::set${attributeName.remove("^Is")}(${QT_TYPE(name
${documentation}
*/
[%- END %]
-${returnType}Q${namespace}${className}::${operationName}(
+${returnType}${namespace}${className}::${operationName}(
[% SET parameters = operation.findnodes("ownedParameter[@direction!='return']") -%]
[%- FOREACH parameter = parameters -%]
[%- QT_TYPE(namespace, parameter) -%]
@@ -352,7 +332,7 @@ ${parameter.findvalue("@name")}
[%- END -%]
)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %]
{
- qWarning("Q${namespace}${className}::${operationName}(): to be implemented (operation)");
+ qWarning("${namespace}${className}::${operationName}(): to be implemented (operation)");
[%- FOREACH parameter = parameters %]
Q_UNUSED(${parameter.findvalue("@name")});
@@ -365,5 +345,3 @@ ${parameter.findvalue("@name")}
}
[%- END %]
-QT_END_NAMESPACE
-
diff --git a/scripts/templates/class.h b/scripts/templates/class_p.h
index e692d35b..47c18855 100644
--- a/scripts/templates/class.h
+++ b/scripts/templates/class_p.h
@@ -39,22 +39,21 @@
** \$QT_END_LICENSE\$
**
****************************************************************************/
-#ifndef Q${namespace.upper}${className.upper}_H
-#define Q${namespace.upper}${className.upper}_H
-
-#include <Qt${namespace}/Qt${namespace}Global>
+#ifndef ${namespace.upper}${className.upper}_H
+#define ${namespace.upper}${className.upper}_H
[% superclasses = [] -%]
[%- SET generalization = class.findnodes("generalization") -%]
-[% FOREACH superclass IN generalization -%]
+[%- FOREACH superclass IN generalization -%]
[% SET superclassName = superclass.findvalue("@general") %]
-#include <Qt${namespace}/Q${namespace}${superclassName}>
-[%- superclasses.push("Q${namespace}${superclassName}") -%]
+#include "private/${namespace.lower}${superclassName.lower}_p.h"
+[%- superclasses.push("${namespace}${superclassName}") -%]
[%- IF loop.last %]
[% END -%]
[%- END -%]
-[%- IF superclasses.size == 0 -%]
-#include <QtModeling/QModelingObject>
-[% END -%]
+
+#include <QtCore/QSet>
+#include <QtCore/QList>
+#include <QtCore/QString>
[%- SET useNamespace = 'false' -%]
[%- forwards = [] -%]
@@ -63,34 +62,27 @@
[%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$forwardName']").findvalue("@name") != "" -%]
[%- SET useNamespace = 'true' -%]
[%- ELSE -%]
-[%- IF forwardName != className && superclasses.grep("^Q${namespace}${forwardName}\$").size == 0 -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%]
+[%- IF forwardName != className && superclasses.grep("^${namespace}${forwardName}\$").size == 0 -%][%- forwards.push("${namespace}${forwardName}") -%][%- END -%]
[%- END -%]
[%- END -%]
-[%- IF useNamespace == 'true' -%]
+[%- IF useNamespace == 'true' %]
#include <Qt${namespace}/Qt${namespace}Namespace>
-[% END %]
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt${namespace})
-[% FOREACH forward = forwards.unique.sort %]
+[% END -%]
+[%- FOREACH forward = forwards.unique.sort %]
class ${forward};
[%- IF loop.last %]
[% END %]
[%- END -%]
-class Q_${namespace.upper}_EXPORT Q${namespace}${className} :
+class ${namespace}${className}
[%- FOREACH superclass IN generalization -%]
-public Q${namespace}${superclass.findvalue("@general")}
+[%- IF loop.first -%] : [%- END -%]
+public ${namespace}${superclass.findvalue("@general")}
[%- IF !loop.last %], [% END -%]
[%- END %]
-[%- IF superclasses.size == 0 -%]
-public QModelingObject
-[%- END %]
{
public:
- [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% END %]Q${namespace}${className}();
+ explicit ${namespace}${className}();
[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
[%- IF loop.first %]
@@ -101,10 +93,10 @@ public:
[% IF qtType.match("QList|QSet") %]const [% END %]${qtType}${qtAttribute}() const;
[%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
[%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
- [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute});
- [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute});
+ void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute});
+ void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute});
[%- ELSE %]
- [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
+ void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
[%- END %]
[%- IF loop.last %]
[%- END %]
@@ -131,13 +123,5 @@ protected:
[%- END %]
};
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(Q${namespace}${className} *)
-Q_DECLARE_METATYPE(QList<Q${namespace}${className} *> *)
-Q_DECLARE_METATYPE(QSet<Q${namespace}${className} *> *)
-
-QT_END_HEADER
-
-#endif // Q${namespace.upper}${className.upper}_H
+#endif // ${namespace.upper}${className.upper}_H
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl
index d173d2a7..d6d6ddff 100644
--- a/scripts/templates/common.tmpl
+++ b/scripts/templates/common.tmpl
@@ -8,7 +8,7 @@
"Real" = "double"
};
-%]
-[%- MACRO QT_TYPE(namespace, attribute) BLOCK -%]
+[%- MACRO QT_TYPE(namespace, attribute, internal) BLOCK -%]
[%- SET multiplicity = attribute.findnodes("upperValue").findvalue("@value") -%]
[%- SET isUnique = attribute.findvalue("@isUnique") -%]
[%- SET isOrdered = attribute.findvalue("@isOrdered") -%]
@@ -18,7 +18,7 @@
[%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$attributeType']").findvalue("@name") != "" -%]
Qt${namespace}::${attributeType}
[%- ELSE -%]
-Q${namespace}${attributeType} *
+[% IF internal == "false" %]Q[% END %]${namespace}${attributeType} *
[%- END -%]
[%- ELSE -%]
${uml2qt_type.item(attribute.findnodes("type").findvalue("@href").split("#").last)}[%- IF multiplicity != "*" %] [% END -%]
diff --git a/scripts/templates/module.pri b/scripts/templates/module.pri
index 4c1784a3..88876e4b 100644
--- a/scripts/templates/module.pri
+++ b/scripts/templates/module.pri
@@ -7,9 +7,16 @@ HEADERS += \
q${namespace.lower}${class.findvalue('@name').lower}.h
[%- END %]
+PRIVATE_HEADERS +=
+[%- FOREACH class = xmi.findnodes('//packagedElement[@xmi:type=\'uml:Class\']') -%]
+ \
+ internal/${namespace.lower}${class.findvalue('@name').lower}_p.h
+[%- END %]
+
SOURCES += \
qt${namespace.lower}namespace.cpp
[%- FOREACH class = xmi.findnodes('//packagedElement[@xmi:type=\'uml:Class\']') -%]
\
+ internal/${namespace.lower}${class.findvalue('@name').lower}.cpp \
q${namespace.lower}${class.findvalue('@name').lower}.cpp
[%- END %]
diff --git a/scripts/templates/module.pro b/scripts/templates/module.pro
index b88feb62..eea9495e 100644
--- a/scripts/templates/module.pro
+++ b/scripts/templates/module.pro
@@ -1,7 +1,7 @@
load(qt_build_config)
TARGET = Qt${namespace}
-QT = core modeling-private
+QT = core
QMAKE_DOCS = [%- GET '$$PWD' -%]/doc/qt${namespace.lower}.qdocconf
diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp
new file mode 100644
index 00000000..b4d24f45
--- /dev/null
+++ b/scripts/templates/qclass.cpp
@@ -0,0 +1,156 @@
+[%- PROCESS common.tmpl -%]
+/****************************************************************************
+**
+** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt${namespace} module of the Qt Toolkit.
+**
+** \$QT_BEGIN_LICENSE:LGPL\$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** \$QT_END_LICENSE\$
+**
+****************************************************************************/
+#include "q${namespace.lower}${className.lower}.h"
+
+[% FOREACH forward = forwards.unique.sort %]
+#include <Qt${namespace}/${forward}>
+[%- IF loop.last %]
+[% END %]
+[%- END -%]
+QT_BEGIN_NAMESPACE
+
+Q${namespace}${className}::Q${namespace}${className}()
+{
+}
+
+[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
+ [%- IF loop.first %]
+// Owned attributes
+ [% END -%]
+ [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
+ [%- SET derived = attribute.findvalue("@isDerived") -%]
+ [%- SET derivedUnion = attribute.findvalue("@isDerivedUnion") -%]
+ [%- IF qtType.match("QList|QSet") %]
+const ${qtType}Q${namespace}${className}::${qtAttribute}() const
+{
+ [%- IF derived == "true" && (derivedUnion == "" || derivedUnion == "false") %]
+ ${qtType}r;
+ foreach (${qtType.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, ${namespace}${className}::${qtAttribute}())
+ r.[% IF qtType.match("QList") %]append[% ELSE %]insert[% END %](reinterpret_cast<${qtType.remove("QList<").remove("QSet<").remove(">").trim}>(element));
+ return r;
+ [%- ELSE %]
+ return *(reinterpret_cast<const ${qtType.trim.remove(' \*$')} *>(&_${qtAttribute}));
+ [%- END %]
+}
+ [% ELSIF qtType.match('\*$') %]
+${qtType}Q${namespace}${className}::${qtAttribute}() const
+{
+ return reinterpret_cast<${qtType.trim}>(_${qtAttribute});
+}
+ [% ELSE %]
+${qtType}Q${namespace}${className}::${qtAttribute}() const
+{
+ return _${qtAttribute};
+}
+ [% END %]
+ [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
+ [%- IF readOnly == "false" || readOnly == "" -%]
+ [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
+ [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
+void Q${namespace}${className}::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
+{
+ ${namespace}${className}::add${attributeName}(${qtAttribute});
+}
+
+void Q${namespace}${className}::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
+{
+ ${namespace}${className}::remove${attributeName}(${qtAttribute});
+}
+
+ [%- ELSE -%]
+ [%- IF qtType.match('QList|QSet') %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
+ [%- ELSIF qtType.match('\*$') %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
+ [%- ELSE %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
+ [%- END -%]
+ [%- END -%]
+ [%- END %]
+ [%- IF loop.last %]
+ [%- END %]
+[%- END -%]
+[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
+[%- IF loop.first %]
+// Operations
+[% END %]
+[% SET operationName = operation.findvalue("@name") -%]
+[%- SET return = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") -%]
+[% return -%]
+Q${namespace}${className}::${operationName}(
+ [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
+ [%- QT_TYPE(namespace, parameter, "false") -%]
+${parameter.findvalue("@name")}
+ [%- IF !loop.last %], [% END -%]
+ [%- END -%]
+)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %]
+{
+ [%- IF return.match('\*$') || !return.match("QList|QSet") %]
+ return [% IF return.match('\*$') %]reinterpret_cast<${return.trim}>([% END %]${namespace}${className}::${operationName}(
+ [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
+${parameter.findvalue("@name")}
+ [%- IF !loop.last %], [% END -%]
+ [%- END -%])[% IF return.match('\*$') %])[% END %];
+ [%- ELSE %]
+ ${return}r;
+ foreach (${return.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, ${namespace}${className}::${operationName}(
+ [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
+${parameter.findvalue("@name")}
+ [%- IF !loop.last %], [% END -%]
+ [%- END -%]))
+ r.[% IF return.match("QList") %]append[% ELSE %]insert[% END %](reinterpret_cast<${return.remove("QList<").remove("QSet<").remove(">").trim}>(element));
+ return r;
+ [%- END %]
+}
+[% END %]
+QT_END_NAMESPACE
+
diff --git a/scripts/templates/qclass.h b/scripts/templates/qclass.h
new file mode 100644
index 00000000..363d815a
--- /dev/null
+++ b/scripts/templates/qclass.h
@@ -0,0 +1,148 @@
+[%- PROCESS common.tmpl -%]
+/****************************************************************************
+**
+** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt${namespace} module of the Qt Toolkit.
+**
+** \$QT_BEGIN_LICENSE:LGPL\$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** \$QT_END_LICENSE\$
+**
+****************************************************************************/
+#ifndef Q${namespace.upper}${className.upper}_H
+#define Q${namespace.upper}${className.upper}_H
+
+#include <Qt${namespace}/Qt${namespace}Global>
+
+#include <QtCore/QObject>
+#include "private/${namespace.lower}${className.lower}_p.h"
+
+[%- SET useNamespace = 'false' -%]
+[%- forwards = [] -%]
+[%- FOREACH forward = class.findnodes("ownedAttribute[@type] | ownedOperation/ownedParameter[@type]") -%]
+[%- SET forwardName = forward.findvalue('@type') -%]
+[%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$forwardName']").findvalue("@name") != "" -%]
+ [%- SET useNamespace = 'true' -%]
+[%- ELSE -%]
+[%- IF forwardName != className -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%]
+[%- END -%]
+[%- END -%]
+[%- IF useNamespace == 'true' -%]
+#include <Qt${namespace}/Qt${namespace}Namespace>
+[% END %]
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qt${namespace})
+[% FOREACH forward = forwards.unique.sort %]
+class ${forward};
+[%- IF loop.last %]
+[% END %]
+[%- END -%]
+
+class Q_${namespace.upper}_EXPORT Q${namespace}${className} : public QObject, public ${namespace}${className}
+{
+ Q_OBJECT
+[%- SET attributes = class.findnodes("ownedAttribute") -%]
+[%- FOREACH attribute IN attributes -%]
+ [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute, "false") %]
+ [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
+ [%- SET upperValue = attribute.findvalue("upperValue/@value") -%]
+ [%- SET attributeName = attribute.findvalue("@name").ucfirst %]
+ Q_PROPERTY(${qtType.trim} ${qtAttribute} READ ${qtAttribute})
+[%- END %]
+
+public:
+ [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% ELSE %]Q_INVOKABLE [% END %]explicit Q${namespace}${className}();
+[%- FOREACH attribute IN attributes -%]
+ [%- IF loop.first %]
+
+ // Owned attributes
+ [%- END -%]
+ [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
+ [%- IF qtType.match("QList|QSet") %]
+ Q_INVOKABLE const ${qtType}${qtAttribute}() const;
+ [%- ELSIF qtType.match('\*$') %]
+ Q_INVOKABLE ${qtType}${qtAttribute}() const;
+ [%- ELSE %]
+ Q_INVOKABLE ${qtType}${qtAttribute}() const;
+ [%- END %]
+ [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
+ [%- IF readOnly == "false" || readOnly == "" -%]
+ [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
+ [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
+ Q_INVOKABLE void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
+ Q_INVOKABLE void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
+ [%- ELSE -%]
+ [%- IF qtType.match('QList|QSet') %]
+ Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute});
+ [%- ELSIF qtType.match('\*$') %]
+ Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
+ [%- ELSE %]
+ Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
+ [%- END -%]
+ [%- END -%]
+ [%- END %]
+ [%- IF loop.last %]
+ [%- END %]
+[%- END -%]
+[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
+[%- IF loop.first %]
+
+ // Operations
+[%- END %]
+[% SET operationName = operation.findvalue("@name") -%]
+ Q_INVOKABLE [% QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") -%]
+${operationName}(
+ [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
+ [%- QT_TYPE(namespace, parameter, "false") -%]
+${parameter.findvalue("@name")}
+ [%- IF !loop.last %], [% END -%]
+ [%- END -%]
+)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %];
+[%- END %]
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Q${namespace}${className} *)
+Q_DECLARE_METATYPE(QList<Q${namespace}${className} *> *)
+Q_DECLARE_METATYPE(QSet<Q${namespace}${className} *> *)
+
+QT_END_HEADER
+
+#endif // Q${namespace.upper}${className.upper}_H
+
diff --git a/scripts/xmi2qt.pl b/scripts/xmi2qt.pl
index 9ed092c6..921e0d1b 100755
--- a/scripts/xmi2qt.pl
+++ b/scripts/xmi2qt.pl
@@ -56,7 +56,7 @@ my $tt = Template->new(INTERPOLATE => 1, INCLUDE_PATH => 'templates/');
my $xmi = XML::XPath->new(filename => $options{i});
my $namespace = $xmi->findvalue('//uml:Package/@name');
-make_path($options{o}."/".$namespace);
+make_path($options{o}."/".$namespace."/"."internal");
{
local *STDOUT;