From c01056aecc5004661c73e5f5b7162310bc0dc5c5 Mon Sep 17 00:00:00 2001
From: Henrik Rentz-Reichert
Date: Thu, 14 Feb 2013 15:05:24 +0100
Subject: [runtime.c, generator.c, generator.c.tests] bug 400678: variable
declarations should be at beginning of block https://bugs.eclipse.org/400678
Improved ANSI compliance of the runtime and generated code
- no use of // comments
- variable declarations not after first statement---
.../eclipse/etrice/generator/c/gen/DataClassGen.xtend | 1 -
.../etrice/generator/c/gen/ProtocolClassGen.xtend | 1 -
.../eclipse/etrice/generator/c/gen/StateMachineGen.xtend | 4 ++--
.../org/eclipse/etrice/generator/c/gen/DataClassGen.java | 2 --
.../eclipse/etrice/generator/c/gen/ProtocolClassGen.java | 2 --
.../eclipse/etrice/generator/c/gen/StateMachineGen.java | 16 ++++++----------
.../src/common/messaging/etMessageQueue.c | 2 +-
.../src/common/modelbase/etPort.h | 2 +-
.../src/config/etRuntimeConfig.h | 2 +-
tests/org.eclipse.etrice.generator.c.tests/make.xml | 5 +++++
.../models/SendingDataTestC.room | 12 ++++++------
11 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index d7a97691f..e9933c85a 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -111,7 +111,6 @@ class DataClassGen {
«dc.operations.operationsImplementation(dc.name)»
- // deep copy
void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
memcpy(target, source, sizeof(«dc.name»));
}
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 641c97704..3d1ddf5f1 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
@@ -291,7 +291,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«pc.getPortClass(conj).operations.operationsImplementation(replPortClassName)»
«ENDIF»
- // getReplication
etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
return ((etReplPort*)self)->size;
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index ee3dbe5ca..5bde0cde3 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -59,11 +59,11 @@ class StateMachineGen extends GenericStateMachineGenerator {
override protected genExtra(ExpandedActorClass xpac) {
val ac = xpac.actorClass
'''
-
+
«langExt.accessLevelPrivate»void setState(«ac.name»* self, int new_state) {
self->state = new_state;
}
-
+
«langExt.accessLevelPrivate»int getState(«ac.name»* self) {
return self->state;
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 531521bc1..49b9bb464 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -220,8 +220,6 @@ public class DataClassGen {
_builder.append(_operationsImplementation, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("// deep copy");
- _builder.newLine();
_builder.append("void ");
String _name_2 = dc.getName();
_builder.append(_name_2, "");
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 f3f3b1534..315a87858 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
@@ -988,8 +988,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
}
_builder.newLine();
- _builder.append("// getReplication");
- _builder.newLine();
_builder.append("etInt32 ");
_builder.append(replPortClassName, "");
_builder.append("_getReplication(const ");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index 8dfe6a6c2..5bcbbf21b 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -102,33 +102,29 @@ public class StateMachineGen extends GenericStateMachineGenerator {
final ActorClass ac = xpac.getActorClass();
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
- _builder.append("\t\t");
String _accessLevelPrivate = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate, " ");
+ _builder.append(_accessLevelPrivate, "");
_builder.append("void setState(");
String _name = ac.getName();
- _builder.append(_name, " ");
+ _builder.append(_name, "");
_builder.append("* self, int new_state) {");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
+ _builder.append("\t");
_builder.append("self->state = new_state;");
_builder.newLine();
- _builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
- _builder.append("\t\t");
String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_1, " ");
+ _builder.append(_accessLevelPrivate_1, "");
_builder.append("int getState(");
String _name_1 = ac.getName();
- _builder.append(_name_1, " ");
+ _builder.append(_name_1, "");
_builder.append("* self) {");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
+ _builder.append("\t");
_builder.append("return self->state;");
_builder.newLine();
- _builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_xblockexpression = (_builder);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
index b1a5fea54..16583e7d6 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
@@ -25,7 +25,7 @@ void etMessageQueue_init(etMessageQueue* self){
void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
- // TODO: optimize queue for concurrent push / pop
+ /* TODO: optimize queue for concurrent push / pop */
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push")
if (self->first == NULL) {
/*no message in queue*/
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 dbeeaa7e0..302b6f34c 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
@@ -52,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/config/etRuntimeConfig.h b/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
index b1759ab47..9e5549a7d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
@@ -23,7 +23,7 @@
/* timing and scheduling */
#define FREQUENCY 10L
#define ET_RUNTIME_MAXLOOP 100
-//#define ET_RUNTIME_ENDLESS
+/*#define ET_RUNTIME_ENDLESS*/
/* pool and block size */
#define MESSAGE_POOL_MAX 50
diff --git a/tests/org.eclipse.etrice.generator.c.tests/make.xml b/tests/org.eclipse.etrice.generator.c.tests/make.xml
index 32004214a..594edc733 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.c.tests/make.xml
@@ -145,6 +145,7 @@
+
@@ -191,6 +192,7 @@
+
@@ -226,6 +228,7 @@
+
@@ -261,6 +264,7 @@
+
@@ -302,6 +306,7 @@
+
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestC.room b/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestC.room
index d9ead4eda..cabf33299 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestC.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestC.room
@@ -187,7 +187,7 @@ RoomModel SendingDataTestC {
"caseId = etUnit_openAll(\"tmp\", \"SendingDataTestC\", \"org.eclipse.etrice.generator.common.tests.SendingDataTest\", \"SendingDataTest_case\");"
"EXPECT_ORDER_START(caseId,resultlist,23);"
"EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);"
- "// send the default values"
+ "/* send the default values */"
""
"PingPongPort.pingInt8(i8Val);"
"PingPongPort.pingInt16(i16Val);"
@@ -270,7 +270,7 @@ RoomModel SendingDataTestC {
action {
"counter=0;"
"if (lang == 1){"
- "// Java cannot send references of primitive types"
+ "/* Java cannot send references of primitive types */"
"\tif (d==4711){\t"
"\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);"
"\t}else{"
@@ -278,7 +278,7 @@ RoomModel SendingDataTestC {
"\t}"
"} "
"if (lang == 2){"
- "// C"
+ "/* C */"
"\tif (d==4712){\t"
"\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);"
"\t}else{"
@@ -427,7 +427,7 @@ RoomModel SendingDataTestC {
action {
"counter++;"
"if (lang == 1){"
- "// Java cannot send references of primitive types"
+ "/* Java cannot send references of primitive types */"
"\tif (d==19){\t"
"\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);"
"\t}else{"
@@ -435,7 +435,7 @@ RoomModel SendingDataTestC {
"\t}"
"} "
"if (lang == 2){"
- "// C"
+ "/* C */"
"\tif (d==20){\t"
"\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);"
"\t}else{"
@@ -477,7 +477,7 @@ RoomModel SendingDataTestC {
Transition tr0: my tp0 -> state0 {
action {
"counter=0;"
- "// send default values"
+ "/* send default values */"
"PingPongPort.pingComplex(&(data));"
"PingPongPort.pingComplexRef(&(data));"
}
--
cgit v1.2.3