Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2019-01-12 06:29:57 -0500
committerJuergen Haug2019-01-12 06:30:29 -0500
commit8d023fb6af978b7da56d7f39376699d417279e9e (patch)
tree887f0c30577b1c260254b492becf59cde3de7ee6 /plugins/org.eclipse.etrice.generator.cpp
parent322931d01d3fdf0411b2756f5aad5f582eddeed0 (diff)
downloadorg.eclipse.etrice-8d023fb6af978b7da56d7f39376699d417279e9e.tar.gz
org.eclipse.etrice-8d023fb6af978b7da56d7f39376699d417279e9e.tar.xz
org.eclipse.etrice-8d023fb6af978b7da56d7f39376699d417279e9e.zip
Bug 540562 - Support var args for operations
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.cpp')
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend30
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend13
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend4
3 files changed, 32 insertions, 15 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index e88a2feed..ff6606faa 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -35,15 +35,17 @@ import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.core.room.MessageData
import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.RefableType
import org.eclipse.etrice.core.room.RoomClass
+import org.eclipse.etrice.core.room.VarDecl
import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.generator.cpp.Main
+import org.eclipse.etrice.generator.cpp.setup.GeneratorOptionsHelper
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
import org.eclipse.xtext.util.Pair
import org.eclipse.xtext.util.Strings
-import org.eclipse.etrice.generator.cpp.Main
-import org.eclipse.etrice.generator.cpp.setup.GeneratorOptionsHelper
@Singleton
class CppExtensions implements ILanguageExtension {
@@ -298,6 +300,30 @@ class CppExtensions implements ILanguageExtension {
}
}
}
+
+ override String getTypeSignature(RefableType type) {
+ switch it : type {
+ case null: 'void'
+ case isRef: type.type.dataTypeName + pointerLiteral
+ default: type.type.dataTypeName
+ }
+ }
+
+ override String getDataTypeName(DataType it) {
+ switch it {
+ PrimitiveType: targetName
+ EnumerationType: targetType
+ ExternalType: targetName
+ default: name
+ }
+ }
+
+ override toParameterDecl(VarDecl it) {
+ switch it {
+ case varargs : refType.typeSignature + ' ' + name + '...'
+ default: refType.typeSignature + ' ' + name
+ }
+ }
// def targetFQN(RoomClass roomClass){
// roomClass.targetPkg + '::' + roomClass.name
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
index c73e7add1..22d29c519 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
@@ -2,7 +2,6 @@ package org.eclipse.etrice.generator.cpp.gen
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.core.room.RefableType
class CppProcedureHelpers extends ProcedureHelpers {
@@ -15,22 +14,14 @@ class CppProcedureHelpers extends ProcedureHelpers {
switch it : attribute {
// no reference
case size > 0: super.declarationString(it)
- default: super.signatureString(type) + ' ' + name
- }
- }
-
- override signatureString(RefableType type) {
- switch it : type {
- case null: 'void'
- case !(isRef || type.type.primitive): super.signatureString(type) + '&'
- default: super.signatureString(type)
+ default: languageExt.getTypeSignature(type) + ' ' + name
}
}
override signatureString(Attribute attribute) {
switch it : attribute {
case size > 0: super.signatureString(attribute) + '&'
- default: type.signatureString
+ default: languageExt.getTypeSignature(type)
}
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index 815e4c17e..4f98c8cbb 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -351,11 +351,11 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def protected messageSignature(Message m, boolean impl) {
- '''«IF m.priv||impl»private:«ELSE»public:«ENDIF» void «m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.signatureString» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
+ '''«IF m.priv||impl»private:«ELSE»public:«ENDIF» void «m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.typeSignature» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
}
def protected messageSignatureDefinition(Message m, String classPrefix, boolean impl) {
- '''void «classPrefix»::«m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.signatureString» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
+ '''void «classPrefix»::«m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.typeSignature» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
}
def protected sendMessage(Message m, String portClassName, String classPrefix, boolean conj) {

Back to the top