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