annotate python/c3/examples/types.c3 @ 259:ac603eb66b63

Added function call
author Windel Bouwman
date Mon, 05 Aug 2013 20:41:25 +0200
parents 81752b0f85a5
children
rev   line source
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
1
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
2 /*
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
3 Demo of how to define types
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
4 */
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
5
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
6 package typedemo;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
7
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
8 type int A;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
9 type int B;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
10 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
11 int x, y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
12 A z;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
13 } C;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
14 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
15 C x;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
16 B y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
17 int z;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
18 } D;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
19
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
20 type D* E;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
21
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
22 function int testcast()
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
23 {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
24 var A a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
25 var B b;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
26 a = 3;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
27 b = a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
28 var C c;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
29 c.x = a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
30 c.z = c.y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
31 var D d;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
32 var E e;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
33 var D* e2;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
34 e = &d;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
35 e2 = e;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
36 e2->x.x = 22;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
37
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
38 return 0;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
39 }
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
40