diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-08-29 00:21:34 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-08-29 15:36:14 +0200 |
commit | 15f1561dff2533d45f513ae885b4ffe748af5e54 (patch) | |
tree | 25ce0de84e2641c427ef27119e4b3a1b2b9163b5 /scripts | |
parent | f3f02b513ecc79d1ce7a108664ed772cacc60766 (diff) |
New UML metamodel implementation almost done
Still missing:
- Forward methods for inherited properties and operations
- Auto-removal of deleted composite properties
- Moving documentation from internal do QObject-based classes
Change-Id: I2676e48c53d9ad4cdc6333c28e1a912d4e72cdd0
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/templates/class_p.h | 13 | ||||
-rw-r--r-- | scripts/templates/qclass.cpp | 16 |
2 files changed, 20 insertions, 9 deletions
diff --git a/scripts/templates/class_p.h b/scripts/templates/class_p.h index 47c18855..7ec0ec53 100644 --- a/scripts/templates/class_p.h +++ b/scripts/templates/class_p.h @@ -41,6 +41,8 @@ ****************************************************************************/ #ifndef ${namespace.upper}${className.upper}_H #define ${namespace.upper}${className.upper}_H + +#include <Qt${namespace}/Qt${namespace}Global> [% superclasses = [] -%] [%- SET generalization = class.findnodes("generalization") -%] [%- FOREACH superclass IN generalization -%] @@ -74,7 +76,7 @@ class ${forward}; [% END %] [%- END -%] -class ${namespace}${className} +class Q_${namespace.upper}_EXPORT ${namespace}${className} [%- FOREACH superclass IN generalization -%] [%- IF loop.first -%] : [%- END -%] public ${namespace}${superclass.findvalue("@general")} @@ -82,21 +84,22 @@ public ${namespace}${superclass.findvalue("@general")} [%- END %] { public: - explicit ${namespace}${className}(); + Q_DECL_HIDDEN explicit ${namespace}${className}(); [%- FOREACH attribute = class.findnodes("ownedAttribute") -%] [%- IF loop.first %] // Owned attributes [%- END -%] [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- SET readOnly = attribute.findvalue("@isReadOnly") -%] [%- SET qtType = QT_TYPE(namespace, attribute) %] [% IF qtType.match("QList|QSet") %]const [% END %]${qtType}${qtAttribute}() const; [%- SET attributeName = attribute.findvalue("@name").ucfirst -%] [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %] - void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute}); - void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute}); + [% IF readOnly == "true" %]Q_DECL_HIDDEN [% END %]void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute}); + [% IF readOnly == "true" %]Q_DECL_HIDDEN [% END %]void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %]${qtAttribute}); [%- ELSE %] - void set${attributeName.remove("^Is")}(${qtType}${qtAttribute}); + [% IF readOnly == "true" %]Q_DECL_HIDDEN [% END %]void set${attributeName.remove("^Is")}(${qtType}${qtAttribute}); [%- END %] [%- IF loop.last %] [%- END %] diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp index 51a24d75..1894cb0c 100644 --- a/scripts/templates/qclass.cpp +++ b/scripts/templates/qclass.cpp @@ -63,7 +63,7 @@ Q${namespace}${className}::Q${namespace}${className}(QObject *parent) : [%- FOREACH attribute = class.findnodes("ownedAttribute") -%] [%- IF loop.first %] // Owned attributes - [% END -%] +[% END -%] [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%] [%- SET derived = attribute.findvalue("@isDerived") -%] @@ -79,13 +79,13 @@ Q${namespace}${className}::Q${namespace}${className}(QObject *parent) : [%- ELSE %] return *(reinterpret_cast<const ${qtType.trim.remove(' \*$')} *>(&_${qtAttribute})); [%- END -%] - [% ELSIF qtType.match('\*$') %] + [%- ELSIF qtType.match('\*$') %] [%- IF derived == "true" && (derivedUnion == "" || derivedUnion == "false") %] return reinterpret_cast<${qtType.trim}>(${namespace}${className}::${qtAttribute}()); [%- ELSE %] return reinterpret_cast<${qtType.trim}>(_${qtAttribute}); [%- END -%] - [% ELSE %] + [%- ELSE %] [%- IF derived == "true" && (derivedUnion == "" || derivedUnion == "false") %] return ${namespace}${className}::${qtAttribute}(); [%- ELSE %] @@ -122,11 +122,13 @@ void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType.remov { ${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}) { @@ -159,7 +161,7 @@ ${parameter.findvalue("@name")} ${parameter.findvalue("@name")} [%- IF !loop.last %], [% END -%] [%- END -%])[% IF return.match('\*$') %])[% END %]; - [%- ELSE %] + [%- ELSIF return.match('\*') %] ${return}r; foreach (${return.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, ${namespace}${className}::${operationName}( [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%] @@ -173,6 +175,12 @@ ${parameter.findvalue("@name")} [%- END -%])) r.[% IF return.match("QList") %]append[% ELSE %]insert[% END %](reinterpret_cast<${return.remove("QList<").remove("QSet<").remove(">").trim}>(element)); return r; + [%- ELSE %] + return ${namespace}${className}::${operationName}( + [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%] +${parameter.findvalue("@name")} + [%- IF !loop.last %], [% END -%] + [%- END -%]); [%- END %] } |