Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl79
1 files changed, 79 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl
new file mode 100644
index 00000000000..f37e2687c9d
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl
@@ -0,0 +1,79 @@
+[module CppOperationDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1', 'http://www.eclipse.org/uml2/4.0.0/UML/Profile/L2')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppParameter/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/]
+
+
+[template public virtualTxt(operation : Operation)]
+[if((operation.interface <> null) or (operation.isAbstract) or (operation.hasStereotype(Virtual)))]virtual [/if]
+[/template]
+
+
+[template public virtualSuffix(operation : Operation)]
+[if((operation.interface <> null) or (operation.isAbstract))] = 0[/if]
+[/template]
+
+
+[query public ConsDestructorOrVoid(operation : Operation) : String =
+if (hasStereotype(l2::Create)) then
+ ''
+else
+ if (hasStereotype(l2::Destroy)) then
+ '~'
+ else
+ 'void '
+ endif
+endif
+/]
+
+
+[template public CppReturnSpec(operation : Operation)]
+[modConst()/][if (type = null)][ConsDestructorOrVoid()/][else][type.qualifiedName()/] [/if][returnResult().modPtr()/][returnResult().modRef()/]
+[/template]
+
+
+[template public CppConstOp(operation : Operation)]
+[if (hasStereotype(operation, 'Const'))] const[/if]
+[/template]
+
+
+[template public InlineTxt(element : Element)]
+[if (hasStereotype(Inline))]inline [/if]
+[/template]
+
+
+[template public staticTxt(operation : Operation)]
+[if (isStatic)]static [/if]
+[/template]
+
+[template public CppOperationDeclaration(operation : Operation)]
+[CppOperationDoc()/]
+[InlineTxt()/][virtualTxt()/][staticTxt()/][CppReturnSpec()/] [operation.name/]([CppOperationParameters()/])[CppConstOp()/][virtualSuffix()/];
+[/template]
+
+
+[template public CppConstInit(operation : Operation)]
+[if (hasStereotype(ConstInit) and hasStereotype(l2::Create))] : [getApplication(ConstInit).oclAsType(ConstInit).initialisation/][/if]
+[/template]
+
+
+[comment wrapper for native query (otherwise Acceleo does not indent properly)/]
+[template public getBodyInTemplate(operation : Operation, language : String)]
+[getBody(language).trim()/]
+[/template]
+
+
+[template public CppOperationImplementation(operation : Operation)]
+[CppOperationDoc()/]
+[if (operation.name = 'main')]
+[CppReturnSpec()/][operation.name/]([CppOperationParameters()/]) {
+ [getBody('C/C++')/]
+}
+[else]
+[templateSignature()/][InlineTxt()/][CppReturnSpec()/][operation.class.name/]::[operation.name/]([CppOperationParameters()/])[CppConstOp()/][CppConstInit()/] {
+ [getBodyInTemplate('C/C++')/]
+}
+[/if]
+[/template]

Back to the top