1 /* ---------------------------------------------------------------------------- 2 * This file was automatically generated by SWIG (http://www.swig.org). 3 * Version 2.0.11 4 * 5 * This file is not intended to be easily readable and contains a number of 6 * coding conventions designed to improve portability and efficiency. Do not make 7 * changes to this file unless you know what you are doing--modify the SWIG 8 * interface file instead. 9 * ----------------------------------------------------------------------------- */ 10 11 #define SWIGPYTHON 12 #define SWIG_PYTHON_DIRECTOR_NO_VTABLE 13 14 /* ----------------------------------------------------------------------------- 15 * This section contains generic SWIG labels for method/variable 16 * declarations/attributes, and other compiler dependent labels. 17 * ----------------------------------------------------------------------------- */ 18 19 /* template workaround for compilers that cannot correctly implement the C++ standard */ 20 #ifndef SWIGTEMPLATEDISAMBIGUATOR 21 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) 22 # define SWIGTEMPLATEDISAMBIGUATOR template 23 # elif defined(__HP_aCC) 24 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ 25 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ 26 # define SWIGTEMPLATEDISAMBIGUATOR template 27 # else 28 # define SWIGTEMPLATEDISAMBIGUATOR 29 # endif 30 #endif 31 32 /* inline attribute */ 33 #ifndef SWIGINLINE 34 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) 35 # define SWIGINLINE inline 36 # else 37 # define SWIGINLINE 38 # endif 39 #endif 40 41 /* attribute recognised by some compilers to avoid 'unused' warnings */ 42 #ifndef SWIGUNUSED 43 # if defined(__GNUC__) 44 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 45 # define SWIGUNUSED __attribute__ ((__unused__)) 46 # else 47 # define SWIGUNUSED 48 # endif 49 # elif defined(__ICC) 50 # define SWIGUNUSED __attribute__ ((__unused__)) 51 # else 52 # define SWIGUNUSED 53 # endif 54 #endif 55 56 #ifndef SWIG_MSC_UNSUPPRESS_4505 57 # if defined(_MSC_VER) 58 # pragma warning(disable : 4505) /* unreferenced local function has been removed */ 59 # endif 60 #endif 61 62 #ifndef SWIGUNUSEDPARM 63 # ifdef __cplusplus 64 # define SWIGUNUSEDPARM(p) 65 # else 66 # define SWIGUNUSEDPARM(p) p SWIGUNUSED 67 # endif 68 #endif 69 70 /* internal SWIG method */ 71 #ifndef SWIGINTERN 72 # define SWIGINTERN static SWIGUNUSED 73 #endif 74 75 /* internal inline SWIG method */ 76 #ifndef SWIGINTERNINLINE 77 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE 78 #endif 79 80 /* exporting methods */ 81 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 82 # ifndef GCC_HASCLASSVISIBILITY 83 # define GCC_HASCLASSVISIBILITY 84 # endif 85 #endif 86 87 #ifndef SWIGEXPORT 88 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 89 # if defined(STATIC_LINKED) 90 # define SWIGEXPORT 91 # else 92 # define SWIGEXPORT __declspec(dllexport) 93 # endif 94 # else 95 # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) 96 # define SWIGEXPORT __attribute__ ((visibility("default"))) 97 # else 98 # define SWIGEXPORT 99 # endif 100 # endif 101 #endif 102 103 /* calling conventions for Windows */ 104 #ifndef SWIGSTDCALL 105 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 106 # define SWIGSTDCALL __stdcall 107 # else 108 # define SWIGSTDCALL 109 # endif 110 #endif 111 112 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ 113 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) 114 # define _CRT_SECURE_NO_DEPRECATE 115 #endif 116 117 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ 118 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) 119 # define _SCL_SECURE_NO_DEPRECATE 120 #endif 121 122 123 124 #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) 125 /* Use debug wrappers with the Python release dll */ 126 # undef _DEBUG 127 # include <Python.h> 128 # define _DEBUG 129 #else 130 # include <Python.h> 131 #endif 132 133 /* ----------------------------------------------------------------------------- 134 * swigrun.swg 135 * 136 * This file contains generic C API SWIG runtime support for pointer 137 * type checking. 138 * ----------------------------------------------------------------------------- */ 139 140 /* This should only be incremented when either the layout of swig_type_info changes, 141 or for whatever reason, the runtime changes incompatibly */ 142 #define SWIG_RUNTIME_VERSION "4" 143 144 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ 145 #ifdef SWIG_TYPE_TABLE 146 # define SWIG_QUOTE_STRING(x) #x 147 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) 148 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) 149 #else 150 # define SWIG_TYPE_TABLE_NAME 151 #endif 152 153 /* 154 You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for 155 creating a static or dynamic library from the SWIG runtime code. 156 In 99.9% of the cases, SWIG just needs to declare them as 'static'. 157 158 But only do this if strictly necessary, ie, if you have problems 159 with your compiler or suchlike. 160 */ 161 162 #ifndef SWIGRUNTIME 163 # define SWIGRUNTIME SWIGINTERN 164 #endif 165 166 #ifndef SWIGRUNTIMEINLINE 167 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE 168 #endif 169 170 /* Generic buffer size */ 171 #ifndef SWIG_BUFFER_SIZE 172 # define SWIG_BUFFER_SIZE 1024 173 #endif 174 175 /* Flags for pointer conversions */ 176 #define SWIG_POINTER_DISOWN 0x1 177 #define SWIG_CAST_NEW_MEMORY 0x2 178 179 /* Flags for new pointer objects */ 180 #define SWIG_POINTER_OWN 0x1 181 182 183 /* 184 Flags/methods for returning states. 185 186 The SWIG conversion methods, as ConvertPtr, return an integer 187 that tells if the conversion was successful or not. And if not, 188 an error code can be returned (see swigerrors.swg for the codes). 189 190 Use the following macros/flags to set or process the returning 191 states. 192 193 In old versions of SWIG, code such as the following was usually written: 194 195 if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { 196 // success code 197 } else { 198 //fail code 199 } 200 201 Now you can be more explicit: 202 203 int res = SWIG_ConvertPtr(obj,vptr,ty.flags); 204 if (SWIG_IsOK(res)) { 205 // success code 206 } else { 207 // fail code 208 } 209 210 which is the same really, but now you can also do 211 212 Type *ptr; 213 int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); 214 if (SWIG_IsOK(res)) { 215 // success code 216 if (SWIG_IsNewObj(res) { 217 ... 218 delete *ptr; 219 } else { 220 ... 221 } 222 } else { 223 // fail code 224 } 225 226 I.e., now SWIG_ConvertPtr can return new objects and you can 227 identify the case and take care of the deallocation. Of course that 228 also requires SWIG_ConvertPtr to return new result values, such as 229 230 int SWIG_ConvertPtr(obj, ptr,...) { 231 if (<obj is ok>) { 232 if (<need new object>) { 233 *ptr = <ptr to new allocated object>; 234 return SWIG_NEWOBJ; 235 } else { 236 *ptr = <ptr to old object>; 237 return SWIG_OLDOBJ; 238 } 239 } else { 240 return SWIG_BADOBJ; 241 } 242 } 243 244 Of course, returning the plain '0(success)/-1(fail)' still works, but you can be 245 more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the 246 SWIG errors code. 247 248 Finally, if the SWIG_CASTRANK_MODE is enabled, the result code 249 allows to return the 'cast rank', for example, if you have this 250 251 int food(double) 252 int fooi(int); 253 254 and you call 255 256 food(1) // cast rank '1' (1 -> 1.0) 257 fooi(1) // cast rank '0' 258 259 just use the SWIG_AddCast()/SWIG_CheckState() 260 */ 261 262 #define SWIG_OK (0) 263 #define SWIG_ERROR (-1) 264 #define SWIG_IsOK(r) (r >= 0) 265 #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) 266 267 /* The CastRankLimit says how many bits are used for the cast rank */ 268 #define SWIG_CASTRANKLIMIT (1 << 8) 269 /* The NewMask denotes the object was created (using new/malloc) */ 270 #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) 271 /* The TmpMask is for in/out typemaps that use temporal objects */ 272 #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) 273 /* Simple returning values */ 274 #define SWIG_BADOBJ (SWIG_ERROR) 275 #define SWIG_OLDOBJ (SWIG_OK) 276 #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) 277 #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) 278 /* Check, add and del mask methods */ 279 #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) 280 #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) 281 #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) 282 #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) 283 #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) 284 #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) 285 286 /* Cast-Rank Mode */ 287 #if defined(SWIG_CASTRANK_MODE) 288 # ifndef SWIG_TypeRank 289 # define SWIG_TypeRank unsigned long 290 # endif 291 # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ 292 # define SWIG_MAXCASTRANK (2) 293 # endif 294 # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) 295 # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) 296 SWIGINTERNINLINE int SWIG_AddCast(int r) { 297 return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; 298 } 299 SWIGINTERNINLINE int SWIG_CheckState(int r) { 300 return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 301 } 302 #else /* no cast-rank mode */ 303 # define SWIG_AddCast(r) (r) 304 # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) 305 #endif 306 307 308 #include <string.h> 309 310 #ifdef __cplusplus 311 extern "C" { 312 #endif 313 314 typedef void *(*swig_converter_func)(void *, int *); 315 typedef struct swig_type_info *(*swig_dycast_func)(void **); 316 317 /* Structure to store information on one type */ 318 typedef struct swig_type_info { 319 const char *name; /* mangled name of this type */ 320 const char *str; /* human readable name of this type */ 321 swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ 322 struct swig_cast_info *cast; /* linked list of types that can cast into this type */ 323 void *clientdata; /* language specific type data */ 324 int owndata; /* flag if the structure owns the clientdata */ 325 } swig_type_info; 326 327 /* Structure to store a type and conversion function used for casting */ 328 typedef struct swig_cast_info { 329 swig_type_info *type; /* pointer to type that is equivalent to this type */ 330 swig_converter_func converter; /* function to cast the void pointers */ 331 struct swig_cast_info *next; /* pointer to next cast in linked list */ 332 struct swig_cast_info *prev; /* pointer to the previous cast */ 333 } swig_cast_info; 334 335 /* Structure used to store module information 336 * Each module generates one structure like this, and the runtime collects 337 * all of these structures and stores them in a circularly linked list.*/ 338 typedef struct swig_module_info { 339 swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ 340 size_t size; /* Number of types in this module */ 341 struct swig_module_info *next; /* Pointer to next element in circularly linked list */ 342 swig_type_info **type_initial; /* Array of initially generated type structures */ 343 swig_cast_info **cast_initial; /* Array of initially generated casting structures */ 344 void *clientdata; /* Language specific module data */ 345 } swig_module_info; 346 347 /* 348 Compare two type names skipping the space characters, therefore 349 "char*" == "char *" and "Class<int>" == "Class<int >", etc. 350 351 Return 0 when the two name types are equivalent, as in 352 strncmp, but skipping ' '. 353 */ 354 SWIGRUNTIME int 355 SWIG_TypeNameComp(const char *f1, const char *l1, 356 const char *f2, const char *l2) { 357 for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { 358 while ((*f1 == ' ') && (f1 != l1)) ++f1; 359 while ((*f2 == ' ') && (f2 != l2)) ++f2; 360 if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; 361 } 362 return (int)((l1 - f1) - (l2 - f2)); 363 } 364 365 /* 366 Check type equivalence in a name list like <name1>|<name2>|... 367 Return 0 if equal, -1 if nb < tb, 1 if nb > tb 368 */ 369 SWIGRUNTIME int 370 SWIG_TypeCmp(const char *nb, const char *tb) { 371 int equiv = 1; 372 const char* te = tb + strlen(tb); 373 const char* ne = nb; 374 while (equiv != 0 && *ne) { 375 for (nb = ne; *ne; ++ne) { 376 if (*ne == '|') break; 377 } 378 equiv = SWIG_TypeNameComp(nb, ne, tb, te); 379 if (*ne) ++ne; 380 } 381 return equiv; 382 } 383 384 /* 385 Check type equivalence in a name list like <name1>|<name2>|... 386 Return 0 if not equal, 1 if equal 387 */ 388 SWIGRUNTIME int 389 SWIG_TypeEquiv(const char *nb, const char *tb) { 390 return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; 391 } 392 393 /* 394 Check the typename 395 */ 396 SWIGRUNTIME swig_cast_info * 397 SWIG_TypeCheck(const char *c, swig_type_info *ty) { 398 if (ty) { 399 swig_cast_info *iter = ty->cast; 400 while (iter) { 401 if (strcmp(iter->type->name, c) == 0) { 402 if (iter == ty->cast) 403 return iter; 404 /* Move iter to the top of the linked list */ 405 iter->prev->next = iter->next; 406 if (iter->next) 407 iter->next->prev = iter->prev; 408 iter->next = ty->cast; 409 iter->prev = 0; 410 if (ty->cast) ty->cast->prev = iter; 411 ty->cast = iter; 412 return iter; 413 } 414 iter = iter->next; 415 } 416 } 417 return 0; 418 } 419 420 /* 421 Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison 422 */ 423 SWIGRUNTIME swig_cast_info * 424 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { 425 if (ty) { 426 swig_cast_info *iter = ty->cast; 427 while (iter) { 428 if (iter->type == from) { 429 if (iter == ty->cast) 430 return iter; 431 /* Move iter to the top of the linked list */ 432 iter->prev->next = iter->next; 433 if (iter->next) 434 iter->next->prev = iter->prev; 435 iter->next = ty->cast; 436 iter->prev = 0; 437 if (ty->cast) ty->cast->prev = iter; 438 ty->cast = iter; 439 return iter; 440 } 441 iter = iter->next; 442 } 443 } 444 return 0; 445 } 446 447 /* 448 Cast a pointer up an inheritance hierarchy 449 */ 450 SWIGRUNTIMEINLINE void * 451 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { 452 return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); 453 } 454 455 /* 456 Dynamic pointer casting. Down an inheritance hierarchy 457 */ 458 SWIGRUNTIME swig_type_info * 459 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { 460 swig_type_info *lastty = ty; 461 if (!ty || !ty->dcast) return ty; 462 while (ty && (ty->dcast)) { 463 ty = (*ty->dcast)(ptr); 464 if (ty) lastty = ty; 465 } 466 return lastty; 467 } 468 469 /* 470 Return the name associated with this type 471 */ 472 SWIGRUNTIMEINLINE const char * 473 SWIG_TypeName(const swig_type_info *ty) { 474 return ty->name; 475 } 476 477 /* 478 Return the pretty name associated with this type, 479 that is an unmangled type name in a form presentable to the user. 480 */ 481 SWIGRUNTIME const char * 482 SWIG_TypePrettyName(const swig_type_info *type) { 483 /* The "str" field contains the equivalent pretty names of the 484 type, separated by vertical-bar characters. We choose 485 to print the last name, as it is often (?) the most 486 specific. */ 487 if (!type) return NULL; 488 if (type->str != NULL) { 489 const char *last_name = type->str; 490 const char *s; 491 for (s = type->str; *s; s++) 492 if (*s == '|') last_name = s+1; 493 return last_name; 494 } 495 else 496 return type->name; 497 } 498 499 /* 500 Set the clientdata field for a type 501 */ 502 SWIGRUNTIME void 503 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { 504 swig_cast_info *cast = ti->cast; 505 /* if (ti->clientdata == clientdata) return; */ 506 ti->clientdata = clientdata; 507 508 while (cast) { 509 if (!cast->converter) { 510 swig_type_info *tc = cast->type; 511 if (!tc->clientdata) { 512 SWIG_TypeClientData(tc, clientdata); 513 } 514 } 515 cast = cast->next; 516 } 517 } 518 SWIGRUNTIME void 519 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { 520 SWIG_TypeClientData(ti, clientdata); 521 ti->owndata = 1; 522 } 523 524 /* 525 Search for a swig_type_info structure only by mangled name 526 Search is a O(log #types) 527 528 We start searching at module start, and finish searching when start == end. 529 Note: if start == end at the beginning of the function, we go all the way around 530 the circular list. 531 */ 532 SWIGRUNTIME swig_type_info * 533 SWIG_MangledTypeQueryModule(swig_module_info *start, 534 swig_module_info *end, 535 const char *name) { 536 swig_module_info *iter = start; 537 do { 538 if (iter->size) { 539 register size_t l = 0; 540 register size_t r = iter->size - 1; 541 do { 542 /* since l+r >= 0, we can (>> 1) instead (/ 2) */ 543 register size_t i = (l + r) >> 1; 544 const char *iname = iter->types[i]->name; 545 if (iname) { 546 register int compare = strcmp(name, iname); 547 if (compare == 0) { 548 return iter->types[i]; 549 } else if (compare < 0) { 550 if (i) { 551 r = i - 1; 552 } else { 553 break; 554 } 555 } else if (compare > 0) { 556 l = i + 1; 557 } 558 } else { 559 break; /* should never happen */ 560 } 561 } while (l <= r); 562 } 563 iter = iter->next; 564 } while (iter != end); 565 return 0; 566 } 567 568 /* 569 Search for a swig_type_info structure for either a mangled name or a human readable name. 570 It first searches the mangled names of the types, which is a O(log #types) 571 If a type is not found it then searches the human readable names, which is O(#types). 572 573 We start searching at module start, and finish searching when start == end. 574 Note: if start == end at the beginning of the function, we go all the way around 575 the circular list. 576 */ 577 SWIGRUNTIME swig_type_info * 578 SWIG_TypeQueryModule(swig_module_info *start, 579 swig_module_info *end, 580 const char *name) { 581 /* STEP 1: Search the name field using binary search */ 582 swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); 583 if (ret) { 584 return ret; 585 } else { 586 /* STEP 2: If the type hasn't been found, do a complete search 587 of the str field (the human readable name) */ 588 swig_module_info *iter = start; 589 do { 590 register size_t i = 0; 591 for (; i < iter->size; ++i) { 592 if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) 593 return iter->types[i]; 594 } 595 iter = iter->next; 596 } while (iter != end); 597 } 598 599 /* neither found a match */ 600 return 0; 601 } 602 603 /* 604 Pack binary data into a string 605 */ 606 SWIGRUNTIME char * 607 SWIG_PackData(char *c, void *ptr, size_t sz) { 608 static const char hex[17] = "0123456789abcdef"; 609 register const unsigned char *u = (unsigned char *) ptr; 610 register const unsigned char *eu = u + sz; 611 for (; u != eu; ++u) { 612 register unsigned char uu = *u; 613 *(c++) = hex[(uu & 0xf0) >> 4]; 614 *(c++) = hex[uu & 0xf]; 615 } 616 return c; 617 } 618 619 /* 620 Unpack binary data from a string 621 */ 622 SWIGRUNTIME const char * 623 SWIG_UnpackData(const char *c, void *ptr, size_t sz) { 624 register unsigned char *u = (unsigned char *) ptr; 625 register const unsigned char *eu = u + sz; 626 for (; u != eu; ++u) { 627 register char d = *(c++); 628 register unsigned char uu; 629 if ((d >= '0') && (d <= '9')) 630 uu = ((d - '0') << 4); 631 else if ((d >= 'a') && (d <= 'f')) 632 uu = ((d - ('a'-10)) << 4); 633 else 634 return (char *) 0; 635 d = *(c++); 636 if ((d >= '0') && (d <= '9')) 637 uu |= (d - '0'); 638 else if ((d >= 'a') && (d <= 'f')) 639 uu |= (d - ('a'-10)); 640 else 641 return (char *) 0; 642 *u = uu; 643 } 644 return c; 645 } 646 647 /* 648 Pack 'void *' into a string buffer. 649 */ 650 SWIGRUNTIME char * 651 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { 652 char *r = buff; 653 if ((2*sizeof(void *) + 2) > bsz) return 0; 654 *(r++) = '_'; 655 r = SWIG_PackData(r,&ptr,sizeof(void *)); 656 if (strlen(name) + 1 > (bsz - (r - buff))) return 0; 657 strcpy(r,name); 658 return buff; 659 } 660 661 SWIGRUNTIME const char * 662 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { 663 if (*c != '_') { 664 if (strcmp(c,"NULL") == 0) { 665 *ptr = (void *) 0; 666 return name; 667 } else { 668 return 0; 669 } 670 } 671 return SWIG_UnpackData(++c,ptr,sizeof(void *)); 672 } 673 674 SWIGRUNTIME char * 675 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { 676 char *r = buff; 677 size_t lname = (name ? strlen(name) : 0); 678 if ((2*sz + 2 + lname) > bsz) return 0; 679 *(r++) = '_'; 680 r = SWIG_PackData(r,ptr,sz); 681 if (lname) { 682 strncpy(r,name,lname+1); 683 } else { 684 *r = 0; 685 } 686 return buff; 687 } 688 689 SWIGRUNTIME const char * 690 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { 691 if (*c != '_') { 692 if (strcmp(c,"NULL") == 0) { 693 memset(ptr,0,sz); 694 return name; 695 } else { 696 return 0; 697 } 698 } 699 return SWIG_UnpackData(++c,ptr,sz); 700 } 701 702 #ifdef __cplusplus 703 } 704 #endif 705 706 /* Errors in SWIG */ 707 #define SWIG_UnknownError -1 708 #define SWIG_IOError -2 709 #define SWIG_RuntimeError -3 710 #define SWIG_IndexError -4 711 #define SWIG_TypeError -5 712 #define SWIG_DivisionByZero -6 713 #define SWIG_OverflowError -7 714 #define SWIG_SyntaxError -8 715 #define SWIG_ValueError -9 716 #define SWIG_SystemError -10 717 #define SWIG_AttributeError -11 718 #define SWIG_MemoryError -12 719 #define SWIG_NullReferenceError -13 720 721 722 723 /* Compatibility macros for Python 3 */ 724 #if PY_VERSION_HEX >= 0x03000000 725 726 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) 727 #define PyInt_Check(x) PyLong_Check(x) 728 #define PyInt_AsLong(x) PyLong_AsLong(x) 729 #define PyInt_FromLong(x) PyLong_FromLong(x) 730 #define PyInt_FromSize_t(x) PyLong_FromSize_t(x) 731 #define PyString_Check(name) PyBytes_Check(name) 732 #define PyString_FromString(x) PyUnicode_FromString(x) 733 #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) 734 #define PyString_AsString(str) PyBytes_AsString(str) 735 #define PyString_Size(str) PyBytes_Size(str) 736 #define PyString_InternFromString(key) PyUnicode_InternFromString(key) 737 #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE 738 #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) 739 #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) 740 741 #endif 742 743 #ifndef Py_TYPE 744 # define Py_TYPE(op) ((op)->ob_type) 745 #endif 746 747 /* SWIG APIs for compatibility of both Python 2 & 3 */ 748 749 #if PY_VERSION_HEX >= 0x03000000 750 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat 751 #else 752 # define SWIG_Python_str_FromFormat PyString_FromFormat 753 #endif 754 755 756 /* Warning: This function will allocate a new string in Python 3, 757 * so please call SWIG_Python_str_DelForPy3(x) to free the space. 758 */ 759 SWIGINTERN char* 760 SWIG_Python_str_AsChar(PyObject *str) 761 { 762 #if PY_VERSION_HEX >= 0x03000000 763 char *cstr; 764 char *newstr; 765 Py_ssize_t len; 766 str = PyUnicode_AsUTF8String(str); 767 PyBytes_AsStringAndSize(str, &cstr, &len); 768 newstr = (char *) malloc(len+1); 769 memcpy(newstr, cstr, len+1); 770 Py_XDECREF(str); 771 return newstr; 772 #else 773 return PyString_AsString(str); 774 #endif 775 } 776 777 #if PY_VERSION_HEX >= 0x03000000 778 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) 779 #else 780 # define SWIG_Python_str_DelForPy3(x) 781 #endif 782 783 784 SWIGINTERN PyObject* 785 SWIG_Python_str_FromChar(const char *c) 786 { 787 #if PY_VERSION_HEX >= 0x03000000 788 return PyUnicode_FromString(c); 789 #else 790 return PyString_FromString(c); 791 #endif 792 } 793 794 /* Add PyOS_snprintf for old Pythons */ 795 #if PY_VERSION_HEX < 0x02020000 796 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) 797 # define PyOS_snprintf _snprintf 798 # else 799 # define PyOS_snprintf snprintf 800 # endif 801 #endif 802 803 /* A crude PyString_FromFormat implementation for old Pythons */ 804 #if PY_VERSION_HEX < 0x02020000 805 806 #ifndef SWIG_PYBUFFER_SIZE 807 # define SWIG_PYBUFFER_SIZE 1024 808 #endif 809 810 static PyObject * 811 PyString_FromFormat(const char *fmt, ...) { 812 va_list ap; 813 char buf[SWIG_PYBUFFER_SIZE * 2]; 814 int res; 815 va_start(ap, fmt); 816 res = vsnprintf(buf, sizeof(buf), fmt, ap); 817 va_end(ap); 818 return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); 819 } 820 #endif 821 822 /* Add PyObject_Del for old Pythons */ 823 #if PY_VERSION_HEX < 0x01060000 824 # define PyObject_Del(op) PyMem_DEL((op)) 825 #endif 826 #ifndef PyObject_DEL 827 # define PyObject_DEL PyObject_Del 828 #endif 829 830 /* A crude PyExc_StopIteration exception for old Pythons */ 831 #if PY_VERSION_HEX < 0x02020000 832 # ifndef PyExc_StopIteration 833 # define PyExc_StopIteration PyExc_RuntimeError 834 # endif 835 # ifndef PyObject_GenericGetAttr 836 # define PyObject_GenericGetAttr 0 837 # endif 838 #endif 839 840 /* Py_NotImplemented is defined in 2.1 and up. */ 841 #if PY_VERSION_HEX < 0x02010000 842 # ifndef Py_NotImplemented 843 # define Py_NotImplemented PyExc_RuntimeError 844 # endif 845 #endif 846 847 /* A crude PyString_AsStringAndSize implementation for old Pythons */ 848 #if PY_VERSION_HEX < 0x02010000 849 # ifndef PyString_AsStringAndSize 850 # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} 851 # endif 852 #endif 853 854 /* PySequence_Size for old Pythons */ 855 #if PY_VERSION_HEX < 0x02000000 856 # ifndef PySequence_Size 857 # define PySequence_Size PySequence_Length 858 # endif 859 #endif 860 861 /* PyBool_FromLong for old Pythons */ 862 #if PY_VERSION_HEX < 0x02030000 863 static 864 PyObject *PyBool_FromLong(long ok) 865 { 866 PyObject *result = ok ? Py_True : Py_False; 867 Py_INCREF(result); 868 return result; 869 } 870 #endif 871 872 /* Py_ssize_t for old Pythons */ 873 /* This code is as recommended by: */ 874 /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ 875 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) 876 typedef int Py_ssize_t; 877 # define PY_SSIZE_T_MAX INT_MAX 878 # define PY_SSIZE_T_MIN INT_MIN 879 typedef inquiry lenfunc; 880 typedef intargfunc ssizeargfunc; 881 typedef intintargfunc ssizessizeargfunc; 882 typedef intobjargproc ssizeobjargproc; 883 typedef intintobjargproc ssizessizeobjargproc; 884 typedef getreadbufferproc readbufferproc; 885 typedef getwritebufferproc writebufferproc; 886 typedef getsegcountproc segcountproc; 887 typedef getcharbufferproc charbufferproc; 888 static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) 889 { 890 long result = 0; 891 PyObject *i = PyNumber_Int(x); 892 if (i) { 893 result = PyInt_AsLong(i); 894 Py_DECREF(i); 895 } 896 return result; 897 } 898 #endif 899 900 #if PY_VERSION_HEX < 0x02050000 901 #define PyInt_FromSize_t(x) PyInt_FromLong((long)x) 902 #endif 903 904 #if PY_VERSION_HEX < 0x02040000 905 #define Py_VISIT(op) \ 906 do { \ 907 if (op) { \ 908 int vret = visit((op), arg); \ 909 if (vret) \ 910 return vret; \ 911 } \ 912 } while (0) 913 #endif 914 915 #if PY_VERSION_HEX < 0x02030000 916 typedef struct { 917 PyTypeObject type; 918 PyNumberMethods as_number; 919 PyMappingMethods as_mapping; 920 PySequenceMethods as_sequence; 921 PyBufferProcs as_buffer; 922 PyObject *name, *slots; 923 } PyHeapTypeObject; 924 #endif 925 926 #if PY_VERSION_HEX < 0x02030000 927 typedef destructor freefunc; 928 #endif 929 930 #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ 931 (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ 932 (PY_MAJOR_VERSION > 3)) 933 # define SWIGPY_USE_CAPSULE 934 # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) 935 #endif 936 937 #if PY_VERSION_HEX < 0x03020000 938 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) 939 #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) 940 #endif 941 942 /* ----------------------------------------------------------------------------- 943 * error manipulation 944 * ----------------------------------------------------------------------------- */ 945 946 SWIGRUNTIME PyObject* 947 SWIG_Python_ErrorType(int code) { 948 PyObject* type = 0; 949 switch(code) { 950 case SWIG_MemoryError: 951 type = PyExc_MemoryError; 952 break; 953 case SWIG_IOError: 954 type = PyExc_IOError; 955 break; 956 case SWIG_RuntimeError: 957 type = PyExc_RuntimeError; 958 break; 959 case SWIG_IndexError: 960 type = PyExc_IndexError; 961 break; 962 case SWIG_TypeError: 963 type = PyExc_TypeError; 964 break; 965 case SWIG_DivisionByZero: 966 type = PyExc_ZeroDivisionError; 967 break; 968 case SWIG_OverflowError: 969 type = PyExc_OverflowError; 970 break; 971 case SWIG_SyntaxError: 972 type = PyExc_SyntaxError; 973 break; 974 case SWIG_ValueError: 975 type = PyExc_ValueError; 976 break; 977 case SWIG_SystemError: 978 type = PyExc_SystemError; 979 break; 980 case SWIG_AttributeError: 981 type = PyExc_AttributeError; 982 break; 983 default: 984 type = PyExc_RuntimeError; 985 } 986 return type; 987 } 988 989 990 SWIGRUNTIME void 991 SWIG_Python_AddErrorMsg(const char* mesg) 992 { 993 PyObject *type = 0; 994 PyObject *value = 0; 995 PyObject *traceback = 0; 996 997 if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); 998 if (value) { 999 char *tmp; 1000 PyObject *old_str = PyObject_Str(value); 1001 PyErr_Clear(); 1002 Py_XINCREF(type); 1003 1004 PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); 1005 SWIG_Python_str_DelForPy3(tmp); 1006 Py_DECREF(old_str); 1007 Py_DECREF(value); 1008 } else { 1009 PyErr_SetString(PyExc_RuntimeError, mesg); 1010 } 1011 } 1012 1013 #if defined(SWIG_PYTHON_NO_THREADS) 1014 # if defined(SWIG_PYTHON_THREADS) 1015 # undef SWIG_PYTHON_THREADS 1016 # endif 1017 #endif 1018 #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ 1019 # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) 1020 # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ 1021 # define SWIG_PYTHON_USE_GIL 1022 # endif 1023 # endif 1024 # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ 1025 # ifndef SWIG_PYTHON_INITIALIZE_THREADS 1026 # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() 1027 # endif 1028 # ifdef __cplusplus /* C++ code */ 1029 class SWIG_Python_Thread_Block { 1030 bool status; 1031 PyGILState_STATE state; 1032 public: 1033 void end() { if (status) { PyGILState_Release(state); status = false;} } 1034 SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} 1035 ~SWIG_Python_Thread_Block() { end(); } 1036 }; 1037 class SWIG_Python_Thread_Allow { 1038 bool status; 1039 PyThreadState *save; 1040 public: 1041 void end() { if (status) { PyEval_RestoreThread(save); status = false; }} 1042 SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} 1043 ~SWIG_Python_Thread_Allow() { end(); } 1044 }; 1045 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block 1046 # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() 1047 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow 1048 # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() 1049 # else /* C code */ 1050 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() 1051 # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) 1052 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() 1053 # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) 1054 # endif 1055 # else /* Old thread way, not implemented, user must provide it */ 1056 # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) 1057 # define SWIG_PYTHON_INITIALIZE_THREADS 1058 # endif 1059 # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) 1060 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK 1061 # endif 1062 # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) 1063 # define SWIG_PYTHON_THREAD_END_BLOCK 1064 # endif 1065 # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) 1066 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW 1067 # endif 1068 # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) 1069 # define SWIG_PYTHON_THREAD_END_ALLOW 1070 # endif 1071 # endif 1072 #else /* No thread support */ 1073 # define SWIG_PYTHON_INITIALIZE_THREADS 1074 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK 1075 # define SWIG_PYTHON_THREAD_END_BLOCK 1076 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW 1077 # define SWIG_PYTHON_THREAD_END_ALLOW 1078 #endif 1079 1080 /* ----------------------------------------------------------------------------- 1081 * Python API portion that goes into the runtime 1082 * ----------------------------------------------------------------------------- */ 1083 1084 #ifdef __cplusplus 1085 extern "C" { 1086 #endif 1087 1088 /* ----------------------------------------------------------------------------- 1089 * Constant declarations 1090 * ----------------------------------------------------------------------------- */ 1091 1092 /* Constant Types */ 1093 #define SWIG_PY_POINTER 4 1094 #define SWIG_PY_BINARY 5 1095 1096 /* Constant information structure */ 1097 typedef struct swig_const_info { 1098 int type; 1099 char *name; 1100 long lvalue; 1101 double dvalue; 1102 void *pvalue; 1103 swig_type_info **ptype; 1104 } swig_const_info; 1105 1106 1107 /* ----------------------------------------------------------------------------- 1108 * Wrapper of PyInstanceMethod_New() used in Python 3 1109 * It is exported to the generated module, used for -fastproxy 1110 * ----------------------------------------------------------------------------- */ 1111 #if PY_VERSION_HEX >= 0x03000000 1112 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) 1113 { 1114 return PyInstanceMethod_New(func); 1115 } 1116 #else 1117 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) 1118 { 1119 return NULL; 1120 } 1121 #endif 1122 1123 #ifdef __cplusplus 1124 } 1125 #endif 1126 1127 1128 /* ----------------------------------------------------------------------------- 1129 * pyrun.swg 1130 * 1131 * This file contains the runtime support for Python modules 1132 * and includes code for managing global variables and pointer 1133 * type checking. 1134 * 1135 * ----------------------------------------------------------------------------- */ 1136 1137 /* Common SWIG API */ 1138 1139 /* for raw pointers */ 1140 #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) 1141 #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) 1142 #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) 1143 1144 #ifdef SWIGPYTHON_BUILTIN 1145 #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) 1146 #else 1147 #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 1148 #endif 1149 1150 #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 1151 1152 #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) 1153 #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) 1154 #define swig_owntype int 1155 1156 /* for raw packed data */ 1157 #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 1158 #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 1159 1160 /* for class or struct pointers */ 1161 #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) 1162 #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) 1163 1164 /* for C or C++ function pointers */ 1165 #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) 1166 #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) 1167 1168 /* for C++ member pointers, ie, member methods */ 1169 #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 1170 #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 1171 1172 1173 /* Runtime API */ 1174 1175 #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) 1176 #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) 1177 #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) 1178 1179 #define SWIG_SetErrorObj SWIG_Python_SetErrorObj 1180 #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg 1181 #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) 1182 #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 1183 #define SWIG_fail goto fail 1184 1185 1186 /* Runtime API implementation */ 1187 1188 /* Error manipulation */ 1189 1190 SWIGINTERN void 1191 SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { 1192 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 1193 PyErr_SetObject(errtype, obj); 1194 Py_DECREF(obj); 1195 SWIG_PYTHON_THREAD_END_BLOCK; 1196 } 1197 1198 SWIGINTERN void 1199 SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { 1200 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 1201 PyErr_SetString(errtype, msg); 1202 SWIG_PYTHON_THREAD_END_BLOCK; 1203 } 1204 1205 #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) 1206 1207 /* Set a constant value */ 1208 1209 #if defined(SWIGPYTHON_BUILTIN) 1210 1211 SWIGINTERN void 1212 SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { 1213 PyObject *s = PyString_InternFromString(key); 1214 PyList_Append(seq, s); 1215 Py_DECREF(s); 1216 } 1217 1218 SWIGINTERN void 1219 SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { 1220 #if PY_VERSION_HEX < 0x02030000 1221 PyDict_SetItemString(d, (char *)name, obj); 1222 #else 1223 PyDict_SetItemString(d, name, obj); 1224 #endif 1225 Py_DECREF(obj); 1226 if (public_interface) 1227 SwigPyBuiltin_AddPublicSymbol(public_interface, name); 1228 } 1229 1230 #else 1231 1232 SWIGINTERN void 1233 SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { 1234 #if PY_VERSION_HEX < 0x02030000 1235 PyDict_SetItemString(d, (char *)name, obj); 1236 #else 1237 PyDict_SetItemString(d, name, obj); 1238 #endif 1239 Py_DECREF(obj); 1240 } 1241 1242 #endif 1243 1244 /* Append a value to the result obj */ 1245 1246 SWIGINTERN PyObject* 1247 SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { 1248 #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) 1249 if (!result) { 1250 result = obj; 1251 } else if (result == Py_None) { 1252 Py_DECREF(result); 1253 result = obj; 1254 } else { 1255 if (!PyList_Check(result)) { 1256 PyObject *o2 = result; 1257 result = PyList_New(1); 1258 PyList_SetItem(result, 0, o2); 1259 } 1260 PyList_Append(result,obj); 1261 Py_DECREF(obj); 1262 } 1263 return result; 1264 #else 1265 PyObject* o2; 1266 PyObject* o3; 1267 if (!result) { 1268 result = obj; 1269 } else if (result == Py_None) { 1270 Py_DECREF(result); 1271 result = obj; 1272 } else { 1273 if (!PyTuple_Check(result)) { 1274 o2 = result; 1275 result = PyTuple_New(1); 1276 PyTuple_SET_ITEM(result, 0, o2); 1277 } 1278 o3 = PyTuple_New(1); 1279 PyTuple_SET_ITEM(o3, 0, obj); 1280 o2 = result; 1281 result = PySequence_Concat(o2, o3); 1282 Py_DECREF(o2); 1283 Py_DECREF(o3); 1284 } 1285 return result; 1286 #endif 1287 } 1288 1289 /* Unpack the argument tuple */ 1290 1291 SWIGINTERN int 1292 SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) 1293 { 1294 if (!args) { 1295 if (!min && !max) { 1296 return 1; 1297 } else { 1298 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 1299 name, (min == max ? "" : "at least "), (int)min); 1300 return 0; 1301 } 1302 } 1303 if (!PyTuple_Check(args)) { 1304 if (min <= 1 && max >= 1) { 1305 register int i; 1306 objs[0] = args; 1307 for (i = 1; i < max; ++i) { 1308 objs[i] = 0; 1309 } 1310 return 2; 1311 } 1312 PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); 1313 return 0; 1314 } else { 1315 register Py_ssize_t l = PyTuple_GET_SIZE(args); 1316 if (l < min) { 1317 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 1318 name, (min == max ? "" : "at least "), (int)min, (int)l); 1319 return 0; 1320 } else if (l > max) { 1321 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 1322 name, (min == max ? "" : "at most "), (int)max, (int)l); 1323 return 0; 1324 } else { 1325 register int i; 1326 for (i = 0; i < l; ++i) { 1327 objs[i] = PyTuple_GET_ITEM(args, i); 1328 } 1329 for (; l < max; ++l) { 1330 objs[l] = 0; 1331 } 1332 return i + 1; 1333 } 1334 } 1335 } 1336 1337 /* A functor is a function object with one single object argument */ 1338 #if PY_VERSION_HEX >= 0x02020000 1339 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); 1340 #else 1341 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); 1342 #endif 1343 1344 /* 1345 Helper for static pointer initialization for both C and C++ code, for example 1346 static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); 1347 */ 1348 #ifdef __cplusplus 1349 #define SWIG_STATIC_POINTER(var) var 1350 #else 1351 #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var 1352 #endif 1353 1354 /* ----------------------------------------------------------------------------- 1355 * Pointer declarations 1356 * ----------------------------------------------------------------------------- */ 1357 1358 /* Flags for new pointer objects */ 1359 #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) 1360 #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) 1361 1362 #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) 1363 1364 #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) 1365 #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) 1366 1367 #ifdef __cplusplus 1368 extern "C" { 1369 #endif 1370 1371 /* How to access Py_None */ 1372 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 1373 # ifndef SWIG_PYTHON_NO_BUILD_NONE 1374 # ifndef SWIG_PYTHON_BUILD_NONE 1375 # define SWIG_PYTHON_BUILD_NONE 1376 # endif 1377 # endif 1378 #endif 1379 1380 #ifdef SWIG_PYTHON_BUILD_NONE 1381 # ifdef Py_None 1382 # undef Py_None 1383 # define Py_None SWIG_Py_None() 1384 # endif 1385 SWIGRUNTIMEINLINE PyObject * 1386 _SWIG_Py_None(void) 1387 { 1388 PyObject *none = Py_BuildValue((char*)""); 1389 Py_DECREF(none); 1390 return none; 1391 } 1392 SWIGRUNTIME PyObject * 1393 SWIG_Py_None(void) 1394 { 1395 static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); 1396 return none; 1397 } 1398 #endif 1399 1400 /* The python void return value */ 1401 1402 SWIGRUNTIMEINLINE PyObject * 1403 SWIG_Py_Void(void) 1404 { 1405 PyObject *none = Py_None; 1406 Py_INCREF(none); 1407 return none; 1408 } 1409 1410 /* SwigPyClientData */ 1411 1412 typedef struct { 1413 PyObject *klass; 1414 PyObject *newraw; 1415 PyObject *newargs; 1416 PyObject *destroy; 1417 int delargs; 1418 int implicitconv; 1419 PyTypeObject *pytype; 1420 } SwigPyClientData; 1421 1422 SWIGRUNTIMEINLINE int 1423 SWIG_Python_CheckImplicit(swig_type_info *ty) 1424 { 1425 SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; 1426 return data ? data->implicitconv : 0; 1427 } 1428 1429 SWIGRUNTIMEINLINE PyObject * 1430 SWIG_Python_ExceptionType(swig_type_info *desc) { 1431 SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; 1432 PyObject *klass = data ? data->klass : 0; 1433 return (klass ? klass : PyExc_RuntimeError); 1434 } 1435 1436 1437 SWIGRUNTIME SwigPyClientData * 1438 SwigPyClientData_New(PyObject* obj) 1439 { 1440 if (!obj) { 1441 return 0; 1442 } else { 1443 SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); 1444 /* the klass element */ 1445 data->klass = obj; 1446 Py_INCREF(data->klass); 1447 /* the newraw method and newargs arguments used to create a new raw instance */ 1448 if (PyClass_Check(obj)) { 1449 data->newraw = 0; 1450 data->newargs = obj; 1451 Py_INCREF(obj); 1452 } else { 1453 #if (PY_VERSION_HEX < 0x02020000) 1454 data->newraw = 0; 1455 #else 1456 data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); 1457 #endif 1458 if (data->newraw) { 1459 Py_INCREF(data->newraw); 1460 data->newargs = PyTuple_New(1); 1461 PyTuple_SetItem(data->newargs, 0, obj); 1462 } else { 1463 data->newargs = obj; 1464 } 1465 Py_INCREF(data->newargs); 1466 } 1467 /* the destroy method, aka as the C++ delete method */ 1468 data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); 1469 if (PyErr_Occurred()) { 1470 PyErr_Clear(); 1471 data->destroy = 0; 1472 } 1473 if (data->destroy) { 1474 int flags; 1475 Py_INCREF(data->destroy); 1476 flags = PyCFunction_GET_FLAGS(data->destroy); 1477 #ifdef METH_O 1478 data->delargs = !(flags & (METH_O)); 1479 #else 1480 data->delargs = 0; 1481 #endif 1482 } else { 1483 data->delargs = 0; 1484 } 1485 data->implicitconv = 0; 1486 data->pytype = 0; 1487 return data; 1488 } 1489 } 1490 1491 SWIGRUNTIME void 1492 SwigPyClientData_Del(SwigPyClientData *data) { 1493 Py_XDECREF(data->newraw); 1494 Py_XDECREF(data->newargs); 1495 Py_XDECREF(data->destroy); 1496 } 1497 1498 /* =============== SwigPyObject =====================*/ 1499 1500 typedef struct { 1501 PyObject_HEAD 1502 void *ptr; 1503 swig_type_info *ty; 1504 int own; 1505 PyObject *next; 1506 #ifdef SWIGPYTHON_BUILTIN 1507 PyObject *dict; 1508 #endif 1509 } SwigPyObject; 1510 1511 SWIGRUNTIME PyObject * 1512 SwigPyObject_long(SwigPyObject *v) 1513 { 1514 return PyLong_FromVoidPtr(v->ptr); 1515 } 1516 1517 SWIGRUNTIME PyObject * 1518 SwigPyObject_format(const char* fmt, SwigPyObject *v) 1519 { 1520 PyObject *res = NULL; 1521 PyObject *args = PyTuple_New(1); 1522 if (args) { 1523 if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { 1524 PyObject *ofmt = SWIG_Python_str_FromChar(fmt); 1525 if (ofmt) { 1526 #if PY_VERSION_HEX >= 0x03000000 1527 res = PyUnicode_Format(ofmt,args); 1528 #else 1529 res = PyString_Format(ofmt,args); 1530 #endif 1531 Py_DECREF(ofmt); 1532 } 1533 Py_DECREF(args); 1534 } 1535 } 1536 return res; 1537 } 1538 1539 SWIGRUNTIME PyObject * 1540 SwigPyObject_oct(SwigPyObject *v) 1541 { 1542 return SwigPyObject_format("%o",v); 1543 } 1544 1545 SWIGRUNTIME PyObject * 1546 SwigPyObject_hex(SwigPyObject *v) 1547 { 1548 return SwigPyObject_format("%x",v); 1549 } 1550 1551 SWIGRUNTIME PyObject * 1552 #ifdef METH_NOARGS 1553 SwigPyObject_repr(SwigPyObject *v) 1554 #else 1555 SwigPyObject_repr(SwigPyObject *v, PyObject *args) 1556 #endif 1557 { 1558 const char *name = SWIG_TypePrettyName(v->ty); 1559 PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); 1560 if (v->next) { 1561 # ifdef METH_NOARGS 1562 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); 1563 # else 1564 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); 1565 # endif 1566 # if PY_VERSION_HEX >= 0x03000000 1567 PyObject *joined = PyUnicode_Concat(repr, nrep); 1568 Py_DecRef(repr); 1569 Py_DecRef(nrep); 1570 repr = joined; 1571 # else 1572 PyString_ConcatAndDel(&repr,nrep); 1573 # endif 1574 } 1575 return repr; 1576 } 1577 1578 SWIGRUNTIME int 1579 SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) 1580 { 1581 void *i = v->ptr; 1582 void *j = w->ptr; 1583 return (i < j) ? -1 : ((i > j) ? 1 : 0); 1584 } 1585 1586 /* Added for Python 3.x, would it also be useful for Python 2.x? */ 1587 SWIGRUNTIME PyObject* 1588 SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) 1589 { 1590 PyObject* res; 1591 if( op != Py_EQ && op != Py_NE ) { 1592 Py_INCREF(Py_NotImplemented); 1593 return Py_NotImplemented; 1594 } 1595 res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); 1596 return res; 1597 } 1598 1599 1600 SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); 1601 1602 #ifdef SWIGPYTHON_BUILTIN 1603 static swig_type_info *SwigPyObject_stype = 0; 1604 SWIGRUNTIME PyTypeObject* 1605 SwigPyObject_type(void) { 1606 SwigPyClientData *cd; 1607 assert(SwigPyObject_stype); 1608 cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; 1609 assert(cd); 1610 assert(cd->pytype); 1611 return cd->pytype; 1612 } 1613 #else 1614 SWIGRUNTIME PyTypeObject* 1615 SwigPyObject_type(void) { 1616 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); 1617 return type; 1618 } 1619 #endif 1620 1621 SWIGRUNTIMEINLINE int 1622 SwigPyObject_Check(PyObject *op) { 1623 #ifdef SWIGPYTHON_BUILTIN 1624 PyTypeObject *target_tp = SwigPyObject_type(); 1625 if (PyType_IsSubtype(op->ob_type, target_tp)) 1626 return 1; 1627 return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); 1628 #else 1629 return (Py_TYPE(op) == SwigPyObject_type()) 1630 || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); 1631 #endif 1632 } 1633 1634 SWIGRUNTIME PyObject * 1635 SwigPyObject_New(void *ptr, swig_type_info *ty, int own); 1636 1637 SWIGRUNTIME void 1638 SwigPyObject_dealloc(PyObject *v) 1639 { 1640 SwigPyObject *sobj = (SwigPyObject *) v; 1641 PyObject *next = sobj->next; 1642 if (sobj->own == SWIG_POINTER_OWN) { 1643 swig_type_info *ty = sobj->ty; 1644 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 1645 PyObject *destroy = data ? data->destroy : 0; 1646 if (destroy) { 1647 /* destroy is always a VARARGS method */ 1648 PyObject *res; 1649 if (data->delargs) { 1650 /* we need to create a temporary object to carry the destroy operation */ 1651 PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); 1652 res = SWIG_Python_CallFunctor(destroy, tmp); 1653 Py_DECREF(tmp); 1654 } else { 1655 PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); 1656 PyObject *mself = PyCFunction_GET_SELF(destroy); 1657 res = ((*meth)(mself, v)); 1658 } 1659 Py_XDECREF(res); 1660 } 1661 #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) 1662 else { 1663 const char *name = SWIG_TypePrettyName(ty); 1664 printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); 1665 } 1666 #endif 1667 } 1668 Py_XDECREF(next); 1669 PyObject_DEL(v); 1670 } 1671 1672 SWIGRUNTIME PyObject* 1673 SwigPyObject_append(PyObject* v, PyObject* next) 1674 { 1675 SwigPyObject *sobj = (SwigPyObject *) v; 1676 #ifndef METH_O 1677 PyObject *tmp = 0; 1678 if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; 1679 next = tmp; 1680 #endif 1681 if (!SwigPyObject_Check(next)) { 1682 return NULL; 1683 } 1684 sobj->next = next; 1685 Py_INCREF(next); 1686 return SWIG_Py_Void(); 1687 } 1688 1689 SWIGRUNTIME PyObject* 1690 #ifdef METH_NOARGS 1691 SwigPyObject_next(PyObject* v) 1692 #else 1693 SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1694 #endif 1695 { 1696 SwigPyObject *sobj = (SwigPyObject *) v; 1697 if (sobj->next) { 1698 Py_INCREF(sobj->next); 1699 return sobj->next; 1700 } else { 1701 return SWIG_Py_Void(); 1702 } 1703 } 1704 1705 SWIGINTERN PyObject* 1706 #ifdef METH_NOARGS 1707 SwigPyObject_disown(PyObject *v) 1708 #else 1709 SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1710 #endif 1711 { 1712 SwigPyObject *sobj = (SwigPyObject *)v; 1713 sobj->own = 0; 1714 return SWIG_Py_Void(); 1715 } 1716 1717 SWIGINTERN PyObject* 1718 #ifdef METH_NOARGS 1719 SwigPyObject_acquire(PyObject *v) 1720 #else 1721 SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1722 #endif 1723 { 1724 SwigPyObject *sobj = (SwigPyObject *)v; 1725 sobj->own = SWIG_POINTER_OWN; 1726 return SWIG_Py_Void(); 1727 } 1728 1729 SWIGINTERN PyObject* 1730 SwigPyObject_own(PyObject *v, PyObject *args) 1731 { 1732 PyObject *val = 0; 1733 #if (PY_VERSION_HEX < 0x02020000) 1734 if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) 1735 #elif (PY_VERSION_HEX < 0x02050000) 1736 if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 1737 #else 1738 if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) 1739 #endif 1740 { 1741 return NULL; 1742 } 1743 else 1744 { 1745 SwigPyObject *sobj = (SwigPyObject *)v; 1746 PyObject *obj = PyBool_FromLong(sobj->own); 1747 if (val) { 1748 #ifdef METH_NOARGS 1749 if (PyObject_IsTrue(val)) { 1750 SwigPyObject_acquire(v); 1751 } else { 1752 SwigPyObject_disown(v); 1753 } 1754 #else 1755 if (PyObject_IsTrue(val)) { 1756 SwigPyObject_acquire(v,args); 1757 } else { 1758 SwigPyObject_disown(v,args); 1759 } 1760 #endif 1761 } 1762 return obj; 1763 } 1764 } 1765 1766 #ifdef METH_O 1767 static PyMethodDef 1768 swigobject_methods[] = { 1769 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, 1770 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, 1771 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1772 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, 1773 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, 1774 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, 1775 {0, 0, 0, 0} 1776 }; 1777 #else 1778 static PyMethodDef 1779 swigobject_methods[] = { 1780 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, 1781 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, 1782 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1783 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, 1784 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, 1785 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, 1786 {0, 0, 0, 0} 1787 }; 1788 #endif 1789 1790 #if PY_VERSION_HEX < 0x02020000 1791 SWIGINTERN PyObject * 1792 SwigPyObject_getattr(SwigPyObject *sobj,char *name) 1793 { 1794 return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); 1795 } 1796 #endif 1797 1798 SWIGRUNTIME PyTypeObject* 1799 SwigPyObject_TypeOnce(void) { 1800 static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; 1801 1802 static PyNumberMethods SwigPyObject_as_number = { 1803 (binaryfunc)0, /*nb_add*/ 1804 (binaryfunc)0, /*nb_subtract*/ 1805 (binaryfunc)0, /*nb_multiply*/ 1806 /* nb_divide removed in Python 3 */ 1807 #if PY_VERSION_HEX < 0x03000000 1808 (binaryfunc)0, /*nb_divide*/ 1809 #endif 1810 (binaryfunc)0, /*nb_remainder*/ 1811 (binaryfunc)0, /*nb_divmod*/ 1812 (ternaryfunc)0,/*nb_power*/ 1813 (unaryfunc)0, /*nb_negative*/ 1814 (unaryfunc)0, /*nb_positive*/ 1815 (unaryfunc)0, /*nb_absolute*/ 1816 (inquiry)0, /*nb_nonzero*/ 1817 0, /*nb_invert*/ 1818 0, /*nb_lshift*/ 1819 0, /*nb_rshift*/ 1820 0, /*nb_and*/ 1821 0, /*nb_xor*/ 1822 0, /*nb_or*/ 1823 #if PY_VERSION_HEX < 0x03000000 1824 0, /*nb_coerce*/ 1825 #endif 1826 (unaryfunc)SwigPyObject_long, /*nb_int*/ 1827 #if PY_VERSION_HEX < 0x03000000 1828 (unaryfunc)SwigPyObject_long, /*nb_long*/ 1829 #else 1830 0, /*nb_reserved*/ 1831 #endif 1832 (unaryfunc)0, /*nb_float*/ 1833 #if PY_VERSION_HEX < 0x03000000 1834 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ 1835 (unaryfunc)SwigPyObject_hex, /*nb_hex*/ 1836 #endif 1837 #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 1838 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ 1839 #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 1840 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ 1841 #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 1842 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 1843 #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 1844 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ 1845 #endif 1846 }; 1847 1848 static PyTypeObject swigpyobject_type; 1849 static int type_init = 0; 1850 if (!type_init) { 1851 const PyTypeObject tmp = { 1852 /* PyObject header changed in Python 3 */ 1853 #if PY_VERSION_HEX >= 0x03000000 1854 PyVarObject_HEAD_INIT(NULL, 0) 1855 #else 1856 PyObject_HEAD_INIT(NULL) 1857 0, /* ob_size */ 1858 #endif 1859 (char *)"SwigPyObject", /* tp_name */ 1860 sizeof(SwigPyObject), /* tp_basicsize */ 1861 0, /* tp_itemsize */ 1862 (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 1863 0, /* tp_print */ 1864 #if PY_VERSION_HEX < 0x02020000 1865 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ 1866 #else 1867 (getattrfunc)0, /* tp_getattr */ 1868 #endif 1869 (setattrfunc)0, /* tp_setattr */ 1870 #if PY_VERSION_HEX >= 0x03000000 1871 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ 1872 #else 1873 (cmpfunc)SwigPyObject_compare, /* tp_compare */ 1874 #endif 1875 (reprfunc)SwigPyObject_repr, /* tp_repr */ 1876 &SwigPyObject_as_number, /* tp_as_number */ 1877 0, /* tp_as_sequence */ 1878 0, /* tp_as_mapping */ 1879 (hashfunc)0, /* tp_hash */ 1880 (ternaryfunc)0, /* tp_call */ 1881 0, /* tp_str */ 1882 PyObject_GenericGetAttr, /* tp_getattro */ 1883 0, /* tp_setattro */ 1884 0, /* tp_as_buffer */ 1885 Py_TPFLAGS_DEFAULT, /* tp_flags */ 1886 swigobject_doc, /* tp_doc */ 1887 0, /* tp_traverse */ 1888 0, /* tp_clear */ 1889 (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 1890 0, /* tp_weaklistoffset */ 1891 #if PY_VERSION_HEX >= 0x02020000 1892 0, /* tp_iter */ 1893 0, /* tp_iternext */ 1894 swigobject_methods, /* tp_methods */ 1895 0, /* tp_members */ 1896 0, /* tp_getset */ 1897 0, /* tp_base */ 1898 0, /* tp_dict */ 1899 0, /* tp_descr_get */ 1900 0, /* tp_descr_set */ 1901 0, /* tp_dictoffset */ 1902 0, /* tp_init */ 1903 0, /* tp_alloc */ 1904 0, /* tp_new */ 1905 0, /* tp_free */ 1906 0, /* tp_is_gc */ 1907 0, /* tp_bases */ 1908 0, /* tp_mro */ 1909 0, /* tp_cache */ 1910 0, /* tp_subclasses */ 1911 0, /* tp_weaklist */ 1912 #endif 1913 #if PY_VERSION_HEX >= 0x02030000 1914 0, /* tp_del */ 1915 #endif 1916 #if PY_VERSION_HEX >= 0x02060000 1917 0, /* tp_version */ 1918 #endif 1919 #ifdef COUNT_ALLOCS 1920 0,0,0,0 /* tp_alloc -> tp_next */ 1921 #endif 1922 }; 1923 swigpyobject_type = tmp; 1924 type_init = 1; 1925 #if PY_VERSION_HEX < 0x02020000 1926 swigpyobject_type.ob_type = &PyType_Type; 1927 #else 1928 if (PyType_Ready(&swigpyobject_type) < 0) 1929 return NULL; 1930 #endif 1931 } 1932 return &swigpyobject_type; 1933 } 1934 1935 SWIGRUNTIME PyObject * 1936 SwigPyObject_New(void *ptr, swig_type_info *ty, int own) 1937 { 1938 SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); 1939 if (sobj) { 1940 sobj->ptr = ptr; 1941 sobj->ty = ty; 1942 sobj->own = own; 1943 sobj->next = 0; 1944 } 1945 return (PyObject *)sobj; 1946 } 1947 1948 /* ----------------------------------------------------------------------------- 1949 * Implements a simple Swig Packed type, and use it instead of string 1950 * ----------------------------------------------------------------------------- */ 1951 1952 typedef struct { 1953 PyObject_HEAD 1954 void *pack; 1955 swig_type_info *ty; 1956 size_t size; 1957 } SwigPyPacked; 1958 1959 SWIGRUNTIME int 1960 SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 1961 { 1962 char result[SWIG_BUFFER_SIZE]; 1963 fputs("<Swig Packed ", fp); 1964 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 1965 fputs("at ", fp); 1966 fputs(result, fp); 1967 } 1968 fputs(v->ty->name,fp); 1969 fputs(">", fp); 1970 return 0; 1971 } 1972 1973 SWIGRUNTIME PyObject * 1974 SwigPyPacked_repr(SwigPyPacked *v) 1975 { 1976 char result[SWIG_BUFFER_SIZE]; 1977 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 1978 return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); 1979 } else { 1980 return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); 1981 } 1982 } 1983 1984 SWIGRUNTIME PyObject * 1985 SwigPyPacked_str(SwigPyPacked *v) 1986 { 1987 char result[SWIG_BUFFER_SIZE]; 1988 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ 1989 return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); 1990 } else { 1991 return SWIG_Python_str_FromChar(v->ty->name); 1992 } 1993 } 1994 1995 SWIGRUNTIME int 1996 SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) 1997 { 1998 size_t i = v->size; 1999 size_t j = w->size; 2000 int s = (i < j) ? -1 : ((i > j) ? 1 : 0); 2001 return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); 2002 } 2003 2004 SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); 2005 2006 SWIGRUNTIME PyTypeObject* 2007 SwigPyPacked_type(void) { 2008 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); 2009 return type; 2010 } 2011 2012 SWIGRUNTIMEINLINE int 2013 SwigPyPacked_Check(PyObject *op) { 2014 return ((op)->ob_type == SwigPyPacked_TypeOnce()) 2015 || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); 2016 } 2017 2018 SWIGRUNTIME void 2019 SwigPyPacked_dealloc(PyObject *v) 2020 { 2021 if (SwigPyPacked_Check(v)) { 2022 SwigPyPacked *sobj = (SwigPyPacked *) v; 2023 free(sobj->pack); 2024 } 2025 PyObject_DEL(v); 2026 } 2027 2028 SWIGRUNTIME PyTypeObject* 2029 SwigPyPacked_TypeOnce(void) { 2030 static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; 2031 static PyTypeObject swigpypacked_type; 2032 static int type_init = 0; 2033 if (!type_init) { 2034 const PyTypeObject tmp = { 2035 /* PyObject header changed in Python 3 */ 2036 #if PY_VERSION_HEX>=0x03000000 2037 PyVarObject_HEAD_INIT(NULL, 0) 2038 #else 2039 PyObject_HEAD_INIT(NULL) 2040 0, /* ob_size */ 2041 #endif 2042 (char *)"SwigPyPacked", /* tp_name */ 2043 sizeof(SwigPyPacked), /* tp_basicsize */ 2044 0, /* tp_itemsize */ 2045 (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ 2046 (printfunc)SwigPyPacked_print, /* tp_print */ 2047 (getattrfunc)0, /* tp_getattr */ 2048 (setattrfunc)0, /* tp_setattr */ 2049 #if PY_VERSION_HEX>=0x03000000 2050 0, /* tp_reserved in 3.0.1 */ 2051 #else 2052 (cmpfunc)SwigPyPacked_compare, /* tp_compare */ 2053 #endif 2054 (reprfunc)SwigPyPacked_repr, /* tp_repr */ 2055 0, /* tp_as_number */ 2056 0, /* tp_as_sequence */ 2057 0, /* tp_as_mapping */ 2058 (hashfunc)0, /* tp_hash */ 2059 (ternaryfunc)0, /* tp_call */ 2060 (reprfunc)SwigPyPacked_str, /* tp_str */ 2061 PyObject_GenericGetAttr, /* tp_getattro */ 2062 0, /* tp_setattro */ 2063 0, /* tp_as_buffer */ 2064 Py_TPFLAGS_DEFAULT, /* tp_flags */ 2065 swigpacked_doc, /* tp_doc */ 2066 0, /* tp_traverse */ 2067 0, /* tp_clear */ 2068 0, /* tp_richcompare */ 2069 0, /* tp_weaklistoffset */ 2070 #if PY_VERSION_HEX >= 0x02020000 2071 0, /* tp_iter */ 2072 0, /* tp_iternext */ 2073 0, /* tp_methods */ 2074 0, /* tp_members */ 2075 0, /* tp_getset */ 2076 0, /* tp_base */ 2077 0, /* tp_dict */ 2078 0, /* tp_descr_get */ 2079 0, /* tp_descr_set */ 2080 0, /* tp_dictoffset */ 2081 0, /* tp_init */ 2082 0, /* tp_alloc */ 2083 0, /* tp_new */ 2084 0, /* tp_free */ 2085 0, /* tp_is_gc */ 2086 0, /* tp_bases */ 2087 0, /* tp_mro */ 2088 0, /* tp_cache */ 2089 0, /* tp_subclasses */ 2090 0, /* tp_weaklist */ 2091 #endif 2092 #if PY_VERSION_HEX >= 0x02030000 2093 0, /* tp_del */ 2094 #endif 2095 #if PY_VERSION_HEX >= 0x02060000 2096 0, /* tp_version */ 2097 #endif 2098 #ifdef COUNT_ALLOCS 2099 0,0,0,0 /* tp_alloc -> tp_next */ 2100 #endif 2101 }; 2102 swigpypacked_type = tmp; 2103 type_init = 1; 2104 #if PY_VERSION_HEX < 0x02020000 2105 swigpypacked_type.ob_type = &PyType_Type; 2106 #else 2107 if (PyType_Ready(&swigpypacked_type) < 0) 2108 return NULL; 2109 #endif 2110 } 2111 return &swigpypacked_type; 2112 } 2113 2114 SWIGRUNTIME PyObject * 2115 SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) 2116 { 2117 SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); 2118 if (sobj) { 2119 void *pack = malloc(size); 2120 if (pack) { 2121 memcpy(pack, ptr, size); 2122 sobj->pack = pack; 2123 sobj->ty = ty; 2124 sobj->size = size; 2125 } else { 2126 PyObject_DEL((PyObject *) sobj); 2127 sobj = 0; 2128 } 2129 } 2130 return (PyObject *) sobj; 2131 } 2132 2133 SWIGRUNTIME swig_type_info * 2134 SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) 2135 { 2136 if (SwigPyPacked_Check(obj)) { 2137 SwigPyPacked *sobj = (SwigPyPacked *)obj; 2138 if (sobj->size != size) return 0; 2139 memcpy(ptr, sobj->pack, size); 2140 return sobj->ty; 2141 } else { 2142 return 0; 2143 } 2144 } 2145 2146 /* ----------------------------------------------------------------------------- 2147 * pointers/data manipulation 2148 * ----------------------------------------------------------------------------- */ 2149 2150 SWIGRUNTIMEINLINE PyObject * 2151 _SWIG_This(void) 2152 { 2153 return SWIG_Python_str_FromChar("this"); 2154 } 2155 2156 static PyObject *swig_this = NULL; 2157 2158 SWIGRUNTIME PyObject * 2159 SWIG_This(void) 2160 { 2161 if (swig_this == NULL) 2162 swig_this = _SWIG_This(); 2163 return swig_this; 2164 } 2165 2166 /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ 2167 2168 /* TODO: I don't know how to implement the fast getset in Python 3 right now */ 2169 #if PY_VERSION_HEX>=0x03000000 2170 #define SWIG_PYTHON_SLOW_GETSET_THIS 2171 #endif 2172 2173 SWIGRUNTIME SwigPyObject * 2174 SWIG_Python_GetSwigThis(PyObject *pyobj) 2175 { 2176 PyObject *obj; 2177 2178 if (SwigPyObject_Check(pyobj)) 2179 return (SwigPyObject *) pyobj; 2180 2181 #ifdef SWIGPYTHON_BUILTIN 2182 (void)obj; 2183 # ifdef PyWeakref_CheckProxy 2184 if (PyWeakref_CheckProxy(pyobj)) { 2185 pyobj = PyWeakref_GET_OBJECT(pyobj); 2186 if (pyobj && SwigPyObject_Check(pyobj)) 2187 return (SwigPyObject*) pyobj; 2188 } 2189 # endif 2190 return NULL; 2191 #else 2192 2193 obj = 0; 2194 2195 #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) 2196 if (PyInstance_Check(pyobj)) { 2197 obj = _PyInstance_Lookup(pyobj, SWIG_This()); 2198 } else { 2199 PyObject **dictptr = _PyObject_GetDictPtr(pyobj); 2200 if (dictptr != NULL) { 2201 PyObject *dict = *dictptr; 2202 obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; 2203 } else { 2204 #ifdef PyWeakref_CheckProxy 2205 if (PyWeakref_CheckProxy(pyobj)) { 2206 PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); 2207 return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; 2208 } 2209 #endif 2210 obj = PyObject_GetAttr(pyobj,SWIG_This()); 2211 if (obj) { 2212 Py_DECREF(obj); 2213 } else { 2214 if (PyErr_Occurred()) PyErr_Clear(); 2215 return 0; 2216 } 2217 } 2218 } 2219 #else 2220 obj = PyObject_GetAttr(pyobj,SWIG_This()); 2221 if (obj) { 2222 Py_DECREF(obj); 2223 } else { 2224 if (PyErr_Occurred()) PyErr_Clear(); 2225 return 0; 2226 } 2227 #endif 2228 if (obj && !SwigPyObject_Check(obj)) { 2229 /* a PyObject is called 'this', try to get the 'real this' 2230 SwigPyObject from it */ 2231 return SWIG_Python_GetSwigThis(obj); 2232 } 2233 return (SwigPyObject *)obj; 2234 #endif 2235 } 2236 2237 /* Acquire a pointer value */ 2238 2239 SWIGRUNTIME int 2240 SWIG_Python_AcquirePtr(PyObject *obj, int own) { 2241 if (own == SWIG_POINTER_OWN) { 2242 SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); 2243 if (sobj) { 2244 int oldown = sobj->own; 2245 sobj->own = own; 2246 return oldown; 2247 } 2248 } 2249 return 0; 2250 } 2251 2252 /* Convert a pointer value */ 2253 2254 SWIGRUNTIME int 2255 SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { 2256 int res; 2257 SwigPyObject *sobj; 2258 int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; 2259 2260 if (!obj) 2261 return SWIG_ERROR; 2262 if (obj == Py_None && !implicit_conv) { 2263 if (ptr) 2264 *ptr = 0; 2265 return SWIG_OK; 2266 } 2267 2268 res = SWIG_ERROR; 2269 2270 sobj = SWIG_Python_GetSwigThis(obj); 2271 if (own) 2272 *own = 0; 2273 while (sobj) { 2274 void *vptr = sobj->ptr; 2275 if (ty) { 2276 swig_type_info *to = sobj->ty; 2277 if (to == ty) { 2278 /* no type cast needed */ 2279 if (ptr) *ptr = vptr; 2280 break; 2281 } else { 2282 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 2283 if (!tc) { 2284 sobj = (SwigPyObject *)sobj->next; 2285 } else { 2286 if (ptr) { 2287 int newmemory = 0; 2288 *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 2289 if (newmemory == SWIG_CAST_NEW_MEMORY) { 2290 assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ 2291 if (own) 2292 *own = *own | SWIG_CAST_NEW_MEMORY; 2293 } 2294 } 2295 break; 2296 } 2297 } 2298 } else { 2299 if (ptr) *ptr = vptr; 2300 break; 2301 } 2302 } 2303 if (sobj) { 2304 if (own) 2305 *own = *own | sobj->own; 2306 if (flags & SWIG_POINTER_DISOWN) { 2307 sobj->own = 0; 2308 } 2309 res = SWIG_OK; 2310 } else { 2311 if (implicit_conv) { 2312 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 2313 if (data && !data->implicitconv) { 2314 PyObject *klass = data->klass; 2315 if (klass) { 2316 PyObject *impconv; 2317 data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ 2318 impconv = SWIG_Python_CallFunctor(klass, obj); 2319 data->implicitconv = 0; 2320 if (PyErr_Occurred()) { 2321 PyErr_Clear(); 2322 impconv = 0; 2323 } 2324 if (impconv) { 2325 SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); 2326 if (iobj) { 2327 void *vptr; 2328 res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); 2329 if (SWIG_IsOK(res)) { 2330 if (ptr) { 2331 *ptr = vptr; 2332 /* transfer the ownership to 'ptr' */ 2333 iobj->own = 0; 2334 res = SWIG_AddCast(res); 2335 res = SWIG_AddNewMask(res); 2336 } else { 2337 res = SWIG_AddCast(res); 2338 } 2339 } 2340 } 2341 Py_DECREF(impconv); 2342 } 2343 } 2344 } 2345 } 2346 if (!SWIG_IsOK(res) && obj == Py_None) { 2347 if (ptr) 2348 *ptr = 0; 2349 if (PyErr_Occurred()) 2350 PyErr_Clear(); 2351 res = SWIG_OK; 2352 } 2353 } 2354 return res; 2355 } 2356 2357 /* Convert a function ptr value */ 2358 2359 SWIGRUNTIME int 2360 SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { 2361 if (!PyCFunction_Check(obj)) { 2362 return SWIG_ConvertPtr(obj, ptr, ty, 0); 2363 } else { 2364 void *vptr = 0; 2365 2366 /* here we get the method pointer for callbacks */ 2367 const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); 2368 const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; 2369 if (desc) 2370 desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; 2371 if (!desc) 2372 return SWIG_ERROR; 2373 if (ty) { 2374 swig_cast_info *tc = SWIG_TypeCheck(desc,ty); 2375 if (tc) { 2376 int newmemory = 0; 2377 *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 2378 assert(!newmemory); /* newmemory handling not yet implemented */ 2379 } else { 2380 return SWIG_ERROR; 2381 } 2382 } else { 2383 *ptr = vptr; 2384 } 2385 return SWIG_OK; 2386 } 2387 } 2388 2389 /* Convert a packed value value */ 2390 2391 SWIGRUNTIME int 2392 SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { 2393 swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); 2394 if (!to) return SWIG_ERROR; 2395 if (ty) { 2396 if (to != ty) { 2397 /* check type cast? */ 2398 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 2399 if (!tc) return SWIG_ERROR; 2400 } 2401 } 2402 return SWIG_OK; 2403 } 2404 2405 /* ----------------------------------------------------------------------------- 2406 * Create a new pointer object 2407 * ----------------------------------------------------------------------------- */ 2408 2409 /* 2410 Create a new instance object, without calling __init__, and set the 2411 'this' attribute. 2412 */ 2413 2414 SWIGRUNTIME PyObject* 2415 SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) 2416 { 2417 #if (PY_VERSION_HEX >= 0x02020000) 2418 PyObject *inst = 0; 2419 PyObject *newraw = data->newraw; 2420 if (newraw) { 2421 inst = PyObject_Call(newraw, data->newargs, NULL); 2422 if (inst) { 2423 #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 2424 PyObject **dictptr = _PyObject_GetDictPtr(inst); 2425 if (dictptr != NULL) { 2426 PyObject *dict = *dictptr; 2427 if (dict == NULL) { 2428 dict = PyDict_New(); 2429 *dictptr = dict; 2430 PyDict_SetItem(dict, SWIG_This(), swig_this); 2431 } 2432 } 2433 #else 2434 PyObject *key = SWIG_This(); 2435 PyObject_SetAttr(inst, key, swig_this); 2436 #endif 2437 } 2438 } else { 2439 #if PY_VERSION_HEX >= 0x03000000 2440 inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); 2441 if (inst) { 2442 PyObject_SetAttr(inst, SWIG_This(), swig_this); 2443 Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; 2444 } 2445 #else 2446 PyObject *dict = PyDict_New(); 2447 if (dict) { 2448 PyDict_SetItem(dict, SWIG_This(), swig_this); 2449 inst = PyInstance_NewRaw(data->newargs, dict); 2450 Py_DECREF(dict); 2451 } 2452 #endif 2453 } 2454 return inst; 2455 #else 2456 #if (PY_VERSION_HEX >= 0x02010000) 2457 PyObject *inst = 0; 2458 PyObject *dict = PyDict_New(); 2459 if (dict) { 2460 PyDict_SetItem(dict, SWIG_This(), swig_this); 2461 inst = PyInstance_NewRaw(data->newargs, dict); 2462 Py_DECREF(dict); 2463 } 2464 return (PyObject *) inst; 2465 #else 2466 PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); 2467 if (inst == NULL) { 2468 return NULL; 2469 } 2470 inst->in_class = (PyClassObject *)data->newargs; 2471 Py_INCREF(inst->in_class); 2472 inst->in_dict = PyDict_New(); 2473 if (inst->in_dict == NULL) { 2474 Py_DECREF(inst); 2475 return NULL; 2476 } 2477 #ifdef Py_TPFLAGS_HAVE_WEAKREFS 2478 inst->in_weakreflist = NULL; 2479 #endif 2480 #ifdef Py_TPFLAGS_GC 2481 PyObject_GC_Init(inst); 2482 #endif 2483 PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); 2484 return (PyObject *) inst; 2485 #endif 2486 #endif 2487 } 2488 2489 SWIGRUNTIME void 2490 SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) 2491 { 2492 PyObject *dict; 2493 #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 2494 PyObject **dictptr = _PyObject_GetDictPtr(inst); 2495 if (dictptr != NULL) { 2496 dict = *dictptr; 2497 if (dict == NULL) { 2498 dict = PyDict_New(); 2499 *dictptr = dict; 2500 } 2501 PyDict_SetItem(dict, SWIG_This(), swig_this); 2502 return; 2503 } 2504 #endif 2505 dict = PyObject_GetAttrString(inst, (char*)"__dict__"); 2506 PyDict_SetItem(dict, SWIG_This(), swig_this); 2507 Py_DECREF(dict); 2508 } 2509 2510 2511 SWIGINTERN PyObject * 2512 SWIG_Python_InitShadowInstance(PyObject *args) { 2513 PyObject *obj[2]; 2514 if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { 2515 return NULL; 2516 } else { 2517 SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); 2518 if (sthis) { 2519 SwigPyObject_append((PyObject*) sthis, obj[1]); 2520 } else { 2521 SWIG_Python_SetSwigThis(obj[0], obj[1]); 2522 } 2523 return SWIG_Py_Void(); 2524 } 2525 } 2526 2527 /* Create a new pointer object */ 2528 2529 SWIGRUNTIME PyObject * 2530 SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { 2531 SwigPyClientData *clientdata; 2532 PyObject * robj; 2533 int own; 2534 2535 if (!ptr) 2536 return SWIG_Py_Void(); 2537 2538 clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; 2539 own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; 2540 if (clientdata && clientdata->pytype) { 2541 SwigPyObject *newobj; 2542 if (flags & SWIG_BUILTIN_TP_INIT) { 2543 newobj = (SwigPyObject*) self; 2544 if (newobj->ptr) { 2545 PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); 2546 while (newobj->next) 2547 newobj = (SwigPyObject *) newobj->next; 2548 newobj->next = next_self; 2549 newobj = (SwigPyObject *)next_self; 2550 } 2551 } else { 2552 newobj = PyObject_New(SwigPyObject, clientdata->pytype); 2553 } 2554 if (newobj) { 2555 newobj->ptr = ptr; 2556 newobj->ty = type; 2557 newobj->own = own; 2558 newobj->next = 0; 2559 #ifdef SWIGPYTHON_BUILTIN 2560 newobj->dict = 0; 2561 #endif 2562 return (PyObject*) newobj; 2563 } 2564 return SWIG_Py_Void(); 2565 } 2566 2567 assert(!(flags & SWIG_BUILTIN_TP_INIT)); 2568 2569 robj = SwigPyObject_New(ptr, type, own); 2570 if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { 2571 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); 2572 Py_DECREF(robj); 2573 robj = inst; 2574 } 2575 return robj; 2576 } 2577 2578 /* Create a new packed object */ 2579 2580 SWIGRUNTIMEINLINE PyObject * 2581 SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { 2582 return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); 2583 } 2584 2585 /* -----------------------------------------------------------------------------* 2586 * Get type list 2587 * -----------------------------------------------------------------------------*/ 2588 2589 #ifdef SWIG_LINK_RUNTIME 2590 void *SWIG_ReturnGlobalTypeList(void *); 2591 #endif 2592 2593 SWIGRUNTIME swig_module_info * 2594 SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { 2595 static void *type_pointer = (void *)0; 2596 /* first check if module already created */ 2597 if (!type_pointer) { 2598 #ifdef SWIG_LINK_RUNTIME 2599 type_pointer = SWIG_ReturnGlobalTypeList((void *)0); 2600 #else 2601 # ifdef SWIGPY_USE_CAPSULE 2602 type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); 2603 # else 2604 type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 2605 (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); 2606 # endif 2607 if (PyErr_Occurred()) { 2608 PyErr_Clear(); 2609 type_pointer = (void *)0; 2610 } 2611 #endif 2612 } 2613 return (swig_module_info *) type_pointer; 2614 } 2615 2616 #if PY_MAJOR_VERSION < 2 2617 /* PyModule_AddObject function was introduced in Python 2.0. The following function 2618 is copied out of Python/modsupport.c in python version 2.3.4 */ 2619 SWIGINTERN int 2620 PyModule_AddObject(PyObject *m, char *name, PyObject *o) 2621 { 2622 PyObject *dict; 2623 if (!PyModule_Check(m)) { 2624 PyErr_SetString(PyExc_TypeError, 2625 "PyModule_AddObject() needs module as first arg"); 2626 return SWIG_ERROR; 2627 } 2628 if (!o) { 2629 PyErr_SetString(PyExc_TypeError, 2630 "PyModule_AddObject() needs non-NULL value"); 2631 return SWIG_ERROR; 2632 } 2633 2634 dict = PyModule_GetDict(m); 2635 if (dict == NULL) { 2636 /* Internal error -- modules must have a dict! */ 2637 PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", 2638 PyModule_GetName(m)); 2639 return SWIG_ERROR; 2640 } 2641 if (PyDict_SetItemString(dict, name, o)) 2642 return SWIG_ERROR; 2643 Py_DECREF(o); 2644 return SWIG_OK; 2645 } 2646 #endif 2647 2648 SWIGRUNTIME void 2649 #ifdef SWIGPY_USE_CAPSULE 2650 SWIG_Python_DestroyModule(PyObject *obj) 2651 #else 2652 SWIG_Python_DestroyModule(void *vptr) 2653 #endif 2654 { 2655 #ifdef SWIGPY_USE_CAPSULE 2656 swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); 2657 #else 2658 swig_module_info *swig_module = (swig_module_info *) vptr; 2659 #endif 2660 swig_type_info **types = swig_module->types; 2661 size_t i; 2662 for (i =0; i < swig_module->size; ++i) { 2663 swig_type_info *ty = types[i]; 2664 if (ty->owndata) { 2665 SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; 2666 if (data) SwigPyClientData_Del(data); 2667 } 2668 } 2669 Py_DECREF(SWIG_This()); 2670 swig_this = NULL; 2671 } 2672 2673 SWIGRUNTIME void 2674 SWIG_Python_SetModule(swig_module_info *swig_module) { 2675 #if PY_VERSION_HEX >= 0x03000000 2676 /* Add a dummy module object into sys.modules */ 2677 PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); 2678 #else 2679 static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ 2680 PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); 2681 #endif 2682 #ifdef SWIGPY_USE_CAPSULE 2683 PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); 2684 if (pointer && module) { 2685 PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); 2686 } else { 2687 Py_XDECREF(pointer); 2688 } 2689 #else 2690 PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); 2691 if (pointer && module) { 2692 PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); 2693 } else { 2694 Py_XDECREF(pointer); 2695 } 2696 #endif 2697 } 2698 2699 /* The python cached type query */ 2700 SWIGRUNTIME PyObject * 2701 SWIG_Python_TypeCache(void) { 2702 static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); 2703 return cache; 2704 } 2705 2706 SWIGRUNTIME swig_type_info * 2707 SWIG_Python_TypeQuery(const char *type) 2708 { 2709 PyObject *cache = SWIG_Python_TypeCache(); 2710 PyObject *key = SWIG_Python_str_FromChar(type); 2711 PyObject *obj = PyDict_GetItem(cache, key); 2712 swig_type_info *descriptor; 2713 if (obj) { 2714 #ifdef SWIGPY_USE_CAPSULE 2715 descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); 2716 #else 2717 descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); 2718 #endif 2719 } else { 2720 swig_module_info *swig_module = SWIG_GetModule(0); 2721 descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); 2722 if (descriptor) { 2723 #ifdef SWIGPY_USE_CAPSULE 2724 obj = PyCapsule_New((void*) descriptor, NULL, NULL); 2725 #else 2726 obj = PyCObject_FromVoidPtr(descriptor, NULL); 2727 #endif 2728 PyDict_SetItem(cache, key, obj); 2729 Py_DECREF(obj); 2730 } 2731 } 2732 Py_DECREF(key); 2733 return descriptor; 2734 } 2735 2736 /* 2737 For backward compatibility only 2738 */ 2739 #define SWIG_POINTER_EXCEPTION 0 2740 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) 2741 #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) 2742 2743 SWIGRUNTIME int 2744 SWIG_Python_AddErrMesg(const char* mesg, int infront) 2745 { 2746 if (PyErr_Occurred()) { 2747 PyObject *type = 0; 2748 PyObject *value = 0; 2749 PyObject *traceback = 0; 2750 PyErr_Fetch(&type, &value, &traceback); 2751 if (value) { 2752 char *tmp; 2753 PyObject *old_str = PyObject_Str(value); 2754 Py_XINCREF(type); 2755 PyErr_Clear(); 2756 if (infront) { 2757 PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); 2758 } else { 2759 PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); 2760 } 2761 SWIG_Python_str_DelForPy3(tmp); 2762 Py_DECREF(old_str); 2763 } 2764 return 1; 2765 } else { 2766 return 0; 2767 } 2768 } 2769 2770 SWIGRUNTIME int 2771 SWIG_Python_ArgFail(int argnum) 2772 { 2773 if (PyErr_Occurred()) { 2774 /* add information about failing argument */ 2775 char mesg[256]; 2776 PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); 2777 return SWIG_Python_AddErrMesg(mesg, 1); 2778 } else { 2779 return 0; 2780 } 2781 } 2782 2783 SWIGRUNTIMEINLINE const char * 2784 SwigPyObject_GetDesc(PyObject *self) 2785 { 2786 SwigPyObject *v = (SwigPyObject *)self; 2787 swig_type_info *ty = v ? v->ty : 0; 2788 return ty ? ty->str : ""; 2789 } 2790 2791 SWIGRUNTIME void 2792 SWIG_Python_TypeError(const char *type, PyObject *obj) 2793 { 2794 if (type) { 2795 #if defined(SWIG_COBJECT_TYPES) 2796 if (obj && SwigPyObject_Check(obj)) { 2797 const char *otype = (const char *) SwigPyObject_GetDesc(obj); 2798 if (otype) { 2799 PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", 2800 type, otype); 2801 return; 2802 } 2803 } else 2804 #endif 2805 { 2806 const char *otype = (obj ? obj->ob_type->tp_name : 0); 2807 if (otype) { 2808 PyObject *str = PyObject_Str(obj); 2809 const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; 2810 if (cstr) { 2811 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", 2812 type, otype, cstr); 2813 SWIG_Python_str_DelForPy3(cstr); 2814 } else { 2815 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", 2816 type, otype); 2817 } 2818 Py_XDECREF(str); 2819 return; 2820 } 2821 } 2822 PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); 2823 } else { 2824 PyErr_Format(PyExc_TypeError, "unexpected type is received"); 2825 } 2826 } 2827 2828 2829 /* Convert a pointer value, signal an exception on a type mismatch */ 2830 SWIGRUNTIME void * 2831 SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { 2832 void *result; 2833 if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { 2834 PyErr_Clear(); 2835 #if SWIG_POINTER_EXCEPTION 2836 if (flags) { 2837 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); 2838 SWIG_Python_ArgFail(argnum); 2839 } 2840 #endif 2841 } 2842 return result; 2843 } 2844 2845 #ifdef SWIGPYTHON_BUILTIN 2846 SWIGRUNTIME int 2847 SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { 2848 PyTypeObject *tp = obj->ob_type; 2849 PyObject *descr; 2850 PyObject *encoded_name; 2851 descrsetfunc f; 2852 int res = -1; 2853 2854 # ifdef Py_USING_UNICODE 2855 if (PyString_Check(name)) { 2856 name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); 2857 if (!name) 2858 return -1; 2859 } else if (!PyUnicode_Check(name)) 2860 # else 2861 if (!PyString_Check(name)) 2862 # endif 2863 { 2864 PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); 2865 return -1; 2866 } else { 2867 Py_INCREF(name); 2868 } 2869 2870 if (!tp->tp_dict) { 2871 if (PyType_Ready(tp) < 0) 2872 goto done; 2873 } 2874 2875 descr = _PyType_Lookup(tp, name); 2876 f = NULL; 2877 if (descr != NULL) 2878 f = descr->ob_type->tp_descr_set; 2879 if (!f) { 2880 if (PyString_Check(name)) { 2881 encoded_name = name; 2882 Py_INCREF(name); 2883 } else { 2884 encoded_name = PyUnicode_AsUTF8String(name); 2885 } 2886 PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); 2887 Py_DECREF(encoded_name); 2888 } else { 2889 res = f(descr, obj, value); 2890 } 2891 2892 done: 2893 Py_DECREF(name); 2894 return res; 2895 } 2896 #endif 2897 2898 2899 #ifdef __cplusplus 2900 } 2901 #endif 2902 2903 2904 2905 #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 2906 2907 #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 2908 2909 2910 2911 #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 2912 2913 2914 /* -------- TYPES TABLE (BEGIN) -------- */ 2915 2916 #define SWIGTYPE_p_char swig_types[0] 2917 #define SWIGTYPE_p_int swig_types[1] 2918 #define SWIGTYPE_p_long_long swig_types[2] 2919 #define SWIGTYPE_p_qpol_avrule swig_types[3] 2920 #define SWIGTYPE_p_qpol_bool swig_types[4] 2921 #define SWIGTYPE_p_qpol_capability swig_types[5] 2922 #define SWIGTYPE_p_qpol_cat swig_types[6] 2923 #define SWIGTYPE_p_qpol_class swig_types[7] 2924 #define SWIGTYPE_p_qpol_common swig_types[8] 2925 #define SWIGTYPE_p_qpol_cond swig_types[9] 2926 #define SWIGTYPE_p_qpol_cond_expr_node swig_types[10] 2927 #define SWIGTYPE_p_qpol_constraint swig_types[11] 2928 #define SWIGTYPE_p_qpol_constraint_expr_node swig_types[12] 2929 #define SWIGTYPE_p_qpol_context swig_types[13] 2930 #define SWIGTYPE_p_qpol_default_object swig_types[14] 2931 #define SWIGTYPE_p_qpol_devicetreecon swig_types[15] 2932 #define SWIGTYPE_p_qpol_filename_trans swig_types[16] 2933 #define SWIGTYPE_p_qpol_fs_use swig_types[17] 2934 #define SWIGTYPE_p_qpol_genfscon swig_types[18] 2935 #define SWIGTYPE_p_qpol_iomemcon swig_types[19] 2936 #define SWIGTYPE_p_qpol_ioportcon swig_types[20] 2937 #define SWIGTYPE_p_qpol_isid swig_types[21] 2938 #define SWIGTYPE_p_qpol_iterator swig_types[22] 2939 #define SWIGTYPE_p_qpol_level swig_types[23] 2940 #define SWIGTYPE_p_qpol_mls_level swig_types[24] 2941 #define SWIGTYPE_p_qpol_mls_range swig_types[25] 2942 #define SWIGTYPE_p_qpol_netifcon swig_types[26] 2943 #define SWIGTYPE_p_qpol_nodecon swig_types[27] 2944 #define SWIGTYPE_p_qpol_pcidevicecon swig_types[28] 2945 #define SWIGTYPE_p_qpol_pirqcon swig_types[29] 2946 #define SWIGTYPE_p_qpol_polcap swig_types[30] 2947 #define SWIGTYPE_p_qpol_policy swig_types[31] 2948 #define SWIGTYPE_p_qpol_portcon swig_types[32] 2949 #define SWIGTYPE_p_qpol_range_trans swig_types[33] 2950 #define SWIGTYPE_p_qpol_role swig_types[34] 2951 #define SWIGTYPE_p_qpol_role_allow swig_types[35] 2952 #define SWIGTYPE_p_qpol_role_trans swig_types[36] 2953 #define SWIGTYPE_p_qpol_rolebounds swig_types[37] 2954 #define SWIGTYPE_p_qpol_semantic_level swig_types[38] 2955 #define SWIGTYPE_p_qpol_terule swig_types[39] 2956 #define SWIGTYPE_p_qpol_type swig_types[40] 2957 #define SWIGTYPE_p_qpol_typebounds swig_types[41] 2958 #define SWIGTYPE_p_qpol_user swig_types[42] 2959 #define SWIGTYPE_p_qpol_userbounds swig_types[43] 2960 #define SWIGTYPE_p_qpol_validatetrans swig_types[44] 2961 #define SWIGTYPE_p_short swig_types[45] 2962 #define SWIGTYPE_p_signed_char swig_types[46] 2963 #define SWIGTYPE_p_unsigned_char swig_types[47] 2964 #define SWIGTYPE_p_unsigned_int swig_types[48] 2965 #define SWIGTYPE_p_unsigned_long_long swig_types[49] 2966 #define SWIGTYPE_p_unsigned_short swig_types[50] 2967 #define SWIGTYPE_p_void swig_types[51] 2968 static swig_type_info *swig_types[53]; 2969 static swig_module_info swig_module = {swig_types, 52, 0, 0, 0, 0}; 2970 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) 2971 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) 2972 2973 /* -------- TYPES TABLE (END) -------- */ 2974 2975 #if (PY_VERSION_HEX <= 0x02000000) 2976 # if !defined(SWIG_PYTHON_CLASSIC) 2977 # error "This python version requires swig to be run with the '-classic' option" 2978 # endif 2979 #endif 2980 2981 /*----------------------------------------------- 2982 @(target):= _qpol.so 2983 ------------------------------------------------*/ 2984 #if PY_VERSION_HEX >= 0x03000000 2985 # define SWIG_init PyInit__qpol 2986 2987 #else 2988 # define SWIG_init init_qpol 2989 2990 #endif 2991 #define SWIG_name "_qpol" 2992 2993 #define SWIGVERSION 0x020011 2994 #define SWIG_VERSION SWIGVERSION 2995 2996 2997 #define SWIG_as_voidptr(a) (void *)((const void *)(a)) 2998 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 2999 3000 3001 #include <sys/stat.h> 3002 #include <arpa/inet.h> 3003 #include <sepol/policydb.h> 3004 #include <sepol/policydb/policydb.h> 3005 #include "include/qpol/avrule_query.h" 3006 #include "include/qpol/bool_query.h" 3007 #include "include/qpol/class_perm_query.h" 3008 #include "include/qpol/cond_query.h" 3009 #include "include/qpol/constraint_query.h" 3010 #include "include/qpol/context_query.h" 3011 #include "include/qpol/fs_use_query.h" 3012 #include "include/qpol/genfscon_query.h" 3013 #include "include/qpol/isid_query.h" 3014 #include "include/qpol/iterator.h" 3015 #include "include/qpol/mls_query.h" 3016 #include "include/qpol/mlsrule_query.h" 3017 #include "include/qpol/module.h" 3018 #include "include/qpol/netifcon_query.h" 3019 #include "include/qpol/nodecon_query.h" 3020 #include "include/qpol/policy.h" 3021 #include "include/qpol/policy_extend.h" 3022 #include "include/qpol/portcon_query.h" 3023 #include "include/qpol/rbacrule_query.h" 3024 #include "include/qpol/role_query.h" 3025 #include "include/qpol/syn_rule_query.h" 3026 #include "include/qpol/terule_query.h" 3027 #include "include/qpol/type_query.h" 3028 #include "include/qpol/user_query.h" 3029 #include "include/qpol/util.h" 3030 #include "include/qpol/xen_query.h" 3031 3032 /* Provide hooks so that language-specific modules can define the 3033 * callback function, used by the handler in 3034 * qpol_policy_open_from_file(). 3035 */ 3036 SWIGEXPORT qpol_callback_fn_t qpol_swig_message_callback = NULL; 3037 SWIGEXPORT void * qpol_swig_message_callback_arg = NULL; 3038 3039 3040 3041 #include <stdint.h> // Use the C99 official header 3042 3043 3044 /* cast void * to char * as it can't have a constructor */ 3045 const char * to_str(void *x) { 3046 return (const char *)x; 3047 } 3048 3049 /* cast a void * to int, while freeing the pointer */ 3050 int to_int_with_free(void *x) { 3051 int i = *(int *)x; 3052 free(x); 3053 return i; 3054 } 3055 3056 3057 SWIGINTERN swig_type_info* 3058 SWIG_pchar_descriptor(void) 3059 { 3060 static int init = 0; 3061 static swig_type_info* info = 0; 3062 if (!init) { 3063 info = SWIG_TypeQuery("_p_char"); 3064 init = 1; 3065 } 3066 return info; 3067 } 3068 3069 3070 SWIGINTERNINLINE PyObject * 3071 SWIG_FromCharPtrAndSize(const char* carray, size_t size) 3072 { 3073 if (carray) { 3074 if (size > INT_MAX) { 3075 swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); 3076 return pchar_descriptor ? 3077 SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); 3078 } else { 3079 #if PY_VERSION_HEX >= 0x03000000 3080 return PyUnicode_FromStringAndSize(carray, (int)(size)); 3081 #else 3082 return PyString_FromStringAndSize(carray, (int)(size)); 3083 #endif 3084 } 3085 } else { 3086 return SWIG_Py_Void(); 3087 } 3088 } 3089 3090 3091 SWIGINTERNINLINE PyObject * 3092 SWIG_FromCharPtr(const char *cptr) 3093 { 3094 return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); 3095 } 3096 3097 3098 SWIGINTERNINLINE PyObject* 3099 SWIG_From_int (int value) 3100 { 3101 return PyInt_FromLong((long) value); 3102 } 3103 3104 3105 /* C Bridge to Python logging callback */ 3106 __attribute__ ((format(printf, 4, 0))) 3107 static void qpol_log_callback(void *varg, 3108 const qpol_policy_t * p __attribute__ ((unused)), 3109 int level, 3110 const char *fmt, 3111 va_list va_args) 3112 { 3113 /* Expand to a full string to avoid any C format string 3114 * or variable args handling when passing to Python 3115 */ 3116 3117 PyObject *py_callback, *rc; 3118 char *str = NULL; 3119 3120 if(vasprintf(&str, fmt, va_args) < 0) 3121 return; 3122 3123 py_callback = (PyObject *) varg; 3124 3125 /* this char* casting doesn't make sense, but this runs afoul of -Werror 3126 * otherwise as the Python library doesn't do const char* */ 3127 rc = PyObject_CallFunction(py_callback, (char*)"(is)", level, str); 3128 Py_XDECREF(rc); 3129 free(str); 3130 } 3131 3132 3133 SWIGINTERN int 3134 SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) 3135 { 3136 #if PY_VERSION_HEX>=0x03000000 3137 if (PyUnicode_Check(obj)) 3138 #else 3139 if (PyString_Check(obj)) 3140 #endif 3141 { 3142 char *cstr; Py_ssize_t len; 3143 #if PY_VERSION_HEX>=0x03000000 3144 if (!alloc && cptr) { 3145 /* We can't allow converting without allocation, since the internal 3146 representation of string in Python 3 is UCS-2/UCS-4 but we require 3147 a UTF-8 representation. 3148 TODO(bhy) More detailed explanation */ 3149 return SWIG_RuntimeError; 3150 } 3151 obj = PyUnicode_AsUTF8String(obj); 3152 PyBytes_AsStringAndSize(obj, &cstr, &len); 3153 if(alloc) *alloc = SWIG_NEWOBJ; 3154 #else 3155 PyString_AsStringAndSize(obj, &cstr, &len); 3156 #endif 3157 if (cptr) { 3158 if (alloc) { 3159 /* 3160 In python the user should not be able to modify the inner 3161 string representation. To warranty that, if you define 3162 SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string 3163 buffer is always returned. 3164 3165 The default behavior is just to return the pointer value, 3166 so, be careful. 3167 */ 3168 #if defined(SWIG_PYTHON_SAFE_CSTRINGS) 3169 if (*alloc != SWIG_OLDOBJ) 3170 #else 3171 if (*alloc == SWIG_NEWOBJ) 3172 #endif 3173 { 3174 *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); 3175 *alloc = SWIG_NEWOBJ; 3176 } 3177 else { 3178 *cptr = cstr; 3179 *alloc = SWIG_OLDOBJ; 3180 } 3181 } else { 3182 #if PY_VERSION_HEX>=0x03000000 3183 assert(0); /* Should never reach here in Python 3 */ 3184 #endif 3185 *cptr = SWIG_Python_str_AsChar(obj); 3186 } 3187 } 3188 if (psize) *psize = len + 1; 3189 #if PY_VERSION_HEX>=0x03000000 3190 Py_XDECREF(obj); 3191 #endif 3192 return SWIG_OK; 3193 } else { 3194 swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); 3195 if (pchar_descriptor) { 3196 void* vptr = 0; 3197 if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { 3198 if (cptr) *cptr = (char *) vptr; 3199 if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; 3200 if (alloc) *alloc = SWIG_OLDOBJ; 3201 return SWIG_OK; 3202 } 3203 } 3204 } 3205 return SWIG_TypeError; 3206 } 3207 3208 3209 3210 3211 3212 #include <limits.h> 3213 #if !defined(SWIG_NO_LLONG_MAX) 3214 # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) 3215 # define LLONG_MAX __LONG_LONG_MAX__ 3216 # define LLONG_MIN (-LLONG_MAX - 1LL) 3217 # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) 3218 # endif 3219 #endif 3220 3221 3222 SWIGINTERN int 3223 SWIG_AsVal_double (PyObject *obj, double *val) 3224 { 3225 int res = SWIG_TypeError; 3226 if (PyFloat_Check(obj)) { 3227 if (val) *val = PyFloat_AsDouble(obj); 3228 return SWIG_OK; 3229 } else if (PyInt_Check(obj)) { 3230 if (val) *val = PyInt_AsLong(obj); 3231 return SWIG_OK; 3232 } else if (PyLong_Check(obj)) { 3233 double v = PyLong_AsDouble(obj); 3234 if (!PyErr_Occurred()) { 3235 if (val) *val = v; 3236 return SWIG_OK; 3237 } else { 3238 PyErr_Clear(); 3239 } 3240 } 3241 #ifdef SWIG_PYTHON_CAST_MODE 3242 { 3243 int dispatch = 0; 3244 double d = PyFloat_AsDouble(obj); 3245 if (!PyErr_Occurred()) { 3246 if (val) *val = d; 3247 return SWIG_AddCast(SWIG_OK); 3248 } else { 3249 PyErr_Clear(); 3250 } 3251 if (!dispatch) { 3252 long v = PyLong_AsLong(obj); 3253 if (!PyErr_Occurred()) { 3254 if (val) *val = v; 3255 return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); 3256 } else { 3257 PyErr_Clear(); 3258 } 3259 } 3260 } 3261 #endif 3262 return res; 3263 } 3264 3265 3266 #include <float.h> 3267 3268 3269 #include <math.h> 3270 3271 3272 SWIGINTERNINLINE int 3273 SWIG_CanCastAsInteger(double *d, double min, double max) { 3274 double x = *d; 3275 if ((min <= x && x <= max)) { 3276 double fx = floor(x); 3277 double cx = ceil(x); 3278 double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ 3279 if ((errno == EDOM) || (errno == ERANGE)) { 3280 errno = 0; 3281 } else { 3282 double summ, reps, diff; 3283 if (rd < x) { 3284 diff = x - rd; 3285 } else if (rd > x) { 3286 diff = rd - x; 3287 } else { 3288 return 1; 3289 } 3290 summ = rd + x; 3291 reps = diff/summ; 3292 if (reps < 8*DBL_EPSILON) { 3293 *d = rd; 3294 return 1; 3295 } 3296 } 3297 } 3298 return 0; 3299 } 3300 3301 3302 SWIGINTERN int 3303 SWIG_AsVal_long (PyObject *obj, long* val) 3304 { 3305 if (PyInt_Check(obj)) { 3306 if (val) *val = PyInt_AsLong(obj); 3307 return SWIG_OK; 3308 } else if (PyLong_Check(obj)) { 3309 long v = PyLong_AsLong(obj); 3310 if (!PyErr_Occurred()) { 3311 if (val) *val = v; 3312 return SWIG_OK; 3313 } else { 3314 PyErr_Clear(); 3315 } 3316 } 3317 #ifdef SWIG_PYTHON_CAST_MODE 3318 { 3319 int dispatch = 0; 3320 long v = PyInt_AsLong(obj); 3321 if (!PyErr_Occurred()) { 3322 if (val) *val = v; 3323 return SWIG_AddCast(SWIG_OK); 3324 } else { 3325 PyErr_Clear(); 3326 } 3327 if (!dispatch) { 3328 double d; 3329 int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); 3330 if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { 3331 if (val) *val = (long)(d); 3332 return res; 3333 } 3334 } 3335 } 3336 #endif 3337 return SWIG_TypeError; 3338 } 3339 3340 3341 SWIGINTERN int 3342 SWIG_AsVal_int (PyObject * obj, int *val) 3343 { 3344 long v; 3345 int res = SWIG_AsVal_long (obj, &v); 3346 if (SWIG_IsOK(res)) { 3347 if ((v < INT_MIN || v > INT_MAX)) { 3348 return SWIG_OverflowError; 3349 } else { 3350 if (val) *val = (int)(v); 3351 } 3352 } 3353 return res; 3354 } 3355 3356 SWIGINTERN struct qpol_policy *new_qpol_policy(char const *path,int const options,PyObject *py_callback){ 3357 qpol_policy_t *p; 3358 3359 if (!PyCallable_Check(py_callback)) { 3360 PyErr_SetString(PyExc_TypeError, "Callback parameter must be callable"); 3361 return NULL; 3362 } 3363 3364 qpol_policy_open_from_file(path, &p, qpol_log_callback, (void*)py_callback, options); 3365 return p; 3366 } 3367 SWIGINTERN void delete_qpol_policy(struct qpol_policy *self){ 3368 qpol_policy_destroy(&self); 3369 } 3370 SWIGINTERN int qpol_policy_version(struct qpol_policy *self){ 3371 unsigned int v; 3372 (void)qpol_policy_get_policy_version(self, &v); /* only error is on null parameters neither can be here */ 3373 return (int) v; 3374 } 3375 SWIGINTERN char const *qpol_policy_handle_unknown(struct qpol_policy *self){ 3376 unsigned int h; 3377 qpol_policy_get_policy_handle_unknown(self, &h); 3378 3379 switch (h) { 3380 case SEPOL_DENY_UNKNOWN: return "deny"; 3381 case SEPOL_REJECT_UNKNOWN: return "reject"; 3382 case SEPOL_ALLOW_UNKNOWN: return "allow"; 3383 default: return "unknown"; 3384 } 3385 } 3386 SWIGINTERN char const *qpol_policy_target_platform(struct qpol_policy *self){ 3387 int t; 3388 (void)qpol_policy_get_target_platform(self, &t); 3389 switch (t) { 3390 case SEPOL_TARGET_SELINUX: return "selinux"; 3391 case SEPOL_TARGET_XEN: return "xen"; 3392 default: return "unknown"; 3393 } 3394 } 3395 SWIGINTERN int qpol_policy_capability(struct qpol_policy *self,qpol_capability_e cap){ 3396 return qpol_policy_has_capability(self, cap); 3397 } 3398 SWIGINTERN qpol_iterator_t *qpol_policy_type_iter(struct qpol_policy *self){ 3399 qpol_iterator_t *iter; 3400 if (qpol_policy_get_type_iter(self, &iter)) { 3401 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3402 } 3403 return iter; 3404 fail: 3405 return NULL; 3406 } 3407 SWIGINTERN size_t qpol_policy_type_count(struct qpol_policy *self){ 3408 qpol_iterator_t *iter; 3409 size_t count = 0; 3410 if (qpol_policy_get_type_iter(self, &iter)) { 3411 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3412 } 3413 qpol_iterator_get_size(iter, &count); 3414 return count; 3415 fail: 3416 return 0; 3417 } 3418 3419 #define SWIG_From_long PyLong_FromLong 3420 3421 3422 SWIGINTERNINLINE PyObject* 3423 SWIG_From_unsigned_SS_long (unsigned long value) 3424 { 3425 return (value > LONG_MAX) ? 3426 PyLong_FromUnsignedLong(value) : PyLong_FromLong((long)(value)); 3427 } 3428 3429 3430 SWIGINTERNINLINE PyObject * 3431 SWIG_From_size_t (size_t value) 3432 { 3433 return SWIG_From_unsigned_SS_long ((unsigned long)(value)); 3434 } 3435 3436 SWIGINTERN qpol_iterator_t *qpol_policy_role_iter(struct qpol_policy *self){ 3437 qpol_iterator_t *iter; 3438 if (qpol_policy_get_role_iter(self, &iter)) { 3439 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3440 } 3441 return iter; 3442 fail: 3443 return NULL; 3444 } 3445 SWIGINTERN size_t qpol_policy_role_count(struct qpol_policy *self){ 3446 qpol_iterator_t *iter; 3447 size_t count = 0; 3448 if (qpol_policy_get_role_iter(self, &iter)) { 3449 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3450 } 3451 qpol_iterator_get_size(iter, &count); 3452 return count; 3453 fail: 3454 return 0; 3455 } 3456 SWIGINTERN qpol_iterator_t *qpol_policy_level_iter(struct qpol_policy *self){ 3457 qpol_iterator_t *iter; 3458 if (qpol_policy_get_level_iter(self, &iter)) { 3459 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3460 } 3461 return iter; 3462 fail: 3463 return NULL; 3464 } 3465 SWIGINTERN size_t qpol_policy_level_count(struct qpol_policy *self){ 3466 qpol_iterator_t *iter; 3467 size_t count = 0; 3468 if (qpol_policy_get_level_iter(self, &iter)) { 3469 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3470 } 3471 qpol_iterator_get_size(iter, &count); 3472 return count; 3473 fail: 3474 return 0; 3475 } 3476 SWIGINTERN qpol_iterator_t *qpol_policy_cat_iter(struct qpol_policy *self){ 3477 qpol_iterator_t *iter; 3478 if (qpol_policy_get_cat_iter(self, &iter)) { 3479 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3480 } 3481 return iter; 3482 fail: 3483 return NULL; 3484 } 3485 SWIGINTERN size_t qpol_policy_cat_count(struct qpol_policy *self){ 3486 qpol_iterator_t *iter; 3487 size_t count = 0; 3488 if (qpol_policy_get_cat_iter(self, &iter)) { 3489 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3490 } 3491 qpol_iterator_get_size(iter, &count); 3492 return count; 3493 fail: 3494 return 0; 3495 } 3496 SWIGINTERN qpol_iterator_t *qpol_policy_user_iter(struct qpol_policy *self){ 3497 qpol_iterator_t *iter; 3498 if (qpol_policy_get_user_iter(self, &iter)) { 3499 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3500 } 3501 return iter; 3502 fail: 3503 return NULL; 3504 } 3505 SWIGINTERN size_t qpol_policy_user_count(struct qpol_policy *self){ 3506 qpol_iterator_t *iter; 3507 size_t count = 0; 3508 if (qpol_policy_get_user_iter(self, &iter)) { 3509 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3510 } 3511 qpol_iterator_get_size(iter, &count); 3512 return count; 3513 fail: 3514 return 0; 3515 } 3516 SWIGINTERN qpol_iterator_t *qpol_policy_bool_iter(struct qpol_policy *self){ 3517 qpol_iterator_t *iter; 3518 if (qpol_policy_get_bool_iter(self, &iter)) { 3519 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3520 } 3521 return iter; 3522 fail: 3523 return NULL; 3524 } 3525 SWIGINTERN size_t qpol_policy_bool_count(struct qpol_policy *self){ 3526 qpol_iterator_t *iter; 3527 size_t count = 0; 3528 if (qpol_policy_get_bool_iter(self, &iter)) { 3529 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3530 } 3531 qpol_iterator_get_size(iter, &count); 3532 return count; 3533 fail: 3534 return 0; 3535 } 3536 SWIGINTERN qpol_iterator_t *qpol_policy_class_iter(struct qpol_policy *self,char *perm){ 3537 qpol_iterator_t *iter; 3538 if (perm) { 3539 if (qpol_perm_get_class_iter(self, perm, &iter)) { 3540 SWIG_exception(SWIG_RuntimeError, "Could not get class iterator"); 3541 } 3542 } else { 3543 if (qpol_policy_get_class_iter(self, &iter)) { 3544 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3545 } 3546 } 3547 return iter; 3548 fail: 3549 return NULL; 3550 } 3551 SWIGINTERN size_t qpol_policy_class_count(struct qpol_policy *self){ 3552 qpol_iterator_t *iter; 3553 size_t count = 0; 3554 if (qpol_policy_get_class_iter(self, &iter)) { 3555 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3556 } 3557 qpol_iterator_get_size(iter, &count); 3558 return count; 3559 fail: 3560 return 0; 3561 } 3562 SWIGINTERN qpol_iterator_t *qpol_policy_common_iter(struct qpol_policy *self,char *perm){ 3563 qpol_iterator_t *iter; 3564 if (perm) { 3565 if (qpol_perm_get_common_iter(self, perm, &iter)) { 3566 SWIG_exception(SWIG_RuntimeError, "Could not get common iterator"); 3567 } 3568 } else { 3569 if (qpol_policy_get_common_iter(self, &iter)) { 3570 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3571 } 3572 } 3573 return iter; 3574 fail: 3575 return NULL; 3576 } 3577 SWIGINTERN size_t qpol_policy_common_count(struct qpol_policy *self){ 3578 qpol_iterator_t *iter; 3579 size_t count = 0; 3580 if (qpol_policy_get_common_iter(self, &iter)) { 3581 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3582 } 3583 qpol_iterator_get_size(iter, &count); 3584 return count; 3585 fail: 3586 return 0; 3587 } 3588 SWIGINTERN qpol_iterator_t *qpol_policy_fs_use_iter(struct qpol_policy *self){ 3589 qpol_iterator_t *iter; 3590 if (qpol_policy_get_fs_use_iter(self, &iter)) { 3591 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3592 } 3593 return iter; 3594 fail: 3595 return NULL; 3596 } 3597 SWIGINTERN size_t qpol_policy_fs_use_count(struct qpol_policy *self){ 3598 qpol_iterator_t *iter; 3599 size_t count = 0; 3600 if (qpol_policy_get_fs_use_iter(self, &iter)) { 3601 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3602 } 3603 qpol_iterator_get_size(iter, &count); 3604 return count; 3605 fail: 3606 return 0; 3607 } 3608 SWIGINTERN qpol_iterator_t *qpol_policy_genfscon_iter(struct qpol_policy *self){ 3609 qpol_iterator_t *iter; 3610 if (qpol_policy_get_genfscon_iter(self, &iter)) { 3611 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3612 } 3613 return iter; 3614 fail: 3615 return NULL; 3616 } 3617 SWIGINTERN size_t qpol_policy_genfscon_count(struct qpol_policy *self){ 3618 qpol_iterator_t *iter; 3619 size_t count = 0; 3620 if (qpol_policy_get_genfscon_iter(self, &iter)) { 3621 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3622 } 3623 qpol_iterator_get_size(iter, &count); 3624 return count; 3625 fail: 3626 return 0; 3627 } 3628 SWIGINTERN qpol_iterator_t *qpol_policy_isid_iter(struct qpol_policy *self){ 3629 qpol_iterator_t *iter; 3630 if (qpol_policy_get_isid_iter(self, &iter)) { 3631 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3632 } 3633 return iter; 3634 fail: 3635 return NULL; 3636 } 3637 SWIGINTERN size_t qpol_policy_isid_count(struct qpol_policy *self){ 3638 qpol_iterator_t *iter; 3639 size_t count = 0; 3640 if (qpol_policy_get_isid_iter(self, &iter)) { 3641 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3642 } 3643 qpol_iterator_get_size(iter, &count); 3644 return count; 3645 fail: 3646 return 0; 3647 } 3648 SWIGINTERN qpol_iterator_t *qpol_policy_netifcon_iter(struct qpol_policy *self){ 3649 qpol_iterator_t *iter; 3650 if (qpol_policy_get_netifcon_iter(self, &iter)) { 3651 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3652 } 3653 return iter; 3654 fail: 3655 return NULL; 3656 } 3657 SWIGINTERN size_t qpol_policy_netifcon_count(struct qpol_policy *self){ 3658 qpol_iterator_t *iter; 3659 size_t count = 0; 3660 if (qpol_policy_get_netifcon_iter(self, &iter)) { 3661 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3662 } 3663 qpol_iterator_get_size(iter, &count); 3664 return count; 3665 fail: 3666 return 0; 3667 } 3668 SWIGINTERN qpol_iterator_t *qpol_policy_nodecon_iter(struct qpol_policy *self){ 3669 qpol_iterator_t *iter; 3670 if (qpol_policy_get_nodecon_iter(self, &iter)) { 3671 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3672 } 3673 return iter; 3674 fail: 3675 return NULL; 3676 } 3677 SWIGINTERN size_t qpol_policy_nodecon_count(struct qpol_policy *self){ 3678 qpol_iterator_t *iter; 3679 size_t count = 0; 3680 if (qpol_policy_get_nodecon_iter(self, &iter)) { 3681 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3682 } 3683 qpol_iterator_get_size(iter, &count); 3684 return count; 3685 fail: 3686 return 0; 3687 } 3688 SWIGINTERN qpol_iterator_t *qpol_policy_portcon_iter(struct qpol_policy *self){ 3689 qpol_iterator_t *iter; 3690 if (qpol_policy_get_portcon_iter(self, &iter)) { 3691 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3692 } 3693 return iter; 3694 fail: 3695 return NULL; 3696 } 3697 SWIGINTERN size_t qpol_policy_portcon_count(struct qpol_policy *self){ 3698 qpol_iterator_t *iter; 3699 size_t count = 0; 3700 if (qpol_policy_get_portcon_iter(self, &iter)) { 3701 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3702 } 3703 qpol_iterator_get_size(iter, &count); 3704 return count; 3705 fail: 3706 return 0; 3707 } 3708 SWIGINTERN qpol_iterator_t *qpol_policy_constraint_iter(struct qpol_policy *self){ 3709 qpol_iterator_t *iter; 3710 if (qpol_policy_get_constraint_iter(self, &iter)) { 3711 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3712 } 3713 return iter; 3714 fail: 3715 return NULL; 3716 } 3717 SWIGINTERN size_t qpol_policy_constraint_count(struct qpol_policy *self){ 3718 qpol_iterator_t *iter; 3719 size_t count = 0; 3720 if (qpol_policy_get_constraint_iter(self, &iter)) { 3721 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3722 } 3723 qpol_iterator_get_size(iter, &count); 3724 return count; 3725 fail: 3726 return 0; 3727 } 3728 SWIGINTERN qpol_iterator_t *qpol_policy_validatetrans_iter(struct qpol_policy *self){ 3729 qpol_iterator_t *iter; 3730 if (qpol_policy_get_validatetrans_iter(self, &iter)) { 3731 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3732 } 3733 return iter; 3734 fail: 3735 return NULL; 3736 } 3737 SWIGINTERN size_t qpol_policy_validatetrans_count(struct qpol_policy *self){ 3738 qpol_iterator_t *iter; 3739 size_t count = 0; 3740 if (qpol_policy_get_validatetrans_iter(self, &iter)) { 3741 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3742 } 3743 qpol_iterator_get_size(iter, &count); 3744 return count; 3745 fail: 3746 return 0; 3747 } 3748 SWIGINTERN qpol_iterator_t *qpol_policy_role_allow_iter(struct qpol_policy *self){ 3749 qpol_iterator_t *iter; 3750 if (qpol_policy_get_role_allow_iter(self, &iter)) { 3751 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3752 } 3753 return iter; 3754 fail: 3755 return NULL; 3756 } 3757 SWIGINTERN size_t qpol_policy_role_allow_count(struct qpol_policy *self){ 3758 qpol_iterator_t *iter; 3759 size_t count = 0; 3760 if (qpol_policy_get_role_allow_iter(self, &iter)) { 3761 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3762 } 3763 qpol_iterator_get_size(iter, &count); 3764 return count; 3765 fail: 3766 return 0; 3767 } 3768 SWIGINTERN qpol_iterator_t *qpol_policy_role_trans_iter(struct qpol_policy *self){ 3769 qpol_iterator_t *iter; 3770 if (qpol_policy_get_role_trans_iter(self, &iter)) { 3771 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3772 } 3773 return iter; 3774 fail: 3775 return NULL; 3776 } 3777 SWIGINTERN size_t qpol_policy_role_trans_count(struct qpol_policy *self){ 3778 qpol_iterator_t *iter; 3779 size_t count = 0; 3780 if (qpol_policy_get_role_trans_iter(self, &iter)) { 3781 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3782 } 3783 qpol_iterator_get_size(iter, &count); 3784 return count; 3785 fail: 3786 return 0; 3787 } 3788 SWIGINTERN qpol_iterator_t *qpol_policy_range_trans_iter(struct qpol_policy *self){ 3789 qpol_iterator_t *iter; 3790 if (qpol_policy_get_range_trans_iter(self, &iter)) { 3791 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3792 } 3793 return iter; 3794 fail: 3795 return NULL; 3796 } 3797 SWIGINTERN size_t qpol_policy_range_trans_count(struct qpol_policy *self){ 3798 qpol_iterator_t *iter; 3799 size_t count = 0; 3800 if (qpol_policy_get_range_trans_iter(self, &iter)) { 3801 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3802 } 3803 qpol_iterator_get_size(iter, &count); 3804 return count; 3805 fail: 3806 return 0; 3807 } 3808 SWIGINTERN qpol_iterator_t *qpol_policy_avrule_iter(struct qpol_policy *self){ 3809 qpol_iterator_t *iter; 3810 uint32_t rule_types = QPOL_RULE_ALLOW | QPOL_RULE_AUDITALLOW | QPOL_RULE_DONTAUDIT; 3811 3812 if (qpol_policy_has_capability(self, QPOL_CAP_NEVERALLOW)) 3813 rule_types |= QPOL_RULE_NEVERALLOW; 3814 3815 if (qpol_policy_get_avrule_iter(self, rule_types, &iter)) { 3816 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3817 } 3818 return iter; 3819 fail: 3820 return NULL; 3821 } 3822 SWIGINTERN size_t qpol_policy_avrule_allow_count(struct qpol_policy *self){ 3823 qpol_iterator_t *iter; 3824 size_t count = 0; 3825 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_ALLOW, &iter)) { 3826 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3827 } 3828 qpol_iterator_get_size(iter, &count); 3829 return count; 3830 fail: 3831 return 0; 3832 } 3833 SWIGINTERN size_t qpol_policy_avrule_auditallow_count(struct qpol_policy *self){ 3834 qpol_iterator_t *iter; 3835 size_t count = 0; 3836 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_AUDITALLOW, &iter)) { 3837 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3838 } 3839 qpol_iterator_get_size(iter, &count); 3840 return count; 3841 fail: 3842 return 0; 3843 } 3844 SWIGINTERN size_t qpol_policy_avrule_neverallow_count(struct qpol_policy *self){ 3845 if (qpol_policy_has_capability(self, QPOL_CAP_NEVERALLOW)) { 3846 qpol_iterator_t *iter; 3847 size_t count = 0; 3848 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_NEVERALLOW, &iter)) { 3849 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3850 } 3851 qpol_iterator_get_size(iter, &count); 3852 return count; 3853 } else { 3854 return 0; 3855 } 3856 fail: 3857 return 0; 3858 } 3859 SWIGINTERN size_t qpol_policy_avrule_dontaudit_count(struct qpol_policy *self){ 3860 qpol_iterator_t *iter; 3861 size_t count = 0; 3862 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_DONTAUDIT, &iter)) { 3863 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3864 } 3865 qpol_iterator_get_size(iter, &count); 3866 return count; 3867 fail: 3868 return 0; 3869 } 3870 SWIGINTERN qpol_iterator_t *qpol_policy_avrulex_iter(struct qpol_policy *self){ 3871 qpol_iterator_t *iter; 3872 uint32_t rule_types = QPOL_RULE_XPERMS_ALLOW | QPOL_RULE_XPERMS_AUDITALLOW | QPOL_RULE_XPERMS_DONTAUDIT; 3873 3874 if (qpol_policy_has_capability(self, QPOL_CAP_NEVERALLOW)) 3875 rule_types |= QPOL_RULE_XPERMS_NEVERALLOW; 3876 3877 if (qpol_policy_get_avrule_iter(self, rule_types, &iter)) { 3878 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3879 } 3880 return iter; 3881 fail: 3882 return NULL; 3883 } 3884 SWIGINTERN size_t qpol_policy_avrule_allowx_count(struct qpol_policy *self){ 3885 qpol_iterator_t *iter; 3886 size_t count = 0; 3887 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_XPERMS_ALLOW, &iter)) { 3888 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3889 } 3890 qpol_iterator_get_size(iter, &count); 3891 return count; 3892 fail: 3893 return 0; 3894 } 3895 SWIGINTERN size_t qpol_policy_avrule_auditallowx_count(struct qpol_policy *self){ 3896 qpol_iterator_t *iter; 3897 size_t count = 0; 3898 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_XPERMS_AUDITALLOW, &iter)) { 3899 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3900 } 3901 qpol_iterator_get_size(iter, &count); 3902 return count; 3903 fail: 3904 return 0; 3905 } 3906 SWIGINTERN size_t qpol_policy_avrule_neverallowx_count(struct qpol_policy *self){ 3907 if (qpol_policy_has_capability(self, QPOL_CAP_NEVERALLOW)) { 3908 qpol_iterator_t *iter; 3909 size_t count = 0; 3910 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_XPERMS_NEVERALLOW, &iter)) { 3911 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3912 } 3913 qpol_iterator_get_size(iter, &count); 3914 return count; 3915 } else { 3916 return 0; 3917 } 3918 fail: 3919 return 0; 3920 } 3921 SWIGINTERN size_t qpol_policy_avrule_dontauditx_count(struct qpol_policy *self){ 3922 qpol_iterator_t *iter; 3923 size_t count = 0; 3924 if (qpol_policy_get_avrule_iter(self, QPOL_RULE_XPERMS_DONTAUDIT, &iter)) { 3925 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3926 } 3927 qpol_iterator_get_size(iter, &count); 3928 return count; 3929 fail: 3930 return 0; 3931 } 3932 SWIGINTERN qpol_iterator_t *qpol_policy_terule_iter(struct qpol_policy *self){ 3933 qpol_iterator_t *iter; 3934 uint32_t rule_types = QPOL_RULE_TYPE_TRANS | QPOL_RULE_TYPE_CHANGE | QPOL_RULE_TYPE_MEMBER; 3935 3936 if (qpol_policy_get_terule_iter(self, rule_types, &iter)) { 3937 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3938 } 3939 return iter; 3940 fail: 3941 return NULL; 3942 } 3943 SWIGINTERN size_t qpol_policy_terule_trans_count(struct qpol_policy *self){ 3944 qpol_iterator_t *iter; 3945 size_t count = 0; 3946 if (qpol_policy_get_terule_iter(self, QPOL_RULE_TYPE_TRANS, &iter)) { 3947 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3948 } 3949 qpol_iterator_get_size(iter, &count); 3950 return count; 3951 fail: 3952 return 0; 3953 } 3954 SWIGINTERN size_t qpol_policy_terule_change_count(struct qpol_policy *self){ 3955 qpol_iterator_t *iter; 3956 size_t count = 0; 3957 if (qpol_policy_get_terule_iter(self, QPOL_RULE_TYPE_CHANGE, &iter)) { 3958 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3959 } 3960 qpol_iterator_get_size(iter, &count); 3961 return count; 3962 fail: 3963 return 0; 3964 } 3965 SWIGINTERN size_t qpol_policy_terule_member_count(struct qpol_policy *self){ 3966 qpol_iterator_t *iter; 3967 size_t count = 0; 3968 if (qpol_policy_get_terule_iter(self, QPOL_RULE_TYPE_MEMBER, &iter)) { 3969 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3970 } 3971 qpol_iterator_get_size(iter, &count); 3972 return count; 3973 fail: 3974 return 0; 3975 } 3976 SWIGINTERN qpol_iterator_t *qpol_policy_cond_iter(struct qpol_policy *self){ 3977 qpol_iterator_t *iter; 3978 if (qpol_policy_get_cond_iter(self, &iter)) { 3979 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3980 } 3981 return iter; 3982 fail: 3983 return NULL; 3984 } 3985 SWIGINTERN size_t qpol_policy_cond_count(struct qpol_policy *self){ 3986 qpol_iterator_t *iter; 3987 size_t count = 0; 3988 if (qpol_policy_get_cond_iter(self, &iter)) { 3989 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 3990 } 3991 qpol_iterator_get_size(iter, &count); 3992 return count; 3993 fail: 3994 return 0; 3995 } 3996 SWIGINTERN qpol_iterator_t *qpol_policy_filename_trans_iter(struct qpol_policy *self){ 3997 qpol_iterator_t *iter; 3998 if (qpol_policy_get_filename_trans_iter(self, &iter)) { 3999 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 4000 } 4001 return iter; 4002 fail: 4003 return NULL; 4004 } 4005 SWIGINTERN size_t qpol_policy_filename_trans_count(struct qpol_policy *self){ 4006 qpol_iterator_t *iter; 4007 size_t count = 0; 4008 if (qpol_policy_get_filename_trans_iter(self, &iter)) { 4009 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 4010 } 4011 qpol_iterator_get_size(iter, &count); 4012 return count; 4013 fail: 4014 return 0; 4015 } 4016 SWIGINTERN qpol_iterator_t *qpol_policy_permissive_iter(struct qpol_policy *self){ 4017 qpol_iterator_t *iter; 4018 if (qpol_policy_get_permissive_iter(self, &iter)) { 4019 SWIG_exception(SWIG_MemoryError, "Out of Memory"); 4020 } 4021 return iter; 4022 fail: 4023 return NULL; 4024 } 4025 SWIGINTERN size_t