diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-08-30 14:10:13 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-08-30 19:08:23 +0200 |
commit | 6a665c447fb060422d4b55a6a2716d2f4560c0e2 (patch) | |
tree | 608ad49e0b708be09a4c25138ffd71c0d307fc24 /scripts | |
parent | 5b9826151b9fe94aeca609c3f9c042ac8d95098b (diff) |
Do not generate code for overridden properties and operations
Change-Id: I8aaf79011b508e4de753c5de8a1f4ad473e31086
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/templates/common.tmpl | 166 | ||||
-rw-r--r-- | scripts/templates/qclass.cpp | 24 | ||||
-rw-r--r-- | scripts/templates/qclass.h | 29 |
3 files changed, 149 insertions, 70 deletions
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl index bfe2c4c3..a218b92a 100644 --- a/scripts/templates/common.tmpl +++ b/scripts/templates/common.tmpl @@ -43,39 +43,75 @@ ${uml2qt_attribute.item(attributeName)} ${attributeName} [%- END -%] [%- END -%] -[%- MACRO GENERATE_QPROPERTIES(class, visitedClasses) BLOCK -%] +[%- MACRO POPULATE_REDEFINED_PROPERTIES(class, visitedClasses, redefinedProperties) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_QPROPERTIES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- POPULATE_REDEFINED_PROPERTIES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] [%- END -%] [%- END -%] +[%- FOREACH attribute IN class.findnodes("ownedAttribute[@redefinedProperty]") -%] + [%- FOREACH redefinedProperty IN attribute.findvalue("@redefinedProperty").split(' ') -%] + [%- redefinedProperties.push("${redefinedProperty}") -%] + [%- END -%] +[%- END -%] +[%- END -%] +[%- MACRO POPULATE_REDEFINED_OPERATIONS(class, visitedClasses, redefinedOperations) BLOCK -%] +[%- FOREACH parent IN class.findnodes("generalization") -%] + [%- SET parentName = parent.findvalue("@general") -%] + [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] + [%- visitedClasses.push("${parentName}") -%] + [%- POPULATE_REDEFINED_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%] + [%- END -%] +[%- END -%] +[%- FOREACH operation IN class.findnodes("ownedOperation[@redefinedOperation]") -%] + [%- FOREACH redefinedOperation IN operation.findvalue("@redefinedOperation").split(' ') -%] + [%- redefinedOperations.push("${redefinedOperation}") -%] + [%- END -%] +[%- END -%] +[%- END -%] +[%- MACRO GENERATE_QPROPERTIES(class, visitedClasses, redefinedProperties) BLOCK -%] +[%- FOREACH parent IN class.findnodes("generalization") -%] + [%- SET parentName = parent.findvalue("@general") -%] + [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] + [%- visitedClasses.push("${parentName}") -%] + [%- GENERATE_QPROPERTIES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] + [%- END -%] +[%- END -%] +[%- SET found = "false" -%] [%- FOREACH attribute IN class.findnodes("ownedAttribute") -%] - [%- IF loop.first %] + [%- SET className = class.findvalue("@name") -%] + [%- IF found == "false" %] - // Properties [${class.findvalue("@name")}] + // Properties [${className}] + [%- SET found = "true" -%] [%- END -%] [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") %] Q_PROPERTY(${qtType.trim} ${qtAttribute} READ ${qtAttribute}) [%- END %] [%- END -%] -[%- MACRO GENERATE_ATTRIBUTES(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_ATTRIBUTES(class, visitedClasses, redefinedProperties) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_ATTRIBUTES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_ATTRIBUTES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] [%- END -%] [%- END -%] [%- SET attributes = class.findnodes("ownedAttribute") -%] +[%- SET found = "false" -%] [%- FOREACH attribute IN attributes -%] - [%- IF loop.first %] + [%- SET className = class.findvalue("@name") -%] + [%- IF found == "false" %] - // Owned attributes [${class.findvalue("@name")}] + // Owned attributes [${className}] + [%- SET found = "true" -%] [%- END -%] [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%] [%- IF qtType.match("QList|QSet") %] Q_INVOKABLE const ${qtType}${qtAttribute}() const; @@ -88,20 +124,25 @@ ${attributeName} [%- END %] [%- END -%] [%- END -%] -[%- MACRO GENERATE_OPERATIONS(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_OPERATIONS(class, visitedClasses, redefinedOperations) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%] [%- END -%] [%- END -%] +[%- SET found = "false" -%] [%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%] -[%- IF loop.first %] +[%- SET className = class.findvalue("@name") -%] +[%- IF found == "false" %] - // Operations [${class.findvalue("@name")}] + // Operations [${className}] +[%- SET found = "true" -%] [%- END %] -[% SET operationName = operation.findvalue("@name") -%] +[%- SET operationName = operation.findvalue("@name") -%] +[%- NEXT IF redefinedOperations.grep("^${className}-${operationName}$").size > 0 -%] + Q_INVOKABLE [% QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") -%] ${operationName}( [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%] @@ -112,21 +153,26 @@ ${parameter.findvalue("@name")} )[% IF operation.findvalue("@isQuery") == "true" %] const[% END %]; [%- END %] [%- END -%] -[%- MACRO GENERATE_SLOTS(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_SLOTS(class, visitedClasses, redefinedProperties) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_SLOTS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_SLOTS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] [%- END -%] [%- END -%] +[%- SET found = "false" -%] [%- FOREACH attribute IN class.findnodes("ownedAttribute") -%] -[%- IF loop.first %] - // Slots for owned attributes [${class.findvalue("@name")}] +[%- SET className = class.findvalue("@name") -%] +[%- IF found == "false" %] + + // Slots for owned attributes [${className}] +[%- SET found = "true" -%] [%- END %] - [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- SET qtAttribute = QT_ATTRIBUTE(attribute) %] + [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%] - [%- SET readOnly = attribute.findvalue("@isReadOnly") %] + [%- SET readOnly = attribute.findvalue("@isReadOnly") -%] [%- IF readOnly == "false" || readOnly == "" -%] [%- SET attributeName = attribute.findvalue("@name").ucfirst -%] [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%] @@ -147,21 +193,25 @@ ${parameter.findvalue("@name")} [%- END -%] [%- END -%] [%- END %] -[%- IF loop.last %] -[% END %] -[%- END -%] +[%- END %] [%- END -%] -[%- MACRO GENERATE_CPP_ATTRIBUTES(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_CPP_ATTRIBUTES(originalClassName, class, visitedClasses, redefinedProperties) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_CPP_ATTRIBUTES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_CPP_ATTRIBUTES(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] [%- END -%] [%- END -%] +[%- SET found = "false" -%] [% FOREACH attribute = class.findnodes("ownedAttribute") -%] - [%- IF loop.first -%] -// OWNED ATTRIBUTES [${class.findvalue("@name")}] + [%- SET className = class.findvalue("@name") -%] + [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] + [%- IF found == "false" -%] +// OWNED ATTRIBUTES [${className}] + +[%- SET found = "true" -%] [% END -%] [%- SET documentation = attribute.findvalue("ownedComment/body/text()") -%] [%- IF documentation != "" %] @@ -169,11 +219,10 @@ ${parameter.findvalue("@name")} ${documentation} */ [%- 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 [% END %]${qtType}Q${namespace}${className}::${qtAttribute}() const +[% IF qtType.match("QList|QSet") %]const [% END %]${qtType}Q${namespace}${originalClassName}::${qtAttribute}() const { [%- IF qtType.match("QList|QSet") %] [%- IF derived == "true" && (derivedUnion == "" || derivedUnion == "false") %] @@ -203,19 +252,24 @@ ${parameter.findvalue("@name")} [% END -%] [%- END -%] [%- END -%] -[%- MACRO GENERATE_CPP_OPERATIONS(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_CPP_OPERATIONS(originalClassName, class, visitedClasses, redefinedOperations) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_CPP_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_CPP_OPERATIONS(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%] [%- END -%] [%- END -%] +[%- SET found = "false" -%] [% FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%] -[%- IF loop.first -%] -// OPERATIONS [${class.findvalue("@name")}] +[%- SET className = class.findvalue("@name") -%] +[%- IF found == "false" -%] +// OPERATIONS [${className}] + +[%- SET found = "true" -%] [% END -%] [% SET operationName = operation.findvalue("@name") -%] +[%- NEXT IF redefinedOperations.grep("^${className}-${operationName}$").size > 0 -%] [%- SET return = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") %] [%- SET documentation = operation.findvalue("ownedComment/body/text()") -%] [%- IF documentation != "" %] @@ -224,7 +278,7 @@ ${parameter.findvalue("@name")} */ [%- END %] [% return -%] -Q${namespace}${className}::${operationName}( +Q${namespace}${originalClassName}::${operationName}( [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%] [%- QT_TYPE(namespace, parameter, "false") -%] ${parameter.findvalue("@name")} @@ -265,37 +319,42 @@ ${parameter.findvalue("@name")} [% END -%] [%- END -%] [%- END -%] -[%- MACRO GENERATE_CPP_SLOTS(class, visitedClasses) BLOCK -%] +[%- MACRO GENERATE_CPP_SLOTS(originalClassName, class, visitedClasses, redefinedProperties) BLOCK -%] [%- FOREACH parent IN class.findnodes("generalization") -%] [%- SET parentName = parent.findvalue("@general") -%] [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] [%- visitedClasses.push("${parentName}") -%] - [%- GENERATE_CPP_SLOTS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses) -%] + [%- GENERATE_CPP_SLOTS(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] [%- END -%] [%- END -%] +[%- SET found = "false" -%] [% FOREACH attribute = class.findnodes("ownedAttribute") -%] - [%- IF loop.first -%] -// SLOTS FOR OWNED ATTRIBUTES [${class.findvalue("@name")}] + [%- SET className = class.findvalue("@name") -%] + [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] + [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] + [%- IF found == "false" -%] +// SLOTS FOR OWNED ATTRIBUTES [${className}] + +[%- SET found = "true" -%] [% END -%] [%- SET readOnly = attribute.findvalue("@isReadOnly") %] [%- IF readOnly == "false" || readOnly == "" -%] [%- SET attributeName = attribute.findvalue("@name").ucfirst -%] - [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%] [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%] [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] -void Q${namespace}${className}::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute}) +void Q${namespace}${originalClassName}::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute}) [%- ELSE %] -void Q${namespace}${className}::add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute}) +void Q${namespace}${originalClassName}::add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute}) [%- END %] { ${namespace}${className}::add${attributeName}(${qtAttribute}); } [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] -void Q${namespace}${className}::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute}) +void Q${namespace}${originalClassName}::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute}) [%- ELSE %] -void Q${namespace}${className}::remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute}) +void Q${namespace}${originalClassName}::remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute}) [%- END %] { ${namespace}${className}::remove${attributeName}(${qtAttribute}); @@ -303,19 +362,19 @@ void Q${namespace}${className}::remove${attributeName}(${qtType.remove("QSet<"). [%- ELSE -%] [%- IF qtType.match('QList|QSet') %] -void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute}) +void Q${namespace}${originalClassName}::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}) +void Q${namespace}${originalClassName}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute}) { ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute}); } [%- ELSE %] -void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute}) +void Q${namespace}${originalClassName}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute}) { ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute}); } @@ -325,4 +384,21 @@ void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtA [%- IF loop.last %] [% END -%] [%- END %] +[%- END -%] +[%- MACRO GENERATE_FWD_DECLARATIONS(class, visitedClasses, forwards, useNamespace) BLOCK -%] +[%- FOREACH parent IN class.findnodes("generalization") -%] + [%- SET parentName = parent.findvalue("@general") -%] + [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] + [%- visitedClasses.push("${parentName}") -%] + [%- GENERATE_FWD_DECLARATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, forwards, useNamespace) -%] + [%- END -%] +[%- END -%] +[%- 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") != "" -%] + [%- useNamespace.push("true") -%] +[%- ELSE -%] +[%- IF forwardName != className -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%] +[%- END -%] +[%- END -%] [%- END -%]
\ No newline at end of file diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp index f02d6c79..183c9e1f 100644 --- a/scripts/templates/qclass.cpp +++ b/scripts/templates/qclass.cpp @@ -41,13 +41,10 @@ ****************************************************************************/ #include "q${namespace.lower}${className.lower}.h" -[% 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 -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%] -[%- END -%] -[%- END -%] +[% SET useNamespace = 'false' -%] +[%- forwards = [] -%] +[%- visitedClasses = [] -%] +[%- GENERATE_FWD_DECLARATIONS(class, visitedClasses, forwards, useNamespace) -%] [%- FOREACH forward = forwards.unique.sort -%] #include <Qt${namespace}/${forward}> [% IF loop.last %] @@ -68,11 +65,18 @@ Q${namespace}${className}::Q${namespace}${className}(QObject *parent) : { } +[%- SET originalClassName = class.findvalue("@name") -%] +[%- visitedClasses = [] -%] +[%- redefinedProperties = [] -%] +[%- POPULATE_REDEFINED_PROPERTIES(class, visitedClasses, redefinedProperties) -%] [%- visitedClasses = [] %] -[% GENERATE_CPP_ATTRIBUTES(class, visitedClasses) -%] +[% GENERATE_CPP_ATTRIBUTES(originalClassName, class, visitedClasses, redefinedProperties) -%] +[%- visitedClasses = [] -%] +[%- redefinedOperations = [] -%] +[%- POPULATE_REDEFINED_OPERATIONS(class, visitedClasses, redefinedOperations) -%] [%- visitedClasses = [] %] -[%- GENERATE_CPP_OPERATIONS(class, visitedClasses) -%] +[%- GENERATE_CPP_OPERATIONS(originalClassName, class, visitedClasses, redefinedOperations) -%] [%- visitedClasses = [] %] -[%- GENERATE_CPP_SLOTS(class, visitedClasses) -%] +[%- GENERATE_CPP_SLOTS(originalClassName, class, visitedClasses, redefinedProperties) -%] QT_END_NAMESPACE diff --git a/scripts/templates/qclass.h b/scripts/templates/qclass.h index 81a8cbc1..b40f6ceb 100644 --- a/scripts/templates/qclass.h +++ b/scripts/templates/qclass.h @@ -47,17 +47,11 @@ #include <QtCore/QObject> #include "private/${namespace.lower}${className.lower}_p.h" -[%- SET useNamespace = 'false' -%] +[%- useNamespace = [] -%] [%- 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' -%] +[%- visitedClasses = [] -%] +[%- GENERATE_FWD_DECLARATIONS(class, visitedClasses, forwards, useNamespace) -%] +[%- IF useNamespace.size > 0 %] #include <Qt${namespace}/Qt${namespace}Namespace> [% END %] QT_BEGIN_HEADER @@ -75,18 +69,23 @@ class Q_${namespace.upper}_EXPORT Q${namespace}${className} : public QObject, pu { Q_OBJECT [%- visitedClasses = [] -%] - [%- GENERATE_QPROPERTIES(class, visitedClasses) %] + [%- redefinedProperties = [] -%] + [%- POPULATE_REDEFINED_PROPERTIES(class, visitedClasses, redefinedProperties) -%] + [%- visitedClasses = [] -%] + [%- GENERATE_QPROPERTIES(class, visitedClasses, redefinedProperties) %] public: [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% ELSE %]Q_INVOKABLE [% END %]explicit Q${namespace}${className}(QObject *parent = 0); [%- visitedClasses = [] -%] -[%- GENERATE_ATTRIBUTES(class, visitedClasses) -%] +[%- GENERATE_ATTRIBUTES(class, visitedClasses, redefinedProperties) -%] +[%- visitedClasses = [] -%] +[%- redefinedOperations = [] -%] +[%- POPULATE_REDEFINED_OPERATIONS(class, visitedClasses, redefinedOperations) -%] [%- visitedClasses = [] -%] -[%- GENERATE_OPERATIONS(class, visitedClasses) -%] +[%- GENERATE_OPERATIONS(class, visitedClasses, redefinedOperations) -%] [%- visitedClasses = [] %] -public Q_SLOTS: -[%- GENERATE_SLOTS(class, visitedClasses) -%] +public Q_SLOTS:[%- GENERATE_SLOTS(class, visitedClasses, redefinedProperties) %] }; QT_END_NAMESPACE |