Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 12933cbcef1737a314d47baa16c9048eae5fc3d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
RoomModel VarargsTest {

	import room.basic.types.boolean
	import room.basic.types.int32
	import room.basic.types.string
	import room.basic.test.TestInstance

	ActorClass AVarargs {
		@TestInstance
		Structure {
			Attribute caseId : int32
			
			Port port: PVarargs
			Attribute attr: DVarargs
			Attribute text : string = "text"
		}
		Behavior {

			// varargs keyword is hidden in proposals -> internal use
			Operation log(format: string, args: string varargs) ''''''
			Operation single(args: string varargs) ''''''
			Operation callTest() '''
				//log("text");	// does not work in C due varargs macro
				log("text %d", "5");
				log("text %d, %s", "5", text);
				//single();		// does not work in C due varargs macro
				single("5");
				single("5", "txt");
								
				port.callTest();
							
				//port.log("text");
				port.log("text %d", "5");
				port.log("text %d, %s", "5", "txt");
				//port.single();
				port.single("5");
				port.single("5", "txt");
				
				// not supported by translation
				/* 
				//attr.callTest();
				//attr.log("text");
				attr.log("text %d", "5");
				attr.log("text %d, %s", "5", "txt");
				//attr.single();
				attr.single("5");
				attr.single("5", "txt");
				*/
			'''
			
			ctor '''
				caseId = etUnit_openAll("log", "VarargsTest", "org.eclipse.etrice.generator.common.tests.VarargsTest", "VarargsTest_case");
			'''
			dtor '''
				etUnit_closeAll(caseId);
			'''
			StateMachine {
				Transition init: initial -> finish
				State finish {
					entry '''
						callTest();
						etUnit_testFinished(caseId);
					'''
				}
			}
		}
	}

	ProtocolClass PVarargs {
		incoming {
			Message dummy()
		}
		regular PortClass
		{
			Operation log(format: string, args: string varargs) ''''''
			Operation single(args: string varargs) ''''''
			Operation callTest() '''
				//log("text");
				log("text %d", "5");
				log("text %d, %s", "5", "txt");
				//single();
				single("5");
				single("5", "txt");
			'''
		}
	}

	DataClass DVarargs {
		Attribute dummy: boolean

		// varargs keyword is hidden in proposals -> internal use
		Operation log(format: string, args: string varargs) ''''''
		Operation single(args: string varargs) ''''''
		Operation callTest() '''
			//log("text");
			log("text %d", "5");
			log("text %d, %s", "5", "txt");
			//single();
			single("5");
			single("5", "txt");
		'''
	}
}

Back to the top