Просмотр исходного кода

Define constants with static keyword.

Markus Mühlbrandt 10 лет назад
Родитель
Сommit
05eb329ba6

+ 2 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend

@@ -141,7 +141,7 @@ class Statemachine {
 		
 		/* Declaration of constants for scope «type». */
 		«FOR d : declarations.filter(typeof(VariableDefinition)).filter[const]»
-			«IF d.type.name != 'void'»const «d.type.targetLanguageName» «d.constantName» = «d.initialValue.resolveConstants»;«ENDIF»
+			«IF d.type.name != 'void'»static const «d.type.targetLanguageName» «d.constantName» = «d.initialValue.resolveConstants»;«ENDIF»
 		«ENDFOR»
 
 	'''
@@ -199,7 +199,7 @@ class Statemachine {
 
 	def dispatch functionPrototypes(VariableDefinition it) '''
 		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
-		extern «type.targetLanguageName» «it.asGetter»(const «scHandleDecl»);
+		extern «IF const»const «ENDIF»«type.targetLanguageName» «it.asGetter»(const «scHandleDecl»);
 		«IF !readonly && !const»
 			/*! Sets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
 			extern void «asSetter»(«scHandleDecl», «type.targetLanguageName» value);

+ 1 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend

@@ -259,7 +259,7 @@ class StatemachineC {
 			«ENDFOR»
 			
 			«FOR variable : scope.variableDefinitions»
-				«variable.type.targetLanguageName» «variable.asGetter»(const «scHandleDecl») {
+				«IF variable.const»const «ENDIF»«variable.type.targetLanguageName» «variable.asGetter»(const «scHandleDecl») {
 					return «variable.access»;
 				}
 				«IF !variable.readonly && !variable.const»