Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property')
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet78
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet58
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet37
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet56
4 files changed, 229 insertions, 0 deletions
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet
new file mode 100644
index 00000000000..58c5fc97a71
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet
@@ -0,0 +1,78 @@
+<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
+ skeleton = "../../generator.skeleton"
+ imports = "org.eclipse.uml2.uml.Property org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*"
+ class = "CppAttributeDeclaration"
+%>
+<%
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+ String typeName = "";
+ String prefix = "";
+ String suffix = "";
+ String multiple = "";
+
+ // For property documentation
+ String propDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+ propDoc = jDoc.generate(currentAttribute);
+ propDoc = propDoc.replaceAll(NL, NL+" ");
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined";
+ } else {
+ typeName = GenUtils.qualifiedName (currentAttribute.getType());
+ }
+
+ // Static attribute
+ if (currentAttribute.isStatic()) {
+ prefix = "static"+" ";
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+ // Treat multiplicity for association attributes
+ int multiplicity = currentAttribute.getUpper();
+ if (multiplicity == 1) {
+ multiple = "";
+ } else if (multiplicity == -1) {
+ multiple = "*";
+ } else {
+ multiple = "";
+ modifier.array = "[" + multiplicity + "]";
+ }
+
+ // If attribute is aggregation
+ if (GenUtils.isAggregation(currentAttribute)) {
+ // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab
+ attributeName = "*"+attributeName; // this produce a tab of pointers
+ }
+
+
+ if (GenUtils.hasStereotype(currentAttribute, CppConst.class) && currentAttribute.isStatic()) {
+ // const & static attributes may be initialized within class declaration
+ // check if initial value UML or profile
+ if (currentAttribute.getDefaultValue() != null) {
+ suffix = " = " + currentAttribute.getDefaultValue().stringValue();
+ }
+ else {
+ CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class);
+ if (cppDefault != null) {
+ suffix = " = " + cppDefault.getValue();
+ }
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////%>
+
+ <%= propDoc %>
+ <%= prefix %><%= modifier.isConst %><%= typeName %><%= multiple %><%= modifier.ptr %><%= modifier.ref %> <%= attributeName %><%= modifier.array %><%= suffix %>; \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet
new file mode 100644
index 00000000000..2980c4fee83
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet
@@ -0,0 +1,58 @@
+<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
+ skeleton = "../../generator.skeleton"
+ imports = "org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*"
+ class = "CppAttributeImplementation"
+%>
+<%
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+// String className = currentAttribute.getOwner().getName();
+ String typeName = "";
+ String scopeName = "";
+// String prefix = "";
+ String suffix = "";
+ String multiple = "";
+
+ // For property documentation
+ String propDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+ propDoc = jDoc.generate(currentAttribute);
+ propDoc = propDoc.replaceAll(NL, NL+" ");
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined";
+ }
+ else {
+ Type type = currentAttribute.getType();
+ typeName = GenUtils.qualifiedName (type);
+ /*
+ // If type is owned by a class add the scope
+ if (type.getOwner() instanceof Class) {
+ scopeName = ((Class) type.getOwner()).getName();
+ typeName = scopeName+"::"+typeName;
+ }
+ */
+ }
+
+ // Multiple
+ // TODO? need to evaluate limitMultiplicity stereotype?
+ int upper = currentAttribute.getUpper();
+ if ((upper == -1) || (upper > 1)) {
+ multiple = "*";
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////%>
+ <%= propDoc %>
+ <%= typeName %><%= multiple %><%= modifier.ptr %><%= modifier.ref %> <%= attributeName %><%= modifier.array %><%= suffix %>;
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet
new file mode 100644
index 00000000000..634b097bbb1
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet
@@ -0,0 +1,37 @@
+<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
+ skeleton = "../../generator.skeleton"
+ imports = "org.eclipse.uml2.uml.* java.util.Iterator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils"
+ class = "CppClassAttributesImplementation"
+%>
+<%
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+ String attrDecl = "";
+ String attrSDecl = "";
+
+ CppAttributeImplementation jetAttDecl = new CppAttributeImplementation();
+ CppStaticAttributeImplementation jetSAttDecl = new CppStaticAttributeImplementation();
+
+ Iterator<Property> attributesIt = currentClass.getAttributes().iterator();
+ while (attributesIt.hasNext()) {
+ Property attribute = (Property) attributesIt.next();
+
+ // just check that this property is not a static const
+ // in that case it declared and defined in the header file
+
+ // Static
+ if (attribute.isStatic()) {
+ attrSDecl = attrSDecl+jetSAttDecl.generate(attribute);
+ } else {
+ attrDecl = attrDecl+jetAttDecl.generate(attribute);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////%>
+<%= attrSDecl %><%= attrDecl %> \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet
new file mode 100644
index 00000000000..aafed1f9c64
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet
@@ -0,0 +1,56 @@
+<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
+ skeleton = "../../generator.skeleton"
+ imports = "org.eclipse.uml2.uml.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*"
+ class = "CppStaticAttributeImplementation"
+%>
+<%
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+ String className = GenUtils.qualifiedName (currentAttribute.getClass_());
+ String typeName = "";
+ String suffix = "";
+ String multiple = "";
+ String isAgg = ""; // attribute is an aggregation or association
+
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined"+" ";
+ } else {
+ typeName = GenUtils.qualifiedName (currentAttribute.getType()) + " ";
+ }
+
+ // Multiple
+ // if (currentAttribute.isMultiple()) {
+ // multiple = "*";
+ // }
+
+ // If attribute is aggregation then generate a pointer
+ if (GenUtils.isAggregation(currentAttribute)) {
+ // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab
+ isAgg = "*"; // this produce a tab of pointers
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+ // Initial value
+ if (currentAttribute.getDefaultValue() != null) {
+ // via UML
+ suffix = " = " + currentAttribute.getDefaultValue().stringValue();
+ }
+ else {
+ CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class);
+ if (cppDefault != null) {
+ suffix = " = " + cppDefault.getValue();
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////%>
+<%= typeName %><%= multiple %><%= modifier.ptr %><%= isAgg %><%= modifier.ref %><%= className %>::<%= attributeName %><%= modifier.array %><%= suffix %>;

Back to the top