diff options
author | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-19 17:40:21 +0100 |
---|---|---|
committer | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-19 17:40:21 +0100 |
commit | d8b05323eaee40a2ee0bf8556099f890a013d7ee (patch) | |
tree | 9237f3cc225f3c72b482cc4f1a670e2b9a4048b6 | |
parent | 2b46067ed661f8bf3f5c188bb0c9ee9c953d61b6 (diff) | |
download | genivi-common-api-runtime-d8b05323eaee40a2ee0bf8556099f890a013d7ee.tar.gz |
Enums now individually configurable for deployment
4 files changed, 42 insertions, 32 deletions
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/DeploymentInterfacePropertyAccessorWrapper.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/DeploymentInterfacePropertyAccessorWrapper.java index cc68ee1..65531b0 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/DeploymentInterfacePropertyAccessorWrapper.java +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/DeploymentInterfacePropertyAccessorWrapper.java @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.genivi.commonapi.core.deployment; +import org.franca.core.franca.FEnumerationType; import org.franca.core.franca.FInterface; import org.franca.deploymodel.core.FDeployedInterface; import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor; @@ -19,9 +20,16 @@ public class DeploymentInterfacePropertyAccessorWrapper extends DeploymentInterf encapsulate = (target == null); } - public DeploymentInterfacePropertyAccessor.EnumBackingType getEnumBackingType(FInterface obj) { + public DefaultEnumBackingType getDefaultEnumBackingType(FInterface obj) { if(encapsulate) { - return DeploymentInterfacePropertyAccessor.EnumBackingType.Int32; + return DefaultEnumBackingType.Int32; + } + return super.getDefaultEnumBackingType(obj); + } + + public EnumBackingType getEnumBackingType (FEnumerationType obj) { + if(encapsulate) { + return EnumBackingType.UseDefault; } return super.getEnumBackingType(obj); } diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/deployment.fdepl b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/deployment.fdepl index 7167f2f..a587bee 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/deployment.fdepl +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/deployment.fdepl @@ -1,8 +1,9 @@ - - -specification org.genivi.commonapi.core.deployment.deployment -{ +specification org.genivi.commonapi.core.deployment.deployment { for interfaces { - EnumBackingType: {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (default: UInt32); + DefaultEnumBackingType: {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (default: UInt32); + } + + for enumerations { + EnumBackingType: {UseDefault, UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (default: UseDefault); } } diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend index 3bfa1c5..ff1d3a0 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend @@ -20,7 +20,6 @@ import java.util.LinkedList import java.util.ArrayList import org.franca.core.franca.FTypeRef import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor -import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$EnumBackingType class FTypeCommonAreaGenerator { @Inject private extension FrancaGeneratorExtensions @@ -94,27 +93,7 @@ class FTypeCommonAreaGenerator { ''' def private generateTypeOutput(FEnumerationType fEnumerationType, DeploymentInterfacePropertyAccessor deploymentAccessor) { - if(fEnumerationType.containingInterface != null) { - switch(deploymentAccessor.getEnumBackingType(fEnumerationType.containingInterface)) { - case EnumBackingType::UInt8: - return "UInt8Enum" - case EnumBackingType::UInt16: - return "UInt16Enum" - case EnumBackingType::UInt32: - return "UInt32Enum" - case EnumBackingType::UInt64: - return "UInt64Enum" - case EnumBackingType::Int8: - return "Int8Enum" - case EnumBackingType::Int16: - return "Int16Enum" - case EnumBackingType::Int32: - return "Int32Enum" - case EnumBackingType::Int64: - return "Int64Enum" - } - } - return "Int32Enum" + return fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName.split("_").get(0).toUpperCase.replace("NT", "nt") + "Enum" } def generateVariantComparators(FTypeCollection fTypes) ''' diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend index b8df488..83eb1e6 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend @@ -21,6 +21,7 @@ import org.franca.core.franca.FBroadcast import org.franca.core.franca.FEnumerationType import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$EnumBackingType +import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$DefaultEnumBackingType import static com.google.common.base.Preconditions.* import org.franca.core.franca.FBasicTypeId @@ -32,6 +33,7 @@ import org.franca.core.franca.FUnionType import org.eclipse.emf.ecore.resource.Resource import org.eclipse.core.runtime.Path + class FrancaGeneratorExtensions { def getFullyQualifiedName(FModelElement fModelElement) { if (fModelElement.eContainer instanceof FModel) @@ -366,8 +368,29 @@ class FrancaGeneratorExtensions { } def getBackingType(FEnumerationType fEnumerationType, DeploymentInterfacePropertyAccessor deploymentAccessor) { - if(fEnumerationType.containingInterface != null) { - switch(deploymentAccessor.getEnumBackingType(fEnumerationType.containingInterface)) { + if(deploymentAccessor.getEnumBackingType(fEnumerationType) == EnumBackingType::UseDefault) { + if(fEnumerationType.containingInterface != null) { + switch(deploymentAccessor.getDefaultEnumBackingType(fEnumerationType.containingInterface)) { + case DefaultEnumBackingType::UInt8: + return FBasicTypeId::UINT8 + case DefaultEnumBackingType::UInt16: + return FBasicTypeId::UINT16 + case DefaultEnumBackingType::UInt32: + return FBasicTypeId::UINT32 + case DefaultEnumBackingType::UInt64: + return FBasicTypeId::UINT64 + case DefaultEnumBackingType::Int8: + return FBasicTypeId::INT8 + case DefaultEnumBackingType::Int16: + return FBasicTypeId::INT16 + case DefaultEnumBackingType::Int32: + return FBasicTypeId::INT32 + case DefaultEnumBackingType::Int64: + return FBasicTypeId::INT64 + } + } + } else { + switch(deploymentAccessor.getEnumBackingType(fEnumerationType)) { case EnumBackingType::UInt8: return FBasicTypeId::UINT8 case EnumBackingType::UInt16: @@ -386,7 +409,6 @@ class FrancaGeneratorExtensions { return FBasicTypeId::INT64 } } - return FBasicTypeId::INT32 } def getPrimitiveTypeName(FBasicTypeId fBasicTypeId) { |