1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * Pike configuration module.
8 * ----------------------------------------------------------------------------- */
10 %insert(runtime) "swigrun.swg"; // Common C API type-checking code
11 %insert(runtime) "pikerun.swg"; // Pike run-time code
19 #include <interpret.h>
25 /* -----------------------------------------------------------------------------
27 * ----------------------------------------------------------------------------- */
29 /* --- Input arguments --- */
31 /* Primitive datatypes. */
33 %typemap(in, pikedesc="tInt")
34 int, unsigned int, short, unsigned short,
35 long, unsigned long, char, signed char, unsigned char,
36 bool, enum SWIGTYPE, long long, unsigned long long
38 if ($input.type != T_INT)
39 Pike_error("Bad argument: Expected an integer.\n");
40 $1 = ($1_ltype) $input.u.integer;
43 %typemap(in, pikedesc="tFloat") float, double {
44 if ($input.type != T_FLOAT)
45 Pike_error("Bad argument: Expected a float.\n");
46 $1 = ($1_ltype) $input.u.float_number;
49 %typemap(in, pikedesc="tStr") char *, char [ANY] {
50 if ($input.type != T_STRING)
51 Pike_error("Bad argument: Expected a string.\n");
52 $1 = ($1_ltype) STR0($input.u.string);
55 /* Pointers, references and arrays */
57 %typemap(in) SWIGTYPE *,
60 "SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);"
62 /* Void pointer. Accepts any kind of pointer */
63 %typemap(in) void * "/* FIXME */";
65 /* Object passed by value. Convert to a pointer */
66 %typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */";
68 /* Pointer to a class member */
69 %typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */";
71 /* Const primitive references. Passed by value */
73 %typemap(in, pikedesc="tInt") const int & (int temp),
74 const short & (short temp),
75 const long & (long temp),
76 const unsigned int & (unsigned int temp),
77 const unsigned short & (unsigned short temp),
78 const unsigned long & (unsigned long temp),
79 const char & (char temp),
80 const signed char & (signed char temp),
81 const unsigned char & (unsigned char temp),
82 const bool & (bool temp),
83 const long long & ($*1_ltype temp),
84 const unsigned long long & ($*1_ltype temp),
85 const enum SWIGTYPE & ($*1_ltype temp)
87 if ($input.type != T_INT)
88 Pike_error("Bad argument: Expected an integer.\n");
89 temp = ($*1_ltype) $input.u.integer;
93 %typemap(in, pikedesc="tFloat") const float & (float temp),
94 const double & (double temp)
96 if ($input.type != T_FLOAT)
97 Pike_error("Bad argument: Expected a float.\n");
98 temp = ($*1_ltype) $input.u.float_number;
102 /* -----------------------------------------------------------------------------
104 * ----------------------------------------------------------------------------- */
105 %typemap(out, pikedesc="tInt")
107 short, unsigned short,
109 char, signed char, unsigned char,
113 %typemap(out, pikedesc="tInt") long long "push_int64($1);";
114 %typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);";
115 %typemap(out, pikedesc="tFloat") float, double "push_float($1);";
116 %typemap(out, pikedesc="tStr") char * "push_text($1);";
118 /* Pointers, references, and arrays */
119 %typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
121 /* Void return value; don't push anything */
122 %typemap(out, pikedesc="tVoid") void "";
126 %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */";
129 %typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */";
131 /* Special typemap for character array return values */
132 %typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);";
134 /* Primitive types--return by value */
135 %typemap(out, pikedesc="tObj") SWIGTYPE
139 resultptr = new $1_ltype((const $1_ltype &) $1);
140 push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
145 resultptr = ($&1_ltype) malloc(sizeof($1_type));
146 memmove(resultptr, &$1, sizeof($1_type));
147 push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
151 /* References to primitive types. Return by value */
153 %typemap(out, pikedesc="tInt") const int &, const unsigned int &,
154 const short &, const unsigned short &,
155 const long &, const unsigned long &,
156 const char &, const signed char &, const unsigned char &,
158 const long long &, const unsigned long long &,
159 const enum SWIGTYPE & ($*1_ltype temp)
162 %typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));";
164 /************************ Constant Typemaps *****************************/
168 short, unsigned short,
170 signed char, unsigned char,
172 long long, unsigned long long
173 "add_integer_constant(\"$symname\", $1, 0);";
175 %typemap(constant) char
176 "add_integer_constant(\"$symname\", '$1', 0);";
178 %typemap(constant) long long, unsigned long long
179 "add_integer_constant(\"$symname\", $1, 0);";
181 %typemap(constant) float, double
182 "add_float_constant(\"$symname\", $1, 0);";
184 %typemap(constant) char *
185 "add_string_constant(\"$symname\", \"$1\", 0);";
187 /* ------------------------------------------------------------
189 * ------------------------------------------------------------ */
191 %typemap(in, pikedesc="tStr") (char *STRING, int LENGTH) {
192 if ($input.type != T_STRING)
193 Pike_error("Bad argument: Expected a string.\n");
194 $1 = ($1_ltype) STR0($input.u.string);
195 $2 = ($2_ltype) $input.u.string->length;
198 /* ------------------------------------------------------------
200 * ------------------------------------------------------------ */
202 %typemap(in, pikedesc="tInt") size_t {
203 if ($input.type != T_INT)
204 Pike_error("Bad argument: Expected an integer.\n");
205 $1 = ($1_ltype) $input.u.integer;
208 %typemap(out) size_t = long;
210 /* ------------------------------------------------------------
212 * ------------------------------------------------------------ */
214 %typecheck(SWIG_TYPECHECK_INTEGER)
216 unsigned int, unsigned short, unsigned long,
217 signed char, unsigned char,
218 long long, unsigned long long,
219 const int &, const short &, const long &,
220 const unsigned int &, const unsigned short &, const unsigned long &,
221 const long long &, const unsigned long long &,
222 enum SWIGTYPE, enum SWIGTYPE &,
225 $1 = ($input.type == T_INT) ? 1 : 0;
228 %typecheck(SWIG_TYPECHECK_DOUBLE)
230 const float &, const double &
232 $1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0;
235 %typecheck(SWIG_TYPECHECK_CHAR) char {
236 $1 = ($input.type == T_INT) ? 1 : 0;
239 %typecheck(SWIG_TYPECHECK_STRING) char * {
240 $1 = ($input.type == T_STRING) ? 1 : 0;
243 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
245 if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) {
252 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
254 if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) {
261 %typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
263 if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) {
270 /* ------------------------------------------------------------
271 * Overloaded operator support
272 * ------------------------------------------------------------ */
275 %rename("`+") *::operator+;
276 %rename("`-") *::operator-;
277 %rename("`*") *::operator*;
278 %rename("`/") *::operator/;
279 %rename("`%") *::operator%;
280 %rename("`<<") *::operator<<;
281 %rename("`>>") *::operator>>;
282 %rename("`&") *::operator&;
283 %rename("`|") *::operator|;
284 %rename("`^") *::operator^;
285 %rename("`~") *::operator~;
286 %rename("`<") *::operator<;
287 %rename("`>") *::operator>;
288 %rename("`==") *::operator==;
291 %rename("`()") *::operator();
295 /* ------------------------------------------------------------
296 * The start of the Pike initialization function
297 * ------------------------------------------------------------ */
313 SWIG_InitializeModule(0);
317 %include <pikekw.swg>