Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java
new file mode 100644
index 00000000000..999e3789ce1
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+import java.util.Iterator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppTemplateInlineOperationsImplementation
+{
+ protected static String nl;
+ public static synchronized CppTemplateInlineOperationsImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppTemplateInlineOperationsImplementation result = new CppTemplateInlineOperationsImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Class currentClass = (Class) argument;
+ String opDecl = "";
+ String tDecl = "";
+
+ // Retrieve template declaration
+ CppTemplateDeclaration jetTDecl = new CppTemplateDeclaration();
+ // tDecl should contain something like "template <class x, class y>"
+ tDecl = jetTDecl.generate(currentClass) + " ";
+
+ // Retrieve operations
+ Iterator<Operation> operations = currentClass.getOwnedOperations().iterator();
+ while (operations.hasNext()) {
+ Operation currentOperation = operations.next();
+
+ if (GenUtils.hasStereotype (currentOperation, CppInline.class) &&
+ !GenUtils.hasStereotype (currentOperation, CppNoCodeGen.class)) {
+ String opDoc = "";
+
+ // Doc for the template
+ CppOperationDoc jDoc = new CppOperationDoc();
+ opDoc = jDoc.generate(currentOperation);
+
+ CppOperationTemplateImplementation jetOpImpl = new CppOperationTemplateImplementation();
+ opDecl = opDecl+opDoc+NL+tDecl+jetOpImpl.generate(currentOperation)+NL;
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file

Back to the top