summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schanda <schanda@itestra.de>2013-06-11 14:45:57 +0200
committerJohannes Schanda <schanda@itestra.de>2013-06-11 14:45:57 +0200
commit773c5104ede00dddb2b9dd69ad30743518de184f (patch)
treebb4c1dbe5bab1372d2652ac8431664316a613161
parentf6f7a0e9a30a027bfd866867dac61016a19f7b27 (diff)
downloadgenivi-common-api-runtime-773c5104ede00dddb2b9dd69ad30743518de184f.tar.gz
Correct error type generation
- Corrects placement of inline and extended error type defenitions in methods to place in <Interface>.h - Corrects generation of type references in all proxy and stub declarations for error types
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend9
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend8
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCommonAreaGenerator.xtend29
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend11
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend10
5 files changed, 45 insertions, 22 deletions
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
index 396f738..311c3ed 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
@@ -54,6 +54,9 @@ class FInterfaceGenerator {
«FOR type : fInterface.types»
«type.generateFTypeInlineImplementation(fInterface, deploymentAccessor)»
«ENDFOR»
+ «FOR method : fInterface.methods.filter[errors != null]»
+ «method.errors.generateInlineImplementation(method.errors.errorName, fInterface, fInterface.name, deploymentAccessor)»
+ «ENDFOR»
«fInterface.model.generateNamespaceEndDeclaration»
@@ -65,7 +68,13 @@ class FInterfaceGenerator {
namespace std {
+ //hashes for types
«fInterface.generateHashers(deploymentAccessor)»
+
+ //hashes for error types
+ «FOR method : fInterface.methods.filter[errors != null]»
+ «method.errors.generateHash(method.errors.errorName, fInterface, deploymentAccessor)»
+ «ENDFOR»
}
#endif // «fInterface.defineName»_H_
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
index a583e25..5d361bc 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
@@ -49,10 +49,6 @@ class FInterfaceProxyGenerator {
class «fInterface.proxyBaseClassName»: virtual public CommonAPI::Proxy {
public:
- «FOR method : fInterface.methods.filter[errors != null]»
- «method.errors.generateDeclaration(method.errors.errorName, deploymentAccessor)»
-
- «ENDFOR»
«FOR attribute : fInterface.attributes»
typedef CommonAPI::«attribute.commonApiBaseClassname»<«attribute.getTypeName(fInterface.model)»> «attribute.className»;
«ENDFOR»
@@ -87,10 +83,6 @@ class FInterfaceProxyGenerator {
«ENDFOR»
};
- «FOR method : fInterface.methods.filter[errors != null]»
- «method.errors.generateInlineImplementation(method.errors.errorName, fInterface, fInterface.proxyBaseClassName, deploymentAccessor)»
- «ENDFOR»
-
«fInterface.model.generateNamespaceEndDeclaration»
#endif // «fInterface.defineName»_PROXY_BASE_H_
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 9baa34c..415389b 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
@@ -201,15 +201,32 @@ class FTypeCommonAreaGenerator {
def getFQN(FType type, FTypeCollection fTypes) '''«fTypes.model.namespaceAsList.join("::")»::«type.getClassNamespaceWithName(type.name, fTypes, fTypes.name)»'''
+ def getFQN(FType type, String name, FTypeCollection fTypes) '''«fTypes.model.namespaceAsList.join("::")»::«type.getClassNamespaceWithName(name, fTypes, fTypes.name)»'''
+
+ def generateHash (FType type, String name, FTypeCollection fTypes, DeploymentInterfacePropertyAccessor deploymentAccessor) '''
+ //Hash for «name»
+ template<>
+ struct hash<«type.getFQN(name, fTypes)»> {
+ inline size_t operator()(const «type.getFQN(name, fTypes)»& «name.toFirstLower») const {
+ return static_cast<«type.getFEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(«name.toFirstLower»);
+ }
+ };
+ '''
+
+ def generateHash (FType type, FTypeCollection fTypes, DeploymentInterfacePropertyAccessor deploymentAccessor) '''
+ //Hash for «type.name»
+ template<>
+ struct hash<«type.getFQN(fTypes)»> {
+ inline size_t operator()(const «type.getFQN(fTypes)»& «type.name.toFirstLower») const {
+ return static_cast<«type.getFEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(«type.name.toFirstLower»);
+ }
+ };
+ '''
+
def generateHashers(FTypeCollection fTypes, DeploymentInterfacePropertyAccessor deploymentAccessor) '''
«FOR type: fTypes.types»
«IF type.isFEnumerationType»
- template<>
- struct hash<«type.getFQN(fTypes)»> {
- inline size_t operator()(const «type.getFQN(fTypes)»& «type.name.toFirstLower») const {
- return static_cast<«type.getFEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(«type.name.toFirstLower»);
- }
- };
+ «type.generateHash(fTypes, deploymentAccessor)»
«ENDIF»
«ENDFOR»
'''
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend
index 0908199..514cb1b 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend
@@ -39,6 +39,11 @@ class FTypeGenerator {
«type.generateFTypeDeclaration(deploymentAccessor)»
«ENDFOR»
+ «IF fTypeCollection instanceof FInterface»
+ «FOR method : (fTypeCollection as FInterface).methods.filter[errors != null]»
+ «method.errors.generateDeclaration(method.errors.errorName, deploymentAccessor)»
+ «ENDFOR»
+ «ENDIF»
'''
def private sortTypes(EList<FType> typeList, FTypeCollection containingTypeCollection) {
@@ -402,12 +407,12 @@ class FTypeGenerator {
}
def private generateInlineOperatorWithName(FEnumerationType fEnumerationType, String enumerationName, FEnumerationType base, FModelElement parent, String parentName, String operator, DeploymentInterfacePropertyAccessor deploymentAccessor) '''
- inline bool operator«operator»(const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& lhs, const «base.getRelativeNameReference(fEnumerationType)»& rhs) {
+ inline bool operator«operator»(const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& lhs, const «base.getClassNamespaceWithName(base.name, base.eContainer as FModelElement, (base.eContainer as FModelElement).name)»& rhs) {
return static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(lhs) «operator» static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(rhs);
}
- inline bool operator«operator»(const «base.getRelativeNameReference(fEnumerationType)»& lhs, const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& rhs) {
+ inline bool operator«operator»(const «base.getClassNamespaceWithName(base.name, base.eContainer as FModelElement, (base.eContainer as FModelElement).name)»& lhs, const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& rhs) {
return static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(lhs) «operator» static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(rhs);
- }
+ }
'''
def private getBaseList(FEnumerationType fEnumerationType) {
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 867283b..2d63de0 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
@@ -301,12 +301,12 @@ class FrancaGeneratorExtensions {
def getErrorNameReference(FMethod fMethod, EObject source) {
checkArgument(fMethod.hasError, 'FMethod has no error: ' + fMethod)
- if (fMethod.errorEnum != null)
- return fMethod.errorEnum.getRelativeNameReference(source)
+ if (fMethod.errorEnum != null) {
+ return fMethod.errorEnum.getRelativeNameReference((source as FModelElement).model)
+ }
var errorNameReference = fMethod.errors.errorName
- if (!fMethod.eContainer.equals(source))
- errorNameReference = (fMethod.eContainer as FInterface).getRelativeNameReference(source) + '::' + errorNameReference
+ errorNameReference = (fMethod.eContainer as FInterface).getRelativeNameReference(source) + '::' + errorNameReference
return errorNameReference
}
@@ -387,7 +387,7 @@ class FrancaGeneratorExtensions {
return typeName
}
-
+
def getNameReference(FTypeRef destination, EObject source) {
if (destination.derived != null)
return destination.derived.getRelativeNameReference(source)