Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-01-16 07:42:50 -0500
committerThomas Schuetz2012-01-16 07:42:50 -0500
commit112cbb3dd645b3f91f573290e94d0499da0705c1 (patch)
tree6978fd9bd46e3d36a5fda4bdd0a067c4b1185ab8 /examples/org.eclipse.etrice.generator.c.reference
parenta1c1528bf5d71ba66eb99045edaf3a9fd9fb78f2 (diff)
downloadorg.eclipse.etrice-112cbb3dd645b3f91f573290e94d0499da0705c1.tar.gz
org.eclipse.etrice-112cbb3dd645b3f91f573290e94d0499da0705c1.tar.xz
org.eclipse.etrice-112cbb3dd645b3f91f573290e94d0499da0705c1.zip
[runtime.c] changed naming convention for runtime to prefix et (for eTrice)
Diffstat (limited to 'examples/org.eclipse.etrice.generator.c.reference')
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/CTypes.room21
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room3
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c24
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h33
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c18
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h25
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessage.c8
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c60
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.c58
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.h2
11 files changed, 83 insertions, 171 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/CTypes.room b/examples/org.eclipse.etrice.generator.c.reference/model/CTypes.room
new file mode 100644
index 000000000..9c76a085e
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/CTypes.room
@@ -0,0 +1,21 @@
+RoomModel room.basic.types.c {
+
+ PrimitiveType boolean -> boolean (boolean) default "FALSE"
+ PrimitiveType char -> char (char) default "0"
+ PrimitiveType int8 -> int8 (int8) default "0"
+ PrimitiveType int16 -> int16 (int16) default "0"
+ PrimitiveType int32 -> int32 (int32) default "0"
+ PrimitiveType int64 -> int64 (int64) default "0"
+
+ PrimitiveType uint8 -> uint8 (uint8) default "0"
+ PrimitiveType uint16 -> uint16 (uint16) default "0"
+ PrimitiveType uint32 -> uint32 (uint32) default "0"
+ PrimitiveType uint64 -> uint64 (uint64) default "0"
+
+ PrimitiveType float32 -> float32 (float32) default "0"
+ PrimitiveType float64 -> float64 (float64) default "0"
+
+ // TODO: define strings for C
+ // PrimitiveType string -> string (String) default "\"\""
+
+} \ No newline at end of file
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
index 9abeb2133..c1ec04d23 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
@@ -1,5 +1,6 @@
RoomModel cGenRef {
-
+ import room.basic.types.c.* from "CTypes.room"
+
SubSystemClass SS {
ActorRef Receiver: Receiver
ActorRef Sender: Sender
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c
deleted file mode 100644
index 715b0fb44..000000000
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "DataClass1.h"
-
-#include <string.h>
-
-//--------------------- begin user code
- // usercode3
-//--------------------- end user code
-
-// TODO: do we need setters and getters for C and C++ ?
-
-//--------------------- operations
-int32 DataClass1_MultiplyWithAttr1 (DataClass1* self, int32 value){
- return self->Attr1*value;
-}
-float32 DataClass1_MultiplyWithAttr3 (DataClass1* self, float32 value){
- return self->Attr3*value;
-}
-
-// deep copy
-void DataClass1_deepCopy(DataClass1* source, DataClass1* target) {
- memcpy(target, source, sizeof(DataClass1));
-}
-
-
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h
deleted file mode 100644
index 8c3708d72..000000000
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _DataClass1_H_
-#define _DataClass1_H_
-
-#include "datatypes.h"
-
-/* TODO: includes only for used DataClasses, also for other models */
-#include "DataClass2.h"
-
-//--------------------- begin user code
- // usercode1
-//--------------------- end user code
-
-typedef struct {
- //--------------------- begin user code
- // usercode2
- //--------------------- end user code
- //--------------------- attributes
- int32 Attr1;
- DataClass2 ComplexAttr;
- float32 Attr3;
-} DataClass1;
-
-// TODO: do we need setters and getters for C and C++ ?
-
-//--------------------- operations
-int32 DataClass1_MultiplyWithAttr1 (DataClass1* self, int32 value);
-float32 DataClass1_MultiplyWithAttr3 (DataClass1* self, float32 value);
-
-// deep copy
-void DataClass1_deepCopy(DataClass1* source, DataClass1* target);
-
-#endif /* _DataClass1_H_ */
-
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c
deleted file mode 100644
index 2a94fd07e..000000000
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "DataClass2.h"
-
-#include <string.h>
-
-
-// TODO: do we need setters and getters for C and C++ ?
-
-//--------------------- operations
-void DataClass2_Operation1 (DataClass2* self){
- /*nothing to do*/
-}
-
-// deep copy
-void DataClass2_deepCopy(DataClass2* source, DataClass2* target) {
- memcpy(target, source, sizeof(DataClass2));
-}
-
-
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h
deleted file mode 100644
index 6d7259267..000000000
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _DataClass2_H_
-#define _DataClass2_H_
-
-#include "datatypes.h"
-
-/* TODO: includes only for used DataClasses, also for other models */
-
-
-typedef struct {
- //--------------------- attributes
- int32 Attr1;
- float32 Attr2;
- int32 Attr3;
-} DataClass2;
-
-// TODO: do we need setters and getters for C and C++ ?
-
-//--------------------- operations
-void DataClass2_Operation1 (DataClass2* self);
-
-// deep copy
-void DataClass2_deepCopy(DataClass2* source, DataClass2* target);
-
-#endif /* _DataClass2_H_ */
-
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c b/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
index 6caff4b38..55aad6b4d 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
@@ -12,7 +12,7 @@
#include <stdio.h>
-#include "RUnit.h"
+#include "etUnit.h"
#include "test/generator/RunCGeneratorTestcases.h"
#include "test/runtime/RunCRuntimeTestcases.h"
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessage.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessage.c
index 087c99ff3..0dcd7e47d 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessage.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessage.c
@@ -13,15 +13,15 @@
#include "TestEtMessage.h"
#include <stddef.h>
-#include "RUnit.h"
-#include "RMessage.h"
+#include "etUnit.h"
+#include "etMessage.h"
void TestEtMessage_testBasicMessage(void){
- RMessage msg1 = {(RMessage*)1234567, 123,456,};
- RMessage msg2 = {NULL, 222,333};
+ etMessage msg1 = {(etMessage*)1234567, 123,456,};
+ etMessage msg2 = {NULL, 222,333};
// basic checks -> detects structure changes that would cause problems for generated code
EXPECT_EQUAL_PTR("Message.next", 1234567, msg1.next);
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
index 1708a4c85..bf60c7e69 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
@@ -11,29 +11,28 @@
*******************************************************************************/
#include "TestEtMessageQueue.h"
-#include "RUnit.h"
-#include "RMessageQueue.h"
+#include "etUnit.h"
+#include "etMessageQueue.h"
void TestEtMessageQueue_testPushPop(void){
- RUnit_openTestCase("testPushPop");
- RMessage msg1 = {NULL, 123, 456};
- RMessage msg2 = {NULL, 222, 333};
+ etMessage msg1 = {NULL, 123, 456};
+ etMessage msg2 = {NULL, 222, 333};
- RMessageQueue queue1;
- RMessageQueue_init(&queue1);
+ etMessageQueue queue1;
+ etMessageQueue_init(&queue1);
- RMessageQueue_push(&queue1, &msg1);
- RMessageQueue_push(&queue1, &msg2);
+ etMessageQueue_push(&queue1, &msg1);
+ etMessageQueue_push(&queue1, &msg2);
- EXPECT_EQUAL_INT16("RMessageQueue.size before", 2,queue1.size);
- EXPECT_EQUAL_INT16("RMessageQueue.highWaterMark before", 2, queue1.highWaterMark);
+ EXPECT_EQUAL_INT16("etMessageQueue.size before", 2,queue1.size);
+ EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark before", 2, queue1.highWaterMark);
- RMessage* rcvMsg1 = RMessageQueue_pop(&queue1);
- RMessage* rcvMsg2 = RMessageQueue_pop(&queue1);
+ etMessage* rcvMsg1 = etMessageQueue_pop(&queue1);
+ etMessage* rcvMsg2 = etMessageQueue_pop(&queue1);
- EXPECT_EQUAL_INT16("RMessageQueue.size after", 0,(int32)queue1.size);
- EXPECT_EQUAL_INT16("RMessageQueue.highWaterMark after", 2,queue1.highWaterMark);
+ EXPECT_EQUAL_INT16("etMessageQueue.size after", 0,(int32)queue1.size);
+ EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark after", 2,queue1.highWaterMark);
EXPECT_EQUAL_INT16("rcvMsg1->address", 123, rcvMsg1->address);
EXPECT_EQUAL_INT16("rcvMsg1->evtID", 456, rcvMsg1->evtID);
@@ -43,30 +42,28 @@ void TestEtMessageQueue_testPushPop(void){
EXPECT_EQUAL_INT16("rcvMsg2->evtID", 333, rcvMsg2->evtID);
EXPECT_EQUAL_PTR("rcvMsg2->next", NULL, rcvMsg2->next);
- EXPECT_EQUAL_PTR("RMessageQueue->first", NULL, queue1.first);
- EXPECT_EQUAL_PTR("RMessageQueue->last", NULL, queue1.last);
+ EXPECT_EQUAL_PTR("etMessageQueue->first", NULL, queue1.first);
+ EXPECT_EQUAL_PTR("etMessageQueue->last", NULL, queue1.last);
- RMessage* rcvMsg3 = RMessageQueue_pop(&queue1);
- EXPECT_EQUAL_PTR("RMessageQueue_pop if empty", NULL, rcvMsg3);
+ etMessage* rcvMsg3 = etMessageQueue_pop(&queue1);
+ EXPECT_EQUAL_PTR("etMessageQueue_pop if empty", NULL, rcvMsg3);
- RUnit_closeTestCase();
}
#define MAX 1000
void TestEtMessageQueue_testMassiveMessaging(void){
- RUnit_openTestCase("MassiveMessaging");
- RMessage msgArray[MAX];
- printf("sizeof(RMessage):%d\n", sizeof(RMessage));
+ etMessage msgArray[MAX];
+ printf("sizeof(etMessage):%d\n", sizeof(etMessage));
printf("size(msgArray):%d\n", sizeof(msgArray));
- RMessageQueue queue1;
- RMessageQueue_init(&queue1);
+ etMessageQueue queue1;
+ etMessageQueue_init(&queue1);
int16 i;
for(i=0; i<MAX; i++){
- //RMessage_init(&msgArray[i]);
+ //etMessage_init(&msgArray[i]);
msgArray[i].address = i;
msgArray[i].evtID = i;
}
@@ -74,10 +71,10 @@ void TestEtMessageQueue_testMassiveMessaging(void){
int j;
for(j=0; j<3; j++){
for (i=0; i<MAX; i++){
- RMessageQueue_push(&queue1, &(msgArray[i]));
+ etMessageQueue_push(&queue1, &(msgArray[i]));
}
for (i=0; i<MAX; i++){
- RMessage* msg = RMessageQueue_pop(&queue1);
+ etMessage* msg = etMessageQueue_pop(&queue1);
// EXPECTS are hidden to avoid too many testcases in log
if (msg == NULL){
EXPECT_FALSE("msg == NULL", TRUE);
@@ -94,12 +91,11 @@ void TestEtMessageQueue_testMassiveMessaging(void){
}
EXPECT_EQUAL_INT32("i==MAX", MAX, i);
}
- RUnit_closeTestCase();
}
void TestEtMessageQueue_runSuite(void){
- RUnit_openTestSuite("TestRMessageQueue");
- TestEtMessageQueue_testPushPop();
- TestEtMessageQueue_testMassiveMessaging();
+ RUnit_openTestSuite("TestetMessageQueue");
+ ADD_TESTCASE(TestEtMessageQueue_testPushPop);
+ ADD_TESTCASE(TestEtMessageQueue_testMassiveMessaging);
RUnit_closeTestSuite();
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.c
index ed14defb1..49ce679de 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.c
@@ -11,20 +11,19 @@
*******************************************************************************/
#include "TestEtMessageService.h"
-#include "RUnit.h"
-#include "RMessageService.h"
+#include "etUnit.h"
+#include "etMessageService.h"
void TestEtMessageService_init(void){
- RUnit_openTestCase("testRMessageService_init");
- RMessageService msgService;
+ etMessageService msgService;
int16 max = 6;
int16 blockSize = 32;
uint8 msgBuffer[max*blockSize];
- RMessageService_init(&msgService, msgBuffer, max, blockSize);
+ etMessageService_init(&msgService, msgBuffer, max, blockSize);
EXPECT_EQUAL_PTR("msgService.messagePool.first", msgBuffer, msgService.messagePool.first);
EXPECT_EQUAL_PTR("msgService.messagePool in between", &msgBuffer[3*blockSize], msgService.messagePool.first->next->next->next);
@@ -32,22 +31,20 @@ void TestEtMessageService_init(void){
EXPECT_EQUAL_PTR("msgService.messagePool.last(2)", &msgBuffer[5*blockSize], msgService.messagePool.last);
EXPECT_EQUAL_PTR("msgService.messagePool.last.next", 0, msgService.messagePool.last->next);
- RUnit_closeTestCase();
}
void TestEtMessageService_GetPushPopReturn(void){
- RUnit_openTestCase("testRMessageService_GetPushPopReturn");
- RMessageService msgService;
+ etMessageService msgService;
int16 max = 6;
int16 blockSize = 32;
uint8 msgBuffer[max*blockSize];
- RMessageService_init(&msgService, msgBuffer, max, blockSize);
+ etMessageService_init(&msgService, msgBuffer, max, blockSize);
// get messages from pool
- RMessage* msg1 = RMessageService_getMessageBuffer(&msgService, sizeof(RMessage));
- RMessage* msg2 = RMessageService_getMessageBuffer(&msgService, sizeof(RMessage));
+ etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
EXPECT_EQUAL_INT16("msgService.messagePool.size", 4, msgService.messagePool.size);
@@ -58,14 +55,14 @@ void TestEtMessageService_GetPushPopReturn(void){
msg2->evtID = 222;
// push messages to queue
- RMessageService_pushMessage(&msgService, msg2);
- RMessageService_pushMessage(&msgService, msg1);
+ etMessageService_pushMessage(&msgService, msg2);
+ etMessageService_pushMessage(&msgService, msg1);
EXPECT_EQUAL_INT16("msgService.messageQueue.size", 2, msgService.messageQueue.size);
// pop messages from queue
- RMessage* rcvMsg1 = RMessageService_popMessage(&msgService);
- RMessage* rcvMsg2 = RMessageService_popMessage(&msgService);
+ etMessage* rcvMsg1 = etMessageService_popMessage(&msgService);
+ etMessage* rcvMsg2 = etMessageService_popMessage(&msgService);
EXPECT_EQUAL_INT16("msgService.messageQueue.size",0, msgService.messageQueue.size);
@@ -75,48 +72,45 @@ void TestEtMessageService_GetPushPopReturn(void){
EXPECT_EQUAL_INT16("msgService.popMessage", 11, rcvMsg2->address);
EXPECT_EQUAL_INT16("msgService.popMessage", 111, rcvMsg2->evtID);
- RMessageService_returnMessageBuffer(&msgService, rcvMsg1);
- RMessageService_returnMessageBuffer(&msgService, rcvMsg2);
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg1);
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg2);
EXPECT_EQUAL_INT16("msgService.messagePool.size", 6, msgService.messagePool.size);
- RUnit_closeTestCase();
}
void TestEtMessageService_GetReturn(void){
- RUnit_openTestCase("testRMessageService_GetReturn");
- RMessageService msgService;
+ etMessageService msgService;
int16 max = 2;
int16 blockSize = 32;
uint8 msgBuffer[max*blockSize];
- RMessageService_init(&msgService, msgBuffer, max, blockSize);
+ etMessageService_init(&msgService, msgBuffer, max, blockSize);
// get on message too much from pool
- RMessage* msg1 = RMessageService_getMessageBuffer(&msgService, sizeof(RMessage));
- RMessage* msg2 = RMessageService_getMessageBuffer(&msgService, sizeof(RMessage));
- RMessage* msg3 = RMessageService_getMessageBuffer(&msgService, sizeof(RMessage));
+ etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessage* msg3 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
EXPECT_TRUE("msgService getMessageBuffer", msg1!=NULL);
EXPECT_TRUE("msgService getMessageBuffer", msg2!=NULL);
EXPECT_EQUAL_PTR("msgService getMessageBuffer", msg3, NULL);
// return messages
- RMessageService_returnMessageBuffer(&msgService, msg1);
- RMessageService_returnMessageBuffer(&msgService, msg2);
+ etMessageService_returnMessageBuffer(&msgService, msg1);
+ etMessageService_returnMessageBuffer(&msgService, msg2);
EXPECT_EQUAL_INT16("msgService.messagePool.size", 2, msgService.messagePool.size);
// get message bigger than blocksize
- RMessage* msg4 = RMessageService_getMessageBuffer(&msgService, 33);
+ etMessage* msg4 = etMessageService_getMessageBuffer(&msgService, 33);
EXPECT_EQUAL_PTR("msgService getMessageBuffer", msg4, NULL);
- RUnit_closeTestCase();
}
void TestEtMessageService_runSuite(void){
- RUnit_openTestSuite("TestRMessageService");
- TestEtMessageService_init();
- TestEtMessageService_GetPushPopReturn();
- TestEtMessageService_GetReturn();
+ RUnit_openTestSuite("TestEtMessageService");
+ ADD_TESTCASE(TestEtMessageService_init);
+ ADD_TESTCASE(TestEtMessageService_GetPushPopReturn);
+ ADD_TESTCASE(TestEtMessageService_GetReturn);
RUnit_closeTestSuite();
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.h
index 287ff8c8b..43a85baee 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageService.h
@@ -13,7 +13,7 @@
#ifndef _TESTRMESSAGESERVICE_H_
#define _TESTRMESSAGESERVICE_H_
-#include "RMessageService.h"
+#include "etMessageService.h"
void TestEtMessageService_runSuite(void);

Back to the top