Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet')
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet53
1 files changed, 53 insertions, 0 deletions
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet
new file mode 100644
index 00000000000..ce6419b204f
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet
@@ -0,0 +1,53 @@
+<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
+ skeleton = "../../generator.skeleton"
+ imports = "org.eclipse.uml2.uml.PrimitiveType org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils"
+ class = "CppPrimitiveTypeDefinition"
+%>
+<%
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the type passed as argument
+ PrimitiveType currentPType = (PrimitiveType) argument;
+ String currentPTypeName = currentPType.getName();
+ String definition = "";
+
+ // Doc
+ String typeDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+
+ /**
+ * Support two different kinds of primitive types
+ * (1) those that are native types of the programming language such as long
+ * For these, no additional definition has to be done and they should be referenced
+ * with their name only
+ * (2) those that correspond to a typedef (e.g. typedef long ErrorType). These require
+ * a typedef definition within the package and need to be referenced with their
+ * fully qualified name (e.g. MyPackage::ErrorType)
+ */
+ // Retrieve type definition
+ CppType cppType = GenUtils.getApplication(currentPType, CppType.class);
+ if (cppType != null) {
+ typeDoc = jDoc.generate(currentPType);
+ definition = "typedef " + cppType.getDefinition();
+
+ // If definition string contains "typeName" it should be replaced with type name...
+ if (definition.indexOf("typeName") != -1) {
+ definition = definition.replaceAll("typeName", currentPTypeName);
+ } else {
+ definition = definition + " " + currentPTypeName;
+ }
+ definition = definition + ";";
+ }
+ else {
+ definition = GenUtils.getStdtypes(currentPType);
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////%>
+<%= typeDoc %>
+<%= definition %>

Back to the top