diff options
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl')
-rw-r--r-- | extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl new file mode 100644 index 00000000000..81c80bce0db --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl @@ -0,0 +1,76 @@ +[module CppOperations('http://www.eclipse.org/uml2/4.0.0/UML', 'http://www.eclipse.org/papyrus/C_Cpp/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) or hasStereotype(l2::Destroy) then + '' +else + 'void ' +endif/] + + +[query public destructor(operation : Operation) : String = +if hasStereotype(l2::Destroy) then + '~' +else + '' +endif/] + +[template public CppReturnSpec(operation : Operation)] +[if (type = null)][ConsDestructorOrVoid()/][else][returnResult().modConst()/] [type.qualifiedName()/] [/if][returnResult().modPtr()/][returnResult().modRef()/] +[/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()/] [destructor()/][operation.name/]([CppOperationParameters(true)/])[modConst()/][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(false)/]) { + [getBody('C/C++')/] +} +[else] +[templateSignature()/][InlineTxt()/][CppReturnSpec()/][operation.class.name/][templateShortSignature()/]::[destructor()/][operation.name/]([CppOperationParameters(false)/])[modConst()/][CppConstInit()/] { + [getBodyInTemplate('C/C++')/] +} +[/if] +[/template] |