Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_ffi_c_types.nit
1 in "C header" `{
2 struct s_a{
3 int x, y;
4 };
5 struct s_b{
6 struct s_a super;
7 int w, h;
8 };
9 `}
10
11 extern class A in "C" `{struct s_a*`}
12 new `{
13 struct s_a* v = malloc(sizeof(struct s_a));
14 v->x = 1;
15 v->y = 2;
16 return v;
17 `}
18 fun p `{
19 printf( "A< %d %d >\n", self->x, self->y );
20 `}
21 end
22
23 extern class B in "C" `{struct s_b*`}
24 super A
25 new `{
26 struct s_b* v = malloc(sizeof(struct s_b));
27 v->super.x = 3;
28 v->super.y = 4;
29 v->w = 5;
30 v->h = 6;
31 return v;
32 `}
33 redef fun p import super `{
34 printf( "B< " );
35 B_p___super(self);
36 printf( " %d %d >\n", self->w, self->h );
37 `}
38 end
39
40 extern class C
41 super A
42 new `{
43 struct s_a* v = malloc(sizeof(struct s_a));
44 v->x = 11;
45 v->y = 22;
46 return v;
47 `}
48 redef fun p `{
49 printf( "C< %d %d >\n", self->x, self->y );
50 `}
51 end
52
53 (new A).p
54 (new B).p
55 (new C).p
56