瀏覽代碼

#382 correcting the formatter for cpp generator

Dominik Tesch 9 年之前
父節點
當前提交
0fe32324cb

+ 14 - 7
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/FlowCode.xtend

@@ -40,9 +40,11 @@ class FlowCode extends org.yakindu.sct.generator.c.FlowCode {
 	
 	override dispatch CharSequence code(HistoryEntry it) '''
 		«stepComment»
-		if (historyVector[«region.historyVector.offset»] != «null_state») {
+		if (historyVector[«region.historyVector.offset»] != «null_state»)
+		{
 			«historyStep.code»
-		} «IF initialStep != null»else {
+		} «IF initialStep != null»else
+		{
 			«initialStep.code»
 		} «ENDIF»
 	'''
@@ -50,12 +52,15 @@ class FlowCode extends org.yakindu.sct.generator.c.FlowCode {
 	override dispatch CharSequence code(StateSwitch it) '''
 		«stepComment»
 		«IF historyRegion != null»
-			switch(historyVector[ «historyRegion.historyVector.offset» ]) {
+			switch(historyVector[ «historyRegion.historyVector.offset» ])
+			{
 		«ELSE»
-			switch(stateConfVector[ «stateConfigurationIdx» ]) {
+			switch(stateConfVector[ «stateConfigurationIdx» ])
+			{
 		«ENDIF»
 			«FOR caseid : cases»
-				case «caseid.state.shortName» : {
+				case «caseid.state.shortName» :
+				{
 					«caseid.step.code»
 					break;
 				}
@@ -95,9 +100,11 @@ class FlowCode extends org.yakindu.sct.generator.c.FlowCode {
 		
     override dispatch CharSequence code(If it) '''
 		«stepComment»
-		if («check.code») { 
+		if («check.code»)
+		{ 
 			«thenStep.code»
-		} «IF (elseStep != null)» else {
+		} «IF (elseStep != null)» else
+		{
 			«elseStep.code»
 		}
 		«ENDIF»

+ 6 - 3
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -60,7 +60,8 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 		/*! \file Header of the state machine '«name»'.
 		*/
 		
-		class «module» : «interfaceExtensions» {
+		class «module» : «interfaceExtensions»
+		{
 			
 			public:
 				
@@ -141,7 +142,8 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 
 	def protected createInterface(StatechartScope scope) '''
 		//! Inner class for «scope.simpleName» interface scope.
-		class «scope.interfaceName» {
+		class «scope.interfaceName»
+		{
 			
 			public:
 				«FOR d : scope.declarations»
@@ -165,7 +167,8 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 			
 			«IF scope.hasOperations»
 				//! Inner class for «scope.simpleName» interface scope operation callbacks.
-				class «scope.interfaceOCBName» {
+				class «scope.interfaceOCBName»
+				{
 					public:
 						«IF !entry.useStaticOPC»
 							virtual ~«scope.interfaceOCBName»() = 0;

+ 67 - 35
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

@@ -85,7 +85,8 @@ class StatemachineImplementation {
 	'''
 	
 	def constructorDefinition(ExecutionFlow it) '''
-		«module»::«module»() {
+		«module»::«module»()
+		{
 			
 			«scopes.filter(typeof(StatechartScope)).filter[hasOperations && !entry.useStaticOPC].map['''«OCB_Instance» = null;'''].join('\n')»
 			«IF hasHistory»
@@ -103,7 +104,8 @@ class StatemachineImplementation {
 	'''
 	
 	def destructorDefinition(ExecutionFlow it) '''
-		«module»::~«module»() {
+		«module»::~«module»()
+		{
 		}
 	'''
 	
@@ -124,7 +126,6 @@ class StatemachineImplementation {
 			clearOutEvents();
 			
 			«initSequence.code»
-
 		}
 	'''
 	
@@ -143,7 +144,8 @@ class StatemachineImplementation {
 	'''
 	
 	def clearInEventsFunction(ExecutionFlow it) '''
-		void «module»::clearInEvents() {
+		void «module»::clearInEvents()
+		{
 			«FOR scope : it.scopes»
 				«FOR event : scope.incomingEvents»
 				«event.access» = false;
@@ -163,7 +165,8 @@ class StatemachineImplementation {
 	'''
 	
 	def clearOutEventsFunction(ExecutionFlow it) '''
-		void «module»::clearOutEvents() {
+		void «module»::clearOutEvents()
+		{
 			«FOR scope : it.scopes»
 				«FOR event : scope.outgoingEvents»
 				«event.access» = false;
@@ -173,18 +176,22 @@ class StatemachineImplementation {
 	'''
 	
 	def runCycleFunction(ExecutionFlow it) '''
-		void «module»::runCycle() {
+		void «module»::runCycle()
+		{
 			
 			clearOutEvents();
 			
 			for (stateConfVectorPosition = 0;
 				stateConfVectorPosition < «orthogonalStatesConst»;
-				stateConfVectorPosition++) {
+				stateConfVectorPosition++)
+				{
 					
-				switch (stateConfVector[stateConfVectorPosition]) {
+				switch (stateConfVector[stateConfVectorPosition])
+				{
 				«FOR state : states»
 					«IF state.reactSequence!=null»
-					case «state.shortName.asEscapedIdentifier» : {
+					case «state.shortName.asEscapedIdentifier» :
+					{
 						«state.reactSequence.shortName»();
 						break;
 					}
@@ -202,16 +209,20 @@ class StatemachineImplementation {
 	def timedStatemachineFunctions(ExecutionFlow it) '''
 		«IF timed»
 			
-			void «module»::setTimer(«timerInterface»* timer){
+			void «module»::setTimer(«timerInterface»* timer)
+			{
 				this->«timerInstance» = timer;
 			}
 			
-			«timerInterface»* «module»::getTimer(){
+			«timerInterface»* «module»::getTimer()
+			{
 				return «timerInstance»;
 			}
 			
-			void «module»::«raiseTimeEventFctID»(sc_eventid evid) {
-				if ((evid >= &timeEvents) && (evid < &timeEvents + sizeof(timeEvents))) {
+			void «module»::«raiseTimeEventFctID»(sc_eventid evid)
+			{
+				if ((evid >= &timeEvents) && (evid < &timeEvents + sizeof(timeEvents)))
+				{
 					*(sc_boolean*)evid = true;
 				}
 			}
@@ -219,8 +230,10 @@ class StatemachineImplementation {
 	'''
 	
 	def isStateActiveFunction(ExecutionFlow it) '''
-		sc_boolean «module»::«stateActiveFctID»(«statesEnumType» state) {
-			switch (state) {
+		sc_boolean «module»::«stateActiveFctID»(«statesEnumType» state)
+		{
+			switch (state)
+			{
 				«FOR s : states»
 				case «s.shortName.asEscapedIdentifier» : 
 					return (sc_boolean) («IF s.leaf»stateConfVector[«s.stateVector.offset»] == «s.shortName.asEscapedIdentifier»
@@ -234,12 +247,13 @@ class StatemachineImplementation {
 	
 	
 	def isActiveFunction(ExecutionFlow it) '''
-		sc_boolean «module»::isActive() {
+		sc_boolean «module»::isActive()
+		{
 			return «FOR i : 0 ..< stateVector.size SEPARATOR '||'»stateConfVector[«i»] != «null_state»«ENDFOR»;
 		}
 	'''
 	
-	def protected isFinalFunction(ExecutionFlow it) {
+	def protected isFinalFunction(ExecutionFlow it){
 		val finalStateImpactVector = flow.finalStateImpactVector
 		'''
 			«IF !finalStateImpactVector.isCompletelyCovered»
@@ -247,7 +261,8 @@ class StatemachineImplementation {
 			 * Always returns 'false' since this state machine can never become final.
 			 */
 			«ENDIF»
-			sc_boolean «module»::isFinal(){
+			sc_boolean «module»::isFinal()
+			{
 		''' +
 		// only if the impact vector is completely covered by final states the state machine 
 		// can become final
@@ -272,13 +287,15 @@ class StatemachineImplementation {
 	def interfaceFunctions(ExecutionFlow it) '''
 		«FOR scope : statechartScopes»
 			«IF scope instanceof InterfaceScope»
-			«module»::«scope.interfaceName»* «module»::get«scope.interfaceName»() {
+			«module»::«scope.interfaceName»* «module»::get«scope.interfaceName»()
+			{
 				return &«scope.instance»;
 			}
 			
 			«ENDIF»
 			«FOR event : scope.incomingEvents»
-				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams») {
+				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
+				{
 					«IF event.hasValue»
 					«event.localValueAccess» = value;
 					«ENDIF»
@@ -286,30 +303,35 @@ class StatemachineImplementation {
 				}
 				
 				«IF scope.defaultInterface»
-					void «module»::«event.asRaiser»(«event.valueParams») {
+					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»() {
+				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»()
+				{
 					return «event.localAccess»;
 				}
 				
 				«IF scope.defaultInterface»
-					sc_boolean «module»::«event.asRaised»() {
+					sc_boolean «module»::«event.asRaised»()
+					{
 						return «scope.instance».«event.asRaised»();
 					}
 					
 				«ENDIF»
 				«IF event.hasValue» 
-					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() {
+					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»()
+					{
 						return «event.localValueAccess»;
 					}
 					
 					«IF scope.defaultInterface»
-						«event.type.targetLanguageName» «module»::«event.asGetter»() {
+						«event.type.targetLanguageName» «module»::«event.asGetter»()
+						{
 							return «scope.instance».«event.asGetter»();
 						}
 						
@@ -318,42 +340,49 @@ class StatemachineImplementation {
 			«ENDFOR»
 			
 			«FOR event : scope.localEvents»
-				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams») {
+				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
+				{
 					«IF event.hasValue»
 					«event.localValueAccess» = value;
 					«ENDIF»
 					«event.localAccess» = true;
 				}
 				
-				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»() {
+				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»()
+				{
 					return «event.localAccess»;
 				}
 				
 				«IF event.hasValue» 
-					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() {
+					«event.type.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»()
+					{
 						return «event.localValueAccess»;
 					}
 					
 				«ENDIF»
 			«ENDFOR»
 			«FOR variable : scope.variableDefinitions»
-				«IF variable.const»const «ENDIF»«variable.type.targetLanguageName» «module»::«scope.interfaceName»::«variable.asGetter»() {
+				«IF variable.const»const «ENDIF»«variable.type.targetLanguageName» «module»::«scope.interfaceName»::«variable.asGetter»()
+				{
 					return «variable.localAccess»;
 				}
 				
 				«IF scope.defaultInterface»
-					«IF variable.const»const «ENDIF»«variable.type.targetLanguageName» «module»::«variable.asGetter»() {
+					«IF variable.const»const «ENDIF»«variable.type.targetLanguageName» «module»::«variable.asGetter»()
+					{
 						return «variable.access»;
 					}
 					
 				«ENDIF»
 				«IF !variable.readonly && !variable.const»
-					void «module»::«scope.interfaceName»::«variable.asSetter»(«variable.type.targetLanguageName» 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) {
+						void «module»::«variable.asSetter»(«variable.type.targetLanguageName» value)
+						{
 							«variable.access» = value;
 						}
 						
@@ -361,7 +390,8 @@ class StatemachineImplementation {
 				«ENDIF»
 			«ENDFOR»
 			«IF scope.hasOperations && !entry.useStaticOPC»
-				«scope.OCB_InterfaceSetterDeclaration(true)» {
+				«scope.OCB_InterfaceSetterDeclaration(true)»
+				{
 					«scope.OCB_Instance» = operationCallback;
 				}
 			«ENDIF»
@@ -394,7 +424,8 @@ class StatemachineImplementation {
 	
 	def dispatch functionImplementation(Check it) '''
 		«stepComment»
-		sc_boolean «execution_flow.module»::«shortName»() {
+		sc_boolean «execution_flow.module»::«shortName»()
+		{
 			return «code»;
 		}
 		
@@ -402,7 +433,8 @@ class StatemachineImplementation {
 	
 	def dispatch functionImplementation(Step it) '''
 		«stepComment»
-		void «execution_flow.module»::«shortName»() {
+		void «execution_flow.module»::«shortName»()
+		{
 			«code»
 		}
 		

+ 2 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineInterface.xtend

@@ -37,7 +37,8 @@ class StatemachineInterface {
 		/*
 		 * Basic interface for state machines.
 		 */
-		class «statemachineInterface» {
+		class «statemachineInterface»
+		{
 			public:
 			
 				virtual ~«statemachineInterface»() = 0;

+ 2 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/TimerInterface.xtend

@@ -42,7 +42,8 @@ class TimerInterface {
 		/*
 		 * Basic interface for state machines.
 		 */
-		class «timerInterface» {
+		class «timerInterface»
+		{
 			public:
 				
 				virtual ~«timerInterface»() = 0;