diff options
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz')
8 files changed, 166 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl new file mode 100644 index 00000000000..0b184a07bc2 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl @@ -0,0 +1,12 @@ +[module CppClassAttributesDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::property::CppAttributeDeclaration/] + + + +[template public CppClassAttributesDeclaration(class : Classifier, visibilityFilter : VisibilityKind)] +[for (attribute->select(visibility = visibilityFilter))] + + [CppAttributeDeclaration()/] +[/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl new file mode 100644 index 00000000000..8477e8483dc --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl @@ -0,0 +1,15 @@ +[module CppClassFriendDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] + + +[template public CppClassFriendDeclaration(friend : Classifier)] +friend class [friend.qualifiedName()/];
+[/template] + +[template public CppClassIncludeFriendDeclaration(class : Classifier)] +[for (getUsedClassifiers())] + [if hasStereotype(C_Cpp::Friend) and (not hasStereotype(C_Cpp::NoCodeGen))] + [CppClassFriendDeclaration()/] + [/if] +[/for] +[/template]
\ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl new file mode 100644 index 00000000000..8db26305532 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl @@ -0,0 +1,40 @@ +[module CppClassIncludeClassDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeDeclaration/] + +[comment USED??? /] +[template public CppClassIncludeClassDeclarationTemplate(class : Class)] +[openNS()/]
+[if hasStereotype(class, 'CppTemplate.class')]template [/if]class [class.name/];
+[closeNS()/]
+[/template] + + +[template public CppOwnerPackageIncludeDeclaration(pkg : Package)] +[comment if currentPkg is not root it is referenced here/] +[if ((pkg <> null) and (not hasStereotype(CppRoot)))] +/* Owner package header include */ +#include <[getFullPath()/]/Pkg_[pkg.name/].h> +[/if] +[/template] + + +[template public CppClassAllIncludesDeclaration(class : Classifier)] +[for (cl : Classifier | includedClassifiers())] + [comment Only add include if this is not for the current class and if it does not have the stereotype "CppNoCodeGen", unless + it has stereotype "CppExternalClass"/] + [if((cl <> class) and (not hasStereotype(NoCodeGen)) or hasStereotype(ExternClass))] + [if(oclIsKindOf(Enumeration) or oclIsKindOf(PrimitiveType))] + [comment Enumeration is not defined in a separate file, but in the package that owns it + => include the owning package (might be a duplicate input, if owning package is also the owner of current class/] + [if (cl.owner.oclIsKindOf(Package))] +[cl.owner.oclAsType(Package).CppOwnerPackageIncludeDeclaration()/] + [/if] + [else] + [comment include file associated with the classifier/] +[CppClassIncludeDeclaration()/] + [/if] + [/if] +[/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl new file mode 100644 index 00000000000..9634496107a --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl @@ -0,0 +1,19 @@ +[module CppClassIncludeDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/] + + +[query public includeName(ne : NamedElement) : String = +if (hasStereotype(Template)) then + getApplication(Template).oclAsType(Template).declaration +else + if (hasStereotype(ExternClass)) then getApplication(ExternClass).oclAsType(ExternClass).name + else ne.name + '.' + getHeaderSuffix() + endif +endif +/] + +[comment TODO: original code did not use nearest package, if stereotype CppRoot was applied/] +[template public CppClassIncludeDeclaration(ne : NamedElement)] +#include <[getNearestPackage().getFullPath()/]/[ne.includeName()/]>
+[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl new file mode 100644 index 00000000000..22eb62b8de0 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl @@ -0,0 +1,24 @@ +[module CppClassInheritedDeclarations('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] + +[comment +Return a list of relationships that are either Generalizations or InterfaceRealiazations +and the target does not point to a classifier that has the no-code-gen Stereotype +TODO: not sure if it makes sense NOT to declare an inheritance, since we do not generate code. +/] +[query public filteredRelationships(class : Classifier) : Set(DirectedRelationship) = + getSourceDirectedRelationships()->select( + (oclIsKindOf(Generalization) or oclIsKindOf(InterfaceRealization)) and + (not target->asSequence()->first().hasStereotype(NoCodeGen)) + ) +/] + +[query public getCppVisibility(relationship : Relationship) : String = +if (hasStereotype(Visibility)) then getApplication(Visibility).oclAsType(Visibility).value else 'public' endif +/] + +[template public CppClassInheritedDeclarations(class : Classifier)] +[if (filteredRelationships()->size() > 0)] : [/if] +[for (filteredRelationships()) separator(', \n')] + [getCppVisibility()/] [target->asSequence()->first().oclAsType(Classifier).qualifiedName()/][/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl new file mode 100644 index 00000000000..e15580adddf --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl @@ -0,0 +1,11 @@ +[module CppClassOperationsDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppOperationDeclaration/] + + +[template public CppClassOperationsDeclaration(class : Classifier, visibilityFilter : VisibilityKind)] +[for (getOperations()->select(visibility = visibilityFilter))] + + [CppOperationDeclaration()/] +[/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl new file mode 100644 index 00000000000..aeaf01f3fe6 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl @@ -0,0 +1,15 @@ +[module CppClassOperationsImplementation('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppOperationDeclaration/] + + +[comment implementations of a classifier, parameter controls whether only inline (or only not inline) operations + are produced/] +[template public CppClassOperationsImplementation(class : Classifier, inline : Boolean)] +[for (getOperations()->select( + (not (hasStereotype(NoCodeGen) or isAbstract)) and + (hasStereotype(C_Cpp::Inline) = inline)))] + +[CppOperationImplementation()/] +[/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl new file mode 100644 index 00000000000..50f2a7c4928 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl @@ -0,0 +1,30 @@ +[module CppClassTypeAndEnum('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppPrimitiveTypes/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppEnumerations/] + +[template public TypeAndEnumForVisibility(element : Element, visibilityFilter : VisibilityKind)] +[if (not hasStereotype(NoCodeGen) and oclIsKindOf(Classifier) and oclAsType(Classifier).visibility = visibilityFilter)] +[ if (oclIsKindOf(Enumeration))][oclAsType(Enumeration).CppEnumerationDefinition()/][/if] +[ if (oclIsKindOf(PrimitiveType))][oclAsType(PrimitiveType).CppPrimitiveTypeDefinition()/][/if] +[/if] +[/template] + +[template public TypesAndEnumsForVisibility(ne : Namespace, visibilityFilter : VisibilityKind)] +[for (ownedElement)][TypeAndEnumForVisibility(visibilityFilter)/][/for] +[/template] + +[template public CppClassTypeAndEnum(class : Classifier)] + public: + [TypesAndEnumsForVisibility(VisibilityKind::public)/] + protected: + [TypesAndEnumsForVisibility(VisibilityKind::protected)/] + private: + [TypesAndEnumsForVisibility(VisibilityKind::private)/]
+[/template] + + +[template public CppClassTypeAndEnumPackage(pkg : Package)] +[TypesAndEnumsForVisibility(VisibilityKind::_package)/] +[TypesAndEnumsForVisibility(VisibilityKind::public)/] +[/template]
\ No newline at end of file |