Browse Source

Several bugfixes in sctunit test generator and cpp generator.

markus.muehlbrandt@gmail.com 12 years ago
parent
commit
ee96d022bc

+ 8 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend

@@ -20,10 +20,12 @@ import org.yakindu.sct.model.stext.stext.InternalScope
 import org.yakindu.sct.model.sgraph.Event
 import com.google.inject.Inject
 import org.yakindu.sct.model.sexec.TimeEvent
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 
 class Naming extends org.yakindu.sct.generator.c.Naming {
 	
 	@Inject extension Navigation;
+	@Inject extension ICodegenTypeSystemAccess;
 	
 	def cpp(String it) { it + ".cpp" }
 	
@@ -144,4 +146,10 @@ class Naming extends org.yakindu.sct.generator.c.Naming {
 	
 	def localValueAccess(Event it) 
 		'''«name.asIdentifier.value»'''
+		
+	override valueParams(EventDefinition it) {
+		if (hasValue) 
+			type.targetLanguageName + ' value' 
+		else ''
+	}
 }

+ 9 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -113,6 +113,12 @@ class StatemachineHeader extends Statemachine {
 		«scope.createOperationCallbackInterface»
 		
 		«scope.interfaceName»* get«scope.interfaceName»();
+		
+		«IF scope.defaultInterface»
+			«FOR d : scope.declarations»
+			«d.functionPrototypes»
+			«ENDFOR»
+		«ENDIF»
 	'''
 	
 	def private createInterface(StatechartScope scope)
@@ -229,6 +235,7 @@ class StatemachineHeader extends Statemachine {
 			
 			/*! Checks if the out event '«name»' that is defined in the «scope.scopeDescription» has been raised. */ 
 			sc_boolean «asRaised»();
+			
 			«IF hasValue»
 				/*! Gets the value of the out event '«name»' that is defined in the «scope.scopeDescription». */ 
 				«type.targetLanguageName» «asGetter»();
@@ -253,9 +260,11 @@ class StatemachineHeader extends Statemachine {
 	override dispatch functionPrototypes(VariableDefinition it) '''
 		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
 		«type.targetLanguageName» «it.asGetter»();
+
 		«IF ! readonly »
 			/*! Sets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
 			void «asSetter»(«type.targetLanguageName» value);
+			
 		«ENDIF»
 	'''
 	

+ 42 - 16
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

@@ -74,8 +74,8 @@ class StatemachineImplementation {
 		«ENDFOR»
 		«IF hasHistory»
 			
-			for (i = 0; i < «historyStatesConst»; ++i)
-				historyVector[i] = «last_state»;
+				for (int i = 0; i < «historyStatesConst»; ++i)
+					historyVector[i] = «last_state»;
 			«ENDIF»
 			
 			stateConfVectorPosition = 0;
@@ -94,13 +94,11 @@ class StatemachineImplementation {
 	def initFunction(ExecutionFlow it) '''
 		void «module»::init()
 		{
-			int i;
-
-			for (i = 0; i < «orthogonalStatesConst»; ++i)
+			for (int i = 0; i < «orthogonalStatesConst»; ++i)
 				stateConfVector[i] = «last_state»;
 			
 			«IF hasHistory»
-			for (i = 0; i < «historyStatesConst»; ++i)
+			for (int i = 0; i < «historyStatesConst»; ++i)
 				historyVector[i] = «last_state»;
 			
 			«ENDIF»
@@ -239,19 +237,36 @@ class StatemachineImplementation {
 					«ENDIF»
 					«event.localAccess» = true;
 				}
-				
+				
+				«IF scope.defaultInterface»
+					void «module»::«event.asRaiser»(«event.valueParams») {
+						«scope.instance»->«event.asRaiser»(«IF event.hasValue»value«ENDIF»);
+					}
+					
+				«ENDIF»
 			«ENDFOR»
 			«FOR event : scope.outgoingEvents»
 				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»() {
 					return «event.localAccess»;
 				}
-				
+				
+				«IF scope.defaultInterface»
+					sc_boolean «module»::«event.asRaised»() {
+						return «scope.instance»->«event.asRaised»();
+					}
+					
+				«ENDIF»
 				«IF event.hasValue» 
 					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() {
-						//TODO: Check if event is not raised
 						return «event.localValueAccess»;
 					}
-					
+					
+					«IF scope.defaultInterface»
+						«event.type.targetLanguageName» «module»::«event.asGetter»() {
+							return «scope.instance»->«event.asGetter»();
+						}
+						
+					«ENDIF»
 				«ENDIF»
 			«ENDFOR»
 			
@@ -269,7 +284,6 @@ class StatemachineImplementation {
 				
 				«IF event.hasValue» 
 					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() {
-						//TODO: Check if event is not raised
 						return «event.localValueAccess»;
 					}
 					
@@ -279,12 +293,24 @@ class StatemachineImplementation {
 				«variable.type.targetLanguageName» «module»::«scope.interfaceName»::«variable.asGetter»() {
 					return «variable.localAccess»;
 				}
-				
+				
+				«IF scope.defaultInterface»
+					«variable.type.targetLanguageName» «module»::«variable.asGetter»() {
+						return «variable.access»;
+					}
+					
+				«ENDIF»
 				«IF !variable.readonly »
-				void «module»::«scope.interfaceName»::«variable.asSetter»(«variable.type.targetLanguageName» value) {
-					«variable.localAccess» = value;
-				}
-				
+					void «module»::«scope.interfaceName»::«variable.asSetter»(«variable.type.targetLanguageName» value) {
+						«variable.localAccess» = value;
+					}
+					
+					«IF scope.defaultInterface»
+						void «module»::«variable.asSetter»(«variable.type.targetLanguageName» value) {
+						«variable.access» = value;
+						}
+						
+					«ENDIF»
 				«ENDIF»
 			«ENDFOR»
 		«ENDFOR»

BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Naming.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Navigation.java._trace