From 168bcb97ea99372e921c00bd859b0bab61076cf8 Mon Sep 17 00:00:00 2001 From: aradermache Date: Thu, 4 Apr 2013 22:03:13 +0000 Subject: Transition to Acceleo based generator --- .../org.eclipse.papyrus.cpp.codegen/.classpath | 1 - .../org.eclipse.papyrus.cpp.codegen/.project | 18 +- .../META-INF/MANIFEST.MF | 6 +- .../org.eclipse.papyrus.cpp.codegen/build.acceleo | 26 ++ .../build.properties | 18 +- .../papyrus/cpp/codegen/jet/CppBindBody.java | 167 -------- .../papyrus/cpp/codegen/jet/CppBindHeader.java | 186 --------- .../papyrus/cpp/codegen/jet/CppClassBody.java | 147 -------- .../papyrus/cpp/codegen/jet/CppClassHeader.java | 278 -------------- .../cpp/codegen/jet/CppInterfaceHeader.java | 160 -------- .../papyrus/cpp/codegen/jet/CppPackageHeader.java | 203 ---------- .../papyrus/cpp/codegen/jet/CppTemplateHeader.java | 288 -------------- .../papyrus/cpp/codegen/jet/doc/CppElementDoc.java | 58 --- .../cpp/codegen/jet/doc/CppOperationDoc.java | 82 ---- .../papyrus/cpp/codegen/jet/doc/CppParamDoc.java | 57 --- .../codegen/jet/util/CppAttributeDeclaration.java | 124 ------ .../jet/util/CppAttributeImplementation.java | 105 ------ .../jet/util/CppClassAllIncludesDeclaration.java | 89 ----- .../jet/util/CppClassAttributesDeclaration.java | 59 --- .../jet/util/CppClassAttributesImplementation.java | 71 ---- .../jet/util/CppClassFriendDeclaration.java | 52 --- .../jet/util/CppClassIncludeClassDeclaration.java | 72 ---- .../jet/util/CppClassIncludeDeclaration.java | 88 ----- .../jet/util/CppClassIncludeFriendDeclaration.java | 71 ---- .../jet/util/CppClassInheritedDeclarations.java | 130 ------- .../CppClassInlineOperationsImplementation.java | 63 ---- .../jet/util/CppClassOperationsDeclaration.java | 68 ---- .../jet/util/CppClassOperationsImplementation.java | 63 ---- .../cpp/codegen/jet/util/CppClassTypeAndEnum.java | 134 ------- .../jet/util/CppClassTypeAndEnumPackage.java | 97 ----- .../codegen/jet/util/CppEnumerationDefinition.java | 113 ------ .../util/CppInterfaceAllIncludesDeclaration.java | 113 ------ .../jet/util/CppInterfaceIncludeDeclaration.java | 71 ---- .../util/CppInterfaceInheritedDeclarations.java | 84 ----- .../CppInterfacePublicOperationsDeclaration.java | 69 ---- .../codegen/jet/util/CppOperationDeclaration.java | 142 ------- .../jet/util/CppOperationImplementation.java | 171 --------- .../codegen/jet/util/CppOperationParameters.java | 64 ---- .../CppOperationParametersWithoutDefaultValue.java | 62 --- .../codegen/jet/util/CppOperationReturnType.java | 118 ------ .../util/CppOperationTemplateImplementation.java | 158 -------- .../util/CppOwnerPackageIncludeDeclaration.java | 82 ---- .../papyrus/cpp/codegen/jet/util/CppParameter.java | 76 ---- .../jet/util/CppParameterWithoutDefaultValue.java | 111 ------ .../jet/util/CppPrimitiveTypeDefinition.java | 90 ----- .../jet/util/CppStaticAttributeImplementation.java | 102 ----- .../jet/util/CppTemplateBindingParameter.java | 63 ---- .../codegen/jet/util/CppTemplateDeclaration.java | 69 ---- .../CppTemplateInlineOperationsImplementation.java | 75 ---- .../cpp/codegen/jet/util/CppTemplateParameter.java | 68 ---- .../org/eclipse/papyrus/cpp/codegen/Constants.java | 2 + .../papyrus/cpp/codegen/acceleo/Constants.mtl | 52 +++ .../papyrus/cpp/codegen/acceleo/CppBindBody.mtl | 40 ++ .../papyrus/cpp/codegen/acceleo/CppBindHeader.mtl | 38 ++ .../papyrus/cpp/codegen/acceleo/CppClassBody.mtl | 37 ++ .../papyrus/cpp/codegen/acceleo/CppClassHeader.mtl | 94 +++++ .../cpp/codegen/acceleo/CppPackageHeader.mtl | 52 +++ .../papyrus/cpp/codegen/acceleo/IncludeUtils.mtl | 28 ++ .../cpp/codegen/acceleo/util/CppDocumentation.mtl | 22 ++ .../cpp/codegen/acceleo/util/CppEnumerations.mtl | 14 + .../cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl | 29 ++ .../cpp/codegen/acceleo/util/CppTemplates.mtl | 26 ++ .../util/clazz/CppClassAttributesDeclaration.mtl | 12 + .../util/clazz/CppClassFriendDeclaration.mtl | 15 + .../util/clazz/CppClassIncludeClassDeclaration.mtl | 40 ++ .../util/clazz/CppClassIncludeDeclaration.mtl | 19 + .../util/clazz/CppClassInheritedDeclarations.mtl | 24 ++ .../util/clazz/CppClassOperationsDeclaration.mtl | 11 + .../clazz/CppClassOperationsImplementation.mtl | 15 + .../acceleo/util/clazz/CppClassTypeAndEnum.mtl | 30 ++ .../util/operation/CppOperationDeclaration.mtl | 79 ++++ .../acceleo/util/operation/CppParameter.mtl | 18 + .../util/property/CppAttributeDeclaration.mtl | 21 ++ .../util/property/CppAttributeImplementation.mtl | 35 ++ .../codegen/preferences/CppCodeGenConstants.java | 5 + .../CppCodeGenPreferenceInitializer.java | 1 + .../cpp/codegen/preferences/CppCodeGenUtils.java | 5 + .../cpp/codegen/preferences/CppCodeGenUtils.mtl | 13 + .../transformation/CppModelElementsCreator.java | 158 ++++++++ .../transformation/ModelElementsCreator.java | 420 --------------------- .../papyrus/cpp/codegen/utils/ClassUtils.java | 152 ++------ .../papyrus/cpp/codegen/utils/ClassUtils.mtl | 6 + .../papyrus/cpp/codegen/utils/GenUtils.java | 129 ++++--- .../eclipse/papyrus/cpp/codegen/utils/GenUtils.mtl | 104 +++++ .../papyrus/cpp/codegen/utils/Modifier.java | 96 ++++- .../eclipse/papyrus/cpp/codegen/utils/Modifier.mtl | 15 + .../templates/CppBindBody.cpp.jet | 87 ----- .../templates/CppBindHeader.h.jet | 115 ------ .../templates/CppClassBody.cpp.jet | 71 ---- .../templates/CppClassHeader.h.jet | 192 ---------- .../templates/CppInterfaceHeader.h.jet | 99 ----- .../templates/CppPackageHeader.h.jet | 138 ------- .../templates/CppTemplateHeader.h.jet | 202 ---------- .../templates/doc/CppElementDoc.doc.jet | 27 -- .../templates/doc/CppOperationDoc.doc.jet | 47 --- .../templates/doc/CppParamDoc.doc.jet | 23 -- .../templates/generator.skeleton | 19 - .../templates/generatorTwoArgs.skeleton | 19 - .../class/CppClassAllIncludesDeclaration.util.jet | 47 --- .../class/CppClassAttributesDeclaration.util.jet | 28 -- .../util/class/CppClassFriendDeclaration.util.jet | 18 - .../class/CppClassIncludeClassDeclaration.util.jet | 28 -- .../util/class/CppClassIncludeDeclaration.util.jet | 49 --- .../CppClassIncludeFriendDeclaration.util.jet | 38 -- .../class/CppClassInheritedDeclarations.util.jet | 96 ----- ...CppClassInlineOperationsImplementation.util.jet | 30 -- .../class/CppClassOperationsDeclaration.util.jet | 35 -- .../CppClassOperationsImplementation.util.jet | 30 -- .../util/class/CppClassTypeAndEnum.util.jet | 93 ----- .../util/class/CppClassTypeAndEnumPackage.util.jet | 59 --- .../util/enum/CppEnumerationDefinition.util.jet | 72 ---- .../CppInterfaceAllIncludesDeclaration.util.jet | 72 ---- .../CppInterfaceIncludeDeclaration.util.jet | 29 -- .../CppInterfaceInheritedDeclarations.util.jet | 49 --- ...ppInterfacePublicOperationsDeclaration.util.jet | 34 -- .../operation/CppOperationDeclaration.util.jet | 96 ----- .../operation/CppOperationImplementation.util.jet | 99 ----- .../util/operation/CppOperationParameters.util.jet | 35 -- ...OperationParametersWithoutDefaultValue.util.jet | 33 -- .../util/operation/CppOperationReturnType.util.jet | 76 ---- .../CppOperationTemplateImplementation.util.jet | 90 ----- .../CppOwnerPackageIncludeDeclaration.util.jet | 40 -- .../templates/util/parameter/CppParameter.util.jet | 36 -- .../CppParameterWithoutDefaultValue.util.jet | 56 --- .../util/property/CppAttributeDeclaration.util.jet | 78 ---- .../property/CppAttributeImplementation.util.jet | 58 --- .../CppClassAttributesImplementation.util.jet | 37 -- .../CppStaticAttributeImplementation.util.jet | 56 --- .../template/CppTemplateBindingParameter.util.jet | 35 -- .../util/template/CppTemplateDeclaration.h.jet | 33 -- ...TemplateInlineOperationsImplementation.util.jet | 42 --- .../util/template/CppTemplateParameter.util.jet | 34 -- .../util/type/CppPrimitiveTypeDefinition.util.jet | 53 --- 133 files changed, 1271 insertions(+), 8301 deletions(-) create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindBody.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindHeader.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassBody.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassHeader.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppInterfaceHeader.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppPackageHeader.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppTemplateHeader.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppElementDoc.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppOperationDoc.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppParamDoc.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/Constants.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindBody.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindHeader.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassBody.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppPackageHeader.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/IncludeUtils.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/CppModelElementsCreator.java delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/ModelElementsCreator.java create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.mtl create mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.mtl delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindBody.cpp.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindHeader.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassBody.cpp.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassHeader.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppInterfaceHeader.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppPackageHeader.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppTemplateHeader.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppElementDoc.doc.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppOperationDoc.doc.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppParamDoc.doc.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generator.skeleton delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generatorTwoArgs.skeleton delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAllIncludesDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAttributesDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassFriendDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeClassDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeFriendDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInheritedDeclarations.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInlineOperationsImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnum.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnumPackage.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/enum/CppEnumerationDefinition.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceAllIncludesDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceIncludeDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceInheritedDeclarations.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfacePublicOperationsDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParameters.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParametersWithoutDefaultValue.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationReturnType.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationTemplateImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/package/CppOwnerPackageIncludeDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameter.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameterWithoutDefaultValue.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateBindingParameter.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateDeclaration.h.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateInlineOperationsImplementation.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateParameter.util.jet delete mode 100644 extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen') diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.classpath b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.classpath index 9fd92a96b67..64c5e31b7a2 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.classpath +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.classpath @@ -3,6 +3,5 @@ - diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.project b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.project index 50424ef89ab..196a852f4c5 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.project +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/.project @@ -6,34 +6,30 @@ - org.eclipse.emf.codegen.JETBuilder - - - - - com.ibm.etools.common.migration.MigrationBuilder + org.eclipse.jdt.core.javabuilder - org.eclipse.jdt.core.javabuilder + org.eclipse.pde.ManifestBuilder - org.eclipse.pde.ManifestBuilder + org.eclipse.pde.SchemaBuilder - org.eclipse.pde.SchemaBuilder + org.eclipse.acceleo.ide.ui.acceleoBuilder - org.eclipse.emf.codegen.jet.IJETNature - org.eclipse.pde.PluginNature + org.eclipse.acceleo.ide.ui.acceleoNature org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/META-INF/MANIFEST.MF b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/META-INF/MANIFEST.MF index 0267a84d5f1..647ebebb0c1 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/META-INF/MANIFEST.MF +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/META-INF/MANIFEST.MF @@ -13,12 +13,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.resources, org.eclipse.papyrus.cpp.profile;bundle-version="0.10.0", org.eclipse.ui.ide;bundle-version="3.8.0", - org.eclipse.core.filesystem;bundle-version="1.3.200" + org.eclipse.core.filesystem;bundle-version="1.3.200", + org.eclipse.papyrus.acceleo;bundle-version="0.10.0" Eclipse-LazyStart: true Export-Package: org.eclipse.papyrus.cpp.codegen, - org.eclipse.papyrus.cpp.codegen.jet, - org.eclipse.papyrus.cpp.codegen.jet.doc, - org.eclipse.papyrus.cpp.codegen.jet.util, org.eclipse.papyrus.cpp.codegen.preferences, org.eclipse.papyrus.cpp.codegen.transformation, org.eclipse.papyrus.cpp.codegen.utils diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo new file mode 100644 index 00000000000..8c148cc5dcd --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.properties b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.properties index 1826a56a2e7..c58c8b13617 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.properties +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.properties @@ -1,11 +1,7 @@ -source.. = src/,\ - jetsrc/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - templates/,\ - bin/,\ - plugin.properties,\ - about.html -src.includes = about.html +# +#Tue Mar 26 23:29:07 CET 2013 +bin.includes=META-INF/,.,plugin.xml,templates/,bin/,plugin.properties,about.html +output..=bin/ +src.includes=about.html +source..=src/ +customBuildCallbacks=build.acceleo diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindBody.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindBody.java deleted file mode 100644 index 016a7d87da1..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindBody.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.Constants; -import org.eclipse.papyrus.cpp.codegen.utils.*; -import Cpp.CppInclude; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.*; -import org.eclipse.emf.common.util.EList; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import java.util.*; -import org.eclipse.papyrus.cpp.codegen.Activator; - -public class CppBindBody -{ - protected static String nl; - public static synchronized CppBindBody create(String lineSeparator) - { - nl = lineSeparator; - CppBindBody result = new CppBindBody(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#define "; - protected final String TEXT_2 = "_BODY" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_3 = NL + " "; - protected final String TEXT_4 = " template binding body" + NL + " ************************************************************/" + NL; - protected final String TEXT_5 = NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL; - protected final String TEXT_10 = NL + "#include <"; - protected final String TEXT_11 = "."; - protected final String TEXT_12 = ">" + NL; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL; - protected final String TEXT_15 = NL; - protected final String TEXT_16 = NL; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL; - protected final String TEXT_19 = NL; - protected final String TEXT_20 = NL; - protected final String TEXT_21 = NL + NL + "/************************************************************/" + NL + "template class "; - protected final String TEXT_22 = " <"; - protected final String TEXT_23 = ">;" + NL; - protected final String TEXT_24 = NL; - protected final String TEXT_25 = NL + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_26 = " template binding body" + NL + " ************************************************************/"; - protected final String TEXT_27 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName (currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String parentClass = ""; - String namespace = GenUtils.getNamespace (currentClass); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Retrieve owner Package - Package owner = currentClass.getPackage(); - String fullPath = ""; - - if (owner != null) { - fullPath = GenUtils.getFullPath(owner) + "/"; - } // else fullPath == "" - - TemplateBinding tb = GenUtils.getTemplateBindings(currentClass);; - - // prepare parent class declaration - EList templates = tb.getTargets(); - Class templateClass = (Class) ((TemplateSignature) templates.get(0)).getOwner(); - parentClass = GenUtils.qualifiedName (templateClass); - - // Prepare bindings parameter declaration - - String tParamDecl = ""; - Iterator tps = tb.getParameterSubstitutions().iterator(); - while(tps.hasNext()) { - TemplateParameterSubstitution paramSub = tps.next(); - - CppTemplateBindingParameter jetTParam = new CppTemplateBindingParameter(); - tParamDecl = tParamDecl+jetTParam.generate (paramSub); - - if (tps.hasNext()) { - tParamDecl = tParamDecl + ", "; - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append( className ); - stringBuffer.append(TEXT_4); - stringBuffer.append(TEXT_5); - stringBuffer.append( Constants.cppIncPreBodyStart ); - stringBuffer.append(TEXT_6); - stringBuffer.append( ClassUtils.getCppIncludePreBody(currentClass) ); - stringBuffer.append(TEXT_7); - stringBuffer.append( Constants.cppIncPreBodyEnd ); - stringBuffer.append(TEXT_8); - stringBuffer.append(TEXT_9); - stringBuffer.append( Constants.includeHFile ); - stringBuffer.append(TEXT_10); - stringBuffer.append( fullPath ); - stringBuffer.append( className ); - stringBuffer.append(TEXT_11); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_12); - stringBuffer.append(TEXT_13); - stringBuffer.append( Constants.cppIncBodyStart ); - stringBuffer.append(TEXT_14); - stringBuffer.append( ClassUtils.getCppIncludeBody(currentClass) ); - stringBuffer.append(TEXT_15); - stringBuffer.append( Constants.cppIncBodyEnd ); - stringBuffer.append(TEXT_16); - stringBuffer.append(TEXT_17); - stringBuffer.append( GenUtils.openNS(currentClass) ); - stringBuffer.append(TEXT_18); - stringBuffer.append(TEXT_19); - stringBuffer.append( Constants.derivedIncludes ); - stringBuffer.append(TEXT_20); - stringBuffer.append( ClassUtils.createIncludeDecl(currentClass) ); - stringBuffer.append(TEXT_21); - stringBuffer.append( parentClass ); - stringBuffer.append(TEXT_22); - stringBuffer.append( tParamDecl ); - stringBuffer.append(TEXT_23); - stringBuffer.append(TEXT_24); - stringBuffer.append( GenUtils.closeNS(currentClass) ); - stringBuffer.append(TEXT_25); - stringBuffer.append( className ); - stringBuffer.append(TEXT_26); - stringBuffer.append(TEXT_27); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindHeader.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindHeader.java deleted file mode 100644 index cd28f8d1210..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppBindHeader.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.CppInclude; -import org.eclipse.uml2.uml.Class; -import org.eclipse.emf.common.util.EList; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.TemplateSignature; -import org.eclipse.uml2.uml.TemplateParameterSubstitution; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import java.util.*; -import org.eclipse.papyrus.cpp.codegen.Activator; - -public class CppBindHeader -{ - protected static String nl; - public static synchronized CppBindHeader create(String lineSeparator) - { - nl = lineSeparator; - CppBindHeader result = new CppBindHeader(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#ifndef "; - protected final String TEXT_2 = "_H" + NL + "#define "; - protected final String TEXT_3 = "_H" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_4 = NL + " "; - protected final String TEXT_5 = " template binding header" + NL + " ************************************************************/" + NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL; - protected final String TEXT_10 = NL; - protected final String TEXT_11 = NL + NL + "#include <"; - protected final String TEXT_12 = "."; - protected final String TEXT_13 = ">" + NL; - protected final String TEXT_14 = NL; - protected final String TEXT_15 = " " + NL + "/************************************************************/" + NL + "typedef "; - protected final String TEXT_16 = " <"; - protected final String TEXT_17 = "> "; - protected final String TEXT_18 = ";" + NL; - protected final String TEXT_19 = NL; - protected final String TEXT_20 = NL + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_21 = " template binding header" + NL + " ************************************************************/" + NL + "" + NL + "#endif"; - protected final String TEXT_22 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName (currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String classparent = ""; - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - //find path for the package owning current class - String fullPath = ""; - String separ = ""; - - if (ownerPackage != null) { - fullPath = GenUtils.getFullPath (ownerPackage); - separ = "/"; - } // else fullPath == "" - - org.eclipse.uml2.uml.TemplateBinding tb = GenUtils.getTemplateBindings(currentClass); - - // prepare parent class declaration - EList templates = tb.getTargets(); - Class templateClass = (Class) ((TemplateSignature)templates.get(0)).getOwner(); - classparent = templateClass.getName(); - - // Prepare bindings parameter declaration - - String tParamDecl=""; - TemplateParameterSubstitution paramsub; - Iterator tps = tb.getParameterSubstitutions().iterator(); - while(tps.hasNext()) { - paramsub = (TemplateParameterSubstitution)tps.next(); - - CppTemplateBindingParameter jetTParam - = new CppTemplateBindingParameter(); - tParamDecl = tParamDecl+jetTParam.generate(paramsub); - - if (tps.hasNext()) { - tParamDecl = tParamDecl+", "; - } - } - - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes - = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */"+NL+classIncludes; - } - - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - stringBuffer.append( className ); - stringBuffer.append(TEXT_5); - stringBuffer.append(TEXT_6); - stringBuffer.append( ownerInclude ); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append( classIncludes ); - stringBuffer.append(TEXT_9); - stringBuffer.append(TEXT_10); - stringBuffer.append( headerDecl ); - stringBuffer.append(TEXT_11); - stringBuffer.append( fullPath ); - stringBuffer.append( separ ); - stringBuffer.append( classparent ); - stringBuffer.append(TEXT_12); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_13); - stringBuffer.append(TEXT_14); - stringBuffer.append( openNS ); - stringBuffer.append(TEXT_15); - stringBuffer.append( classparent ); - stringBuffer.append(TEXT_16); - stringBuffer.append( tParamDecl ); - stringBuffer.append(TEXT_17); - stringBuffer.append( className ); - stringBuffer.append(TEXT_18); - stringBuffer.append(TEXT_19); - stringBuffer.append( closeNS ); - stringBuffer.append(TEXT_20); - stringBuffer.append( className ); - stringBuffer.append(TEXT_21); - stringBuffer.append(TEXT_22); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassBody.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassBody.java deleted file mode 100644 index 6d61bd37fe2..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassBody.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.Constants; -import org.eclipse.papyrus.cpp.codegen.utils.*; -import org.eclipse.emf.common.util.EList; -import Cpp.CppInclude; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Package; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import org.eclipse.papyrus.cpp.codegen.Activator; - -public class CppClassBody -{ - protected static String nl; - public static synchronized CppClassBody create(String lineSeparator) - { - nl = lineSeparator; - CppClassBody result = new CppClassBody(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#define "; - protected final String TEXT_2 = "_BODY" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_3 = NL + " "; - protected final String TEXT_4 = " class body" + NL + " ************************************************************/" + NL; - protected final String TEXT_5 = NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL + "#include <"; - protected final String TEXT_10 = "."; - protected final String TEXT_11 = ">" + NL; - protected final String TEXT_12 = NL; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL; - protected final String TEXT_15 = NL; - protected final String TEXT_16 = NL; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL; - protected final String TEXT_19 = NL; - protected final String TEXT_20 = NL; - protected final String TEXT_21 = NL; - protected final String TEXT_22 = NL + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_23 = " class body" + NL + " ************************************************************/"; - protected final String TEXT_24 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName= GenUtils.getFullName (currentClass); - String classFULLNAME= classFullName.toUpperCase(); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // TODO - Prepare static attribute - String staticAttributes = ""; - - // Retrieve owner Package - Package owner = currentClass.getPackage(); - String fullPath = ""; - - if (owner != null) { - fullPath = GenUtils.getFullPath(owner) + "/"; - } // else fullPath == "" - - // Prepare attributes and Methods declarations - String allOperations = ""; - - // Methods - CppClassOperationsImplementation jetClassOp - = new CppClassOperationsImplementation(); - allOperations = jetClassOp.generate(currentClass); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append( className ); - stringBuffer.append(TEXT_4); - stringBuffer.append(TEXT_5); - stringBuffer.append( Constants.cppIncPreBodyStart ); - stringBuffer.append(TEXT_6); - stringBuffer.append( ClassUtils.getCppIncludePreBody(currentClass) -); - stringBuffer.append( Constants.cppIncPreBodyEnd ); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append( Constants.includeHFile ); - stringBuffer.append(TEXT_9); - stringBuffer.append( fullPath ); - stringBuffer.append( className ); - stringBuffer.append(TEXT_10); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_11); - stringBuffer.append(TEXT_12); - stringBuffer.append( Constants.cppIncBodyStart ); - stringBuffer.append(TEXT_13); - stringBuffer.append( ClassUtils.getCppIncludeBody(currentClass) -); - stringBuffer.append( Constants.cppIncBodyEnd ); - stringBuffer.append(TEXT_14); - stringBuffer.append(TEXT_15); - stringBuffer.append( Constants.derivedIncludes ); - stringBuffer.append(TEXT_16); - stringBuffer.append( ClassUtils.createIncludeDecl(currentClass) ); - stringBuffer.append(TEXT_17); - stringBuffer.append(TEXT_18); - stringBuffer.append( GenUtils.openNS(currentClass) ); - stringBuffer.append(TEXT_19); - stringBuffer.append( ClassUtils.getStaticAttributes(currentClass) ); - stringBuffer.append(TEXT_20); - stringBuffer.append( allOperations ); - stringBuffer.append(TEXT_21); - stringBuffer.append( GenUtils.closeNS(currentClass) ); - stringBuffer.append(TEXT_22); - stringBuffer.append( className ); - stringBuffer.append(TEXT_23); - stringBuffer.append(TEXT_24); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassHeader.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassHeader.java deleted file mode 100644 index d7ac634c428..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppClassHeader.java +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.CppInclude; -import Cpp.Union; -import org.eclipse.papyrus.cpp.codegen.StdStereo; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; - -public class CppClassHeader -{ - protected static String nl; - public static synchronized CppClassHeader create(String lineSeparator) - { - nl = lineSeparator; - CppClassHeader result = new CppClassHeader(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#ifndef "; - protected final String TEXT_2 = "_H" + NL + "#define "; - protected final String TEXT_3 = "_H" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_4 = NL + " "; - protected final String TEXT_5 = " class header" + NL + " ************************************************************/" + NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL; - protected final String TEXT_10 = NL; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = " "; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL + "/************************************************************/"; - protected final String TEXT_15 = NL; - protected final String TEXT_16 = NL; - protected final String TEXT_17 = " "; - protected final String TEXT_18 = " {"; - protected final String TEXT_19 = NL; - protected final String TEXT_20 = NL + NL + " public:"; - protected final String TEXT_21 = NL; - protected final String TEXT_22 = NL + NL + " protected:"; - protected final String TEXT_23 = NL; - protected final String TEXT_24 = NL + NL + " private:"; - protected final String TEXT_25 = NL; - protected final String TEXT_26 = NL + NL + "};" + NL + "/************************************************************/" + NL + "/* External declarations (package visibility) */"; - protected final String TEXT_27 = NL; - protected final String TEXT_28 = NL; - protected final String TEXT_29 = NL + "/************************************************************/" + NL + "/* Inline functions */"; - protected final String TEXT_30 = NL; - protected final String TEXT_31 = NL; - protected final String TEXT_32 = NL + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_33 = " class header" + NL + " ************************************************************/" + NL + "" + NL + "#endif"; - protected final String TEXT_34 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFULLNAME = GenUtils.getFullName (currentClass).toUpperCase(); - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - String classDoc = ""; - String classOrStruct = GenUtils.hasStereotype(currentClass, Union.class) ? "union" : - ((currentClass instanceof DataType) ? "struct" : "class"); - - // Doc for the class - CppElementDoc jDoc = new CppElementDoc(); - classDoc = jDoc.generate(currentClass); - - String includeProtection; - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = GenUtils.maskNull(cppInclude.getHeader()); - if (headerDecl.length() > 0) { - headerDecl = "// Include from CppInclude declaration" + NL + headerDecl.replace("HFILENAME", classFULLNAME) + NL; - } - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - - // Prepare owned type and enum declaration - String typeEnumDefPackage = ""; - String typeEnumDef = ""; - - CppClassTypeAndEnum jetTE = new CppClassTypeAndEnum(); - typeEnumDef = jetTE.generate(currentClass); - - CppClassTypeAndEnumPackage jetTEp - = new CppClassTypeAndEnumPackage(); - typeEnumDefPackage = jetTEp.generate(currentClass); - - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes - = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */"+NL+classIncludes; - } - - // Prepare friend dependency includes - CppClassIncludeFriendDeclaration jetClassFIncludes - = new CppClassIncludeFriendDeclaration(); - String friendIncludes = jetClassFIncludes.generate(argument); - if (!friendIncludes.equals("")) { - friendIncludes = "/* Friend class declaration */"+NL+friendIncludes; - } - - // Prepare attributes and Methods declarations - String publicAttributes = ""; - String publicOperations = ""; - String protectedAttributes = ""; - String protectedOperations = ""; - String privateAttributes = ""; - String privateOperations = ""; - String packageAttributes = ""; - String packageOperations = ""; - - // Attributes - CppClassAttributesDeclaration jetClassPAttr = new CppClassAttributesDeclaration(); - publicAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - packageAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PACKAGE_LITERAL); - - // Methods - CppClassOperationsDeclaration jetClassPOp = new CppClassOperationsDeclaration(); - publicOperations = jetClassPOp.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedOperations = jetClassPOp.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateOperations = jetClassPOp.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - packageOperations = jetClassPOp.generate(currentClass, VisibilityKind.PACKAGE_LITERAL); - - boolean hasConstructor = false; - for (Operation operation : currentClass.getOperations ()) { - if (GenUtils.hasStereotype(operation, StdStereo.create)) { - hasConstructor = true; - break; - } - } - String defaultInitializer = ""; - for (Property attribute : currentClass.getAttributes ()) { - if (attribute.isStatic()) { - // static attributes are initialized differently - continue; - } - ValueSpecification vs = attribute.getDefaultValue (); - if ((vs != null) && (vs.stringValue() != null)) { - if (!defaultInitializer.equals("")) { - // not first attribute - defaultInitializer += ", "; - } - defaultInitializer += attribute.getName () + "(" + vs.stringValue() + ")"; - } - } - // no constructor, add it, if some properties have default values - if ((!hasConstructor) && (!defaultInitializer.equals (""))) { - defaultInitializer = className + "() : " + defaultInitializer + " {}"; - } - else { - defaultInitializer = ""; - } - - // Inline functions implementations - String inlineFunctionsImplementation = ""; - CppClassInlineOperationsImplementation jetInlineClassPOp - = new CppClassInlineOperationsImplementation(); - inlineFunctionsImplementation = jetInlineClassPOp.generate(currentClass); - - // Prepare inherited classes or implemented interfaces - String inheritedDeclarations = ""; - CppClassInheritedDeclarations jetInherited - = new CppClassInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentClass); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - stringBuffer.append( className ); - stringBuffer.append(TEXT_5); - stringBuffer.append(TEXT_6); - stringBuffer.append( ownerInclude ); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append( classIncludes ); - stringBuffer.append(TEXT_9); - stringBuffer.append(TEXT_10); - stringBuffer.append( headerDecl ); - stringBuffer.append(TEXT_11); - stringBuffer.append( openNS ); - stringBuffer.append(TEXT_12); - stringBuffer.append(TEXT_13); - stringBuffer.append( typeEnumDefPackage ); - stringBuffer.append(TEXT_14); - stringBuffer.append(TEXT_15); - stringBuffer.append( classDoc ); - stringBuffer.append(TEXT_16); - stringBuffer.append( classOrStruct ); - stringBuffer.append(TEXT_17); - stringBuffer.append( className ); - stringBuffer.append( inheritedDeclarations ); - stringBuffer.append(TEXT_18); - stringBuffer.append(TEXT_19); - stringBuffer.append( friendIncludes ); - stringBuffer.append( typeEnumDef ); - stringBuffer.append(TEXT_20); - stringBuffer.append(TEXT_21); - stringBuffer.append( defaultInitializer ); - stringBuffer.append( publicAttributes ); - stringBuffer.append( publicOperations ); - stringBuffer.append(TEXT_22); - stringBuffer.append(TEXT_23); - stringBuffer.append( protectedAttributes ); - stringBuffer.append( protectedOperations ); - stringBuffer.append(TEXT_24); - stringBuffer.append(TEXT_25); - stringBuffer.append( privateAttributes ); - stringBuffer.append( privateOperations ); - stringBuffer.append(TEXT_26); - stringBuffer.append(TEXT_27); - stringBuffer.append( packageAttributes ); - stringBuffer.append(TEXT_28); - stringBuffer.append( packageOperations ); - stringBuffer.append(TEXT_29); - stringBuffer.append(TEXT_30); - stringBuffer.append( inlineFunctionsImplementation ); - stringBuffer.append(TEXT_31); - stringBuffer.append( closeNS ); - stringBuffer.append(TEXT_32); - stringBuffer.append( className ); - stringBuffer.append(TEXT_33); - stringBuffer.append(TEXT_34); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppInterfaceHeader.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppInterfaceHeader.java deleted file mode 100644 index 933b4a00407..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppInterfaceHeader.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.uml2.uml.Interface; -import org.eclipse.uml2.uml.Package; -import Cpp.CppInclude; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; - -public class CppInterfaceHeader -{ - protected static String nl; - public static synchronized CppInterfaceHeader create(String lineSeparator) - { - nl = lineSeparator; - CppInterfaceHeader result = new CppInterfaceHeader(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#ifndef "; - protected final String TEXT_2 = "_H" + NL + "#define "; - protected final String TEXT_3 = "_H" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_4 = NL + " "; - protected final String TEXT_5 = " interface header" + NL + " ************************************************************/" + NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL; - protected final String TEXT_10 = NL; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = NL + "/************************************************************/"; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL + "class "; - protected final String TEXT_15 = " "; - protected final String TEXT_16 = "{" + NL + "" + NL + "/* Public declarations */" + NL + "public:"; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL + NL + "};" + NL + "" + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_19 = " interface header" + NL + " ************************************************************/"; - protected final String TEXT_20 = NL; - protected final String TEXT_21 = NL + NL + "#endif"; - protected final String TEXT_22 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Interface currentInterface = (Interface) argument; - - // Get the package name - String interfaceName = currentInterface.getName(); - String interfaceFULLNAME = GenUtils.getFullNameUC (currentInterface); - - // For interface documentation - String iDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - iDoc = jDoc.generate(currentInterface); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentInterface, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentInterface.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - - // Prepare dependency includes - CppInterfaceAllIncludesDeclaration jetInterfaceIncludes - = new CppInterfaceAllIncludesDeclaration(); - String interfaceIncludes = jetInterfaceIncludes.generate(argument); - if (!interfaceIncludes.equals("")) { - interfaceIncludes = "/* Structural includes (inheritance, dependencies, ... */"+NL+interfaceIncludes; - } - - // Prepare Methods declarations - String publicOperations = ""; - - // Methods - CppInterfacePublicOperationsDeclaration jetPublicInterfacePOp - = new CppInterfacePublicOperationsDeclaration(); - publicOperations = jetPublicInterfacePOp.generate(currentInterface); - - - // Prepare inherited interfaces - String inheritedDeclarations = ""; - CppInterfaceInheritedDeclarations jetInherited - = new CppInterfaceInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentInterface); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( interfaceFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append( interfaceFULLNAME ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - stringBuffer.append( interfaceName ); - stringBuffer.append(TEXT_5); - stringBuffer.append(TEXT_6); - stringBuffer.append( ownerInclude ); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append( interfaceIncludes ); - stringBuffer.append(TEXT_9); - stringBuffer.append(TEXT_10); - stringBuffer.append( headerDecl ); - stringBuffer.append(TEXT_11); - stringBuffer.append( GenUtils.openNS(currentInterface) ); - stringBuffer.append(TEXT_12); - stringBuffer.append(TEXT_13); - stringBuffer.append( iDoc ); - stringBuffer.append(TEXT_14); - stringBuffer.append( interfaceName ); - stringBuffer.append(TEXT_15); - stringBuffer.append( inheritedDeclarations ); - stringBuffer.append(TEXT_16); - stringBuffer.append(TEXT_17); - stringBuffer.append( publicOperations ); - stringBuffer.append(TEXT_18); - stringBuffer.append( interfaceName ); - stringBuffer.append(TEXT_19); - stringBuffer.append(TEXT_20); - stringBuffer.append( GenUtils.closeNS(currentInterface) ); - stringBuffer.append(TEXT_21); - stringBuffer.append(TEXT_22); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppPackageHeader.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppPackageHeader.java deleted file mode 100644 index 58865c8b294..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppPackageHeader.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.CppInclude; -import Cpp.CppNoCodeGen; -import org.eclipse.uml2.uml.*; -import org.eclipse.uml2.uml.Package; -import org.eclipse.emf.common.util.EList; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import java.util.Iterator; -import java.util.Set; -import java.util.HashSet; -import org.eclipse.papyrus.cpp.codegen.Activator; - -public class CppPackageHeader -{ - protected static String nl; - public static synchronized CppPackageHeader create(String lineSeparator) - { - nl = lineSeparator; - CppPackageHeader result = new CppPackageHeader(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#ifndef PKG_"; - protected final String TEXT_2 = NL + "#define PKG_"; - protected final String TEXT_3 = NL + NL + "/************************************************************" + NL + " Pkg_"; - protected final String TEXT_4 = " package header" + NL + " ************************************************************/" + NL; - protected final String TEXT_5 = NL; - protected final String TEXT_6 = NL + "\t" + NL + "/* Package dependency header include */"; - protected final String TEXT_7 = NL + "#include <"; - protected final String TEXT_8 = "."; - protected final String TEXT_9 = ">"; - protected final String TEXT_10 = NL + NL + "/* CppInclude header declarations insert */"; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = NL; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL + "/* Types Defined in the package */"; - protected final String TEXT_15 = NL; - protected final String TEXT_16 = NL; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL + NL + "/************************************************************" + NL + " End of Pkg_"; - protected final String TEXT_19 = " package header" + NL + " ************************************************************/" + NL + "" + NL + "#endif"; - protected final String TEXT_20 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the package - Package currentPackage = (Package) argument; - Package fatherPackage = currentPackage.getNestingPackage(); // return owner package - - // Get the package name - String packageName = currentPackage.getName(); - String packageFULLNAME = GenUtils.getFullName (currentPackage).toUpperCase(); - String openNS = GenUtils.openNS (currentPackage) + "namespace " + currentPackage.getName () + " {\n"; - String closeNS = "} // of namespace" + currentPackage.getName () + "\n" + GenUtils.closeNS (currentPackage); - - // Prepare the header declarations for this package - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentPackage, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - - // Prepare Father include declaration - String fatherPkgInclude = ""; - if (fatherPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetPkgInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - fatherPkgInclude = jetPkgInclude.generate(fatherPackage); - } - - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - - String cFullName = ""; // used in java to contruct and in template to read list - - // Get packages linked by dependencies - EList usedPackages = GenUtils.getUsedPackages (currentPackage); - Set usedPackagesNames = new HashSet(); - // Add imported packages - usedPackages.addAll(currentPackage.getImportedPackages()); - - Iterator usedPackagesIt = usedPackages.iterator(); - Iterator usedPackagesNamesIt; - - // Refactor as a new Set containing names to be declared for packages (with path) - while(usedPackagesIt.hasNext()) { - Package currentUsedPackage = usedPackagesIt.next(); - String cPackageName = currentUsedPackage.getName(); - String cPackagePath = GenUtils.getFullPath (currentUsedPackage); - - cFullName = cPackagePath+"/Pkg_"+cPackageName; - - // Add this name to the set if codegen stereotype is not applied - PackageImport packImport = currentPackage.getPackageImport(currentUsedPackage); - if(!GenUtils.hasStereotype(packImport, CppNoCodeGen.class)) { - if (!GenUtils.hasStereotype(currentUsedPackage, CppNoCodeGen.class)) { - usedPackagesNames.add(cFullName); - } - } - } - - // and prepare the Iterator for the template... - usedPackagesNamesIt = usedPackagesNames.iterator(); - - - - // Prepare owned type and enum declaration - String typeDef = ""; - String enumDef = ""; - - Iterator typeIt = currentPackage.getOwnedTypes().iterator(); - while (typeIt.hasNext()) { - Type currentElt = typeIt.next(); - if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) { - if (currentElt instanceof org.eclipse.uml2.uml.PrimitiveType) { - - PrimitiveType currentType = (PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - typeDef = typeDef+jetPrimitiveType.generate(currentType); - - } else if (currentElt instanceof org.eclipse.uml2.uml.Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - enumDef = enumDef+jetEnum.generate(currentEnum); - - } - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( packageFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append( packageFULLNAME ); - stringBuffer.append(TEXT_3); - stringBuffer.append( packageName ); - stringBuffer.append(TEXT_4); - stringBuffer.append(TEXT_5); - stringBuffer.append( fatherPkgInclude ); - stringBuffer.append(TEXT_6); - // For every depency linked package - while(usedPackagesNamesIt.hasNext()) { - cFullName = (String) usedPackagesNamesIt.next(); - stringBuffer.append(TEXT_7); - stringBuffer.append( cFullName ); - stringBuffer.append(TEXT_8); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_9); - } - stringBuffer.append(TEXT_10); - stringBuffer.append(TEXT_11); - stringBuffer.append( headerDecl ); - stringBuffer.append(TEXT_12); - stringBuffer.append(TEXT_13); - stringBuffer.append( openNS ); - stringBuffer.append(TEXT_14); - stringBuffer.append(TEXT_15); - stringBuffer.append( typeDef ); - stringBuffer.append(TEXT_16); - stringBuffer.append( enumDef ); - stringBuffer.append(TEXT_17); - stringBuffer.append( closeNS ); - stringBuffer.append(TEXT_18); - stringBuffer.append( packageName ); - stringBuffer.append(TEXT_19); - stringBuffer.append(TEXT_20); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppTemplateHeader.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppTemplateHeader.java deleted file mode 100644 index 4aad3809ba8..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/CppTemplateHeader.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * 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; - -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.jet.util.*; -import Cpp.CppInclude; -import Cpp.CppNoCodeGen; -import Cpp.CppInline; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import java.util.*; - -public class CppTemplateHeader -{ - protected static String nl; - public static synchronized CppTemplateHeader create(String lineSeparator) - { - nl = lineSeparator; - CppTemplateHeader result = new CppTemplateHeader(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#ifndef "; - protected final String TEXT_2 = "_H" + NL + "#define "; - protected final String TEXT_3 = "_H" + NL + "" + NL + "/************************************************************"; - protected final String TEXT_4 = NL + " "; - protected final String TEXT_5 = " template class header" + NL + " ************************************************************/" + NL; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = NL; - protected final String TEXT_10 = NL; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = NL; - protected final String TEXT_13 = NL + "/************************************************************/" + NL + "template <"; - protected final String TEXT_14 = "> class "; - protected final String TEXT_15 = " "; - protected final String TEXT_16 = "{"; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL + "/* Public declarations */" + NL + "public:"; - protected final String TEXT_19 = NL; - protected final String TEXT_20 = NL; - protected final String TEXT_21 = NL + NL + "/* Protected declarations */" + NL + "protected:"; - protected final String TEXT_22 = NL; - protected final String TEXT_23 = NL; - protected final String TEXT_24 = NL + NL + "/* Private declarations */" + NL + "private:"; - protected final String TEXT_25 = NL; - protected final String TEXT_26 = NL; - protected final String TEXT_27 = NL + NL + "};" + NL + "" + NL + "/************************************************************/" + NL + "/* Template functions */"; - protected final String TEXT_28 = NL; - protected final String TEXT_29 = NL; - protected final String TEXT_30 = NL; - protected final String TEXT_31 = NL + "/* Inline functions */"; - protected final String TEXT_32 = NL; - protected final String TEXT_33 = NL; - protected final String TEXT_34 = NL; - protected final String TEXT_35 = NL + NL + "/************************************************************" + NL + " End of "; - protected final String TEXT_36 = " template class header" + NL + " ************************************************************/" + NL + "" + NL + "#endif"; - protected final String TEXT_37 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName(currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - // Prepare owned type and enum declaration - String typeEnumDefPackage = ""; - String typeEnumDef = ""; - - CppClassTypeAndEnum jetTE = new CppClassTypeAndEnum(); - typeEnumDef = jetTE.generate(currentClass); - - CppClassTypeAndEnumPackage jetTEp = new CppClassTypeAndEnumPackage(); - typeEnumDefPackage = jetTEp.generate(currentClass); - - // Prepare template parameter declaration - Iterator tparam = - GenUtils.getTemplateParameters(currentClass).iterator(); - - String tParamDecl = ""; - String tDecl = ""; - - while (tparam.hasNext()) { - CppTemplateParameter jetTParam = new CppTemplateParameter(); - tParamDecl = tParamDecl + jetTParam.generate(tparam.next()); - - if (tparam.hasNext()) { - tParamDecl = tParamDecl + ", "; - } - } - - tDecl = "template <" + tParamDecl + ">" + NL; - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */" - + NL + classIncludes; - } - - // Prepare attributes and Methods declarations - String publicAttributes = ""; - String protectedAttributes = ""; - String privateAttributes = ""; - String publicOperations = "", publicOperationsImpl = ""; - String protectedOperations = "", protectedOperationsImpl = ""; - String privateOperations = "", privateOperationsImpl = ""; - - // Attributes - CppClassAttributesDeclaration jetClassPAttr = new CppClassAttributesDeclaration(); - publicAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - - // Methods implementation - String inlineFuncImpl = ""; - // String inlineFuncDecl = ""; - - // Implementation - CppOperationTemplateImplementation jetOpImpl = new CppOperationTemplateImplementation(); - // Declaration - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOperation = operations.next(); - - if (GenUtils.hasStereotype(currentOperation, CppNoCodeGen.class) || - currentOperation.isAbstract()) { - continue; - } - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - String opDoc = ""; - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = jDoc.generate(currentOperation); - // Inline declaration - if (currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicOperations = publicOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateOperations = privateOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedOperations = protectedOperations - + jetOpDecl.generate(currentOperation) + ";"; - } // else nothing - // Inline implementation - inlineFuncImpl = inlineFuncImpl + opDoc + NL + tDecl - + jetOpImpl.generate(currentOperation) + NL; - } else { - if (currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicOperationsImpl = publicOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - publicOperations = publicOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateOperationsImpl = privateOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - privateOperations = privateOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedOperationsImpl = protectedOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - protectedOperations = protectedOperations - + jetOpDecl.generate(currentOperation) + ";"; - } // else nothing - } - } - - // Prepare inherited classes or implemented interfaces - String inheritedDeclarations = ""; - CppClassInheritedDeclarations jetInherited = new CppClassInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentClass); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_2); - stringBuffer.append( classFULLNAME ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - stringBuffer.append( className ); - stringBuffer.append(TEXT_5); - stringBuffer.append(TEXT_6); - stringBuffer.append( ownerInclude ); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append( classIncludes ); - stringBuffer.append(TEXT_9); - stringBuffer.append(TEXT_10); - stringBuffer.append( headerDecl ); - stringBuffer.append(TEXT_11); - stringBuffer.append( openNS ); - stringBuffer.append(TEXT_12); - stringBuffer.append( typeEnumDefPackage ); - stringBuffer.append(TEXT_13); - stringBuffer.append( tParamDecl ); - stringBuffer.append(TEXT_14); - stringBuffer.append( className ); - stringBuffer.append(TEXT_15); - stringBuffer.append( inheritedDeclarations ); - stringBuffer.append(TEXT_16); - stringBuffer.append(TEXT_17); - stringBuffer.append( typeEnumDef ); - stringBuffer.append(TEXT_18); - stringBuffer.append(TEXT_19); - stringBuffer.append( publicAttributes ); - stringBuffer.append(TEXT_20); - stringBuffer.append( publicOperations ); - stringBuffer.append(TEXT_21); - stringBuffer.append(TEXT_22); - stringBuffer.append( protectedAttributes ); - stringBuffer.append(TEXT_23); - stringBuffer.append( protectedOperations ); - stringBuffer.append(TEXT_24); - stringBuffer.append(TEXT_25); - stringBuffer.append( privateAttributes ); - stringBuffer.append(TEXT_26); - stringBuffer.append( privateOperations ); - stringBuffer.append(TEXT_27); - stringBuffer.append(TEXT_28); - stringBuffer.append( publicOperationsImpl ); - stringBuffer.append(TEXT_29); - stringBuffer.append( protectedOperationsImpl ); - stringBuffer.append(TEXT_30); - stringBuffer.append( privateOperationsImpl ); - stringBuffer.append(TEXT_31); - stringBuffer.append(TEXT_32); - stringBuffer.append( inlineFuncImpl ); - stringBuffer.append(TEXT_33); - stringBuffer.append(TEXT_34); - stringBuffer.append( closeNS ); - stringBuffer.append(TEXT_35); - stringBuffer.append( className ); - stringBuffer.append(TEXT_36); - stringBuffer.append(TEXT_37); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppElementDoc.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppElementDoc.java deleted file mode 100644 index 3b6157ccdb9..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppElementDoc.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.doc; - -import org.eclipse.uml2.uml.Element; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppElementDoc -{ - protected static String nl; - public static synchronized CppElementDoc create(String lineSeparator) - { - nl = lineSeparator; - CppElementDoc result = new CppElementDoc(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "/**" + NL + " * "; - protected final String TEXT_2 = NL + " */"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Element currentElt = (Element) argument; - String eltDoc = ""; - - - // Doc for the element - eltDoc = GenUtils.getComments(currentElt); - eltDoc = eltDoc.replaceAll(NL, NL+" * "); - - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( eltDoc ); - stringBuffer.append(TEXT_2); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppOperationDoc.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppOperationDoc.java deleted file mode 100644 index b8fdbb83fb3..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppOperationDoc.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.doc; - -import org.eclipse.uml2.uml.Operation; -import org.eclipse.uml2.uml.Parameter; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import java.util.Iterator; - -public class CppOperationDoc -{ - protected static String nl; - public static synchronized CppOperationDoc create(String lineSeparator) - { - nl = lineSeparator; - CppOperationDoc result = new CppOperationDoc(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "/**" + NL + " * "; - protected final String TEXT_2 = NL + " * "; - protected final String TEXT_3 = NL + " */"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String opDoc = ""; - String opParams = ""; -// String opReturn = ""; -// TODO: return not handled? (or treated as any other parameter?) - - // Doc for the element - opDoc = GenUtils.getComments(currentOperation); - opDoc = opDoc.replaceAll(NL, NL+" * "); - - // Treat params - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = (Parameter) parameters.next(); - - // Prepare parameters - CppParamDoc jetParam = new CppParamDoc(); - opParams = opParams+jetParam.generate(currentParameter); - - if (parameters.hasNext()){ - opParams = opParams+NL+" * "; - } - } - - // Treat return - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( opDoc ); - stringBuffer.append(TEXT_2); - stringBuffer.append( opParams ); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppParamDoc.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppParamDoc.java deleted file mode 100644 index 398b823a7bb..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/doc/CppParamDoc.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.doc; - -import org.eclipse.uml2.uml.Parameter; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppParamDoc -{ - protected static String nl; - public static synchronized CppParamDoc create(String lineSeparator) - { - nl = lineSeparator; - CppParamDoc result = new CppParamDoc(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "@param "; - protected final String TEXT_2 = " "; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Parameter currentElt = (Parameter) argument; - - String paramName = currentElt.getName(); - String paramDoc = GenUtils.getComments(currentElt); - - paramDoc = paramDoc.replaceAll(NL, NL+" * "); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( paramName ); - stringBuffer.append(TEXT_2); - stringBuffer.append( paramDoc ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java deleted file mode 100644 index faad5c04422..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Property; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.*; - -public class CppAttributeDeclaration -{ - protected static String nl; - public static synchronized CppAttributeDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppAttributeDeclaration result = new CppAttributeDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = NL + "\t"; - protected final String TEXT_2 = NL + "\t"; - protected final String TEXT_3 = " "; - protected final String TEXT_4 = ";"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); - String typeName = ""; - String prefix = ""; - String suffix = ""; - String multiple = ""; - - // For property documentation - String propDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - propDoc = jDoc.generate(currentAttribute); - propDoc = propDoc.replaceAll(NL, NL+" "); - - if (currentAttribute.getType() == null) { - typeName = "undefined"; - } else { - typeName = GenUtils.qualifiedName (currentAttribute.getType()); - } - - // Static attribute - if (currentAttribute.isStatic()) { - prefix = "static"+" "; - } - - Modifier modifier = new Modifier(currentAttribute); - - // Treat multiplicity for association attributes - int multiplicity = currentAttribute.getUpper(); - if (multiplicity == 1) { - multiple = ""; - } else if (multiplicity == -1) { - multiple = "*"; - } else { - multiple = ""; - modifier.array = "[" + multiplicity + "]"; - } - - // If attribute is aggregation - if (GenUtils.isAggregation(currentAttribute)) { - // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab - attributeName = "*"+attributeName; // this produce a tab of pointers - } - - - if (GenUtils.hasStereotype(currentAttribute, CppConst.class) && currentAttribute.isStatic()) { - // const & static attributes may be initialized within class declaration - // check if initial value UML or profile - if (currentAttribute.getDefaultValue() != null) { - suffix = " = " + currentAttribute.getDefaultValue().stringValue(); - } - else { - CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( propDoc ); - stringBuffer.append(TEXT_2); - stringBuffer.append( prefix ); - stringBuffer.append( modifier.isConst ); - stringBuffer.append( typeName ); - stringBuffer.append( multiple ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - stringBuffer.append(TEXT_3); - stringBuffer.append( attributeName ); - stringBuffer.append( modifier.array ); - stringBuffer.append( suffix ); - stringBuffer.append(TEXT_4); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java deleted file mode 100644 index ab85473afbc..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.*; - -public class CppAttributeImplementation -{ - protected static String nl; - public static synchronized CppAttributeImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppAttributeImplementation result = new CppAttributeImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "\t"; - protected final String TEXT_2 = NL + "\t"; - protected final String TEXT_3 = " "; - protected final String TEXT_4 = ";"; - protected final String TEXT_5 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); -// String className = currentAttribute.getOwner().getName(); - String typeName = ""; - String scopeName = ""; -// String prefix = ""; - String suffix = ""; - String multiple = ""; - - // For property documentation - String propDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - propDoc = jDoc.generate(currentAttribute); - propDoc = propDoc.replaceAll(NL, NL+" "); - - if (currentAttribute.getType() == null) { - typeName = "undefined"; - } - else { - Type type = currentAttribute.getType(); - typeName = GenUtils.qualifiedName (type); - /* - // If type is owned by a class add the scope - if (type.getOwner() instanceof Class) { - scopeName = ((Class) type.getOwner()).getName(); - typeName = scopeName+"::"+typeName; - } - */ - } - - // Multiple - // TODO? need to evaluate limitMultiplicity stereotype? - int upper = currentAttribute.getUpper(); - if ((upper == -1) || (upper > 1)) { - multiple = "*"; - } - - Modifier modifier = new Modifier(currentAttribute); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( propDoc ); - stringBuffer.append(TEXT_2); - stringBuffer.append( typeName ); - stringBuffer.append( multiple ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - stringBuffer.append(TEXT_3); - stringBuffer.append( attributeName ); - stringBuffer.append( modifier.array ); - stringBuffer.append( suffix ); - stringBuffer.append(TEXT_4); - stringBuffer.append(TEXT_5); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java deleted file mode 100644 index acc9eb087fa..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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 Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.*; -import org.eclipse.uml2.uml.Class; -import org.eclipse.emf.common.util.EList; -import org.eclipse.uml2.uml.Package; -import org.eclipse.emf.common.util.UniqueEList; -import java.util.*; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.Classifier; - -public class CppClassAllIncludesDeclaration -{ - protected static String nl; - public static synchronized CppClassAllIncludesDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassAllIncludesDeclaration result = new CppClassAllIncludesDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - // String className = currentClass.getName(); - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - // use a unique list to avoid duplicates - EList usedClasses = new UniqueEList (); - - String newInclude = ""; - - // class attributes dependencies - usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentClass)); - // operation parameters dependencies - usedClasses.addAll (GenUtils.getIncludesFromOperations(currentClass)); - // realized interface dependencies - if (currentClass instanceof Class) { - usedClasses.addAll (GenUtils.getImplementedInterfaces((Class) currentClass)); - } - // dependencies and associations - usedClasses.addAll (GenUtils.getRelationshipsNoDeps(currentClass)); - - // template parameters are declared locally (if owned) and do not correspond to a file - // that can be included - usedClasses.removeAll (GenUtils.getTemplateParameteredElements(currentClass)); - - Iterator usedClassesIt = usedClasses.iterator(); - // Parsing all as NamedElement - String includes = ClassUtils.createIncludeDecl (usedClasses, currentClass); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( includes ); - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java deleted file mode 100644 index a0de92709c3..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.Iterator; - -public class CppClassAttributesDeclaration -{ - protected static String nl; - public static synchronized CppClassAttributesDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassAttributesDeclaration result = new CppClassAttributesDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument1, Object argument2) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument1; - String attrDecl = ""; - - // Retrieve public attributes - Iterator attributes = currentClass.getAttributes().iterator(); - while (attributes.hasNext()) { - Property attribute = attributes.next(); - if (attribute.getVisibility() == argument2) { - CppAttributeDeclaration jetAttDecl = new CppAttributeDeclaration(); - attrDecl = attrDecl+jetAttDecl.generate(attribute); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( attrDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java deleted file mode 100644 index 4c30ed0bedd..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.Iterator; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppClassAttributesImplementation -{ - protected static String nl; - public static synchronized CppClassAttributesImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppClassAttributesImplementation result = new CppClassAttributesImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String attrDecl = ""; - String attrSDecl = ""; - - CppAttributeImplementation jetAttDecl = new CppAttributeImplementation(); - CppStaticAttributeImplementation jetSAttDecl = new CppStaticAttributeImplementation(); - - Iterator attributesIt = currentClass.getAttributes().iterator(); - while (attributesIt.hasNext()) { - Property attribute = (Property) attributesIt.next(); - - // just check that this property is not a static const - // in that case it declared and defined in the header file - - // Static - if (attribute.isStatic()) { - attrSDecl = attrSDecl+jetSAttDecl.generate(attribute); - } else { - attrDecl = attrDecl+jetAttDecl.generate(attribute); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( attrSDecl ); - stringBuffer.append( attrDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java deleted file mode 100644 index 030fae595ff..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.NamedElement; - -public class CppClassFriendDeclaration -{ - protected static String nl; - public static synchronized CppClassFriendDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassFriendDeclaration result = new CppClassFriendDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "friend class "; - protected final String TEXT_2 = ";"; - protected final String TEXT_3 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassName = currentNE.getName(); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( cClassName ); - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java deleted file mode 100644 index e7fc0246e6e..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.NamedElement; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassIncludeClassDeclaration -{ - protected static String nl; - public static synchronized CppClassIncludeClassDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassIncludeClassDeclaration result = new CppClassIncludeClassDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = "class "; - protected final String TEXT_5 = ";"; - protected final String TEXT_6 = NL; - protected final String TEXT_7 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassName = currentNE.getName(); - String isTemplate = ""; - String openNS = GenUtils.openNS (currentNE); - String closeNS = GenUtils.closeNS (currentNE); - - if (GenUtils.hasStereotype(currentNE, CppTemplate.class)) { - isTemplate = "template "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append(TEXT_2); - stringBuffer.append( openNS ); - stringBuffer.append(TEXT_3); - stringBuffer.append( isTemplate ); - stringBuffer.append(TEXT_4); - stringBuffer.append( cClassName ); - stringBuffer.append(TEXT_5); - stringBuffer.append(TEXT_6); - stringBuffer.append( closeNS ); - stringBuffer.append(TEXT_7); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java deleted file mode 100644 index a10b49edd59..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Package; -import org.eclipse.papyrus.cpp.codegen.Activator; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassIncludeDeclaration -{ - protected static String nl; - public static synchronized CppClassIncludeDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassIncludeDeclaration result = new CppClassIncludeDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#include <"; - protected final String TEXT_2 = ">"; - protected final String TEXT_3 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassPath = ""; - Package nearestPkg = currentNE.getNearestPackage(); - String cClassName = currentNE.getName(); - - if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model) - /*&& */!(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) { - cClassPath = GenUtils.getFullPath(nearestPkg)+"/"; - } - - - // If an external class is referred - CppExternClass extClass = GenUtils.getApplication(currentNE, CppExternClass.class); - CppTemplate template = GenUtils.getApplication(currentNE, CppTemplate.class); - if (extClass != null) { - cClassPath = ""; - cClassName = extClass.getName(); - if ((cClassName == null) || cClassName.equals ("")) { - // default value - cClassName = currentNE.getQualifiedName ().replace ("::", "/") + "." + headerFileSuffix; - // strip model name - cClassName = cClassName.substring (currentNE.getModel ().getName ().length () + 1); - } - } else if (template != null) { - cClassPath = ""; - cClassName = template.getDeclaration(); - } - else cClassName=cClassName+"."+headerFileSuffix; - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( cClassPath ); - stringBuffer.append( cClassName ); - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java deleted file mode 100644 index 1b37bcb57aa..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassIncludeFriendDeclaration -{ - protected static String nl; - public static synchronized CppClassIncludeFriendDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassIncludeFriendDeclaration result = new CppClassIncludeFriendDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; -// NamedElement currentElt = (NamedElement) argument; - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - Iterator friendClassesIt = GenUtils.getUsedClassifiers(currentClass).iterator(); - - // Parsing all as NamedElement - String friendClass = ""; - - while (friendClassesIt.hasNext()) { - Classifier cClass = friendClassesIt.next(); - - if (GenUtils.hasStereotype(cClass, CppFriend.class) && - (!GenUtils.hasStereotype(cClass, CppNoCodeGen.class))) { - - CppClassFriendDeclaration jetIDecl - = new CppClassFriendDeclaration(); - - friendClass = friendClass+jetIDecl.generate(cClass); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( friendClass ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java deleted file mode 100644 index 9081b1f7aaa..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassInheritedDeclarations -{ - protected static String nl; - public static synchronized CppClassInheritedDeclarations create(String lineSeparator) - { - nl = lineSeparator; - CppClassInheritedDeclarations result = new CppClassInheritedDeclarations(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String targetName = ""; - String visibility = ""; - String decl = ""; - - // Get generalization and implementation relationships - Iterator relationshipIt = - currentClass.getSourceDirectedRelationships().iterator(); - // Iterator impIt = currentClass.getImplementations().iterator(); - - while (relationshipIt.hasNext()) { - - DirectedRelationship relationship = relationshipIt.next(); - - if ((relationship instanceof Generalization) || - (relationship instanceof InterfaceRealization)) - { - org.eclipse.uml2.uml.Classifier target = null; - if (relationship.getTargets ().size() > 0) { - // there should always be at least one element in the target - // list and it should be a classifier, but better check. - org.eclipse.uml2.uml.Element element = - relationship.getTargets().get(0); - if (element instanceof org.eclipse.uml2.uml.Classifier) { - target = (org.eclipse.uml2.uml.Classifier) element; - } - } - if (target != null) { - // If not - if (!GenUtils.hasStereotype(target, CppNoCodeGen.class)) - { - CppVisibility cppVisibility = GenUtils.getApplication(relationship, CppVisibility.class); - if (cppVisibility != null) { - visibility = cppVisibility.getValue(); - } else { - visibility = "public"; - } - - targetName = GenUtils.qualifiedName (target); - if (!decl.equals("")) { - decl = decl + ", "; - } - decl = decl+visibility+" "+targetName; - } - } - } - } - - // Parse implementations - // RS: removed code: Implementation does not exist in UML2 v2. - // TODO: replace Implementation with new UML2 constructions? -// Implementation currentImp; -// -// while (impIt.hasNext()) { -// -// currentImp = (Implementation) impIt.next(); -// currentNE = (NamedElement) currentImp; -// -// // get visibility and target name -// visibility = currentNE.getVisibilityAsString(); -// -// // If not -// if (!GenUtils.hasStereotype(currentImp.getTarget(), CppNoCodeGen.class)) { -// -// targetName = currentImp.getTarget().getName(); -// -// if (!decl.equals("")) { -// decl = decl + ", "; -// } -// decl = decl+visibility+" "+targetName; -// -// } -// } - - - // ":" if decl non empty - String prefix = ""; - if (!decl.equals("")) { - prefix = " : "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( prefix ); - stringBuffer.append( decl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java deleted file mode 100644 index 4ff043d4116..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.Iterator; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassInlineOperationsImplementation -{ - protected static String nl; - public static synchronized CppClassInlineOperationsImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppClassInlineOperationsImplementation result = new CppClassInlineOperationsImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOp = operations.next(); - if (GenUtils.hasStereotype (currentOp, CppInline.class) && - !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class)) { - - CppOperationImplementation jetOpImpl = new CppOperationImplementation(); - opDecl = opDecl+jetOpImpl.generate(currentOp); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( opDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java deleted file mode 100644 index 1ba52bc71f5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.Iterator; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassOperationsDeclaration -{ - protected static String nl; - public static synchronized CppClassOperationsDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppClassOperationsDeclaration result = new CppClassOperationsDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument1, Object argument2) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument1; - String opDecl = ""; - - // Retrieve attributes - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation operation = operations.next(); - if (!GenUtils.hasStereotype (operation, CppNoCodeGen.class)) { - if (operation.getVisibility() == argument2) { - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - String cOpDecl = jetOpDecl.generate(operation); - - // if main cOpDecl = ""; - if (!cOpDecl.equals("")) { - opDecl = opDecl+NL+cOpDecl+";"; - } - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( opDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java deleted file mode 100644 index 377e7f579bf..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.Iterator; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppClassOperationsImplementation -{ - protected static String nl; - public static synchronized CppClassOperationsImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppClassOperationsImplementation result = new CppClassOperationsImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOp = operations.next(); - if (!GenUtils.hasStereotype (currentOp, CppInline.class) && - !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class) && - !currentOp.isAbstract()) { - CppOperationImplementation jetOpImpl = new CppOperationImplementation(); - opDecl = opDecl+jetOpImpl.generate(currentOp); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( opDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java deleted file mode 100644 index db433ffb881..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * 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.utils.GenUtils; -import org.eclipse.uml2.uml.*; - -public class CppClassTypeAndEnum -{ - protected static String nl; - public static synchronized CppClassTypeAndEnum create(String lineSeparator) - { - nl = lineSeparator; - CppClassTypeAndEnum result = new CppClassTypeAndEnum(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Prepare owned type and enum declaration - String publicTypeDef = ""; - String privateTypeDef = ""; - String protectedTypeDef = ""; - String publicEnumDef = ""; - String privateEnumDef = ""; - String protectedEnumDef = ""; - String publicKeyword = "public:"; - String protectedKeyword = "protected:"; - String privateKeyword = "private:"; - - for (Element currentElt : currentClass.getOwnedElements()) { - if (!GenUtils.hasStereotype(currentElt, Cpp.CppNoCodeGen.class)) { - if (currentElt instanceof PrimitiveType) { - - org.eclipse.uml2.uml.PrimitiveType currentType = (org.eclipse.uml2.uml.PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - if (currentType.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicTypeDef = publicTypeDef+jetPrimitiveType.generate(currentType); - } else if (currentType.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedTypeDef = protectedTypeDef+jetPrimitiveType.generate(currentType); - } else if (currentType.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateTypeDef = privateTypeDef+jetPrimitiveType.generate(currentType); - } - } - else if (currentElt instanceof Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - if (currentEnum.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicEnumDef = publicEnumDef+jetEnum.generate(currentEnum); - } else if (currentEnum.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedEnumDef = protectedEnumDef+jetEnum.generate(currentEnum); - } else if (currentEnum.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateEnumDef = privateEnumDef+jetEnum.generate(currentEnum); - } - } - } - } - - // If not "" add a comment before declarations - if (publicTypeDef.equals("") && publicEnumDef.equals("")) { - publicKeyword = ""; - } else { - if (!publicTypeDef.equals("")) { - publicTypeDef = "/* Public type definitions */"+NL+publicTypeDef+NL; - } - if (!publicEnumDef.equals("")) { - publicEnumDef = "/* Public enumeration definitions */"+NL+publicEnumDef+NL; - } - } - - if (protectedTypeDef.equals("") && protectedEnumDef.equals("")) { - protectedKeyword = ""; - } else { - if (!protectedTypeDef.equals("")) { - protectedTypeDef = "/* Protected type definitions */"+NL+protectedTypeDef+NL; - } - if (!protectedEnumDef.equals("")) { - protectedEnumDef = "/* Protected enumeration definitions */"+NL+protectedEnumDef+NL; - } - } - - if (privateTypeDef.equals("") && privateEnumDef.equals("")) { - privateKeyword = ""; - } else { - if (!privateTypeDef.equals("")) { - privateTypeDef = "/* Private type definitions */"+NL+privateTypeDef+NL; - } - if (!privateEnumDef.equals("")) { - privateEnumDef = "/* Private enumeration definitions */"+NL+privateEnumDef+NL; - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( publicKeyword ); - stringBuffer.append( publicTypeDef ); - stringBuffer.append( publicEnumDef ); - stringBuffer.append( protectedKeyword ); - stringBuffer.append( protectedTypeDef ); - stringBuffer.append( protectedEnumDef ); - stringBuffer.append( privateKeyword ); - stringBuffer.append( privateTypeDef ); - stringBuffer.append( privateEnumDef ); - stringBuffer.append(TEXT_2); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java deleted file mode 100644 index 4818c9dd823..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Class; -import org.eclipse.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import java.util.Iterator; -import Cpp.*; - -public class CppClassTypeAndEnumPackage -{ - protected static String nl; - public static synchronized CppClassTypeAndEnumPackage create(String lineSeparator) - { - nl = lineSeparator; - CppClassTypeAndEnumPackage result = new CppClassTypeAndEnumPackage(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - - // Prepare owned type and enum declaration - String packageTypeDef = ""; - String packageEnumDef = ""; - - Iterator typeIt = currentClass.getOwnedElements().iterator(); - while (typeIt.hasNext()) { - Element currentElt = typeIt.next(); - if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) { - if (currentElt instanceof PrimitiveType) { - - PrimitiveType currentType = (PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - if (currentType.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - packageTypeDef = packageTypeDef+jetPrimitiveType.generate(currentType); - } - - - } else if (currentElt instanceof Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - if (currentEnum.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - packageEnumDef = packageEnumDef+jetEnum.generate(currentEnum); - } - - } - } - } - - // If not "" add a comment before declarations - if (!packageEnumDef.equals("")) { - packageEnumDef = "/* Package enumeration definitions */"+NL+packageEnumDef; - } - if (!packageTypeDef.equals("")) { - packageTypeDef = "/* Package type definitions */"+NL+packageTypeDef; - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( packageTypeDef ); - stringBuffer.append(TEXT_2); - stringBuffer.append( packageEnumDef ); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java deleted file mode 100644 index b3589b1a5fe..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.EnumerationLiteral; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import java.util.Iterator; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import Cpp.*; - -public class CppEnumerationDefinition -{ - protected static String nl; - public static synchronized CppEnumerationDefinition create(String lineSeparator) - { - nl = lineSeparator; - CppEnumerationDefinition result = new CppEnumerationDefinition(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL + "enum "; - protected final String TEXT_3 = " {" + NL + "\t"; - protected final String TEXT_4 = NL + "};" + NL; - protected final String TEXT_5 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // This is an util template to prepare Enumeration definition - ///////////////////////////////////////////////////////////// - - - // Retrieve the enumeration - Enumeration currentEnumeration = (Enumeration) argument; - - // Get the package name - String enumName = currentEnumeration.getName(); - - // Doc - String enumDoc = ""; - String enumLitDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - enumDoc = jDoc.generate(currentEnumeration); - - // Retrieve literals - String enumLiterals = ""; - - Iterator literalsIt = currentEnumeration.getOwnedLiterals().iterator(); - - while (literalsIt.hasNext()) { - - // retrieve current - EnumerationLiteral currentLiteral = literalsIt.next(); - - enumLiterals = enumLiterals+currentLiteral.getName(); - - // if current literal is initialised - CppInit cppInit = GenUtils.getApplication(currentLiteral, CppInit.class); - if (cppInit != null) { - // Add the initialisation value - int initValue = cppInit.getValue(); - enumLiterals = enumLiterals + " = " + initValue; - } - - // Retrieve doc - if (!GenUtils.getComments(currentLiteral).equals("")) { - enumLitDoc = " //< "+GenUtils.getComments(currentLiteral); - } else { - enumLitDoc = ""; - } - - // if more literal left prepare new line for next literal - if (literalsIt.hasNext()) { - enumLiterals = enumLiterals+" ,"+enumLitDoc+NL+"\t"; - } else { - enumLiterals = enumLiterals+enumLitDoc; - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( enumDoc ); - stringBuffer.append(TEXT_2); - stringBuffer.append( enumName ); - stringBuffer.append(TEXT_3); - stringBuffer.append( enumLiterals ); - stringBuffer.append(TEXT_4); - stringBuffer.append(TEXT_5); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java deleted file mode 100644 index ced6f6754b1..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * 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 Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import org.eclipse.uml2.uml.Interface; -import org.eclipse.emf.common.util.EList; -import org.eclipse.uml2.uml.Package; -import org.eclipse.emf.common.util.UniqueEList; -import java.util.*; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.Classifier; - -public class CppInterfaceAllIncludesDeclaration -{ - protected static String nl; - public static synchronized CppInterfaceAllIncludesDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppInterfaceAllIncludesDeclaration result = new CppInterfaceAllIncludesDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the interface - Interface currentInterface = (Interface) argument; - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - // use a unique list to avoid duplicates - EList usedClasses = new UniqueEList (); - - String newInclude = ""; - - // class attributes dependencies - usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentInterface)); - // operation parameters dependencies - usedClasses.addAll (GenUtils.getIncludesFromOperations(currentInterface)); - // dependencies and associations - usedClasses.addAll (GenUtils.getRelationships(currentInterface)); - - Iterator usedClassesIt = usedClasses.iterator(); - // Parsing all as NamedElement - String includes = ""; - - while (usedClassesIt.hasNext()) - { - Classifier cl = usedClassesIt.next (); - - // Only add include if this is not for the current class - if (!currentInterface.equals(cl)) { - // ... and if it does not have the stereotype "CppNoCodeGen", unless - // it has stereotype "CppExternalClass" - if ( (!GenUtils.hasStereotype(cl, CppNoCodeGen.class)) || - GenUtils.hasStereotype(cl, CppExternClass.class)) { - - if ((cl instanceof Enumeration) || (cl instanceof PrimitiveType)) - { - // 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 interface) - CppOwnerPackageIncludeDeclaration jetIDecl - = new CppOwnerPackageIncludeDeclaration(); - if (cl.getOwner() instanceof Package) { - newInclude = jetIDecl.generate (cl.getOwner ()); - } - else { - newInclude = ""; - } - } - else { - // include the file associated with the classifier - CppClassIncludeDeclaration jetIDecl - = new CppClassIncludeDeclaration(); - newInclude = jetIDecl.generate (cl); - } - - includes = includes+newInclude; - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( includes ); - stringBuffer.append(TEXT_2); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java deleted file mode 100644 index 63b3a5ebe72..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Package; -import org.eclipse.papyrus.cpp.codegen.Activator; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppInterfaceIncludeDeclaration -{ - protected static String nl; - public static synchronized CppInterfaceIncludeDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppInterfaceIncludeDeclaration result = new CppInterfaceIncludeDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "#include <"; - protected final String TEXT_2 = "."; - protected final String TEXT_3 = ">"; - protected final String TEXT_4 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Retrieve the interface - NamedElement currentNE = (NamedElement) argument; - String iInterfacePath = ""; - Package nearestPkg = currentNE.getNearestPackage(); - String iInterfaceName = currentNE.getName(); - - if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model) - /*&&*/ !(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) { - iInterfacePath = GenUtils.getFullPath (nearestPkg) + "/"; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( iInterfacePath ); - stringBuffer.append( iInterfaceName ); - stringBuffer.append(TEXT_2); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java deleted file mode 100644 index 309f94f1d57..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Generalization; -import java.util.Iterator; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppInterfaceInheritedDeclarations -{ - protected static String nl; - public static synchronized CppInterfaceInheritedDeclarations create(String lineSeparator) - { - nl = lineSeparator; - CppInterfaceInheritedDeclarations result = new CppInterfaceInheritedDeclarations(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the interface - Classifier currentClass = (Classifier) argument; - String decl = ""; - String visibility = ""; - - // Get generalization and implementation relationships - Iterator genIt = currentClass.getGeneralizations().iterator(); - - // Parse generalizations - while (genIt.hasNext()) { - - Generalization currentGen = genIt.next(); - - visibility = GenUtils.getVisibility(currentGen); - - // If not - Classifier tmpClassifier = currentGen.getGeneral(); - if (!GenUtils.hasStereotype(tmpClassifier, CppNoCodeGen.class)) { - - String targetName = tmpClassifier.getName(); - - if (!decl.equals("")) { - decl = decl + ", "; - } - decl = decl+visibility+" "+targetName; - } - } - - // ":" only if decl not empty - String prefix = ""; - if (!decl.equals("")) { - prefix = ": "; - visibility = "public "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( prefix ); - stringBuffer.append( decl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java deleted file mode 100644 index 84debe54ae5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Interface; -import org.eclipse.uml2.uml.Operation; -import org.eclipse.uml2.uml.VisibilityKind; -import java.util.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppInterfacePublicOperationsDeclaration -{ - protected static String nl; - public static synchronized CppInterfacePublicOperationsDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppInterfacePublicOperationsDeclaration result = new CppInterfacePublicOperationsDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Interface currentInterface = (Interface) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentInterface.getOwnedOperations().iterator(); - while (operations.hasNext()) { - Operation currentOperation = operations.next(); - if ((currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) && - !GenUtils.hasStereotype (currentOperation, CppNoCodeGen.class)) { - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - String cOpDecl = jetOpDecl.generate(currentOperation); - - // if main cOpDecl = ""; - if (!cOpDecl.equals("")) { - opDecl = opDecl+"\t"+cOpDecl+";"; - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( opDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java deleted file mode 100644 index 28ff6878080..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.StdStereo; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppOperationDeclaration -{ - protected static String nl; - public static synchronized CppOperationDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppOperationDeclaration result = new CppOperationDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL + "\t"; - protected final String TEXT_4 = "("; - protected final String TEXT_5 = ")"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String operationName = currentOperation.getName(); - - String opParameters = ""; - - String returnTypeName = "void"; - String pVirtualSuffix = ""; - String prefix = ""; - String constOp = ""; - - - String opDoc = ""; - - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = GenUtils.indent (jDoc.generate(currentOperation), "\t"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - if (!returnTypeName.equals ("")) { - returnTypeName += " "; - } - - boolean isInterface = currentOperation.getOwner () instanceof Interface; - - // Static attribute - if (currentOperation.isStatic()) { - prefix = prefix+"static"+" "; - } - - // Inline attribute - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - prefix = prefix+"inline"+" "; - } - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // Const attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - constOp = " const"; - } - - // Virtual attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppVirtual.class)) { - prefix = "virtual "+prefix; - } - - // Pure Virtual attribute on operation - if (isInterface || currentOperation.isAbstract ()) { - prefix = "virtual "+prefix; - pVirtualSuffix = " = 0"; - } - - // Friend attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppFriend.class)) { - prefix = "friend "+prefix; - } - - // Prepare parameters - CppOperationParameters jetParams = new CppOperationParameters(); - opParameters = jetParams.generate(currentOperation); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template only if current operation is not main -// else nothing is return... -////////////////////////////////////////////////////////////////////////////////////////// - -if (!operationName.equals("main")) { - -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append(TEXT_2); - stringBuffer.append( opDoc ); - stringBuffer.append(TEXT_3); - stringBuffer.append( prefix ); - stringBuffer.append( returnTypeName ); - stringBuffer.append( operationName ); - stringBuffer.append(TEXT_4); - stringBuffer.append( opParameters ); - stringBuffer.append(TEXT_5); - stringBuffer.append( constOp ); - stringBuffer.append( pVirtualSuffix ); - ////////////////////////////////////////////////////////////////////////////////////////// -} // else nothing done -////////////////////////////////////////////////////////////////////////////////////////// - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java deleted file mode 100644 index af6da84736b..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.StdStereo; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppOperationImplementation -{ - protected static String nl; - public static synchronized CppOperationImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppOperationImplementation result = new CppOperationImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = " "; - protected final String TEXT_5 = " ("; - protected final String TEXT_6 = ") {"; - protected final String TEXT_7 = NL; - protected final String TEXT_8 = NL + "}" + NL; - protected final String TEXT_9 = "\t" + NL; - protected final String TEXT_10 = NL; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = " "; - protected final String TEXT_13 = "::"; - protected final String TEXT_14 = "("; - protected final String TEXT_15 = ")"; - protected final String TEXT_16 = " {"; - protected final String TEXT_17 = NL; - protected final String TEXT_18 = NL + "}" + NL; - protected final String TEXT_19 = "\t"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String body = ""; - String className = ""; - String operationName = currentOperation.getName(); - String opParameters = ""; - String returnTypeName = "void"; - String isInline = ""; - String isConst = ""; - String constInit = ""; - - String opDoc = ""; - - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = jDoc.generate(currentOperation); - - // Retrieve class name. Operation may belong to a class or datatype, thus use - // generic getOwner function - Element opOwner = currentOperation.getOwner(); - className = (opOwner instanceof NamedElement) ? ((NamedElement) opOwner).getName() : ""; - - // Retrieve body content - body = GenUtils.getBody (currentOperation, "C/C++"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // If is inline operation - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - isInline = "inline "; - } - - // Const op - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - isConst = " const"; - } - - // Constructor init list - CppConstInit cppConstInit = GenUtils.getApplication(currentOperation, CppConstInit.class); - if ((cppConstInit != null) - && StdStereo.isApplied(currentOperation, StdStereo.create)) { - constInit = " : " + cppConstInit.getInitialisation(); - } - - // Prepare parameters - CppOperationParametersWithoutDefaultValue jetParams = new CppOperationParametersWithoutDefaultValue(); - opParameters = jetParams.generate(currentOperation); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template two cases main operation or classical -////////////////////////////////////////////////////////////////////////////////////////// - -// main - if (operationName.equals("main")) { - -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append(TEXT_2); - stringBuffer.append( opDoc ); - stringBuffer.append(TEXT_3); - stringBuffer.append( returnTypeName ); - stringBuffer.append(TEXT_4); - stringBuffer.append( operationName ); - stringBuffer.append(TEXT_5); - stringBuffer.append( opParameters ); - stringBuffer.append(TEXT_6); - stringBuffer.append(TEXT_7); - stringBuffer.append( body ); - stringBuffer.append(TEXT_8); - ////////////////////////////////////////////////////////////////////////////////////////// - - } - else { - -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_9); - stringBuffer.append(TEXT_10); - stringBuffer.append( opDoc ); - stringBuffer.append(TEXT_11); - stringBuffer.append( isInline ); - stringBuffer.append( returnTypeName ); - stringBuffer.append(TEXT_12); - stringBuffer.append( className ); - stringBuffer.append(TEXT_13); - stringBuffer.append( operationName ); - stringBuffer.append(TEXT_14); - stringBuffer.append( opParameters ); - stringBuffer.append(TEXT_15); - stringBuffer.append( isConst ); - stringBuffer.append( constInit ); - stringBuffer.append(TEXT_16); - stringBuffer.append(TEXT_17); - stringBuffer.append( body ); - stringBuffer.append(TEXT_18); - ////////////////////////////////////////////////////////////////////////////////////////// - } -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_19); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java deleted file mode 100644 index fc67d3ec185..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.*; - -public class CppOperationParameters -{ - protected static String nl; - public static synchronized CppOperationParameters create(String lineSeparator) - { - nl = lineSeparator; - CppOperationParameters result = new CppOperationParameters(); - 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 Operation - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String paramDecl = ""; - - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = parameters.next(); - if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) { - // Prepare parameters - CppParameter jetParam = new CppParameter(); - if (!paramDecl.equals("")) { - paramDecl += ", "; - } - paramDecl = paramDecl+jetParam.generate(currentParameter); - } - } - - paramDecl.replaceAll(NL, ""); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( paramDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java deleted file mode 100644 index d3e0dc8d710..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import java.util.*; - -public class CppOperationParametersWithoutDefaultValue -{ - protected static String nl; - public static synchronized CppOperationParametersWithoutDefaultValue create(String lineSeparator) - { - nl = lineSeparator; - CppOperationParametersWithoutDefaultValue result = new CppOperationParametersWithoutDefaultValue(); - 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 Operation - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String paramDecl = ""; - - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = parameters.next(); - if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) { - // Prepare parameters - CppParameterWithoutDefaultValue jetParam = new CppParameterWithoutDefaultValue(); - if (!paramDecl.equals("")) { - paramDecl += ", "; - } - paramDecl = paramDecl+jetParam.generate(currentParameter); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( paramDecl ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java deleted file mode 100644 index 5a75d7009e8..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import org.eclipse.uml2.uml.Class; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.*; - -public class CppOperationReturnType -{ - protected static String nl; - public static synchronized CppOperationReturnType create(String lineSeparator) - { - nl = lineSeparator; - CppOperationReturnType result = new CppOperationReturnType(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "::"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String returnTypeName = "void"; - String ownerName = ""; - Modifier modifier = new Modifier(); - - // Return type - if (currentOperation.getType() == null) { - returnTypeName = "void"; - } else { - if (currentOperation.getType() == null) { - returnTypeName = "undefined"; - } else { - // Treat the type if it is not "package visibility" and owned by a class - Type currentType = currentOperation.getType(); - returnTypeName = GenUtils.qualifiedName (currentType); - - if (currentType.getVisibility() != VisibilityKind.PACKAGE_LITERAL) { - if (currentType.getOwner() instanceof Class) { - ownerName = ((Class) currentType.getOwner()).getName(); - } - } - } - - // Treat pointer or ref on return parameter (only one return parameter should exists) - // retrieve return parameter -// RS: changed test: now getReturnResult returns only one param -// if (currentOperation.getUml2Operation().getReturnResults().size() == 1) { -// org.eclipse.uml2.uml.Parameter uml2Param -// = (org.eclipse.uml2.uml.Parameter) currentOperation.getUml2Operation().getReturnResults().get(0); -// Parameter currentRParameter -// = new Parameter(uml2Param); -// // case Pointer -// if (currentRParameter.hasStereotype(xy, CppPtr.class)) { -// isPointer = " "+currentRParameter.getTaggedValue(CppPtr.class, "declaration"); -// } -// if (currentRParameter.hasStereotype(xy, CppRef.class)) { -// isRef = " "+currentRParameter.getTaggedValue(CppRef.class, "declaration"); -// } -// if (currentRParameter.hasStereotype(xy, CppConst.class_)) { -// isConst = "const "; -// } -// } - if (currentOperation.getReturnResult() instanceof Parameter) { - Parameter uml2Param = (Parameter) currentOperation.getReturnResult(); - modifier = new Modifier(uml2Param); - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template two cases : scope required or not -////////////////////////////////////////////////////////////////////////////////////////// - -// No scope details - if (ownerName.equals("")) { -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( modifier.isConst ); - stringBuffer.append( returnTypeName ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - ////////////////////////////////////////////////////////////////////////////////////////// -} else { -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( modifier.isConst ); - stringBuffer.append( ownerName ); - stringBuffer.append(TEXT_1); - stringBuffer.append( returnTypeName ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - ////////////////////////////////////////////////////////////////////////////////////////// -} -////////////////////////////////////////////////////////////////////////////////////////// - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java deleted file mode 100644 index 18487bed8a5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import org.eclipse.uml2.uml.Class; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.StdStereo; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppOperationTemplateImplementation -{ - protected static String nl; - public static synchronized CppOperationTemplateImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppOperationTemplateImplementation result = new CppOperationTemplateImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "("; - protected final String TEXT_2 = ")"; - protected final String TEXT_3 = " {"; - protected final String TEXT_4 = NL; - protected final String TEXT_5 = NL + "}"; - protected final String TEXT_6 = "<"; - protected final String TEXT_7 = ">::"; - protected final String TEXT_8 = "("; - protected final String TEXT_9 = ")"; - protected final String TEXT_10 = " {"; - protected final String TEXT_11 = NL; - protected final String TEXT_12 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String operationName = currentOperation.getName(); - String opParameters = ""; - String returnTypeName = "void"; - String isConst = ""; - String isInline = ""; - - // Retrieve class & class name - Class currentClass = currentOperation.getClass_ (); - String className = currentClass.getName(); - - // Retrieve body content - String body = GenUtils.getBody (currentOperation, "C/C++"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - if (! "".equals(returnTypeName)) { - returnTypeName = returnTypeName + " "; - } - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // If inline operation - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - isInline = "inline "; - } - - // Const op - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - isConst = " const"; - } - - // Prepare parameters - CppOperationParametersWithoutDefaultValue jetParams - = new CppOperationParametersWithoutDefaultValue(); - opParameters = jetParams.generate(currentOperation); - - - // Prepare template parameter declaration without type - String tparamWoType = ""; - - if (currentClass != null) { - tparamWoType = GenUtils.getTemplateParametersWoType(currentClass); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -// Package visibility - if (currentOperation.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - -////////////////////////////////////////////////////////////////////////////////////////// - - - stringBuffer.append( isInline ); - stringBuffer.append( returnTypeName ); - stringBuffer.append( operationName ); - stringBuffer.append(TEXT_1); - stringBuffer.append( opParameters ); - stringBuffer.append(TEXT_2); - stringBuffer.append( isConst ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - stringBuffer.append( body ); - stringBuffer.append(TEXT_5); - - -////////////////////////////////////////////////////////////////////////////////////////// - - } else { // Default case - -////////////////////////////////////////////////////////////////////////////////////////// - - - stringBuffer.append( isInline ); - stringBuffer.append( returnTypeName ); - stringBuffer.append( className ); - stringBuffer.append(TEXT_6); - stringBuffer.append( tparamWoType ); - stringBuffer.append(TEXT_7); - stringBuffer.append( operationName ); - stringBuffer.append(TEXT_8); - stringBuffer.append( opParameters ); - stringBuffer.append(TEXT_9); - stringBuffer.append( isConst ); - stringBuffer.append(TEXT_10); - stringBuffer.append(TEXT_11); - stringBuffer.append( body ); - stringBuffer.append(TEXT_12); - - -////////////////////////////////////////////////////////////////////////////////////////// - } -////////////////////////////////////////////////////////////////////////////////////////// - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java deleted file mode 100644 index 777e4798740..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Package; -import org.eclipse.papyrus.cpp.codegen.Activator; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppOwnerPackageIncludeDeclaration -{ - protected static String nl; - public static synchronized CppOwnerPackageIncludeDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppOwnerPackageIncludeDeclaration result = new CppOwnerPackageIncludeDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = " \t" + NL + "/* Owner package header include */" + NL + "#include <"; - protected final String TEXT_2 = "/Pkg_"; - protected final String TEXT_3 = "."; - protected final String TEXT_4 = ">"; - protected final String TEXT_5 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the type passed as argument - Package currentPkg = (Package) argument; - String currentPkgName = currentPkg.getName(); - String currentPkgPath = GenUtils.getFullPath (currentPkg); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Prepare Father include declaration - boolean isRoot = false; - - // The currentElt has the CppRoot stereotype - if (GenUtils.hasStereotype(currentPkg, CppRoot.class)) { - isRoot = true; - } - // The currentPkg is the model root package - //if (currentPkg instanceof org.eclipse.uml2.uml.Model){ - // isRoot = true; - //} - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - // if currentPkg is not root it is referenced here - if (!isRoot) { - stringBuffer.append(TEXT_1); - stringBuffer.append( currentPkgPath ); - stringBuffer.append(TEXT_2); - stringBuffer.append( currentPkgName ); - stringBuffer.append(TEXT_3); - stringBuffer.append( headerFileSuffix ); - stringBuffer.append(TEXT_4); - // endif - } - stringBuffer.append(TEXT_5); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java deleted file mode 100644 index 87ac2c0bfac..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Parameter; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.Modifier; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppParameter -{ - protected static String nl; - public static synchronized CppParameter create(String lineSeparator) - { - nl = lineSeparator; - CppParameter result = new CppParameter(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = " "; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Parameter - Parameter currentParameter = (Parameter) argument; - - String parameterName = currentParameter.getName(); - - String typeName = ""; - String suffix = ""; - Modifier modifier = new Modifier(currentParameter); - - if (currentParameter.getType() == null) { - typeName = "undefined"; - } else { - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - - // Initial value - CppDefault cppDefault = GenUtils.getApplication(currentParameter, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( modifier.isConst ); - stringBuffer.append( typeName ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - stringBuffer.append(TEXT_1); - stringBuffer.append( parameterName ); - stringBuffer.append( modifier.array ); - stringBuffer.append( suffix ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java deleted file mode 100644 index 1bb92004f6d..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Parameter; -import org.eclipse.uml2.uml.Classifier; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.Modifier; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppParameterWithoutDefaultValue -{ - protected static String nl; - public static synchronized CppParameterWithoutDefaultValue create(String lineSeparator) - { - nl = lineSeparator; - CppParameterWithoutDefaultValue result = new CppParameterWithoutDefaultValue(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "<"; - protected final String TEXT_2 = ">"; - protected final String TEXT_3 = " "; - protected final String TEXT_4 = " "; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Parameter - Parameter currentParameter = (Parameter) argument; - - String parameterName = currentParameter.getName(); - - String typeName = ""; - Modifier modifier = new Modifier(currentParameter); - - // Prepare template parameter declaration without type - String tparamWoType = ""; - - if (currentParameter.getType() == null) { - typeName = "undefined"; - } - else if (currentParameter.getType() instanceof Classifier) { - Classifier classifier = (Classifier) currentParameter.getType(); - tparamWoType = GenUtils.getTemplateParametersWoType(classifier); - - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - else { - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -// Package visibility - if (!"".equals(tparamWoType)) { - -////////////////////////////////////////////////////////////////////////////////////////// - - - stringBuffer.append( modifier.isConst ); - stringBuffer.append( typeName ); - stringBuffer.append(TEXT_1); - stringBuffer.append( tparamWoType ); - stringBuffer.append(TEXT_2); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - stringBuffer.append(TEXT_3); - stringBuffer.append( parameterName ); - stringBuffer.append( modifier.array ); - - -////////////////////////////////////////////////////////////////////////////////////////// - - } else { // Default case - -////////////////////////////////////////////////////////////////////////////////////////// - - - stringBuffer.append( modifier.isConst ); - stringBuffer.append( typeName ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( modifier.ref ); - stringBuffer.append(TEXT_4); - stringBuffer.append( parameterName ); - stringBuffer.append( modifier.array ); - - - -////////////////////////////////////////////////////////////////////////////////////////// - } -////////////////////////////////////////////////////////////////////////////////////////// - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java deleted file mode 100644 index c014caf01d6..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.PrimitiveType; -import org.eclipse.papyrus.cpp.codegen.jet.doc.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppPrimitiveTypeDefinition -{ - protected static String nl; - public static synchronized CppPrimitiveTypeDefinition create(String lineSeparator) - { - nl = lineSeparator; - CppPrimitiveTypeDefinition result = new CppPrimitiveTypeDefinition(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// 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 -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( typeDoc ); - stringBuffer.append(TEXT_2); - stringBuffer.append( definition ); - stringBuffer.append(TEXT_3); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java deleted file mode 100644 index e24233da4ab..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; -import Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.*; - -public class CppStaticAttributeImplementation -{ - protected static String nl; - public static synchronized CppStaticAttributeImplementation create(String lineSeparator) - { - nl = lineSeparator; - CppStaticAttributeImplementation result = new CppStaticAttributeImplementation(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = ""; - protected final String TEXT_2 = "::"; - protected final String TEXT_3 = ";"; - protected final String TEXT_4 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); - String className = GenUtils.qualifiedName (currentAttribute.getClass_()); - String typeName = ""; - String suffix = ""; - String multiple = ""; - String isAgg = ""; // attribute is an aggregation or association - - - if (currentAttribute.getType() == null) { - typeName = "undefined"+" "; - } else { - typeName = GenUtils.qualifiedName (currentAttribute.getType()) + " "; - } - - // Multiple - // if (currentAttribute.isMultiple()) { - // multiple = "*"; - // } - - // If attribute is aggregation then generate a pointer - if (GenUtils.isAggregation(currentAttribute)) { - // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab - isAgg = "*"; // this produce a tab of pointers - } - - Modifier modifier = new Modifier(currentAttribute); - - // Initial value - if (currentAttribute.getDefaultValue() != null) { - // via UML - suffix = " = " + currentAttribute.getDefaultValue().stringValue(); - } - else { - CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - stringBuffer.append(TEXT_1); - stringBuffer.append( typeName ); - stringBuffer.append( multiple ); - stringBuffer.append( modifier.ptr ); - stringBuffer.append( isAgg ); - stringBuffer.append( modifier.ref ); - stringBuffer.append( className ); - stringBuffer.append(TEXT_2); - stringBuffer.append( attributeName ); - stringBuffer.append( modifier.array ); - stringBuffer.append( suffix ); - stringBuffer.append(TEXT_3); - stringBuffer.append(TEXT_4); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java deleted file mode 100644 index 09feb0868b5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.*; - -public class CppTemplateBindingParameter -{ - protected static String nl; - public static synchronized CppTemplateBindingParameter create(String lineSeparator) - { - nl = lineSeparator; - CppTemplateBindingParameter result = new CppTemplateBindingParameter(); - 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 TemplateParameter - // Retrieve the TemplateParameter - TemplateParameterSubstitution currentTParam = (TemplateParameterSubstitution) argument; - - String typeName = ""; - - if (currentTParam.getActual() == null) { - typeName ="param undefined"; - } - else { - ParameterableElement actual = currentTParam.getActual(); - - if (actual instanceof LiteralInteger) { - typeName = "" + ((LiteralInteger) currentTParam.getActual()).getValue(); - } - else { - typeName = ((NamedElement) currentTParam.getActual()).getName(); - } // value = currentTParam.getFormal().getParameteredElement().getName(); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( typeName ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java deleted file mode 100644 index 567a6ce365f..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * 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.uml2.uml.Class; -import org.eclipse.uml2.uml.TemplateParameter; -import java.util.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; - -public class CppTemplateDeclaration -{ - protected static String nl; - public static synchronized CppTemplateDeclaration create(String lineSeparator) - { - nl = lineSeparator; - CppTemplateDeclaration result = new CppTemplateDeclaration(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "template <"; - protected final String TEXT_2 = ">"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - - // Prepare template parameter declaration - Iterator tparam = GenUtils.getTemplateParameters(currentClass).iterator(); - String tParamDecl = ""; - - while(tparam.hasNext()) { - TemplateParameter currentTParam = tparam.next(); - - CppTemplateParameter jetTParam = new CppTemplateParameter(); - tParamDecl = tParamDecl+jetTParam.generate(currentTParam); - - if (tparam.hasNext()) { - tParamDecl = tParamDecl+", "; - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append(TEXT_1); - stringBuffer.append( tParamDecl ); - stringBuffer.append(TEXT_2); - return stringBuffer.toString(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 999e3789ce1..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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 " - tDecl = jetTDecl.generate(currentClass) + " "; - - // Retrieve operations - Iterator 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 diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java deleted file mode 100644 index 30e4dc8da32..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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 Cpp.*; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import org.eclipse.uml2.uml.TemplateParameter; - -public class CppTemplateParameter -{ - protected static String nl; - public static synchronized CppTemplateParameter create(String lineSeparator) - { - nl = lineSeparator; - CppTemplateParameter result = new CppTemplateParameter(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = " "; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve the TemplateParameter - TemplateParameter currentTParam = (TemplateParameter) argument; - - String parameterName = ""; - String typeName = ""; - - - if (GenUtils.getType(currentTParam) == "") { - typeName = "undefined"; - } else { - typeName = GenUtils.getType(currentTParam); //.getName(); - } - - // Retrieve name under stereotype CppTemplateParameter/name - Cpp.CppTemplateParameter ctp = GenUtils.getApplication(currentTParam, Cpp.CppTemplateParameter.class); - if (ctp != null) { - parameterName = ctp.getName(); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// - - stringBuffer.append( typeName ); - stringBuffer.append(TEXT_1); - stringBuffer.append( parameterName ); - return stringBuffer.toString(); - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/Constants.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/Constants.java index 33e044a0323..34ebf025224 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/Constants.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/Constants.java @@ -33,4 +33,6 @@ public class Constants { public static final String forwardDecl = "// forward declarations"; public static final String staticAttributes = "// static attributes (if any)"; + + public static final String undefinedType = "undefined"; } diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/Constants.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/Constants.mtl new file mode 100644 index 00000000000..2aea121b9e5 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/Constants.mtl @@ -0,0 +1,52 @@ +[comment encoding = UTF-8 /] +[module Constants('http://www.eclipse.org/uml2/4.0.0/UML')] + + +[template public includeHFile(dummy : Element)] +// include associated header file +[/template] + +[template public IncludeHeaderStart(dummy : Element)] +// Include from Include stereotype (header) +[/template] + +[template public IncludePreBodyStart(dummy : Element)] +// Include from Include stereotype (pre-body) +[/template] + +[template public IncludePreBodyEnd(dummy : Element)] +// End of Include stereotype (pre-body) +[/template] + +[template public IncludeBodyStart(dummy : Element)] +// Include from Include declaration (body) +[/template] + +[template public IncludeHeaderEnd(dummy : Element)] +// End of Include stereotype (header) +[/template] + +[template public IncludeBodyEnd(dummy : Element)] +// End of Include stereotype (body) +[/template] + +[template public derivedIncludes(dummy : Element)] +// Derived includes directives +[/template] + +[template public forwardDecl(dummy : Element)] +// forward declarations +[/template] + +[template public staticAttributes(dummy : Element)] +// static attributes (if any) +[/template] + +[template public packageTypes(dummy : Element)] +// Types defined within the package +[/template] + + +[template public undefinedType(dummy : Element)] +undefined +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindBody.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindBody.mtl new file mode 100644 index 00000000000..da720a05838 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindBody.mtl @@ -0,0 +1,40 @@ +[module CppBindBody('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::IncludeUtils/] +[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeClassDeclaration/] + + +[template public CppBindBody(class : Class)] +#define [getFullNameUC()/]_BODY + +/************************************************************ + [class.name/] template binding body + ************************************************************/ + +[IncludePreBody()/] + +[includeHFile()/] +#include <[_package.getFullPath()/][class.name/].[getHeaderSuffix()/]> + +[IncludeBody()/] + +[openNS()/] + +[derivedIncludes()/] +[CppClassAllIncludesDeclaration()/] + +/************************************************************/ +[let tb : TemplateBinding = getTemplateBindings()] +[let templateElement : Classifier = tb.target->asSequence()->first()] +template class [templateElement.name/] <[for (tb.parameterSubstitution)][CppTemplateBindingParameter()/][/for]> [class.name/]; +[/let][/let] +[closeNS()/] + +/************************************************************ + End of [class.name/] template binding body + ************************************************************/ +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindHeader.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindHeader.mtl new file mode 100644 index 00000000000..99148264afc --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppBindHeader.mtl @@ -0,0 +1,38 @@ +[module CppBindHeader('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::clazz::CppClassIncludeClassDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/] +[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/] + + +[template public CppBindHeader(class : Class)] +#ifndef [getFullNameUC()/]_H +#define [getFullNameUC()/]_H + +/************************************************************ + [class.name/] template binding header + ************************************************************/ + +[_package.CppOwnerPackageIncludeDeclaration()/] + +[CppClassAllIncludesDeclaration()/] + +[getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include).header/] + +[let tb : TemplateBinding = getTemplateBindings()] +[let templateElement : Classifier = tb.target->asSequence()->first()] +#include <[_package.getFullPath()/]/[templateElement.owner.oclAsType(NamedElement).name/].[getHeaderSuffix()/]> + +[openNS()/] +/************************************************************/ +typedef [templateElement.name/] <[for (tb.parameterSubstitution)][CppTemplateBindingParameter()/][/for]> [class.name/]; + +[closeNS()/] +[/let][/let] + +/************************************************************ + End of [class.name/] template binding header + ************************************************************/ + +#endif +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassBody.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassBody.mtl new file mode 100644 index 00000000000..cf2e1f70034 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassBody.mtl @@ -0,0 +1,37 @@ +[module CppClassBody('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::IncludeUtils/] +[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeClassDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassOperationsImplementation/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::property::CppAttributeImplementation/] + + +[template public CppClassBody(class : Classifier)] +#define [getFullName()/]_BODY + +/************************************************************ + [class.name/] class body + ************************************************************/ + +[IncludePreBody()/] + +[includeHFile()/] +#include <[_package.getFullPath()/]/[class.name/].[getHeaderSuffix()/]> + +[IncludeBody()/] + +[derivedIncludes()/] +[CppClassAllIncludesDeclaration()/] + +[openNS(class)/] +[CppStaticAttributes(class)/] +[CppClassOperationsImplementation(false)/] +[closeNS(class)/] + +/************************************************************ + End of [class.name/] class body + ************************************************************/ +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl new file mode 100644 index 00000000000..54920cec07c --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl @@ -0,0 +1,94 @@ +[module CppClassHeader('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::IncludeUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeClassDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassTypeAndEnum/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassFriendDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassInheritedDeclarations/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassAttributesDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassOperationsDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassOperationsImplementation/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/] + + + +[query public classUnionOrStruct(classifier : Classifier) : String = +if (hasStereotype(C_Cpp::Union)) then 'union' +else + if (oclIsKindOf(DataType)) then 'struct' + else 'class' + endif +endif +/] + +[comment default initializer for non-static attributes with a default value +TODO: should be disabled by default, since non-static members can be initialized directly +in C++ 011/] +[template public defaultInitializer(classifier : Classifier) post(trim())] +[let attributeList : Set(Property) = attribute->select( + (isStatic = false) and + (defaultValue <> null) and + (defaultValue.stringValue() <> null))] +[if not attributeList->isEmpty()] + [classifier.name/]() : [for (a : Property | attributeList) separator(', ') + ][name/]([defaultValue.stringValue()/])[/for] {} +[/if][/let] +[/template] + + +[template public CppClassHeader(class : Classifier)] +#ifndef [getFullNameUC()/]_H +#define [getFullNameUC()/]_H + +/************************************************************ + [class.name/] class header + ************************************************************/ + +[_package.CppOwnerPackageIncludeDeclaration()/] + +[CppClassAllIncludesDeclaration()/] + +[IncludeHeader()/] + +[openNS()/] +[_package.CppClassTypeAndEnumPackage()/] +/************************************************************/ +[CppElementDoc()/] +[templateSignature()/][classUnionOrStruct()/] [class.name/][CppClassInheritedDeclarations()/] { +[CppClassIncludeFriendDeclaration()/][CppClassTypeAndEnum()/] + + public: +[defaultInitializer()/][CppClassAttributesDeclaration(VisibilityKind::public)/][CppClassOperationsDeclaration(VisibilityKind::public)/] + + protected: +[CppClassAttributesDeclaration(VisibilityKind::protected)/][CppClassOperationsDeclaration(VisibilityKind::protected)/] + + private: +[CppClassAttributesDeclaration(VisibilityKind::private)/][CppClassOperationsDeclaration(VisibilityKind::private)/] + +}; +/************************************************************/ +/* External declarations (package visibility) */ +[CppClassAttributesDeclaration(VisibilityKind::_package)/] +[CppClassOperationsDeclaration(VisibilityKind::_package)/] +/************************************************************/ + +[if (isTemplate())] +/************************************************************/ +/* Template functions */ +[CppClassOperationsImplementation(false)/] +[/if] + +/* Inline functions */ +[CppClassOperationsImplementation(true)/] +[closeNS()/] + +/************************************************************ + End of [class.name/] class header + ************************************************************/ + +#endif +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppPackageHeader.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppPackageHeader.mtl new file mode 100644 index 00000000000..95a0f6b8e65 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppPackageHeader.mtl @@ -0,0 +1,52 @@ +[module CppPackageHeader('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::IncludeUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeClassDeclaration/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassTypeAndEnum/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassFriendDeclaration/] + + +[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/] + + +[template public CppPackageHeader(pkg : Package)] +#ifndef PKG_[getFullNameUC()/] +#define PKG_[getFullNameUC()/] + +/************************************************************ + Pkg_[name/] package header + ************************************************************/ + +[nestingPackage.CppOwnerPackageIncludeDeclaration()/] + +#ifndef _IN_ +#define _IN_ +#endif +#ifndef _OUT_ +#define _OUT_ +#endif +#ifndef _INOUT_ +#define _INOUT_ +#endif + + +/* Package dependency header include */ +[for (getUsedPackages())] +#include <[getFullPath()/]/Pkg_[name/].[getHeaderSuffix()/]> +[/for] + +[IncludeHeader()/] + +[openNS()/] +[packageTypes()/] +[CppClassTypeAndEnumPackage()/] +[closeNS()/] + +/************************************************************ + End of Pkg_[name/] package header + ************************************************************/ + +#endif +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/IncludeUtils.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/IncludeUtils.mtl new file mode 100644 index 00000000000..cd81da94794 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/IncludeUtils.mtl @@ -0,0 +1,28 @@ +[comment encoding = UTF-8 /] +[module IncludeUtils('http://www.eclipse.org/uml2/4.0.0/UML')] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/] + +[template public IncludeHeader(ne : NamedElement)] +[if (hasStereotype(C_Cpp::Include) and (getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include).header.size() > 0))] +[IncludeHeaderStart()/] +[getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include).header/] +[IncludeHeaderEnd()/] +[/if] +[/template] + +[template public IncludeBody(ne : NamedElement)] +[if (hasStereotype(C_Cpp::Include) and (getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include)._body <> null))] +[IncludeBodyStart()/] +[getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include)._body/] +[IncludeBodyEnd()/] +[/if] +[/template] + +[template public IncludePreBody(ne : NamedElement)] +[if (hasStereotype(C_Cpp::Include))] +[IncludePreBodyStart()/] +[getApplication(C_Cpp::Include).oclAsType(C_Cpp::Include).preBody/] +[IncludePreBodyEnd()/] +[/if] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl new file mode 100644 index 00000000000..644096558af --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl @@ -0,0 +1,22 @@ +[module CppDocumentation('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] + + +[template public CppElementDoc(argument : Element)] +/** + * [getComments().replaceAll('\n', '\n * ')/] + */ +[/template] + + +[template public CppOperationDoc(operation : Operation)] +/** + * [getComments().replaceAll('\n', '\n * ')/] + * [for (ownedParameter)][CppParamDoc()/][/for] + */ +[/template] + + +[template public CppParamDoc(parameter : Parameter)] +@param [name/] [getComments().replaceAll('\n', '\n * ')/] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl new file mode 100644 index 00000000000..97f7653d5c2 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl @@ -0,0 +1,14 @@ +[module CppEnumerations('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::CppDocumentation/] + +[template public CppEnumerationDefinition(enum : Enumeration)] +[CppElementDoc()/] +enum [enum.name/] { +[for (ownedLiteral)]/ + [CppElementDoc()/] + [name/][if hasStereotype(CppInit)] = [getApplication(CppInit).oclAsType(CppInit).value/][/if], +[/for] +}; + +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl new file mode 100644 index 00000000000..28072961454 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl @@ -0,0 +1,29 @@ +[module CppPrimitiveTypes('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::CppDocumentation/] + + +[comment + * 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) + * (3) Sometimes the name of the type defined by a typedef does not appear at the end, e.g. + * when defining functionPointers such as "typedef int (*HandlerFct) (void*);" + * (a function with a void* argument returning int) + * Support this case via a specific 'typeName' constant that gets replaced by the name of the + * type + */ +/] +[template public CppPrimitiveTypeDefinition(primitiveType : PrimitiveType)] +[CppElementDoc()/] +[if (hasStereotype(Typedef))] +typedef [getApplication(Typedef).oclAsType(Typedef).definition.replaceAll('typeName', primitiveType.name) + /][if (not getApplication(Typedef).oclAsType(Typedef).definition.contains('typeName'))] [primitiveType.name/][/if]; +[else] +[getStdtypes(primitiveType)/]; +[/if] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl new file mode 100644 index 00000000000..0cb88942a45 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl @@ -0,0 +1,26 @@ +[module CppTemplates('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] + + +[query public CppTemplateBindingParameter(tps : TemplateParameterSubstitution) : String = +if (tps.actual.oclIsKindOf(LiteralInteger)) then + tps.actual.oclAsType(LiteralInteger).value +else + tps.actual.oclAsType(NamedElement).name +endif +/] + +[query public isTemplate(class : Classifier) : Boolean = + getTemplateParameters()->size() > 0 +/] + + +[template public templateSignature(class : Classifier)] +[if isTemplate()] +template<[for (getTemplateParameters()) separator(', ')][getType()/][/for]> [/if] +[/template] + + +[template public templateSignature(operation : Operation)] +[owner.oclAsType(Classifier).templateSignature()/] +[/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/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 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] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl new file mode 100644 index 00000000000..5b5e08e92ca --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl @@ -0,0 +1,18 @@ +[module CppParameter('http://www.eclipse.org/uml2/4.0.0/UML')/] +[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/] +[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/] + + + +[template public defaultValue(parameter : Parameter)] +[if (hasStereotype(C_Cpp::Default))] = [getApplication(C_Cpp::Default).oclAsType(C_Cpp::Default).value/][/if] +[/template] + +[template public CppParameter(parameter : Parameter)] +[modConst()/][parameter.type.qualifiedName()/][modPtr()/][modRef()/] [parameter.name/][modArray()/][defaultValue()/] +[/template] + + +[template public CppOperationParameters(operation : Operation)] +[for (ownedParameter->select(direction <> ParameterDirectionKind::return)) separator(', ')][CppParameter()/][/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/property/CppAttributeDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl new file mode 100644 index 00000000000..9a22ee68143 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl @@ -0,0 +1,21 @@ +[module CppAttributeDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/] +[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/] + + + + +[template public defaultValue(attribute : Property)] +[if (defaultValue <> null) and isStatic] = [attribute.defaultValue.stringValue()/][/if] +[/template] + +[template public staticValue(attribute : Property)] +[if (attribute.isStatic)]static [/if] +[/template] + +[template public CppAttributeDeclaration(attribute : Property)] +[CppElementDoc()/] +[staticValue()/][modConst()/][attribute.type.qualifiedName()/][modPtr()/][modRef()/] [attribute.name/][modArray()/][defaultValue()/]; +[/template] + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl new file mode 100644 index 00000000000..57aae8be4d8 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl @@ -0,0 +1,35 @@ +[module CppAttributeImplementation('http://www.eclipse.org/uml2/4.0.0/UML')/] +[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/] + + +[comment +// for static implementation: +// If attribute is aggregation then generate a pointer + if (GenUtils.isAggregation(currentAttribute)) { + // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab + isAgg = "*"; // this produce a tab of pointers + } +/] + +[template public CppAttributeImplementation(attribute : Property)] + [CppElementDoc()/] + [modConst()/][attribute.type.qualifiedName()/][modPtr()/][modRef()/] [attribute.name/][modArray()/]; +[/template] + +[template public CppStaticAttributeImplementation(attribute : Property)] + [CppElementDoc()/] + [type.qualifiedName()/][modPtr()/][modRef()/][attribute.class.name/]::[attribute.name/][modArray()/]; +[/template] + +[comment +Loop over attributes. Check that the attribute is not a static const. +Constant static attributes are declared within the class declaration/] +[template public CppStaticAttributes(classifier : Classifier)] +[for (classifier.attribute)] + [if(isStatic and (not hasStereotype(C_Cpp::Const)))] + [CppStaticAttributeImplementation()/] + [/if] +[/for] +[/template] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java index 3e579c05b10..27adfd59abb 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java @@ -23,6 +23,11 @@ public class CppCodeGenConstants { */ public static final String P_IMPLEM_SUFFIX = "implSuffix"; + /** + * Suffix for generated body/implementation files + */ + public static final String P_OUT_INOUT_OP = "outInoutOp"; + /** * User defined comment header in generated files */ diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java index 96cacb33444..0de1976c2a8 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java @@ -27,6 +27,7 @@ public class CppCodeGenPreferenceInitializer extends AbstractPreferenceInitializ IPreferenceStore store = Activator.getDefault().getPreferenceStore(); store.setDefault(CppCodeGenConstants.P_HEADER_SUFFIX, "h"); store.setDefault(CppCodeGenConstants.P_IMPLEM_SUFFIX, "cpp"); + store.setDefault(CppCodeGenConstants.P_OUT_INOUT_OP, "*"); // Default value for P_COMMENT_HEADER String NL = System.getProperties().getProperty("line.separator"); diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.java index d7094ee9786..58ee3e6ae9a 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.java @@ -34,6 +34,11 @@ public class CppCodeGenUtils { return preferenceStore.getString(CppCodeGenConstants.P_IMPLEM_SUFFIX); } + public static String getOutInoutOp() { + initPreferenceStore(); + return preferenceStore.getString(CppCodeGenConstants.P_OUT_INOUT_OP); + } + public static String getCommentHeader() { initPreferenceStore(); return preferenceStore.getString(CppCodeGenConstants.P_COMMENT_HEADER); diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.mtl new file mode 100644 index 00000000000..05979359e41 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenUtils.mtl @@ -0,0 +1,13 @@ +[comment encoding = UTF-8 /] +[module CppCodeGenUtils('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[query public getHeaderSuffix() : String + = invoke('org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenUtils', 'getHeaderSuffix()', Sequence{}) /] + + +[query public getBodySuffix() : String + = invoke('org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenUtils', 'getBodySuffix()', Sequence{}) /] + +[query public getCommentHeader() : String + = invoke('org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenUtils', 'getCommentHeader()', Sequence{}) /] + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/CppModelElementsCreator.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/CppModelElementsCreator.java new file mode 100644 index 00000000000..7eb3b2ad5d8 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/CppModelElementsCreator.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) 2006 - 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - initial API and implementation + *******************************************************************************/ + +package org.eclipse.papyrus.cpp.codegen.transformation; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.acceleo.AcceleoDriver; +import org.eclipse.papyrus.acceleo.ModelElementsCreator; +import org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenUtils; +import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; +import org.eclipse.papyrus.cpp.profile.StUtils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Namespace; +import org.eclipse.uml2.uml.Package; + +import C_Cpp.CppRoot; +import C_Cpp.ExternClass; +import C_Cpp.Include; +import C_Cpp.ManualGeneration; +import C_Cpp.NoCodeGen; +import C_Cpp.Template; + + + +/** + * Main class of code generator + */ +public class CppModelElementsCreator extends ModelElementsCreator { + + public static final String ACCELEO_PREFIX = "org::eclipse::papyrus::cpp::codegen::acceleo::"; + + public static final String CppClassBody = ACCELEO_PREFIX + "CppClassBody"; + + public static final String CppClassHeader = ACCELEO_PREFIX + "CppClassHeader"; + + public static final String CppBindBody = ACCELEO_PREFIX + "CppBindBody"; + + public static final String CppBindHeader = ACCELEO_PREFIX + "CppBindHeader"; + + public static final String CppPackageHeader = ACCELEO_PREFIX + "CppPackageHeader"; + + /** + * + * Constructor. + * + * @param project + * the project in which the generated code should be placed + */ + public CppModelElementsCreator(IProject project) { + super(project, CppCodeGenUtils.getCommentHeader()); + hppExt = CppCodeGenUtils.getHeaderSuffix(); + cppExt = CppCodeGenUtils.getBodySuffix(); + } + + /** + * + * Constructor. + * + * @param project + * the project in which the generated code should be placed + * @param commentHeader + * Custom prefix for each generated file + */ + public CppModelElementsCreator(IProject project, String commentHeader) { + super(project, commentHeader); + hppExt = CppCodeGenUtils.getHeaderSuffix(); + cppExt = CppCodeGenUtils.getBodySuffix(); + } + + + protected String hppExt; + + protected String cppExt; + + + /** + * Creates the files corresponding to the class. For a "simple" class + * generates 2 headers (one for the privates concrete operations and one for + * the attributes, public operations and virtual / abstract operations and + * one body file. + * + * @param folder + * @param classifier + * @throws CoreException + */ + protected void createClassifierFiles(IContainer container, Classifier classifier) throws CoreException { + + // treat case of manual code generation + if(GenUtils.hasStereotype(classifier, ManualGeneration.class)) { + ManualGeneration mg = StUtils.getApplication(classifier, ManualGeneration.class); + Include cppInclude = StUtils.getApplication(classifier, Include.class); + String fileContent = commentHeader + cppInclude.getHeader(); + createFile(container, classifier.getName() + "." + hppExt, fileContent, true); + + String manualURI = "TODO"; // fileContent = AcceleoDriver.evaluateURI(new URI(CppPackageHeader)), classifier); + + fileContent = commentHeader + cppInclude.getPreBody() + GenUtils.NL + manualURI + GenUtils.NL + cppInclude.getBody(); + String ext = GenUtils.maskNull(mg.getExtensionBody()); + if(ext.length() == 0) { + ext = cppExt; + } + createFile(container, classifier.getName() + "." + ext, fileContent, true); + } + + // Only generate when no CppNoCodeGen stereotype is applied to the class + else if((!GenUtils.hasStereotype(classifier, NoCodeGen.class)) && (!GenUtils.hasStereotype(classifier, ExternClass.class)) && (!GenUtils.hasStereotype(classifier, Template.class))) { + + // Template Bound Class + if(GenUtils.isTemplateBoundElement(classifier)) { + String fileContent = commentHeader + AcceleoDriver.evaluateURI(CppBindHeader, classifier); + createFile(container, classifier.getName() + "." + hppExt, fileContent, true); + + fileContent = commentHeader + AcceleoDriver.evaluateURI(CppBindBody, classifier); + createFile(container, classifier.getName() + "." + cppExt, fileContent, true); + } + else { + // Header file generation + String fileContent = commentHeader + AcceleoDriver.evaluateURI(CppClassHeader, classifier); + createFile(container, classifier.getName() + "." + hppExt, fileContent, true); + + // Create class body + if(classifier instanceof Class) { + fileContent = commentHeader + AcceleoDriver.evaluateURI(CppClassBody, classifier); + createFile(container, classifier.getName() + "." + cppExt, fileContent, true); + } + } + } + } + + + protected void createPackageFiles(IContainer packageContainer, IProgressMonitor monitor, Package pkg) throws CoreException { + // Creates the header for the package. + String fileContent = commentHeader + AcceleoDriver.evaluateURI(CppPackageHeader, pkg); + createFile(packageContainer, "Pkg_" + pkg.getName() + "." + hppExt, fileContent, true); + } + + + protected boolean isRoot(Namespace ns) { + return GenUtils.hasStereotype(ns, CppRoot.class); + } + + protected boolean noCodeGen(Element element) { + return GenUtils.hasStereotype(element, NoCodeGen.class); + } +} diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/ModelElementsCreator.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/ModelElementsCreator.java deleted file mode 100644 index 85b2c514068..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/transformation/ModelElementsCreator.java +++ /dev/null @@ -1,420 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 - 2012 CEA LIST. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - initial API and implementation - *******************************************************************************/ - -package org.eclipse.papyrus.cpp.codegen.transformation; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.util.EList; -import org.eclipse.papyrus.cpp.codegen.jet.CppBindBody; -import org.eclipse.papyrus.cpp.codegen.jet.CppBindHeader; -import org.eclipse.papyrus.cpp.codegen.jet.CppClassBody; -import org.eclipse.papyrus.cpp.codegen.jet.CppClassHeader; -import org.eclipse.papyrus.cpp.codegen.jet.CppInterfaceHeader; -import org.eclipse.papyrus.cpp.codegen.jet.CppPackageHeader; -import org.eclipse.papyrus.cpp.codegen.jet.CppTemplateHeader; -import org.eclipse.papyrus.cpp.codegen.jet.util.CppClassIncludeDeclaration; -import org.eclipse.papyrus.cpp.codegen.utils.GenUtils; -import org.eclipse.papyrus.cpp.profile.StUtils; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.DataType; -import org.eclipse.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.Interface; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Namespace; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PackageableElement; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.Relationship; -import org.eclipse.uml2.uml.Usage; - -import Cpp.CppExternClass; -import Cpp.CppInclude; -import Cpp.CppNoCodeGen; -import Cpp.CppRoot; -import Cpp.CppTemplate; -import Cpp.ManualGeneration; - - - -/** - * Main class of code generator - */ -public class ModelElementsCreator { - - /** - * - * Constructor. - * - * @param project - * the project in which the generated code should be placed - * @param hppExt - * The file suffix for c++ header files - * @param cppExt - * The file suffix for c++ implementation files - * @param headerComment - * Prefix for each generated file - */ - public ModelElementsCreator(IProject project, String hppExt, String cppExt, String headerComment) { - this.hppExt = hppExt; - this.cppExt = cppExt; - this.headerComment = headerComment; - this.project = project; - } - - private String hppExt; - - private String cppExt; - - private String headerComment; - - private IProject project; - - /** - * Main function for user calls. Creates code for a packageable element. - * - * @param monitor - * a progress monitor - * @param element - * the element for which code should be generated - * @throws CoreException - */ - public void createPackageableElement(IProgressMonitor monitor, PackageableElement element) throws CoreException { - IContainer packageContainer = getContainer(element); - createPackageableElement(packageContainer, monitor, element); - } - - /** - * Variant of main function: user may supply explicit container (also used by internal function to avoid - * re-calculating the entry container for each element). - * - * @param packageContainer - * The container (directory), in which code should be created - * @param monitor - * a progress monitor - * @param element - * the element for which code should be generated - * @throws CoreException - */ - public void createPackageableElement(IContainer packageContainer, IProgressMonitor monitor, PackageableElement element) throws CoreException { - if(element instanceof Package) { - createPackage(packageContainer, monitor, (Package)element); - } else if(element instanceof Class) { - createClassFiles(packageContainer, (Class)element); - } else if(element instanceof Interface) { - createInterfaceFile(packageContainer, (Interface)element); - } else if((element instanceof PrimitiveType) || (element instanceof Enumeration) || (element instanceof Usage)) { - // do nothing, included in package - } else if(element instanceof DataType) { - createDataTypeFiles(packageContainer, (DataType)element); - } else if(element instanceof Relationship) { - // no code generation for relationships - } else { - System.err.println("C++ code generator: unsupported model element " + element); - } - } - - public void removePackageableElement(IProgressMonitor monitor, PackageableElement element) throws CoreException { - IContainer packageContainer = getContainer(element); - if(packageContainer instanceof IFolder) { - if(element instanceof Package) { - IFolder folder = ((IFolder)packageContainer).getFolder(element.getName()); - folder.delete(true, null); - } else if(element instanceof Classifier) { - IFile file = ((IFolder)packageContainer).getFile(element.getName()); - file.delete(true, null); - } - } - } - - /** - * Creates the files corresponding to the class. For a "simple" class - * generates 2 headers (one for the privates concrete operations and one for - * the attributes, public operations and virtual / abstract operations and - * one body file. - * - * @param folder - * @param classObject - * @throws CoreException - */ - protected void createClassFiles(IContainer container, Class classObject) throws CoreException { - - // treat case of manual code generation - if(GenUtils.hasStereotype(classObject, ManualGeneration.class)) { - ManualGeneration mg = StUtils.getApplication(classObject, ManualGeneration.class); - CppInclude cppInclude = StUtils.getApplication(classObject, CppInclude.class); - String fileContent = headerComment + cppInclude.getHeader(); - createFile(container, classObject.getName() + "." + hppExt, fileContent, true); - - CppClassIncludeDeclaration jetIDecl = new CppClassIncludeDeclaration(); - String include = jetIDecl.generate(classObject); - - fileContent = headerComment + cppInclude.getPreBody() + GenUtils.NL + include + GenUtils.NL + cppInclude.getBody(); - String ext = GenUtils.maskNull(mg.getExtensionBody()); - if(ext.length() == 0) { - ext = cppExt; - } - createFile(container, classObject.getName() + "." + ext, fileContent, true); - } - - // Only generate when no CppNoCodeGen stereotype is applied to the class - else if((!GenUtils.hasStereotype(classObject, CppNoCodeGen.class)) && (!GenUtils.hasStereotype(classObject, CppExternClass.class)) && (!GenUtils.hasStereotype(classObject, CppTemplate.class))) { - - CppClassHeader headerGenerator = new CppClassHeader(); - CppClassBody bodyGenerator = new CppClassBody(); - - // Template Bound Class - if(GenUtils.isTemplateBoundElement(classObject)) { - CppBindHeader templateBindingGenerator = new CppBindHeader(); - CppBindBody bodyBindingGenerator = new CppBindBody(); - String fileContent = headerComment + templateBindingGenerator.generate(classObject); - createFile(container, classObject.getName() + "." + hppExt, fileContent, true); - - fileContent = headerComment + bodyBindingGenerator.generate(classObject); - createFile(container, classObject.getName() + "." + cppExt, fileContent, true); - } else { - if(classObject.isTemplate()) { - CppTemplateHeader templateGenerator = new CppTemplateHeader(); - String fileContent = headerComment + templateGenerator.generate(classObject); - createFile(container, classObject.getName() + "." + hppExt, fileContent, true); - } else { - - // The class is actually a class. - - // Header file generation - String fileContent = headerComment + headerGenerator.generate(classObject); - createFile(container, classObject.getName() + "." + hppExt, fileContent, true); - - // "Traditional" code generation : one body file for all - // operations. - fileContent = headerComment + bodyGenerator.generate(classObject); - createFile(container, classObject.getName() + "." + cppExt, fileContent, true); - } - } - } - } - - /** - * Creates the files corresponding to data types. - * - * @param container - * @param dataTypeObject - * @throws CoreException - */ - protected void createDataTypeFiles(IContainer container, DataType dataTypeObject) throws CoreException { - - CppClassHeader headerGenerator = new CppClassHeader(); - CppClassBody bodyGenerator = new CppClassBody(); - - String fileContent = ""; - - // Only generate when no CppNoCodeGen stereotype is applied to the class - if((!GenUtils.hasStereotype(dataTypeObject, CppNoCodeGen.class)) && (!GenUtils.hasStereotype(dataTypeObject, CppExternClass.class)) && (!GenUtils.hasStereotype(dataTypeObject, CppTemplate.class))) { - - // Template Bound Class - // templates for data types currently not supported - /* - * if(dataTypeObject.isTemplateBoundElement()) - * { - * CppBindHeader templateBindingGenerator = new CppBindHeader(); - * CppBindBody bodyBindingGenerator = new CppBindBody(); - * fileContent = headerComment - * + templateBindingGenerator.generate(dataTypeObject); - * createFile(container, dataTypeObject.getName() + "." + hpp, - * fileContent, true); - * - * fileContent = headerComment - * + bodyBindingGenerator.generate(dataTypeObject); - * createFile(container, dataTypeObject.getName() + "." + cpp, - * fileContent, true); - * } else { - */ - - // Header file generation - fileContent = headerComment + headerGenerator.generate(dataTypeObject); - createFile(container, dataTypeObject.getName() + "." + hppExt, fileContent, true); - - // "Traditional" code generation : one body file for all - // operations. - fileContent = headerComment + bodyGenerator.generate(dataTypeObject); - createFile(container, dataTypeObject.getName() + "." + cppExt, fileContent, true); - } - } - - /** - * Creates a text file in an eclipse container (either IFolder or - * IProject). If this file already exists it is replaced. - * - * @param owner - * the container that will contain the file. - * @param filename - * The name of the file to create. - * @param content - * Te text content of the file. - * @throws CoreException - */ - protected void createFile(IContainer owner, String filename, String content, boolean force) throws CoreException { - IFile file = null; - if(owner instanceof IProject) { - file = ((IProject)owner).getFile(filename); - } else if(owner instanceof IFolder) { - file = ((IFolder)owner).getFile(filename); - } else { - // undefined - } - if(file != null) { - createFile(file, content, force); - } - } - - /** - * Creates a text file in an eclipse folder. If this file already - * exists it is replaced. - * - * @param folder - * The folder that will contain the file. - * @param filename - * The name of the file to create. - * @param content - * Te text content of the file. - * @throws CoreException - */ - protected void createFile(IFile file, String content, boolean force) throws CoreException { - if(file.exists() && force) { - // file.delete(true,true,null); - // YT - deleting files produce inconsistency in SVN working copies - final URI locationURI = file.getLocationURI(); - if(locationURI != null) { - IFileStore store = EFS.getStore(locationURI); - OutputStream os = store.openOutputStream(0, null); - try { - os.write(content.getBytes()); - } catch (IOException e) { - System.err.println(e); - } - } - // file.setContents(new ByteArrayInputStream(content.getBytes()), - // true, true, null); - } else if(file.exists() && !(force)) { - // the file is not updated - } else { - // the file does not exists - file.create(new ByteArrayInputStream(content.getBytes()), true, null); - } - } - - /** - * Creates the header file corresponding to the interface - * - * @param folder - * @param interfaceObject - * @throws CoreException - */ - protected void createInterfaceFile(IContainer container, Interface interfaceObject) throws CoreException { - if(!GenUtils.hasStereotype(interfaceObject, CppNoCodeGen.class)) { - - CppInterfaceHeader headerGenerator = new CppInterfaceHeader(); - String fileContent = ""; - - fileContent = headerComment + headerGenerator.generate(interfaceObject); - createFile(container, interfaceObject.getName() + "." + hppExt, fileContent, true); - } - } - - /** - * Recursively creates folders for a given package - * - * @param packageContainer - * The folder where the folder hierarchy for this package will be - * created. - * @param monitor - * a progress monitor - * @param pkg - * the package for which code should be created - * @throws CoreException - */ - protected void createPackage(IContainer packageContainer, IProgressMonitor monitor, Package pkg) throws CoreException { - monitor.subTask("generate package " + pkg.getQualifiedName()); - - if(!GenUtils.hasStereotype(pkg, CppRoot.class) && !GenUtils.hasStereotype(pkg, CppNoCodeGen.class)) { - - String fileContent = ""; - - packageContainer = (packageContainer instanceof IProject) ? ((IProject)packageContainer).getFolder(pkg.getName()) : ((IFolder)packageContainer).getFolder(pkg.getName()); - - // Create a new folder corresponding to the package if it does not exist - if(!packageContainer.exists()) { - // if packageContainer is a Project, it necessarily exists - ((IFolder)packageContainer).create(false, true, null); - } - - // Creates the header for the package. - CppPackageHeader pkgHeaderGenerator = new CppPackageHeader(); - fileContent = ""; - fileContent = headerComment + pkgHeaderGenerator.generate(pkg); - createFile(packageContainer, "Pkg_" + pkg.getName() + "." + hppExt, fileContent, true); - - // Continue generation parsing package content - // If CppNoCodeGen on package, it applies to its content - - for(PackageableElement currentElement : pkg.getPackagedElements()) { - createPackageableElement(packageContainer, monitor, currentElement); - } - } - } - - /** - * Return a container (folder) for a given named element. The folder is embedded into a set - * of folders that correspond to the namespaces of the element. These folders will be - * created, if the do not exist (comparable to "mkdir -p" in Unix). - * - * @param element - * a named element - * @return folder for this element - */ - public IContainer getContainer(NamedElement element) { - try { - IContainer packageContainer = project; - EList namespaces = element.allNamespaces(); - for(int i = namespaces.size() - 1; i >= 0; i--) { - Namespace ns = namespaces.get(i); - if(GenUtils.hasStereotype(ns, CppRoot.class)) { - // TODO: not very clean. Is this stereotype still used? - packageContainer = project; - } else if(packageContainer instanceof IFolder) { - packageContainer = ((IFolder)packageContainer).getFolder(ns.getName()); - } else if(packageContainer instanceof IProject) { - packageContainer = ((IProject)packageContainer).getFolder(ns.getName()); - } - if(!packageContainer.exists()) { - // if packageContainer is a Project, it necessarily exists - ((IFolder)packageContainer).create(false, true, null); - } - } - return packageContainer; - } catch (CoreException e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.java index 78957b9bccd..301851b5be8 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.java @@ -13,20 +13,10 @@ package org.eclipse.papyrus.cpp.codegen.utils; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.UniqueEList; -import org.eclipse.papyrus.cpp.codegen.Constants; -import org.eclipse.papyrus.cpp.codegen.jet.util.CppClassIncludeDeclaration; -import org.eclipse.papyrus.cpp.codegen.jet.util.CppOwnerPackageIncludeDeclaration; -import org.eclipse.papyrus.cpp.codegen.jet.util.CppStaticAttributeImplementation; +import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.Property; -import Cpp.CppConst; -import Cpp.CppExternClass; -import Cpp.CppInclude; -import Cpp.CppNoCodeGen; +import C_Cpp.Include; /** * A set of utility functions related to classes. @@ -37,128 +27,30 @@ import Cpp.CppNoCodeGen; public class ClassUtils { /** - * Generate the "pre-body" statements that are stored in the CppInclude stereotype - * "pre" means: add before the ".cpp" file includes its own header file of a program - * - * @param currentClass - * @return generated text - */ - public static String getCppIncludePreBody(Classifier currentClass) { - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if(cppInclude != null) { - return GenUtils.addNL(cppInclude.getPreBody()); - } - return ""; - } - - /** - * Generate the body statements that are stored in the CppInclude stereotype - * Body means that these statements are added at the beginning of the "body" (the ".cpp") file. - * - * @param currentClass - * @return generated text - */ - public static String getCppIncludeBody(Classifier currentClass) { - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if(cppInclude != null) { - return GenUtils.addNL(cppInclude.getBody()); - } - return ""; - } - - /** - * Generated include statements related to dependencies. - * - * @param currentCl - * @return generated text - */ - public static String createIncludeDecl(Classifier currentCl) { - EList depClassifiers = GenUtils.getDependencies(currentCl); - return createIncludeDecl(depClassifiers, currentCl); - } - - public static String createIncludeDecl(EList usedClassifiers, Classifier currentCl) { - String includes = ""; - String forwardDecls = Constants.forwardDecl; - - // avoid duplicates - EList ownerPackages = new UniqueEList(); - - for(Classifier cl : usedClassifiers) { - - // Only add include if this is not for the current class - if(!currentCl.equals(cl)) { - // ... and if it does not have the stereotype "CppNoCodeGen", unless - // it has stereotype "CppExternalClass" - if((!GenUtils.hasStereotype(cl, CppNoCodeGen.class)) || GenUtils.hasStereotype(cl, CppExternClass.class)) { - String newInclude = ""; - - if((cl instanceof Enumeration) || (cl instanceof PrimitiveType)) { - // 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.getOwner() instanceof Package) { - Package owner = (Package)cl.getOwner(); - if(!ownerPackages.contains(owner)) { - ownerPackages.add(owner); - CppOwnerPackageIncludeDeclaration jetIDecl = new CppOwnerPackageIncludeDeclaration(); - newInclude = jetIDecl.generate(owner); - } - } - } else { - // include the file associated with the classifier - CppClassIncludeDeclaration jetIDecl = new CppClassIncludeDeclaration(); - newInclude = jetIDecl.generate(cl); - } - - includes = includes + newInclude; - - // generate a forward declaration - // this is useful, even if the ".h" file associated with the class is included: - // in case of cyclic dependencies, the include file may actually not be included since - // its #ifndef rule will exclude code. - // Don't generate forward for external classes, which may actually be non-classes - /* - * if ((cl instanceof Class) && !GenUtils.hasStereotype(cl, CppdxternClass)) { - * Class classWithoutBinding = (Class) cl; - * if (classWithoutBinding.getTemplateBindings().isEmpty()) { - * CppClassIncludeClassDeclaration jetCDecl - * = new CppClassIncludeClassDeclaration(); - * String newClass = jetCDecl.generate(classWithoutBinding); - * forwardDecls += newClass; - * } - * } - */ - } - } - } - includes += forwardDecls; - return includes; - } - - /** - * get the list of static attributes for the implementation + * Calculate the list of classifiers that needs to be included * * @param currentClass * @return */ - public static String getStaticAttributes(Classifier currentClass) { - String attrSDecl = ""; - - CppStaticAttributeImplementation jetSAttDecl = new CppStaticAttributeImplementation(); - - for(Property attribute : currentClass.getAttributes()) { - - // check that the attribute is not a static const, in that case it is declared and defined in the header file - - // Static and not constant (constant static attributes are declared within the class declaration) - if(attribute.isStatic() && !GenUtils.hasStereotype(attribute, CppConst.class)) { - attrSDecl = attrSDecl + jetSAttDecl.generate(attribute); - } + public static EList includedClassifiers(Classifier currentClass) { + // Retrieve package used by current package (dependencies) + // use a unique list to avoid duplicates + EList usedClasses = new UniqueEList(); + + // class attributes dependencies + usedClasses.addAll(GenUtils.getOwnedAttributeTypes(currentClass)); + // operation parameters dependencies + usedClasses.addAll(GenUtils.getIncludesFromOperations(currentClass)); + // realized interface dependencies + if(currentClass instanceof Class) { + usedClasses.addAll(GenUtils.getImplementedInterfaces((Class)currentClass)); } - if(attrSDecl.length() > 0) { - attrSDecl = Constants.staticAttributes + "\n" + attrSDecl; - } - return attrSDecl; + // dependencies and associations + usedClasses.addAll(GenUtils.getRelationshipsNoDeps(currentClass)); + + // template parameters are declared locally (if owned) and do not correspond to a file + // that can be included + usedClasses.removeAll(GenUtils.getTemplateParameteredElements(currentClass)); + return usedClasses; } } diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.mtl new file mode 100644 index 00000000000..19e55603802 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/ClassUtils.mtl @@ -0,0 +1,6 @@ +[comment encoding = UTF-8 /] +[module ClassUtils('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[query public includedClassifiers(cl : Classifier) : Sequence(Classifier) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.ClassUtils', 'includedClassifiers(org.eclipse.uml2.uml.Classifier)', Sequence{cl}) /] + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.java index 1c7977bd166..262f936116c 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.java @@ -18,7 +18,9 @@ import java.util.Iterator; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.cpp.codegen.Constants; import org.eclipse.uml2.uml.AggregationKind; import org.eclipse.uml2.uml.Behavior; import org.eclipse.uml2.uml.Class; @@ -50,10 +52,10 @@ import org.eclipse.uml2.uml.TemplateParameter; import org.eclipse.uml2.uml.TemplateSignature; import org.eclipse.uml2.uml.Type; -import Cpp.CppExternClass; -import Cpp.CppNoCodeGen; -import Cpp.CppType; -import Cpp.CppVisibility; +import C_Cpp.ExternClass; +import C_Cpp.NoCodeGen; +import C_Cpp.Typedef; +import C_Cpp.Visibility; @@ -86,14 +88,14 @@ public class GenUtils { return binding; } - public static boolean isTemplateBoundElement(Class uml2Class) { + public static boolean isTemplateBoundElement(Classifier cl) { boolean result = false; - EList tb = uml2Class.getTemplateBindings(); + EList tb = cl.getTemplateBindings(); if(tb != null) { Iterator itb = tb.iterator(); while(itb.hasNext()) { TemplateBinding currentTb = itb.next(); - result = currentTb.getBoundElement() == uml2Class; + result = currentTb.getBoundElement() == cl; } } return result; @@ -439,6 +441,9 @@ public class GenUtils { public static String openNS(NamedElement ne) { String openNS = ""; currentNS = ne.getNamespace(); + if(ne instanceof Package) { + openNS = "namespace " + ne.getName() + " {\n"; + } for(Namespace ns : ne.allNamespaces()) { if(ns.getOwner() != null) { openNS = "namespace " + ns.getName() + " {\n" + openNS; @@ -456,6 +461,9 @@ public class GenUtils { */ public static String closeNS(NamedElement ne) { String closeNS = ""; + if(ne instanceof Package) { + closeNS = "} // of namespace " + ne.getName() + "\n"; + } for(Namespace ns : ne.allNamespaces()) { if(ns.getOwner() != null) { closeNS += "} // of namespace " + ns.getName() + "\n"; @@ -464,13 +472,22 @@ public class GenUtils { return closeNS; } + /** + * Return the qualified name of a named element or "undefined", if it does not exist. + * + * @param ne + * @return + */ public static String qualifiedName(NamedElement ne) { + if(ne == null) { + return Constants.undefinedType; + } Object owner = ne.getOwner(); String owningPkgName = ""; if(owner instanceof Package) { owningPkgName = ((Package)owner).getName(); } - if((hasStereotype(ne, CppExternClass.class)) || (hasStereotype(ne, CppNoCodeGen.class))) { + if((hasStereotype(ne, ExternClass.class)) || (hasStereotype(ne, NoCodeGen.class))) { return ne.getName(); } else if(owningPkgName.equals("AnsiCLibrary")) { // always use the short name for types within the ANSI C library @@ -483,7 +500,7 @@ public class GenUtils { return qName; } if(ne instanceof PrimitiveType) { - if(!hasStereotype(ne, CppType.class) && (getStdtypes((PrimitiveType)ne).length() == 0)) { + if(!hasStereotype(ne, Typedef.class) && (getStdtypes((PrimitiveType)ne).length() == 0)) { // is a primitive type without further definition and not a standard primitive type // => assume that it is a external type without namespace return qName; @@ -507,7 +524,8 @@ public class GenUtils { public static String getComments(Element element) { String commentText = ""; for(Comment comment : element.getOwnedComments()) { - commentText += comment.getBody(); + // remove eventual CRs (avoid confusion in Acceleo template which adds " *" after line breaks) + commentText += comment.getBody().replace("\r", ""); } return commentText; } @@ -579,7 +597,7 @@ public class GenUtils { */ public static boolean hasStereotype(Element element, java.lang.Class clazz) { for(EObject stereoApplication : element.getStereotypeApplications()) { - // check whether the stereotype is a subclass of the passed parameter clazz + // check whether the stereotype is a suopebclass of the passed parameter clazz if(clazz.isAssignableFrom(stereoApplication.getClass())) { return true; } @@ -587,6 +605,29 @@ public class GenUtils { return false; } + + /** + * Is a certain stereotype applied? + * + * @param element + * @param stereotype + * fully qualified stereotype name + * @return + */ + public static boolean hasStereotypeA(Element element, EClass eClass) { + if(element == null) { + // make query more robust + return false; + } + for(EObject stereoApplication : element.getStereotypeApplications()) { + // check whether the stereotype application has the right eClass + if(stereoApplication.eClass() == eClass) { + return true; + } + } + return false; + } + /** * Return the stereotype application by passing an element of the static profile * @@ -607,6 +648,16 @@ public class GenUtils { return null; } + public static EObject getApplicationA(Element element, EClass eClass) { + for(EObject stereoApplication : element.getStereotypeApplications()) { + // check whether the stereotype is an instance of the passed parameter clazz + if(stereoApplication.eClass() == eClass) { + return stereoApplication; + } + } + return null; + } + /** * Is a certain stereotype applied? * @@ -684,48 +735,25 @@ public class GenUtils { for(String language : ob.getLanguages()) { String body = bodies.next(); if(language.equals(selectedLanguage)) { - return indent(body, "\t"); + // additional "\r" confuse Acceleo + return body.replace("\r", ""); } } } } return ""; } - + /** - * Format text output, indent each line with the passed string - * - * @param source - * @param indentStr - * @return - */ - public static String indent(String source, String indentStr) { - String result = ""; - String[] lines = source.split("\n"); - for(int i = 0; i < lines.length; i++) { - result += indentStr + lines[i]; - if(i < lines.length - 1) { - result += "\n"; - } - } - return result; - } - - /** - * return true, if shared aggregation (no composition). - * TODO: consider whether used as association? - * - * @param p + * Return the C++ visibility (on generalizations) in text form. Return public, if no stereotype + * visibility exists + * + * @param element * @return */ - public static boolean isAggregation(Property p) { - return /* (p.getAssociation() != null) && */ - (p.getAggregation() == AggregationKind.SHARED_LITERAL); - } - - public static String getVisibility(Element element) { + public static String getGeneralizationVisibility(Element element) { // get visibility and target name - CppVisibility cppVisibility = GenUtils.getApplication(element, CppVisibility.class); + Visibility cppVisibility = GenUtils.getApplication(element, Visibility.class); if(cppVisibility != null) { return cppVisibility.getValue(); } else { @@ -746,20 +774,5 @@ public class GenUtils { return str; } - /** - * Add a newline character, unless the string is empty and unless it already ends with a - * newline character - */ - public static String addNL(String str) { - if(str == null || str.length() == 0) { - return ""; - } - if(str.endsWith(NL)) { - return str; - } else { - return str + NL; - } - } - private static Namespace currentNS; } diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.mtl new file mode 100644 index 00000000000..c0bc93115e4 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/GenUtils.mtl @@ -0,0 +1,104 @@ +[comment encoding = UTF-8 /] +[module GenUtils('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[query public getName(arg0 : TemplateParameter) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getName(org.eclipse.uml2.uml.TemplateParameter)', Sequence{arg0}) /] + +[query public getType(arg0 : TemplateParameter) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getType(org.eclipse.uml2.uml.TemplateParameter)', Sequence{arg0}) /] + +[query public getFullName(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getFullName(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public maskNull(arg0 : String) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'maskNull(java.lang.String)', Sequence{arg0}) /] + +[query public getNamespace(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getNamespace(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public indent(arg0 : String, arg1 : String) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'indent(java.lang.String, java.lang.String)', Sequence{arg0, arg1}) /] + +[query public getApplication(arg0 : Element, arg1 : OclAny) : OclAny + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getApplicationA(org.eclipse.uml2.uml.Element, org.eclipse.emf.ecore.EClass)', Sequence{arg0, arg1}) /] + +[query public getFullPath(arg0 : Package) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getFullPath(org.eclipse.uml2.uml.Package)', Sequence{arg0}) /] + +[query public qualifiedName(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'qualifiedName(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public getGeneralizationVisibility(arg0 : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getGeneralizationVisibility(org.eclipse.uml2.uml.Element)', Sequence{arg0}) /] + +[query public getRelationships(arg0 : Classifier) : Sequence(Relationship) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getRelationships(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getTemplateBindings(arg0 : Class) : TemplateBinding + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getTemplateBindings(org.eclipse.uml2.uml.Class)', Sequence{arg0}) /] + +[query public getImplementedInterfaces(arg0 : Class) : Sequence(Interface) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getImplementedInterfaces(org.eclipse.uml2.uml.Class)', Sequence{arg0}) /] + +[query public getBody(arg0 : Operation, arg1 : String) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getBody(org.eclipse.uml2.uml.Operation, java.lang.String)', Sequence{arg0, arg1}) /] + +[query public getTaggedValue(arg0 : Element, arg1 : String, arg2 : String) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getTaggedValue(org.eclipse.uml2.uml.Element, java.lang.String, java.lang.String)', Sequence{arg0, arg1, arg2}) /] + +[query public setTaggedValue(arg0 : Element, arg1 : String, arg2 : String, arg3 : OclAny) : OclVoid + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'setTaggedValue(org.eclipse.uml2.uml.Element, java.lang.String, java.lang.String, java.lang.Object)', Sequence{arg0, arg1, arg2, arg3}) /] + +[query public getComments(arg0 : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getComments(org.eclipse.uml2.uml.Element)', Sequence{arg0}) /] + +[query public getDependencies(arg0 : Classifier) : Sequence(Dependency) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getDependencies(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public setStereotype(arg0 : Element, arg1 : String, arg2 : Boolean) : OclVoid + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'setStereotype(org.eclipse.uml2.uml.Element, java.lang.String, boolean)', Sequence{arg0, arg1, arg2}) /] + +[query public hasStereotype(arg0 : Element, arg1 : String) : Boolean + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'hasStereotype(org.eclipse.uml2.uml.Element, java.lang.String)', Sequence{arg0, arg1}) /] + +[query public hasStereotype(arg0 : Element, arg1 : OclAny) : Boolean + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'hasStereotypeA(org.eclipse.uml2.uml.Element, org.eclipse.emf.ecore.EClass)', Sequence{arg0, arg1}) /] + +[query public isTemplateBoundElement(arg0 : Classifier) : Boolean + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'isTemplateBoundElement(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getTemplateParameters(arg0 : Classifier) : Collection(TemplateParameter) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getTemplateParameters(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getTemplateParameteredElements(arg0 : Classifier) : Collection(OclAny) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getTemplateParameteredElements(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getTemplateParametersWoType(arg0 : Classifier) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getTemplateParametersWoType(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getStdtypes(arg0 : PrimitiveType) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getStdtypes(org.eclipse.uml2.uml.PrimitiveType)', Sequence{arg0}) /] + +[query public getOwnedAttributeTypes(arg0 : Classifier) : Sequence(Type) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getOwnedAttributeTypes(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getIncludesFromOperations(arg0 : Classifier) : Sequence(Classifier) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getIncludesFromOperations(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getRelationshipsNoDeps(arg0 : Classifier) : Sequence(Relationship) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getRelationshipsNoDeps(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] + +[query public getFullNameUC(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getFullNameUC(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public openNS(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'openNS(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public closeNS(arg0 : NamedElement) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'closeNS(org.eclipse.uml2.uml.NamedElement)', Sequence{arg0}) /] + +[query public getUsedPackages(arg0 : Package) : Sequence(Package) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getUsedPackages(org.eclipse.uml2.uml.Package)', Sequence{arg0}) /] + +[query public getUsedClassifiers(arg0 : Classifier) : Sequence(Classifier) + = invoke('org.eclipse.papyrus.cpp.codegen.utils.GenUtils', 'getUsedClassifiers(org.eclipse.uml2.uml.Classifier)', Sequence{arg0}) /] diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.java index 1f0c96d8bc0..c9579d7aead 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.java @@ -11,12 +11,19 @@ package org.eclipse.papyrus.cpp.codegen.utils; +import org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenUtils; +import org.eclipse.uml2.uml.AggregationKind; import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.MultiplicityElement; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.ParameterDirectionKind; +import org.eclipse.uml2.uml.Property; + +import C_Cpp.Array; +import C_Cpp.Const; +import C_Cpp.Ptr; +import C_Cpp.Ref; -import Cpp.CppArray; -import Cpp.CppConst; -import Cpp.CppPtr; -import Cpp.CppRef; /** * Utility functions managing the "modifier" of an element, i.e. additional information whether a passed @@ -27,48 +34,97 @@ import Cpp.CppRef; */ public class Modifier { - public String ptr; + public static String ptr; + + public static String ref; + + public static String array; - public String ref; + public static String isConst; + + public static String modPtr(Element propertyOrParameter) { + update(propertyOrParameter); + return ptr; + } - public String array; + public static String modRef(Element propertyOrParameter) { + update(propertyOrParameter); + return ref; + } - public String isConst; + public static String modArray(Element propertyOrParameter) { + update(propertyOrParameter); + return array; + } - public Modifier() { - ptr = ""; - ref = ""; - array = ""; - isConst = ""; + public static String modConst(Element propertyOrParameter) { + update(propertyOrParameter); + return isConst; } /** * Create instance and initialize the ptr/ref/array/isConst attributes. * - * @param currentParameter + * @param propertyOrParameter */ - public Modifier(Element currentParameter) { + public static void update(Element propertyOrParameter) { // Pointer - CppPtr cppPtr = GenUtils.getApplication(currentParameter, CppPtr.class); + Ptr cppPtr = GenUtils.getApplication(propertyOrParameter, Ptr.class); if(cppPtr != null) { ptr = (cppPtr.getDeclaration() != null) ? cppPtr.getDeclaration() : "*"; } else { ptr = ""; } - + if (propertyOrParameter instanceof Property) { + if (((Property) propertyOrParameter).getAggregation() == AggregationKind.SHARED_LITERAL) { + ptr += "*"; + } + } // Ref - ref = GenUtils.hasStereotype(currentParameter, CppRef.class) ? "&" : ""; + ref = GenUtils.hasStereotype(propertyOrParameter, Ref.class) ? "&" : ""; + boolean ptrOrRef = GenUtils.hasStereotype(propertyOrParameter, Ref.class) || + GenUtils.hasStereotype(propertyOrParameter, Ptr.class); // Array - CppArray cppArray = GenUtils.getApplication(currentParameter, CppArray.class); + Array cppArray = GenUtils.getApplication(propertyOrParameter, Array.class); if(cppArray != null) { + // explicit array definition array = (cppArray.getDefinition() != null) ? cppArray.getDefinition() : "[]"; } else { + // calculate array from multiplicity definition + int multiplicity = 1; + if(propertyOrParameter instanceof MultiplicityElement) { + multiplicity = ((MultiplicityElement)propertyOrParameter).getUpper(); + } array = ""; + if(multiplicity == -1) { + ptr += "*"; + } else if(multiplicity > 1) { + array = "[" + multiplicity + "]"; + } } + // out an inout parameter are realized by means of a pointer + if(propertyOrParameter instanceof Parameter) { + ParameterDirectionKind directionKind = ((Parameter)propertyOrParameter).getDirection(); + if(directionKind == ParameterDirectionKind.IN_LITERAL) { + ptr += " _IN_"; + } + else if(directionKind == ParameterDirectionKind.OUT_LITERAL) { + ptr += " _OUT_"; + if(!ptrOrRef) { + ptr += CppCodeGenUtils.getOutInoutOp(); + } + } + else if(directionKind == ParameterDirectionKind.INOUT_LITERAL) { + ptr += " _INOUT_"; + if(!ptrOrRef) { + ptr += CppCodeGenUtils.getOutInoutOp(); + } + } + } // Const - isConst = GenUtils.hasStereotype(currentParameter, CppConst.class) ? "const " : ""; + isConst = GenUtils.hasStereotype(propertyOrParameter, Const.class) ? "const " : ""; } } diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.mtl new file mode 100644 index 00000000000..fed35b5d2ff --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Modifier.mtl @@ -0,0 +1,15 @@ +[comment encoding = UTF-8 /] +[module Modifier('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[query public modPtr(propertyOrParameter : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.Modifier', 'modPtr(org.eclipse.uml2.uml.Element)', Sequence{propertyOrParameter}) /] + +[query public modRef(propertyOrParameter : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.Modifier', 'modRef(org.eclipse.uml2.uml.Element)', Sequence{propertyOrParameter}) /] + +[query public modArray(propertyOrParameter : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.Modifier', 'modArray(org.eclipse.uml2.uml.Element)', Sequence{propertyOrParameter}) /] + +[query public modConst(propertyOrParameter : Element) : String + = invoke('org.eclipse.papyrus.cpp.codegen.utils.Modifier', 'modConst(org.eclipse.uml2.uml.Element)', Sequence{propertyOrParameter}) /] + diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindBody.cpp.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindBody.cpp.jet deleted file mode 100644 index 04e92f6a6fd..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindBody.cpp.jet +++ /dev/null @@ -1,87 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.Constants org.eclipse.papyrus.cpp.codegen.utils.* Cpp.CppInclude org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.Package org.eclipse.uml2.uml.* org.eclipse.emf.common.util.EList org.eclipse.papyrus.cpp.codegen.jet.util.* java.util.* org.eclipse.papyrus.cpp.codegen.Activator" - class = "CppBindBody" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName (currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String parentClass = ""; - String namespace = GenUtils.getNamespace (currentClass); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Retrieve owner Package - Package owner = currentClass.getPackage(); - String fullPath = ""; - - if (owner != null) { - fullPath = GenUtils.getFullPath(owner) + "/"; - } // else fullPath == "" - - TemplateBinding tb = GenUtils.getTemplateBindings(currentClass);; - - // prepare parent class declaration - EList templates = tb.getTargets(); - Class templateClass = (Class) ((TemplateSignature) templates.get(0)).getOwner(); - parentClass = GenUtils.qualifiedName (templateClass); - - // Prepare bindings parameter declaration - - String tParamDecl = ""; - Iterator tps = tb.getParameterSubstitutions().iterator(); - while(tps.hasNext()) { - TemplateParameterSubstitution paramSub = tps.next(); - - CppTemplateBindingParameter jetTParam = new CppTemplateBindingParameter(); - tParamDecl = tParamDecl+jetTParam.generate (paramSub); - - if (tps.hasNext()) { - tParamDecl = tParamDecl + ", "; - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#define <%= classFULLNAME %>_BODY - -/************************************************************ - <%= className %> template binding body - ************************************************************/ - -<%= Constants.cppIncPreBodyStart %> -<%= ClassUtils.getCppIncludePreBody(currentClass) %> -<%= Constants.cppIncPreBodyEnd %> - -<%= Constants.includeHFile %> -#include <<%= fullPath %><%= className %>.<%= headerFileSuffix %>> - -<%= Constants.cppIncBodyStart %> -<%= ClassUtils.getCppIncludeBody(currentClass) %> -<%= Constants.cppIncBodyEnd %> - -<%= GenUtils.openNS(currentClass) %> - -<%= Constants.derivedIncludes %> -<%= ClassUtils.createIncludeDecl(currentClass) %> - -/************************************************************/ -template class <%= parentClass %> <<%= tParamDecl %>>; - -<%= GenUtils.closeNS(currentClass) %> - -/************************************************************ - End of <%= className %> template binding body - ************************************************************/ diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindHeader.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindHeader.h.jet deleted file mode 100644 index 906567e511f..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppBindHeader.h.jet +++ /dev/null @@ -1,115 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.CppInclude org.eclipse.uml2.uml.Class org.eclipse.emf.common.util.EList org.eclipse.uml2.uml.Package org.eclipse.uml2.uml.TemplateSignature org.eclipse.uml2.uml.TemplateParameterSubstitution org.eclipse.papyrus.cpp.codegen.jet.util.* java.util.* org.eclipse.papyrus.cpp.codegen.Activator" - class = "CppBindHeader" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName (currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String classparent = ""; - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - //find path for the package owning current class - String fullPath = ""; - String separ = ""; - - if (ownerPackage != null) { - fullPath = GenUtils.getFullPath (ownerPackage); - separ = "/"; - } // else fullPath == "" - - org.eclipse.uml2.uml.TemplateBinding tb = GenUtils.getTemplateBindings(currentClass); - - // prepare parent class declaration - EList templates = tb.getTargets(); - Class templateClass = (Class) ((TemplateSignature)templates.get(0)).getOwner(); - classparent = templateClass.getName(); - - // Prepare bindings parameter declaration - - String tParamDecl=""; - TemplateParameterSubstitution paramsub; - Iterator tps = tb.getParameterSubstitutions().iterator(); - while(tps.hasNext()) { - paramsub = (TemplateParameterSubstitution)tps.next(); - - CppTemplateBindingParameter jetTParam - = new CppTemplateBindingParameter(); - tParamDecl = tParamDecl+jetTParam.generate(paramsub); - - if (tps.hasNext()) { - tParamDecl = tParamDecl+", "; - } - } - - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes - = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */"+NL+classIncludes; - } - - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#ifndef <%= classFULLNAME %>_H -#define <%= classFULLNAME %>_H - -/************************************************************ - <%= className %> template binding header - ************************************************************/ - -<%= ownerInclude %> - -<%= classIncludes %> - -<%= headerDecl %> - -#include <<%= fullPath %><%= separ %><%= classparent %>.<%= headerFileSuffix %>> - -<%= openNS %> -/************************************************************/ -typedef <%= classparent %> <<%= tParamDecl %>> <%= className %>; - -<%= closeNS %> - -/************************************************************ - End of <%= className %> template binding header - ************************************************************/ - -#endif diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassBody.cpp.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassBody.cpp.jet deleted file mode 100644 index 13c3fe6ca9e..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassBody.cpp.jet +++ /dev/null @@ -1,71 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.Constants org.eclipse.papyrus.cpp.codegen.utils.* org.eclipse.emf.common.util.EList Cpp.CppInclude org.eclipse.uml2.uml.Classifier org.eclipse.uml2.uml.Package org.eclipse.papyrus.cpp.codegen.jet.util.* org.eclipse.papyrus.cpp.codegen.Activator" - class = "CppClassBody" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName= GenUtils.getFullName (currentClass); - String classFULLNAME= classFullName.toUpperCase(); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // TODO - Prepare static attribute - String staticAttributes = ""; - - // Retrieve owner Package - Package owner = currentClass.getPackage(); - String fullPath = ""; - - if (owner != null) { - fullPath = GenUtils.getFullPath(owner) + "/"; - } // else fullPath == "" - - // Prepare attributes and Methods declarations - String allOperations = ""; - - // Methods - CppClassOperationsImplementation jetClassOp - = new CppClassOperationsImplementation(); - allOperations = jetClassOp.generate(currentClass); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#define <%= classFULLNAME %>_BODY - -/************************************************************ - <%= className %> class body - ************************************************************/ - -<%= Constants.cppIncPreBodyStart %> -<%= ClassUtils.getCppIncludePreBody(currentClass) -%><%= Constants.cppIncPreBodyEnd %> - -<%= Constants.includeHFile %> -#include <<%= fullPath %><%= className %>.<%= headerFileSuffix %>> - -<%= Constants.cppIncBodyStart %> -<%= ClassUtils.getCppIncludeBody(currentClass) -%><%= Constants.cppIncBodyEnd %> - -<%= Constants.derivedIncludes %> -<%= ClassUtils.createIncludeDecl(currentClass) %> - -<%= GenUtils.openNS(currentClass) %> -<%= ClassUtils.getStaticAttributes(currentClass) %> -<%= allOperations %> -<%= GenUtils.closeNS(currentClass) %> - -/************************************************************ - End of <%= className %> class body - ************************************************************/ diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassHeader.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassHeader.h.jet deleted file mode 100644 index e151058efd7..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppClassHeader.h.jet +++ /dev/null @@ -1,192 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.CppInclude Cpp.Union org.eclipse.papyrus.cpp.codegen.StdStereo org.eclipse.uml2.uml.Package org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.util.* org.eclipse.papyrus.cpp.codegen.jet.doc.*" - class = "CppClassHeader" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFULLNAME = GenUtils.getFullName (currentClass).toUpperCase(); - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - String classDoc = ""; - String classOrStruct = GenUtils.hasStereotype(currentClass, Union.class) ? "union" : - ((currentClass instanceof DataType) ? "struct" : "class"); - - // Doc for the class - CppElementDoc jDoc = new CppElementDoc(); - classDoc = jDoc.generate(currentClass); - - String includeProtection; - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = GenUtils.maskNull(cppInclude.getHeader()); - if (headerDecl.length() > 0) { - headerDecl = "// Include from CppInclude declaration" + NL + headerDecl.replace("HFILENAME", classFULLNAME) + NL; - } - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - - // Prepare owned type and enum declaration - String typeEnumDefPackage = ""; - String typeEnumDef = ""; - - CppClassTypeAndEnum jetTE = new CppClassTypeAndEnum(); - typeEnumDef = jetTE.generate(currentClass); - - CppClassTypeAndEnumPackage jetTEp - = new CppClassTypeAndEnumPackage(); - typeEnumDefPackage = jetTEp.generate(currentClass); - - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes - = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */"+NL+classIncludes; - } - - // Prepare friend dependency includes - CppClassIncludeFriendDeclaration jetClassFIncludes - = new CppClassIncludeFriendDeclaration(); - String friendIncludes = jetClassFIncludes.generate(argument); - if (!friendIncludes.equals("")) { - friendIncludes = "/* Friend class declaration */"+NL+friendIncludes; - } - - // Prepare attributes and Methods declarations - String publicAttributes = ""; - String publicOperations = ""; - String protectedAttributes = ""; - String protectedOperations = ""; - String privateAttributes = ""; - String privateOperations = ""; - String packageAttributes = ""; - String packageOperations = ""; - - // Attributes - CppClassAttributesDeclaration jetClassPAttr = new CppClassAttributesDeclaration(); - publicAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - packageAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PACKAGE_LITERAL); - - // Methods - CppClassOperationsDeclaration jetClassPOp = new CppClassOperationsDeclaration(); - publicOperations = jetClassPOp.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedOperations = jetClassPOp.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateOperations = jetClassPOp.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - packageOperations = jetClassPOp.generate(currentClass, VisibilityKind.PACKAGE_LITERAL); - - boolean hasConstructor = false; - for (Operation operation : currentClass.getOperations ()) { - if (GenUtils.hasStereotype(operation, StdStereo.create)) { - hasConstructor = true; - break; - } - } - String defaultInitializer = ""; - for (Property attribute : currentClass.getAttributes ()) { - if (attribute.isStatic()) { - // static attributes are initialized differently - continue; - } - ValueSpecification vs = attribute.getDefaultValue (); - if ((vs != null) && (vs.stringValue() != null)) { - if (!defaultInitializer.equals("")) { - // not first attribute - defaultInitializer += ", "; - } - defaultInitializer += attribute.getName () + "(" + vs.stringValue() + ")"; - } - } - // no constructor, add it, if some properties have default values - if ((!hasConstructor) && (!defaultInitializer.equals (""))) { - defaultInitializer = className + "() : " + defaultInitializer + " {}"; - } - else { - defaultInitializer = ""; - } - - // Inline functions implementations - String inlineFunctionsImplementation = ""; - CppClassInlineOperationsImplementation jetInlineClassPOp - = new CppClassInlineOperationsImplementation(); - inlineFunctionsImplementation = jetInlineClassPOp.generate(currentClass); - - // Prepare inherited classes or implemented interfaces - String inheritedDeclarations = ""; - CppClassInheritedDeclarations jetInherited - = new CppClassInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentClass); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#ifndef <%= classFULLNAME %>_H -#define <%= classFULLNAME %>_H - -/************************************************************ - <%= className %> class header - ************************************************************/ - -<%= ownerInclude %> - -<%= classIncludes %> - -<%= headerDecl %> -<%= openNS %> -<%= typeEnumDefPackage %> -/************************************************************/ -<%= classDoc %> -<%= classOrStruct %> <%= className %><%= inheritedDeclarations %> { -<%= friendIncludes %><%= typeEnumDef %> - - public: -<%= defaultInitializer %><%= publicAttributes %><%= publicOperations %> - - protected: -<%= protectedAttributes %><%= protectedOperations %> - - private: -<%= privateAttributes %><%= privateOperations %> - -}; -/************************************************************/ -/* External declarations (package visibility) */ -<%= packageAttributes %> -<%= packageOperations %> -/************************************************************/ -/* Inline functions */ -<%= inlineFunctionsImplementation %> -<%= closeNS %> - -/************************************************************ - End of <%= className %> class header - ************************************************************/ - -#endif diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppInterfaceHeader.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppInterfaceHeader.h.jet deleted file mode 100644 index 29a627bfbdc..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppInterfaceHeader.h.jet +++ /dev/null @@ -1,99 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.uml2.uml.Interface org.eclipse.uml2.uml.Package Cpp.CppInclude org.eclipse.papyrus.cpp.codegen.utils.GenUtils org.eclipse.papyrus.cpp.codegen.jet.util.* org.eclipse.papyrus.cpp.codegen.jet.doc.*" - class = "CppInterfaceHeader" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Interface currentInterface = (Interface) argument; - - // Get the package name - String interfaceName = currentInterface.getName(); - String interfaceFULLNAME = GenUtils.getFullNameUC (currentInterface); - - // For interface documentation - String iDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - iDoc = jDoc.generate(currentInterface); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentInterface, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentInterface.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - - // Prepare dependency includes - CppInterfaceAllIncludesDeclaration jetInterfaceIncludes - = new CppInterfaceAllIncludesDeclaration(); - String interfaceIncludes = jetInterfaceIncludes.generate(argument); - if (!interfaceIncludes.equals("")) { - interfaceIncludes = "/* Structural includes (inheritance, dependencies, ... */"+NL+interfaceIncludes; - } - - // Prepare Methods declarations - String publicOperations = ""; - - // Methods - CppInterfacePublicOperationsDeclaration jetPublicInterfacePOp - = new CppInterfacePublicOperationsDeclaration(); - publicOperations = jetPublicInterfacePOp.generate(currentInterface); - - - // Prepare inherited interfaces - String inheritedDeclarations = ""; - CppInterfaceInheritedDeclarations jetInherited - = new CppInterfaceInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentInterface); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#ifndef <%= interfaceFULLNAME %>_H -#define <%= interfaceFULLNAME %>_H - -/************************************************************ - <%= interfaceName %> interface header - ************************************************************/ - -<%= ownerInclude %> - -<%= interfaceIncludes %> - -<%= headerDecl %> -<%= GenUtils.openNS(currentInterface) %> -/************************************************************/ -<%= iDoc %> -class <%= interfaceName %> <%= inheritedDeclarations %>{ - -/* Public declarations */ -public: -<%= publicOperations %> - -}; - -/************************************************************ - End of <%= interfaceName %> interface header - ************************************************************/ -<%= GenUtils.closeNS(currentInterface) %> - -#endif diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppPackageHeader.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppPackageHeader.h.jet deleted file mode 100644 index e0a61e00335..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppPackageHeader.h.jet +++ /dev/null @@ -1,138 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.CppInclude Cpp.CppNoCodeGen org.eclipse.uml2.uml.* org.eclipse.uml2.uml.Package org.eclipse.emf.common.util.EList org.eclipse.papyrus.cpp.codegen.jet.util.* org.eclipse.papyrus.cpp.codegen.jet.doc.* java.util.Iterator java.util.Set java.util.HashSet org.eclipse.papyrus.cpp.codegen.Activator" - class = "CppPackageHeader" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the package - Package currentPackage = (Package) argument; - Package fatherPackage = currentPackage.getNestingPackage(); // return owner package - - // Get the package name - String packageName = currentPackage.getName(); - String packageFULLNAME = GenUtils.getFullName (currentPackage).toUpperCase(); - String openNS = GenUtils.openNS (currentPackage) + "namespace " + currentPackage.getName () + " {\n"; - String closeNS = "} // of namespace" + currentPackage.getName () + "\n" + GenUtils.closeNS (currentPackage); - - // Prepare the header declarations for this package - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentPackage, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - - // Prepare Father include declaration - String fatherPkgInclude = ""; - if (fatherPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetPkgInclude - = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - fatherPkgInclude = jetPkgInclude.generate(fatherPackage); - } - - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - - String cFullName = ""; // used in java to contruct and in template to read list - - // Get packages linked by dependencies - EList usedPackages = GenUtils.getUsedPackages (currentPackage); - Set usedPackagesNames = new HashSet(); - // Add imported packages - usedPackages.addAll(currentPackage.getImportedPackages()); - - Iterator usedPackagesIt = usedPackages.iterator(); - Iterator usedPackagesNamesIt; - - // Refactor as a new Set containing names to be declared for packages (with path) - while(usedPackagesIt.hasNext()) { - Package currentUsedPackage = usedPackagesIt.next(); - String cPackageName = currentUsedPackage.getName(); - String cPackagePath = GenUtils.getFullPath (currentUsedPackage); - - cFullName = cPackagePath+"/Pkg_"+cPackageName; - - // Add this name to the set if codegen stereotype is not applied - PackageImport packImport = currentPackage.getPackageImport(currentUsedPackage); - if(!GenUtils.hasStereotype(packImport, CppNoCodeGen.class)) { - if (!GenUtils.hasStereotype(currentUsedPackage, CppNoCodeGen.class)) { - usedPackagesNames.add(cFullName); - } - } - } - - // and prepare the Iterator for the template... - usedPackagesNamesIt = usedPackagesNames.iterator(); - - - - // Prepare owned type and enum declaration - String typeDef = ""; - String enumDef = ""; - - Iterator typeIt = currentPackage.getOwnedTypes().iterator(); - while (typeIt.hasNext()) { - Type currentElt = typeIt.next(); - if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) { - if (currentElt instanceof org.eclipse.uml2.uml.PrimitiveType) { - - PrimitiveType currentType = (PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - typeDef = typeDef+jetPrimitiveType.generate(currentType); - - } else if (currentElt instanceof org.eclipse.uml2.uml.Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - enumDef = enumDef+jetEnum.generate(currentEnum); - - } - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#ifndef PKG_<%= packageFULLNAME %> -#define PKG_<%= packageFULLNAME %> - -/************************************************************ - Pkg_<%= packageName %> package header - ************************************************************/ - -<%= fatherPkgInclude %> - -/* Package dependency header include */ -<% // For every depency linked package - while(usedPackagesNamesIt.hasNext()) { - cFullName = (String) usedPackagesNamesIt.next(); %> -#include <<%= cFullName %>.<%= headerFileSuffix %>> -<% } %> - -/* CppInclude header declarations insert */ -<%= headerDecl %> - -<%= openNS %> -/* Types Defined in the package */ -<%= typeDef %> -<%= enumDef %> -<%= closeNS %> - -/************************************************************ - End of Pkg_<%= packageName %> package header - ************************************************************/ - -#endif diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppTemplateHeader.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppTemplateHeader.h.jet deleted file mode 100644 index 4b72e7c51c0..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/CppTemplateHeader.h.jet +++ /dev/null @@ -1,202 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet" - skeleton = "generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.jet.doc.* org.eclipse.uml2.uml.Package org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.util.* Cpp.CppInclude Cpp.CppNoCodeGen Cpp.CppInline org.eclipse.papyrus.cpp.codegen.utils.GenUtils java.util.*" - class = "CppTemplateHeader" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - String className = currentClass.getName(); - String classFullName = GenUtils.getFullName(currentClass); - String classFULLNAME = classFullName.toUpperCase(); - String openNS = GenUtils.openNS (currentClass); - String closeNS = GenUtils.closeNS (currentClass); - - // Include declaration "CppInclude" - String headerDecl = ""; - CppInclude cppInclude = GenUtils.getApplication(currentClass, CppInclude.class); - if (cppInclude != null) { - headerDecl = "// Include from CppInclude declaration" + NL + cppInclude.getHeader() + NL; - } - - // Prepare owner package header include - Package ownerPackage = currentClass.getPackage(); - String ownerInclude = ""; - if (ownerPackage != null) { - // Create an util template to prepare the declaration - CppOwnerPackageIncludeDeclaration jetOwnerInclude = new CppOwnerPackageIncludeDeclaration(); - // Execute the util template - ownerInclude = jetOwnerInclude.generate(ownerPackage); - } - - // Prepare owned type and enum declaration - String typeEnumDefPackage = ""; - String typeEnumDef = ""; - - CppClassTypeAndEnum jetTE = new CppClassTypeAndEnum(); - typeEnumDef = jetTE.generate(currentClass); - - CppClassTypeAndEnumPackage jetTEp = new CppClassTypeAndEnumPackage(); - typeEnumDefPackage = jetTEp.generate(currentClass); - - // Prepare template parameter declaration - Iterator tparam = - GenUtils.getTemplateParameters(currentClass).iterator(); - - String tParamDecl = ""; - String tDecl = ""; - - while (tparam.hasNext()) { - CppTemplateParameter jetTParam = new CppTemplateParameter(); - tParamDecl = tParamDecl + jetTParam.generate(tparam.next()); - - if (tparam.hasNext()) { - tParamDecl = tParamDecl + ", "; - } - } - - tDecl = "template <" + tParamDecl + ">" + NL; - - // Prepare dependency includes - CppClassAllIncludesDeclaration jetClassIncludes = new CppClassAllIncludesDeclaration(); - String classIncludes = jetClassIncludes.generate(argument); - if (!classIncludes.equals("")) { - classIncludes = "/* Structural includes (inheritance, dependencies... */" - + NL + classIncludes; - } - - // Prepare attributes and Methods declarations - String publicAttributes = ""; - String protectedAttributes = ""; - String privateAttributes = ""; - String publicOperations = "", publicOperationsImpl = ""; - String protectedOperations = "", protectedOperationsImpl = ""; - String privateOperations = "", privateOperationsImpl = ""; - - // Attributes - CppClassAttributesDeclaration jetClassPAttr = new CppClassAttributesDeclaration(); - publicAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PUBLIC_LITERAL); - protectedAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PROTECTED_LITERAL); - privateAttributes = jetClassPAttr.generate(currentClass, VisibilityKind.PRIVATE_LITERAL); - - // Methods implementation - String inlineFuncImpl = ""; - // String inlineFuncDecl = ""; - - // Implementation - CppOperationTemplateImplementation jetOpImpl = new CppOperationTemplateImplementation(); - // Declaration - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOperation = operations.next(); - - if (GenUtils.hasStereotype(currentOperation, CppNoCodeGen.class) || - currentOperation.isAbstract()) { - continue; - } - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - String opDoc = ""; - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = jDoc.generate(currentOperation); - // Inline declaration - if (currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicOperations = publicOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateOperations = privateOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedOperations = protectedOperations - + jetOpDecl.generate(currentOperation) + ";"; - } // else nothing - // Inline implementation - inlineFuncImpl = inlineFuncImpl + opDoc + NL + tDecl - + jetOpImpl.generate(currentOperation) + NL; - } else { - if (currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicOperationsImpl = publicOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - publicOperations = publicOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateOperationsImpl = privateOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - privateOperations = privateOperations - + jetOpDecl.generate(currentOperation) + ";"; - } else if (currentOperation.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedOperationsImpl = protectedOperationsImpl + tDecl - + jetOpImpl.generate(currentOperation); - protectedOperations = protectedOperations - + jetOpDecl.generate(currentOperation) + ";"; - } // else nothing - } - } - - // Prepare inherited classes or implemented interfaces - String inheritedDeclarations = ""; - CppClassInheritedDeclarations jetInherited = new CppClassInheritedDeclarations(); - inheritedDeclarations = jetInherited.generate(currentClass); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#ifndef <%= classFULLNAME %>_H -#define <%= classFULLNAME %>_H - -/************************************************************ - <%= className %> template class header - ************************************************************/ - -<%= ownerInclude %> - -<%= classIncludes %> - -<%= headerDecl %> -<%= openNS %> -<%= typeEnumDefPackage %> -/************************************************************/ -template <<%= tParamDecl %>> class <%= className %> <%= inheritedDeclarations %>{ -<%= typeEnumDef %> -/* Public declarations */ -public: -<%= publicAttributes %> -<%= publicOperations %> - -/* Protected declarations */ -protected: -<%= protectedAttributes %> -<%= protectedOperations %> - -/* Private declarations */ -private: -<%= privateAttributes %> -<%= privateOperations %> - -}; - -/************************************************************/ -/* Template functions */ -<%= publicOperationsImpl %> -<%= protectedOperationsImpl %> -<%= privateOperationsImpl %> -/* Inline functions */ -<%= inlineFuncImpl %> - -<%= closeNS %> - -/************************************************************ - End of <%= className %> template class header - ************************************************************/ - -#endif diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppElementDoc.doc.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppElementDoc.doc.jet deleted file mode 100644 index 2a0e5b591c7..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppElementDoc.doc.jet +++ /dev/null @@ -1,27 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.doc" - skeleton = "../generator.skeleton" - imports = "org.eclipse.uml2.uml.Element org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppElementDoc" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Element currentElt = (Element) argument; - String eltDoc = ""; - - - // Doc for the element - eltDoc = GenUtils.getComments(currentElt); - eltDoc = eltDoc.replaceAll(NL, NL+" * "); - - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -/** - * <%= eltDoc %> - */ \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppOperationDoc.doc.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppOperationDoc.doc.jet deleted file mode 100644 index de8ebf7cc19..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppOperationDoc.doc.jet +++ /dev/null @@ -1,47 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.doc" - skeleton = "../generator.skeleton" - imports = "org.eclipse.uml2.uml.Operation org.eclipse.uml2.uml.Parameter org.eclipse.papyrus.cpp.codegen.utils.GenUtils java.util.Iterator" - class = "CppOperationDoc" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String opDoc = ""; - String opParams = ""; -// String opReturn = ""; -// TODO: return not handled? (or treated as any other parameter?) - - // Doc for the element - opDoc = GenUtils.getComments(currentOperation); - opDoc = opDoc.replaceAll(NL, NL+" * "); - - // Treat params - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = (Parameter) parameters.next(); - - // Prepare parameters - CppParamDoc jetParam = new CppParamDoc(); - opParams = opParams+jetParam.generate(currentParameter); - - if (parameters.hasNext()){ - opParams = opParams+NL+" * "; - } - } - - // Treat return - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -/** - * <%= opDoc %> - * <%= opParams %> - */ \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppParamDoc.doc.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppParamDoc.doc.jet deleted file mode 100644 index 4e8e2ee3fda..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/doc/CppParamDoc.doc.jet +++ /dev/null @@ -1,23 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.doc" - skeleton = "../generator.skeleton" - imports = "org.eclipse.uml2.uml.Parameter org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppParamDoc" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the element - Parameter currentElt = (Parameter) argument; - - String paramName = currentElt.getName(); - String paramDoc = GenUtils.getComments(currentElt); - - paramDoc = paramDoc.replaceAll(NL, NL+" * "); - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -@param <%= paramName %> <%= paramDoc %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generator.skeleton b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generator.skeleton deleted file mode 100644 index aa011c805d5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generator.skeleton +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * 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 PACKAGE; - -public class CLASS -{ - public String generate(Object argument) - { - return ""; - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generatorTwoArgs.skeleton b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generatorTwoArgs.skeleton deleted file mode 100644 index 1e268756e0c..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/generatorTwoArgs.skeleton +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * 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 PACKAGE; - -public class CLASS -{ - public String generate(Object argument1, Object argument2) - { - return ""; - } -} \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAllIncludesDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAllIncludesDeclaration.util.jet deleted file mode 100644 index b872a010e91..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAllIncludesDeclaration.util.jet +++ /dev/null @@ -1,47 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "Cpp.* org.eclipse.papyrus.cpp.codegen.utils.* org.eclipse.uml2.uml.Class org.eclipse.emf.common.util.EList org.eclipse.uml2.uml.Package org.eclipse.emf.common.util.UniqueEList java.util.* org.eclipse.uml2.uml.PrimitiveType org.eclipse.uml2.uml.Enumeration org.eclipse.uml2.uml.Classifier" - class = "CppClassAllIncludesDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Get the package name - // String className = currentClass.getName(); - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - // use a unique list to avoid duplicates - EList usedClasses = new UniqueEList (); - - String newInclude = ""; - - // class attributes dependencies - usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentClass)); - // operation parameters dependencies - usedClasses.addAll (GenUtils.getIncludesFromOperations(currentClass)); - // realized interface dependencies - if (currentClass instanceof Class) { - usedClasses.addAll (GenUtils.getImplementedInterfaces((Class) currentClass)); - } - // dependencies and associations - usedClasses.addAll (GenUtils.getRelationshipsNoDeps(currentClass)); - - // template parameters are declared locally (if owned) and do not correspond to a file - // that can be included - usedClasses.removeAll (GenUtils.getTemplateParameteredElements(currentClass)); - - Iterator usedClassesIt = usedClasses.iterator(); - // Parsing all as NamedElement - String includes = ClassUtils.createIncludeDecl (usedClasses, currentClass); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= includes %> - diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAttributesDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAttributesDeclaration.util.jet deleted file mode 100644 index a1c1ebc1f4a..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassAttributesDeclaration.util.jet +++ /dev/null @@ -1,28 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generatorTwoArgs.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.Iterator" - class = "CppClassAttributesDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument1; - String attrDecl = ""; - - // Retrieve public attributes - Iterator attributes = currentClass.getAttributes().iterator(); - while (attributes.hasNext()) { - Property attribute = attributes.next(); - if (attribute.getVisibility() == argument2) { - CppAttributeDeclaration jetAttDecl = new CppAttributeDeclaration(); - attrDecl = attrDecl+jetAttDecl.generate(attribute); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= attrDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassFriendDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassFriendDeclaration.util.jet deleted file mode 100644 index ddfb72badfc..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassFriendDeclaration.util.jet +++ /dev/null @@ -1,18 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.NamedElement" - class = "CppClassFriendDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassName = currentNE.getName(); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -friend class <%= cClassName %>; diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeClassDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeClassDeclaration.util.jet deleted file mode 100644 index 41949a00117..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeClassDeclaration.util.jet +++ /dev/null @@ -1,28 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.NamedElement org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassIncludeClassDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassName = currentNE.getName(); - String isTemplate = ""; - String openNS = GenUtils.openNS (currentNE); - String closeNS = GenUtils.closeNS (currentNE); - - if (GenUtils.hasStereotype(currentNE, CppTemplate.class)) { - isTemplate = "template "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> - -<%= openNS %> -<%= isTemplate %>class <%= cClassName %>; -<%= closeNS %> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeDeclaration.util.jet deleted file mode 100644 index e00089131b3..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeDeclaration.util.jet +++ /dev/null @@ -1,49 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.NamedElement org.eclipse.uml2.uml.Package org.eclipse.papyrus.cpp.codegen.Activator org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassIncludeDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - - // Retrieve the class - NamedElement currentNE = (NamedElement) argument; - String cClassPath = ""; - Package nearestPkg = currentNE.getNearestPackage(); - String cClassName = currentNE.getName(); - - if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model) - /*&& */!(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) { - cClassPath = GenUtils.getFullPath(nearestPkg)+"/"; - } - - - // If an external class is referred - CppExternClass extClass = GenUtils.getApplication(currentNE, CppExternClass.class); - CppTemplate template = GenUtils.getApplication(currentNE, CppTemplate.class); - if (extClass != null) { - cClassPath = ""; - cClassName = extClass.getName(); - if ((cClassName == null) || cClassName.equals ("")) { - // default value - cClassName = currentNE.getQualifiedName ().replace ("::", "/") + "." + headerFileSuffix; - // strip model name - cClassName = cClassName.substring (currentNE.getModel ().getName ().length () + 1); - } - } else if (template != null) { - cClassPath = ""; - cClassName = template.getDeclaration(); - } - else cClassName=cClassName+"."+headerFileSuffix; - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#include <<%= cClassPath %><%= cClassName %>> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeFriendDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeFriendDeclaration.util.jet deleted file mode 100644 index ab1941de515..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassIncludeFriendDeclaration.util.jet +++ /dev/null @@ -1,38 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassIncludeFriendDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; -// NamedElement currentElt = (NamedElement) argument; - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - Iterator friendClassesIt = GenUtils.getUsedClassifiers(currentClass).iterator(); - - // Parsing all as NamedElement - String friendClass = ""; - - while (friendClassesIt.hasNext()) { - Classifier cClass = friendClassesIt.next(); - - if (GenUtils.hasStereotype(cClass, CppFriend.class) && - (!GenUtils.hasStereotype(cClass, CppNoCodeGen.class))) { - - CppClassFriendDeclaration jetIDecl - = new CppClassFriendDeclaration(); - - friendClass = friendClass+jetIDecl.generate(cClass); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= friendClass %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInheritedDeclarations.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInheritedDeclarations.util.jet deleted file mode 100644 index 4ed12621cb3..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInheritedDeclarations.util.jet +++ /dev/null @@ -1,96 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassInheritedDeclarations" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String targetName = ""; - String visibility = ""; - String decl = ""; - - // Get generalization and implementation relationships - Iterator relationshipIt = - currentClass.getSourceDirectedRelationships().iterator(); - // Iterator impIt = currentClass.getImplementations().iterator(); - - while (relationshipIt.hasNext()) { - - DirectedRelationship relationship = relationshipIt.next(); - - if ((relationship instanceof Generalization) || - (relationship instanceof InterfaceRealization)) - { - org.eclipse.uml2.uml.Classifier target = null; - if (relationship.getTargets ().size() > 0) { - // there should always be at least one element in the target - // list and it should be a classifier, but better check. - org.eclipse.uml2.uml.Element element = - relationship.getTargets().get(0); - if (element instanceof org.eclipse.uml2.uml.Classifier) { - target = (org.eclipse.uml2.uml.Classifier) element; - } - } - if (target != null) { - // If not - if (!GenUtils.hasStereotype(target, CppNoCodeGen.class)) - { - CppVisibility cppVisibility = GenUtils.getApplication(relationship, CppVisibility.class); - if (cppVisibility != null) { - visibility = cppVisibility.getValue(); - } else { - visibility = "public"; - } - - targetName = GenUtils.qualifiedName (target); - if (!decl.equals("")) { - decl = decl + ", "; - } - decl = decl+visibility+" "+targetName; - } - } - } - } - - // Parse implementations - // RS: removed code: Implementation does not exist in UML2 v2. - // TODO: replace Implementation with new UML2 constructions? -// Implementation currentImp; -// -// while (impIt.hasNext()) { -// -// currentImp = (Implementation) impIt.next(); -// currentNE = (NamedElement) currentImp; -// -// // get visibility and target name -// visibility = currentNE.getVisibilityAsString(); -// -// // If not -// if (!GenUtils.hasStereotype(currentImp.getTarget(), CppNoCodeGen.class)) { -// -// targetName = currentImp.getTarget().getName(); -// -// if (!decl.equals("")) { -// decl = decl + ", "; -// } -// decl = decl+visibility+" "+targetName; -// -// } -// } - - - // ":" if decl non empty - String prefix = ""; - if (!decl.equals("")) { - prefix = " : "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= prefix %><%= decl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInlineOperationsImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInlineOperationsImplementation.util.jet deleted file mode 100644 index 1c8f5382870..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassInlineOperationsImplementation.util.jet +++ /dev/null @@ -1,30 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.Iterator org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassInlineOperationsImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOp = operations.next(); - if (GenUtils.hasStereotype (currentOp, CppInline.class) && - !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class)) { - - CppOperationImplementation jetOpImpl = new CppOperationImplementation(); - opDecl = opDecl+jetOpImpl.generate(currentOp); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= opDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsDeclaration.util.jet deleted file mode 100644 index a05242cb999..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsDeclaration.util.jet +++ /dev/null @@ -1,35 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generatorTwoArgs.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.Iterator org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassOperationsDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument1; - String opDecl = ""; - - // Retrieve attributes - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation operation = operations.next(); - if (!GenUtils.hasStereotype (operation, CppNoCodeGen.class)) { - if (operation.getVisibility() == argument2) { - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - String cOpDecl = jetOpDecl.generate(operation); - - // if main cOpDecl = ""; - if (!cOpDecl.equals("")) { - opDecl = opDecl+NL+cOpDecl+";"; - } - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= opDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsImplementation.util.jet deleted file mode 100644 index 0ca8426587b..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassOperationsImplementation.util.jet +++ /dev/null @@ -1,30 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.Iterator org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppClassOperationsImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentClass.getOperations().iterator(); - while (operations.hasNext()) { - Operation currentOp = operations.next(); - if (!GenUtils.hasStereotype (currentOp, CppInline.class) && - !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class) && - !currentOp.isAbstract()) { - CppOperationImplementation jetOpImpl = new CppOperationImplementation(); - opDecl = opDecl+jetOpImpl.generate(currentOp); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= opDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnum.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnum.util.jet deleted file mode 100644 index 8901678c6d4..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnum.util.jet +++ /dev/null @@ -1,93 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.utils.GenUtils org.eclipse.uml2.uml.*" - class = "CppClassTypeAndEnum" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - // Prepare owned type and enum declaration - String publicTypeDef = ""; - String privateTypeDef = ""; - String protectedTypeDef = ""; - String publicEnumDef = ""; - String privateEnumDef = ""; - String protectedEnumDef = ""; - String publicKeyword = "public:"; - String protectedKeyword = "protected:"; - String privateKeyword = "private:"; - - for (Element currentElt : currentClass.getOwnedElements()) { - if (!GenUtils.hasStereotype(currentElt, Cpp.CppNoCodeGen.class)) { - if (currentElt instanceof PrimitiveType) { - - org.eclipse.uml2.uml.PrimitiveType currentType = (org.eclipse.uml2.uml.PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - if (currentType.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicTypeDef = publicTypeDef+jetPrimitiveType.generate(currentType); - } else if (currentType.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedTypeDef = protectedTypeDef+jetPrimitiveType.generate(currentType); - } else if (currentType.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateTypeDef = privateTypeDef+jetPrimitiveType.generate(currentType); - } - } - else if (currentElt instanceof Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - if (currentEnum.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - publicEnumDef = publicEnumDef+jetEnum.generate(currentEnum); - } else if (currentEnum.getVisibility() == VisibilityKind.PROTECTED_LITERAL) { - protectedEnumDef = protectedEnumDef+jetEnum.generate(currentEnum); - } else if (currentEnum.getVisibility() == VisibilityKind.PRIVATE_LITERAL) { - privateEnumDef = privateEnumDef+jetEnum.generate(currentEnum); - } - } - } - } - - // If not "" add a comment before declarations - if (publicTypeDef.equals("") && publicEnumDef.equals("")) { - publicKeyword = ""; - } else { - if (!publicTypeDef.equals("")) { - publicTypeDef = "/* Public type definitions */"+NL+publicTypeDef+NL; - } - if (!publicEnumDef.equals("")) { - publicEnumDef = "/* Public enumeration definitions */"+NL+publicEnumDef+NL; - } - } - - if (protectedTypeDef.equals("") && protectedEnumDef.equals("")) { - protectedKeyword = ""; - } else { - if (!protectedTypeDef.equals("")) { - protectedTypeDef = "/* Protected type definitions */"+NL+protectedTypeDef+NL; - } - if (!protectedEnumDef.equals("")) { - protectedEnumDef = "/* Protected enumeration definitions */"+NL+protectedEnumDef+NL; - } - } - - if (privateTypeDef.equals("") && privateEnumDef.equals("")) { - privateKeyword = ""; - } else { - if (!privateTypeDef.equals("")) { - privateTypeDef = "/* Private type definitions */"+NL+privateTypeDef+NL; - } - if (!privateEnumDef.equals("")) { - privateEnumDef = "/* Private enumeration definitions */"+NL+privateEnumDef+NL; - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= publicKeyword %><%= publicTypeDef %><%= publicEnumDef %><%= protectedKeyword %><%= protectedTypeDef %><%= protectedEnumDef %><%= privateKeyword %><%= privateTypeDef %><%= privateEnumDef %> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnumPackage.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnumPackage.util.jet deleted file mode 100644 index 52feb87b245..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/class/CppClassTypeAndEnumPackage.util.jet +++ /dev/null @@ -1,59 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils java.util.Iterator Cpp.*" - class = "CppClassTypeAndEnumPackage" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - - - // Prepare owned type and enum declaration - String packageTypeDef = ""; - String packageEnumDef = ""; - - Iterator typeIt = currentClass.getOwnedElements().iterator(); - while (typeIt.hasNext()) { - Element currentElt = typeIt.next(); - if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) { - if (currentElt instanceof PrimitiveType) { - - PrimitiveType currentType = (PrimitiveType) currentElt; - CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition(); - // Execute the util template - if (currentType.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - packageTypeDef = packageTypeDef+jetPrimitiveType.generate(currentType); - } - - - } else if (currentElt instanceof Enumeration) { - - Enumeration currentEnum = (Enumeration) currentElt; - CppEnumerationDefinition jetEnum = new CppEnumerationDefinition(); - // Execute the util template - if (currentEnum.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - packageEnumDef = packageEnumDef+jetEnum.generate(currentEnum); - } - - } - } - } - - // If not "" add a comment before declarations - if (!packageEnumDef.equals("")) { - packageEnumDef = "/* Package enumeration definitions */"+NL+packageEnumDef; - } - if (!packageTypeDef.equals("")) { - packageTypeDef = "/* Package type definitions */"+NL+packageTypeDef; - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= packageTypeDef %> -<%= packageEnumDef %> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/enum/CppEnumerationDefinition.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/enum/CppEnumerationDefinition.util.jet deleted file mode 100644 index 469b0a3d723..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/enum/CppEnumerationDefinition.util.jet +++ /dev/null @@ -1,72 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Enumeration org.eclipse.uml2.uml.EnumerationLiteral org.eclipse.papyrus.cpp.codegen.jet.doc.* java.util.Iterator org.eclipse.papyrus.cpp.codegen.utils.GenUtils Cpp.*" - class = "CppEnumerationDefinition" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // This is an util template to prepare Enumeration definition - ///////////////////////////////////////////////////////////// - - - // Retrieve the enumeration - Enumeration currentEnumeration = (Enumeration) argument; - - // Get the package name - String enumName = currentEnumeration.getName(); - - // Doc - String enumDoc = ""; - String enumLitDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - enumDoc = jDoc.generate(currentEnumeration); - - // Retrieve literals - String enumLiterals = ""; - - Iterator literalsIt = currentEnumeration.getOwnedLiterals().iterator(); - - while (literalsIt.hasNext()) { - - // retrieve current - EnumerationLiteral currentLiteral = literalsIt.next(); - - enumLiterals = enumLiterals+currentLiteral.getName(); - - // if current literal is initialised - CppInit cppInit = GenUtils.getApplication(currentLiteral, CppInit.class); - if (cppInit != null) { - // Add the initialisation value - int initValue = cppInit.getValue(); - enumLiterals = enumLiterals + " = " + initValue; - } - - // Retrieve doc - if (!GenUtils.getComments(currentLiteral).equals("")) { - enumLitDoc = " //< "+GenUtils.getComments(currentLiteral); - } else { - enumLitDoc = ""; - } - - // if more literal left prepare new line for next literal - if (literalsIt.hasNext()) { - enumLiterals = enumLiterals+" ,"+enumLitDoc+NL+"\t"; - } else { - enumLiterals = enumLiterals+enumLitDoc; - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= enumDoc %> -enum <%= enumName %> { - <%= enumLiterals %> -}; - diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceAllIncludesDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceAllIncludesDeclaration.util.jet deleted file mode 100644 index fdffc73bde7..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceAllIncludesDeclaration.util.jet +++ /dev/null @@ -1,72 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils org.eclipse.uml2.uml.Interface org.eclipse.emf.common.util.EList org.eclipse.uml2.uml.Package org.eclipse.emf.common.util.UniqueEList java.util.* org.eclipse.uml2.uml.PrimitiveType org.eclipse.uml2.uml.Enumeration org.eclipse.uml2.uml.Classifier" - class = "CppInterfaceAllIncludesDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the interface - Interface currentInterface = (Interface) argument; - - // Prepare Dependency includes declarations ... - // Retrieve package used by current package (dependencies) - // use a unique list to avoid duplicates - EList usedClasses = new UniqueEList (); - - String newInclude = ""; - - // class attributes dependencies - usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentInterface)); - // operation parameters dependencies - usedClasses.addAll (GenUtils.getIncludesFromOperations(currentInterface)); - // dependencies and associations - usedClasses.addAll (GenUtils.getRelationships(currentInterface)); - - Iterator usedClassesIt = usedClasses.iterator(); - // Parsing all as NamedElement - String includes = ""; - - while (usedClassesIt.hasNext()) - { - Classifier cl = usedClassesIt.next (); - - // Only add include if this is not for the current class - if (!currentInterface.equals(cl)) { - // ... and if it does not have the stereotype "CppNoCodeGen", unless - // it has stereotype "CppExternalClass" - if ( (!GenUtils.hasStereotype(cl, CppNoCodeGen.class)) || - GenUtils.hasStereotype(cl, CppExternClass.class)) { - - if ((cl instanceof Enumeration) || (cl instanceof PrimitiveType)) - { - // 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 interface) - CppOwnerPackageIncludeDeclaration jetIDecl - = new CppOwnerPackageIncludeDeclaration(); - if (cl.getOwner() instanceof Package) { - newInclude = jetIDecl.generate (cl.getOwner ()); - } - else { - newInclude = ""; - } - } - else { - // include the file associated with the classifier - CppClassIncludeDeclaration jetIDecl - = new CppClassIncludeDeclaration(); - newInclude = jetIDecl.generate (cl); - } - - includes = includes+newInclude; - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= includes %> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceIncludeDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceIncludeDeclaration.util.jet deleted file mode 100644 index 3984fdbb0f3..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceIncludeDeclaration.util.jet +++ /dev/null @@ -1,29 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.NamedElement org.eclipse.uml2.uml.Package org.eclipse.papyrus.cpp.codegen.Activator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppInterfaceIncludeDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Retrieve the interface - NamedElement currentNE = (NamedElement) argument; - String iInterfacePath = ""; - Package nearestPkg = currentNE.getNearestPackage(); - String iInterfaceName = currentNE.getName(); - - if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model) - /*&&*/ !(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) { - iInterfacePath = GenUtils.getFullPath (nearestPkg) + "/"; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -#include <<%= iInterfacePath %><%= iInterfaceName %>.<%= headerFileSuffix %>> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceInheritedDeclarations.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceInheritedDeclarations.util.jet deleted file mode 100644 index b2528ccac0f..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfaceInheritedDeclarations.util.jet +++ /dev/null @@ -1,49 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Classifier org.eclipse.uml2.uml.Generalization java.util.Iterator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppInterfaceInheritedDeclarations" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the interface - Classifier currentClass = (Classifier) argument; - String decl = ""; - String visibility = ""; - - // Get generalization and implementation relationships - Iterator genIt = currentClass.getGeneralizations().iterator(); - - // Parse generalizations - while (genIt.hasNext()) { - - Generalization currentGen = genIt.next(); - - visibility = GenUtils.getVisibility(currentGen); - - // If not - Classifier tmpClassifier = currentGen.getGeneral(); - if (!GenUtils.hasStereotype(tmpClassifier, CppNoCodeGen.class)) { - - String targetName = tmpClassifier.getName(); - - if (!decl.equals("")) { - decl = decl + ", "; - } - decl = decl+visibility+" "+targetName; - } - } - - // ":" only if decl not empty - String prefix = ""; - if (!decl.equals("")) { - prefix = ": "; - visibility = "public "; - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= prefix %><%= decl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfacePublicOperationsDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfacePublicOperationsDeclaration.util.jet deleted file mode 100644 index 0867efce3b5..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/interface/CppInterfacePublicOperationsDeclaration.util.jet +++ /dev/null @@ -1,34 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Interface org.eclipse.uml2.uml.Operation org.eclipse.uml2.uml.VisibilityKind java.util.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppInterfacePublicOperationsDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Interface currentInterface = (Interface) argument; - String opDecl = ""; - - // Retrieve operations - Iterator operations = currentInterface.getOwnedOperations().iterator(); - while (operations.hasNext()) { - Operation currentOperation = operations.next(); - if ((currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) && - !GenUtils.hasStereotype (currentOperation, CppNoCodeGen.class)) { - CppOperationDeclaration jetOpDecl = new CppOperationDeclaration(); - String cOpDecl = jetOpDecl.generate(currentOperation); - - // if main cOpDecl = ""; - if (!cOpDecl.equals("")) { - opDecl = opDecl+"\t"+cOpDecl+";"; - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= opDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationDeclaration.util.jet deleted file mode 100644 index 0498b6ddd1c..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationDeclaration.util.jet +++ /dev/null @@ -1,96 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.StdStereo org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppOperationDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String operationName = currentOperation.getName(); - - String opParameters = ""; - - String returnTypeName = "void"; - String pVirtualSuffix = ""; - String prefix = ""; - String constOp = ""; - - - String opDoc = ""; - - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = GenUtils.indent (jDoc.generate(currentOperation), "\t"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - if (!returnTypeName.equals ("")) { - returnTypeName += " "; - } - - boolean isInterface = currentOperation.getOwner () instanceof Interface; - - // Static attribute - if (currentOperation.isStatic()) { - prefix = prefix+"static"+" "; - } - - // Inline attribute - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - prefix = prefix+"inline"+" "; - } - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // Const attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - constOp = " const"; - } - - // Virtual attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppVirtual.class)) { - prefix = "virtual "+prefix; - } - - // Pure Virtual attribute on operation - if (isInterface || currentOperation.isAbstract ()) { - prefix = "virtual "+prefix; - pVirtualSuffix = " = 0"; - } - - // Friend attribute on operation - if (GenUtils.hasStereotype(currentOperation, CppFriend.class)) { - prefix = "friend "+prefix; - } - - // Prepare parameters - CppOperationParameters jetParams = new CppOperationParameters(); - opParameters = jetParams.generate(currentOperation); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template only if current operation is not main -// else nothing is return... -////////////////////////////////////////////////////////////////////////////////////////// - -if (!operationName.equals("main")) { - -//////////////////////////////////////////////////////////////////////////////////////////%> - -<%= opDoc %> - <%= prefix %><%= returnTypeName %><%= operationName %>(<%= opParameters %>)<%= constOp %><%= pVirtualSuffix %> -<%////////////////////////////////////////////////////////////////////////////////////////// -} // else nothing done -//////////////////////////////////////////////////////////////////////////////////////////%> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationImplementation.util.jet deleted file mode 100644 index b7761341a77..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationImplementation.util.jet +++ /dev/null @@ -1,99 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.StdStereo org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppOperationImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String body = ""; - String className = ""; - String operationName = currentOperation.getName(); - String opParameters = ""; - String returnTypeName = "void"; - String isInline = ""; - String isConst = ""; - String constInit = ""; - - String opDoc = ""; - - // Doc for the template - CppOperationDoc jDoc = new CppOperationDoc(); - opDoc = jDoc.generate(currentOperation); - - // Retrieve class name. Operation may belong to a class or datatype, thus use - // generic getOwner function - Element opOwner = currentOperation.getOwner(); - className = (opOwner instanceof NamedElement) ? ((NamedElement) opOwner).getName() : ""; - - // Retrieve body content - body = GenUtils.getBody (currentOperation, "C/C++"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // If is inline operation - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - isInline = "inline "; - } - - // Const op - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - isConst = " const"; - } - - // Constructor init list - CppConstInit cppConstInit = GenUtils.getApplication(currentOperation, CppConstInit.class); - if ((cppConstInit != null) - && StdStereo.isApplied(currentOperation, StdStereo.create)) { - constInit = " : " + cppConstInit.getInitialisation(); - } - - // Prepare parameters - CppOperationParametersWithoutDefaultValue jetParams = new CppOperationParametersWithoutDefaultValue(); - opParameters = jetParams.generate(currentOperation); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template two cases main operation or classical -////////////////////////////////////////////////////////////////////////////////////////// - -// main - if (operationName.equals("main")) { - -//////////////////////////////////////////////////////////////////////////////////////////%> - -<%= opDoc %> -<%= returnTypeName %> <%= operationName %> (<%= opParameters %>) { -<%= body %> -} - -<%////////////////////////////////////////////////////////////////////////////////////////// - - } - else { - -//////////////////////////////////////////////////////////////////////////////////////////%> - -<%= opDoc %> -<%= isInline %><%= returnTypeName %> <%= className %>::<%= operationName %>(<%= opParameters %>)<%= isConst %><%= constInit %> { -<%= body %> -} - -<%////////////////////////////////////////////////////////////////////////////////////////// - } -//////////////////////////////////////////////////////////////////////////////////////////%> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParameters.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParameters.util.jet deleted file mode 100644 index 00858e02574..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParameters.util.jet +++ /dev/null @@ -1,35 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.*" - class = "CppOperationParameters" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String paramDecl = ""; - - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = parameters.next(); - if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) { - // Prepare parameters - CppParameter jetParam = new CppParameter(); - if (!paramDecl.equals("")) { - paramDecl += ", "; - } - paramDecl = paramDecl+jetParam.generate(currentParameter); - } - } - - paramDecl.replaceAll(NL, ""); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%><%= paramDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParametersWithoutDefaultValue.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParametersWithoutDefaultValue.util.jet deleted file mode 100644 index 9cc336e09c7..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationParametersWithoutDefaultValue.util.jet +++ /dev/null @@ -1,33 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.*" - class = "CppOperationParametersWithoutDefaultValue" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - Parameter currentParameter; - - String paramDecl = ""; - - Iterator parameters = currentOperation.getOwnedParameters().iterator(); - while(parameters.hasNext()) { - currentParameter = parameters.next(); - if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) { - // Prepare parameters - CppParameterWithoutDefaultValue jetParam = new CppParameterWithoutDefaultValue(); - if (!paramDecl.equals("")) { - paramDecl += ", "; - } - paramDecl = paramDecl+jetParam.generate(currentParameter); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%><%= paramDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationReturnType.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationReturnType.util.jet deleted file mode 100644 index 5c776417ef8..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationReturnType.util.jet +++ /dev/null @@ -1,76 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* org.eclipse.uml2.uml.Class Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*" - class = "CppOperationReturnType" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String returnTypeName = "void"; - String ownerName = ""; - Modifier modifier = new Modifier(); - - // Return type - if (currentOperation.getType() == null) { - returnTypeName = "void"; - } else { - if (currentOperation.getType() == null) { - returnTypeName = "undefined"; - } else { - // Treat the type if it is not "package visibility" and owned by a class - Type currentType = currentOperation.getType(); - returnTypeName = GenUtils.qualifiedName (currentType); - - if (currentType.getVisibility() != VisibilityKind.PACKAGE_LITERAL) { - if (currentType.getOwner() instanceof Class) { - ownerName = ((Class) currentType.getOwner()).getName(); - } - } - } - - // Treat pointer or ref on return parameter (only one return parameter should exists) - // retrieve return parameter -// RS: changed test: now getReturnResult returns only one param -// if (currentOperation.getUml2Operation().getReturnResults().size() == 1) { -// org.eclipse.uml2.uml.Parameter uml2Param -// = (org.eclipse.uml2.uml.Parameter) currentOperation.getUml2Operation().getReturnResults().get(0); -// Parameter currentRParameter -// = new Parameter(uml2Param); -// // case Pointer -// if (currentRParameter.hasStereotype(xy, CppPtr.class)) { -// isPointer = " "+currentRParameter.getTaggedValue(CppPtr.class, "declaration"); -// } -// if (currentRParameter.hasStereotype(xy, CppRef.class)) { -// isRef = " "+currentRParameter.getTaggedValue(CppRef.class, "declaration"); -// } -// if (currentRParameter.hasStereotype(xy, CppConst.class_)) { -// isConst = "const "; -// } -// } - if (currentOperation.getReturnResult() instanceof Parameter) { - Parameter uml2Param = (Parameter) currentOperation.getReturnResult(); - modifier = new Modifier(uml2Param); - } - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template two cases : scope required or not -////////////////////////////////////////////////////////////////////////////////////////// - -// No scope details - if (ownerName.equals("")) { -////////////////////////////////////////////////////////////////////////////////////////// -%><%= modifier.isConst %><%= returnTypeName %><%= modifier.ptr %><%= modifier.ref %> -<%////////////////////////////////////////////////////////////////////////////////////////// -} else { -////////////////////////////////////////////////////////////////////////////////////////// -%><%= modifier.isConst %><%= ownerName %>::<%= returnTypeName %><%= modifier.ptr %><%= modifier.ref %> -<%////////////////////////////////////////////////////////////////////////////////////////// -} -//////////////////////////////////////////////////////////////////////////////////////////%> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationTemplateImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationTemplateImplementation.util.jet deleted file mode 100644 index a7dde0e50da..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/operation/CppOperationTemplateImplementation.util.jet +++ /dev/null @@ -1,90 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* org.eclipse.uml2.uml.Class Cpp.* org.eclipse.papyrus.cpp.codegen.StdStereo org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppOperationTemplateImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Operation - Operation currentOperation = (Operation) argument; - - String operationName = currentOperation.getName(); - String opParameters = ""; - String returnTypeName = "void"; - String isConst = ""; - String isInline = ""; - - // Retrieve class & class name - Class currentClass = currentOperation.getClass_ (); - String className = currentClass.getName(); - - // Retrieve body content - String body = GenUtils.getBody (currentOperation, "C/C++"); - - // Prepare return type - CppOperationReturnType jetRT = new CppOperationReturnType(); - returnTypeName = jetRT.generate(currentOperation); - if (! "".equals(returnTypeName)) { - returnTypeName = returnTypeName + " "; - } - - // Creator / Destructor: use function within StdStereo - if (StdStereo.isApplied(currentOperation, StdStereo.create)) { - returnTypeName = ""; - } - if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) { - returnTypeName = ""; - operationName = "~"+operationName; - } - - // If inline operation - if (GenUtils.hasStereotype(currentOperation, CppInline.class)) { - isInline = "inline "; - } - - // Const op - if (GenUtils.hasStereotype(currentOperation, CppConst.class)) { - isConst = " const"; - } - - // Prepare parameters - CppOperationParametersWithoutDefaultValue jetParams - = new CppOperationParametersWithoutDefaultValue(); - opParameters = jetParams.generate(currentOperation); - - - // Prepare template parameter declaration without type - String tparamWoType = ""; - - if (currentClass != null) { - tparamWoType = GenUtils.getTemplateParametersWoType(currentClass); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -// Package visibility - if (currentOperation.getVisibility() == VisibilityKind.PACKAGE_LITERAL) { - -////////////////////////////////////////////////////////////////////////////////////////// - -%><%= isInline %><%= returnTypeName %><%= operationName %>(<%= opParameters %>)<%= isConst %> { -<%= body %> -}<% - -////////////////////////////////////////////////////////////////////////////////////////// - - } else { // Default case - -////////////////////////////////////////////////////////////////////////////////////////// - -%><%= isInline %><%= returnTypeName %><%= className %><<%= tparamWoType %>>::<%= operationName %>(<%= opParameters %>)<%= isConst %> { -<%= body %> -}<% - -////////////////////////////////////////////////////////////////////////////////////////// - } -//////////////////////////////////////////////////////////////////////////////////////////%> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/package/CppOwnerPackageIncludeDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/package/CppOwnerPackageIncludeDeclaration.util.jet deleted file mode 100644 index bd5a5d8dfb0..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/package/CppOwnerPackageIncludeDeclaration.util.jet +++ /dev/null @@ -1,40 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Package org.eclipse.papyrus.cpp.codegen.Activator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppOwnerPackageIncludeDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the type passed as argument - Package currentPkg = (Package) argument; - String currentPkgName = currentPkg.getName(); - String currentPkgPath = GenUtils.getFullPath (currentPkg); - - // Retrieve header file suffix - String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix"); - - // Prepare Father include declaration - boolean isRoot = false; - - // The currentElt has the CppRoot stereotype - if (GenUtils.hasStereotype(currentPkg, CppRoot.class)) { - isRoot = true; - } - // The currentPkg is the model root package - //if (currentPkg instanceof org.eclipse.uml2.uml.Model){ - // isRoot = true; - //} - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<% // if currentPkg is not root it is referenced here - if (!isRoot) { %> -/* Owner package header include */ -#include <<%= currentPkgPath %>/Pkg_<%= currentPkgName %>.<%= headerFileSuffix %>> -<% // endif - } %> diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameter.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameter.util.jet deleted file mode 100644 index 78d0d60c020..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameter.util.jet +++ /dev/null @@ -1,36 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Parameter Cpp.* org.eclipse.papyrus.cpp.codegen.utils.Modifier org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppParameter" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Parameter - Parameter currentParameter = (Parameter) argument; - - String parameterName = currentParameter.getName(); - - String typeName = ""; - String suffix = ""; - Modifier modifier = new Modifier(currentParameter); - - if (currentParameter.getType() == null) { - typeName = "undefined"; - } else { - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - - // Initial value - CppDefault cppDefault = GenUtils.getApplication(currentParameter, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%><%= modifier.isConst %><%= typeName %><%= modifier.ptr %><%= modifier.ref %> <%= parameterName %><%= modifier.array %><%= suffix %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameterWithoutDefaultValue.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameterWithoutDefaultValue.util.jet deleted file mode 100644 index 95862d64632..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/parameter/CppParameterWithoutDefaultValue.util.jet +++ /dev/null @@ -1,56 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Parameter org.eclipse.uml2.uml.Classifier Cpp.* org.eclipse.papyrus.cpp.codegen.utils.Modifier org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppParameterWithoutDefaultValue" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the Parameter - Parameter currentParameter = (Parameter) argument; - - String parameterName = currentParameter.getName(); - - String typeName = ""; - Modifier modifier = new Modifier(currentParameter); - - // Prepare template parameter declaration without type - String tparamWoType = ""; - - if (currentParameter.getType() == null) { - typeName = "undefined"; - } - else if (currentParameter.getType() instanceof Classifier) { - Classifier classifier = (Classifier) currentParameter.getType(); - tparamWoType = GenUtils.getTemplateParametersWoType(classifier); - - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - else { - typeName = GenUtils.qualifiedName (currentParameter.getType()); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -// Package visibility - if (!"".equals(tparamWoType)) { - -////////////////////////////////////////////////////////////////////////////////////////// - -%><%= modifier.isConst %><%= typeName %><<%= tparamWoType %>><%= modifier.ptr %><%= modifier.ref %> <%= parameterName %><%= modifier.array %><% - -////////////////////////////////////////////////////////////////////////////////////////// - - } else { // Default case - -////////////////////////////////////////////////////////////////////////////////////////// - -%><%= modifier.isConst %><%= typeName %><%= modifier.ptr %><%= modifier.ref %> <%= parameterName %><%= modifier.array %><% - - -////////////////////////////////////////////////////////////////////////////////////////// - } -//////////////////////////////////////////////////////////////////////////////////////////%> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet deleted file mode 100644 index 58c5fc97a71..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeDeclaration.util.jet +++ /dev/null @@ -1,78 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Property org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*" - class = "CppAttributeDeclaration" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); - String typeName = ""; - String prefix = ""; - String suffix = ""; - String multiple = ""; - - // For property documentation - String propDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - propDoc = jDoc.generate(currentAttribute); - propDoc = propDoc.replaceAll(NL, NL+" "); - - if (currentAttribute.getType() == null) { - typeName = "undefined"; - } else { - typeName = GenUtils.qualifiedName (currentAttribute.getType()); - } - - // Static attribute - if (currentAttribute.isStatic()) { - prefix = "static"+" "; - } - - Modifier modifier = new Modifier(currentAttribute); - - // Treat multiplicity for association attributes - int multiplicity = currentAttribute.getUpper(); - if (multiplicity == 1) { - multiple = ""; - } else if (multiplicity == -1) { - multiple = "*"; - } else { - multiple = ""; - modifier.array = "[" + multiplicity + "]"; - } - - // If attribute is aggregation - if (GenUtils.isAggregation(currentAttribute)) { - // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab - attributeName = "*"+attributeName; // this produce a tab of pointers - } - - - if (GenUtils.hasStereotype(currentAttribute, CppConst.class) && currentAttribute.isStatic()) { - // const & static attributes may be initialized within class declaration - // check if initial value UML or profile - if (currentAttribute.getDefaultValue() != null) { - suffix = " = " + currentAttribute.getDefaultValue().stringValue(); - } - else { - CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> - - <%= propDoc %> - <%= prefix %><%= modifier.isConst %><%= typeName %><%= multiple %><%= modifier.ptr %><%= modifier.ref %> <%= attributeName %><%= modifier.array %><%= suffix %>; \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet deleted file mode 100644 index 2980c4fee83..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppAttributeImplementation.util.jet +++ /dev/null @@ -1,58 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.jet.doc.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*" - class = "CppAttributeImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); -// String className = currentAttribute.getOwner().getName(); - String typeName = ""; - String scopeName = ""; -// String prefix = ""; - String suffix = ""; - String multiple = ""; - - // For property documentation - String propDoc = ""; - - // Retrieve enum doc - CppElementDoc jDoc = new CppElementDoc(); - propDoc = jDoc.generate(currentAttribute); - propDoc = propDoc.replaceAll(NL, NL+" "); - - if (currentAttribute.getType() == null) { - typeName = "undefined"; - } - else { - Type type = currentAttribute.getType(); - typeName = GenUtils.qualifiedName (type); - /* - // If type is owned by a class add the scope - if (type.getOwner() instanceof Class) { - scopeName = ((Class) type.getOwner()).getName(); - typeName = scopeName+"::"+typeName; - } - */ - } - - // Multiple - // TODO? need to evaluate limitMultiplicity stereotype? - int upper = currentAttribute.getUpper(); - if ((upper == -1) || (upper > 1)) { - multiple = "*"; - } - - Modifier modifier = new Modifier(currentAttribute); - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> - <%= propDoc %> - <%= typeName %><%= multiple %><%= modifier.ptr %><%= modifier.ref %> <%= attributeName %><%= modifier.array %><%= suffix %>; diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet deleted file mode 100644 index 634b097bbb1..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppClassAttributesImplementation.util.jet +++ /dev/null @@ -1,37 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* java.util.Iterator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppClassAttributesImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Classifier currentClass = (Classifier) argument; - String attrDecl = ""; - String attrSDecl = ""; - - CppAttributeImplementation jetAttDecl = new CppAttributeImplementation(); - CppStaticAttributeImplementation jetSAttDecl = new CppStaticAttributeImplementation(); - - Iterator attributesIt = currentClass.getAttributes().iterator(); - while (attributesIt.hasNext()) { - Property attribute = (Property) attributesIt.next(); - - // just check that this property is not a static const - // in that case it declared and defined in the header file - - // Static - if (attribute.isStatic()) { - attrSDecl = attrSDecl+jetSAttDecl.generate(attribute); - } else { - attrDecl = attrDecl+jetAttDecl.generate(attribute); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= attrSDecl %><%= attrDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet deleted file mode 100644 index aafed1f9c64..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/property/CppStaticAttributeImplementation.util.jet +++ /dev/null @@ -1,56 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.* Cpp.* org.eclipse.papyrus.cpp.codegen.utils.*" - class = "CppStaticAttributeImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the property - Property currentAttribute = (Property) argument; - - String attributeName = currentAttribute.getName(); - String className = GenUtils.qualifiedName (currentAttribute.getClass_()); - String typeName = ""; - String suffix = ""; - String multiple = ""; - String isAgg = ""; // attribute is an aggregation or association - - - if (currentAttribute.getType() == null) { - typeName = "undefined"+" "; - } else { - typeName = GenUtils.qualifiedName (currentAttribute.getType()) + " "; - } - - // Multiple - // if (currentAttribute.isMultiple()) { - // multiple = "*"; - // } - - // If attribute is aggregation then generate a pointer - if (GenUtils.isAggregation(currentAttribute)) { - // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab - isAgg = "*"; // this produce a tab of pointers - } - - Modifier modifier = new Modifier(currentAttribute); - - // Initial value - if (currentAttribute.getDefaultValue() != null) { - // via UML - suffix = " = " + currentAttribute.getDefaultValue().stringValue(); - } - else { - CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class); - if (cppDefault != null) { - suffix = " = " + cppDefault.getValue(); - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -//////////////////////////////////////////////////////////////////////////////////////////%> -<%= typeName %><%= multiple %><%= modifier.ptr %><%= isAgg %><%= modifier.ref %><%= className %>::<%= attributeName %><%= modifier.array %><%= suffix %>; diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateBindingParameter.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateBindingParameter.util.jet deleted file mode 100644 index ed41e210f5c..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateBindingParameter.util.jet +++ /dev/null @@ -1,35 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.*" - class = "CppTemplateBindingParameter" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve the TemplateParameter - // Retrieve the TemplateParameter - TemplateParameterSubstitution currentTParam = (TemplateParameterSubstitution) argument; - - String typeName = ""; - - if (currentTParam.getActual() == null) { - typeName ="param undefined"; - } - else { - ParameterableElement actual = currentTParam.getActual(); - - if (actual instanceof LiteralInteger) { - typeName = "" + ((LiteralInteger) currentTParam.getActual()).getValue(); - } - else { - typeName = ((NamedElement) currentTParam.getActual()).getName(); - } // value = currentTParam.getFormal().getParameteredElement().getName(); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%><%= typeName %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateDeclaration.h.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateDeclaration.h.jet deleted file mode 100644 index c76b40afb08..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateDeclaration.h.jet +++ /dev/null @@ -1,33 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.TemplateParameter java.util.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppTemplateDeclaration" - %> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - // Retrieve the class - Class currentClass = (Class) argument; - - - // Prepare template parameter declaration - Iterator tparam = GenUtils.getTemplateParameters(currentClass).iterator(); - String tParamDecl = ""; - - while(tparam.hasNext()) { - TemplateParameter currentTParam = tparam.next(); - - CppTemplateParameter jetTParam = new CppTemplateParameter(); - tParamDecl = tParamDecl+jetTParam.generate(currentTParam); - - if (tparam.hasNext()) { - tParamDecl = tParamDecl+", "; - } - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%>template <<%= tParamDecl %>> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateInlineOperationsImplementation.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateInlineOperationsImplementation.util.jet deleted file mode 100644 index 146deefca76..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateInlineOperationsImplementation.util.jet +++ /dev/null @@ -1,42 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "org.eclipse.papyrus.cpp.codegen.jet.doc.* org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.Operation java.util.Iterator Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils" - class = "CppTemplateInlineOperationsImplementation" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// 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 " - tDecl = jetTDecl.generate(currentClass) + " "; - - // Retrieve operations - Iterator 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 -////////////////////////////////////////////////////////////////////////////////////////// -%><%= opDecl %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateParameter.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateParameter.util.jet deleted file mode 100644 index 925439208bb..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/template/CppTemplateParameter.util.jet +++ /dev/null @@ -1,34 +0,0 @@ -<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util" - skeleton = "../../generator.skeleton" - imports = "Cpp.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils org.eclipse.uml2.uml.TemplateParameter" - class = "CppTemplateParameter" -%> -<% -////////////////////////////////////////////////////////////////////////////////////////// -// Java preparation -////////////////////////////////////////////////////////////////////////////////////////// - - - // Retrieve the TemplateParameter - TemplateParameter currentTParam = (TemplateParameter) argument; - - String parameterName = ""; - String typeName = ""; - - - if (GenUtils.getType(currentTParam) == "") { - typeName = "undefined"; - } else { - typeName = GenUtils.getType(currentTParam); //.getName(); - } - - // Retrieve name under stereotype CppTemplateParameter/name - Cpp.CppTemplateParameter ctp = GenUtils.getApplication(currentTParam, Cpp.CppTemplateParameter.class); - if (ctp != null) { - parameterName = ctp.getName(); - } - -////////////////////////////////////////////////////////////////////////////////////////// -// The following part contains the template -////////////////////////////////////////////////////////////////////////////////////////// -%><%= typeName %> <%= parameterName %> \ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet deleted file mode 100644 index ce6419b204f..00000000000 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/templates/util/type/CppPrimitiveTypeDefinition.util.jet +++ /dev/null @@ -1,53 +0,0 @@ -<%@ 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 %> -- cgit v1.2.3