[generator.cpp.reference] cleaned up reference project,
[generator.cpp] added const to all non ref attributes for generated
field constructor (DataClass)
[runtime.cpp] added getter function c_str to StaticString and added
typefef for StaticString<32>
Change-Id: I8d00801fdcce8e4ea94e5377caa6a376eb84fca0
diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room
index 0cc8810..5ff3f44 100644
--- a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room
+++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room
@@ -35,13 +35,10 @@
StateMachine {
State state0 {
entry {
- "\tsprintf(charArray.getData(), \"Hallo eTrice\"); // no very secure -> only for testcase"
- "\t//DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, \'A\', charArray);"
- "\tDAllDatatypes data;"
- "\tdata.attribute_char_array[3]=65;"
- "\tdata.attribute_string32 = \"Hallo\";"
- "\tdata.attribute_charPtr = charArray.getData();"
- "\tportSend.sendAllDatatypes(data);"
+ "sprintf(charArray.getData(), \"Hallo eTrice\"); // no very secure -> only for testcase"
+ "DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, 'A', charArray.getData(), std::string(\"ABC\"), string32(\"XYZ\"), (void*)0x0F0F, StaticArray<char, 4>(66), StaticArray<int32, 4>(55555));"
+ "data.printAll(\"data 1 send\");"
+ "portSend.sendAllDatatypes(data);"
}
}
Transition init: initial -> state0
@@ -51,9 +48,8 @@
<mirrorAllDatatypes: portSend>
}
action {
- "//printf(\"%d, %ld, %f, %d, %c, %s\\n\", data.attribute_int8, data.attribute_uint64, data.attribute_float64, data.attribute_boolean, data.attribute_char, data.attribute_charPtr);"
"// TODO: code proposals for data. do not work"
- "printf(\"\\nReceived: (%c, %s, %s)\\n\", data.attribute_char_array[3], data.attribute_string32.getData(), data.attribute_charPtr);"
+ "data.printAll(\"data 4 receive\");"
}
}
}
@@ -79,12 +75,11 @@
}
action {
"allDatatypes = data;"
- "printf(\"\\nEmpfangen: (%c, %s, %s)\\n\", data.attribute_char_array[3], data.attribute_string32.getData(), data.attribute_charPtr);"
- ""
+ "allDatatypes.printAll(\"data 2 receive\");"
"allDatatypes.attribute_char_array[3]++;"
"allDatatypes.attribute_string32+=\"2\";"
"allDatatypes.attribute_charPtr[0]=\'X\';"
- "printf(\"\\nGesendet: (%c, %s, %s)\\n\", allDatatypes.attribute_char_array[3], allDatatypes.attribute_string32.getData(), allDatatypes.attribute_charPtr);"
+ "allDatatypes.printAll(\"data 3 modify & send\");"
""
"portMirror.mirrorAllDatatypes(allDatatypes);"
}
@@ -184,10 +179,10 @@
ActorClass InheritanceDerivedClassSimple extends InheritanceBaseClassSimple {
Behavior {
- StateMachine { RefinedState state0 {
+ StateMachine {
+ RefinedState state0 {
subgraph {
- State state0
- {
+ State state0 {
entry {
"port.message0();"
}
@@ -200,7 +195,7 @@
}
}
}
- RefinedState state2 {
+ RefinedState state2 {
subgraph {
Transition tr0: my tp0 -> my tp1
}
diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room
index 5c2b087..7ac666f 100644
--- a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room
+++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room
@@ -1,41 +1,82 @@
//
-
RoomModel ReferenceCPP_DataClasses {
+
import room.basic.types.* from "../../org.eclipse.etrice.modellib.cpp/model/Types.room"
+
import room.basic.annotations.* from "../../org.eclipse.etrice.modellib.cpp/model/Annotations.room"
DataClass DAllDatatypes {
- // int
- Attribute attribute_int8 : int8
- Attribute attribute_int16 : int16
- Attribute attribute_int32 : int32
- Attribute attribute_int64 : int64
+ // int
+ Attribute attribute_int8: int8
+ Attribute attribute_int16: int16
+ Attribute attribute_int32: int32
+ Attribute attribute_int64: int64
// uint
- Attribute attribute_uint8 : uint8
- Attribute attribute_uint16 : uint16
- Attribute attribute_uint32 : uint32
- Attribute attribute_uint64 : uint64
-
+ Attribute attribute_uint8: uint8
+ Attribute attribute_uint16: uint16
+ Attribute attribute_uint32: uint32
+ Attribute attribute_uint64: uint64
+
// float
- Attribute attribute_float32 : float32
- Attribute attribute_float64 : float64
+ Attribute attribute_float32: float32
+ Attribute attribute_float64: float64
// others
- Attribute attribute_boolean : boolean
- Attribute attribute_char : char
- Attribute attribute_charPtr : charPtr
+ Attribute attribute_boolean: boolean
+ Attribute attribute_char: char
+ Attribute attribute_charPtr: charPtr
// strings
- Attribute attribute_string : string // maps to std::string attribute_string; (standard template library)
- Attribute attribute_string32 : string32 // maps to StaticString<32> attribute_string32; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
+ Attribute attribute_string: string // maps to std::string attribute_string; (standard template library)
+ Attribute attribute_string32: string32 // maps to StaticString<32> attribute_string32; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
// references
- Attribute attribute_voidTypeRef : voidType ref
-
+ Attribute attribute_voidTypeRef: voidType ref
+
// arrays
- Attribute attribute_char_array[4] : char // maps to StaticArray<char, 4> attribute_char_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
- Attribute attribute_int32_array[4] : int32 // maps to StaticArray<int32, 4> attribute_int32_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
- }
+ Attribute attribute_char_array [ 4 ]: char // maps to StaticArray<char, 4> attribute_char_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
+ Attribute attribute_int32_array [ 4 ]: int32 // maps to StaticArray<int32, 4> attribute_int32_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers)
+ Operation printAll(text: charPtr) {
+ "// This operation is only for testing purposes - do not use printf in embedded systems"
+ " "
+ " printf(\"\\n%s -> DAllDatatypes=(\" , text);"
+ " printf(\"%d, \", attribute_int8);"
+ " printf(\"%d, \", attribute_int16);"
+ " printf(\"%d, \", attribute_int32);"
+ ""
+ " printf(\"%d, \", attribute_uint8);"
+ " printf(\"%d, \", attribute_uint16);"
+ " printf(\"%d, \", attribute_uint32);"
+ ""
+ " printf(\"%f, \", attribute_float32);"
+ " printf(\"%f, \", attribute_float64);"
+ ""
+ " printf(\"%s, \", attribute_boolean ? \"true\" : \"false\");"
+ " printf(\"%c, \", attribute_char);"
+ " printf(\"%s, \", attribute_charPtr);"
+ ""
+ " printf(\"%s, \", attribute_string.c_str());"
+ " printf(\"%s, \", attribute_string32.c_str());"
+ ""
+ " printf(\"%.4x, \", (int32)attribute_voidTypeRef);"
+ ""
+ " printf(\"(\");"
+ " for (int i=0; i<attribute_char_array.getSize(); i++){"
+ " printf(\"%c\", attribute_char_array[i]);"
+ " }"
+ " printf(\"), \");"
+ ""
+ " printf(\"(\");"
+ " for (int i=0; i<attribute_int32_array.getSize(); i++){"
+ " printf(\"%d \", attribute_int32_array[i]);"
+ " }"
+ " printf(\") \");"
+ ""
+ " printf(\")\\n\" );"
+ ""
+ }
+ }
+
}
diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_StructureInheritance.room b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_StructureInheritance.room
new file mode 100644
index 0000000..c567769
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_StructureInheritance.room
@@ -0,0 +1,14 @@
+RoomModel ReferenceCPP_ActorClasses {
+
+ import ReferenceCPP_DataClasses.* from "ReferenceCPP_DataClasses.room"
+
+ import ReferenceCPP_ProtocolClasses.* from "ReferenceCPP_ProtocolClasses.room"
+
+ import room.basic.annotations.* from "../../org.eclipse.etrice.modellib.cpp/model/Annotations.room"
+
+ import room.basic.types.* from "../../org.eclipse.etrice.modellib.cpp/model/Types.room"
+
+
+
+// ActorClass
+}
\ No newline at end of file
diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.InheritanceBaseClassSimple.behavior b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.InheritanceBaseClassSimple.behavior
index e352d7b..3ed8a68 100644
--- a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.InheritanceBaseClassSimple.behavior
+++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.InheritanceBaseClassSimple.behavior
@@ -4,7 +4,7 @@
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#ActorClass:InheritanceBaseClassSimple"/>
</link>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="sg"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
@@ -13,10 +13,10 @@
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#StateGraph:InheritanceBaseClassSimple$sg"/>
</link>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/"/>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="trp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="40" height="40" x="100" y="100">
<graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/>
@@ -25,11 +25,11 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#StateGraph:InheritanceBaseClassSimple$sg"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="40" height="20" y="10" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="I"/>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="state"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="208" height="123" x="216" y="227">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="148" height="63" x="30" y="30" cornerHeight="20" cornerWidth="20">
@@ -56,10 +56,10 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#SimpleState:InheritanceBaseClassSimple$state0"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.2/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="148" height="63" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="state0"/>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="entp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="73">
@@ -77,11 +77,11 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#EntryPoint:InheritanceBaseClassSimple$state0$tp0"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.2"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_BOTTOM" value="tp0"/>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="extp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" y="38">
@@ -97,12 +97,12 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#ExitPoint:InheritanceBaseClassSimple$state0$tp1"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.1"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" y="37" font="//@fonts.0" verticalAlignment="ALIGNMENT_TOP" value="tp1"/>
</children>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="state"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="226" height="131" x="198" y="64">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="166" height="71" x="30" y="30" cornerHeight="20" cornerWidth="20">
@@ -129,11 +129,11 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#SimpleState:InheritanceBaseClassSimple$state1"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.2" incomingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.3/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="166" height="71" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="state1"/>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="state"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="208" height="123" x="207" y="358">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="148" height="63" x="30" y="30" cornerHeight="20" cornerWidth="20">
@@ -160,10 +160,10 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#SimpleState:InheritanceBaseClassSimple$state2"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.4/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="148" height="63" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="state2"/>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="entp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="60">
@@ -181,11 +181,11 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#EntryPoint:InheritanceBaseClassSimple$state2$tp0"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.1"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_BOTTOM" value="tp0"/>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="extp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="148" y="29">
@@ -201,12 +201,12 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#ExitPoint:InheritanceBaseClassSimple$state2$tp1"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.3"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" font="//@fonts.0" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_BOTTOM" value="tp1"/>
</children>
</children>
</children>
- <children xsi:type="pi:ContainerShape" active="true">
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="state"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="208" height="123" x="541" y="330">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="148" height="63" x="30" y="30" cornerHeight="20" cornerWidth="20">
@@ -233,7 +233,7 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#SimpleState:InheritanceBaseClassSimple$Done"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.3" referencedGraphicsAlgorithm="//@children.0/@children.5/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
- <children>
+ <children visible="true">
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="148" height="63" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Done"/>
</children>
</children>
@@ -293,7 +293,7 @@
</children>
</children>
</children>
- <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <children xsi:type="pi:ContainerShape" active="true">
<properties key="obj-type" value="sg"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
<graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
@@ -302,10 +302,10 @@
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#StateGraph:InheritanceBaseClassSimple$state2$sg"/>
</link>
- <children visible="true">
+ <children>
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/state2"/>
</children>
- <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <children xsi:type="pi:ContainerShape" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="entp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="226">
@@ -323,11 +323,11 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#EntryPoint:InheritanceBaseClassSimple$state2$tp0"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor"/>
- <children visible="true">
+ <children>
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="80" height="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_BOTTOM" value="tp0"/>
</children>
</children>
- <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <children xsi:type="pi:ContainerShape" active="true">
<properties key="obj-type" value="trp"/>
<properties key="item-kind" value="extp"/>
<graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="492">
@@ -343,76 +343,76 @@
<businessObjects href="../ReferenceCPP_ActorClasses.room#ExitPoint:InheritanceBaseClassSimple$state2$tp1"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor"/>
- <children visible="true">
+ <children>
<graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="80" height="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_BOTTOM" value="tp1"/>
</children>
</children>
</children>
- <connections xsi:type="pi:FreeFormConnection" active="true" start="//@children.0/@children.1/@anchors.0" end="//@children.0/@children.3/@anchors.0">
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.1/@anchors.0" end="//@children.0/@children.3/@anchors.0">
<properties key="obj-type" value="trans"/>
<graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#InitialTransition:InheritanceBaseClassSimple$initial"/>
</link>
- <connectionDecorators locationRelative="true" location="1.0">
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
<graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
<points x="-15" y="5"/>
<points/>
<points x="-15" y="-5"/>
</graphicsAlgorithm>
</connectionDecorators>
- <connectionDecorators active="true" locationRelative="true" location="0.5">
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
<graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="init"/>
</connectionDecorators>
</connections>
- <connections xsi:type="pi:FreeFormConnection" active="true" start="//@children.0/@children.2/@children.2/@anchors.0" end="//@children.0/@children.4/@children.1/@anchors.0">
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@children.2/@anchors.0" end="//@children.0/@children.4/@children.1/@anchors.0">
<properties key="obj-type" value="trans"/>
<graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#ContinuationTransition:InheritanceBaseClassSimple$tr0"/>
</link>
- <connectionDecorators locationRelative="true" location="1.0">
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
<graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
<points x="-15" y="5"/>
<points/>
<points x="-15" y="-5"/>
</graphicsAlgorithm>
</connectionDecorators>
- <connectionDecorators active="true" locationRelative="true" location="0.5">
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
<graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="tr0: "/>
</connectionDecorators>
</connections>
- <connections xsi:type="pi:FreeFormConnection" active="true" start="//@children.0/@children.3/@anchors.0" end="//@children.0/@children.2/@children.1/@anchors.0">
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.3/@anchors.0" end="//@children.0/@children.2/@children.1/@anchors.0">
<properties key="obj-type" value="trans"/>
<graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#TriggeredTransition:InheritanceBaseClassSimple$tr1"/>
</link>
- <connectionDecorators locationRelative="true" location="1.0">
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
<graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
<points x="-15" y="5"/>
<points/>
<points x="-15" y="-5"/>
</graphicsAlgorithm>
</connectionDecorators>
- <connectionDecorators active="true" locationRelative="true" location="0.5">
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
<graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="-67" y="-8" font="//@fonts.0" value="tr1: <reply2:port>"/>
</connectionDecorators>
</connections>
- <connections xsi:type="pi:FreeFormConnection" active="true" start="//@children.0/@children.4/@children.2/@anchors.0" end="//@children.0/@children.5/@anchors.0">
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.4/@children.2/@anchors.0" end="//@children.0/@children.5/@anchors.0">
<properties key="obj-type" value="trans"/>
<graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
<link>
<businessObjects href="../ReferenceCPP_ActorClasses.room#ContinuationTransition:InheritanceBaseClassSimple$tr2"/>
</link>
- <connectionDecorators locationRelative="true" location="1.0">
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
<graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
<points x="-15" y="5"/>
<points/>
<points x="-15" y="-5"/>
</graphicsAlgorithm>
</connectionDecorators>
- <connectionDecorators active="true" locationRelative="true" location="0.5">
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
<graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="tr2: "/>
</connectionDecorators>
</connections>
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
index ca2d266..c73e7ad 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.xtend
@@ -34,4 +34,15 @@
}
}
+ /**
+ * @param attributes a list of {@link Attribute}s
+ * @return an argument list for the attributes with const except for ref {@link Attribute}s
+ */
+ def constArgList(Iterable<Attribute> attributes) {
+ attributes.map[(if(!type.ref) 'const ' else '' ) + signatureString + ' ' + name].join(', ')
+ }
+
+
+
+
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 20f92d5..8c31b08 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -20,7 +20,6 @@
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.ComplexType
import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.core.room.util.RoomHelpers
@@ -31,7 +30,7 @@
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension CppExtensions stdExt
@Inject extension RoomExtensions roomExt
- @Inject extension ProcedureHelpers helpers
+ @Inject extension CppProcedureHelpers helpers
// @Inject extension TypeHelpers typeHelpers
@Inject Initialization initHelper
@Inject extension RoomHelpers
@@ -92,10 +91,11 @@
// default constructor, copy constructor and assignment operator
«dc.name»();
«dc.name»(const «dc.name»& rhs);
+ // constructor using fields
+ «IF !dc.allAttributes.empty»«dc.name»(«dc.allAttributes.constArgList»);«ENDIF»
+
«dc.name»& operator=(const «dc.name»& rhs);
- // constructor using fields
- «IF !dc.allAttributes.empty»«dc.name»(«dc.allAttributes.argList»);«ENDIF»
};
«dc.generateNamespaceEnd»
@@ -138,7 +138,7 @@
// constructor using fields
// TODO
«IF !dc.allAttributes.empty»
- «dc.name»::«dc.name»(«dc.allAttributes.argList»)
+ «dc.name»::«dc.name»(«dc.allAttributes.constArgList»)
«dc.generateFieldInitializerList»
{
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.java
index 20cb159..e5e1372 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppProcedureHelpers.java
@@ -5,6 +5,8 @@
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class CppProcedureHelpers extends ProcedureHelpers {
@@ -117,4 +119,31 @@
}
return _switchResult;
}
+
+ /**
+ * @param attributes a list of {@link Attribute}s
+ * @return an argument list for the attributes with const except for ref {@link Attribute}s
+ */
+ public String constArgList(final Iterable<Attribute> attributes) {
+ final Function1<Attribute, String> _function = new Function1<Attribute, String>() {
+ public String apply(final Attribute it) {
+ String _xifexpression = null;
+ RefableType _type = it.getType();
+ boolean _isRef = _type.isRef();
+ boolean _not = (!_isRef);
+ if (_not) {
+ _xifexpression = "const ";
+ } else {
+ _xifexpression = "";
+ }
+ String _signatureString = CppProcedureHelpers.this.signatureString(it);
+ String _plus = (_xifexpression + _signatureString);
+ String _plus_1 = (_plus + " ");
+ String _name = it.getName();
+ return (_plus_1 + _name);
+ }
+ };
+ Iterable<String> _map = IterableExtensions.<Attribute, String>map(attributes, _function);
+ return IterableExtensions.join(_map, ", ");
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
index f71c8a4..40f2096 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -29,8 +29,8 @@
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.cpp.gen.CppProcedureHelpers;
import org.eclipse.etrice.generator.cpp.gen.Initialization;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
@@ -57,7 +57,7 @@
@Inject
@Extension
- private ProcedureHelpers helpers;
+ private CppProcedureHelpers helpers;
@Inject
private Initialization initHelper;
@@ -227,15 +227,6 @@
_builder.append("& rhs);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- String _name_10 = dc.getName();
- _builder.append(_name_10, "\t");
- _builder.append("& operator=(const ");
- String _name_11 = dc.getName();
- _builder.append(_name_11, "\t");
- _builder.append("& rhs);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
_builder.append("// constructor using fields");
_builder.newLine();
_builder.append("\t");
@@ -244,16 +235,26 @@
boolean _isEmpty = _allAttributes.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
- String _name_12 = dc.getName();
- _builder.append(_name_12, "\t");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, "\t");
_builder.append("(");
List<Attribute> _allAttributes_1 = this._roomHelpers.getAllAttributes(dc);
- String _argList = this.helpers.argList(_allAttributes_1);
- _builder.append(_argList, "\t");
+ String _constArgList = this.helpers.constArgList(_allAttributes_1);
+ _builder.append(_constArgList, "\t");
_builder.append(");");
}
}
_builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, "\t");
+ _builder.append("& operator=(const ");
+ String _name_12 = dc.getName();
+ _builder.append(_name_12, "\t");
+ _builder.append("& rhs);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
_builder.append("};");
_builder.newLine();
_builder.newLine();
@@ -369,8 +370,8 @@
_builder.append(_name_7, "");
_builder.append("(");
List<Attribute> _allAttributes_1 = this._roomHelpers.getAllAttributes(dc);
- String _argList = this.helpers.argList(_allAttributes_1);
- _builder.append(_argList, "");
+ String _constArgList = this.helpers.constArgList(_allAttributes_1);
+ _builder.append(_constArgList, "");
_builder.append(")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/StaticString.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/StaticString.h
index ffa5303..d4b8a11 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/StaticString.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/StaticString.h
@@ -61,6 +61,14 @@
}
/**
+ * returns a const char * pointer to the data of this array
+ */
+ const char* c_str(void) const {
+ return this->data;
+ }
+
+
+ /**
* forwards to operator=(const char *rhs)
*/
template<int RhsSize> StaticString<Size>& operator=(const StaticString<RhsSize> &rhs) {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/etDatatypesCpp.hpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/etDatatypesCpp.hpp
index 1df838f..02e2d37 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/etDatatypesCpp.hpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/etDatatypesCpp.hpp
@@ -17,6 +17,9 @@
#include "common/containers/StaticArray.h"
#include "common/containers/StaticString.h"
+
+typedef etRuntime::StaticString<32> string32;
+
#include "etUnit/etUnit.h" // TODO move to tests
#include <string>