diff options
author | Henrik Rentz-Reichert | 2012-02-20 14:39:26 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2012-02-20 14:39:26 +0000 |
commit | 82ccdad95b178e017ff657e7c8dbd5492639b3d0 (patch) | |
tree | 63d554999681d87005d8d18456f515596a9ed1a1 /plugins/org.eclipse.etrice.generator/src/org/eclipse | |
parent | 75040cb3a48b029271bd431075fbee68f03b40de (diff) | |
download | org.eclipse.etrice-82ccdad95b178e017ff657e7c8dbd5492639b3d0.tar.gz org.eclipse.etrice-82ccdad95b178e017ff657e7c8dbd5492639b3d0.tar.xz org.eclipse.etrice-82ccdad95b178e017ff657e7c8dbd5492639b3d0.zip |
[generator, generator.c] some fixes, added actor attributes
Diffstat (limited to 'plugins/org.eclipse.etrice.generator/src/org/eclipse')
5 files changed, 27 insertions, 17 deletions
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java index 29b5dcc34..f5d76f605 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java @@ -48,6 +48,7 @@ import com.google.inject.Provider; public abstract class AbstractGenerator {
protected static ILineOutput output = new StdLineOutput();
+ private static Injector injector;
public static void setOutput(ILineOutput out) {
if (out!=null)
@@ -60,12 +61,16 @@ public abstract class AbstractGenerator { * @return
*/
protected static void createAndRunGenerator(Module generatorModule, String[] args) {
- Injector injector = Guice.createInjector(generatorModule);
+ injector = Guice.createInjector(generatorModule);
AbstractGenerator generator = injector.getInstance(AbstractGenerator.class);
generator.logger.setOutput(output);
generator.runGenerator(args);
}
+ public static Injector getInjector() {
+ return injector;
+ }
+
@Inject
protected Provider<ResourceSet> resourceSetProvider;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend index a0638cc73..bf81f38b3 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend @@ -112,7 +112,7 @@ class GenericStateMachineGenerator { //*** Action Codes «FOR tr : xpac.stateMachine.getTransitionList()» «IF xpac.isOwnObject(tr) && tr.hasActionCode()» - protected void «tr.getActionCodeOperationName()»(«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») { + «langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, tr instanceof NonInitialTransition)»«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») { «xpac.getActionCode(tr)» } «ENDIF» @@ -130,7 +130,7 @@ class GenericStateMachineGenerator { switch (current) { «FOR state : xpac.stateMachine.getBaseStateList()» case «state.getStateId()»: - «IF state.hasExitCode()»if (!handler) «state.getExitCodeOperationName()»();«ENDIF» + «IF state.hasExitCode()»if (!handler) «state.getExitCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF» «langExt.memberAccess»history[«state.getParentStateId()»] = «state.getStateId()»; current = «state.getParentStateId()»; break; @@ -170,7 +170,7 @@ class GenericStateMachineGenerator { switch (state) { «FOR state : xpac.stateMachine.getBaseStateList()» case «state.getStateId()»: - «IF state.hasEntryCode()»if (!(skip_entry || handler)) «state.getEntryCodeOperationName()»();«ENDIF» + «IF state.hasEntryCode()»if (!(skip_entry || handler)) «state.getEntryCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF» «IF state.isLeaf()» // in leaf state: return state id return «state.getStateId()»; @@ -234,8 +234,8 @@ class GenericStateMachineGenerator { { chain = «chain.getChainId()»; catching_state = «chain.getContextId()»; - «IF chain.isHandler()»is_handler = true;«ENDIF» - «IF chain.skipEntry»skip_entry = true;«ENDIF» + «IF chain.isHandler()»is_handler = «langExt.booleanConstant(true)»;«ENDIF» + «IF chain.skipEntry»skip_entry = «langExt.booleanConstant(true)»;«ENDIF» } «ENDFOR» «IF needData»}«ENDIF» diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java index cc5f57bf2..3267367a1 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java @@ -20,6 +20,7 @@ import org.eclipse.etrice.core.room.Transition; import org.eclipse.etrice.core.room.Trigger;
import org.eclipse.etrice.core.room.TriggeredTransition;
import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
@@ -27,6 +28,7 @@ public class LanguageGenerator { public String getExecuteChain(ExpandedActorClass ac, TransitionChain tc) {
LanguageTransitionChainVisitor tcv = new LanguageTransitionChainVisitor(ac, tc);
+ AbstractGenerator.getInjector().injectMembers(tcv);
return tc.genExecuteChain(tcv);
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java index 07bdf8a15..233109327 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java @@ -24,10 +24,13 @@ import org.eclipse.etrice.generator.etricegen.ITransitionChainVisitor; import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.extensions.Extensions;
+import com.google.inject.Inject;
+
public class LanguageTransitionChainVisitor implements ITransitionChainVisitor {
private ExpandedActorClass ac;
private LanguageGenerator javaGen = new LanguageGenerator();
+ @Inject ILanguageExtension langExt;
private String typedData = "";
private String dataArg = "";
@@ -49,19 +52,19 @@ public class LanguageTransitionChainVisitor implements ITransitionChainVisitor { public String genActionOperationCall(Transition tr) {
if (tr.getAction()!=null && !tr.getAction().getCommands().isEmpty()) {
if (tr instanceof InitialTransition)
- return Extensions.getActionCodeOperationName(tr)+"();\n";
+ return Extensions.getActionCodeOperationName(tr)+"("+langExt.selfPointer(false)+");\n";
else
- return Extensions.getActionCodeOperationName(tr)+"(ifitem"+dataArg+");\n";
+ return Extensions.getActionCodeOperationName(tr)+"("+langExt.selfPointer(true)+"ifitem"+dataArg+");\n";
}
return "";
}
public String genEntryOperationCall(State state) {
- return Extensions.getEntryCodeOperationName(state)+"();\n";
+ return Extensions.getEntryCodeOperationName(state)+"("+langExt.selfPointer(false)+");\n";
}
public String genExitOperationCall(State state) {
- return Extensions.getExitCodeOperationName(state)+"();\n";
+ return Extensions.getExitCodeOperationName(state)+"("+langExt.selfPointer(false)+");\n";
}
public String genElseIfBranch(CPBranchTransition tr, boolean isFirst) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend index 31feeff47..3d4ab1f91 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend @@ -36,10 +36,10 @@ class ProcedureHelpers { def userCode(DetailCode dc) {'''
«IF dc!=null»
- //--------------------- begin user code
+ /*--------------------- begin user code ---------------------*/
«FOR command : dc.commands» «command»
«ENDFOR»
- //--------------------- end user code
+ /*--------------------- end user code ---------------------*/
«ENDIF»
'''
}
@@ -47,12 +47,12 @@ class ProcedureHelpers { // Attributes
/* TODO: add ref type */
def attributes(List<Attribute> attribs) {'''
- //--------------------- attributes
+ /*--------------------- attributes ---------------------*/
«FOR attribute : attribs»
«IF attribute.size==0»
- «languageExt.accessLevelProtected()»«attribute.refType.type.typeName» «attribute.name»;
+ «attribute.refType.type.typeName» «attribute.name»;
«ELSE»
- «languageExt.accessLevelProtected()»«attribute.refType.type.typeName»[] «attribute.name»;
+ «attribute.refType.type.typeName»[] «attribute.name»;
«ENDIF»
«ENDFOR»
'''
@@ -144,7 +144,7 @@ class ProcedureHelpers { // Operations
def operationsDeclaration(List<? extends Operation> operations, String classname) {'''
- //--------------------- operations
+ /*--------------------- operations ---------------------*/
«FOR operation : operations»
«operationSignature(operation, classname, true)»;
«ENDFOR»
@@ -152,7 +152,7 @@ class ProcedureHelpers { }
def operationsImplementation(List<? extends Operation> operations, String classname) {'''
- //--------------------- operations
+ /*--------------------- operations ---------------------*/
«FOR operation : operations»
«operationSignature(operation, classname, false)» {
«FOR command : operation.detailCode.commands»
|