PageRenderTime 34ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/modula3/typemap/example.i

#
Swig | 90 lines | 69 code | 19 blank | 2 comment | 0 complexity | ca2ffbb6d46b0b58ebf717ebca0fe414 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* File : example.i */
  2. %module Example
  3. %pragma(modula3) unsafe="true";
  4. %insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point;
  5. %}
  6. %insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point;
  7. IMPORT M3toC;
  8. IMPORT Ctypes AS C;
  9. %}
  10. /* Typemap applied to patterns of multiple arguments */
  11. %typemap(m3rawinmode) (char *outstr) %{VAR%}
  12. %typemap(m3rawintype) (char *outstr) %{CHAR%}
  13. %typemap(m3wrapinmode) (char *outstr, int size) %{VAR%}
  14. %typemap(m3wrapintype) (char *outstr, int size) %{ARRAY OF CHAR%}
  15. %typemap(m3wrapargraw) (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%}
  16. %typemap(m3rawinmode) (const struct Window *) %{READONLY%}
  17. %typemap(m3wrapinmode) (const struct Window *) %{READONLY%}
  18. %typemap(m3rawintype) ( struct Window *) %{Window%}
  19. %typemap(m3wrapintype) ( struct Window *) %{Window%}
  20. %typemap(m3rawinmode) (const char *str []) %{READONLY%}
  21. %typemap(m3wrapinmode) (const char *str []) %{READONLY%}
  22. %typemap(m3rawintype) (const char *str []) %{(*ARRAY OF*) C.char_star%}
  23. %typemap(m3wrapintype) (const char *str []) %{ARRAY OF TEXT%}
  24. %typemap(m3wrapargvar) (const char *str []) %{$1: REF ARRAY OF C.char_star;%}
  25. %typemap(m3wrapargraw) (const char *str []) %{$1[0]%}
  26. %typemap(m3wrapinconv) (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name));
  27. FOR i:=FIRST($1_name) TO LAST($1_name) DO
  28. $1[i]:=M3toC.SharedTtoS($1_name[i]);
  29. END;%}
  30. %typemap(m3wrapfreearg) (const char *str [])
  31. %{FOR i:=FIRST($1_name) TO LAST($1_name) DO
  32. M3toC.FreeSharedS($1_name[i],$1[i]);
  33. END;%}
  34. %typemap(m3wraprettype) char * %{TEXT%}
  35. %typemap(m3wrapretvar) char * %{result_string: C.char_star;%}
  36. %typemap(m3wrapretraw) char * %{result_string%}
  37. %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%}
  38. struct Window {
  39. char *label;
  40. int left,top,width,height;
  41. };
  42. %typemap(m3wrapinname) (int x, int y) %{p%}
  43. %typemap(m3wrapinmode) (int x, int y) %{READONLY%}
  44. %typemap(m3wrapintype) (int x, int y) %{Point%}
  45. %typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%}
  46. %typemap(m3wrapargraw) (int &x, int &y) %{p.$1_name, p.$2_name%}
  47. %typemap(m3wrapintype) (int &x, int &y) %{Point%}
  48. %typemap(m3wrapoutname) (int &x, int &y) %{p%}
  49. %typemap(m3wrapouttype) (int &x, int &y) %{Point%}
  50. %typemap(m3wrapargdir) (int &x, int &y) "out"
  51. %typemap(m3wrapargvar) int &left, int &top, int &width, int &height "$1:C.int;"
  52. %typemap(m3wrapargraw) int &left, int &top, int &width, int &height "$1"
  53. %typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1"
  54. %typemap(m3wrapargdir) int &left, int &top "out"
  55. %typemap(m3wrapouttype) int &width, int &height "CARDINAL"
  56. %typemap(m3wrapargdir) int &width, int &height "out"
  57. struct Point {
  58. int x,y;
  59. };
  60. %m3multiretval get_box;
  61. void set_label ( struct Window *win, const char *str, bool activate);
  62. void set_multi_label ( struct Window *win, const char *str []);
  63. void write_label (const struct Window *win, char *outstr, int size);
  64. int get_label (const struct Window *win, char *outstr, int size);
  65. char *get_label_ptr (const struct Window *win);
  66. void move(struct Window *win, int x, int y);
  67. int get_area(const struct Window *win);
  68. void get_box(const struct Window *win, int &left, int &top, int &width, int &height);
  69. void get_left(const struct Window *win, int &left);
  70. void get_mouse(const struct Window *win, int &x, int &y);
  71. int get_attached_data(const struct Window *win, const char *id);