| 1 | /*************************************************************** -*- c -*- |
| 2 | * python/precommon.swg |
| 3 | * |
| 4 | * Rename all exported symbols from common.swg, to avoid symbol |
| 5 | * clashes if multiple interpreters are included |
| 6 | * |
| 7 | ************************************************************************/ |
| 8 | |
| 9 | #define SWIG_TypeRegister SWIG_Python_TypeRegister |
| 10 | #define SWIG_TypeCheck SWIG_Python_TypeCheck |
| 11 | #define SWIG_TypeCast SWIG_Python_TypeCast |
| 12 | #define SWIG_TypeDynamicCast SWIG_Python_TypeDynamicCast |
| 13 | #define SWIG_TypeName SWIG_Python_TypeName |
| 14 | #define SWIG_TypeQuery SWIG_Python_TypeQuery |
| 15 | #define SWIG_TypeClientData SWIG_Python_TypeClientData |
| 16 | |
| 17 | /*********************************************************************** |
| 18 | * common.swg |
| 19 | * |
| 20 | * This file contains generic SWIG runtime support for pointer |
| 21 | * type checking as well as a few commonly used macros to control |
| 22 | * external linkage. |
| 23 | * |
| 24 | * Author : David Beazley (beazley@cs.uchicago.edu) |
| 25 | * |
| 26 | * Copyright (c) 1999-2000, The University of Chicago |
| 27 | * |
| 28 | * This file may be freely redistributed without license or fee provided |
| 29 | * this copyright message remains intact. |
| 30 | ************************************************************************/ |
| 31 | |
| 32 | #include "Python.h" |
| 33 | #include <string.h> |
| 34 | |
| 35 | #if defined(_WIN32) || defined(__WIN32__) |
| 36 | # if defined(_MSC_VER) |
| 37 | # if defined(STATIC_LINKED) |
| 38 | # define SWIGEXPORT(a) a |
| 39 | # define SWIGIMPORT(a) extern a |
| 40 | # else |
| 41 | # define SWIGEXPORT(a) __declspec(dllexport) a |
| 42 | # define SWIGIMPORT(a) extern a |
| 43 | # endif |
| 44 | # else |
| 45 | # if defined(__BORLANDC__) |
| 46 | # define SWIGEXPORT(a) a _export |
| 47 | # define SWIGIMPORT(a) a _export |
| 48 | # else |
| 49 | # define SWIGEXPORT(a) a |
| 50 | # define SWIGIMPORT(a) a |
| 51 | # endif |
| 52 | # endif |
| 53 | #else |
| 54 | # define SWIGEXPORT(a) a |
| 55 | # define SWIGIMPORT(a) a |
| 56 | #endif |
| 57 | |
| 58 | #ifdef SWIG_GLOBAL |
| 59 | #define SWIGRUNTIME(a) SWIGEXPORT(a) |
| 60 | #else |
| 61 | #define SWIGRUNTIME(a) static a |
| 62 | #endif |
| 63 | |
| 64 | #ifdef __cplusplus |
| 65 | extern "C" { |
| 66 | #endif |
| 67 | |
| 68 | typedef void *(*swig_converter_func)(void *); |
| 69 | typedef struct swig_type_info *(*swig_dycast_func)(void **); |
| 70 | |
| 71 | typedef struct swig_type_info { |
| 72 | const char *name; |
| 73 | swig_converter_func converter; |
| 74 | const char *str; |
| 75 | void *clientdata; |
| 76 | swig_dycast_func dcast; |
| 77 | struct swig_type_info *next; |
| 78 | struct swig_type_info *prev; |
| 79 | } swig_type_info; |
| 80 | |
| 81 | #ifdef SWIG_NOINCLUDE |
| 82 | |
| 83 | SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *); |
| 84 | SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *); |
| 85 | SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *); |
| 86 | SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **); |
| 87 | SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *); |
| 88 | SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *); |
| 89 | SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *); |
| 90 | |
| 91 | #else |
| 92 | |
| 93 | static swig_type_info *swig_type_list = 0; |
| 94 | |
| 95 | /* Register a type mapping with the type-checking */ |
| 96 | SWIGRUNTIME(swig_type_info *) |
| 97 | SWIG_TypeRegister(swig_type_info *ti) |
| 98 | { |
| 99 | swig_type_info *tc, *head, *ret, *next; |
| 100 | /* Check to see if this type has already been registered */ |
| 101 | tc = swig_type_list; |
| 102 | while (tc) { |
| 103 | if (strcmp(tc->name, ti->name) == 0) { |
| 104 | /* Already exists in the table. Just add additional types to the list */ |
| 105 | if (tc->clientdata) ti->clientdata = tc->clientdata; |
| 106 | head = tc; |
| 107 | next = tc->next; |
| 108 | goto l1; |
| 109 | } |
| 110 | tc = tc->prev; |
| 111 | } |
| 112 | head = ti; |
| 113 | next = 0; |
| 114 | |
| 115 | /* Place in list */ |
| 116 | ti->prev = swig_type_list; |
| 117 | swig_type_list = ti; |
| 118 | |
| 119 | /* Build linked lists */ |
| 120 | l1: |
| 121 | ret = head; |
| 122 | tc = ti + 1; |
| 123 | /* Patch up the rest of the links */ |
| 124 | while (tc->name) { |
| 125 | head->next = tc; |
| 126 | tc->prev = head; |
| 127 | head = tc; |
| 128 | tc++; |
| 129 | } |
| 130 | if (next) next->prev = head; /**/ |
| 131 | head->next = next; |
| 132 | return ret; |
| 133 | } |
| 134 | |
| 135 | /* Check the typename */ |
| 136 | SWIGRUNTIME(swig_type_info *) |
| 137 | SWIG_TypeCheck(char *c, swig_type_info *ty) |
| 138 | { |
| 139 | swig_type_info *s; |
| 140 | if (!ty) return 0; /* Void pointer */ |
| 141 | s = ty->next; /* First element always just a name */ |
| 142 | do { |
| 143 | if (strcmp(s->name,c) == 0) { |
| 144 | if (s == ty->next) return s; |
| 145 | /* Move s to the top of the linked list */ |
| 146 | s->prev->next = s->next; |
| 147 | if (s->next) { |
| 148 | s->next->prev = s->prev; |
| 149 | } |
| 150 | /* Insert s as second element in the list */ |
| 151 | s->next = ty->next; |
| 152 | if (ty->next) ty->next->prev = s; |
| 153 | ty->next = s; |
| 154 | s->prev = ty; /**/ |
| 155 | return s; |
| 156 | } |
| 157 | s = s->next; |
| 158 | } while (s && (s != ty->next)); |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | /* Cast a pointer up an inheritance hierarchy */ |
| 163 | SWIGRUNTIME(void *) |
| 164 | SWIG_TypeCast(swig_type_info *ty, void *ptr) |
| 165 | { |
| 166 | if ((!ty) || (!ty->converter)) return ptr; |
| 167 | return (*ty->converter)(ptr); |
| 168 | } |
| 169 | |
| 170 | /* Dynamic pointer casting. Down an inheritance hierarchy */ |
| 171 | SWIGRUNTIME(swig_type_info *) |
| 172 | SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) |
| 173 | { |
| 174 | swig_type_info *lastty = ty; |
| 175 | if (!ty || !ty->dcast) return ty; |
| 176 | while (ty && (ty->dcast)) { |
| 177 | ty = (*ty->dcast)(ptr); |
| 178 | if (ty) lastty = ty; |
| 179 | } |
| 180 | return lastty; |
| 181 | } |
| 182 | |
| 183 | /* Return the name associated with this type */ |
| 184 | SWIGRUNTIME(const char *) |
| 185 | SWIG_TypeName(const swig_type_info *ty) { |
| 186 | return ty->name; |
| 187 | } |
| 188 | |
| 189 | /* Search for a swig_type_info structure */ |
| 190 | SWIGRUNTIME(swig_type_info *) |
| 191 | SWIG_TypeQuery(const char *name) { |
| 192 | swig_type_info *ty = swig_type_list; |
| 193 | while (ty) { |
| 194 | if (ty->str && (strcmp(name,ty->str) == 0)) return ty; |
| 195 | if (ty->name && (strcmp(name,ty->name) == 0)) return ty; |
| 196 | ty = ty->prev; |
| 197 | } |
| 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | /* Set the clientdata field for a type */ |
| 202 | SWIGRUNTIME(void) |
| 203 | SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { |
| 204 | swig_type_info *tc, *equiv; |
| 205 | if (ti->clientdata == clientdata) return; |
| 206 | ti->clientdata = clientdata; |
| 207 | equiv = ti->next; |
| 208 | while (equiv) { |
| 209 | if (!equiv->converter) { |
| 210 | tc = swig_type_list; |
| 211 | while (tc) { |
| 212 | if ((strcmp(tc->name, equiv->name) == 0)) |
| 213 | SWIG_TypeClientData(tc,clientdata); |
| 214 | tc = tc->prev; |
| 215 | } |
| 216 | } |
| 217 | equiv = equiv->next; |
| 218 | } |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 | #ifdef __cplusplus |
| 223 | } |
| 224 | |
| 225 | #endif |
| 226 | /*********************************************************************** |
| 227 | * python.swg |
| 228 | * |
| 229 | * This file contains the runtime support for Python modules |
| 230 | * and includes code for managing global variables and pointer |
| 231 | * type checking. |
| 232 | * |
| 233 | * Author : David Beazley (beazley@cs.uchicago.edu) |
| 234 | ************************************************************************/ |
| 235 | |
| 236 | |
| 237 | #ifdef __cplusplus |
| 238 | extern "C" { |
| 239 | #endif |
| 240 | |
| 241 | #define SWIG_PY_INT 1 |
| 242 | #define SWIG_PY_FLOAT 2 |
| 243 | #define SWIG_PY_STRING 3 |
| 244 | #define SWIG_PY_POINTER 4 |
| 245 | #define SWIG_PY_BINARY 5 |
| 246 | |
| 247 | /* Flags for pointer conversion */ |
| 248 | |
| 249 | #define SWIG_POINTER_EXCEPTION 0x1 |
| 250 | #define SWIG_POINTER_DISOWN 0x2 |
| 251 | |
| 252 | /* Exception handling in wrappers */ |
| 253 | #define SWIG_fail goto fail |
| 254 | |
| 255 | /* Constant information structure */ |
| 256 | typedef struct swig_const_info { |
| 257 | int type; |
| 258 | char *name; |
| 259 | long lvalue; |
| 260 | double dvalue; |
| 261 | void *pvalue; |
| 262 | swig_type_info **ptype; |
| 263 | } swig_const_info; |
| 264 | |
| 265 | /* Common SWIG API */ |
| 266 | #define SWIG_ConvertPtr(obj, pp, type, flags) \ |
| 267 | SWIG_Python_ConvertPtr(obj, pp, type, flags) |
| 268 | #define SWIG_NewPointerObj(p, type, flags) \ |
| 269 | SWIG_Python_NewPointerObj(p, type, flags) |
| 270 | #define SWIG_MustGetPtr(p, type, argnum, flags) \ |
| 271 | SWIG_Python_MustGetPtr(p, type, argnum, flags) |
| 272 | |
| 273 | /* Python-specific SWIG API */ |
| 274 | #define SWIG_newvarlink() \ |
| 275 | SWIG_Python_newvarlink() |
| 276 | #define SWIG_addvarlink(p, name, get_attr, set_attr) \ |
| 277 | SWIG_Python_addvarlink(p, name, get_attr, set_attr) |
| 278 | #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \ |
| 279 | SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) |
| 280 | #define SWIG_PackData(c, ptr, sz) \ |
| 281 | SWIG_Python_PackData(c, ptr, sz) |
| 282 | #define SWIG_UnpackData(c, ptr, sz) \ |
| 283 | SWIG_Python_UnpackData(c, ptr, sz) |
| 284 | #define SWIG_NewPackedObj(ptr, sz, type) \ |
| 285 | SWIG_Python_NewPackedObj(ptr, sz, type) |
| 286 | #define SWIG_InstallConstants(d, constants) \ |
| 287 | SWIG_Python_InstallConstants(d, constants) |
| 288 | |
| 289 | #ifdef SWIG_NOINCLUDE |
| 290 | |
| 291 | SWIGEXPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int); |
| 292 | SWIGEXPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own); |
| 293 | SWIGEXPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int); |
| 294 | |
| 295 | SWIGEXPORT(PyObject *) SWIG_Python_newvarlink(void); |
| 296 | SWIGEXPORT(void) SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); |
| 297 | SWIGEXPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int); |
| 298 | SWIGEXPORT(char *) SWIG_Python_PackData(char *c, void *, int); |
| 299 | SWIGEXPORT(char *) SWIG_Python_UnpackData(char *c, void *, int); |
| 300 | SWIGEXPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *); |
| 301 | SWIGEXPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]); |
| 302 | #else |
| 303 | |
| 304 | /* ----------------------------------------------------------------------------- |
| 305 | * global variable support code. |
| 306 | * ----------------------------------------------------------------------------- */ |
| 307 | |
| 308 | typedef struct swig_globalvar { |
| 309 | char *name; /* Name of global variable */ |
| 310 | PyObject *(*get_attr)(void); /* Return the current value */ |
| 311 | int (*set_attr)(PyObject *); /* Set the value */ |
| 312 | struct swig_globalvar *next; |
| 313 | } swig_globalvar; |
| 314 | |
| 315 | typedef struct swig_varlinkobject { |
| 316 | PyObject_HEAD |
| 317 | swig_globalvar *vars; |
| 318 | } swig_varlinkobject; |
| 319 | |
| 320 | static PyObject * |
| 321 | swig_varlink_repr(swig_varlinkobject *v) { |
| 322 | v = v; |
| 323 | return PyString_FromString("<Global variables>"); |
| 324 | } |
| 325 | |
| 326 | static int |
| 327 | swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { |
| 328 | swig_globalvar *var; |
| 329 | flags = flags; |
| 330 | fprintf(fp,"Global variables { "); |
| 331 | for (var = v->vars; var; var=var->next) { |
| 332 | fprintf(fp,"%s", var->name); |
| 333 | if (var->next) fprintf(fp,", "); |
| 334 | } |
| 335 | fprintf(fp," }\n"); |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | static PyObject * |
| 340 | swig_varlink_getattr(swig_varlinkobject *v, char *n) { |
| 341 | swig_globalvar *var = v->vars; |
| 342 | while (var) { |
| 343 | if (strcmp(var->name,n) == 0) { |
| 344 | return (*var->get_attr)(); |
| 345 | } |
| 346 | var = var->next; |
| 347 | } |
| 348 | PyErr_SetString(PyExc_NameError,"Unknown C global variable"); |
| 349 | return NULL; |
| 350 | } |
| 351 | |
| 352 | static int |
| 353 | swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { |
| 354 | swig_globalvar *var = v->vars; |
| 355 | while (var) { |
| 356 | if (strcmp(var->name,n) == 0) { |
| 357 | return (*var->set_attr)(p); |
| 358 | } |
| 359 | var = var->next; |
| 360 | } |
| 361 | PyErr_SetString(PyExc_NameError,"Unknown C global variable"); |
| 362 | return 1; |
| 363 | } |
| 364 | |
| 365 | statichere PyTypeObject varlinktype = { |
| 366 | PyObject_HEAD_INIT(0) |
| 367 | 0, |
| 368 | (char *)"swigvarlink", /* Type name */ |
| 369 | sizeof(swig_varlinkobject), /* Basic size */ |
| 370 | 0, /* Itemsize */ |
| 371 | 0, /* Deallocator */ |
| 372 | (printfunc) swig_varlink_print, /* Print */ |
| 373 | (getattrfunc) swig_varlink_getattr, /* get attr */ |
| 374 | (setattrfunc) swig_varlink_setattr, /* Set attr */ |
| 375 | 0, /* tp_compare */ |
| 376 | (reprfunc) swig_varlink_repr, /* tp_repr */ |
| 377 | 0, /* tp_as_number */ |
| 378 | 0, /* tp_as_mapping*/ |
| 379 | 0, /* tp_hash */ |
| 380 | }; |
| 381 | |
| 382 | /* Create a variable linking object for use later */ |
| 383 | SWIGRUNTIME(PyObject *) |
| 384 | SWIG_Python_newvarlink(void) { |
| 385 | swig_varlinkobject *result = 0; |
| 386 | result = PyMem_NEW(swig_varlinkobject,1); |
| 387 | varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ |
| 388 | result->ob_type = &varlinktype; |
| 389 | result->vars = 0; |
| 390 | result->ob_refcnt = 0; |
| 391 | Py_XINCREF((PyObject *) result); |
| 392 | return ((PyObject*) result); |
| 393 | } |
| 394 | |
| 395 | SWIGRUNTIME(void) |
| 396 | SWIG_Python_addvarlink(PyObject *p, char *name, |
| 397 | PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { |
| 398 | swig_varlinkobject *v; |
| 399 | swig_globalvar *gv; |
| 400 | v= (swig_varlinkobject *) p; |
| 401 | gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); |
| 402 | gv->name = (char *) malloc(strlen(name)+1); |
| 403 | strcpy(gv->name,name); |
| 404 | gv->get_attr = get_attr; |
| 405 | gv->set_attr = set_attr; |
| 406 | gv->next = v->vars; |
| 407 | v->vars = gv; |
| 408 | } |
| 409 | |
| 410 | /* Pack binary data into a string */ |
| 411 | SWIGRUNTIME(char *) |
| 412 | SWIG_Python_PackData(char *c, void *ptr, int sz) { |
| 413 | static char hex[17] = "0123456789abcdef"; |
| 414 | int i; |
| 415 | unsigned char *u = (unsigned char *) ptr; |
| 416 | register unsigned char uu; |
| 417 | for (i = 0; i < sz; i++,u++) { |
| 418 | uu = *u; |
| 419 | *(c++) = hex[(uu & 0xf0) >> 4]; |
| 420 | *(c++) = hex[uu & 0xf]; |
| 421 | } |
| 422 | return c; |
| 423 | } |
| 424 | |
| 425 | /* Unpack binary data from a string */ |
| 426 | SWIGRUNTIME(char *) |
| 427 | SWIG_Python_UnpackData(char *c, void *ptr, int sz) { |
| 428 | register unsigned char uu = 0; |
| 429 | register int d; |
| 430 | unsigned char *u = (unsigned char *) ptr; |
| 431 | int i; |
| 432 | for (i = 0; i < sz; i++, u++) { |
| 433 | d = *(c++); |
| 434 | if ((d >= '0') && (d <= '9')) |
| 435 | uu = ((d - '0') << 4); |
| 436 | else if ((d >= 'a') && (d <= 'f')) |
| 437 | uu = ((d - ('a'-10)) << 4); |
| 438 | d = *(c++); |
| 439 | if ((d >= '0') && (d <= '9')) |
| 440 | uu |= (d - '0'); |
| 441 | else if ((d >= 'a') && (d <= 'f')) |
| 442 | uu |= (d - ('a'-10)); |
| 443 | *u = uu; |
| 444 | } |
| 445 | return c; |
| 446 | } |
| 447 | |
| 448 | /* Convert a pointer value */ |
| 449 | SWIGRUNTIME(int) |
| 450 | SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { |
| 451 | swig_type_info *tc; |
| 452 | char *c = 0; |
| 453 | static PyObject *SWIG_this = 0; |
| 454 | int newref = 0; |
| 455 | PyObject *pyobj = 0; |
| 456 | |
| 457 | if (!obj) return 0; |
| 458 | if (obj == Py_None) { |
| 459 | *ptr = 0; |
| 460 | return 0; |
| 461 | } |
| 462 | #ifdef SWIG_COBJECT_TYPES |
| 463 | if (!(PyCObject_Check(obj))) { |
| 464 | if (!SWIG_this) |
| 465 | SWIG_this = PyString_FromString("this"); |
| 466 | pyobj = obj; |
| 467 | obj = PyObject_GetAttr(obj,SWIG_this); |
| 468 | newref = 1; |
| 469 | if (!obj) goto type_error; |
| 470 | if (!PyCObject_Check(obj)) { |
| 471 | Py_DECREF(obj); |
| 472 | goto type_error; |
| 473 | } |
| 474 | } |
| 475 | *ptr = PyCObject_AsVoidPtr(obj); |
| 476 | c = (char *) PyCObject_GetDesc(obj); |
| 477 | if (newref) Py_DECREF(obj); |
| 478 | goto cobject; |
| 479 | #else |
| 480 | if (!(PyString_Check(obj))) { |
| 481 | if (!SWIG_this) |
| 482 | SWIG_this = PyString_FromString("this"); |
| 483 | pyobj = obj; |
| 484 | obj = PyObject_GetAttr(obj,SWIG_this); |
| 485 | newref = 1; |
| 486 | if (!obj) goto type_error; |
| 487 | if (!PyString_Check(obj)) { |
| 488 | Py_DECREF(obj); |
| 489 | goto type_error; |
| 490 | } |
| 491 | } |
| 492 | c = PyString_AsString(obj); |
| 493 | /* Pointer values must start with leading underscore */ |
| 494 | if (*c != '_') { |
| 495 | *ptr = (void *) 0; |
| 496 | if (strcmp(c,"NULL") == 0) { |
| 497 | if (newref) { Py_DECREF(obj); } |
| 498 | return 0; |
| 499 | } else { |
| 500 | if (newref) { Py_DECREF(obj); } |
| 501 | goto type_error; |
| 502 | } |
| 503 | } |
| 504 | c++; |
| 505 | c = SWIG_UnpackData(c,ptr,sizeof(void *)); |
| 506 | if (newref) { Py_DECREF(obj); } |
| 507 | #endif |
| 508 | |
| 509 | #ifdef SWIG_COBJECT_TYPES |
| 510 | cobject: |
| 511 | #endif |
| 512 | |
| 513 | if (ty) { |
| 514 | tc = SWIG_TypeCheck(c,ty); |
| 515 | if (!tc) goto type_error; |
| 516 | *ptr = SWIG_TypeCast(tc,(void*) *ptr); |
| 517 | } |
| 518 | |
| 519 | if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { |
| 520 | PyObject *zero = PyInt_FromLong(0); |
| 521 | PyObject_SetAttrString(pyobj,(char*)"thisown",zero); |
| 522 | Py_DECREF(zero); |
| 523 | } |
| 524 | return 0; |
| 525 | |
| 526 | type_error: |
| 527 | if (flags & SWIG_POINTER_EXCEPTION) { |
| 528 | if (ty && c) { |
| 529 | char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c)); |
| 530 | sprintf(temp,"Type error. Got %s, expected %s", c, ty->name); |
| 531 | PyErr_SetString(PyExc_TypeError, temp); |
| 532 | free((char *) temp); |
| 533 | } else { |
| 534 | PyErr_SetString(PyExc_TypeError,"Expected a pointer"); |
| 535 | } |
| 536 | } |
| 537 | return -1; |
| 538 | } |
| 539 | |
| 540 | /* Convert a pointer value, signal an exception on a type mismatch */ |
| 541 | SWIGRUNTIME(void *) |
| 542 | SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) |
| 543 | { |
| 544 | void *result; |
| 545 | SWIG_Python_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION); |
| 546 | return result; |
| 547 | } |
| 548 | |
| 549 | /* Convert a packed value value */ |
| 550 | SWIGRUNTIME(int) |
| 551 | SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) { |
| 552 | swig_type_info *tc; |
| 553 | char *c = 0; |
| 554 | |
| 555 | if ((!obj) || (!PyString_Check(obj))) goto type_error; |
| 556 | c = PyString_AsString(obj); |
| 557 | /* Pointer values must start with leading underscore */ |
| 558 | if (*c != '_') goto type_error; |
| 559 | c++; |
| 560 | c = SWIG_UnpackData(c,ptr,sz); |
| 561 | if (ty) { |
| 562 | tc = SWIG_TypeCheck(c,ty); |
| 563 | if (!tc) goto type_error; |
| 564 | } |
| 565 | return 0; |
| 566 | |
| 567 | type_error: |
| 568 | |
| 569 | if (flags) { |
| 570 | if (ty && c) { |
| 571 | char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c)); |
| 572 | sprintf(temp,"Type error. Got %s, expected %s", c, ty->name); |
| 573 | PyErr_SetString(PyExc_TypeError, temp); |
| 574 | free((char *) temp); |
| 575 | } else { |
| 576 | PyErr_SetString(PyExc_TypeError,"Expected a pointer"); |
| 577 | } |
| 578 | } |
| 579 | return -1; |
| 580 | } |
| 581 | |
| 582 | /* Create a new pointer object */ |
| 583 | SWIGRUNTIME(PyObject *) |
| 584 | SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { |
| 585 | PyObject *robj; |
| 586 | if (!ptr) { |
| 587 | Py_INCREF(Py_None); |
| 588 | return Py_None; |
| 589 | } |
| 590 | #ifdef SWIG_COBJECT_TYPES |
| 591 | robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); |
| 592 | #else |
| 593 | { |
| 594 | char result[1024]; |
| 595 | char *r = result; |
| 596 | *(r++) = '_'; |
| 597 | r = SWIG_PackData(r,&ptr,sizeof(void *)); |
| 598 | strcpy(r,type->name); |
| 599 | robj = PyString_FromString(result); |
| 600 | } |
| 601 | #endif |
| 602 | if (!robj || (robj == Py_None)) return robj; |
| 603 | if (type->clientdata) { |
| 604 | PyObject *inst; |
| 605 | PyObject *args = Py_BuildValue((char*)"(O)", robj); |
| 606 | Py_DECREF(robj); |
| 607 | inst = PyObject_CallObject((PyObject *) type->clientdata, args); |
| 608 | Py_DECREF(args); |
| 609 | if (inst) { |
| 610 | if (own) { |
| 611 | PyObject *n = PyInt_FromLong(1); |
| 612 | PyObject_SetAttrString(inst,(char*)"thisown",n); |
| 613 | Py_DECREF(n); |
| 614 | } |
| 615 | robj = inst; |
| 616 | } |
| 617 | } |
| 618 | return robj; |
| 619 | } |
| 620 | |
| 621 | SWIGRUNTIME(PyObject *) |
| 622 | SWIG_Python_NewPackedObj(void *ptr, int sz, swig_type_info *type) { |
| 623 | char result[1024]; |
| 624 | char *r = result; |
| 625 | if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; |
| 626 | *(r++) = '_'; |
| 627 | r = SWIG_PackData(r,ptr,sz); |
| 628 | strcpy(r,type->name); |
| 629 | return PyString_FromString(result); |
| 630 | } |
| 631 | |
| 632 | /* Install Constants */ |
| 633 | SWIGRUNTIME(void) |
| 634 | SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { |
| 635 | int i; |
| 636 | PyObject *obj; |
| 637 | for (i = 0; constants[i].type; i++) { |
| 638 | switch(constants[i].type) { |
| 639 | case SWIG_PY_INT: |
| 640 | obj = PyInt_FromLong(constants[i].lvalue); |
| 641 | break; |
| 642 | case SWIG_PY_FLOAT: |
| 643 | obj = PyFloat_FromDouble(constants[i].dvalue); |
| 644 | break; |
| 645 | case SWIG_PY_STRING: |
| 646 | obj = PyString_FromString((char *) constants[i].pvalue); |
| 647 | break; |
| 648 | case SWIG_PY_POINTER: |
| 649 | obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); |
| 650 | break; |
| 651 | case SWIG_PY_BINARY: |
| 652 | obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); |
| 653 | break; |
| 654 | default: |
| 655 | obj = 0; |
| 656 | break; |
| 657 | } |
| 658 | if (obj) { |
| 659 | PyDict_SetItemString(d,constants[i].name,obj); |
| 660 | Py_DECREF(obj); |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | #endif |
| 666 | |
| 667 | /* Contract support */ |
| 668 | |
| 669 | #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else |
| 670 | |
| 671 | #ifdef __cplusplus |
| 672 | } |
| 673 | #endif |