annotate lib/swig/swigwin-2.0.11/Lib/swig.swg @ 1983:5cd26f2c6904

small fix
author Ritor1
date Fri, 01 Nov 2013 17:29:49 +0600
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * swig.swg
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 * Common macro definitions for various SWIG directives. This file is always
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * included at the top of each input file.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 * User Directives
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 /* Deprecated SWIG directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 #define %disabledoc %warn "104:%disabledoc is deprecated"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 #define %enabledoc %warn "105:%enabledoc is deprecated"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 #define %doconly %warn "106:%doconly is deprecated"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 #define %style %warn "107:%style is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 #define %localstyle %warn "108:%localstyle is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 #define %title %warn "109:%title is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 #define %section %warn "110:%section is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 #define %subsection %warn "111:%subsection is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22 #define %subsubsection %warn "112:%subsubsection is deprecated" /##/
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 #define %new %warn "117:%new is deprecated. Use %newobject"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 #define %text %insert("null")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 /* Code insertion directives such as %wrapper %{ ... %} */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 #define %begin %insert("begin")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 #define %runtime %insert("runtime")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 #define %header %insert("header")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31 #define %wrapper %insert("wrapper")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 #define %init %insert("init")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 /* Class extension */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 #define %addmethods %warn "113:%addmethods is now %extend" %extend
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 /* %ignore directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 #define %ignore %rename($ignore)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 #define %ignorewarn(x) %rename("$ignore:" x)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 /* Access control directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 #define %readonly %warn "114:%readonly is deprecated. Use %immutable; " %feature("immutable");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 #define %readwrite %warn "115:%readwrite is deprecated. Use %mutable; " %feature("immutable","");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 #define %immutable %feature("immutable")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 #define %noimmutable %feature("immutable","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 #define %clearimmutable %feature("immutable","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 #define %mutable %clearimmutable
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 /* Generation of default constructors/destructors (old form, don't use) */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 #define %nodefault %feature("nodefault","1")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 #define %default %feature("nodefault","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 #define %clearnodefault %feature("nodefault","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 #define %makedefault %clearnodefault
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 /* Disable the generation of implicit default constructor */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 #define %nodefaultctor %feature("nodefaultctor","1")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 #define %defaultctor %feature("nodefaultctor","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 #define %clearnodefaultctor %feature("nodefaultctor","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 /* Disable the generation of implicit default destructor (dangerous) */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 #define %nodefaultdtor %feature("nodefaultdtor","1")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 #define %defaultdtor %feature("nodefaultdtor","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 #define %clearnodefaultdtor %feature("nodefaultdtor","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 /* Enable the generation of copy constructor */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 #define %copyctor %feature("copyctor","1")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 #define %nocopyctor %feature("copyctor","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 #define %clearcopyctor %feature("copyctor","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 /* Force the old nodefault behavior, ie disable both constructor and destructor */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 #define %oldnodefault %feature("oldnodefault","1")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 #define %nooldnodefault %feature("oldnodefault","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 #define %clearoldnodefault %feature("oldnodefault","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 /* the %exception directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 #if defined(SWIGCSHARP) || defined(SWIGD)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81 #define %exception %feature("except", canthrow=1)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82 #else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 #define %exception %feature("except")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85 #define %noexception %feature("except","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 #define %clearexception %feature("except","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 /* the %allowexception directive allows the %exception feature to
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 be applied to set/get variable methods */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 #define %allowexception %feature("allowexcept")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 #define %noallowexception %feature("allowexcept","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 #define %clearallowexception %feature("allowexcept","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 /* the %exceptionvar directive, as %exception but it is only applied
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 to set/get variable methods. You don't need to use the
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 %allowexception directive when using %exceptionvar.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 #if defined(SWIGCSHARP) || defined(SWIGD)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 #define %exceptionvar %feature("exceptvar", canthrow=1)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 #else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101 #define %exceptionvar %feature("exceptvar")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103 #define %noexceptionvar %feature("exceptvar","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 #define %clearexceptionvar %feature("exceptvar","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106 /* the %catches directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 #define %catches(tlist...) %feature("catches","("`tlist`")")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108 #define %clearcatches %feature("catches","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 /* the %exceptionclass directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 #define %exceptionclass %feature("exceptionclass")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 #define %noexceptionclass %feature("exceptionclass","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113 #define %clearexceptionclass %feature("exceptionclass","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 /* the %newobject directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116 #define %newobject %feature("new")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117 #define %nonewobject %feature("new","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118 #define %clearnewobject %feature("new","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 /* the %delobject directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 #define %delobject %feature("del")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 #define %nodelobject %feature("del","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123 #define %cleardelobject %feature("del","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125 /* the %refobject/%unrefobject directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126 #define %refobject %feature("ref")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 #define %norefobject %feature("ref","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128 #define %clearrefobject %feature("ref","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
129
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
130 #define %unrefobject %feature("unref")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
131 #define %nounrefobject %feature("unref","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
132 #define %clearunrefobject %feature("unref","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
133
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
134 /* Directives for callback functions (experimental) */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
135 #define %callback(x) %feature("callback",`x`)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
136 #define %nocallback %feature("callback","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
137 #define %clearcallback %feature("callback","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
138
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
139 /* the %nestedworkaround directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
140 #define %nestedworkaround %feature("nestedworkaround")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
141 #define %nonestedworkaround %feature("nestedworkaround","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
142 #define %clearnestedworkaround %feature("nestedworkaround","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
143
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
144 /* the %fastdispatch directive */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
145 #define %fastdispatch %feature("fastdispatch")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
146 #define %nofastdispatch %feature("fastdispatch","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
147 #define %clearfastdispatch %feature("fastdispatch","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
148
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
149 /* directors directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
150 #define %director %feature("director")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
151 #define %nodirector %feature("director","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
152 #define %cleardirector %feature("director","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
153
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
154 /* naturalvar directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
155 #define %naturalvar %feature("naturalvar")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
156 #define %nonaturalvar %feature("naturalvar","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
157 #define %clearnaturalvar %feature("naturalvar","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
158
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
159 /* nspace directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
160 #define %nspace %feature("nspace")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
161 #define %nonspace %feature("nspace","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
162 #define %clearnspace %feature("nspace","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
163
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
164 /* valuewrapper directives */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
165 #define %valuewrapper %feature("valuewrapper")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
166 #define %clearvaluewrapper %feature("valuewrapper","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
167 #define %novaluewrapper %feature("novaluewrapper")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
168 #define %clearnovaluewrapper %feature("novaluewrapper","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
169
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
170 /* Contract support - Experimental and undocumented */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
171 #define %contract %feature("contract")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
172 #define %nocontract %feature("contract","0")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
173 #define %clearcontract %feature("contract","")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
174
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
175 /* Macro for setting a dynamic cast function */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
176 %define DYNAMIC_CAST(mangle,func)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
177 %init %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
178 mangle->dcast = (swig_dycast_func) func;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
179 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
180 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
181
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
182 /* aggregation support */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
183 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
184 This macro performs constant aggregation. Basically the idea of
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
185 constant aggregation is that you can group a collection of constants
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
186 together. For example, suppose you have some code like this:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
187
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
188 #define UP 1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
189 #define DOWN 2
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
190 #define LEFT 3
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
191 #define RIGHT 4
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
192
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
193 Now, suppose you had a function like this:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
194
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
195 int move(int direction)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
196
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
197 In this case, you might want to restrict the direction argument to
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
198 one of the supplied constant names. To do this, you could write some
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
199 typemap code by hand. Alternatively, you can use the
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
200 %aggregate_check macro defined here to create a simple check
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
201 function for you. Here is an example:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
202
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
203 %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
204
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
205 Now, using a typemap
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
206
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
207 %typemap(check) int direction {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
208 if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction.");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
209 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
210
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
211 or a contract (better)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
212
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
213 %contract move(int x) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
214 require:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
215 check_direction(x);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
216 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
217
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
218 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
219
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
220 %define %aggregate_check(TYPE, NAME, FIRST, ...)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
221 %wrapper %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
222 static int NAME(TYPE x) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
223 static TYPE values[] = { FIRST, ##__VA_ARGS__ };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
224 static int size = sizeof(values);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
225 int i,j;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
226 for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
227 if (x == values[j]) return 1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
228 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
229 return 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
230 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
231 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
232 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
233
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
234
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
235 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
236 * %rename predicates
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
237 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
238 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
239 Predicates to be used with %rename, for example:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
240
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
241 - to rename all the functions:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
242
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
243 %rename("%(utitle)s", %$isfunction) "";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
244
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
245 - to rename only the member methods:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
246
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
247 %rename("m_%(utitle)s", %$isfunction, %$ismember) "";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
248
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
249 - to rename only the global functions:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
250
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
251 %rename("m_%(utitle)s", %$isfunction, %$not %$ismember) "";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
252
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
253 or
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
254
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
255 %rename("g_%(utitle)s", %$isfunction, %$isglobal) "";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
256
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
257 - to ignore the enumitems in a given class:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
258
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
259 %rename("$ignore", %$isenumitem, %$classname="MyClass") "";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
260
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
261 we use the prefix '%$' to avoid clashings with other swig
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
262 macros/directives.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
263
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
264 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
265
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
266 %define %$not "not" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
267 %define %$isenum "match"="enum" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
268 %define %$isenumitem "match"="enumitem" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
269 %define %$isaccess "match"="access" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
270 %define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
271 %define %$isextend "match"="extend" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
272 %define %$isconstructor "match"="constructor" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
273 %define %$isdestructor "match"="destructor" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
274 %define %$isnamespace "match"="namespace" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
275 %define %$istemplate "match"="template" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
276 %define %$isconstant "match"="constant" %enddef /* %constant definition */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
277
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
278 %define %$isunion "match$kind"="union" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
279 %define %$isfunction "match$kind"="function" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
280 %define %$isvariable "match$kind"="variable" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
281 %define %$isimmutable "match$feature:immutable"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
282 %define %$hasconsttype "match$hasconsttype"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
283 %define %$hasvalue "match$hasvalue"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
284 %define %$isextension "match$isextension"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
285
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
286 %define %$isstatic "match$storage"="static" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
287 %define %$isfriend "match$storage"="friend" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
288 %define %$istypedef "match$storage"="typedef" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
289 %define %$isvirtual "match$storage"="virtual" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
290 %define %$isexplicit "match$storage"="explicit" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
291 %define %$isextern "match$storage"="extern" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
292
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
293 %define %$ismember "match$ismember"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
294 %define %$isglobal %$not %$ismember %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
295 %define %$innamespace "match$parentNode$nodeType"="namespace" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
296
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
297 %define %$ispublic "match$access"="public" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
298 %define %$isprotected "match$access"="protected" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
299 %define %$isprivate "match$access"="private" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
300
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
301 %define %$ismemberget "match$memberget"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
302 %define %$ismemberset "match$memberset"="1" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
303
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
304 %define %$classname %$ismember,"match$parentNode$name" %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
305
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
306 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
307 * Include all the warnings labels and macros
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
308 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
309
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
310 %include <swigwarnings.swg>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
311
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
312 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
313 * Default handling of certain overloaded operators
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
314 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
315
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
316 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
317 %ignoreoperator(NEW) operator new;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
318 %ignoreoperator(DELETE) operator delete;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
319 %ignoreoperator(NEWARR) operator new[];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
320 %ignoreoperator(DELARR) operator delete[];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
321
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
322 /* add C++ operator aliases */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
323 %rename("operator &&") operator and; // `and' `&&'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
324 %rename("operator ||") operator or; // `or' `||'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
325 %rename("operator !") operator not; // `not' `!'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
326 %rename("operator &=") operator and_eq; // `and_eq' `&='
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
327 %rename("operator &") operator bitand; // `bitand' `&'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
328 %rename("operator |") operator bitor; // `bitor' `|'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
329 %rename("operator ~") operator compl; // `compl' `~'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
330 %rename("operator !=") operator not_eq; // `not_eq' `!='
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
331 %rename("operator |=") operator or_eq; // `or_eq' `|='
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
332 %rename("operator ^") operator xor; // `xor' `^'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
333 %rename("operator ^=") operator xor_eq; // `xor_eq' `^='
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
334
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
335 /* Smart pointer handling */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
336
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
337 %rename(__deref__) *::operator->;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
338 %rename(__ref__) *::operator*();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
339 %rename(__ref__) *::operator*() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
340
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
341 /* Define std namespace */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
342 namespace std {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
343 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
344 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
345
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
346 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
347 * Default char * and C array typemaps
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
348 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
349
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
350 /* Set up the typemap for handling new return strings */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
351
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
352 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
353 %typemap(newfree) char * "delete [] $1;";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
354 #else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
355 %typemap(newfree) char * "free($1);";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
356 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
357
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
358 /* Default typemap for handling char * members */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
359
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
360 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
361 %typemap(memberin) char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
362 delete [] $1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
363 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
364 $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
365 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
366 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
367 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
368 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
369 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
370 %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
371 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
372 $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
373 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
374 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
375 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
376 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
377 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
378 %typemap(globalin) char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
379 delete [] $1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
380 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
381 $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
382 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
383 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
384 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
385 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
386 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
387 %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
388 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
389 $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
390 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
391 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
392 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
393 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
394 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
395 #else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
396 %typemap(memberin) char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
397 free($1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
398 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
399 $1 = ($1_type) malloc(strlen((const char *)$input)+1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
400 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
401 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
402 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
403 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
404 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
405 %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
406 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
407 $1 = ($1_type) malloc(strlen((const char *)$input)+1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
408 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
409 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
410 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
411 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
412 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
413 %typemap(globalin) char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
414 free($1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
415 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
416 $1 = ($1_type) malloc(strlen((const char *)$input)+1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
417 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
418 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
419 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
420 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
421 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
422 %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
423 if ($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
424 $1 = ($1_type) malloc(strlen((const char *)$input)+1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
425 strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
426 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
427 $1 = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
428 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
429 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
430
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
431 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
432
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
433 /* Character array handling */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
434
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
435 %typemap(memberin) char [ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
436 if($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
437 strncpy((char*)$1, (const char *)$input, $1_dim0-1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
438 $1[$1_dim0-1] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
439 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
440 $1[0] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
441 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
442 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
443
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
444 %typemap(globalin) char [ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
445 if($input) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
446 strncpy((char*)$1, (const char *)$input, $1_dim0-1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
447 $1[$1_dim0-1] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
448 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
449 $1[0] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
450 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
451 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
452
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
453 %typemap(memberin) char [] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
454 if ($input) strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
455 else $1[0] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
456 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
457
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
458 %typemap(globalin) char [] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
459 if ($input) strcpy((char *)$1, (const char *)$input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
460 else $1[0] = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
461 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
462
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
463 /* memberin/globalin typemap for arrays. */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
464
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
465 %typemap(memberin) SWIGTYPE [ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
466 size_t ii;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
467 $1_basetype *b = ($1_basetype *) $1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
468 for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
469 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
470
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
471 %typemap(globalin) SWIGTYPE [ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
472 size_t ii;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
473 $1_basetype *b = ($1_basetype *) $1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
474 for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
475 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
476
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
477 /* memberin/globalin typemap for double arrays. */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
478
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
479 %typemap(memberin) SWIGTYPE [ANY][ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
480 $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
481 $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
482 size_t ii = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
483 for (; ii < $1_dim0; ++ii) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
484 $basetype *ip = inp[ii];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
485 $basetype *dp = dest[ii];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
486 size_t jj = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
487 for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
488 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
489 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
490
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
491 %typemap(globalin) SWIGTYPE [ANY][ANY] {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
492 $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
493 $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
494 size_t ii = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
495 for (; ii < $1_dim0; ++ii) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
496 $basetype *ip = inp[ii];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
497 $basetype *dp = dest[ii];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
498 size_t jj = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
499 for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
500 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
501 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
502
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
503 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
504 * Overloading support
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
505 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
506
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
507 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
508 * Function/method overloading support. This is done through typemaps,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
509 * but also involve a precedence level.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
510 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
511
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
512 /* Macro for overload resolution */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
513
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
514 %define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
515
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
516 /* Macros for precedence levels */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
517
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
518 %define SWIG_TYPECHECK_POINTER 0 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
519 %define SWIG_TYPECHECK_ITERATOR 5 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
520 %define SWIG_TYPECHECK_VOIDPTR 10 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
521 %define SWIG_TYPECHECK_BOOL 15 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
522 %define SWIG_TYPECHECK_UINT8 20 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
523 %define SWIG_TYPECHECK_INT8 25 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
524 %define SWIG_TYPECHECK_UINT16 30 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
525 %define SWIG_TYPECHECK_INT16 35 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
526 %define SWIG_TYPECHECK_UINT32 40 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
527 %define SWIG_TYPECHECK_INT32 45 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
528 %define SWIG_TYPECHECK_SIZE 47 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
529 %define SWIG_TYPECHECK_PTRDIFF 48 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
530 %define SWIG_TYPECHECK_UINT64 50 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
531 %define SWIG_TYPECHECK_INT64 55 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
532 %define SWIG_TYPECHECK_UINT128 60 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
533 %define SWIG_TYPECHECK_INT128 65 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
534 %define SWIG_TYPECHECK_INTEGER 70 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
535 %define SWIG_TYPECHECK_FLOAT 80 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
536 %define SWIG_TYPECHECK_DOUBLE 90 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
537 %define SWIG_TYPECHECK_CPLXFLT 95 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
538 %define SWIG_TYPECHECK_CPLXDBL 100 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
539 %define SWIG_TYPECHECK_COMPLEX 105 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
540 %define SWIG_TYPECHECK_UNICHAR 110 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
541 %define SWIG_TYPECHECK_STDUNISTRING 115 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
542 %define SWIG_TYPECHECK_UNISTRING 120 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
543 %define SWIG_TYPECHECK_CHAR 130 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
544 %define SWIG_TYPECHECK_STDSTRING 135 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
545 %define SWIG_TYPECHECK_STRING 140 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
546 %define SWIG_TYPECHECK_PAIR 150 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
547 %define SWIG_TYPECHECK_VECTOR 160 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
548 %define SWIG_TYPECHECK_DEQUE 170 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
549 %define SWIG_TYPECHECK_LIST 180 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
550 %define SWIG_TYPECHECK_SET 190 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
551 %define SWIG_TYPECHECK_MULTISET 200 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
552 %define SWIG_TYPECHECK_MAP 210 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
553 %define SWIG_TYPECHECK_MULTIMAP 220 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
554 %define SWIG_TYPECHECK_STACK 230 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
555 %define SWIG_TYPECHECK_QUEUE 240 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
556
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
557 %define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
558 %define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
559 %define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
560 %define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
561 %define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
562 %define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
563 %define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
564 %define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
565 %define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
566 %define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
567 %define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
568
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
569 %define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
570 %define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
571 %define SWIG_TYPECHECK_INT8_PTR 2025 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
572 %define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
573 %define SWIG_TYPECHECK_INT16_PTR 2035 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
574 %define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
575 %define SWIG_TYPECHECK_INT32_PTR 2045 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
576 %define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
577 %define SWIG_TYPECHECK_INT64_PTR 2055 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
578 %define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
579 %define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
580 %define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
581
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
582
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
583 %define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
584
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
585
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
586 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
587 * Runtime code
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
588 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
589
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
590 /* The SwigValueWrapper class */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
591
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
592 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
593 * This template wrapper is used to handle C++ objects that are passed or
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
594 * returned by value. This is necessary to handle objects that define
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
595 * no default-constructor (making it difficult for SWIG to properly declare
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
596 * local variables).
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
597 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
598 * The wrapper is used as follows. First consider a function like this:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
599 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
600 * Vector cross_product(Vector a, Vector b)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
601 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
602 * Now, if Vector is defined as a C++ class with no default constructor,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
603 * code is generated as follows:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
604 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
605 * Vector *wrap_cross_product(Vector *inarg1, Vector *inarg2) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
606 * SwigValueWrapper<Vector> arg1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
607 * SwigValueWrapper<Vector> arg2;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
608 * SwigValueWrapper<Vector> result;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
609 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
610 * arg1 = *inarg1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
611 * arg2 = *inarg2;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
612 * ...
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
613 * result = cross_product(arg1,arg2);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
614 * ...
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
615 * return new Vector(result);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
616 * }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
617 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
618 * In the wrappers, the template SwigValueWrapper simply provides a thin
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
619 * layer around a Vector *. However, it does this in a way that allows
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
620 * the object to be bound after the variable declaration (which is not possible
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
621 * with the bare object when it lacks a default constructor).
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
622 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
623 * An observant reader will notice that the code after the variable declarations
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
624 * is *identical* to the code used for classes that do define default constructors.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
625 * Thus, this neat trick allows us to fix this special case without having to
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
626 * make massive changes to typemaps and other parts of the SWIG code generator.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
627 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
628 * Note: this code is not included when SWIG runs in C-mode, when classes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
629 * define default constructors, or when pointers and references are used.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
630 * SWIG tries to avoid doing this except in very special circumstances.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
631 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
632 * Note: This solution suffers from making a large number of copies
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
633 * of the underlying object. However, this is needed in the interest of
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
634 * safety and in order to cover all of the possible ways in which a value
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
635 * might be assigned. For example:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
636 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
637 * arg1 = *inarg1; // Assignment from a pointer
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
638 * arg1 = Vector(1,2,3); // Assignment from a value
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
639 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
640 * The class offers a strong guarantee of exception safety.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
641 * With regards to the implementation, the private SwigMovePointer nested class is
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
642 * a simple smart pointer with move semantics, much like std::auto_ptr.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
643 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
644 * This wrapping technique was suggested by William Fulton and is henceforth
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
645 * known as the "Fulton Transform" :-).
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
646 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
647
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
648 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
649 %insert("runtime") %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
650 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
651 /* SwigValueWrapper is described in swig.swg */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
652 template<typename T> class SwigValueWrapper {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
653 struct SwigMovePointer {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
654 T *ptr;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
655 SwigMovePointer(T *p) : ptr(p) { }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
656 ~SwigMovePointer() { delete ptr; }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
657 SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
658 } pointer;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
659 SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
660 SwigValueWrapper(const SwigValueWrapper<T>& rhs);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
661 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
662 SwigValueWrapper() : pointer(0) { }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
663 SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
664 operator T&() const { return *pointer.ptr; }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
665 T *operator&() { return pointer.ptr; }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
666 };%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
667
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
668 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
669 * SwigValueInit() is a generic initialisation solution as the following approach:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
670 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
671 * T c_result = T();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
672 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
673 * doesn't compile for all types for example:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
674 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
675 * unsigned int c_result = unsigned int();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
676 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
677 %insert("runtime") %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
678 template <typename T> T SwigValueInit() {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
679 return T();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
680 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
681 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
682 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
683 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
684
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
685 /* The swiglabels */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
686
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
687 %insert("runtime") "swiglabels.swg"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
688
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
689