aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-04-30 10:35:42 -0400
committerHenrik Rentz-Reichert2012-04-30 10:35:42 -0400
commit1b0c3ef0efd3aff268c480d58a90350a142f3d34 (patch)
treec8c16133309900b695c173649d494a8d71166e81
parent6a6d077f68902300419327b0045c88fb8d8a0b7a (diff)
parente52bc6be93813aada3973f3151eb2844fa8b6f13 (diff)
downloadorg.eclipse.etrice-1b0c3ef0efd3aff268c480d58a90350a142f3d34.tar.gz
org.eclipse.etrice-1b0c3ef0efd3aff268c480d58a90350a142f3d34.tar.xz
org.eclipse.etrice-1b0c3ef0efd3aff268c480d58a90350a142f3d34.zip
Merge remote branch 'remotes/origin/master'
-rw-r--r--gerritKeys30
-rw-r--r--gerritKeys.pub1
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/.classpath8
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/.project28
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/build.properties5
-rw-r--r--plugins/org.eclipse.etrice.core.config/.classpath9
-rw-r--r--plugins/org.eclipse.etrice.core.config/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.core.config/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.config).launch18
-rw-r--r--plugins/org.eclipse.etrice.core.config/.launch/Launch Runtime Eclipse.launch34
-rw-r--r--plugins/org.eclipse.etrice.core.config/.project34
-rw-r--r--plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.etrice.core.config/build.properties6
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext45
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/GenerateConfig.mwe2149
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend79
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend75
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java2435
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java475
-rw-r--r--plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/platform/etTimer.h2
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/.classpath8
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/.project28
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/META-INF/MANIFEST.MF18
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/build.properties4
27 files changed, 2145 insertions, 1391 deletions
diff --git a/gerritKeys b/gerritKeys
new file mode 100644
index 000000000..59db13967
--- /dev/null
+++ b/gerritKeys
@@ -0,0 +1,30 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,CEF20592097C4125
+
+xI5lJO/5sDRE2QVgmVDrcru/fKR6fSg/puFOYDert2hBkMK9s1DSLXq4RwFqql4R
+RZSZgq1DX9MMFKPY18W5Vy4laW2hgZmOG5E+9bbY9T0gdsH5nrbNnkxXXE9qFdEs
+8jhBKNzpowYc8jlK0KdA2yQJ7tPIL2jGsUIbUBaUhGFKxK5bh8Vm3d8viyGQKR16
+44ysLHx3cEONeaDTDcyb/BA6gipGymsIm9WazQqC0x3WKGktjB7bLQXnnsQR8vFE
+11sKTwXzUM4up79BAnNAJWwg6CvCVGgPJ6dbDnLiWSN7rwIQdtVAZR/ngwlCsjuO
+H4ocwtbU/SVTfG9/4c47XuGrYft+Iul36ut66P5jLEAwfRk6UoS+4nVKmSTce4Ze
+JHXicxEUOwXfX+e3/nXS3fvV0VBMEIBSC8GhU9aDH4hjOA/g85c0bBOqnSaq5e1L
+7iBSDAODAX0SN+3ElLIxonCNo0+M8YPaBbIhN4iSt6XmG/TP6mmvINvgDQ5z7QL0
+i0WoIvimQxw1CTGbSUHEdlzhQHMWw8B7qcsMyS48NF+z4QGT+W3+E9EdkBW+7KdD
+8r3xuC1rrGbbYZX2YRkc33sRX81VZ6Y5hctjsP6um4ebJrOHgGhfW7HIIGbIMDWE
+WDhQsUAw0Zz6NMN5O1ZtS3X5+fYJBRElYy+/ooTLthpRL/wmUalR/vWHBxaiDiyG
+SboWqN2yeZH3DUDJS2qG7S2lcmIVUJoPC+PF3Q4Ski2EJqQA7lO7KR+H2zgKbDvJ
+cxydFZIHwq6eiTQA+85OOKziRQUVH1wWnvliXbbfbc3g9U8V/LAeITlrxkSfG6Rp
+IV2cppKvDzxOkkPqhbqUJOMyAXpEqFyeBtEzvXq+jbckb9jMQZdfLIq0ApCThX1I
+hG1JxbkEqR0xHjv3+FNN6VIBBqs1OxxYuSGqb2XgzHGbMxu8GvsLa2AZRYk4ui/d
+piUPGDvCrD5TL9/jrvX/yzWgWRRRmXOjA357QjUR9hcwLhT/8K/tL9clPTZYIDEg
+OyDUaJInK9GMAmtt6FA76Ab5TFwm1x9IpItTD4yq/QpeMGQpnoQNp98n/bEawHBZ
+zkPCFLu2XBcoupCbZJT2Y6bdvEx5Spq02gVojHpdNuMUSQ4M8Fi+7uyKtdVBvCrD
+SJcp1mwomvQ7ksaJ2WqxfjmN0mJGyJU60OiwCTHcLakPyQfq+OHMN6/t1dYBRHpZ
+YMJmOMA7upTlywtLhVZsR+SjMaaWbCQpRwBYQKHJOO+dWPU67+vL7KjvNLaNaObU
+1x9x9TA6kVF91lUtsYXnocFYHmtBqrDi6LblIEKN2cXrKRlcGtdmGi0ZTM/2jnLM
+8WuxXRmB4DvIEkxMFQS3V+dWo6B6jm8HnEKlzvJAt6X+5yFsix4YsiEfpo2epj+7
+9Db60SAfZx4QrT5frkQgYo3g8WaQqeXiooRC5FUu6JU0W8AbsIjSmPk78illr+HL
+JIUqVKAIy6o56qyfgLS/uqgHHoscwXBLyifVbGkNOrbOnj6+tNtd9wVP6haUVQmi
+PURYXrEkI+vwqhj034jpbdV3mS6VaQqqDi6rNDnLZaPx7uezgDkgZg==
+-----END RSA PRIVATE KEY-----
diff --git a/gerritKeys.pub b/gerritKeys.pub
new file mode 100644
index 000000000..b24b6a1e4
--- /dev/null
+++ b/gerritKeys.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuBcuKvdgGQse39VkA5FbVWtzm312qrCnZE+4SjnoZe+qm1JR8gIM+9xKRAkTn1z/ZX2vxYq2IcAS0IX+fp5KpH6q1CUV2WcaP7AQ7QtabjsHRbYnpqH+Ep9Ej/GYW9BbQpDCQp/D72M11b2JzoMYzJJbPrpwx464GFydIOJKt2my4BNAf/HQG7zk74pvYae4hbZOm1Ssum5DAEtbk0kPSSaOiphy0BpmakcofB3UVxQfOXl6pqnDYBnFhbmqdAKY+y4mbnVunJqRZ/jThB5vO/HLLurasRUkAJBUzmecBkC+dvVLisCj1zD87lxm8pnTVp/+CjrUUy1R52iieK1vEw== thomas.jung@tieto.com
diff --git a/plugins/org.eclipse.etrice.core.config.ui/.classpath b/plugins/org.eclipse.etrice.core.config.ui/.classpath
new file mode 100644
index 000000000..7e8449de0
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config.ui/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.core.config.ui/.project b/plugins/org.eclipse.etrice.core.config.ui/.project
new file mode 100644
index 000000000..1f147cb79
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.core.config.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.core.config.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.config.ui/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..af52eaaca
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: org.eclipse.etrice.core.config.ui
+Bundle-Vendor: My Company
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: org.eclipse.etrice.core.config.ui; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.etrice.core.config;visibility:=reexport,
+ org.eclipse.xtext.ui,
+ org.eclipse.ui.editors;bundle-version="3.5.0",
+ org.eclipse.ui.ide;bundle-version="3.5.0"
+Import-Package: org.apache.log4j,
+ org.apache.commons.logging
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.etrice.core.config.ui/build.properties b/plugins/org.eclipse.etrice.core.config.ui/build.properties
new file mode 100644
index 000000000..e10dcceb6
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ src-gen/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.config/.classpath b/plugins/org.eclipse.etrice.core.config/.classpath
new file mode 100644
index 000000000..406ca4abd
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.core.config/.gitignore b/plugins/org.eclipse.etrice.core.config/.gitignore
new file mode 100644
index 000000000..ba077a403
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/.gitignore
@@ -0,0 +1 @@
+bin
diff --git a/plugins/org.eclipse.etrice.core.config/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.config).launch b/plugins/org.eclipse.etrice.core.config/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.config).launch
new file mode 100644
index 000000000..02f9fee76
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.config).launch
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1299248699643_13&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.etrice.core.config&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.etrice.core.config.generator&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.etrice.core.config.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.etrice.core.config.ui&quot; type=&quot;4&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.etrice.core.config"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/org/eclipse/etrice/core/GenerateConfig.mwe2"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.etrice.core.config"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.etrice.core.config/.launch/Launch Runtime Eclipse.launch b/plugins/org.eclipse.etrice.core.config/.launch/Launch Runtime Eclipse.launch
new file mode 100644
index 000000000..6aea24fb5
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/.launch/Launch Runtime Eclipse.launch
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="true"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bad_container_name" value="/org.eclipse.etrice.core.config/.launch/"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="false"/>
+<booleanAttribute key="clearws" value="false"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../runtime-New_configuration"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -XX:MaxPermSize=256m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<booleanAttribute key="useProduct" value="true"/>
+<booleanAttribute key="usefeatures" value="false"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.etrice.core.config/.project b/plugins/org.eclipse.etrice.core.config/.project
new file mode 100644
index 000000000..6bde47b31
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.core.config</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..c1e88a812
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: org.eclipse.etrice.core.config
+Bundle-Vendor: My Company
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: org.eclipse.etrice.core.config; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.xtext;bundle-version="2.1.0";visibility:=reexport,
+ org.eclipse.xtext.xbase;bundle-version="2.1.0";resolution:=optional;visibility:=reexport,
+ org.apache.log4j;bundle-version="1.2.15";visibility:=reexport,
+ org.apache.commons.logging;bundle-version="1.0.4";resolution:=optional;visibility:=reexport,
+ org.eclipse.xtext.generator;resolution:=optional,
+ org.eclipse.emf.codegen.ecore;resolution:=optional,
+ org.eclipse.emf.mwe.utils;resolution:=optional,
+ org.eclipse.emf.mwe2.launch;resolution:=optional
+Import-Package: org.apache.log4j,
+ org.apache.commons.logging
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.etrice.core.config/build.properties b/plugins/org.eclipse.etrice.core.config/build.properties
new file mode 100644
index 000000000..31255ed05
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/build.properties
@@ -0,0 +1,6 @@
+source.. = src/,\
+ src-gen/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext
new file mode 100644
index 000000000..a0cb9828a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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:
+ * Juergen Haug and Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+grammar org.eclipse.etrice.core.Config with org.eclipse.xtext.common.Terminals
+
+generate config "http://www.eclipse.org/etrice/core/Config"
+
+import 'platform:/resource/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore' as room
+import 'platform:/resource/org.eclipse.etrice.generator/model/etricegen.ecore' as etricegen
+
+
+
+
+ConfigModel:
+ actorClassConfigs+=ActorClassConfig*
+ actorInstanceConfigs+=ActorInstanceConfig*
+ ;
+
+
+ActorClassConfig:
+ 'ActorClassConfig' actorClass = [room::ActorClass] '{'
+
+ '}'
+;
+
+// ActorInstanceConfig MySS.AR1.AR2 {
+// min = 1
+// max = 5
+// }
+
+ActorInstanceConfig:
+ 'ActorInstanceConfig' actorInstance = [etricegen::ActorInstance] '{'
+
+ '}'
+;
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/GenerateConfig.mwe2 b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/GenerateConfig.mwe2
new file mode 100644
index 000000000..dd5c0c15d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/GenerateConfig.mwe2
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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:
+ * Juergen Haug and Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+module org.eclipse.etrice.core.GenerateConfig
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "classpath:/org/eclipse/etrice/core/Config.xtext"
+var file.extensions = "config"
+var projectName = "org.eclipse.etrice.core.config"
+var runtimeProject = "../${projectName}"
+
+Workflow {
+ bean = StandaloneSetup {
+ scanClassPath = true
+ platformUri = "${runtimeProject}/.."
+ registerGenModelFile = "platform:/resource/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.genmodel"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}/src-gen"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.ui/src-gen"
+ }
+
+ component = Generator {
+ pathRtProject = runtimeProject
+ pathUiProject = "${runtimeProject}.ui"
+ pathTestProject = "${runtimeProject}.tests"
+ projectNameRt = projectName
+ projectNameUi = "${projectName}.ui"
+ language = {
+ uri = grammarURI
+ fileExtensions = file.extensions
+
+ // Java API to access grammar elements (required by several other fragments)
+ fragment = grammarAccess.GrammarAccessFragment {}
+
+ // generates Java API for the generated EPackages
+ fragment = ecore.EcoreGeneratorFragment {
+ // referencedGenModels = "
+ // platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
+ // platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
+ // "
+ }
+
+ // Serializer 2.0
+ fragment = serializer.SerializerFragment {
+ generateStub = false
+ }
+
+ // the serialization component (1.0)
+ // fragment = parseTreeConstructor.ParseTreeConstructorFragment {}
+
+ // a custom ResourceFactory for use with EMF
+ fragment = resourceFactory.ResourceFactoryFragment {
+ fileExtensions = file.extensions
+ }
+
+ // The antlr parser generator fragment.
+ fragment = parser.antlr.XtextAntlrGeneratorFragment {
+ // options = {
+ // backtrack = true
+ // }
+ }
+
+ // java-based API for validation
+ fragment = validation.JavaValidatorFragment {
+ // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+ // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ }
+
+ // scoping and exporting API
+ // fragment = scoping.ImportURIScopingFragment {}
+ // fragment = exporting.SimpleNamesFragment {}
+
+ // scoping and exporting API
+ fragment = scoping.ImportNamespacesScopingFragment {}
+ fragment = exporting.QualifiedNamesFragment {}
+ fragment = builder.BuilderIntegrationFragment {}
+
+ // generator API
+ fragment = generator.GeneratorFragment {
+ generateMwe = false
+ generateJavaMain = false
+ }
+
+ // formatter API
+ fragment = formatting.FormatterFragment {}
+
+ // labeling API
+ fragment = labeling.LabelProviderFragment {}
+
+ // outline API
+ fragment = outline.OutlineTreeProviderFragment {}
+ fragment = outline.QuickOutlineFragment {}
+
+ // quickfix API
+ fragment = quickfix.QuickfixProviderFragment {}
+
+ // content assist API
+ fragment = contentAssist.JavaBasedContentAssistFragment {}
+
+ // generates a more lightweight Antlr parser and lexer tailored for content assist
+ fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}
+
+ // generates junit test support classes into Generator#pathTestProject
+ fragment = junit.Junit4Fragment {}
+
+ // project wizard (optional)
+ // fragment = projectWizard.SimpleProjectWizardFragment {
+ // generatorProjectName = "${projectName}"
+ // modelFileExtension = file.extensions
+ // }
+
+ // rename refactoring
+ fragment = refactoring.RefactorElementNameFragment {}
+
+ // provides the necessary bindings for java types integration
+ fragment = types.TypesGeneratorFragment {}
+
+ // generates the required bindings only if the grammar inherits from Xbase
+ fragment = xbase.XbaseGeneratorFragment {}
+
+ // provides a preference page for template proposals
+ fragment = templates.CodetemplatesGeneratorFragment {}
+
+ // provides a compare view
+ fragment = compare.CompareFragment {
+ fileExtensions = file.extensions
+ }
+
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index dd9773f3e..8aee50036 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -136,31 +136,48 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
'''
+ typedef etPort «portClassName»;
+ typedef etReplPort «replPortClassName»;
- typedef etPort «portClassName»;
- typedef etReplPort «replPortClassName»;
+ «IF pc.getPortClass(conj)!=null»
+ «IF !(pc.getPortClass(conj).attributes.empty)»
+/* variable part of PortClass (RAM) */
+typedef struct «portClassName»_var «portClassName»_var;
+struct «portClassName»_var {
+ «helpers.attributes(pc.getPortClass(conj).attributes)»
+ };
+ «FOR a:pc.getPortClass(conj).attributes»
+ «IF a.defaultValueLiteral!=null»
+ «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDIF»
- «FOR message : messages»
- «var hasData = message.data!=null»
- «var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
- «messageSignature(portClassName, message.name, "", data)»;
- «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
- «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
- «ENDFOR»
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSignature(portClassName, message.name, "", data)»;
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
+ «ENDFOR»
«IF (pc.getPortClass(conj) != null)»
«helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
«helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
«ENDIF»
- «IF pc.handlesReceive(conj)»
- void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «IF pc.handlesReceive(conj)»
+ «FOR h:getReceiveHandlers(pc,conj)»
+void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «ENDFOR»
«ENDIF»
-
'''
}
+
+
def private genDataDrivenPortHeaders(ProtocolClass pc) {
var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
@@ -226,6 +243,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
«var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
«var data = if (hasData) ", "+typeName+refpd+" data" else ""»
+ «var dataCall = if (hasData) ", data" else ""»
«var hdlr = message.getSendHandler(conj)»
«messageSignature(portClassName, message.name, "", data)» {
@@ -234,9 +252,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDFOR»
«ELSE»
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
- if (self->receiveMessageFunc!=NULL) {
«sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
ET_MSC_LOGGER_SYNC_EXIT
«ENDIF»
}
@@ -244,14 +260,14 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignature(replPortClassName, message.name, "_broadcast", data)» {
«IF hdlr != null»
int i;
- for (i=0; i<self->size; ++i) {
- «portClassName»_«message.name»((«portClassName»*)&self->ports[i]«data»);
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[i]«dataCall»);
}
«ELSE»
int i;
ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- for (i=0; i<self->size; ++i) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
}
ET_MSC_LOGGER_SYNC_EXIT
«ENDIF»
@@ -259,11 +275,11 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
«IF hdlr != null»
- «portClassName»_«message.name»((«portClassName»*)&self->ports[idx]«data»);
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[idx]«dataCall»);
«ELSE»
ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- if (0<=idx && idx<self->size) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
}
ET_MSC_LOGGER_SYNC_EXIT
«ENDIF»
@@ -277,7 +293,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// getReplication
etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
- return self->size;
+ return ((etReplPort*)self)->size;
}
«IF pc.handlesReceive(conj)»
@@ -328,18 +344,15 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
/* receiver handlers */
- void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
- switch (msg->evtID){
- «FOR h:getReceiveHandlers(pc,conj)»
- case «pc.name»_«h.msg.codeName»:
+ «FOR h:getReceiveHandlers(pc,conj)»
+ void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
«userCode(h.detailCode)»
- break;
- «ENDFOR»
- default:receiveMessageFunc(actor, self, msg);
- break;
+ /* hand over the message to the actor: */
+ /* (*receiveMessageFunc)(actor, self, msg); */
}
- }
+ «ENDFOR»
'''}
+
def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index 833b68afd..190133bf5 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -268,7 +268,26 @@ class SubSystemClassGen {
«FOR ai : ssi.allContainedInstances»
static «ai.actorClass.name» «ai.path.getPathName()»;
«ENDFOR»
-
+
+ /* forward declaration of variable port structs */
+ «FOR ai: ssi.allContainedInstances»
+ «IF ai.orderedIfItemInstances.empty»
+/*nothing to do */
+ «ELSE»
+ «FOR pi:ai.orderedIfItemInstances»
+ «IF pi.interfaceItem.protocol.getPortClass(pi.conjugated)!=null»
+ «IF !pi.interfaceItem.protocol.getPortClass(pi.conjugated).attributes.empty»
+ «IF pi.replicated»
+ static «pi.interfaceItem.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var[«pi.peers.size»];
+ «ELSE»
+ static «pi.interfaceItem.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var;
+ «ENDIF»
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDFOR»
+
«FOR ai : ssi.allContainedInstances»
/* instance «ai.path.getPathName()» */
@@ -313,7 +332,7 @@ class SubSystemClassGen {
'''
«IF haveReplSubPorts»
static const etReplSubPort «replSubPortsArray»[«offset»] = {
- /* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, index} */
+ /* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */
«FOR pi : replPorts SEPARATOR ","»
«genReplSubPortInitializers(root, ai, pi)»
«ENDFOR»
@@ -321,7 +340,7 @@ class SubSystemClassGen {
«ENDIF»
«IF !(eventPorts.empty && recvPorts.empty)»
static const «ai.actorClass.name»_const «instName»_const = {
- /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ /* Ports: {varData, msgService, peerAddress, localId} */
«FOR pi : eventPorts SEPARATOR ","»
«IF pi.simple»
«genPortInitializer(root, ai, pi)»
@@ -345,14 +364,23 @@ class SubSystemClassGen {
var objId = if (pi.peers.empty) 0 else pi.peers.get(0).objId
var idx = if (pi.peers.empty) 0 else pi.peers.get(0).peers.indexOf(pi)
- "{&"+ai.path.getPathName()+", "
- +recvMsg+", "
+ "{"+getInterfaceItemInstanceData(pi)+","
+"&msgService_Thread1, "
+(objId+idx)+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.interfaceItem)+1)
+"} /* Port "+pi.name+" */"
}
+ def private getInterfaceItemInstanceData(InterfaceItemInstance pi){
+ if (pi.interfaceItem.protocol.getPortClass(pi.conjugated)== null) return "0"
+ if (pi.interfaceItem.protocol.getPortClass(pi.conjugated).attributes.empty){
+ return "0"
+ }else{
+ return "&"+pi.path.pathName+"_var"
+ }
+ }
+
+
def private String genRecvPortInitializer(Root root, ActorInstance ai, InterfaceItemInstance pi) {
if (pi.peers.empty)
return "{NULL}"
@@ -370,9 +398,10 @@ class SubSystemClassGen {
for (p: pi.peers) {
var idx = pi.peers.indexOf(p)
var comma = if (idx<pi.peers.size-1) "," else ""
+ var iiiD = getInterfaceItemInstanceData(pi)
+ iiiD = if (iiiD.equals("0")) iiiD+"," else iiiD+"["+idx+"],"
result = result +
- "{&"+ai.path.getPathName()+", "
- +ai.actorClass.name+"_receiveMessage, "
+ "{"+iiiD
+"&msgService_Thread1, "
+p.objId+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.interfaceItem)+1)+", "
@@ -401,24 +430,38 @@ class SubSystemClassGen {
«FOR ai : ssi.allContainedInstances»
/* interface items of «ai.path» */
- «FOR pi : ai.orderedIfItemInstances.filter(p|p.interfaceItem.protocol.commType==CommunicationType::EVENT_DRIVEN)»
+ «FOR pi : ai. orderedIfItemInstances.filter(p|p.interfaceItem.protocol.commType==CommunicationType::EVENT_DRIVEN)»
«IF pi.replicated»
«FOR peer: pi.peers»
case «pi.objId+pi.peers.indexOf(peer)»:
- «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
- «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»],msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «IF (pi.interfaceItem.protocol.handlesReceive(pi.isConjugated()))»
+ switch (msg->evtID){
+ «FOR h:getReceiveHandlers(pi.interfaceItem.protocol,pi.isConjugated())»
+ case «pi.interfaceItem.protocol.name»_«h.msg.codeName»:
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated)»_«h.msg.name»_receiveHandler((etPort *)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»],msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ break;
+ «ENDFOR»
+ default: «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
+ break;
+ }
«ELSE»
- //etPort_receive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
«ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
«ENDIF»
break;
«ENDFOR»
«ELSE»
case «pi.objId»:
- «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
- «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name»,msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «IF (pi.interfaceItem.protocol.handlesReceive(pi.isConjugated()))»
+ switch (msg->evtID){
+ «FOR h:getReceiveHandlers(pi.interfaceItem.protocol,pi.isConjugated())»
+ case «pi.interfaceItem.protocol.name»_«h.msg.codeName»:
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated)»_«h.msg.name»_receiveHandler((etPort *)&«ai.path.pathName»_const.«pi.name»,msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ break;
+ «ENDFOR»
+ default: «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name», msg);
+ break;
+ }
«ELSE»
- //etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
«ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name», msg);
«ENDIF»
break;
@@ -428,13 +471,13 @@ class SubSystemClassGen {
default:
etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address);
- break;
+ break;
}
ET_MSC_LOGGER_SYNC_EXIT
}
'''
}
-
+
def private generateDatadrivenExecutes(Root root, SubSystemInstance ssi) {'''
«FOR ai : ssi.allContainedInstances»
«IF ai.actorClass.commType == ActorCommunicationType::ASYNCHRONOUS || ai.actorClass.commType == ActorCommunicationType::DATA_DRIVEN»
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 453ce84dc..fabb3af52 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -1,1200 +1,1235 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.CommunicationType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PortOperation;
-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.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"modelbase/etPort.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- _builder.newLine();
- _builder.append("/* message IDs */");
- _builder.newLine();
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
- _builder.append(_portClassHeader, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
- _builder.append(_portClassHeader_1, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
- _builder.append(_genDataDrivenPortHeaders, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronoue protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* get message string for message id */");
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_4 = pc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"debugging/etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = pc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port methods */");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
- _builder.append(_portClassSource, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
- _builder.append(_portClassSource_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
- _builder.append(_genDataDrivenPortSources, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronoue protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- return _builder;
- }
-
- private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("typedef etPort ");
- _builder.append(portClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("typedef etReplPort ");
- _builder.append(replPortClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- for(final Message message : messages) {
- _builder.append("\t");
- VarDecl _data = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_1 = _typeName;
- } else {
- _xifexpression_1 = "";
- }
- String typeName = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _operator_or = true;
- } else {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- boolean _isRef = _refType_2.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef);
- }
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_3 = _operator_plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_1 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_1, "_broadcast", data);
- _builder.append(_messageSignature_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_2 = message.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_2, "", _operator_plus_3);
- _builder.append(_messageSignature_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_portClass, null);
- if (_operator_notEquals_1) {
- PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations = _portClass_1.getOperations();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations_1 = _portClass_2.getOperations();
- StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
- _builder.append(_operationsDeclaration_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_handleReceive(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> sentMsgs = _filter;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* data driven send port (conjugated) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- {
- for(final Message msg : sentMsgs) {
- _builder.append("\t");
- VarDecl _data = msg.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String typeName = _typeName;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression = null;
- VarDecl _data_1 = msg.getData();
- RefableType _refType_1 = _data_1.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(typeName, " ");
- _builder.append(refp, " ");
- _builder.append(" ");
- String _name = msg.getName();
- _builder.append(_name, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* data driven receive port (regular) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName_1, " ");
- _builder.append("* peer;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
- _builder.append(_portClassName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- for(final Message message : sentMsgs) {
- VarDecl _data_2 = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _xifexpression_1 = _typeName_1;
- } else {
- _xifexpression_1 = "";
- }
- String typeName_1 = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- DataType _type_2 = _refType_3.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp_1 = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_3 = _operator_plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
- String _name_1 = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
- _builder.append(_messageGetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> messages = _filter;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String typeName = _typeName;
- _builder.newLineIfNotEmpty();
- String _xifexpression = null;
- VarDecl _data_1 = message.getData();
- RefableType _refType_1 = _data_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- VarDecl _data_2 = message.getData();
- RefableType _refType_2 = _data_2.getRefType();
- DataType _type_2 = _refType_2.getType();
- if ((_type_2 instanceof PrimitiveType)) {
- _xifexpression_1 = "&";
- } else {
- _xifexpression_1 = "";
- }
- String refa = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- String data = _operator_plus_2;
- _builder.newLineIfNotEmpty();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- String _name = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = data;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
- _builder.append(_messageGetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return self->peer->");
- String _name_3 = message.getName();
- _builder.append(_name_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- String _xifexpression_1 = null;
- if (conj) {
- _xifexpression_1 = "IN_";
- } else {
- _xifexpression_1 = "OUT_";
- }
- String dir = _xifexpression_1;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_2 = _typeName;
- } else {
- _xifexpression_2 = "";
- }
- String typeName = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- boolean _isRef = _refType_1.isRef();
- _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
- }
- if (_operator_and) {
- _xifexpression_3 = "*";
- } else {
- _xifexpression_3 = "";
- }
- String refp = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _xifexpression_4 = null;
- boolean _operator_and_1 = false;
- if (!hasData) {
- _operator_and_1 = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _operator_or = true;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- boolean _isRef_1 = _refType_3.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
- }
- _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and_1) {
- _xifexpression_4 = "*";
- } else {
- _xifexpression_4 = "";
- }
- String refpd = _xifexpression_4;
- _builder.newLineIfNotEmpty();
- String _xifexpression_5 = null;
- boolean _operator_and_2 = false;
- boolean _operator_and_3 = false;
- if (!hasData) {
- _operator_and_3 = false;
- } else {
- VarDecl _data_5 = message.getData();
- RefableType _refType_4 = _data_5.getRefType();
- DataType _type_2 = _refType_4.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
- }
- if (!_operator_and_3) {
- _operator_and_2 = false;
- } else {
- VarDecl _data_6 = message.getData();
- RefableType _refType_5 = _data_6.getRefType();
- boolean _isRef_2 = _refType_5.isRef();
- boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
- _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
- }
- if (_operator_and_2) {
- _xifexpression_5 = "";
- } else {
- _xifexpression_5 = "&";
- }
- String refa = _xifexpression_5;
- _builder.newLineIfNotEmpty();
- String _xifexpression_6 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_6 = _operator_plus_2;
- } else {
- _xifexpression_6 = "";
- }
- String data = _xifexpression_6;
- _builder.newLineIfNotEmpty();
- MessageHandler _sendHandler = this.roomExt.getSendHandler(message, conj);
- MessageHandler hdlr = _sendHandler;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(portClassName, " ");
- _builder.append("\", \"");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (self->receiveMessageFunc!=NULL) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
- String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
- String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
- _builder.append(_sendMessageCall, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_4 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_2) {
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<self->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_5 = message.getName();
- _builder.append(_name_5, " ");
- _builder.append("((");
- _builder.append(portClassName, " ");
- _builder.append("*)&self->ports[i]");
- _builder.append(data, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}\t\t\t\t\t");
- _builder.newLine();
- } else {
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_6 = message.getName();
- _builder.append(_name_6, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (i=0; i<self->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_7 = pc.getName();
- String _name_8 = message.getName();
- String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_8);
- String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _operator_plus_6);
- String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_1 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[i])", _memberInUse_1, _operator_plus_7, _operator_plus_8);
- _builder.append(_sendMessageCall_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_9 = message.getName();
- String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _operator_plus_9);
- _builder.append(_messageSignature_2, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals_3) {
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_10 = message.getName();
- _builder.append(_name_10, " ");
- _builder.append("((");
- _builder.append(portClassName, " ");
- _builder.append("*)&self->ports[idx]");
- _builder.append(data, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_11 = message.getName();
- _builder.append(_name_11, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (0<=idx && idx<self->size) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_12 = pc.getName();
- String _name_13 = message.getName();
- String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_13);
- String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _operator_plus_10);
- String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_2 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_plus_12);
- _builder.append(_sendMessageCall_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_portClass, null);
- if (_operator_notEquals_4) {
- PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations = _portClass_1.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
- EList<PortOperation> _operations_1 = _portClass_2.getOperations();
- StringConcatenation _operationsImplementation_1 = this.helpers.operationsImplementation(_operations_1, replPortClassName);
- _builder.append(_operationsImplementation_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// getReplication");
- _builder.newLine();
- _builder.append("etInt32 ");
- _builder.append(replPortClassName, "");
- _builder.append("_getReplication(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return self->size;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- StringConcatenation _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
- _builder.append(_genReceiveHandlers, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
- String _xifexpression = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
- _xifexpression = _operator_plus_7;
- } else {
- String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
- _xifexpression = _operator_plus_11;
- }
- return _xifexpression;
- }
-
- private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
- return _operator_plus_8;
- }
-
- private String messageSetterSignature(final String className, final String messageName, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
- return _operator_plus_7;
- }
-
- private String messageGetterSignature(final String className, final String messageName, final String type) {
- String _operator_plus = StringExtensions.operator_plus(type, " ");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
- return _operator_plus_6;
- }
-
- private StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- private StringConcatenation genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* receiver handlers */");
- _builder.newLine();
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_handleReceive(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("switch (msg->evtID){");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("\t");
- _builder.append("case ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append("_");
- Message _msg = h.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- DetailCode _detailCode = h.getDetailCode();
- StringConcatenation _userCode = this.helpers.userCode(_detailCode);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("default:receiveMessageFunc(actor, self, msg);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("static const char* ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append("\",");
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, "");
- _builder.append("\", ");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (msg_id<");
- String _name_4 = pc.getName();
- _builder.append(_name_4, " ");
- _builder.append("_MSG_MIN || msg_id>");
- String _name_5 = pc.getName();
- _builder.append(_name_5, " ");
- _builder.append("_MSG_MAX+1){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("/* id out of range */");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_6 = pc.getName();
- _builder.append(_name_6, " ");
- _builder.append("_messageStrings[msg_id];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+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.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etPort.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ _builder.newLine();
+ _builder.append("/* message IDs */");
+ _builder.newLine();
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
+ _builder.append(_portClassHeader, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
+ _builder.append(_portClassHeader_1, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* get message string for message id */");
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = pc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port methods */");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
+ _builder.append(_portClassSource, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
+ _builder.append(_portClassSource_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals) {
+ {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
+ StringConcatenation _attributes_2 = this.helpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ {
+ PortClass _portClass_3 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t\t\t\t");
+ String _operator_plus = StringExtensions.operator_plus(portClassName, " ");
+ String _name = a.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
+ this.logger.logInfo(_operator_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not_1) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not_1, _isRef);
+ }
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus_3 = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, " data");
+ _xifexpression_3 = _operator_plus_5;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _name_1 = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_3 = message.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _operator_plus_6);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ PortClass _portClass_4 = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_portClass_4, null);
+ if (_operator_notEquals_3) {
+ PortClass _portClass_5 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_5.getOperations();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_6 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_6.getOperations();
+ StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name_4 = _msg.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> sentMsgs = _filter;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* data driven send port (conjugated) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ {
+ for(final Message msg : sentMsgs) {
+ _builder.append("\t");
+ VarDecl _data = msg.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String typeName = _typeName;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression = null;
+ VarDecl _data_1 = msg.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(typeName, " ");
+ _builder.append(refp, " ");
+ _builder.append(" ");
+ String _name = msg.getName();
+ _builder.append(_name, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data driven receive port (regular) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
+ boolean hasData = _operator_notEquals;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName_1;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_3 = _operator_plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
+ String _name_1 = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> messages = _filter;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String typeName = _typeName;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_2 = _data_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ if ((_type_2 instanceof PrimitiveType)) {
+ _xifexpression_1 = "&";
+ } else {
+ _xifexpression_1 = "";
+ }
+ String refa = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ String data = _operator_plus_2;
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ String _name = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = data;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->peer->");
+ String _name_3 = message.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if (conj) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_2 = _typeName;
+ } else {
+ _xifexpression_2 = "";
+ }
+ String typeName = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
+ }
+ if (_operator_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _operator_and_1 = false;
+ if (!hasData) {
+ _operator_and_1 = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
+ }
+ _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _operator_and_2 = false;
+ boolean _operator_and_3 = false;
+ if (!hasData) {
+ _operator_and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
+ }
+ if (!_operator_and_3) {
+ _operator_and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
+ _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
+ }
+ if (_operator_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_6 = _operator_plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_7 = null;
+ if (hasData) {
+ _xifexpression_7 = ", data";
+ } else {
+ _xifexpression_7 = "";
+ }
+ String dataCall = _xifexpression_7;
+ _builder.newLineIfNotEmpty();
+ MessageHandler _sendHandler = this.roomExt.getSendHandler(message, conj);
+ MessageHandler hdlr = _sendHandler;
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(portClassName, " ");
+ _builder.append("\", \"");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
+ String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_6 = message.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_8);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _operator_plus_6);
+ String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _operator_plus_7, _operator_plus_8);
+ _builder.append(_sendMessageCall_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_9 = message.getName();
+ String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _operator_plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_3) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_11 = message.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_13);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _operator_plus_10);
+ String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_plus_12);
+ _builder.append(_sendMessageCall_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals_4) {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ StringConcatenation _operationsImplementation_1 = this.helpers.operationsImplementation(_operations_1, replPortClassName);
+ _builder.append(_operationsImplementation_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// getReplication");
+ _builder.newLine();
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return ((etReplPort*)self)->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ StringConcatenation _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
+ _builder.append(_genReceiveHandlers, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
+ String _xifexpression = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
+ _xifexpression = _operator_plus_7;
+ } else {
+ String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
+ _xifexpression = _operator_plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
+ return _operator_plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
+ return _operator_plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _operator_plus = StringExtensions.operator_plus(type, " ");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
+ return _operator_plus_6;
+ }
+
+ private StringConcatenation messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ private StringConcatenation genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* receiver handlers */");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name = _msg.getName();
+ _builder.append(_name, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ StringConcatenation _userCode = this.helpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* hand over the message to the actor: */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id<");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_MSG_MIN || msg_id>");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index 9d7bcf17a..96b737de8 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -4,14 +4,19 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.CommunicationType;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.InterfaceItem;
+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.StandardOperation;
import org.eclipse.etrice.core.room.SubSystemClass;
@@ -733,24 +738,100 @@ public class SubSystemClassGen {
}
}
_builder.newLine();
+ _builder.append("/* forward declaration of variable port structs */\t\t");
+ _builder.newLine();
{
EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/*nothing to do */");
+ _builder.newLine();
+ } else {
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_1.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances_1) {
+ {
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals) {
+ {
+ InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
+ ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty_1 = _attributes.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ _builder.append("static ");
+ InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
+ ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
+ boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
+ String _portClassName = this.roomExt.getPortClassName(_protocol_2, _isConjugated_2);
+ _builder.append(_portClassName, "");
+ _builder.append("_var ");
+ String _path_1 = pi.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append("_var[");
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ int _size = _peers.size();
+ _builder.append(_size, "");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("static ");
+ InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
+ ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
+ boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
+ String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3);
+ _builder.append(_portClassName_1, "");
+ _builder.append("_var ");
+ String _path_2 = pi.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("_var;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_2) {
_builder.newLine();
_builder.append("/* instance ");
- String _path_1 = ai_1.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName_1, "");
+ String _path_3 = ai_2.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_3, "");
_builder.append(" */");
_builder.newLineIfNotEmpty();
{
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances.isEmpty();
- if (_isEmpty) {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_2 = _orderedIfItemInstances_2.isEmpty();
+ if (_isEmpty_2) {
_builder.append("/* no ports/saps/services - nothing to initialize statically */");
_builder.newLine();
} else {
- StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1);
+ StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_2);
_builder.append(_genActorInstanceInitializer, "");
_builder.newLineIfNotEmpty();
}
@@ -884,7 +965,7 @@ public class SubSystemClassGen {
_builder.append("] = {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, index} */");
+ _builder.append("/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */");
_builder.newLine();
{
boolean hasAnyElements = false;
@@ -924,7 +1005,7 @@ public class SubSystemClassGen {
_builder.append("_const = {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
+ _builder.append("/* Ports: {varData, msgService, peerAddress, localId} */");
_builder.newLine();
{
boolean hasAnyElements_1 = false;
@@ -1053,30 +1134,53 @@ public class SubSystemClassGen {
_xifexpression_2 = _indexOf;
}
int idx = _xifexpression_2;
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
- int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6));
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
+ String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi);
+ String _operator_plus_1 = StringExtensions.operator_plus("{", _interfaceItemInstanceData);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ",");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "&msgService_Thread1, ");
+ int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_3, ((Integer)_operator_plus_4));
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ", ");
ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
InterfaceItem _interfaceItem = pi.getInterfaceItem();
int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
- int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port ");
+ int _operator_plus_7 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_operator_plus_7));
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, "} /* Port ");
String _name_1 = pi.getName();
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1);
- String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */");
- _xblockexpression = (_operator_plus_13);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, _name_1);
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, " */");
+ _xblockexpression = (_operator_plus_11);
}
return _xblockexpression;
}
+ private String getInterfaceItemInstanceData(final InterfaceItemInstance pi) {
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
+ if (_operator_equals) {
+ return "0";
+ }
+ InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
+ ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ if (_isEmpty) {
+ return "0";
+ } else {
+ String _path = pi.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus = StringExtensions.operator_plus("&", _pathName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_var");
+ return _operator_plus_1;
+ }
+ }
+
private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
String _xblockexpression = null;
{
@@ -1124,35 +1228,42 @@ public class SubSystemClassGen {
_xifexpression = "";
}
String comma = _xifexpression;
- String _operator_plus = StringExtensions.operator_plus(result, "{&");
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
- ActorClass _actorClass = ai.getActorClass();
- String _name = _actorClass.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_receiveMessage, ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi);
+ String iiiD = _interfaceItemInstanceData;
+ String _xifexpression_1 = null;
+ boolean _equals = iiiD.equals("0");
+ if (_equals) {
+ String _operator_plus = StringExtensions.operator_plus(iiiD, ",");
+ _xifexpression_1 = _operator_plus;
+ } else {
+ String _operator_plus_1 = StringExtensions.operator_plus(iiiD, "[");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ((Integer)idx));
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "],");
+ _xifexpression_1 = _operator_plus_3;
+ }
+ iiiD = _xifexpression_1;
+ String _operator_plus_4 = StringExtensions.operator_plus(result, "{");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, iiiD);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "&msgService_Thread1, ");
int _objId = p.getObjId();
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId));
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_objId));
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
InterfaceItem _interfaceItem = pi.getInterfaceItem();
int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
- int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", ");
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx));
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}");
- String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma);
- String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port ");
- String _name_1 = pi.getName();
- String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1);
- String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +");
- String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx));
- String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n");
- result = _operator_plus_18;
+ int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", ");
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, ((Integer)idx));
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, "}");
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, comma);
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, " /* Repl Sub Port ");
+ String _name = pi.getName();
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, _name);
+ String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, " idx +");
+ String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, ((Integer)idx));
+ String _operator_plus_19 = StringExtensions.operator_plus(_operator_plus_18, "*/\n");
+ result = _operator_plus_19;
}
}
return result;
@@ -1241,62 +1352,113 @@ public class SubSystemClassGen {
boolean _handlesReceive = this.roomExt.handlesReceive(_protocol, _isConjugated);
if (_handlesReceive) {
_builder.append("\t\t");
- InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
- ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
- boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
- String _portClassName = this.roomExt.getPortClassName(_protocol_1, _isConjugated_1);
- _builder.append(_portClassName, " ");
- _builder.append("_handleReceive((etPort*)&");
- String _path_1 = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append("_const.");
- String _name_1 = pi.getName();
- _builder.append(_name_1, " ");
- _builder.append(".ports[");
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _indexOf_1 = _peers_2.indexOf(peer);
- _builder.append(_indexOf_1, " ");
- _builder.append("],msg,(void*)&");
- String _path_2 = ai.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_2);
- _builder.append(_pathName_1, " ");
- _builder.append(",");
- ActorClass _actorClass = ai.getActorClass();
- String _name_2 = _actorClass.getName();
- _builder.append(_name_2, " ");
- _builder.append("_receiveMessage);");
- _builder.newLineIfNotEmpty();
- } else {
+ _builder.append("switch (msg->evtID){");
+ _builder.newLine();
+ {
+ InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
+ ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(_protocol_1, _isConjugated_1);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
+ ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
+ String _name_1 = _protocol_2.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
+ ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
+ boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
+ String _portClassName = this.roomExt.getPortClassName(_protocol_3, _isConjugated_2);
+ _builder.append(_portClassName, " ");
+ _builder.append("_");
+ Message _msg_1 = h.getMsg();
+ String _name_2 = _msg_1.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("_receiveHandler((etPort *)&");
+ String _path_1 = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append("_const.");
+ String _name_3 = pi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_1 = _peers_2.indexOf(peer);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("],msg,(void*)&");
+ String _path_2 = ai.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_1, " ");
+ _builder.append(",");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_4 = _actorClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
_builder.append("\t\t");
- _builder.append("//etPort_receive((etPort*)&");
+ _builder.append("\t");
+ _builder.append("default: ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_5 = _actorClass_1.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_receiveMessage((void*)&");
String _path_3 = ai.getPath();
String _pathName_2 = this.roomExt.getPathName(_path_3);
- _builder.append(_pathName_2, " ");
+ _builder.append(_pathName_2, " ");
+ _builder.append(",(etPort*)&");
+ String _path_4 = ai.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_4);
+ _builder.append(_pathName_3, " ");
_builder.append("_const.");
- String _name_3 = pi.getName();
- _builder.append(_name_3, " ");
+ String _name_6 = pi.getName();
+ _builder.append(_name_6, " ");
_builder.append(".ports[");
EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
int _indexOf_2 = _peers_3.indexOf(peer);
- _builder.append(_indexOf_2, " ");
+ _builder.append(_indexOf_2, " ");
_builder.append("], msg);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
- ActorClass _actorClass_1 = ai.getActorClass();
- String _name_4 = _actorClass_1.getName();
- _builder.append(_name_4, " ");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ ActorClass _actorClass_2 = ai.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
_builder.append("_receiveMessage((void*)&");
- String _path_4 = ai.getPath();
- String _pathName_3 = this.roomExt.getPathName(_path_4);
- _builder.append(_pathName_3, " ");
- _builder.append(",(etPort*)&");
String _path_5 = ai.getPath();
String _pathName_4 = this.roomExt.getPathName(_path_5);
_builder.append(_pathName_4, " ");
+ _builder.append(",(etPort*)&");
+ String _path_6 = ai.getPath();
+ String _pathName_5 = this.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_5, " ");
_builder.append("_const.");
- String _name_5 = pi.getName();
- _builder.append(_name_5, " ");
+ String _name_8 = pi.getName();
+ _builder.append(_name_8, " ");
_builder.append(".ports[");
EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
int _indexOf_3 = _peers_4.indexOf(peer);
@@ -1318,49 +1480,70 @@ public class SubSystemClassGen {
_builder.append(":");
_builder.newLineIfNotEmpty();
{
- InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
- ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
- boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_2, _isConjugated_2);
+ InterfaceItem _interfaceItem_4 = pi.getInterfaceItem();
+ ProtocolClass _protocol_4 = _interfaceItem_4.getProtocol();
+ boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_4, _isConjugated_3);
if (_handlesReceive_1) {
_builder.append("\t\t");
- InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
- ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
- boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
- String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3);
- _builder.append(_portClassName_1, " ");
- _builder.append("_handleReceive((etPort*)&");
- String _path_6 = ai.getPath();
- String _pathName_5 = this.roomExt.getPathName(_path_6);
- _builder.append(_pathName_5, " ");
- _builder.append("_const.");
- String _name_6 = pi.getName();
- _builder.append(_name_6, " ");
- _builder.append(",msg,(void*)&");
- String _path_7 = ai.getPath();
- String _pathName_6 = this.roomExt.getPathName(_path_7);
- _builder.append(_pathName_6, " ");
- _builder.append(",");
- ActorClass _actorClass_2 = ai.getActorClass();
- String _name_7 = _actorClass_2.getName();
- _builder.append(_name_7, " ");
- _builder.append("_receiveMessage);");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("//etPort_receive(&");
- String _path_8 = ai.getPath();
- String _pathName_7 = this.roomExt.getPathName(_path_8);
- _builder.append(_pathName_7, " ");
- _builder.append("_const.");
- String _name_8 = pi.getName();
- _builder.append(_name_8, " ");
- _builder.append(", msg);");
- _builder.newLineIfNotEmpty();
+ _builder.append("switch (msg->evtID){");
+ _builder.newLine();
+ {
+ InterfaceItem _interfaceItem_5 = pi.getInterfaceItem();
+ ProtocolClass _protocol_5 = _interfaceItem_5.getProtocol();
+ boolean _isConjugated_4 = this.roomExt.isConjugated(pi);
+ List<MessageHandler> _receiveHandlers_1 = this.roomExt.getReceiveHandlers(_protocol_5, _isConjugated_4);
+ for(final MessageHandler h_1 : _receiveHandlers_1) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ InterfaceItem _interfaceItem_6 = pi.getInterfaceItem();
+ ProtocolClass _protocol_6 = _interfaceItem_6.getProtocol();
+ String _name_9 = _protocol_6.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("_");
+ Message _msg_2 = h_1.getMsg();
+ String _codeName_1 = this.roomExt.getCodeName(_msg_2);
+ _builder.append(_codeName_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ InterfaceItem _interfaceItem_7 = pi.getInterfaceItem();
+ ProtocolClass _protocol_7 = _interfaceItem_7.getProtocol();
+ boolean _isConjugated_5 = this.roomExt.isConjugated(pi);
+ String _portClassName_1 = this.roomExt.getPortClassName(_protocol_7, _isConjugated_5);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("_");
+ Message _msg_3 = h_1.getMsg();
+ String _name_10 = _msg_3.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("_receiveHandler((etPort *)&");
+ String _path_7 = ai.getPath();
+ String _pathName_6 = this.roomExt.getPathName(_path_7);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_const.");
+ String _name_11 = pi.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(",msg,(void*)&");
+ String _path_8 = ai.getPath();
+ String _pathName_7 = this.roomExt.getPathName(_path_8);
+ _builder.append(_pathName_7, " ");
+ _builder.append(",");
+ ActorClass _actorClass_3 = ai.getActorClass();
+ String _name_12 = _actorClass_3.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
_builder.append("\t\t");
- ActorClass _actorClass_3 = ai.getActorClass();
- String _name_9 = _actorClass_3.getName();
- _builder.append(_name_9, " ");
+ _builder.append("default: ");
+ ActorClass _actorClass_4 = ai.getActorClass();
+ String _name_13 = _actorClass_4.getName();
+ _builder.append(_name_13, " ");
_builder.append("_receiveMessage((void*)&");
String _path_9 = ai.getPath();
String _pathName_8 = this.roomExt.getPathName(_path_9);
@@ -1370,8 +1553,32 @@ public class SubSystemClassGen {
String _pathName_9 = this.roomExt.getPathName(_path_10);
_builder.append(_pathName_9, " ");
_builder.append("_const.");
- String _name_10 = pi.getName();
- _builder.append(_name_10, " ");
+ String _name_14 = pi.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ ActorClass _actorClass_5 = ai.getActorClass();
+ String _name_15 = _actorClass_5.getName();
+ _builder.append(_name_15, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_11 = ai.getPath();
+ String _pathName_10 = this.roomExt.getPathName(_path_11);
+ _builder.append(_pathName_10, " ");
+ _builder.append(",(etPort*)&");
+ String _path_12 = ai.getPath();
+ String _pathName_11 = this.roomExt.getPathName(_path_12);
+ _builder.append(_pathName_11, " ");
+ _builder.append("_const.");
+ String _name_16 = pi.getName();
+ _builder.append(_name_16, " ");
_builder.append(", msg);");
_builder.newLineIfNotEmpty();
}
@@ -1392,7 +1599,7 @@ public class SubSystemClassGen {
_builder.append("\t\t\t");
_builder.append("etLogger_logErrorF(\"MessageService_Thread1_receiveMessage: address %d does not exist \", msg->address);");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("break;");
_builder.newLine();
_builder.append("\t");
diff --git a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
index 66c19c57c..d3b9fb263 100644
--- a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
@@ -38,3 +38,4 @@ Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
org.eclipse.xtext;bundle-version="2.1.1",
org.eclipse.xtext.xtend2.lib;bundle-version="2.1.1"
Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.etrice.generator.generic
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c
index 90b0f19cb..d8b94aa04 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c
@@ -16,13 +16,14 @@
#include "platform/etMemory.h"
#include <string.h>
+/*
void etPort_receive(const etPort* self, const etMessage* msg) {
ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive")
if (self->receiveMessageFunc!=NULL)
(self->receiveMessageFunc)(self->myActor, (void*)self, msg);
ET_MSC_LOGGER_SYNC_EXIT
}
-
+*/
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data) {
int offset = MEM_CEIL(sizeof(etMessage));
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
index 49321065a..f6fe71c2d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
@@ -21,8 +21,7 @@
#include "messaging/etMessageService.h"
typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
+ void* varData;
etMessageService* msgService;
etAddressId peerAddress;
etAddressId localId;
@@ -34,8 +33,7 @@ typedef struct {
} etPort;
typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
+ void* varData;
etMessageService* msgService;
etAddressId peerAddress;
etAddressId localId;
@@ -54,7 +52,7 @@ typedef struct {
typedef etPort* InterfaceItemBase;
-void etPort_receive(const etPort* self, const etMessage* msg);
+//void etPort_receive(const etPort* self, const etMessage* msg);
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etTimer.h b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etTimer.h
index 0491d653e..a3cc3fb37 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etTimer.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etTimer.h
@@ -11,8 +11,6 @@ void etTimer_init(void);
uint32 getNSecFromTarget(void);
uint32 getSecFromTarget(void);
-uint64 getTargetTimeUs(void);
-
void getTimeFromTarget(etTargetTime_t *t);
int isTimeGreaterThanActualTime(const etTargetTime_t *t);
diff --git a/tests/org.eclipse.etrice.core.config.tests/.classpath b/tests/org.eclipse.etrice.core.config.tests/.classpath
new file mode 100644
index 000000000..7e8449de0
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.config.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.etrice.core.config.tests/.project b/tests/org.eclipse.etrice.core.config.tests/.project
new file mode 100644
index 000000000..63e34047b
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.config.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.core.config.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.etrice.core.config.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.etrice.core.config.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..1d3dee48f
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.config.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: org.eclipse.etrice.core.config.tests
+Bundle-Vendor: My Company
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: org.eclipse.etrice.core.config.tests; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.etrice.core.config,
+ org.eclipse.etrice.core.config.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.xtext,
+ org.eclipse.xtext.junit4,
+ org.eclipse.xtext.ui.junit,
+ org.junit4,
+ org.eclipse.ui.workbench;resolution:=optional
+Import-Package: org.apache.log4j,
+ org.apache.commons.logging
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/tests/org.eclipse.etrice.core.config.tests/build.properties b/tests/org.eclipse.etrice.core.config.tests/build.properties
new file mode 100644
index 000000000..7ed56c2b7
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.config.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/,\
+ src-gen/
+bin.includes = META-INF/,\
+ .