浏览代码

Fixed minor issues in C generator.

anyssen 9 年之前
父节点
当前提交
c926c77d0b

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

@@ -80,7 +80,7 @@ class Statemachine {
 		
 		«IF timed»
 			/*! Raises a time event. */
-			extern void «raiseTimeEventFctID»(«scHandleDecl», sc_eventid evid);
+			extern void «raiseTimeEventFctID»(const «scHandleDecl», sc_eventid evid);
 		«ENDIF»
 		
 		«FOR s : it.scopes.filter( typeof(InterfaceScope) )»

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

@@ -87,7 +87,7 @@ class StatemachineC {
 	def initFunction(ExecutionFlow it) '''
 		void «functionPrefix»init(«scHandleDecl»)
 		{
-			int i;
+			sc_integer i;
 
 			for (i = 0; i < «type.toUpperCase»_MAX_ORTHOGONAL_STATES; ++i) {
 				«scHandle»->stateConfVector[i] = «null_state»;
@@ -211,7 +211,6 @@ class StatemachineC {
 	'''
 	
 	def isActiveFunction(ExecutionFlow it) '''
-
 		sc_boolean «isActiveFctID»(const «scHandleDecl») {
 			return «FOR i : 0 ..< stateVector.size SEPARATOR '||'»«scHandle»->stateConfVector[«i»] != «null_state»«ENDFOR»;
 		}
@@ -231,7 +230,7 @@ class StatemachineC {
 		// only if the impact vector is completely covered by final states the state machine 
 		// can become final
 		{if (finalStateImpactVector.isCompletelyCovered) {'''	return «FOR i : 0 ..<finalStateImpactVector.size SEPARATOR ' && '»(«FOR fs : finalStateImpactVector.get(i) SEPARATOR ' || '»«scHandle»->stateConfVector[«i»] == «IF fs.stateVector.offset == i»«fs.shortName»«ELSE»«null_state»«ENDIF»«ENDFOR»)«ENDFOR»;
-		'''} else {'''   return false;'''} }		
+		'''} else {'''   return bool_false;'''} }		
 		+ '''}'''
 	}
 	
@@ -309,7 +308,7 @@ class StatemachineC {
 	'''
 	
 	def dispatch functionPrototype(Check it) '''
-		static sc_boolean «shortName»(«scHandleDecl»);
+		static sc_boolean «shortName»(const «scHandleDecl»);
 	'''
 	
 	def dispatch functionPrototype(Step it) '''
@@ -344,7 +343,7 @@ class StatemachineC {
 	
 	def dispatch functionImplementation(Check it) '''
 		«stepComment»
-		static sc_boolean «shortName»(«scHandleDecl») {
+		static sc_boolean «shortName»(const «scHandleDecl») {
 			return «code»;
 		}