import source from 1.3.40
[external/swig.git] / Examples / modula3 / typemap / example.i
1 /* File : example.i */
2 %module Example
3
4 %pragma(modula3) unsafe="true";
5
6 %insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point;
7 %}
8 %insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point;
9 IMPORT M3toC;
10 IMPORT Ctypes AS C;
11 %}
12
13 /* Typemap applied to patterns of multiple arguments */
14
15 %typemap(m3rawinmode)   (char *outstr) %{VAR%}
16 %typemap(m3rawintype)   (char *outstr) %{CHAR%}
17 %typemap(m3wrapinmode)  (char *outstr, int size) %{VAR%}
18 %typemap(m3wrapintype)  (char *outstr, int size) %{ARRAY OF CHAR%}
19 %typemap(m3wrapargraw)  (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%}
20
21
22 %typemap(m3rawinmode)   (const struct Window *) %{READONLY%}
23 %typemap(m3wrapinmode)  (const struct Window *) %{READONLY%}
24 %typemap(m3rawintype)   (      struct Window *) %{Window%}
25 %typemap(m3wrapintype)  (      struct Window *) %{Window%}
26
27 %typemap(m3rawinmode)   (const char *str []) %{READONLY%}
28 %typemap(m3wrapinmode)  (const char *str []) %{READONLY%}
29 %typemap(m3rawintype)   (const char *str []) %{(*ARRAY OF*) C.char_star%}
30 %typemap(m3wrapintype)  (const char *str []) %{ARRAY OF TEXT%}
31 %typemap(m3wrapargvar)  (const char *str []) %{$1: REF ARRAY OF C.char_star;%}
32 %typemap(m3wrapargraw)  (const char *str []) %{$1[0]%}
33 %typemap(m3wrapinconv)  (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name));
34 FOR i:=FIRST($1_name) TO LAST($1_name) DO
35 $1[i]:=M3toC.SharedTtoS($1_name[i]);
36 END;%}
37 %typemap(m3wrapfreearg) (const char *str [])
38 %{FOR i:=FIRST($1_name) TO LAST($1_name) DO
39 M3toC.FreeSharedS($1_name[i],$1[i]);
40 END;%}
41
42 %typemap(m3wraprettype) char * %{TEXT%}
43 %typemap(m3wrapretvar)  char * %{result_string: C.char_star;%}
44 %typemap(m3wrapretraw)  char * %{result_string%}
45 %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%}
46
47 struct Window {
48   char *label;
49   int left,top,width,height;
50 };
51
52
53 %typemap(m3wrapinname) (int x, int y) %{p%}
54 %typemap(m3wrapinmode) (int x, int y) %{READONLY%}
55 %typemap(m3wrapintype) (int x, int y) %{Point%}
56 %typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%}
57
58 %typemap(m3wrapargraw)  (int &x, int &y) %{p.$1_name, p.$2_name%}
59 %typemap(m3wrapintype)  (int &x, int &y) %{Point%}
60 %typemap(m3wrapoutname) (int &x, int &y) %{p%}
61 %typemap(m3wrapouttype) (int &x, int &y) %{Point%}
62 %typemap(m3wrapargdir)  (int &x, int &y) "out"
63
64
65 %typemap(m3wrapargvar)  int &left, int &top, int &width, int &height "$1:C.int;"
66 %typemap(m3wrapargraw)  int &left, int &top, int &width, int &height "$1"
67 %typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1"
68
69 %typemap(m3wrapargdir)  int &left, int &top "out"
70
71 %typemap(m3wrapouttype) int &width, int &height "CARDINAL"
72 %typemap(m3wrapargdir)  int &width, int &height "out"
73
74 struct Point {
75   int x,y;
76 };
77
78 %m3multiretval get_box;
79
80 void  set_label       (      struct Window *win, const char *str, bool activate);
81 void  set_multi_label (      struct Window *win, const char *str []);
82 void  write_label     (const struct Window *win,       char *outstr, int size);
83 int   get_label       (const struct Window *win,       char *outstr, int size);
84 char *get_label_ptr   (const struct Window *win);
85 void  move(struct Window *win, int x, int y);
86 int   get_area(const struct Window *win);
87 void  get_box(const struct Window *win, int &left, int &top, int &width, int &height);
88 void  get_left(const struct Window *win, int &left);
89 void  get_mouse(const struct Window *win, int &x, int &y);
90 int   get_attached_data(const struct Window *win, const char *id);