Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-01-25 10:29:46 +0000
committerThomas Schuetz2012-01-25 10:29:46 +0000
commit749b13f65870f2cbdc3ae89c90b432966300d235 (patch)
tree082725e7ff15264393e1f1b37390e652c6c20297 /plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
parent4ff0a97045e63ba53a013a5f680328d359854731 (diff)
downloadorg.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.tar.gz
org.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.tar.xz
org.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.zip
[generator.c] first version of generator for ProtocolClass
Diffstat (limited to 'plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend27
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index 29adb4a9b..ab9ed4120 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -19,7 +19,10 @@ import java.util.List
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.DetailCode
import org.eclipse.etrice.core.room.Operation
-import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.core.room.VarDecl
+import org.eclipse.emf.common.util.EList
+
@Singleton
@@ -131,14 +134,14 @@ class ProcedureHelpers {
// Operations
def OperationsDeclaration(List<? extends Operation> operations, String classname) {'''
//--------------------- operations
- «FOR operation : operations»«OperationHeader(operation, classname, true)»;
+ «FOR operation : operations»«OperationSignature(operation, classname, true)»;
«ENDFOR»
'''
}
def OperationsImplementation(List<? extends Operation> operations, String classname) {'''
//--------------------- operations
- «FOR operation : operations»«OperationHeader(operation, classname, false)» {
+ «FOR operation : operations»«OperationSignature(operation, classname, false)» {
«FOR command : operation.detailCode.commands» «command»
«ENDFOR»
}
@@ -146,8 +149,22 @@ class ProcedureHelpers {
'''
}
- def private OperationHeader(Operation operation, String classname, boolean isDeclaration) {'''
- «languageExt.accessLevelPublic()»«IF operation.returntype==null»void«ELSE»«operation.returntype.typeName»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operation.name»(«languageExt.selfPointer(classname, operation.arguments.size)»«FOR argument : operation.arguments SEPARATOR ", "»«argument.type.typeName» «argument.name»«ENDFOR»)'''
+
+ def private OperationSignature(Operation operation, String classname, boolean isDeclaration) {'''
+««« «ClassOperationSignature(classname, operation.name, BuildArgumentList(operation.arguments), if(operation.returntype==null)"void"else operation.returntype.typeName, isDeclaration)»
+ «languageExt.accessLevelPublic()»«IF operation.returntype==null»void«ELSE»«operation.returntype.typeName»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operation.name»(«languageExt.selfPointer(classname, operation.arguments.size)»«BuildArgumentList(operation.arguments)»)'''
+ }
+
+ /*
+ * builds comma separated argument list as string from EList<VarDecl> arguments
+ */
+ def private BuildArgumentList(EList<VarDecl> arguments){
+ '''«FOR argument : arguments SEPARATOR ", "»«argument.type.typeName» «argument.name»«ENDFOR»'''
+ }
+
+// def ClassFunctionSignature(String classname, String functionname, EList<VarDecl> arguments, ){
+ def ClassOperationSignature(String classname, String operationname, String argumentList, String returnType, boolean isDeclaration){'''
+ «languageExt.accessLevelPublic()»«IF returnType==""»void«ELSE»«returnType»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operationname»(«languageExt.selfPointer(classname, argumentList.length)»«argumentList»)'''
}
} \ No newline at end of file

Back to the top