PageRenderTime 95ms CodeModel.GetById 32ms RepoModel.GetById 6ms app.codeStats 0ms

/trunk/Lib/swigrun.swg

#
Unknown | 583 lines | 521 code | 62 blank | 0 comment | 0 complexity | 4eb99603eb7e279a8466dc20c757e105 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * swigrun.swg
  3. *
  4. * This file contains generic C API SWIG runtime support for pointer
  5. * type checking.
  6. * ----------------------------------------------------------------------------- */
  7. /* This should only be incremented when either the layout of swig_type_info changes,
  8. or for whatever reason, the runtime changes incompatibly */
  9. #define SWIG_RUNTIME_VERSION "4"
  10. /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
  11. #ifdef SWIG_TYPE_TABLE
  12. # define SWIG_QUOTE_STRING(x) #x
  13. # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
  14. # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
  15. #else
  16. # define SWIG_TYPE_TABLE_NAME
  17. #endif
  18. /*
  19. You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
  20. creating a static or dynamic library from the SWIG runtime code.
  21. In 99.9% of the cases, SWIG just needs to declare them as 'static'.
  22. But only do this if strictly necessary, ie, if you have problems
  23. with your compiler or suchlike.
  24. */
  25. #ifndef SWIGRUNTIME
  26. # define SWIGRUNTIME SWIGINTERN
  27. #endif
  28. #ifndef SWIGRUNTIMEINLINE
  29. # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
  30. #endif
  31. /* Generic buffer size */
  32. #ifndef SWIG_BUFFER_SIZE
  33. # define SWIG_BUFFER_SIZE 1024
  34. #endif
  35. /* Flags for pointer conversions */
  36. #define SWIG_POINTER_DISOWN 0x1
  37. #define SWIG_CAST_NEW_MEMORY 0x2
  38. /* Flags for new pointer objects */
  39. #define SWIG_POINTER_OWN 0x1
  40. /*
  41. Flags/methods for returning states.
  42. The SWIG conversion methods, as ConvertPtr, return an integer
  43. that tells if the conversion was successful or not. And if not,
  44. an error code can be returned (see swigerrors.swg for the codes).
  45. Use the following macros/flags to set or process the returning
  46. states.
  47. In old versions of SWIG, code such as the following was usually written:
  48. if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
  49. // success code
  50. } else {
  51. //fail code
  52. }
  53. Now you can be more explicit:
  54. int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
  55. if (SWIG_IsOK(res)) {
  56. // success code
  57. } else {
  58. // fail code
  59. }
  60. which is the same really, but now you can also do
  61. Type *ptr;
  62. int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
  63. if (SWIG_IsOK(res)) {
  64. // success code
  65. if (SWIG_IsNewObj(res) {
  66. ...
  67. delete *ptr;
  68. } else {
  69. ...
  70. }
  71. } else {
  72. // fail code
  73. }
  74. I.e., now SWIG_ConvertPtr can return new objects and you can
  75. identify the case and take care of the deallocation. Of course that
  76. also requires SWIG_ConvertPtr to return new result values, such as
  77. int SWIG_ConvertPtr(obj, ptr,...) {
  78. if (<obj is ok>) {
  79. if (<need new object>) {
  80. *ptr = <ptr to new allocated object>;
  81. return SWIG_NEWOBJ;
  82. } else {
  83. *ptr = <ptr to old object>;
  84. return SWIG_OLDOBJ;
  85. }
  86. } else {
  87. return SWIG_BADOBJ;
  88. }
  89. }
  90. Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
  91. more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
  92. SWIG errors code.
  93. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
  94. allows to return the 'cast rank', for example, if you have this
  95. int food(double)
  96. int fooi(int);
  97. and you call
  98. food(1) // cast rank '1' (1 -> 1.0)
  99. fooi(1) // cast rank '0'
  100. just use the SWIG_AddCast()/SWIG_CheckState()
  101. */
  102. #define SWIG_OK (0)
  103. #define SWIG_ERROR (-1)
  104. #define SWIG_IsOK(r) (r >= 0)
  105. #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
  106. /* The CastRankLimit says how many bits are used for the cast rank */
  107. #define SWIG_CASTRANKLIMIT (1 << 8)
  108. /* The NewMask denotes the object was created (using new/malloc) */
  109. #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
  110. /* The TmpMask is for in/out typemaps that use temporal objects */
  111. #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
  112. /* Simple returning values */
  113. #define SWIG_BADOBJ (SWIG_ERROR)
  114. #define SWIG_OLDOBJ (SWIG_OK)
  115. #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
  116. #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
  117. /* Check, add and del mask methods */
  118. #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
  119. #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
  120. #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
  121. #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
  122. #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
  123. #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
  124. /* Cast-Rank Mode */
  125. #if defined(SWIG_CASTRANK_MODE)
  126. # ifndef SWIG_TypeRank
  127. # define SWIG_TypeRank unsigned long
  128. # endif
  129. # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
  130. # define SWIG_MAXCASTRANK (2)
  131. # endif
  132. # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
  133. # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
  134. SWIGINTERNINLINE int SWIG_AddCast(int r) {
  135. return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
  136. }
  137. SWIGINTERNINLINE int SWIG_CheckState(int r) {
  138. return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
  139. }
  140. #else /* no cast-rank mode */
  141. # define SWIG_AddCast
  142. # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
  143. #endif
  144. #include <string.h>
  145. #ifdef __cplusplus
  146. extern "C" {
  147. #endif
  148. typedef void *(*swig_converter_func)(void *, int *);
  149. typedef struct swig_type_info *(*swig_dycast_func)(void **);
  150. /* Structure to store information on one type */
  151. typedef struct swig_type_info {
  152. const char *name; /* mangled name of this type */
  153. const char *str; /* human readable name of this type */
  154. swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
  155. struct swig_cast_info *cast; /* linked list of types that can cast into this type */
  156. void *clientdata; /* language specific type data */
  157. int owndata; /* flag if the structure owns the clientdata */
  158. } swig_type_info;
  159. /* Structure to store a type and conversion function used for casting */
  160. typedef struct swig_cast_info {
  161. swig_type_info *type; /* pointer to type that is equivalent to this type */
  162. swig_converter_func converter; /* function to cast the void pointers */
  163. struct swig_cast_info *next; /* pointer to next cast in linked list */
  164. struct swig_cast_info *prev; /* pointer to the previous cast */
  165. } swig_cast_info;
  166. /* Structure used to store module information
  167. * Each module generates one structure like this, and the runtime collects
  168. * all of these structures and stores them in a circularly linked list.*/
  169. typedef struct swig_module_info {
  170. swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
  171. size_t size; /* Number of types in this module */
  172. struct swig_module_info *next; /* Pointer to next element in circularly linked list */
  173. swig_type_info **type_initial; /* Array of initially generated type structures */
  174. swig_cast_info **cast_initial; /* Array of initially generated casting structures */
  175. void *clientdata; /* Language specific module data */
  176. } swig_module_info;
  177. /*
  178. Compare two type names skipping the space characters, therefore
  179. "char*" == "char *" and "Class<int>" == "Class<int >", etc.
  180. Return 0 when the two name types are equivalent, as in
  181. strncmp, but skipping ' '.
  182. */
  183. SWIGRUNTIME int
  184. SWIG_TypeNameComp(const char *f1, const char *l1,
  185. const char *f2, const char *l2) {
  186. for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
  187. while ((*f1 == ' ') && (f1 != l1)) ++f1;
  188. while ((*f2 == ' ') && (f2 != l2)) ++f2;
  189. if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
  190. }
  191. return (int)((l1 - f1) - (l2 - f2));
  192. }
  193. /*
  194. Check type equivalence in a name list like <name1>|<name2>|...
  195. Return 0 if not equal, 1 if equal
  196. */
  197. SWIGRUNTIME int
  198. SWIG_TypeEquiv(const char *nb, const char *tb) {
  199. int equiv = 0;
  200. const char* te = tb + strlen(tb);
  201. const char* ne = nb;
  202. while (!equiv && *ne) {
  203. for (nb = ne; *ne; ++ne) {
  204. if (*ne == '|') break;
  205. }
  206. equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
  207. if (*ne) ++ne;
  208. }
  209. return equiv;
  210. }
  211. /*
  212. Check type equivalence in a name list like <name1>|<name2>|...
  213. Return 0 if equal, -1 if nb < tb, 1 if nb > tb
  214. */
  215. SWIGRUNTIME int
  216. SWIG_TypeCompare(const char *nb, const char *tb) {
  217. int equiv = 0;
  218. const char* te = tb + strlen(tb);
  219. const char* ne = nb;
  220. while (!equiv && *ne) {
  221. for (nb = ne; *ne; ++ne) {
  222. if (*ne == '|') break;
  223. }
  224. equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
  225. if (*ne) ++ne;
  226. }
  227. return equiv;
  228. }
  229. /*
  230. Check the typename
  231. */
  232. SWIGRUNTIME swig_cast_info *
  233. SWIG_TypeCheck(const char *c, swig_type_info *ty) {
  234. if (ty) {
  235. swig_cast_info *iter = ty->cast;
  236. while (iter) {
  237. if (strcmp(iter->type->name, c) == 0) {
  238. if (iter == ty->cast)
  239. return iter;
  240. /* Move iter to the top of the linked list */
  241. iter->prev->next = iter->next;
  242. if (iter->next)
  243. iter->next->prev = iter->prev;
  244. iter->next = ty->cast;
  245. iter->prev = 0;
  246. if (ty->cast) ty->cast->prev = iter;
  247. ty->cast = iter;
  248. return iter;
  249. }
  250. iter = iter->next;
  251. }
  252. }
  253. return 0;
  254. }
  255. /*
  256. Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
  257. */
  258. SWIGRUNTIME swig_cast_info *
  259. SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
  260. if (ty) {
  261. swig_cast_info *iter = ty->cast;
  262. while (iter) {
  263. if (iter->type == from) {
  264. if (iter == ty->cast)
  265. return iter;
  266. /* Move iter to the top of the linked list */
  267. iter->prev->next = iter->next;
  268. if (iter->next)
  269. iter->next->prev = iter->prev;
  270. iter->next = ty->cast;
  271. iter->prev = 0;
  272. if (ty->cast) ty->cast->prev = iter;
  273. ty->cast = iter;
  274. return iter;
  275. }
  276. iter = iter->next;
  277. }
  278. }
  279. return 0;
  280. }
  281. /*
  282. Cast a pointer up an inheritance hierarchy
  283. */
  284. SWIGRUNTIMEINLINE void *
  285. SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
  286. return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
  287. }
  288. /*
  289. Dynamic pointer casting. Down an inheritance hierarchy
  290. */
  291. SWIGRUNTIME swig_type_info *
  292. SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
  293. swig_type_info *lastty = ty;
  294. if (!ty || !ty->dcast) return ty;
  295. while (ty && (ty->dcast)) {
  296. ty = (*ty->dcast)(ptr);
  297. if (ty) lastty = ty;
  298. }
  299. return lastty;
  300. }
  301. /*
  302. Return the name associated with this type
  303. */
  304. SWIGRUNTIMEINLINE const char *
  305. SWIG_TypeName(const swig_type_info *ty) {
  306. return ty->name;
  307. }
  308. /*
  309. Return the pretty name associated with this type,
  310. that is an unmangled type name in a form presentable to the user.
  311. */
  312. SWIGRUNTIME const char *
  313. SWIG_TypePrettyName(const swig_type_info *type) {
  314. /* The "str" field contains the equivalent pretty names of the
  315. type, separated by vertical-bar characters. We choose
  316. to print the last name, as it is often (?) the most
  317. specific. */
  318. if (!type) return NULL;
  319. if (type->str != NULL) {
  320. const char *last_name = type->str;
  321. const char *s;
  322. for (s = type->str; *s; s++)
  323. if (*s == '|') last_name = s+1;
  324. return last_name;
  325. }
  326. else
  327. return type->name;
  328. }
  329. /*
  330. Set the clientdata field for a type
  331. */
  332. SWIGRUNTIME void
  333. SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
  334. swig_cast_info *cast = ti->cast;
  335. /* if (ti->clientdata == clientdata) return; */
  336. ti->clientdata = clientdata;
  337. while (cast) {
  338. if (!cast->converter) {
  339. swig_type_info *tc = cast->type;
  340. if (!tc->clientdata) {
  341. SWIG_TypeClientData(tc, clientdata);
  342. }
  343. }
  344. cast = cast->next;
  345. }
  346. }
  347. SWIGRUNTIME void
  348. SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
  349. SWIG_TypeClientData(ti, clientdata);
  350. ti->owndata = 1;
  351. }
  352. /*
  353. Search for a swig_type_info structure only by mangled name
  354. Search is a O(log #types)
  355. We start searching at module start, and finish searching when start == end.
  356. Note: if start == end at the beginning of the function, we go all the way around
  357. the circular list.
  358. */
  359. SWIGRUNTIME swig_type_info *
  360. SWIG_MangledTypeQueryModule(swig_module_info *start,
  361. swig_module_info *end,
  362. const char *name) {
  363. swig_module_info *iter = start;
  364. do {
  365. if (iter->size) {
  366. register size_t l = 0;
  367. register size_t r = iter->size - 1;
  368. do {
  369. /* since l+r >= 0, we can (>> 1) instead (/ 2) */
  370. register size_t i = (l + r) >> 1;
  371. const char *iname = iter->types[i]->name;
  372. if (iname) {
  373. register int compare = strcmp(name, iname);
  374. if (compare == 0) {
  375. return iter->types[i];
  376. } else if (compare < 0) {
  377. if (i) {
  378. r = i - 1;
  379. } else {
  380. break;
  381. }
  382. } else if (compare > 0) {
  383. l = i + 1;
  384. }
  385. } else {
  386. break; /* should never happen */
  387. }
  388. } while (l <= r);
  389. }
  390. iter = iter->next;
  391. } while (iter != end);
  392. return 0;
  393. }
  394. /*
  395. Search for a swig_type_info structure for either a mangled name or a human readable name.
  396. It first searches the mangled names of the types, which is a O(log #types)
  397. If a type is not found it then searches the human readable names, which is O(#types).
  398. We start searching at module start, and finish searching when start == end.
  399. Note: if start == end at the beginning of the function, we go all the way around
  400. the circular list.
  401. */
  402. SWIGRUNTIME swig_type_info *
  403. SWIG_TypeQueryModule(swig_module_info *start,
  404. swig_module_info *end,
  405. const char *name) {
  406. /* STEP 1: Search the name field using binary search */
  407. swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
  408. if (ret) {
  409. return ret;
  410. } else {
  411. /* STEP 2: If the type hasn't been found, do a complete search
  412. of the str field (the human readable name) */
  413. swig_module_info *iter = start;
  414. do {
  415. register size_t i = 0;
  416. for (; i < iter->size; ++i) {
  417. if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
  418. return iter->types[i];
  419. }
  420. iter = iter->next;
  421. } while (iter != end);
  422. }
  423. /* neither found a match */
  424. return 0;
  425. }
  426. /*
  427. Pack binary data into a string
  428. */
  429. SWIGRUNTIME char *
  430. SWIG_PackData(char *c, void *ptr, size_t sz) {
  431. static const char hex[17] = "0123456789abcdef";
  432. register const unsigned char *u = (unsigned char *) ptr;
  433. register const unsigned char *eu = u + sz;
  434. for (; u != eu; ++u) {
  435. register unsigned char uu = *u;
  436. *(c++) = hex[(uu & 0xf0) >> 4];
  437. *(c++) = hex[uu & 0xf];
  438. }
  439. return c;
  440. }
  441. /*
  442. Unpack binary data from a string
  443. */
  444. SWIGRUNTIME const char *
  445. SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
  446. register unsigned char *u = (unsigned char *) ptr;
  447. register const unsigned char *eu = u + sz;
  448. for (; u != eu; ++u) {
  449. register char d = *(c++);
  450. register unsigned char uu;
  451. if ((d >= '0') && (d <= '9'))
  452. uu = ((d - '0') << 4);
  453. else if ((d >= 'a') && (d <= 'f'))
  454. uu = ((d - ('a'-10)) << 4);
  455. else
  456. return (char *) 0;
  457. d = *(c++);
  458. if ((d >= '0') && (d <= '9'))
  459. uu |= (d - '0');
  460. else if ((d >= 'a') && (d <= 'f'))
  461. uu |= (d - ('a'-10));
  462. else
  463. return (char *) 0;
  464. *u = uu;
  465. }
  466. return c;
  467. }
  468. /*
  469. Pack 'void *' into a string buffer.
  470. */
  471. SWIGRUNTIME char *
  472. SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
  473. char *r = buff;
  474. if ((2*sizeof(void *) + 2) > bsz) return 0;
  475. *(r++) = '_';
  476. r = SWIG_PackData(r,&ptr,sizeof(void *));
  477. if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
  478. strcpy(r,name);
  479. return buff;
  480. }
  481. SWIGRUNTIME const char *
  482. SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
  483. if (*c != '_') {
  484. if (strcmp(c,"NULL") == 0) {
  485. *ptr = (void *) 0;
  486. return name;
  487. } else {
  488. return 0;
  489. }
  490. }
  491. return SWIG_UnpackData(++c,ptr,sizeof(void *));
  492. }
  493. SWIGRUNTIME char *
  494. SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
  495. char *r = buff;
  496. size_t lname = (name ? strlen(name) : 0);
  497. if ((2*sz + 2 + lname) > bsz) return 0;
  498. *(r++) = '_';
  499. r = SWIG_PackData(r,ptr,sz);
  500. if (lname) {
  501. strncpy(r,name,lname+1);
  502. } else {
  503. *r = 0;
  504. }
  505. return buff;
  506. }
  507. SWIGRUNTIME const char *
  508. SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
  509. if (*c != '_') {
  510. if (strcmp(c,"NULL") == 0) {
  511. memset(ptr,0,sz);
  512. return name;
  513. } else {
  514. return 0;
  515. }
  516. }
  517. return SWIG_UnpackData(++c,ptr,sz);
  518. }
  519. #ifdef __cplusplus
  520. }
  521. #endif