| 1 | /* ----------------------------------------------------------------------------- |
| 2 | * tcl8.swg |
| 3 | * |
| 4 | * Tcl8 configuration module. |
| 5 | * ----------------------------------------------------------------------------- */ |
| 6 | |
| 7 | %runtime "swigrun.swg" // Common C API type-checking code |
| 8 | %runtime "swigtcl8.swg" |
| 9 | |
| 10 | /* ----------------------------------------------------------------------------- |
| 11 | * --- standard typemaps --- |
| 12 | * ----------------------------------------------------------------------------- */ |
| 13 | |
| 14 | /* Input arguments */ |
| 15 | |
| 16 | /* For primitive types, the Tcl module uses a special function |
| 17 | |
| 18 | SWIG_GetArgs(Tcl_Interp *, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) |
| 19 | |
| 20 | The fmt field contains special conversion characters i,h,l,b,f,d,c,p, and o |
| 21 | that are used to marshal different types. The parse codes below correspond |
| 22 | to these special codes */ |
| 23 | |
| 24 | %typemap(in,parse="i") int ""; |
| 25 | %typemap(in,parse="h") short, unsigned short ""; |
| 26 | %typemap(in,parse="l") long ""; |
| 27 | %typemap(in,parse="b") signed char, unsigned char ""; |
| 28 | %typemap(in,parse="f") float ""; |
| 29 | %typemap(in,parse="d") double ""; |
| 30 | %typemap(in,parse="c") char ""; |
| 31 | %typemap(in,parse="s") char *, char [ANY] ""; |
| 32 | |
| 33 | /* Pointers */ |
| 34 | %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] |
| 35 | "if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION | $disown) != TCL_OK)) SWIG_fail;"; |
| 36 | |
| 37 | %typemap(in) void * |
| 38 | "if ((SWIG_ConvertPtr($input, (void **) &$1, 0,SWIG_POINTER_EXCEPTION | $disown) != TCL_OK)) SWIG_fail;"; |
| 39 | |
| 40 | /* For bools, we first convert to an integer and then to a bool. There |
| 41 | is no guarantee that a bool is the same size as an int so we have to do this */ |
| 42 | |
| 43 | %typemap(in) bool (int tempb) "if (Tcl_GetIntFromObj(interp,$input,&tempb) == TCL_ERROR) SWIG_fail; |
| 44 | $1 = tempb ? true : false;"; |
| 45 | |
| 46 | %typemap(in) unsigned int "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL), 0, 0);"; |
| 47 | %typemap(in) unsigned long "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL), 0, 0);"; |
| 48 | |
| 49 | /* These will pass an integer as an unsigned long. However, the implementation is crippled due |
| 50 | to limited precision in Tcl */ |
| 51 | |
| 52 | %typemap(in) long long "$1 = ($1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);"; |
| 53 | %typemap(in) unsigned long long "$1 = ($1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL), 0, 0);"; |
| 54 | |
| 55 | /* Enum parsing. Note: internally SWIG converts enums to/from integers so it's okay to use |
| 56 | the "i" parse code here */ |
| 57 | |
| 58 | %typemap(in,parse="i") enum SWIGTYPE ""; |
| 59 | |
| 60 | /* Unknown type. We convert from a pointer */ |
| 61 | %typemap(in) SWIGTYPE ($&1_ltype argp) |
| 62 | "if ((SWIG_ConvertPtr($input, (void **) &argp, $&1_descriptor,SWIG_POINTER_EXCEPTION ) != TCL_OK)) SWIG_fail; |
| 63 | $1 = *argp; "; |
| 64 | |
| 65 | /* Member pointer */ |
| 66 | %typemap(in) SWIGTYPE (CLASS::*) "if ((SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor, SWIG_POINTER_EXCEPTION)) != TCL_OK) SWIG_fail;"; |
| 67 | |
| 68 | /* Special constant variations. These typemaps can be used to parse objects that are both constants |
| 69 | or values. A Hash table lookup will occur. */ |
| 70 | |
| 71 | %typemap(in,parse="I") int CONSTANT, unsigned int CONSTANT ""; |
| 72 | %typemap(in,parse="H") short CONSTANT, unsigned short CONSTANT ""; |
| 73 | %typemap(in,parse="L") long CONSTANT, unsigned long CONSTANT ""; |
| 74 | %typemap(in,parse="B") signed char CONSTANT, unsigned char CONSTANT ""; |
| 75 | %typemap(in,parse="F") float CONSTANT ""; |
| 76 | %typemap(in,parse="D") double CONSTANT ""; |
| 77 | %typemap(in,parse="C") char CONSTANT ""; |
| 78 | %typemap(in,parse="S") char * CONSTANT ""; |
| 79 | %typemap(in,parse="P") SWIGTYPE *CONSTANT, SWIGTYPE &CONSTANT, SWIGTYPE CONSTANT [] ""; |
| 80 | %typemap(in,parse="I") enum SWIGTYPE CONSTANT ""; |
| 81 | |
| 82 | /* Constant references. Passed by value */ |
| 83 | /* Const primitive references. Passed by value */ |
| 84 | |
| 85 | %typemap(in) const int & ($*1_ltype temp), |
| 86 | const short & ($*1_ltype temp), |
| 87 | const long & ($*1_ltype temp), |
| 88 | const unsigned short & ($*1_ltype temp), |
| 89 | const signed char & ($*1_ltype temp), |
| 90 | const unsigned char & ($*1_ltype temp), |
| 91 | const enum SWIGTYPE & ($*1_ltype temp) |
| 92 | { |
| 93 | long ltemp; |
| 94 | if (Tcl_GetLongFromObj(interp, $input, <emp) != TCL_OK) { |
| 95 | SWIG_fail; |
| 96 | } |
| 97 | temp = ($*1_ltype) ltemp; |
| 98 | $1 = &temp; |
| 99 | } |
| 100 | |
| 101 | %typemap(in) const unsigned int & ($*1_ltype temp) |
| 102 | "temp = ($*1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0); |
| 103 | $1 = &temp;"; |
| 104 | |
| 105 | %typemap(in) const unsigned long & ($*1_ltype temp) |
| 106 | "temp = ($*1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0); |
| 107 | $1 = &temp;"; |
| 108 | |
| 109 | %typemap(in) const bool & (bool temp) |
| 110 | { |
| 111 | long ltemp; |
| 112 | if (Tcl_GetLongFromObj(interp, $input, <emp) != TCL_OK) { |
| 113 | SWIG_fail; |
| 114 | } |
| 115 | temp = ltemp ? true : false; |
| 116 | $1 = &temp; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | %typemap(in) const float & (float temp), |
| 121 | const double & (double temp) |
| 122 | { |
| 123 | double dtemp; |
| 124 | if (Tcl_GetDoubleFromObj(interp, $input, &dtemp) != TCL_OK) { |
| 125 | SWIG_fail; |
| 126 | } |
| 127 | temp = ($*1_ltype) dtemp; |
| 128 | $1 = &temp; |
| 129 | } |
| 130 | |
| 131 | %typemap(in) const long long & ($*1_ltype temp) |
| 132 | "temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0); |
| 133 | $1 = &temp;"; |
| 134 | |
| 135 | %typemap(in) const unsigned long long & ($*1_ltype temp) |
| 136 | "temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0); |
| 137 | $1 = &temp;"; |
| 138 | |
| 139 | %typemap(in) const char &(char temp) { |
| 140 | char *stemp = Tcl_GetStringFromObj($input,NULL); |
| 141 | temp = *stemp; |
| 142 | $1 = &temp; |
| 143 | } |
| 144 | |
| 145 | /* Output values */ |
| 146 | |
| 147 | %typemap(out) bool, int, short, unsigned short, signed char, unsigned char, enum SWIGTYPE |
| 148 | "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) $1));"; |
| 149 | |
| 150 | %typemap(out) long |
| 151 | "Tcl_SetObjResult(interp,Tcl_NewLongObj((long) $1));"; |
| 152 | |
| 153 | %typemap(out) unsigned int, unsigned long { |
| 154 | char temp[256]; |
| 155 | sprintf(temp,"%lu", (unsigned long) $1); |
| 156 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 157 | } |
| 158 | |
| 159 | |
| 160 | %typemap(out) long long { |
| 161 | char temp[256]; |
| 162 | sprintf(temp,"%lld", (long long) $1); |
| 163 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 164 | } |
| 165 | |
| 166 | %typemap(out) unsigned long long { |
| 167 | char temp[256]; |
| 168 | sprintf(temp,"%llu", (unsigned long long) $1); |
| 169 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 170 | } |
| 171 | |
| 172 | %typemap(out) char |
| 173 | "Tcl_SetObjResult(interp,Tcl_NewStringObj(&$1,1));"; |
| 174 | |
| 175 | %typemap(out) float, double |
| 176 | "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) $1));"; |
| 177 | |
| 178 | %typemap(out) char * |
| 179 | "Tcl_SetObjResult(interp,Tcl_NewStringObj($1,-1));"; |
| 180 | |
| 181 | %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] |
| 182 | "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));"; |
| 183 | |
| 184 | %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { |
| 185 | swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); |
| 186 | Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) $1, ty, $owner)); |
| 187 | } |
| 188 | |
| 189 | %typemap(out) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] |
| 190 | "Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, $1_descriptor, $owner));"; |
| 191 | |
| 192 | %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] |
| 193 | "Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, $1_descriptor, $owner));"; |
| 194 | |
| 195 | %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { |
| 196 | swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); |
| 197 | Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, ty, $owner)); |
| 198 | } |
| 199 | |
| 200 | %typemap(out) SWIGTYPE (CLASS::*) |
| 201 | "Tcl_SetObjResult(interp, SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor, $owner));"; |
| 202 | |
| 203 | %typemap(out) void ""; |
| 204 | |
| 205 | /* Primitive types--return by value */ |
| 206 | %typemap(out) SWIGTYPE NOINSTANCE |
| 207 | #ifdef __cplusplus |
| 208 | { |
| 209 | $&1_ltype resultptr; |
| 210 | resultptr = new $1_ltype(($1_ltype &) $1); |
| 211 | Tcl_SetObjResult(interp,SWIG_NewPointerObj((void*) resultptr, $&1_descriptor, $owner)); |
| 212 | } |
| 213 | #else |
| 214 | { |
| 215 | $&1_ltype resultptr; |
| 216 | resultptr = ($&1_ltype) malloc(sizeof($1_type)); |
| 217 | memmove(resultptr, &$1, sizeof($1_type)); |
| 218 | Tcl_SetObjResult(interp,SWIG_NewPointerObj((void*) resultptr, $&1_descriptor, $owner)); |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 | /* Primitive types--return by value */ |
| 223 | %typemap(out) SWIGTYPE INSTANCE |
| 224 | #ifdef __cplusplus |
| 225 | { |
| 226 | $&1_ltype resultptr; |
| 227 | resultptr = new $1_ltype(($1_ltype &) $1); |
| 228 | Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void*) resultptr, $&1_descriptor,1)); |
| 229 | } |
| 230 | #else |
| 231 | { |
| 232 | $&1_ltype resultptr; |
| 233 | resultptr = ($&1_ltype) malloc(sizeof($1_type)); |
| 234 | memmove(resultptr, &$1, sizeof($1_type)); |
| 235 | Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void*) resultptr, $&1_descriptor,1)); |
| 236 | } |
| 237 | #endif |
| 238 | |
| 239 | %typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; |
| 240 | |
| 241 | /* Special typemap for character array returns */ |
| 242 | %typemap(out) char [ANY] "Tcl_SetObjResult(interp,Tcl_NewStringObj($1,-1));" |
| 243 | |
| 244 | |
| 245 | /* Primitive references */ |
| 246 | |
| 247 | %typemap(out) const int &, |
| 248 | const short &, const unsigned short &, |
| 249 | const signed char &, const unsigned char &, |
| 250 | const bool &, |
| 251 | const enum SWIGTYPE & |
| 252 | "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) *($1)));"; |
| 253 | |
| 254 | %typemap(out) const long & |
| 255 | "Tcl_SetObjResult(interp,Tcl_NewLongObj((long) *($1)));"; |
| 256 | |
| 257 | %typemap(out) const unsigned int &, const unsigned long & |
| 258 | { |
| 259 | char temp[256]; |
| 260 | sprintf(temp,"%lu", (unsigned long)*($1)); |
| 261 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | %typemap(out) const float &, const double & |
| 266 | "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) *($1)));"; |
| 267 | |
| 268 | %typemap(out) const long long & { |
| 269 | char temp[256]; |
| 270 | sprintf(temp,"%lld", (long long)*($1)); |
| 271 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 272 | } |
| 273 | |
| 274 | %typemap(out) const unsigned long long & |
| 275 | { |
| 276 | char temp[256]; |
| 277 | sprintf(temp,"%llu", (unsigned long long)*($1)); |
| 278 | Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1)); |
| 279 | } |
| 280 | |
| 281 | %typemap(out) const char & |
| 282 | "Tcl_SetObjResult(interp,Tcl_NewStringObj($1,1));"; |
| 283 | |
| 284 | |
| 285 | /* --- Variable output --- */ |
| 286 | |
| 287 | %typemap(varout) int, short, unsigned short, signed char, unsigned char, bool, enum SWIGTYPE |
| 288 | "$result = Tcl_NewIntObj((long) $1);"; |
| 289 | |
| 290 | %typemap(varout) long |
| 291 | "$result = Tcl_NewLongObj((long) $1);"; |
| 292 | |
| 293 | %typemap(varout) unsigned int, unsigned long { |
| 294 | char temp[256]; |
| 295 | sprintf(temp,"%lu", (unsigned long)$1); |
| 296 | $result = Tcl_NewStringObj(temp,-1); |
| 297 | } |
| 298 | |
| 299 | %typemap(varout) long long { |
| 300 | char temp[256]; |
| 301 | sprintf(temp,"%lld", (long long)$1); |
| 302 | $result = Tcl_NewStringObj(temp,-1); |
| 303 | } |
| 304 | |
| 305 | %typemap(varout) unsigned long long { |
| 306 | char temp[256]; |
| 307 | sprintf(temp,"%llu", (unsigned long long)$1); |
| 308 | $result = Tcl_NewStringObj(temp,-1); |
| 309 | } |
| 310 | |
| 311 | %typemap(varout) double,float "$result = Tcl_NewDoubleObj((double) $1);"; |
| 312 | %typemap(varout) char * "$result = Tcl_NewStringObj((char*) $1,-1);"; |
| 313 | %typemap(varout) char [ANY] "$result = Tcl_NewStringObj((char *) $1,-1);"; |
| 314 | %typemap(varout) char "$result = Tcl_NewStringObj(&$1,1);"; |
| 315 | %typemap(varout) SWIGTYPE *, SWIGTYPE [] "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 0);"; |
| 316 | %typemap(varout) SWIGTYPE & "$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);"; |
| 317 | |
| 318 | %typemap(varout) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] |
| 319 | "$result = SWIG_NewInstanceObj((void *) $1, $1_descriptor, 0);"; |
| 320 | |
| 321 | %typemap(varout) SWIGTYPE &INSTANCE |
| 322 | "$result = SWIG_NewInstanceObj((void *) &$1, $1_descriptor, 0);"; |
| 323 | |
| 324 | %typemap(varout) SWIGTYPE INSTANCE "$result = SWIG_NewInstanceObj((void *) &$1, $&1_descriptor, 0);"; |
| 325 | %typemap(varout) SWIGTYPE "$result = SWIG_NewInstanceObj((void *) &$1, $&1_descriptor, 0);"; |
| 326 | %typemap(varout) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor, 0);"; |
| 327 | |
| 328 | /* -- Variable input --- */ |
| 329 | |
| 330 | %typemap(varin) int, short, unsigned short, long, signed char, unsigned char |
| 331 | { |
| 332 | long temp; |
| 333 | if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) { |
| 334 | return (char*) "Type error. expected an integer"; |
| 335 | } |
| 336 | $1 = ($1_type) temp; |
| 337 | } |
| 338 | |
| 339 | %typemap(varin) unsigned int, unsigned long "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0);"; |
| 340 | |
| 341 | %typemap(varin) enum SWIGTYPE |
| 342 | { |
| 343 | int temp; |
| 344 | if (Tcl_GetIntFromObj(interp, $input, &temp) != TCL_OK) { |
| 345 | return (char*) "Type error. expected an integer"; |
| 346 | } |
| 347 | if (sizeof(int) != sizeof($1)) { |
| 348 | return (char*) "enum variable '$name' can not be set."; |
| 349 | } |
| 350 | *(int *)(void *)&($1) = temp; |
| 351 | } |
| 352 | |
| 353 | %typemap(varin) bool |
| 354 | { |
| 355 | long temp; |
| 356 | if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) { |
| 357 | return (char*) "Type error. expected an integer"; |
| 358 | } |
| 359 | $1 = temp ? true : false; |
| 360 | } |
| 361 | |
| 362 | %typemap(varin) long long "$1 = ($1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);"; |
| 363 | %typemap(varin) unsigned long long "$1 = ($1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);"; |
| 364 | |
| 365 | %typemap(varin) double, float { |
| 366 | double temp; |
| 367 | if (Tcl_GetDoubleFromObj(interp, $input, &temp) != TCL_OK) { |
| 368 | return (char*) "Type error. expected a double."; |
| 369 | } |
| 370 | $1 = ($1_type) temp; |
| 371 | } |
| 372 | |
| 373 | %typemap(varin) char * |
| 374 | #ifdef __cplusplus |
| 375 | { |
| 376 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 377 | if ($1) delete [] $1; |
| 378 | $1 = ($1_type) new char[strlen(temp)+1]; |
| 379 | strcpy((char *) $1,temp); |
| 380 | } |
| 381 | #else |
| 382 | { |
| 383 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 384 | if ($1) free((char*)$1); |
| 385 | $1 = ($1_type) malloc(strlen(temp)+1); |
| 386 | strcpy((char *) $1,temp); |
| 387 | } |
| 388 | #endif |
| 389 | |
| 390 | %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * |
| 391 | #ifdef __cplusplus |
| 392 | { |
| 393 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 394 | $1 = ($1_type) new char[strlen(temp)+1]; |
| 395 | strcpy((char *) $1,temp); |
| 396 | } |
| 397 | #else |
| 398 | { |
| 399 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 400 | $1 = ($1_type) malloc(strlen(temp)+1); |
| 401 | strcpy((char *) $1,temp); |
| 402 | } |
| 403 | #endif |
| 404 | |
| 405 | %typemap(varin) char [ANY] { |
| 406 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 407 | strncpy((char*)$1,temp,$1_dim0); |
| 408 | } |
| 409 | |
| 410 | %typemap(varin,warning="462: Unable to set variable of type char []") char [] { |
| 411 | return (char*)"Variable $symname is read-only."; |
| 412 | } |
| 413 | |
| 414 | %typemap(varin) char |
| 415 | { |
| 416 | char *temp = Tcl_GetStringFromObj($input,NULL); |
| 417 | $1 = *temp; |
| 418 | } |
| 419 | |
| 420 | %typemap(varin) SWIGTYPE * { |
| 421 | if (SWIG_ConvertPtr($input,(void **)&$1,$1_descriptor, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN) != TCL_OK) { |
| 422 | return (char*)"Type error. Expected $1_ltype"; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | %typemap(varin,warning="462: Unable to set dimensionless array variable") SWIGTYPE [] { |
| 427 | return (char*)"Variable $symname is read-only."; |
| 428 | } |
| 429 | |
| 430 | %typemap(varin) void * { |
| 431 | void *temp; |
| 432 | if (SWIG_ConvertPtr($input,&temp,0, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN) != TCL_OK) { |
| 433 | return (char*)"Type error. Expected $1_ltype"; |
| 434 | } |
| 435 | $1 = ($1_type) temp; |
| 436 | } |
| 437 | |
| 438 | %typemap(varin) SWIGTYPE & { |
| 439 | void *temp; |
| 440 | if (SWIG_ConvertPtr($input,&temp,$1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) { |
| 441 | return (char*)"Type error. Expected $1_ltype"; |
| 442 | } |
| 443 | $1 = *($1_ltype) temp; |
| 444 | } |
| 445 | |
| 446 | %typemap(varin) SWIGTYPE { |
| 447 | void *temp; |
| 448 | if (SWIG_ConvertPtr($input,&temp,$&1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) { |
| 449 | return (char*)"Type error. Expected $&1_ltype"; |
| 450 | } |
| 451 | $1 = *(($&1_type) temp); |
| 452 | } |
| 453 | |
| 454 | %typemap(varin) SWIGTYPE [ANY] { |
| 455 | void *temp; |
| 456 | if (SWIG_ConvertPtr($input,&temp,$1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) { |
| 457 | return (char *)"Type error. Expected $1_ltype"; |
| 458 | } |
| 459 | memmove((void *) $1,temp,$1_size*sizeof($1_basetype)); |
| 460 | } |
| 461 | |
| 462 | %typemap(varin) SWIGTYPE (CLASS::*) { |
| 463 | char temp[sizeof($1_type)]; |
| 464 | if (SWIG_ConvertPacked($input, temp, sizeof($1_type), $1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) { |
| 465 | return (char *) "Type error. Expected $1_ltype"; |
| 466 | } |
| 467 | memmove((void *) &$1, temp, sizeof($1_type)); |
| 468 | } |
| 469 | |
| 470 | /* --- Constants --- */ |
| 471 | |
| 472 | %typemap(consttab) int, short, unsigned short, unsigned char, signed char, bool, enum SWIGTYPE |
| 473 | { SWIG_TCL_INT, (char *)"$nsname", (long) $value, 0, 0, 0} |
| 474 | |
| 475 | %typemap(consttab) unsigned int, unsigned long |
| 476 | { SWIG_TCL_STRING, (char *) "$nsname", 0, 0, (void *)"$value", 0} |
| 477 | |
| 478 | %typemap(consttab) float, double |
| 479 | { SWIG_TCL_FLOAT, (char*)"$nsname", 0, (double) $value, 0, 0} |
| 480 | |
| 481 | %typemap(consttab) char, char * |
| 482 | { SWIG_TCL_STRING, (char*)"$nsname", 0, 0, (void *)"$value", 0} |
| 483 | |
| 484 | %typemap(consttab) long long, unsigned long long |
| 485 | { SWIG_TCL_STRING, (char *) "$nsname", 0, 0, (void *)"$value", 0} |
| 486 | |
| 487 | %typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] |
| 488 | { SWIG_TCL_POINTER, (char*)"$nsname", 0, 0, (void *)$value, &$1_descriptor} |
| 489 | |
| 490 | %typemap(consttab) SWIGTYPE (CLASS::*) |
| 491 | { SWIG_TCL_BINARY, (char *)"$nsname", sizeof($type), 0, (void *)&$value, &$1_descriptor} |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | /* ------------------------------------------------------------ |
| 497 | * String & length |
| 498 | * ------------------------------------------------------------ */ |
| 499 | |
| 500 | %typemap(in) (char *STRING, int LENGTH) { |
| 501 | int temp; |
| 502 | $1 = ($1_ltype) Tcl_GetStringFromObj($input,&temp); |
| 503 | $2 = ($2_ltype) temp; |
| 504 | } |
| 505 | |
| 506 | /* ------------------------------------------------------------ |
| 507 | * ANSI C typemaps |
| 508 | * ------------------------------------------------------------ */ |
| 509 | |
| 510 | %types(size_t); |
| 511 | %apply unsigned long { size_t }; |
| 512 | %apply const unsigned long& { const size_t& }; |
| 513 | |
| 514 | %types(ptrdiff_t); |
| 515 | %apply long { ptrdiff_t }; |
| 516 | %apply const long& { const ptrdiff_t& }; |
| 517 | |
| 518 | |
| 519 | /* ------------------------------------------------------------ |
| 520 | * Typechecking rules |
| 521 | * ------------------------------------------------------------ */ |
| 522 | |
| 523 | %typecheck(SWIG_TYPECHECK_INTEGER) |
| 524 | int, short, long, |
| 525 | unsigned int, unsigned short, unsigned long, |
| 526 | signed char, unsigned char, |
| 527 | const int &, const short &, const long &, |
| 528 | const unsigned int &, const unsigned short &, const unsigned long &, |
| 529 | enum SWIGTYPE, const enum SWIGTYPE &, |
| 530 | bool, const bool & |
| 531 | { |
| 532 | long tmp; |
| 533 | if (Tcl_GetLongFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0; |
| 534 | else $1 = 1; |
| 535 | } |
| 536 | |
| 537 | %typecheck(SWIG_TYPECHECK_INTEGER) |
| 538 | long long, const long long & |
| 539 | { |
| 540 | int len; |
| 541 | char *end = 0; |
| 542 | char *str = Tcl_GetStringFromObj($input, &len); |
| 543 | strtoll(str, &end, 0); |
| 544 | $1 = (end != 0) && (*end != '\0') && (str != end) && (errno == 0); |
| 545 | } |
| 546 | |
| 547 | %typecheck(SWIG_TYPECHECK_INTEGER) |
| 548 | unsigned long long, const unsigned long long & |
| 549 | { |
| 550 | int len; |
| 551 | char *end = 0; |
| 552 | char *str = Tcl_GetStringFromObj($input, &len); |
| 553 | strtoull(str, &end, 0); |
| 554 | $1 = (end != 0) && (*end != '\0') && (str != end) && (errno == 0); |
| 555 | } |
| 556 | |
| 557 | %typecheck(SWIG_TYPECHECK_DOUBLE) |
| 558 | float, double, |
| 559 | const float &, const double & |
| 560 | { |
| 561 | double tmp; |
| 562 | if (Tcl_GetDoubleFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0; |
| 563 | else $1 = 1; |
| 564 | } |
| 565 | |
| 566 | %typecheck(SWIG_TYPECHECK_CHAR) char { |
| 567 | char *tmp; |
| 568 | int len; |
| 569 | tmp = Tcl_GetStringFromObj($input,&len); |
| 570 | $1 = (len == 1) ? 1 : 0; |
| 571 | } |
| 572 | |
| 573 | %typecheck(SWIG_TYPECHECK_STRING) char * { |
| 574 | $1 = 1; |
| 575 | } |
| 576 | |
| 577 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { |
| 578 | void *ptr; |
| 579 | if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0) == TCL_ERROR) { |
| 580 | $1 = 0; |
| 581 | } else { |
| 582 | $1 = 1; |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { |
| 587 | void *ptr; |
| 588 | if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0) == TCL_ERROR) { |
| 589 | $1 = 0; |
| 590 | } else { |
| 591 | $1 = 1; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { |
| 596 | void *ptr; |
| 597 | if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0) == TCL_ERROR) { |
| 598 | $1 = 0; |
| 599 | } else { |
| 600 | $1 = 1; |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | /* ------------------------------------------------------------ |
| 605 | * Exception handling |
| 606 | * ------------------------------------------------------------ */ |
| 607 | |
| 608 | %typemap(throws) int, |
| 609 | long, |
| 610 | short, |
| 611 | unsigned int, |
| 612 | unsigned long, |
| 613 | unsigned short { |
| 614 | Tcl_SetObjResult(interp, Tcl_NewIntObj((long) $1)); |
| 615 | SWIG_fail; |
| 616 | } |
| 617 | |
| 618 | %typemap(throws) SWIGTYPE CLASS { |
| 619 | $&1_ltype temp = new $1_ltype($1); |
| 620 | Tcl_SetObjResult(interp, SWIG_NewInstanceObj((void *) temp, $&1_descriptor, 1)); |
| 621 | SWIG_fail; |
| 622 | } |
| 623 | |
| 624 | %typemap(throws) SWIGTYPE { |
| 625 | (void)$1; |
| 626 | Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1)); |
| 627 | SWIG_fail; |
| 628 | } |
| 629 | |
| 630 | %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] { |
| 631 | (void)$1; |
| 632 | Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1)); |
| 633 | SWIG_fail; |
| 634 | } |
| 635 | |
| 636 | %typemap(throws) enum SWIGTYPE { |
| 637 | (void)$1; |
| 638 | Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1)); |
| 639 | SWIG_fail; |
| 640 | } |
| 641 | |
| 642 | %typemap(throws) char * { |
| 643 | Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1, -1)); |
| 644 | SWIG_fail; |
| 645 | } |
| 646 | |
| 647 | // Some special reserved words in classes |
| 648 | %include "tcl8kw.swg" |
| 649 | |
| 650 | /* C++ overloaded operators. |
| 651 | |
| 652 | These declarations define how SWIG is going to rename C++ |
| 653 | overloaded operators in Tcl. Since Tcl allows identifiers |
| 654 | to be essentially any valid string, we'll just use the |
| 655 | normal operator names */ |
| 656 | |
| 657 | #ifdef __cplusplus |
| 658 | %rename("+") *::operator+; |
| 659 | //%rename("u+") *::operator+(); // Unary + |
| 660 | //%rename("u+") *::operator+() const; // Unary + |
| 661 | %rename("-") *::operator-; |
| 662 | //%rename("u-") *::operator-(); // Unary - |
| 663 | //%rename("u-") *::operator-() const; // Unary - |
| 664 | %rename("*") *::operator*; |
| 665 | %rename("/") *::operator/; |
| 666 | %rename("<<") *::operator<<; |
| 667 | %rename(">>") *::operator>>; |
| 668 | %rename("&") *::operator&; |
| 669 | %rename("|") *::operator|; |
| 670 | %rename("^") *::operator^; |
| 671 | %rename("%") *::operator%; |
| 672 | %rename("=") *::operator=; |
| 673 | #endif |
| 674 | |
| 675 | |
| 676 | /* This initialization code exports the module initialization function */ |
| 677 | |
| 678 | %header %{ |
| 679 | |
| 680 | #ifdef __cplusplus |
| 681 | extern "C" { |
| 682 | #endif |
| 683 | #ifdef MAC_TCL |
| 684 | #pragma export on |
| 685 | #endif |
| 686 | SWIGEXPORT int SWIG_init(Tcl_Interp *); |
| 687 | #ifdef MAC_TCL |
| 688 | #pragma export off |
| 689 | #endif |
| 690 | #ifdef __cplusplus |
| 691 | } |
| 692 | #endif |
| 693 | |
| 694 | %} |
| 695 | |
| 696 | /* Start the initialization function */ |
| 697 | |
| 698 | %insert(init) "swiginit.swg" |
| 699 | |
| 700 | %init %{ |
| 701 | SWIGEXPORT int SWIG_init(Tcl_Interp *interp) { |
| 702 | int i; |
| 703 | if (interp == 0) return TCL_ERROR; |
| 704 | #ifdef USE_TCL_STUBS |
| 705 | if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) { |
| 706 | return TCL_ERROR; |
| 707 | } |
| 708 | #endif |
| 709 | |
| 710 | Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version); |
| 711 | |
| 712 | #ifdef SWIG_namespace |
| 713 | Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }"); |
| 714 | #endif |
| 715 | |
| 716 | SWIG_InitializeModule((void *) interp); |
| 717 | SWIG_PropagateClientData(); |
| 718 | |
| 719 | for (i = 0; swig_commands[i].name; i++) { |
| 720 | Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, swig_commands[i].clientdata, NULL); |
| 721 | } |
| 722 | for (i = 0; swig_variables[i].name; i++) { |
| 723 | Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY); |
| 724 | Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr); |
| 725 | Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr); |
| 726 | } |
| 727 | SWIG_InstallConstants(interp, swig_constants); |
| 728 | %} |
| 729 | |
| 730 | /* Note: the initialization function is closed after all code is generated */ |