summaryrefslogtreecommitdiffstats
path: root/test/src/test-c-inline.c
blob: c12ac7375d3fee845bfb7b1181ac62d97e66082b (plain)
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
#include <stdlib.h> // EXIT_SUCCESS
#include <stdio.h> // printf
#include <string.h> // memset

/**
 * Preprocess:
 * uscxml-transform -tc -i ./test-c-inline.c -o ./test-c-inline.c.scxml.c
 */

/** INLINE SCXML BEGIN
<scxml name="test-inline" datamodel="native">
	<state id="foo">
		<onentry>
			enteredFoo();
		</onentry>
	</state>
</scxml>
INLINE SCXML END */ 

/** 
 * These function can be called from within executable content
 */
void enteredFoo() {
	printf("Entered Foo!\n");
}

#include "test-c-inline.c.scxml.c"

int main(int argc, char** argv) {
	uscxml_ctx ctx;
	memset(&ctx, 0, sizeof(uscxml_ctx));
	ctx.machine = &USCXML_MACHINE_TEST_INLINE;
	
	int err = USCXML_ERR_OK;
	while(err != USCXML_ERR_DONE) {
		err = uscxml_step(&ctx);
	}
	
	return EXIT_SUCCESS;
}