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

Java Code Generator uses ITypeSystemAccess

Andreas Mülder 13 лет назад
Родитель
Сommit
e2e2de0cee

+ 21 - 4
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java

@@ -11,23 +11,40 @@ package org.yakindu.sct.generator.java;
 
 import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
 
+import org.yakindu.base.types.ITypeSystemAccess;
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
 public class JavaCodeGenerator extends GenericJavaBasedGenerator {
 
 	@Override
 	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
-		JavaGenerator delegate = getInjector(entry).getInstance(JavaGenerator.class);
-		
+		JavaGenerator delegate = getInjector(entry).getInstance(
+				JavaGenerator.class);
+
 		ExecutionFlow flow = createExecutionFlow(statechart, entry);
-		
+
 		if (isDumpSexec(entry)) {
 			dumpSexec(entry, flow);
 		}
-		
+
 		delegate.generate(flow, entry, getFileSystemAccess(entry));
 	}
+
+	@Override
+	protected Module createModule(GeneratorEntry entry) {
+		Module module = super.createModule(entry);
+		return Modules.override(module).with(new Module() {
+			public void configure(Binder binder) {
+				binder.bind(ITypeSystemAccess.class).to(
+						JavaTypeSystemAccess.class);
+			}
+		});
+	}
 }

+ 20 - 19
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend

@@ -19,13 +19,14 @@ import org.yakindu.sct.model.stext.stext.EventDefinition
 import java.util.List
 import org.yakindu.sct.model.sexec.Step
 import org.yakindu.sct.model.sexec.Check
