فهرست منبع

bind separator in cpp generator module'

René Beckmann 7 سال پیش
والد
کامیت
fa780849ee

+ 19 - 6
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGeneratorModule.java

@@ -20,6 +20,7 @@ import org.yakindu.sct.generator.c.DefaultGenArtifactConfigurations;
 import org.yakindu.sct.generator.c.IGenArtifactConfigurations;
 import org.yakindu.sct.generator.c.IncludeProvider;
 import org.yakindu.sct.generator.c.SimpleGenArtifactConfigurations;
+import org.yakindu.sct.generator.c.extensions.GenmodelEntries;
 import org.yakindu.sct.generator.c.extensions.Naming;
 import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator;
@@ -37,17 +38,19 @@ import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.stext.inferrer.STextTypeInferrer;
 
 import com.google.inject.Binder;
+import com.google.inject.name.Names;
 
 /**
- * 
+ *
  * @author andreas muelder - Initial contribution and API
- * 
+ *
  */
 public class CppCodeGeneratorModule implements IGeneratorModule {
 
 	@Override
 	public void configure(GeneratorEntry entry, Binder binder) {
 		binder.bind(GeneratorEntry.class).toInstance(entry);
+		binder.bind(String.class).annotatedWith(Names.named("Separator")).toInstance(getSeparator(entry));
 		binder.bind(IExecutionFlowGenerator.class).to(CppGenerator.class);
 		binder.bind(ICodegenTypeSystemAccess.class).to(CTypeSystemAccess.class);
 		binder.bind(INamingService.class).to(CppNamingService.class);
@@ -57,7 +60,7 @@ public class CppCodeGeneratorModule implements IGeneratorModule {
 		bindEventDrivenClasses(entry, binder);
 		bindIGenArtifactConfigurations(entry, binder);
 	}
-	
+
 	protected void bindIGenArtifactConfigurations(GeneratorEntry entry, Binder binder) {
 		FeatureParameterValue useRelativePathParam = entry.getFeatureParameterValue(FEATURE_INCLUDES,
 				PARAMETER_INCLUDES_USE_RELATIVE_PATHS);
@@ -68,12 +71,12 @@ public class CppCodeGeneratorModule implements IGeneratorModule {
 			binder.bind(IGenArtifactConfigurations.class).to(SimpleGenArtifactConfigurations.class);
 		}
 	}
-	
+
 	protected void bindEventDrivenClasses(GeneratorEntry entry, Binder binder) {
 		Statechart statechart = (Statechart) entry.getElementRef();
 		Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
-		
-		if(eventDrivenAnnotation != null) {
+
+		if (eventDrivenAnnotation != null) {
 			binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
 			binder.bind(StatemachineImplementation.class).to(EventDrivenStatemachineImplementation.class);
 			binder.bind(CppExpressionsGenerator.class).to(EventDrivenExpressionCode.class);
@@ -82,4 +85,14 @@ public class CppCodeGeneratorModule implements IGeneratorModule {
 		}
 	}
 
+	protected String getSeparator(GeneratorEntry entry) {
+		GenmodelEntries entries = new GenmodelEntries();
+		String separator = entries.getSeparator(entry);
+		if (separator == null) {
+			return "_";
+		} else {
+			return separator;
+		}
+	}
+
 }