Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-01-03 19:42:01 +0000
committerHenrik Rentz-Reichert2012-01-03 19:42:01 +0000
commit12d085d0c849291049c7fe1bf82508570518d592 (patch)
treec913b9e8e3b9001b8310fdff6fc0b7f978dd8336 /plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
parentdf35a49da5a4aadb7875e37d938afc605251868d (diff)
downloadorg.eclipse.etrice-12d085d0c849291049c7fe1bf82508570518d592.tar.gz
org.eclipse.etrice-12d085d0c849291049c7fe1bf82508570518d592.tar.xz
org.eclipse.etrice-12d085d0c849291049c7fe1bf82508570518d592.zip
[core.room and affected] changed ROOM types and semantic rules
- dropped PrimitiveTypes enum - all types modeled explicitly now - semantic rules defined consistently now
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.xtend41
1 files changed, 34 insertions, 7 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 5925c0176..c09d28670 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
@@ -23,8 +23,8 @@ import org.eclipse.etrice.core.room.Operation
@Singleton
class ProcedureHelpers {
- @Inject
- extension ILanguageExtension languageExt
+ @Inject extension ILanguageExtension languageExt
+ @Inject extension TypeHelpers
def UserCode(DetailCode dc) {'''
«IF dc!=null»
@@ -40,13 +40,40 @@ class ProcedureHelpers {
def Attributes(List<Attribute> attribs) {'''
//--------------------- attributes
«FOR attribute : attribs»
- «IF attribute.size==0»«languageExt.accessLevelProtected()»«IF attribute.type.ext != null»«attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF» «attribute.name»;
- «ELSE»«languageExt.accessLevelProtected()»«attribute.type.typeName()»[] «attribute.name»«IF attribute.defaultValueLiteral==null» =new «attribute.type.typeName()»[«attribute.size»];«ELSE» = «attribute.defaultValueLiteral»;«ENDIF»
+ «IF attribute.size==0»
+ «languageExt.accessLevelProtected()»«attribute.type.name» «attribute.name»«IF attribute.defaultValueLiteral==null» = «attribute.type.defaultValue»«ELSE» = «attribute.defaultValueLiteral»«ENDIF»;
+ «ELSE»
+ «languageExt.accessLevelProtected()»«attribute.type.name»[] «attribute.name»«IF attribute.defaultValueLiteral==null» = «attribute.type.defaultValue»[«attribute.size»];«ELSE» = «attribute.defaultValueLiteral»;«ENDIF»
«ENDIF»
«ENDFOR»
'''
}
+ def attributeInitialization(List<Attribute> attribs) {
+ '''
+ // initialize attributes
+ «FOR a : attribs»
+ «IF a.defaultValueLiteral!=null»
+ «IF a.size==0»
+ «a.name» = «a.defaultValueLiteral»;
+ «ELSE»
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «a.defaultValueLiteral»
+ }
+ «ENDIF»
+ «ELSE»
+ «IF a.size==0»
+ «a.name» = «a.type.defaultValue»;
+ «ELSE»
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «a.type.defaultValue»
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ '''
+ }
+
// Attribute setters & getters
def AttributeSettersGettersDeclaration(List<Attribute> attribs, String classname) {'''
//--------------------- attribute setters and getters
@@ -69,10 +96,10 @@ class ProcedureHelpers {
}
def private SetterHeader(Attribute attribute, String classname){'''
- «languageExt.accessLevelPublic()»void set«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 1)»«IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» «attribute.name»)'''
+ «languageExt.accessLevelPublic()»void set«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 1)»«attribute.type.name»«IF attribute.size!=0»[]«ENDIF» «attribute.name»)'''
}
def private GetterHeader(Attribute attribute, String classname){'''
- «languageExt.accessLevelPublic()»«IF attribute.type.ext != null» «attribute.type.ext»«ELSE»«attribute.type.typeName()»«ENDIF»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 0)»)'''
+ «languageExt.accessLevelPublic()»«attribute.type.name»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 0)»)'''
}
@@ -95,7 +122,7 @@ class ProcedureHelpers {
}
def private OperationHeader(Operation operation, String classname, boolean isDeclaration) {'''
- «languageExt.accessLevelPublic()»«IF operation.returntype==null»void«ELSE»«operation.returntype.freeTypeName()»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operation.name» («languageExt.selfPointer(classname, operation.arguments.size)»«FOR argument : operation.arguments SEPARATOR ", "»«argument.type.freeTypeName()» «argument.name»«ENDFOR»)'''
+ «languageExt.accessLevelPublic()»«IF operation.returntype==null»void«ELSE»«operation.returntype.name»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operation.name» («languageExt.selfPointer(classname, operation.arguments.size)»«FOR argument : operation.arguments SEPARATOR ", "»«argument.type.name» «argument.name»«ENDFOR»)'''
}
} \ No newline at end of file

Back to the top