+import org.yakindu.base.types.ITypeSystemAccess
 
 class Statemachine {
 	
 	@Inject extension Naming
 	@Inject extension GenmodelEntries
 	@Inject extension Navigation
-	@Inject extension TypeModel
+	@Inject extension ITypeSystemAccess
 	@Inject extension FlowCode
 	@Inject Beautifier beautifier
 	
@@ -88,7 +89,7 @@ class Statemachine {
 		private boolean «event.name.asEscapedIdentifier»;
 		
 		«IF !event.type.isVoid()»
-			private «event.type.javaType» «event.valueIdentifier»;
+			private «event.type.targetLanguageTypeName» «event.valueIdentifier»;
 		«ENDIF»
 		«ENDFOR»
 		«var timeEvents = flow.timeEvents»
@@ -114,7 +115,7 @@ class Statemachine {
 		};
 		
 		«FOR variable : flow.internalScopeVariables»
-		private «variable.type.getJavaType()» «variable.name.asEscapedIdentifier»;
+		private «variable.type.targetLanguageTypeName» «variable.name.asEscapedIdentifier»;
 		«ENDFOR»
 		
 		«IF flow.hasHistory»
@@ -267,17 +268,17 @@ class Statemachine {
 			private boolean «event.name.asEscapedIdentifier»;
 			
 			«IF !event.type.isVoid()»
-				private «event.type.getJavaType()» «event.valueIdentifier»;
+				private «event.type.targetLanguageTypeName» «event.valueIdentifier»;
 			«ENDIF»
 			
 			«IF event.direction == Direction::IN»
 				«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.getJavaType()» value) {
+					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
 						«event.name.asEscapedIdentifier» = true;
 						«event.valueIdentifier» = value;
 					}
 					
-					private «event.type.getJavaType()» get«event.name.asName»Value() {
+					private «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
 						«event.getIllegalAccessValidation()»
 						return «event.valueIdentifier»;
 					}
@@ -297,7 +298,7 @@ class Statemachine {
 				}
 				
 				«IF !event.type.isVoid()»
-					private void raise«event.name.asName»(«event.type.getJavaType()» value) {
+					private void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
 						«event.name.asEscapedIdentifier» = true;
 						«event.valueIdentifier» = value;
 						«IF entry.createInterfaceObserver»
@@ -307,7 +308,7 @@ class Statemachine {
 						«ENDIF»
 					}
 					
-					public «event.type.getJavaType()» get«event.name.asName»Value() {
+					public «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
 						«event.getIllegalAccessValidation()»
 						return «event.valueIdentifier»;
 					}
@@ -326,14 +327,14 @@ class Statemachine {
 		
 		«FOR variable : scope.variableDefinitions»
 				
-				private «variable.type.getJavaType()» «variable.name.asEscapedIdentifier»;
+				private «variable.type.targetLanguageTypeName» «variable.name.asEscapedIdentifier»;
 				
-				public «variable.type.getJavaType()» «variable.getter» {
+				public «variable.type.targetLanguageTypeName» «variable.getter» {
 					return «variable.name.asEscapedIdentifier»;
 				}
 				
 				«IF  !variable.readonly»
-					public void «variable.setter»(«variable.type.getJavaType()» value) {
+					public void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
 						this.«variable.name.asEscapedIdentifier» = value;
 					}
 				«ENDIF»
@@ -370,12 +371,12 @@ class Statemachine {
 	def private internalScopeFunctions (ExecutionFlow flow) '''
 		«FOR event : flow.internalScopeEvents»
 			«IF !event.type.void»
-				private void raise«event.name.asEscapedName»(«event.type.getJavaType()» value) {
+				private void raise«event.name.asEscapedName»(«event.type.targetLanguageTypeName» value) {
 					«event.valueIdentifier» = value;
 					«event.name.asEscapedIdentifier» = true;
 				}
 				
-				private «event.type.getJavaType()» get«event.name.asEscapedName»Value() {
+				private «event.type.targetLanguageTypeName» get«event.name.asEscapedName»Value() {
 					«event.getIllegalAccessValidation()»
 					return «event.valueIdentifier»;
 				}
@@ -388,11 +389,11 @@ class Statemachine {
 			«ENDIF»
 		«ENDFOR»
 «««		«FOR variable : flow.internalScopeVariables»
-«««		private «variable.type.javaType» «variable.getter» {
+«««		private «variable.type.targetLanguageTypeName» «variable.getter» {
 «««			return «variable.name.asEscapedIdentifier»;
 «««		}
 «««		
-«««		private void «variable.setter»(«variable.type.javaType» value) {
+«««		private void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
 «««			«variable.name.asEscapedIdentifier» = value;
 «««		}	
 «««		«ENDFOR»
@@ -413,7 +414,7 @@ class Statemachine {
 			«FOR event : scope.eventDefinitions»
 				«IF event.direction == Direction::IN»
 					«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.javaType» value) {
+					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
 						«scope.interfaceName.asEscapedIdentifier».raise«event.name.asName»(value);
 					}
 					«ELSE»
@@ -427,7 +428,7 @@ class Statemachine {
 						return «scope.interfaceName.asEscapedIdentifier».isRaised«event.name.asName»();
 					}
 					«IF !event.type.isVoid()»
-						public «event.type.getJavaType()» get«event.name.asName»Value() {
+						public «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
 							return «scope.interfaceName.asEscapedIdentifier».get«event.name.asName»Value();
 						}
 					«ENDIF»
@@ -435,11 +436,11 @@ class Statemachine {
 			«ENDFOR»
 			
 			«FOR variable : scope.variableDefinitions»
-			public «variable.type.javaType» «variable.getter()» {
+			public «variable.type.targetLanguageTypeName» «variable.getter()» {
 				return «scope.interfaceName.asEscapedIdentifier».«variable.getter()»;
 			}
 			
-			public void «variable.setter»(«variable.type.javaType» value) {
+			public void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
 				«scope.interfaceName.asEscapedIdentifier».«variable.setter»(value);
 			}	
 			«ENDFOR»

+ 8 - 7
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/StatemachineInterface.xtend

@@ -19,13 +19,14 @@ import org.yakindu.base.types.Parameter
 import org.yakindu.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.model.stext.stext.InternalScope
 import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.base.types.ITypeSystemAccess
 
 class StatemachineInterface {
 	
 	@Inject extension Naming 
 	@Inject extension GenmodelEntries
 	@Inject extension Navigation
-	@Inject extension TypeModel
+	@Inject extension ITypeSystemAccess
 	@Inject Beautifier beautifier
 	
 	def generateStatemachineInterface(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
@@ -111,7 +112,7 @@ class StatemachineInterface {
 				«FOR event : scope.eventDefinitions»
 					«IF event.direction ==  Direction::OUT»
 						«IF !event.type.isVoid()»
-							public void on«event.name.toFirstUpper()»Raised(«event.type.getJavaType()» value);
+							public void on«event.name.toFirstUpper()»Raised(«event.type.targetLanguageTypeName» value);
 						«ELSE»
 							public void on«event.name.toFirstUpper()»Raised();
 						«ENDIF»	
@@ -140,14 +141,14 @@ class StatemachineInterface {
 		«FOR event : scope.eventDefinitions»
 			«IF  event.direction ==  Direction::IN»
 				«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.getJavaType()» value);
+					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value);
 				«ELSE»
 					public void raise«event.name.asName»();
 				«ENDIF»
 			«ELSEIF event.direction ==  Direction::OUT»
 				public boolean isRaised«event.name.asName»();
 				«IF !event.type.void»
-					public «event.type.getJavaType()» get«event.name.asName»Value();
+					public «event.type.targetLanguageTypeName» get«event.name.asName»Value();
 				«ENDIF»	
 			«ENDIF»
 		«ENDFOR»
@@ -156,9 +157,9 @@ class StatemachineInterface {
 	
 	def private variableAccessors(InterfaceScope scope) '''
 		«FOR variable : scope.variableDefinitions»
-					public «variable.type.getJavaType()» «variable.getter»;
+					public «variable.type.targetLanguageTypeName» «variable.getter»;
 					«IF  !variable.readonly»
-						public void «variable.setter»(«variable.type.getJavaType()» value);	
+						public void «variable.setter»(«variable.type.targetLanguageTypeName» value);	
 					«ENDIF»
 		«ENDFOR»
 	'''
@@ -178,7 +179,7 @@ class StatemachineInterface {
 	
 	def private operationSignature(OperationDefinition it) {
 		'''
-		public «type.javaType» «name.asEscapedIdentifier»(«FOR parameter : parameters SEPARATOR ', '»«parameter.type.javaType» «parameter.identifier»«ENDFOR»);
+		public «type.targetLanguageTypeName» «name.asEscapedIdentifier»(«FOR parameter : parameters SEPARATOR ', '»«parameter.type.targetLanguageTypeName» «parameter.identifier»«ENDFOR»);
 		'''
 	}