PageRenderTime 25ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-15/SWIG/Examples/test-suite/overload_simple.i

#
Swig | 92 lines | 78 code | 14 blank | 0 comment | 0 complexity | 23f936023f49c2645c739822f08894ca MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1// Simple tests of overloaded functions
 2%module overload_simple
 3
 4#ifndef SWIG_NO_OVERLOAD
 5%immutable Spam::type;
 6
 7%inline %{
 8
 9struct Foo {
10};
11
12struct Bar {
13};
14
15char *foo(int) {
16   return (char*) "foo:int";
17}
18
19char *foo(double) {
20   return (char*) "foo:double";
21}
22
23char *foo(char *) {
24   return (char*) "foo:char *";
25}
26
27char *foo(Foo *) {
28   return (char*) "foo:Foo *";
29}
30char *foo(Bar *) {
31   return (char *) "foo:Bar *";
32}
33char *foo(void *) {
34   return (char *) "foo:void *";
35}
36
37class Spam {
38public:
39    Spam() { type = "none"; }
40    Spam(int) { type = "int"; }
41    Spam(double) { type = "double"; }
42    Spam(char *) { type = "char *"; }
43    Spam(Foo *) { type = "Foo *"; }
44    Spam(Bar *) { type = "Bar *"; }
45    Spam(void *) { type = "void *"; }
46    const char *type;
47
48char *foo(int) {
49   return (char*) "foo:int";
50}
51char *foo(double) {
52   return (char*) "foo:double";
53}
54char *foo(char *) {
55   return (char*) "foo:char *";
56}
57char *foo(Foo *) {
58   return (char*) "foo:Foo *";
59}
60char *foo(Bar *) {
61   return (char *) "foo:Bar *";
62}
63char *foo(void *) {
64   return (char *) "foo:void *";
65}
66
67static char *bar(int) {
68   return (char*) "bar:int";
69}
70static char *bar(double) {
71   return (char*) "bar:double";
72}
73static char *bar(char *) {
74   return (char*) "bar:char *";
75}
76static char *bar(Foo *) {
77   return (char*) "bar:Foo *";
78}
79static char *bar(Bar *) {
80   return (char *) "bar:Bar *";
81}
82static char *bar(void *) {
83   return (char *) "bar:void *";
84}
85};
86%}
87
88%include cmalloc.i
89%malloc(void);
90
91#endif
92