summaryrefslogtreecommitdiffstats
path: root/scripts/templates/common.tmpl
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-10-07 19:57:57 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-10-08 01:01:15 +0200
commitb453dca1261158461363076d3a312c22a51da3de (patch)
tree3d71d5cbf572d6d53aaa6740a9ba93524a86155d /scripts/templates/common.tmpl
parent5e4a780b40543fa12d6d9607e3193fb111c5ab84 (diff)
Improve property metadata for XMI serialization
Change-Id: I5a5c4dd61312824c63f6eac73b7170376c2b6bdb Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/templates/common.tmpl')
-rw-r--r--scripts/templates/common.tmpl35
1 files changed, 26 insertions, 9 deletions
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl
index ba4d8e63..75b1a0b7 100644
--- a/scripts/templates/common.tmpl
+++ b/scripts/templates/common.tmpl
@@ -100,8 +100,8 @@ ${attributeName}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
+[%- SET className = class.findvalue("@name") -%]
[%- FOREACH attribute IN class.findnodes("ownedAttribute") -%]
- [%- SET className = class.findvalue("@name") -%]
[%- IF found == "false" %]
// Properties [${className}]
@@ -110,7 +110,7 @@ ${attributeName}
[%- 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 ${PLURALFORM(qtAttribute, attribute)}[% IF attribute.findvalue("@isReadOnly") != "true" and !(attribute.findnodes("upperValue").findvalue("@value") == "*")%] WRITE set${qtAttribute.remove("^is").ucfirst.remove('_$')}[% END %][% IF attribute.findvalue("defaultValue/@xmi:type") != "" %] RESET unset${qtAttribute.remove("^is").ucfirst}[% END %][% IF attribute.findvalue("@isDerived") == "true" and attribute.findvalue("@isDerivedUnion") != "true" %] STORED false[% END %])
+ Q_PROPERTY(${qtType.trim} ${PLURALFORM(qtAttribute, attribute)} READ ${PLURALFORM(qtAttribute, attribute)}[% IF attribute.findvalue("@isReadOnly") != "true" and !(attribute.findnodes("upperValue").findvalue("@value") == "*")%] WRITE set${qtAttribute.remove("^is").ucfirst.remove('_$')}[% END %][% IF attribute.findvalue("defaultValue/@xmi:type") != "" %] RESET unset${qtAttribute.remove("^is").ucfirst}[% END %][% IF attribute.findvalue("@isDerived") == "true" and attribute.findvalue("@isDerivedUnion") != "true" %] STORED false[% END %])
[%- END %]
[%- END -%]
[%- MACRO GENERATE_ATTRIBUTES(class, visitedClasses, redefinedProperties) BLOCK -%]
@@ -123,8 +123,8 @@ ${attributeName}
[%- END -%]
[%- SET attributes = class.findnodes("ownedAttribute") -%]
[%- SET found = "false" -%]
+[%- SET className = class.findvalue("@name") -%]
[%- FOREACH attribute IN attributes -%]
- [%- SET className = class.findvalue("@name") -%]
[%- IF found == "false" %]
// Owned attributes [${className}]
@@ -153,8 +153,8 @@ ${attributeName}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
-[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- SET className = class.findvalue("@name") -%]
+[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- IF found == "false" %]
// Operations [${className}]
@@ -182,8 +182,8 @@ ${parameter.findvalue("@name")}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
-[%- FOREACH attribute IN class.findnodes("ownedAttribute") -%]
[%- SET className = class.findvalue("@name") -%]
+[%- FOREACH attribute IN class.findnodes("ownedAttribute") -%]
[%- IF found == "false" %]
// Slots for owned attributes [${className}]
@@ -225,8 +225,8 @@ ${parameter.findvalue("@name")}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
+[%- SET className = class.findvalue("@name") -%]
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
- [%- SET className = class.findvalue("@name") -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
[%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
[%- IF found == "false" -%]
@@ -267,8 +267,8 @@ ${parameter.findvalue("@name")}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
-[% FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- SET className = class.findvalue("@name") -%]
+[% FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- IF found == "false" -%]
// OPERATIONS [${className}]
@@ -360,8 +360,8 @@ ${parameter.findvalue("@name")}
[%- END -%]
[%- END -%]
[%- SET found = "false" -%]
+[%- SET className = class.findvalue("@name") -%]
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
- [%- SET className = class.findvalue("@name") -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
[%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
[%- IF found == "false" -%]
@@ -448,10 +448,10 @@ void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").u
[%- GENERATE_CLONE(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
[%- END -%]
[%- END -%]
+[%- SET className = class.findvalue("@name") -%]
[%- FOREACH attribute = class.findnodes("ownedAttribute[@isDerived=\"false\" or not(@isDerived)]") -%]
[%- SET qtType = QT_TYPE(namespace, attribute) -%]
[%- SET attributeName = attribute.findvalue("@name") -%]
- [%- SET className = class.findvalue("@name") -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
[%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
[%- IF qtType.match("QList|QSet") %]
@@ -469,3 +469,20 @@ void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").u
[%- END -%]
[%- END %]
[%- END -%]
+[%- MACRO SET_CLASS_FOR_PROPERTY(class, visitedClasses, redefinedProperties) BLOCK -%]
+[%- FOREACH parent IN class.findnodes("generalization") -%]
+ [%- SET parentName = parent.findvalue("@general") -%]
+ [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
+ [%- visitedClasses.push("${parentName}") -%]
+ [%- SET_CLASS_FOR_PROPERTY(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
+ [%- END -%]
+[%- END -%]
+[%- SET className = class.findvalue("@name") -%]
+[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute) -%]
+ [%- SET attributeName = attribute.findvalue("@name") -%]
+ [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
+ [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 %]
+ _classForProperty[QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")] = QStringLiteral("Q${namespace}${className}");
+[%- END %]
+[%- END -%] \ No newline at end of file