Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2017-08-31 16:06:02 +0000
committerJan Belle2017-08-31 16:06:02 +0000
commit2312786d9c8b27fe97fd361e0aeeef99fe0e67de (patch)
treeeb6430be1083782b820a9107be8ae51e112dc4aa /plugins/org.eclipse.etrice.generator
parent2b3ac6e99310df76f704e7231748bcc236e708a6 (diff)
downloadorg.eclipse.etrice-2312786d9c8b27fe97fd361e0aeeef99fe0e67de.tar.gz
org.eclipse.etrice-2312786d9c8b27fe97fd361e0aeeef99fe0e67de.tar.xz
org.eclipse.etrice-2312786d9c8b27fe97fd361e0aeeef99fe0e67de.zip
Bug 521698 - Tycho build
generate xtend files Change-Id: Ifc0808742d7f72da305cb0879384af6f7da85581
Diffstat (limited to 'plugins/org.eclipse.etrice.generator')
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java127
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java132
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java155
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java441
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java132
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java912
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java646
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java291
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java198
9 files changed, 0 insertions, 3034 deletions
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java
deleted file mode 100644
index 2b60bb84b..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- * Juergen Haug
- */
-package org.eclipse.etrice.generator.base;
-
-import java.util.List;
-import org.eclipse.xtend.lib.annotations.Accessors;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Pure;
-
-@Accessors
-@SuppressWarnings("all")
-public class GlobalGeneratorSettings {
- private final List<String> inputModelURIs = CollectionLiterals.<String>newArrayList();
-
- private boolean generateAsLibrary = false;
-
- private boolean generateMSCInstrumentation = false;
-
- private boolean generateDataInstrumentation = false;
-
- private boolean noTranslation = false;
-
- private String mainMethodName = "main";
-
- private String generatorModelPath = null;
-
- private boolean generateDocumentation = false;
-
- private boolean generateWithVerboseOutput = false;
-
- private boolean debugMode = false;
-
- @Pure
- public List<String> getInputModelURIs() {
- return this.inputModelURIs;
- }
-
- @Pure
- public boolean isGenerateAsLibrary() {
- return this.generateAsLibrary;
- }
-
- public void setGenerateAsLibrary(final boolean generateAsLibrary) {
- this.generateAsLibrary = generateAsLibrary;
- }
-
- @Pure
- public boolean isGenerateMSCInstrumentation() {
- return this.generateMSCInstrumentation;
- }
-
- public void setGenerateMSCInstrumentation(final boolean generateMSCInstrumentation) {
- this.generateMSCInstrumentation = generateMSCInstrumentation;
- }
-
- @Pure
- public boolean isGenerateDataInstrumentation() {
- return this.generateDataInstrumentation;
- }
-
- public void setGenerateDataInstrumentation(final boolean generateDataInstrumentation) {
- this.generateDataInstrumentation = generateDataInstrumentation;
- }
-
- @Pure
- public boolean isNoTranslation() {
- return this.noTranslation;
- }
-
- public void setNoTranslation(final boolean noTranslation) {
- this.noTranslation = noTranslation;
- }
-
- @Pure
- public String getMainMethodName() {
- return this.mainMethodName;
- }
-
- public void setMainMethodName(final String mainMethodName) {
- this.mainMethodName = mainMethodName;
- }
-
- @Pure
- public String getGeneratorModelPath() {
- return this.generatorModelPath;
- }
-
- public void setGeneratorModelPath(final String generatorModelPath) {
- this.generatorModelPath = generatorModelPath;
- }
-
- @Pure
- public boolean isGenerateDocumentation() {
- return this.generateDocumentation;
- }
-
- public void setGenerateDocumentation(final boolean generateDocumentation) {
- this.generateDocumentation = generateDocumentation;
- }
-
- @Pure
- public boolean isGenerateWithVerboseOutput() {
- return this.generateWithVerboseOutput;
- }
-
- public void setGenerateWithVerboseOutput(final boolean generateWithVerboseOutput) {
- this.generateWithVerboseOutput = generateWithVerboseOutput;
- }
-
- @Pure
- public boolean isDebugMode() {
- return this.debugMode;
- }
-
- public void setDebugMode(final boolean debugMode) {
- this.debugMode = debugMode;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
deleted file mode 100644
index 509b81d29..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.SAP;
-import org.eclipse.etrice.core.room.SPP;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.fsm.base.Indexed;
-import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-/**
- * Target language independent part of an actor class generator.
- * It uses the {@link ILanguageExtension}.
- */
-@SuppressWarnings("all")
-public class GenericActorClassGenerator implements IIfItemIdGenerator {
- @Inject
- @Extension
- protected RoomHelpers _roomHelpers;
-
- @Inject
- @Extension
- protected RoomExtensions _roomExtensions;
-
- @Inject
- protected ILanguageExtension langExt;
-
- /**
- * Generate constants for the local IDs of all interface items of an actor
- * class.
- *
- * @param xpac an {@link ExpandedActorClass}
- * @return the generated code
- */
- public String genInterfaceItemConstants(final ExpandedActorClass xpac) {
- final ActorClass ac = xpac.getActorClass();
- List<Port> _xifexpression = null;
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- _xifexpression = this._roomHelpers.getEndPorts(ac);
- } else {
- _xifexpression = this._roomHelpers.getAllEndPorts(ac);
- }
- final List<Port> endPorts = _xifexpression;
- List<SAP> _xifexpression_1 = null;
- boolean _usesInheritance_1 = this.langExt.usesInheritance();
- if (_usesInheritance_1) {
- _xifexpression_1 = ac.getServiceAccessPoints();
- } else {
- _xifexpression_1 = this._roomHelpers.getAllSAPs(ac);
- }
- final List<SAP> strSAPs = _xifexpression_1;
- List<ServiceImplementation> _xifexpression_2 = null;
- boolean _usesInheritance_2 = this.langExt.usesInheritance();
- if (_usesInheritance_2) {
- _xifexpression_2 = ac.getServiceImplementations();
- } else {
- _xifexpression_2 = this._roomHelpers.getAllServiceImplementations(ac);
- }
- final List<ServiceImplementation> svcImpls = _xifexpression_2;
- final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
- for (final Port ep : endPorts) {
- String _ifItemId = this.getIfItemId(ep);
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
- int _plus = (1 + _interfaceItemLocalId);
- String _string = Integer.valueOf(_plus).toString();
- Pair<String, String> _pair = Tuples.<String, String>pair(_ifItemId, _string);
- list.add(_pair);
- }
- for (final SAP sap : strSAPs) {
- String _ifItemId_1 = this.getIfItemId(sap);
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
- int _plus_1 = (1 + _interfaceItemLocalId_1);
- String _string_1 = Integer.valueOf(_plus_1).toString();
- Pair<String, String> _pair_1 = Tuples.<String, String>pair(_ifItemId_1, _string_1);
- list.add(_pair_1);
- }
- for (final ServiceImplementation svc : svcImpls) {
- SPP _spp = svc.getSpp();
- String _ifItemId_2 = this.getIfItemId(_spp);
- SPP _spp_1 = svc.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
- int _plus_2 = (1 + _interfaceItemLocalId_2);
- String _string_2 = Integer.valueOf(_plus_2).toString();
- Pair<String, String> _pair_2 = Tuples.<String, String>pair(_ifItemId_2, _string_2);
- list.add(_pair_2);
- }
- return this.langExt.genEnumeration("interface_items", list);
- }
-
- public String genInterfaceItemConstantsForOptionalActor(final ActorClass ac) {
- final List<Port> ports = this._roomHelpers.getAllInterfacePorts(ac);
- final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
- Iterable<Indexed<Port>> _indexed = Indexed.<Port>indexed(ports);
- for (final Indexed<Port> ep : _indexed) {
- Port _value = ep.getValue();
- String _ifItemId = this.getIfItemId(_value);
- int _index1 = ep.getIndex1();
- String _string = Integer.valueOf(_index1).toString();
- Pair<String, String> _pair = Tuples.<String, String>pair(_ifItemId, _string);
- list.add(_pair);
- }
- return this.langExt.genEnumeration("interface_items", list);
- }
-
- @Override
- public String getIfItemId(final AbstractInterfaceItem item) {
- String _name = item.getName();
- return ("IFITEM_" + _name);
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
deleted file mode 100644
index 8b476a3c3..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
-import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.SAP;
-import org.eclipse.etrice.core.room.SPP;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-/**
- * Target language independent protocol class generator.
- */
-@SuppressWarnings("all")
-public class GenericProtocolClassGenerator implements IMessageIdGenerator {
- @Inject
- @Extension
- protected RoomHelpers _roomHelpers;
-
- @Inject
- @Extension
- protected ILanguageExtension _iLanguageExtension;
-
- @Inject
- @Extension
- protected RoomExtensions _roomExtensions;
-
- /**
- * Generate constants for message IDs.
- *
- * @param pc the {@link ProtocolClass}
- * @return the generated code for message ID constants
- */
- public String genMessageIDs(final ProtocolClass pc) {
- int offset = 0;
- ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
- String _name = pc.getName();
- String _memberInDeclaration = this._iLanguageExtension.memberInDeclaration(_name, "MSG_MIN");
- String _string = Integer.valueOf(offset).toString();
- Pair<String, String> _pair = Tuples.<String, String>pair(_memberInDeclaration, _string);
- list.add(_pair);
- List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc);
- for (final Message msg : _allOutgoingMessages) {
- {
- offset = (offset + 1);
- String _name_1 = pc.getName();
- String _name_2 = msg.getName();
- String _plus = ("OUT_" + _name_2);
- String _memberInDeclaration_1 = this._iLanguageExtension.memberInDeclaration(_name_1, _plus);
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String, String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- }
- }
- List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc);
- for (final Message msg_1 : _allIncomingMessages) {
- {
- offset = (offset + 1);
- String _name_1 = pc.getName();
- String _name_2 = msg_1.getName();
- String _plus = ("IN_" + _name_2);
- String _memberInDeclaration_1 = this._iLanguageExtension.memberInDeclaration(_name_1, _plus);
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String, String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- }
- }
- offset = (offset + 1);
- String _name_1 = pc.getName();
- String _memberInDeclaration_1 = this._iLanguageExtension.memberInDeclaration(_name_1, "MSG_MAX");
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String, String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- String _name_2 = pc.getName();
- String _memberInDeclaration_2 = this._iLanguageExtension.memberInDeclaration(_name_2, "msg_ids");
- return this._iLanguageExtension.genEnumeration(_memberInDeclaration_2, list);
- }
-
- /**
- * @param mif a {@link MessageFromIf}
- * @return an identifier for the message
- */
- @Override
- public String getMessageID(final MessageFromIf mif) {
- EObject _message = mif.getMessage();
- AbstractInterfaceItem _from = mif.getFrom();
- return this.getMessageID(((Message) _message), ((InterfaceItem) _from));
- }
-
- /**
- * @param msg a {@link Message}
- * @param item a {@link InterfaceItem}
- * @return an identifier for the message
- */
- public String getMessageID(final Message msg, final InterfaceItem item) {
- if ((item instanceof Port)) {
- Port p = ((Port) item);
- String _xifexpression = null;
- boolean _isConjugated = p.isConjugated();
- if (_isConjugated) {
- _xifexpression = "OUT_";
- } else {
- _xifexpression = "IN_";
- }
- String direction = _xifexpression;
- GeneralProtocolClass _protocol = p.getProtocol();
- String _name = _protocol.getName();
- String _name_1 = msg.getName();
- String _plus = (direction + _name_1);
- return this._iLanguageExtension.memberInUse(_name, _plus);
- } else {
- if ((item instanceof SAP)) {
- SAP sap = ((SAP) item);
- ProtocolClass _protocol_1 = sap.getProtocol();
- String _name_2 = _protocol_1.getName();
- String _name_3 = msg.getName();
- String _plus_1 = ("OUT_" + _name_3);
- return this._iLanguageExtension.memberInUse(_name_2, _plus_1);
- } else {
- if ((item instanceof SPP)) {
- SPP spp = ((SPP) item);
- ProtocolClass _protocol_2 = spp.getProtocol();
- String _name_4 = _protocol_2.getName();
- String _name_5 = msg.getName();
- String _plus_2 = ("IN_" + _name_5);
- return this._iLanguageExtension.memberInUse(_name_4, _plus_2);
- }
- }
- }
- return "unknown interface item";
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
deleted file mode 100644
index d31d8c586..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/**
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.Guard;
-import org.eclipse.etrice.core.fsm.fSM.GuardedTransition;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
-import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition;
-import org.eclipse.etrice.core.fsm.fSM.State;
-import org.eclipse.etrice.core.fsm.fSM.Transition;
-import org.eclipse.etrice.core.fsm.fSM.Trigger;
-import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedRefinedState;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
-import org.eclipse.etrice.generator.fsm.generic.AbstractStateMachineGenerator;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-/**
- * A target language independent generator of the state machine implementation
- */
-@SuppressWarnings("all")
-public class GenericStateMachineGenerator extends AbstractStateMachineGenerator {
- /**
- * generates the code of the whole state machine, consisting of constants + methods
- *
- * @param xpmc the {@link ExpandedModelComponent}
- * @return the generated code
- */
- public CharSequence genStateMachine(final ExpandedModelComponent xpmc) {
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _genStateMachineConstants = this.genStateMachineConstants(xpmc);
- _builder.append(_genStateMachineConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- CharSequence _genStateMachineMethods = this.genStateMachineMethods(xpmc, true);
- _builder.append(_genStateMachineMethods, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- /**
- * generates the constants for the state machine
- */
- public CharSequence genStateMachineConstants(final ExpandedModelComponent xpmc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* state IDs */");
- _builder.newLine();
- String _genStateIdConstants = this.genStateIdConstants(xpmc);
- _builder.append(_genStateIdConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* transition chains */");
- _builder.newLine();
- String _genTransitionChainConstants = this.genTransitionChainConstants(xpmc);
- _builder.append(_genTransitionChainConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* triggers */");
- _builder.newLine();
- String _genTriggerConstants = this.genTriggerConstants(xpmc);
- _builder.append(_genTriggerConstants, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- /**
- * generates the methods for the state machine codes and state switching
- *
- * @param xpmc the {@link ExpandedModelComponent}
- * @param generateImplemenation or declaration only
- * @return the generated code
- */
- public CharSequence genStateMachineMethods(final ExpandedModelComponent xpmc, final boolean generateImplementation) {
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _genExtra = this.genExtra(xpmc, generateImplementation);
- _builder.append(_genExtra, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* Entry and Exit Codes */");
- _builder.newLine();
- String _genEntryAndExitCodes = this.genEntryAndExitCodes(xpmc, generateImplementation);
- _builder.append(_genEntryAndExitCodes, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* Action Codes */");
- _builder.newLine();
- String _genActionCodes = this.genActionCodes(xpmc, generateImplementation);
- _builder.append(_genActionCodes, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* State Switch Methods */");
- _builder.newLine();
- String _genStateSwitchMethods = this.genStateSwitchMethods(xpmc, generateImplementation);
- _builder.append(_genStateSwitchMethods, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- /**
- * generate a transition guard if applicable
- *
- * @param tt a {@link TriggeredTransition}
- * @param trigger a trigger string
- * @param xpmc an expanded actor class
- * @return the generated code
- */
- @Override
- public String guard(final TriggeredTransition tt, final String trigger, final ExpandedModelComponent mc) {
- String _xblockexpression = null;
- {
- EList<Trigger> _triggers = tt.getTriggers();
- final Function1<Trigger, Boolean> _function = (Trigger e) -> {
- return Boolean.valueOf(mc.isMatching(e, trigger));
- };
- final Trigger tr = IterableExtensions.<Trigger>findFirst(_triggers, _function);
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasGuard = this._fSMHelpers.hasGuard(tr);
- if (_hasGuard) {
- _builder.append("if (");
- Guard _guard = tr.getGuard();
- DetailCode _guard_1 = _guard.getGuard();
- String _translatedCode = this.translator.getTranslatedCode(_guard_1);
- _builder.append(_translatedCode, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = _builder.toString();
- }
- return _xblockexpression;
- }
-
- @Override
- public String guard(final GuardedTransition tt, final String trigger, final ExpandedModelComponent mc) {
- StringConcatenation _builder = new StringConcatenation();
- DetailCode _guard = tt.getGuard();
- String _translatedCode = this.translator.getTranslatedCode(_guard);
- _builder.append(_translatedCode, "");
- _builder.newLineIfNotEmpty();
- return _builder.toString();
- }
-
- @Override
- public String genActionCodeMethod(final ExpandedModelComponent xpmc, final Transition tr, final boolean generateImplementation) {
- String _xblockexpression = null;
- {
- EList<TransitionChain> chain = xpmc.getChains(tr);
- boolean hasArgs = ((!chain.isEmpty()) && IterableExtensions.<TransitionChain>forall(chain, ((Function1<TransitionChain, Boolean>) (TransitionChain it) -> {
- return Boolean.valueOf(((it.getTransition() instanceof NonInitialTransition) && (!(it.getTransition() instanceof GuardedTransition))));
- })));
- String _className = this.getClassName(xpmc);
- final String opScope = this.langExt.operationScope(_className, false);
- String _xifexpression = null;
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- _xifexpression = opScope;
- } else {
- _xifexpression = "";
- }
- final String opScopePriv = _xifexpression;
- String _pointerLiteral = this.langExt.pointerLiteral();
- final String ifItemPtr = ("InterfaceItemBase" + _pointerLiteral);
- String _xifexpression_1 = null;
- boolean _usesPointers = this.langExt.usesPointers();
- if (_usesPointers) {
- _xifexpression_1 = ("const " + ifItemPtr);
- } else {
- _xifexpression_1 = ifItemPtr;
- }
- final String constIfItemPtr = _xifexpression_1;
- String _xifexpression_2 = null;
- if (generateImplementation) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelProtected = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected, "");
- _builder.append("void ");
- _builder.append(opScopePriv, "");
- String _actionCodeOperationName = this._codegenHelpers.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- String _className_1 = this.getClassName(xpmc);
- String _selfPointer = this.langExt.selfPointer(_className_1, hasArgs);
- _builder.append(_selfPointer, "");
- {
- if (hasArgs) {
- _builder.append(constIfItemPtr, "");
- _builder.append(" ifitem");
- String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpmc, tr);
- _builder.append(_generateArgumentList, "");
- }
- }
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- DetailCode _action = tr.getAction();
- String _translatedCode = this.translator.getTranslatedCode(_action);
- _builder.append(_translatedCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _xifexpression_2 = _builder.toString();
- } else {
- StringConcatenation _builder_1 = new StringConcatenation();
- String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
- _builder_1.append(_accessLevelProtected_1, "");
- String _makeOverridable = this.langExt.makeOverridable();
- _builder_1.append(_makeOverridable, "");
- _builder_1.append("void ");
- String _actionCodeOperationName_1 = this._codegenHelpers.getActionCodeOperationName(tr);
- _builder_1.append(_actionCodeOperationName_1, "");
- _builder_1.append("(");
- String _className_2 = this.getClassName(xpmc);
- String _selfPointer_1 = this.langExt.selfPointer(_className_2, hasArgs);
- _builder_1.append(_selfPointer_1, "");
- {
- if (hasArgs) {
- _builder_1.append(constIfItemPtr, "");
- _builder_1.append(" ifitem");
- String _generateArgumentList_1 = this.transitionChainGenerator.generateArgumentList(xpmc, tr);
- _builder_1.append(_generateArgumentList_1, "");
- }
- }
- _builder_1.append(");");
- _builder_1.newLineIfNotEmpty();
- _xifexpression_2 = _builder_1.toString();
- }
- _xblockexpression = _xifexpression_2;
- }
- return _xblockexpression;
- }
-
- /**
- * generate action code method implementations or declarations
- *
- * @param xpax the {@link ExpandedModelComponent}
- * @param state the {@link State}
- * @param generateImplementation if only declarations should be generated then <code>false</code> has to be passed
- * @return the generated code
- */
- @Override
- public String genActionCodeMethods(final ExpandedModelComponent xpmc, final State state, final boolean generateImplementation) {
- String _xblockexpression = null;
- {
- final ModelComponent mc = xpmc.getModelComponent();
- String _className = this.getClassName(mc);
- final String selfPtr = this.langExt.selfPointer(_className, false);
- String _className_1 = this.getClassName(mc);
- final String opScope = this.langExt.operationScope(_className_1, false);
- String _xifexpression = null;
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- _xifexpression = opScope;
- } else {
- _xifexpression = "";
- }
- final String opScopePriv = _xifexpression;
- final String entryOp = this._codegenHelpers.getEntryCodeOperationName(state);
- final String exitOp = this._codegenHelpers.getExitCodeOperationName(state);
- final String doOp = this._codegenHelpers.getDoCodeOperationName(state);
- DetailCode _entryCode = state.getEntryCode();
- String entry = this.translator.getTranslatedCode(_entryCode);
- DetailCode _exitCode = state.getExitCode();
- String exit = this.translator.getTranslatedCode(_exitCode);
- DetailCode _doCode = state.getDoCode();
- String docode = this.translator.getTranslatedCode(_doCode);
- if ((state instanceof ExpandedRefinedState)) {
- final ExpandedRefinedState rs = ((ExpandedRefinedState) state);
- DetailCode _inheritedEntry = rs.getInheritedEntry();
- final String inhEntry = this.translator.getTranslatedCode(_inheritedEntry);
- DetailCode _inheritedExit = rs.getInheritedExit();
- final String inhExit = this.translator.getTranslatedCode(_inheritedExit);
- DetailCode _inheritedDo = rs.getInheritedDo();
- final String inhDo = this.translator.getTranslatedCode(_inheritedDo);
- boolean _usesInheritance_1 = this.langExt.usesInheritance();
- if (_usesInheritance_1) {
- ModelComponent _base = mc.getBase();
- final String baseName = this.getClassName(_base);
- DetailCode _inheritedEntry_1 = rs.getInheritedEntry();
- boolean _hasDetailCode = this._fSMHelpers.hasDetailCode(_inheritedEntry_1);
- if (_hasDetailCode) {
- String _superCall = this.langExt.superCall(baseName, entryOp, "");
- String _plus = (_superCall + entry);
- entry = _plus;
- }
- DetailCode _inheritedExit_1 = rs.getInheritedExit();
- boolean _hasDetailCode_1 = this._fSMHelpers.hasDetailCode(_inheritedExit_1);
- if (_hasDetailCode_1) {
- String _superCall_1 = this.langExt.superCall(baseName, exitOp, "");
- String _plus_1 = (exit + _superCall_1);
- exit = _plus_1;
- }
- DetailCode _inheritedDo_1 = rs.getInheritedDo();
- boolean _hasDetailCode_2 = this._fSMHelpers.hasDetailCode(_inheritedDo_1);
- if (_hasDetailCode_2) {
- String _superCall_2 = this.langExt.superCall(baseName, doOp, "");
- String _plus_2 = (_superCall_2 + docode);
- docode = _plus_2;
- }
- } else {
- entry = (inhEntry + entry);
- exit = (exit + inhExit);
- docode = (inhDo + docode);
- }
- }
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isEmpty = entry.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- {
- if (generateImplementation) {
- String _accessLevelProtected = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected, "");
- _builder.append("void ");
- _builder.append(opScopePriv, "");
- _builder.append(entryOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(entry, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- } else {
- String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_1, "");
- String _makeOverridable = this.langExt.makeOverridable();
- _builder.append(_makeOverridable, "");
- _builder.append("void ");
- _builder.append(entryOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- {
- boolean _isEmpty_1 = exit.isEmpty();
- boolean _not_1 = (!_isEmpty_1);
- if (_not_1) {
- {
- if (generateImplementation) {
- String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_2, "");
- _builder.append("void ");
- _builder.append(opScopePriv, "");
- _builder.append(exitOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(exit, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- } else {
- String _accessLevelProtected_3 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_3, "");
- String _makeOverridable_1 = this.langExt.makeOverridable();
- _builder.append(_makeOverridable_1, "");
- _builder.append("void ");
- _builder.append(exitOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- {
- boolean _isEmpty_2 = docode.isEmpty();
- boolean _not_2 = (!_isEmpty_2);
- if (_not_2) {
- {
- if (generateImplementation) {
- String _accessLevelProtected_4 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_4, "");
- _builder.append(" void ");
- _builder.append(opScopePriv, "");
- _builder.append(doOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(docode, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- } else {
- String _accessLevelProtected_5 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_5, "");
- String _makeOverridable_2 = this.langExt.makeOverridable();
- _builder.append(_makeOverridable_2, "");
- _builder.append("void ");
- _builder.append(doOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = _builder.toString();
- }
- return _xblockexpression;
- }
-
- /**
- * let derived class add extra code after definition of constants
- *
- * @param xpmc an expanded actor class
- * @param generateImplementation or declaration only
- * @return the generated code
- */
- public CharSequence genExtra(final ExpandedModelComponent xpmc, final boolean generateImplementation) {
- StringConcatenation _builder = new StringConcatenation();
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java
deleted file mode 100644
index 667fe42c5..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-/**
- * A class that is used to recursively erase all folders receiving generated code
- * an to place a readme file into those folders.
- */
-@Singleton
-@SuppressWarnings("all")
-public class PrepareFileSystem {
- @Inject
- @Extension
- private RoomExtensions _roomExtensions;
-
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private ILogger logger;
-
- public void prepareCodeTargetPaths(final Resource resource) {
- Set<String> pathes = new HashSet<String>();
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- EList<RoomModel> _models = ((Root) e).getModels();
- for (final RoomModel mdl : _models) {
- {
- final String tgtpath = this._roomExtensions.getGenerationTargetPath(mdl);
- if (((!Objects.equal(tgtpath, null)) && (!tgtpath.isEmpty()))) {
- pathes.add(tgtpath);
- }
- }
- }
- }
- }
- this.prepare(pathes);
- }
-
- public void prepareDocTargetPaths(final Resource resource) {
- Set<String> pathes = new HashSet<String>();
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- EList<RoomModel> _models = ((Root) e).getModels();
- for (final RoomModel mdl : _models) {
- {
- final String tgtpath = this._roomExtensions.getDocGenerationTargetPath(mdl);
- if (((!Objects.equal(tgtpath, null)) && (!tgtpath.isEmpty()))) {
- pathes.add(tgtpath);
- }
- }
- }
- }
- }
- this.prepare(pathes);
- }
-
- /**
- * Recursively erase all folders receiving generated code
- * and place a readme file in those folders.
- * The folders are determined from the used models of every generator
- * model found in the resource.
- *
- * @param resource a {@link Resource}
- */
- public void prepare(final Collection<String> pathes) {
- for (final String path : pathes) {
- {
- this.logger.logInfo(("clearing " + path));
- File f = new File(path);
- this.eraseContents(f);
- this.fileAccess.setOutputPath(path);
- CharSequence _readmeText = this.readmeText();
- this.fileAccess.generateFile("readme.txt", _readmeText);
- }
- }
- }
-
- private void eraseContents(final File f) {
- boolean _isDirectory = f.isDirectory();
- if (_isDirectory) {
- File[] children = f.listFiles();
- for (final File child : children) {
- boolean _not = (!(child.isDirectory() && child.getName().equals("images")));
- if (_not) {
- this.eraseContents(child);
- child.delete();
- }
- }
- }
- }
-
- private CharSequence readmeText() {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("This directory is an eTrice code generation target.");
- _builder.newLine();
- _builder.append("It will be erased every time the generator is executed.");
- _builder.newLine();
- _builder.newLine();
- _builder.append("DO NOT PLACE OTHER FILES HERE!");
- _builder.newLine();
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
deleted file mode 100644
index 4c6cebeb3..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ /dev/null
@@ -1,912 +0,0 @@
-/**
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- * Thomas Schuetz (refactoring, adapted for other target languages)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorContainerClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ClassStructor;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.Operation;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Extension;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-/**
- * A collection of methods for generation of user code, attributes with getters and setters
- * and operations.
- */
-@Singleton
-@SuppressWarnings("all")
-public class ProcedureHelpers {
- protected final String NEWLINE = System.getProperty("line.separator");
-
- @Inject
- @Extension
- protected RoomHelpers _roomHelpers;
-
- @Inject
- @Extension
- protected TypeHelpers _typeHelpers;
-
- @Inject
- protected ILanguageExtension languageExt;
-
- @Inject
- protected ILogger logger;
-
- /**
- * @param dc a {@link DataClass}
- * @param id 0, 1 or 2 for the corresponding user codes
- * @return the generated code
- */
- public CharSequence userCode(final DataClass dc, final int id) {
- CharSequence _switchResult = null;
- switch (id) {
- case 1:
- String _deepUserCode1 = this._roomHelpers.getDeepUserCode1(dc);
- _switchResult = this.userCode(_deepUserCode1);
- break;
- case 2:
- String _deepUserCode2 = this._roomHelpers.getDeepUserCode2(dc);
- _switchResult = this.userCode(_deepUserCode2);
- break;
- case 3:
- String _deepUserCode3 = this._roomHelpers.getDeepUserCode3(dc);
- _switchResult = this.userCode(_deepUserCode3);
- break;
- }
- return _switchResult;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param id 0, 1 or 2 for the corresponding user codes
- * @return the generated code
- */
- public CharSequence userCode(final ProtocolClass pc, final int id) {
- CharSequence _switchResult = null;
- switch (id) {
- case 1:
- String _deepUserCode1 = this._roomHelpers.getDeepUserCode1(pc);
- _switchResult = this.userCode(_deepUserCode1);
- break;
- case 2:
- String _deepUserCode2 = this._roomHelpers.getDeepUserCode2(pc);
- _switchResult = this.userCode(_deepUserCode2);
- break;
- case 3:
- String _deepUserCode3 = this._roomHelpers.getDeepUserCode3(pc);
- _switchResult = this.userCode(_deepUserCode3);
- break;
- }
- return _switchResult;
- }
-
- /**
- * @param ac an {@link ActorContainerClass}
- * @param id 0, 1 or 2 for the corresponding user codes
- * @return the generated code
- */
- public CharSequence userCode(final ActorContainerClass ac, final int id, final boolean includeInherited) {
- CharSequence _xifexpression = null;
- if (includeInherited) {
- CharSequence _switchResult = null;
- switch (id) {
- case 1:
- String _deepUserCode1 = this._roomHelpers.getDeepUserCode1(ac);
- _switchResult = this.userCode(_deepUserCode1);
- break;
- case 2:
- String _deepUserCode2 = this._roomHelpers.getDeepUserCode2(ac);
- _switchResult = this.userCode(_deepUserCode2);
- break;
- case 3:
- String _deepUserCode3 = this._roomHelpers.getDeepUserCode3(ac);
- _switchResult = this.userCode(_deepUserCode3);
- break;
- }
- _xifexpression = _switchResult;
- } else {
- CharSequence _switchResult_1 = null;
- switch (id) {
- case 1:
- DetailCode _userCode1 = ac.getUserCode1();
- _switchResult_1 = this.userCode(_userCode1);
- break;
- case 2:
- DetailCode _userCode2 = ac.getUserCode2();
- _switchResult_1 = this.userCode(_userCode2);
- break;
- case 3:
- DetailCode _userCode3 = ac.getUserCode3();
- _switchResult_1 = this.userCode(_userCode3);
- break;
- }
- _xifexpression = _switchResult_1;
- }
- return _xifexpression;
- }
-
- /**
- * @param dc some {@link DetailCode}
- * @return a string containing the expanded code surrounded by
- * comments (no tag replacement will happen)
- */
- public CharSequence userCode(final DetailCode dc) {
- String _detailCode = this._roomHelpers.getDetailCode(dc);
- return this.userCode(_detailCode);
- }
-
- private CharSequence userCode(final String code) {
- StringConcatenation _builder = new StringConcatenation();
- {
- if (((!Objects.equal(code, null)) && (!code.isEmpty()))) {
- _builder.append("/*--------------------- begin user code ---------------------*/");
- _builder.newLine();
- _builder.append(code, "");
- _builder.newLineIfNotEmpty();
- _builder.append("/*--------------------- end user code ---------------------*/");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- /**
- * @param attributes a list of {@link Attribute}s
- * @return code declaring the attributes
- */
- public CharSequence attributes(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/*--------------------- attributes ---------------------*/");
- _builder.newLine();
- {
- for(final Attribute it : attributes) {
- CharSequence _attributeDeclaration = this.attributeDeclaration(it);
- _builder.append(_attributeDeclaration, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- /**
- * @param attribute an {@link Attribute}
- * @return the code declaring the attribute
- */
- public CharSequence attributeDeclaration(final Attribute attribute) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelPublic = this.languageExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- _builder.append(" ");
- String _declarationString = this.declarationString(attribute);
- _builder.append(_declarationString, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- /**
- * @param attribute an {@link Attribute}
- * @return the code for an array initializer
- */
- public String arrayInitializer(final Attribute att) {
- String _xifexpression = null;
- String _defaultValueLiteral = att.getDefaultValueLiteral();
- boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
- if (_notEquals) {
- _xifexpression = att.getDefaultValueLiteral();
- } else {
- RefableType _type = att.getType();
- DataType _type_1 = _type.getType();
- _xifexpression = this.languageExt.defaultValue(_type_1);
- }
- final String dflt = _xifexpression;
- boolean _startsWith = dflt.startsWith("{");
- if (_startsWith) {
- String[] _split = dflt.split(",");
- int _size = ((List<String>)Conversions.doWrapArray(_split)).size();
- int _size_1 = att.getSize();
- boolean _notEquals_1 = (_size != _size_1);
- if (_notEquals_1) {
- String _name = att.getName();
- String _plus = ("WARNING: array size determined by initializer differs from attribute size (" + _name);
- String _plus_1 = (_plus + "[");
- int _size_2 = att.getSize();
- String _plus_2 = (_plus_1 + Integer.valueOf(_size_2));
- String _plus_3 = (_plus_2 + "] <-> ");
- String _plus_4 = (_plus_3 + dflt);
- String _plus_5 = (_plus_4 + ")");
- this.logger.logInfo(_plus_5);
- }
- return dflt;
- }
- String result = "{";
- int i = 0;
- while ((i < att.getSize())) {
- {
- result = (result + dflt);
- i = (i + 1);
- int _size_3 = att.getSize();
- boolean _lessThan = (i < _size_3);
- if (_lessThan) {
- result = (result + ", ");
- }
- }
- }
- return (result + "}");
- }
-
- /**
- * @param EnumTest a list of {@link Attribute}s
- * @param classname the name of the defining class
- * @return code declaring setters and getters for the attributes
- */
- public CharSequence attributeSettersGettersDeclaration(final List<Attribute> attributes, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* --------------------- attribute setters and getters */");
- _builder.newLine();
- {
- for(final Attribute attribute : attributes) {
- CharSequence _setterHeader = this.setterHeader(attribute, classname);
- _builder.append(_setterHeader, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- CharSequence _terHeader = this.getterHeader(attribute, classname);
- _builder.append(_terHeader, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- /**
- * @param EnumTest a list of {@link Attribute}s
- * @param classname the name of the defining class
- * @return code defining setters and getters for the attributes
- */
- public CharSequence attributeSettersGettersImplementation(final List<Attribute> attributes, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* --------------------- attribute setters and getters */");
- _builder.newLine();
- {
- for(final Attribute attribute : attributes) {
- CharSequence _setterHeader = this.setterHeader(attribute, classname);
- _builder.append(_setterHeader, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- String _memberAccess = this.languageExt.memberAccess();
- _builder.append(_memberAccess, "\t ");
- String _name = attribute.getName();
- _builder.append(_name, "\t ");
- _builder.append(" = ");
- String _name_1 = attribute.getName();
- _builder.append(_name_1, "\t ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- CharSequence _terHeader = this.getterHeader(attribute, classname);
- _builder.append(_terHeader, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return ");
- String _memberAccess_1 = this.languageExt.memberAccess();
- _builder.append(_memberAccess_1, "\t");
- String _name_2 = attribute.getName();
- _builder.append(_name_2, "\t");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- /**
- * @param attribute an {@link Attribute}
- * @param classname the name of the defining class
- * @return code for the attribute setter declaration
- */
- protected CharSequence setterHeader(final Attribute attribute, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelPublic = this.languageExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- _builder.append("void set");
- String _name = attribute.getName();
- String _firstUpper = StringExtensions.toFirstUpper(_name);
- _builder.append(_firstUpper, "");
- _builder.append("(");
- String _selfPointer = this.languageExt.selfPointer(classname, true);
- _builder.append(_selfPointer, "");
- String _argList = this.argList(Collections.<Attribute>unmodifiableList(CollectionLiterals.<Attribute>newArrayList(attribute)));
- _builder.append(_argList, "");
- _builder.append(")");
- return _builder;
- }
-
- /**
- * @param attribute an {@link Attribute}
- * @param classname the name of the defining class
- * @return code for the attribute getter declaration
- */
- protected CharSequence getterHeader(final Attribute attribute, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelPublic = this.languageExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- String _signatureString = this.signatureString(attribute);
- _builder.append(_signatureString, "");
- _builder.append(" get");
- String _name = attribute.getName();
- String _firstUpper = StringExtensions.toFirstUpper(_name);
- _builder.append(_firstUpper, "");
- _builder.append("(");
- String _selfPointer = this.languageExt.selfPointer(classname, false);
- _builder.append(_selfPointer, "");
- _builder.append(")");
- return _builder;
- }
-
- /**
- * @param attributes a list of {@link Attribute}s
- * @return an argument list for the attributes
- */
- public String argList(final Iterable<Attribute> attributes) {
- final Function1<Attribute, String> _function = (Attribute it) -> {
- String _signatureString = this.signatureString(it);
- String _plus = (_signatureString + " ");
- String _name = it.getName();
- return (_plus + _name);
- };
- Iterable<String> _map = IterableExtensions.<Attribute, String>map(attributes, _function);
- return IterableExtensions.join(_map, ", ");
- }
-
- /**
- * @param EnumTest an iterable of {@link Attribute}s representing a path
- * @param classname the name of the defining class
- * @return the invocation code for the call of a setter
- */
- public CharSequence invokeGetters(final Iterable<Attribute> path, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : path) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(".", "");
- }
- String _name = a.getName();
- CharSequence _invokeGetter = this.invokeGetter(_name, classname);
- _builder.append(_invokeGetter, "");
- }
- }
- return _builder;
- }
-
- /**
- * @param typeName the type name of the attribute
- * @param name the name of the attribute
- * @param classname the name of the type defining the getter
- * @return code defining the attribute getter
- */
- public CharSequence getterImplementation(final String typeName, final String name, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelPublic = this.languageExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- _builder.append(typeName, "");
- _builder.append(" get");
- String _firstUpper = StringExtensions.toFirstUpper(name);
- _builder.append(_firstUpper, "");
- _builder.append(" (");
- String _selfPointer = this.languageExt.selfPointer(classname, false);
- _builder.append(_selfPointer, "");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return ");
- String _memberAccess = this.languageExt.memberAccess();
- _builder.append(_memberAccess, "\t");
- _builder.append(name, "\t");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- /**
- * @param name the name of the attribute
- * @param classname the name of the type defining the getter
- * @return code defining the getter call
- */
- public CharSequence invokeGetter(final String name, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("get");
- String _firstUpper = StringExtensions.toFirstUpper(name);
- _builder.append(_firstUpper, "");
- _builder.append("(");
- String _selfPointer = this.languageExt.selfPointer(classname, true);
- _builder.append(_selfPointer, "");
- _builder.append(")");
- return _builder;
- }
-
- /**
- * @param name the name of the attribute
- * @param classname the name of the type defining the getter
- * @param value the value to be assigned
- * @return code defining the setter call
- */
- public CharSequence invokeSetter(final String name, final String classname, final String value) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("set");
- String _firstUpper = StringExtensions.toFirstUpper(name);
- _builder.append(_firstUpper, "");
- _builder.append("(");
- String _selfPointer = this.languageExt.selfPointer(classname, true);
- _builder.append(_selfPointer, "");
- _builder.append(value, "");
- _builder.append(")");
- return _builder;
- }
-
- /**
- * @param operations a list of {@link Operation}s
- * @param classname the name of the type defining the getter
- * @return code declaring the operations
- */
- public CharSequence operationsDeclaration(final List<? extends Operation> operations, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/*--------------------- operations ---------------------*/");
- _builder.newLine();
- {
- for(final Operation operation : operations) {
- CharSequence _operationSignature = this.operationSignature(operation, classname, true);
- _builder.append(_operationSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- /**
- * @param operations a list of {@link Operation}s
- * @param classname the name of the type defining the getter
- * @return code defining the operations
- */
- public CharSequence operationsImplementation(final List<? extends Operation> operations, final String classname) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/*--------------------- operations ---------------------*/");
- _builder.newLine();
- {
- for(final Operation operation : operations) {
- CharSequence _operationSignature = this.operationSignature(operation, classname, false);
- _builder.append(_operationSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- AbstractGenerator _instance = AbstractGenerator.getInstance();
- DetailCode _detailCode = operation.getDetailCode();
- String _translatedCode = _instance.getTranslatedCode(_detailCode);
- _builder.append(_translatedCode, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- public CharSequence asBlock(final CharSequence str) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append(str, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- /**
- * invoke user structor, if (inherited) present - <b>C only</b>
- *
- * @param cls {@link ActorClass} or {@link DataClass}
- * @param args self pointer to instance
- */
- public String invokeUserStructor(final RoomClass cls, final String args, final boolean ctor) {
- boolean _usesInheritance = this.languageExt.usesInheritance();
- boolean _not = (!_usesInheritance);
- List<ClassStructor> _structors = this.getStructors(cls, _not);
- final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> {
- boolean _isConstructor = it.isConstructor();
- return Boolean.valueOf((_isConstructor == ctor));
- };
- boolean _exists = IterableExtensions.<ClassStructor>exists(_structors, _function);
- if (_exists) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = cls.getName();
- String _xifexpression = null;
- if (ctor) {
- _xifexpression = "ctor";
- } else {
- _xifexpression = "dtor";
- }
- String _memberInDeclaration = this.languageExt.memberInDeclaration(_name, _xifexpression);
- _builder.append(_memberInDeclaration, "");
- _builder.append("(");
- _builder.append(args, "");
- _builder.append(");");
- return _builder.toString();
- }
- return "";
- }
-
- /**
- * declaration of user constructor + destructor, if (inherited) present - <b>C only</b>
- *
- * @param cls {@link ActorClass} or {@link DataClass}
- */
- public String userStructorsDeclaration(final RoomClass cls) {
- String _xblockexpression = null;
- {
- String _name = cls.getName();
- final String namePrefix = this.languageExt.operationScope(_name, true);
- final ArrayList<String> declBlock = CollectionLiterals.<String>newArrayList();
- declBlock.add("/*--------------------- user constructor/destructor ---------------------*/");
- boolean _usesInheritance = this.languageExt.usesInheritance();
- boolean _not = (!_usesInheritance);
- List<ClassStructor> _structors = this.getStructors(cls, _not);
- final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> {
- return Boolean.valueOf(it.isConstructor());
- };
- boolean _exists = IterableExtensions.<ClassStructor>exists(_structors, _function);
- if (_exists) {
- String _name_1 = cls.getName();
- CharSequence _functionSignature = this.functionSignature(_name_1, (namePrefix + "ctor"), "void", "");
- String _plus = (_functionSignature + ";");
- declBlock.add(_plus);
- }
- boolean _usesInheritance_1 = this.languageExt.usesInheritance();
- boolean _not_1 = (!_usesInheritance_1);
- List<ClassStructor> _structors_1 = this.getStructors(cls, _not_1);
- final Function1<ClassStructor, Boolean> _function_1 = (ClassStructor it) -> {
- boolean _isConstructor = it.isConstructor();
- return Boolean.valueOf((!_isConstructor));
- };
- boolean _exists_1 = IterableExtensions.<ClassStructor>exists(_structors_1, _function_1);
- if (_exists_1) {
- String _name_2 = cls.getName();
- CharSequence _functionSignature_1 = this.functionSignature(_name_2, (namePrefix + "dtor"), "void", "");
- String _plus_1 = (_functionSignature_1 + ";");
- declBlock.add(_plus_1);
- }
- _xblockexpression = IterableExtensions.join(declBlock, this.NEWLINE);
- }
- return _xblockexpression;
- }
-
- /**
- * implementation of user constructor + destructor, if (inherited) present - <b>C only</b>
- *
- * @param cls {@link ActorClass} or {@link DataClass}
- */
- public String userStructorsImplementation(final RoomClass cls) {
- String _xblockexpression = null;
- {
- final ArrayList<String> declBlock = CollectionLiterals.<String>newArrayList();
- declBlock.add("/*--------------------- user constructor/destructor ---------------------*/");
- String _userStuctorImplementation = this.userStuctorImplementation(cls, true);
- declBlock.add(_userStuctorImplementation);
- String _userStuctorImplementation_1 = this.userStuctorImplementation(cls, false);
- declBlock.add(_userStuctorImplementation_1);
- Iterable<String> _filterNull = IterableExtensions.<String>filterNull(declBlock);
- _xblockexpression = IterableExtensions.join(_filterNull, this.NEWLINE);
- }
- return _xblockexpression;
- }
-
- protected String userStuctorImplementation(final RoomClass cls, final boolean ctor) {
- String _xblockexpression = null;
- {
- String _name = cls.getName();
- final String namePrefix = this.languageExt.operationScope(_name, false);
- boolean _usesInheritance = this.languageExt.usesInheritance();
- boolean _not = (!_usesInheritance);
- List<ClassStructor> _structors = this.getStructors(cls, _not);
- final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> {
- boolean _isConstructor = it.isConstructor();
- return Boolean.valueOf((_isConstructor == ctor));
- };
- boolean _exists = IterableExtensions.<ClassStructor>exists(_structors, _function);
- boolean _not_1 = (!_exists);
- if (_not_1) {
- return null;
- }
- StringConcatenation _builder = new StringConcatenation();
- String _name_1 = cls.getName();
- String _xifexpression = null;
- if (ctor) {
- _xifexpression = "ctor";
- } else {
- _xifexpression = "dtor";
- }
- String _plus = (namePrefix + _xifexpression);
- CharSequence _functionSignature = this.functionSignature(_name_1, _plus, "void", "");
- _builder.append(_functionSignature, "");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _userStructorBody = this.userStructorBody(cls, ctor);
- _builder.append(_userStructorBody, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = _builder.toString();
- }
- return _xblockexpression;
- }
-
- /**
- * implementation of user structor, if (inherited) present
- */
- public String userStructorBody(final RoomClass cls, final boolean ctor) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* user defined ");
- {
- if (ctor) {
- _builder.append("con");
- } else {
- _builder.append("de");
- }
- }
- _builder.append("structor body */");
- final String comment = _builder.toString();
- boolean _usesInheritance = this.languageExt.usesInheritance();
- boolean _not = (!_usesInheritance);
- List<ClassStructor> _structors = this.getStructors(cls, _not);
- final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> {
- boolean _isConstructor = it.isConstructor();
- return Boolean.valueOf((_isConstructor == ctor));
- };
- final Iterable<ClassStructor> implementedStructors = IterableExtensions.<ClassStructor>filter(_structors, _function);
- final Function1<ClassStructor, DetailCode> _function_1 = (ClassStructor it) -> {
- return it.getDetailCode();
- };
- Iterable<DetailCode> _map = IterableExtensions.<ClassStructor, DetailCode>map(implementedStructors, _function_1);
- final Function1<DetailCode, String> _function_2 = (DetailCode it) -> {
- AbstractGenerator _instance = AbstractGenerator.getInstance();
- return _instance.getTranslatedCode(it);
- };
- final Iterable<String> translatedCodes = IterableExtensions.<DetailCode, String>map(_map, _function_2);
- final Function1<String, CharSequence> _function_3 = (String it) -> {
- CharSequence _xifexpression = null;
- int _size = IterableExtensions.size(translatedCodes);
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
- _xifexpression = this.asBlock(it);
- } else {
- _xifexpression = it;
- }
- return _xifexpression;
- };
- Iterable<CharSequence> _map_1 = IterableExtensions.<String, CharSequence>map(translatedCodes, _function_3);
- String _join = IterableExtensions.join(_map_1);
- return ((comment + this.NEWLINE) + _join);
- }
-
- protected List<ClassStructor> getStructors(final RoomClass cls, final boolean inherited) {
- List<ClassStructor> _switchResult = null;
- final RoomClass it = cls;
- boolean _matched = false;
- if (it instanceof ActorClass) {
- if ((!inherited)) {
- _matched=true;
- _switchResult = ((ActorClass)it).getStructors();
- }
- }
- if (!_matched) {
- if (it instanceof DataClass) {
- if ((!inherited)) {
- _matched=true;
- _switchResult = ((DataClass)it).getStructors();
- }
- }
- }
- if (!_matched) {
- if (it instanceof ActorClass) {
- if (inherited) {
- _matched=true;
- _switchResult = this._roomHelpers.getAllStructors(((ActorClass)it));
- }
- }
- }
- if (!_matched) {
- if (it instanceof DataClass) {
- if (inherited) {
- _matched=true;
- _switchResult = this._roomHelpers.getAllStructors(((DataClass)it));
- }
- }
- }
- return _switchResult;
- }
-
- /**
- * @param operation an {@link Operation}
- * @return the operation signature (with special care for
- * constructor and destructor
- */
- protected CharSequence operationSignature(final Operation operation, final String classname, final boolean isDeclaration) {
- CharSequence _xblockexpression = null;
- {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<VarDecl> _arguments = operation.getArguments();
- boolean _hasElements = false;
- for(final VarDecl argument : _arguments) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType = argument.getRefType();
- String _signatureString = this.signatureString(_refType);
- _builder.append(_signatureString, "");
- _builder.append(" ");
- String _name = argument.getName();
- _builder.append(_name, "");
- }
- }
- final String arguments = _builder.toString();
- RefableType _returnType = operation.getReturnType();
- final String returnType = this.signatureString(_returnType);
- String _operationScope = this.languageExt.operationScope(classname, isDeclaration);
- String _name_1 = operation.getName();
- String _plus = (_operationScope + _name_1);
- _xblockexpression = this.functionSignature(classname, _plus, returnType, arguments);
- }
- return _xblockexpression;
- }
-
- /**
- * @param type a {@link RefableType}
- * @return a string for the type (also for pointers)
- */
- public String signatureString(final RefableType type) {
- String _switchResult = null;
- final RefableType it = type;
- boolean _matched = false;
- if (Objects.equal(it, null)) {
- _matched=true;
- _switchResult = "void";
- }
- if (!_matched) {
- boolean _isRef = it.isRef();
- if (_isRef) {
- _matched=true;
- DataType _type = type.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String _pointerLiteral = this.languageExt.pointerLiteral();
- _switchResult = (_typeName + _pointerLiteral);
- }
- }
- if (!_matched) {
- DataType _type_1 = type.getType();
- _switchResult = this._typeHelpers.typeName(_type_1);
- }
- return _switchResult;
- }
-
- public String signatureString(final Attribute attribute) {
- String _switchResult = null;
- final Attribute it = attribute;
- boolean _matched = false;
- int _size = it.getSize();
- boolean _greaterThan = (_size > 0);
- if (_greaterThan) {
- _matched=true;
- RefableType _type = it.getType();
- DataType _type_1 = _type.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- int _size_1 = it.getSize();
- RefableType _type_2 = it.getType();
- boolean _isRef = _type_2.isRef();
- _switchResult = this.languageExt.arrayType(_typeName, _size_1, _isRef);
- }
- if (!_matched) {
- RefableType _type_3 = it.getType();
- _switchResult = this.signatureString(_type_3);
- }
- return _switchResult;
- }
-
- /**
- * @param attribute a {@link Attribute}
- * @return a string for <code>type name</code>
- */
- public String declarationString(final Attribute attribute) {
- String _switchResult = null;
- final Attribute it = attribute;
- boolean _matched = false;
- int _size = it.getSize();
- boolean _greaterThan = (_size > 0);
- if (_greaterThan) {
- _matched=true;
- RefableType _type = it.getType();
- DataType _type_1 = _type.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- int _size_1 = it.getSize();
- RefableType _type_2 = it.getType();
- boolean _isRef = _type_2.isRef();
- String _name = it.getName();
- _switchResult = this.languageExt.arrayDeclaration(_typeName, _size_1, _isRef, _name);
- }
- if (!_matched) {
- RefableType _type_3 = it.getType();
- String _signatureString = this.signatureString(_type_3);
- String _plus = (_signatureString + " ");
- String _name_1 = it.getName();
- _switchResult = (_plus + _name_1);
- }
- return _switchResult;
- }
-
- protected CharSequence functionSignature(final String className, final String fullFctName, final String returnType, final String arguments) {
- StringConcatenation _builder = new StringConcatenation();
- String _accessLevelPublic = this.languageExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- _builder.append(" ");
- _builder.append(returnType, "");
- _builder.append(" ");
- _builder.append(fullFctName, "");
- _builder.append("(");
- boolean _isEmpty = arguments.isEmpty();
- boolean _not = (!_isEmpty);
- String _selfPointer = this.languageExt.selfPointer(className, _not);
- _builder.append(_selfPointer, "");
- _builder.append(arguments, "");
- _builder.append(")");
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
deleted file mode 100644
index 730f7758f..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/**
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Consumer;
-import javax.inject.Inject;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.PortInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.SAPInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.ServiceImplInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ExternalPort;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SAP;
-import org.eclipse.etrice.core.room.SPP;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers;
-import org.eclipse.etrice.generator.fsm.generic.FSMExtensions;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Extension;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-/**
- * collection of convenience functions for code generation
- */
-@Singleton
-@SuppressWarnings("all")
-public class RoomExtensions extends FSMExtensions {
- public final String NEWLINE = System.getProperty("line.separator");
-
- private static String genDir = "/src-gen/";
-
- private static String genInfoDir = "/src-gen-info/";
-
- private static String genDocDir = "/doc-gen/";
-
- @Inject
- @Extension
- protected RoomHelpers _roomHelpers;
-
- public static String setDefaultGenDir() {
- return RoomExtensions.genDir = "/src-gen/";
- }
-
- public static String setDefaultGenInfoDir() {
- return RoomExtensions.genInfoDir = "/src-gen-info/";
- }
-
- public static String setDefaultGenDocDir() {
- return RoomExtensions.genDocDir = "/doc-gen/";
- }
-
- public static String setGenDir(final String dir) {
- return RoomExtensions.genDir = (("/" + dir) + "/");
- }
-
- public static String setGenInfoDir(final String dir) {
- return RoomExtensions.genInfoDir = (("/" + dir) + "/");
- }
-
- public static String setGenDocDir(final String dir) {
- return RoomExtensions.genDocDir = (("/" + dir) + "/");
- }
-
- /**
- * a specialized version of {@link #union(Iterable, Iterable)}
- * @param in1 an iterable of type T
- * @param in2 a second iterable of type T
- * @return the union of the two iterables as new list
- */
- public List<Port> punion(final Iterable<Port> in1, final Iterable<ExternalPort> in2) {
- final ArrayList<Port> ret = new ArrayList<Port>();
- final Consumer<ExternalPort> _function = (ExternalPort e) -> {
- Port _interfacePort = e.getInterfacePort();
- ret.add(_interfacePort);
- };
- in2.forEach(_function);
- Iterables.<Port>addAll(ret, in1);
- return ret;
- }
-
- /**
- * @return the relative path to the destination folder for the generated code
- */
- public String getGenerationPathSegment() {
- return RoomExtensions.genDir;
- }
-
- /**
- * @return the relative path to the destination folder for the generated code
- */
- public String getGenerationInfoSegment() {
- return RoomExtensions.genInfoDir;
- }
-
- /**
- * @return the relative path to the destination folder for the generated documentation
- */
- public String getDocGenerationPathSegment() {
- return RoomExtensions.genDocDir;
- }
-
- /**
- * @param e an {@link EObject}
- * @return the URI of the EObject's resource as file string
- * (or an empty string if no such resource exists)
- */
- public String getModelPath(final EObject e) {
- Resource res = e.eResource();
- boolean _equals = Objects.equal(res, null);
- if (_equals) {
- return "";
- } else {
- URI _uRI = res.getURI();
- return _uRI.toFileString();
- }
- }
-
- /**
- * @param rc a {@link RoomClass}
- * @return the name of the room model which also serves as a package name
- */
- public String getPackage(final RoomClass rc) {
- EObject _eContainer = rc.eContainer();
- return ((RoomModel) _eContainer).getName();
- }
-
- /**
- * @param rc a {@link RoomClass}
- * @return the name of the room model followed by the class name and all . replaced with _
- */
- public String getFullyQualifiedName(final RoomClass rc) {
- String _package = this.getPackage(rc);
- String _replace = _package.replace(".", "_");
- String _plus = (_replace + "_");
- String _name = rc.getName();
- return (_plus + _name);
- }
-
- /**
- * @param packageName a dot (.) separated package anem
- * @return the input with dots replaced with slashes (/)
- */
- public String getPathFromPackage(final String packageName) {
- String _replaceAll = packageName.replaceAll("\\.", "/");
- return (_replaceAll + "/");
- }
-
- /**
- * @param rc a {@link RoomClass}
- * @return the relative folder path of the package
- * (as defined by the Java convention)
- */
- public String getPath(final RoomClass rc) {
- String _package = this.getPackage(rc);
- return this.getPathFromPackage(_package);
- }
-
- /**
- * @param e an {@link EObject}
- * @return the path of the Eclipse project containing the EObject's resource
- */
- public String getProjectPath(final EObject e) {
- final URI res = FileSystemHelpers.getProjectURI(e);
- boolean _equals = Objects.equal(res, null);
- if (_equals) {
- return "";
- }
- return res.toFileString();
- }
-
- /**
- * @param e an {@link EObject}
- * @return the concatenation of the object's project path
- * with the {@link #getGenerationPathSegment()}
- */
- public String getGenerationTargetPath(final EObject e) {
- String _projectPath = this.getProjectPath(e);
- String _generationPathSegment = this.getGenerationPathSegment();
- return (_projectPath + _generationPathSegment);
- }
-
- /**
- * @param e an {@link EObject}
- * @return the concatenation of the object's project path
- * with the {@link #getGenerationInfoSegment()}
- */
- public String getGenerationInfoPath(final EObject e) {
- String _projectPath = this.getProjectPath(e);
- String _generationInfoSegment = this.getGenerationInfoSegment();
- return (_projectPath + _generationInfoSegment);
- }
-
- /**
- * @param e an {@link EObject}
- * @return the concatenation of the objects project path
- * with the {@link #getDocGenerationPathSegment()}
- */
- public String getDocGenerationTargetPath(final EObject e) {
- String _projectPath = this.getProjectPath(e);
- String _docGenerationPathSegment = this.getDocGenerationPathSegment();
- return (_projectPath + _docGenerationPathSegment);
- }
-
- /**
- * makes a valid identifier from a path string
- * @param path a slash (/) separated path
- * @return the path with slashes (and colons as in replicated actors) replaced by underscores (_)
- */
- public String getPathName(final String path) {
- String _replaceAll = path.replaceAll("/", "_");
- return _replaceAll.replaceAll(":", "_");
- }
-
- /**
- * @param p a {@link Port}
- * @return a name for the associated port class
- */
- protected String _getPortClassName(final Port p) {
- String _xifexpression = null;
- GeneralProtocolClass _protocol = p.getProtocol();
- if ((_protocol instanceof ProtocolClass)) {
- GeneralProtocolClass _protocol_1 = p.getProtocol();
- boolean _isConjugated = p.isConjugated();
- boolean _isReplicated = p.isReplicated();
- _xifexpression = this.getPortClassName(((ProtocolClass) _protocol_1), _isConjugated, _isReplicated);
- } else {
- _xifexpression = "";
- }
- return _xifexpression;
- }
-
- /**
- * @param p a {@link ExternalPort}
- * @return a name for the associated port class
- */
- protected String _getPortClassName(final ExternalPort p) {
- Port _interfacePort = p.getInterfacePort();
- return this.getPortClassName(_interfacePort);
- }
-
- /**
- * @param sap a {@link SAP}
- * @return a name for the associated port class
- */
- protected String _getPortClassName(final SAP sap) {
- ProtocolClass _protocol = sap.getProtocol();
- return this.getPortClassName(_protocol, true);
- }
-
- /**
- * @param spp a {@link SPP}
- * @return a name for the associated port class
- */
- protected String _getPortClassName(final SPP spp) {
- ProtocolClass _protocol = spp.getProtocol();
- return this.getPortClassName(_protocol, false, true);
- }
-
- /**
- * @param svc a {@link ServiceImplementation}
- * @return a name for the associated port class
- */
- protected String _getPortClassName(final ServiceImplementation svc) {
- SPP _spp = svc.getSpp();
- ProtocolClass _protocol = _spp.getProtocol();
- return this.getPortClassName(_protocol, false, true);
- }
-
- /**
- * @param p a {@link ProtocolClass}
- * @param conj if <code>true</code> consider conjugate port, else regular
- * @return a name for the associated port class
- */
- public String getPortClassName(final ProtocolClass p, final boolean conj) {
- return this.getPortClassName(p, conj, false);
- }
-
- /**
- * @param p a {@link ProtocolClass}
- * @param conj if <code>true</code> consider conjugate port, else regular
- * @param repl if <code>true</code> class name for replicated port
- * else for plain port
- * @return a name for the associated port class
- */
- public String getPortClassName(final ProtocolClass p, final boolean conj, final boolean repl) {
- String _name = p.getName();
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "Conj";
- } else {
- _xifexpression = "";
- }
- String _plus = (_name + _xifexpression);
- String _xifexpression_1 = null;
- if (repl) {
- _xifexpression_1 = "Repl";
- } else {
- _xifexpression_1 = "";
- }
- String _plus_1 = (_plus + _xifexpression_1);
- return (_plus_1 + "Port");
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired {@link PortClass}
- * @return the port class
- */
- public PortClass getPortClass(final ProtocolClass pc, final boolean conj) {
- if (conj) {
- return pc.getConjugated();
- } else {
- return pc.getRegular();
- }
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired {@link PortClass}
- * @return the port class
- */
- public List<PortClass> getAllPortClasses(final ProtocolClass pc, final boolean conj) {
- final ArrayList<PortClass> result = CollectionLiterals.<PortClass>newArrayList();
- ProtocolClass protocol = pc;
- while ((!Objects.equal(protocol, null))) {
- {
- if (conj) {
- PortClass _conjugated = protocol.getConjugated();
- boolean _notEquals = (!Objects.equal(_conjugated, null));
- if (_notEquals) {
- PortClass _conjugated_1 = protocol.getConjugated();
- result.add(_conjugated_1);
- }
- } else {
- PortClass _regular = protocol.getRegular();
- boolean _notEquals_1 = (!Objects.equal(_regular, null));
- if (_notEquals_1) {
- PortClass _regular_1 = protocol.getRegular();
- result.add(_regular_1);
- }
- }
- ProtocolClass _base = protocol.getBase();
- protocol = _base;
- }
- }
- return result;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return <code>true</code> if a send handler is specified for this direction
- */
- public boolean handlesSend(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _equals = Objects.equal(_portClass, null);
- if (_equals) {
- return false;
- } else {
- final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj);
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMessages.contains(_msg);
- if (_contains) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return <code>true</code> if a receive handler is specified for this direction
- */
- public boolean handlesReceive(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _equals = Objects.equal(_portClass, null);
- if (_equals) {
- return false;
- } else {
- final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMessages.contains(_msg);
- if (_contains) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return <code>true</code> if a receive handler is specified for this direction including base classes
- */
- public boolean handlesReceiveIncludingSuper(final ProtocolClass pc, final boolean conj) {
- final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
- final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
- for (final PortClass p : allPortClasses) {
- EList<MessageHandler> _msgHandlers = p.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMessages.contains(_msg);
- if (_contains) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @param iii an {@link InterfaceItemInstance}
- * @return <code>true</code> if the interface item instance is logically conjugate
- */
- public boolean isConjugated(final InterfaceItemInstance iii) {
- if ((iii instanceof PortInstance)) {
- Port _port = ((PortInstance) iii).getPort();
- return _port.isConjugated();
- } else {
- if ((iii instanceof SAPInstance)) {
- return true;
- } else {
- if ((iii instanceof ServiceImplInstance)) {
- return false;
- } else {
- return false;
- }
- }
- }
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return a list of defined receive {@link MessageHandler} for this direction
- */
- public List<MessageHandler> getReceiveHandlers(final ProtocolClass pc, final boolean conj) {
- final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _notEquals = (!Objects.equal(_portClass, null));
- if (_notEquals) {
- final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMessages.contains(_msg);
- if (_contains) {
- res.add(hdlr);
- }
- }
- }
- return res;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return a list of defined receive {@link MessageHandler} for this direction including base classes
- */
- public List<MessageHandler> getReceiveHandlersIncludingSuper(final ProtocolClass pc, final boolean conj) {
- final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
- final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
- final List<Message> allMsgs = this._roomHelpers.getAllMessages(pc, (!conj));
- for (final PortClass p : allPortClasses) {
- EList<MessageHandler> _msgHandlers = p.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMsgs.contains(_msg);
- if (_contains) {
- res.add(hdlr);
- }
- }
- }
- return res;
- }
-
- /**
- * @param pc a {@link ProtocolClass}
- * @param conj flag indicating the desired communication direction
- * @return a list of defined send {@link MessageHandler} for this direction
- */
- public List<MessageHandler> getSendHandlers(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _equals = Objects.equal(_portClass, null);
- if (_equals) {
- return Collections.<MessageHandler>emptyList();
- } else {
- final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
- final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj);
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
- for (final MessageHandler hdlr : _safeList) {
- Message _msg = hdlr.getMsg();
- boolean _contains = allMessages.contains(_msg);
- if (_contains) {
- res.add(hdlr);
- }
- }
- return res;
- }
- }
-
- /**
- * @param m a {@link Message}
- * @param conj flag indicating the desired communication direction
- * @return a send {@link MessageHandler} for this direction if it is defined, <code>null</code> else
- */
- public MessageHandler getSendHandler(final Message m, final boolean conj) {
- EObject _eContainer = m.eContainer();
- List<MessageHandler> _sendHandlers = this.getSendHandlers(((ProtocolClass) _eContainer), conj);
- final Function1<MessageHandler, Boolean> _function = (MessageHandler e) -> {
- Message _msg = e.getMsg();
- return Boolean.valueOf(Objects.equal(_msg, m));
- };
- return IterableExtensions.<MessageHandler>findFirst(_sendHandlers, _function);
- }
-
- /**
- * @param m a {@link Message}
- * @return <code>true</code> if this message is an incoming message
- */
- public boolean isIncoming(final Message m) {
- EObject _eContainer = m.eContainer();
- List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(((ProtocolClass) _eContainer));
- return _allIncomingMessages.contains(m);
- }
-
- /**
- * @param m a {@link Message}
- * @return a string that can be used as identifier for the message. It is prefixed with IN_ or OUT_
- * to avoid ambiguities
- */
- public String getCodeName(final Message m) {
- boolean _isIncoming = this.isIncoming(m);
- if (_isIncoming) {
- String _name = m.getName();
- return ("IN_" + _name);
- } else {
- String _name_1 = m.getName();
- return ("OUT_" + _name_1);
- }
- }
-
- /**
- * @param ac an {@link ActorClass}
- * @return <code>true</code> if an operation named 'stop' is defined with a void argument list and
- * void return type
- */
- public boolean overridesStop(final ActorClass ac) {
- return (IterableExtensions.<StandardOperation>exists(ac.getOperations(), ((Function1<StandardOperation, Boolean>) (StandardOperation e) -> {
- return Boolean.valueOf(((Objects.equal(e.getName(), "stop") && e.getArguments().isEmpty()) && Objects.equal(e.getReturnType(), null)));
- })) || ((!Objects.equal(ac.getActorBase(), null)) && this.overridesStop(ac.getActorBase())));
- }
-
- public BasicEList<AbstractInstance> getAllSubInstances(final StructureInstance ssi) {
- final BasicEList<AbstractInstance> result = new BasicEList<AbstractInstance>();
- final TreeIterator<EObject> it = ssi.eAllContents();
- while (it.hasNext()) {
- {
- final EObject obj = it.next();
- if ((obj instanceof AbstractInstance)) {
- result.add(((AbstractInstance) obj));
- }
- }
- }
- return result;
- }
-
- public static List<MessageHandler> getSafeList(final List<MessageHandler> msgHandlers) {
- List<MessageHandler> _xifexpression = null;
- boolean _equals = Objects.equal(msgHandlers, null);
- if (_equals) {
- _xifexpression = Collections.<MessageHandler>emptyList();
- } else {
- _xifexpression = msgHandlers;
- }
- return _xifexpression;
- }
-
- public String getPortClassName(final EObject p) {
- if (p instanceof Port) {
- return _getPortClassName((Port)p);
- } else if (p instanceof SAP) {
- return _getPortClassName((SAP)p);
- } else if (p instanceof SPP) {
- return _getPortClassName((SPP)p);
- } else if (p instanceof ExternalPort) {
- return _getPortClassName((ExternalPort)p);
- } else if (p instanceof ServiceImplementation) {
- return _getPortClassName((ServiceImplementation)p);
- } else {
- throw new IllegalArgumentException("Unhandled parameter types: " +
- Arrays.<Object>asList(p).toString());
- }
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java
deleted file mode 100644
index 5df095c60..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java
+++ /dev/null
@@ -1,291 +0,0 @@
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Consumer;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.etrice.core.common.base.Annotation;
-import org.eclipse.etrice.core.common.base.AnnotationType;
-import org.eclipse.etrice.core.etmap.eTMap.ETMapFactory;
-import org.eclipse.etrice.core.etmap.eTMap.Mapping;
-import org.eclipse.etrice.core.etmap.eTMap.MappingModel;
-import org.eclipse.etrice.core.etmap.eTMap.SubSystemMapping;
-import org.eclipse.etrice.core.etphys.eTPhys.NodeRef;
-import org.eclipse.etrice.core.etphys.eTPhys.PhysicalModel;
-import org.eclipse.etrice.core.etphys.eTPhys.PhysicalSystem;
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorRef;
-import org.eclipse.etrice.core.room.LogicalSystem;
-import org.eclipse.etrice.core.room.RoomFactory;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.core.room.SubSystemRef;
-import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Extension;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.Functions.Function2;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-
-@FinalFieldsConstructor
-@SuppressWarnings("all")
-public class TestInstanceCreator {
- private final static String ANNOTATION_TYPE_NAME = "TestInstance";
-
- @Extension
- private final RoomFactory _roomFactory = RoomFactory.eINSTANCE;
-
- @Extension
- private final ETMapFactory _eTMapFactory = ETMapFactory.eINSTANCE;
-
- private final ILogger logger;
-
- /**
- * Creates instance and mapping for classes having <code>@TestInstance</code> annotation:
- * <p>
- * a) In case of a single SubSystemClass, a new LogicalSystem with a SubSystemRef will be created<br>
- * b) For ActorClasses, one new SubSystem- and LogicalSystem with necessary refs will be created</br>
- * Resulting ROOM classes are stored in new RoomModel within a new memory-only resource.</br>
- * Resulting mapping is stored in a new MappingModel within a new memory-only resource.</br>
- * </p>
- *
- * Note: currently only one class having <code>@TestInstance</code> annotation is supported
- *
- * @param rs ResourceSet for new resources
- * @return false, if creation failed and generation should stop
- */
- public List<Resource> createInstancesAndMapping(final ResourceSet rs) {
- final ArrayList<RoomModel> roomModels = CollectionLiterals.<RoomModel>newArrayList();
- final ArrayList<PhysicalModel> physModels = CollectionLiterals.<PhysicalModel>newArrayList();
- EList<Resource> _resources = rs.getResources();
- final Consumer<Resource> _function = (Resource it) -> {
- EList<EObject> _contents = it.getContents();
- final Function1<EObject, Boolean> _function_1 = (EObject it_1) -> {
- boolean _switchResult = false;
- boolean _matched = false;
- if (it_1 instanceof RoomModel) {
- _matched=true;
- _switchResult = roomModels.add(((RoomModel)it_1));
- }
- if (!_matched) {
- if (it_1 instanceof PhysicalModel) {
- _matched=true;
- _switchResult = physModels.add(((PhysicalModel)it_1));
- }
- }
- return Boolean.valueOf(_switchResult);
- };
- IterableExtensions.<EObject>forall(_contents, _function_1);
- };
- _resources.forEach(_function);
- ArrayList<SubSystemClass> _newArrayList = CollectionLiterals.<SubSystemClass>newArrayList();
- final Function2<ArrayList<SubSystemClass>, RoomModel, ArrayList<SubSystemClass>> _function_1 = (ArrayList<SubSystemClass> list, RoomModel model) -> {
- EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses();
- final Function1<SubSystemClass, Boolean> _function_2 = (SubSystemClass it) -> {
- return Boolean.valueOf(this.hasTestAnnotation(it));
- };
- Iterable<SubSystemClass> _filter = IterableExtensions.<SubSystemClass>filter(_subSystemClasses, _function_2);
- Iterables.<SubSystemClass>addAll(list, _filter);
- return list;
- };
- final ArrayList<SubSystemClass> allTestSubSystems = IterableExtensions.<RoomModel, ArrayList<SubSystemClass>>fold(roomModels, _newArrayList, _function_1);
- final List<StructureClass> allAnnotatedClasses = CollectionLiterals.<StructureClass>newArrayList(((StructureClass[])Conversions.unwrapArray(allTestSubSystems, StructureClass.class)));
- final ArrayList<Resource> result = CollectionLiterals.<Resource>newArrayList();
- {
- SubSystemClass _createSubSystemClass = this._roomFactory.createSubSystemClass();
- final Procedure1<SubSystemClass> _function_2 = (SubSystemClass it) -> {
- it.setName("DerivedTestSubSystem");
- };
- final SubSystemClass derivedSubSystem = ObjectExtensions.<SubSystemClass>operator_doubleArrow(_createSubSystemClass, _function_2);
- final Consumer<RoomModel> _function_3 = (RoomModel model) -> {
- EList<ActorRef> _actorRefs = derivedSubSystem.getActorRefs();
- EList<ActorClass> _actorClasses = model.getActorClasses();
- final Function1<ActorClass, Boolean> _function_4 = (ActorClass it) -> {
- return Boolean.valueOf(this.hasTestAnnotation(it));
- };
- Iterable<ActorClass> _filter = IterableExtensions.<ActorClass>filter(_actorClasses, _function_4);
- final Function1<ActorClass, ActorRef> _function_5 = (ActorClass ac) -> {
- ActorRef _xblockexpression = null;
- {
- allAnnotatedClasses.add(ac);
- ActorRef _createActorRef = this._roomFactory.createActorRef();
- final Procedure1<ActorRef> _function_6 = (ActorRef it) -> {
- String _name = ac.getName();
- String _plus = ("ref_" + _name);
- it.setName(_plus);
- it.setType(ac);
- };
- _xblockexpression = ObjectExtensions.<ActorRef>operator_doubleArrow(_createActorRef, _function_6);
- }
- return _xblockexpression;
- };
- Iterable<ActorRef> _map = IterableExtensions.<ActorClass, ActorRef>map(_filter, _function_5);
- Iterables.<ActorRef>addAll(_actorRefs, _map);
- };
- roomModels.forEach(_function_3);
- EList<ActorRef> _actorRefs = derivedSubSystem.getActorRefs();
- boolean _isEmpty = _actorRefs.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- allTestSubSystems.add(derivedSubSystem);
- }
- }
- boolean _isEmpty = allTestSubSystems.isEmpty();
- if (_isEmpty) {
- return result;
- }
- int _size = allAnnotatedClasses.size();
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
- final Consumer<StructureClass> _function_2 = (StructureClass roomCls) -> {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("TestInstanceCreator: mapping failed, multiple test instances present");
- this.logger.logError(_builder.toString(), roomCls);
- };
- allAnnotatedClasses.forEach(_function_2);
- return null;
- }
- ArrayList<PhysicalSystem> _newArrayList_1 = CollectionLiterals.<PhysicalSystem>newArrayList();
- final Function2<ArrayList<PhysicalSystem>, PhysicalModel, ArrayList<PhysicalSystem>> _function_3 = (ArrayList<PhysicalSystem> list, PhysicalModel model) -> {
- EList<PhysicalSystem> _systems = model.getSystems();
- Iterables.<PhysicalSystem>addAll(list, _systems);
- return list;
- };
- final List<PhysicalSystem> allPhysSystems = IterableExtensions.<PhysicalModel, ArrayList<PhysicalSystem>>fold(physModels, _newArrayList_1, _function_3);
- int _size_1 = allPhysSystems.size();
- boolean _notEquals = (_size_1 != 1);
- if (_notEquals) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("TestInstanceCreator: mapping failed, found ");
- int _size_2 = allPhysSystems.size();
- _builder.append(_size_2, "");
- _builder.append(" physical systems");
- this.logger.logError(_builder.toString(), null);
- return null;
- }
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("TestInstanceCreator: creating instance and mapping for ");
- StructureClass _head = IterableExtensions.<StructureClass>head(allAnnotatedClasses);
- String _name = _head.getName();
- _builder_1.append(_name, "");
- _builder_1.append(":");
- StructureClass _head_1 = IterableExtensions.<StructureClass>head(allAnnotatedClasses);
- EClass _eClass = _head_1.eClass();
- String _name_1 = _eClass.getName();
- _builder_1.append(_name_1, "");
- this.logger.logInfo(_builder_1.toString());
- final PhysicalSystem physSystem = IterableExtensions.<PhysicalSystem>head(allPhysSystems);
- final SubSystemClass testSubSystem = IterableExtensions.<SubSystemClass>head(allTestSubSystems);
- LogicalSystem _createLogicalSystem = this._roomFactory.createLogicalSystem();
- final Procedure1<LogicalSystem> _function_4 = (LogicalSystem it) -> {
- it.setName("DerivedTestSystem");
- };
- final LogicalSystem testSystem = ObjectExtensions.<LogicalSystem>operator_doubleArrow(_createLogicalSystem, _function_4);
- EList<SubSystemRef> _subSystems = testSystem.getSubSystems();
- SubSystemRef _createSubSystemRef = this._roomFactory.createSubSystemRef();
- final Procedure1<SubSystemRef> _function_5 = (SubSystemRef it) -> {
- String _name_2 = testSubSystem.getName();
- String _plus = ("ref_" + _name_2);
- it.setName(_plus);
- it.setType(testSubSystem);
- };
- SubSystemRef _doubleArrow = ObjectExtensions.<SubSystemRef>operator_doubleArrow(_createSubSystemRef, _function_5);
- _subSystems.add(_doubleArrow);
- RoomModel _createRoomModel = this._roomFactory.createRoomModel();
- final Procedure1<RoomModel> _function_6 = (RoomModel it) -> {
- it.setName("DerivedTestRoomModel");
- EList<LogicalSystem> _systems = it.getSystems();
- _systems.add(testSystem);
- Resource _eResource = testSubSystem.eResource();
- boolean _tripleEquals = (_eResource == null);
- if (_tripleEquals) {
- EList<SubSystemClass> _subSystemClasses = it.getSubSystemClasses();
- _subSystemClasses.add(testSubSystem);
- }
- };
- final RoomModel testRoomModel = ObjectExtensions.<RoomModel>operator_doubleArrow(_createRoomModel, _function_6);
- MappingModel _createMappingModel = this._eTMapFactory.createMappingModel();
- final Procedure1<MappingModel> _function_7 = (MappingModel it) -> {
- it.setName("DerivedTestMappingModel");
- EList<Mapping> _mappings = it.getMappings();
- Mapping _createMapping = this._eTMapFactory.createMapping();
- final Procedure1<Mapping> _function_8 = (Mapping it_1) -> {
- it_1.setLogicalSys(testSystem);
- it_1.setPhysicalSys(physSystem);
- EList<SubSystemMapping> _subsysMappings = it_1.getSubsysMappings();
- EList<SubSystemRef> _subSystems_1 = testSystem.getSubSystems();
- final Function1<SubSystemRef, SubSystemMapping> _function_9 = (SubSystemRef subSysRef) -> {
- SubSystemMapping _createSubSystemMapping = this._eTMapFactory.createSubSystemMapping();
- final Procedure1<SubSystemMapping> _function_10 = (SubSystemMapping it_2) -> {
- it_2.setLogicalSubSys(subSysRef);
- EList<NodeRef> _nodeRefs = physSystem.getNodeRefs();
- NodeRef _head_2 = IterableExtensions.<NodeRef>head(_nodeRefs);
- it_2.setNode(_head_2);
- };
- return ObjectExtensions.<SubSystemMapping>operator_doubleArrow(_createSubSystemMapping, _function_10);
- };
- List<SubSystemMapping> _map = ListExtensions.<SubSystemRef, SubSystemMapping>map(_subSystems_1, _function_9);
- Iterables.<SubSystemMapping>addAll(_subsysMappings, _map);
- };
- Mapping _doubleArrow_1 = ObjectExtensions.<Mapping>operator_doubleArrow(_createMapping, _function_8);
- _mappings.add(_doubleArrow_1);
- };
- final MappingModel testMappingModel = ObjectExtensions.<MappingModel>operator_doubleArrow(_createMappingModel, _function_7);
- Resource _xifexpression = null;
- Resource _eResource = testSubSystem.eResource();
- boolean _tripleNotEquals = (_eResource != null);
- if (_tripleNotEquals) {
- _xifexpression = testSubSystem.eResource();
- } else {
- StructureClass _head_2 = IterableExtensions.<StructureClass>head(allAnnotatedClasses);
- _xifexpression = _head_2.eResource();
- }
- final Resource existingResource = _xifexpression;
- URI _uRI = existingResource.getURI();
- URI _trimFileExtension = _uRI.trimFileExtension();
- final URI uriPath = _trimFileExtension.trimSegments(1);
- URI _appendSegment = uriPath.appendSegment("DerivedTestMappingModel");
- URI _appendFileExtension = _appendSegment.appendFileExtension("etmap");
- Resource res = rs.createResource(_appendFileExtension);
- EList<EObject> _contents = res.getContents();
- _contents.add(testMappingModel);
- result.add(res);
- URI _appendSegment_1 = uriPath.appendSegment("DerivedTestRoomModel");
- URI _appendFileExtension_1 = _appendSegment_1.appendFileExtension("room");
- Resource _createResource = rs.createResource(_appendFileExtension_1);
- res = _createResource;
- EList<EObject> _contents_1 = res.getContents();
- _contents_1.add(testRoomModel);
- result.add(res);
- return result;
- }
-
- protected boolean hasTestAnnotation(final StructureClass cls) {
- EList<Annotation> _annotations = cls.getAnnotations();
- final Function1<Annotation, Boolean> _function = (Annotation it) -> {
- AnnotationType _type = it.getType();
- String _name = _type.getName();
- return Boolean.valueOf(Objects.equal(_name, TestInstanceCreator.ANNOTATION_TYPE_NAME));
- };
- return IterableExtensions.<Annotation>exists(_annotations, _function);
- }
-
- public TestInstanceCreator(final ILogger logger) {
- super();
- this.logger = logger;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java
deleted file mode 100644
index e3193f69f..000000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
- */
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.common.base.LiteralType;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.EnumerationType;
-import org.eclipse.etrice.core.room.ExternalType;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.IDataConfiguration;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-@Singleton
-@SuppressWarnings("all")
-public class TypeHelpers {
- @Inject
- @Extension
- protected RoomHelpers _roomHelpers;
-
- @Inject
- private ILanguageExtension languageExt;
-
- @Inject
- private IDataConfiguration dataConfigExt;
-
- public String typeName(final DataType type) {
- if ((type instanceof PrimitiveType)) {
- return ((PrimitiveType) type).getTargetName();
- } else {
- if ((type instanceof EnumerationType)) {
- return this.languageExt.getTargetType(((EnumerationType) type));
- } else {
- if ((type instanceof ExternalType)) {
- return ((ExternalType) type).getTargetName();
- } else {
- return type.getName();
- }
- }
- }
- }
-
- public String getTypeName(final RefableType t) {
- DataType _type = t.getType();
- return this.typeName(_type);
- }
-
- public String getTypeName(final Message m) {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- return this.getTypeName(_refType);
- }
-
- public String getTypeName(final Attribute att) {
- RefableType _type = att.getType();
- return this.getTypeName(_type);
- }
-
- /**
- * This function returns the name of the primitive type.
- * It can be overridden to map room types to the target language. This (basic) implementation returns the room type
- *
- * @param t
- * @return
- */
- public String getPrimitiveTypeName(final RefableType t) {
- DataType _type = t.getType();
- return _type.getName();
- }
-
- public String getPrimitiveTypeName(final Message m) {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- return this.getPrimitiveTypeName(_refType);
- }
-
- public String getPrimitiveTypeName(final Attribute att) {
- RefableType _type = att.getType();
- return this.getPrimitiveTypeName(_type);
- }
-
- public String defaultValue(final VarDecl a) {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- return this.languageExt.defaultValue(_type);
- }
-
- public String getArgumentList(final VarDecl data) {
- String[] _generateArglistAndTypedData = this.languageExt.generateArglistAndTypedData(data);
- return _generateArglistAndTypedData[0];
- }
-
- public String getTypedDataDefinition(final VarDecl data) {
- String[] _generateArglistAndTypedData = this.languageExt.generateArglistAndTypedData(data);
- return _generateArglistAndTypedData[1];
- }
-
- public String generateTypedArgumentList(final VarDecl data) {
- String[] _generateArglistAndTypedData = this.languageExt.generateArglistAndTypedData(data);
- return _generateArglistAndTypedData[2];
- }
-
- public boolean isPrimitive(final DataType type) {
- return (type instanceof PrimitiveType);
- }
-
- public boolean isBoolean(final DataType type) {
- return (this.isPrimitive(type) && Objects.equal(((PrimitiveType) type).getType(), LiteralType.BOOL));
- }
-
- public boolean isEnumeration(final DataType type) {
- return (type instanceof EnumerationType);
- }
-
- public boolean isEnumerationOrPrimitive(final DataType type) {
- return ((type instanceof EnumerationType) || (type instanceof PrimitiveType));
- }
-
- public boolean isDataClass(final DataType type) {
- return (type instanceof DataClass);
- }
-
- public boolean isCharacterType(final PrimitiveType type) {
- LiteralType _type = type.getType();
- return Objects.equal(_type, LiteralType.CHAR);
- }
-
- public boolean isCharacterType(final DataType type) {
- return (this.isPrimitive(type) && this.isCharacterType(((PrimitiveType) type)));
- }
-
- public String getAttrInstanceConfigValue(final List<Attribute> attributePath, final InstanceBase instance) {
- String _switchResult = null;
- boolean _matched = false;
- if (instance instanceof ActorInstance) {
- _matched=true;
- _switchResult = this.dataConfigExt.getAttrInstanceConfigValue(((ActorInstance)instance), attributePath);
- }
- if (!_matched) {
- if (instance instanceof InterfaceItemInstance) {
- _matched=true;
- _switchResult = this.dataConfigExt.getAttrInstanceConfigValue(((InterfaceItemInstance)instance), attributePath);
- }
- }
- return _switchResult;
- }
-
- public String getAttrClassConfigValue(final List<Attribute> attributePath, final ActorClass actor, final boolean inherite) {
- String result = this.dataConfigExt.getAttrClassConfigValue(actor, attributePath);
- if ((Objects.equal(result, null) && inherite)) {
- ActorClass base = actor.getActorBase();
- while (((!Objects.equal(base, null)) && Objects.equal(result, null))) {
- {
- String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(base, attributePath);
- result = _attrClassConfigValue;
- ActorClass _actorBase = base.getActorBase();
- base = _actorBase;
- }
- }
- }
- return result;
- }
-
- public String getAttrClassConfigValue(final List<Attribute> attributePath, final PortClass port) {
- ProtocolClass pc = this._roomHelpers.getProtocolClass(port);
- boolean _equals = Objects.equal(pc, null);
- if (_equals) {
- return null;
- }
- PortClass _regular = pc.getRegular();
- boolean _equals_1 = port.equals(_regular);
- return this.dataConfigExt.getAttrClassConfigValue(pc, _equals_1, attributePath);
- }
-}

Back to the top