Line data Source code
1 : /* ----------------------------------------------------------------------------
2 : * This file was automatically generated by SWIG (http://www.swig.org).
3 : * Version 4.0.1
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 :
12 : #ifndef SWIGPYTHON
13 : #define SWIGPYTHON
14 : #define SED_HACKS
15 : #endif
16 :
17 : #define SWIG_PYTHON_THREADS
18 : #define SWIG_PYTHON_DIRECTOR_NO_VTABLE
19 :
20 :
21 : #ifdef __cplusplus
22 : /* SwigValueWrapper is described in swig.swg */
23 : template<typename T> class SwigValueWrapper {
24 : struct SwigMovePointer {
25 : T *ptr;
26 : SwigMovePointer(T *p) : ptr(p) { }
27 : ~SwigMovePointer() { delete ptr; }
28 : SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
29 : } pointer;
30 : SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
31 : SwigValueWrapper(const SwigValueWrapper<T>& rhs);
32 : public:
33 : SwigValueWrapper() : pointer(0) { }
34 : SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
35 : operator T&() const { return *pointer.ptr; }
36 : T *operator&() { return pointer.ptr; }
37 : };
38 :
39 : template <typename T> T SwigValueInit() {
40 : return T();
41 : }
42 : #endif
43 :
44 : /* -----------------------------------------------------------------------------
45 : * This section contains generic SWIG labels for method/variable
46 : * declarations/attributes, and other compiler dependent labels.
47 : * ----------------------------------------------------------------------------- */
48 :
49 : /* template workaround for compilers that cannot correctly implement the C++ standard */
50 : #ifndef SWIGTEMPLATEDISAMBIGUATOR
51 : # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
52 : # define SWIGTEMPLATEDISAMBIGUATOR template
53 : # elif defined(__HP_aCC)
54 : /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
55 : /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
56 : # define SWIGTEMPLATEDISAMBIGUATOR template
57 : # else
58 : # define SWIGTEMPLATEDISAMBIGUATOR
59 : # endif
60 : #endif
61 :
62 : /* inline attribute */
63 : #ifndef SWIGINLINE
64 : # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
65 : # define SWIGINLINE inline
66 : # else
67 : # define SWIGINLINE
68 : # endif
69 : #endif
70 :
71 : /* attribute recognised by some compilers to avoid 'unused' warnings */
72 : #ifndef SWIGUNUSED
73 : # if defined(__GNUC__)
74 : # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
75 : # define SWIGUNUSED __attribute__ ((__unused__))
76 : # else
77 : # define SWIGUNUSED
78 : # endif
79 : # elif defined(__ICC)
80 : # define SWIGUNUSED __attribute__ ((__unused__))
81 : # else
82 : # define SWIGUNUSED
83 : # endif
84 : #endif
85 :
86 : #ifndef SWIG_MSC_UNSUPPRESS_4505
87 : # if defined(_MSC_VER)
88 : # pragma warning(disable : 4505) /* unreferenced local function has been removed */
89 : # endif
90 : #endif
91 :
92 : #ifndef SWIGUNUSEDPARM
93 : # ifdef __cplusplus
94 : # define SWIGUNUSEDPARM(p)
95 : # else
96 : # define SWIGUNUSEDPARM(p) p SWIGUNUSED
97 : # endif
98 : #endif
99 :
100 : /* internal SWIG method */
101 : #ifndef SWIGINTERN
102 : # define SWIGINTERN static SWIGUNUSED
103 : #endif
104 :
105 : /* internal inline SWIG method */
106 : #ifndef SWIGINTERNINLINE
107 : # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
108 : #endif
109 :
110 : /* exporting methods */
111 : #if defined(__GNUC__)
112 : # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
113 : # ifndef GCC_HASCLASSVISIBILITY
114 : # define GCC_HASCLASSVISIBILITY
115 : # endif
116 : # endif
117 : #endif
118 :
119 : #ifndef SWIGEXPORT
120 : # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
121 : # if defined(STATIC_LINKED)
122 : # define SWIGEXPORT
123 : # else
124 : # define SWIGEXPORT __declspec(dllexport)
125 : # endif
126 : # else
127 : # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
128 : # define SWIGEXPORT __attribute__ ((visibility("default")))
129 : # else
130 : # define SWIGEXPORT
131 : # endif
132 : # endif
133 : #endif
134 :
135 : /* calling conventions for Windows */
136 : #ifndef SWIGSTDCALL
137 : # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
138 : # define SWIGSTDCALL __stdcall
139 : # else
140 : # define SWIGSTDCALL
141 : # endif
142 : #endif
143 :
144 : /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
145 : #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
146 : # define _CRT_SECURE_NO_DEPRECATE
147 : #endif
148 :
149 : /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
150 : #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
151 : # define _SCL_SECURE_NO_DEPRECATE
152 : #endif
153 :
154 : /* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
155 : #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
156 : # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
157 : #endif
158 :
159 : /* Intel's compiler complains if a variable which was never initialised is
160 : * cast to void, which is a common idiom which we use to indicate that we
161 : * are aware a variable isn't used. So we just silence that warning.
162 : * See: https://github.com/swig/swig/issues/192 for more discussion.
163 : */
164 : #ifdef __INTEL_COMPILER
165 : # pragma warning disable 592
166 : #endif
167 :
168 :
169 : #if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND)
170 : /* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */
171 : # include <math.h>
172 : #endif
173 :
174 : #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
175 : /* Use debug wrappers with the Python release dll */
176 : # undef _DEBUG
177 : # include <Python.h>
178 : # define _DEBUG 1
179 : #else
180 : # include <Python.h>
181 : #endif
182 :
183 : /* -----------------------------------------------------------------------------
184 : * swigrun.swg
185 : *
186 : * This file contains generic C API SWIG runtime support for pointer
187 : * type checking.
188 : * ----------------------------------------------------------------------------- */
189 :
190 : /* This should only be incremented when either the layout of swig_type_info changes,
191 : or for whatever reason, the runtime changes incompatibly */
192 : #define SWIG_RUNTIME_VERSION "4"
193 :
194 : /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
195 : #ifdef SWIG_TYPE_TABLE
196 : # define SWIG_QUOTE_STRING(x) #x
197 : # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
198 : # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
199 : #else
200 : # define SWIG_TYPE_TABLE_NAME
201 : #endif
202 :
203 : /*
204 : You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
205 : creating a static or dynamic library from the SWIG runtime code.
206 : In 99.9% of the cases, SWIG just needs to declare them as 'static'.
207 :
208 : But only do this if strictly necessary, ie, if you have problems
209 : with your compiler or suchlike.
210 : */
211 :
212 : #ifndef SWIGRUNTIME
213 : # define SWIGRUNTIME SWIGINTERN
214 : #endif
215 :
216 : #ifndef SWIGRUNTIMEINLINE
217 : # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
218 : #endif
219 :
220 : /* Generic buffer size */
221 : #ifndef SWIG_BUFFER_SIZE
222 : # define SWIG_BUFFER_SIZE 1024
223 : #endif
224 :
225 : /* Flags for pointer conversions */
226 : #define SWIG_POINTER_DISOWN 0x1
227 : #define SWIG_CAST_NEW_MEMORY 0x2
228 : #define SWIG_POINTER_NO_NULL 0x4
229 :
230 : /* Flags for new pointer objects */
231 : #define SWIG_POINTER_OWN 0x1
232 :
233 :
234 : /*
235 : Flags/methods for returning states.
236 :
237 : The SWIG conversion methods, as ConvertPtr, return an integer
238 : that tells if the conversion was successful or not. And if not,
239 : an error code can be returned (see swigerrors.swg for the codes).
240 :
241 : Use the following macros/flags to set or process the returning
242 : states.
243 :
244 : In old versions of SWIG, code such as the following was usually written:
245 :
246 : if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
247 : // success code
248 : } else {
249 : //fail code
250 : }
251 :
252 : Now you can be more explicit:
253 :
254 : int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
255 : if (SWIG_IsOK(res)) {
256 : // success code
257 : } else {
258 : // fail code
259 : }
260 :
261 : which is the same really, but now you can also do
262 :
263 : Type *ptr;
264 : int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
265 : if (SWIG_IsOK(res)) {
266 : // success code
267 : if (SWIG_IsNewObj(res) {
268 : ...
269 : delete *ptr;
270 : } else {
271 : ...
272 : }
273 : } else {
274 : // fail code
275 : }
276 :
277 : I.e., now SWIG_ConvertPtr can return new objects and you can
278 : identify the case and take care of the deallocation. Of course that
279 : also requires SWIG_ConvertPtr to return new result values, such as
280 :
281 : int SWIG_ConvertPtr(obj, ptr,...) {
282 : if (<obj is ok>) {
283 : if (<need new object>) {
284 : *ptr = <ptr to new allocated object>;
285 : return SWIG_NEWOBJ;
286 : } else {
287 : *ptr = <ptr to old object>;
288 : return SWIG_OLDOBJ;
289 : }
290 : } else {
291 : return SWIG_BADOBJ;
292 : }
293 : }
294 :
295 : Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
296 : more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
297 : SWIG errors code.
298 :
299 : Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
300 : allows to return the 'cast rank', for example, if you have this
301 :
302 : int food(double)
303 : int fooi(int);
304 :
305 : and you call
306 :
307 : food(1) // cast rank '1' (1 -> 1.0)
308 : fooi(1) // cast rank '0'
309 :
310 : just use the SWIG_AddCast()/SWIG_CheckState()
311 : */
312 :
313 : #define SWIG_OK (0)
314 : #define SWIG_ERROR (-1)
315 : #define SWIG_IsOK(r) (r >= 0)
316 : #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
317 :
318 : /* The CastRankLimit says how many bits are used for the cast rank */
319 : #define SWIG_CASTRANKLIMIT (1 << 8)
320 : /* The NewMask denotes the object was created (using new/malloc) */
321 : #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
322 : /* The TmpMask is for in/out typemaps that use temporal objects */
323 : #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
324 : /* Simple returning values */
325 : #define SWIG_BADOBJ (SWIG_ERROR)
326 : #define SWIG_OLDOBJ (SWIG_OK)
327 : #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
328 : #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
329 : /* Check, add and del mask methods */
330 : #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
331 : #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
332 : #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
333 : #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
334 : #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
335 : #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
336 :
337 : /* Cast-Rank Mode */
338 : #if defined(SWIG_CASTRANK_MODE)
339 : # ifndef SWIG_TypeRank
340 : # define SWIG_TypeRank unsigned long
341 : # endif
342 : # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
343 : # define SWIG_MAXCASTRANK (2)
344 : # endif
345 : # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
346 : # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
347 : SWIGINTERNINLINE int SWIG_AddCast(int r) {
348 : return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
349 : }
350 : SWIGINTERNINLINE int SWIG_CheckState(int r) {
351 : return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
352 : }
353 : #else /* no cast-rank mode */
354 : # define SWIG_AddCast(r) (r)
355 : # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
356 : #endif
357 :
358 :
359 : #include <string.h>
360 :
361 : #ifdef __cplusplus
362 : extern "C" {
363 : #endif
364 :
365 : typedef void *(*swig_converter_func)(void *, int *);
366 : typedef struct swig_type_info *(*swig_dycast_func)(void **);
367 :
368 : /* Structure to store information on one type */
369 : typedef struct swig_type_info {
370 : const char *name; /* mangled name of this type */
371 : const char *str; /* human readable name of this type */
372 : swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
373 : struct swig_cast_info *cast; /* linked list of types that can cast into this type */
374 : void *clientdata; /* language specific type data */
375 : int owndata; /* flag if the structure owns the clientdata */
376 : } swig_type_info;
377 :
378 : /* Structure to store a type and conversion function used for casting */
379 : typedef struct swig_cast_info {
380 : swig_type_info *type; /* pointer to type that is equivalent to this type */
381 : swig_converter_func converter; /* function to cast the void pointers */
382 : struct swig_cast_info *next; /* pointer to next cast in linked list */
383 : struct swig_cast_info *prev; /* pointer to the previous cast */
384 : } swig_cast_info;
385 :
386 : /* Structure used to store module information
387 : * Each module generates one structure like this, and the runtime collects
388 : * all of these structures and stores them in a circularly linked list.*/
389 : typedef struct swig_module_info {
390 : swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
391 : size_t size; /* Number of types in this module */
392 : struct swig_module_info *next; /* Pointer to next element in circularly linked list */
393 : swig_type_info **type_initial; /* Array of initially generated type structures */
394 : swig_cast_info **cast_initial; /* Array of initially generated casting structures */
395 : void *clientdata; /* Language specific module data */
396 : } swig_module_info;
397 :
398 : /*
399 : Compare two type names skipping the space characters, therefore
400 : "char*" == "char *" and "Class<int>" == "Class<int >", etc.
401 :
402 : Return 0 when the two name types are equivalent, as in
403 : strncmp, but skipping ' '.
404 : */
405 : SWIGRUNTIME int
406 0 : SWIG_TypeNameComp(const char *f1, const char *l1,
407 : const char *f2, const char *l2) {
408 0 : for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
409 0 : while ((*f1 == ' ') && (f1 != l1)) ++f1;
410 0 : while ((*f2 == ' ') && (f2 != l2)) ++f2;
411 0 : if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
412 : }
413 0 : return (int)((l1 - f1) - (l2 - f2));
414 : }
415 :
416 : /*
417 : Check type equivalence in a name list like <name1>|<name2>|...
418 : Return 0 if equal, -1 if nb < tb, 1 if nb > tb
419 : */
420 : SWIGRUNTIME int
421 0 : SWIG_TypeCmp(const char *nb, const char *tb) {
422 0 : int equiv = 1;
423 0 : const char* te = tb + strlen(tb);
424 0 : const char* ne = nb;
425 0 : while (equiv != 0 && *ne) {
426 0 : for (nb = ne; *ne; ++ne) {
427 0 : if (*ne == '|') break;
428 : }
429 0 : equiv = SWIG_TypeNameComp(nb, ne, tb, te);
430 0 : if (*ne) ++ne;
431 : }
432 0 : return equiv;
433 : }
434 :
435 : /*
436 : Check type equivalence in a name list like <name1>|<name2>|...
437 : Return 0 if not equal, 1 if equal
438 : */
439 : SWIGRUNTIME int
440 0 : SWIG_TypeEquiv(const char *nb, const char *tb) {
441 0 : return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
442 : }
443 :
444 : /*
445 : Check the typename
446 : */
447 : SWIGRUNTIME swig_cast_info *
448 3600 : SWIG_TypeCheck(const char *c, swig_type_info *ty) {
449 3600 : if (ty) {
450 3600 : swig_cast_info *iter = ty->cast;
451 3600 : while (iter) {
452 3600 : if (strcmp(iter->type->name, c) == 0) {
453 3600 : if (iter == ty->cast)
454 : return iter;
455 : /* Move iter to the top of the linked list */
456 0 : iter->prev->next = iter->next;
457 0 : if (iter->next)
458 0 : iter->next->prev = iter->prev;
459 0 : iter->next = ty->cast;
460 0 : iter->prev = 0;
461 0 : if (ty->cast) ty->cast->prev = iter;
462 0 : ty->cast = iter;
463 0 : return iter;
464 : }
465 0 : iter = iter->next;
466 : }
467 : }
468 : return 0;
469 : }
470 :
471 : /*
472 : Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
473 : */
474 : SWIGRUNTIME swig_cast_info *
475 : SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
476 : if (ty) {
477 : swig_cast_info *iter = ty->cast;
478 : while (iter) {
479 : if (iter->type == from) {
480 : if (iter == ty->cast)
481 : return iter;
482 : /* Move iter to the top of the linked list */
483 : iter->prev->next = iter->next;
484 : if (iter->next)
485 : iter->next->prev = iter->prev;
486 : iter->next = ty->cast;
487 : iter->prev = 0;
488 : if (ty->cast) ty->cast->prev = iter;
489 : ty->cast = iter;
490 : return iter;
491 : }
492 : iter = iter->next;
493 : }
494 : }
495 : return 0;
496 : }
497 :
498 : /*
499 : Cast a pointer up an inheritance hierarchy
500 : */
501 : SWIGRUNTIMEINLINE void *
502 0 : SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
503 0 : return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
504 : }
505 :
506 : /*
507 : Dynamic pointer casting. Down an inheritance hierarchy
508 : */
509 : SWIGRUNTIME swig_type_info *
510 : SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
511 : swig_type_info *lastty = ty;
512 : if (!ty || !ty->dcast) return ty;
513 : while (ty && (ty->dcast)) {
514 : ty = (*ty->dcast)(ptr);
515 : if (ty) lastty = ty;
516 : }
517 : return lastty;
518 : }
519 :
520 : /*
521 : Return the name associated with this type
522 : */
523 : SWIGRUNTIMEINLINE const char *
524 : SWIG_TypeName(const swig_type_info *ty) {
525 : return ty->name;
526 : }
527 :
528 : /*
529 : Return the pretty name associated with this type,
530 : that is an unmangled type name in a form presentable to the user.
531 : */
532 : SWIGRUNTIME const char *
533 0 : SWIG_TypePrettyName(const swig_type_info *type) {
534 : /* The "str" field contains the equivalent pretty names of the
535 : type, separated by vertical-bar characters. We choose
536 : to print the last name, as it is often (?) the most
537 : specific. */
538 0 : if (!type) return NULL;
539 0 : if (type->str != NULL) {
540 : const char *last_name = type->str;
541 : const char *s;
542 0 : for (s = type->str; *s; s++)
543 0 : if (*s == '|') last_name = s+1;
544 : return last_name;
545 : }
546 : else
547 0 : return type->name;
548 : }
549 :
550 : /*
551 : Set the clientdata field for a type
552 : */
553 : SWIGRUNTIME void
554 : SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
555 : swig_cast_info *cast = ti->cast;
556 : /* if (ti->clientdata == clientdata) return; */
557 : ti->clientdata = clientdata;
558 :
559 : while (cast) {
560 : if (!cast->converter) {
561 : swig_type_info *tc = cast->type;
562 : if (!tc->clientdata) {
563 : SWIG_TypeClientData(tc, clientdata);
564 : }
565 : }
566 : cast = cast->next;
567 : }
568 : }
569 : SWIGRUNTIME void
570 225 : SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
571 225 : SWIG_TypeClientData(ti, clientdata);
572 225 : ti->owndata = 1;
573 : }
574 :
575 : /*
576 : Search for a swig_type_info structure only by mangled name
577 : Search is a O(log #types)
578 :
579 : We start searching at module start, and finish searching when start == end.
580 : Note: if start == end at the beginning of the function, we go all the way around
581 : the circular list.
582 : */
583 : SWIGRUNTIME swig_type_info *
584 9000 : SWIG_MangledTypeQueryModule(swig_module_info *start,
585 : swig_module_info *end,
586 : const char *name) {
587 9000 : swig_module_info *iter = start;
588 27000 : do {
589 27000 : if (iter->size) {
590 27000 : size_t l = 0;
591 27000 : size_t r = iter->size - 1;
592 108900 : do {
593 : /* since l+r >= 0, we can (>> 1) instead (/ 2) */
594 108900 : size_t i = (l + r) >> 1;
595 108900 : const char *iname = iter->types[i]->name;
596 108900 : if (iname) {
597 108900 : int compare = strcmp(name, iname);
598 108900 : if (compare == 0) {
599 7200 : return iter->types[i];
600 101700 : } else if (compare < 0) {
601 53550 : if (i) {
602 44550 : r = i - 1;
603 : } else {
604 : break;
605 : }
606 48150 : } else if (compare > 0) {
607 48150 : l = i + 1;
608 : }
609 : } else {
610 : break; /* should never happen */
611 : }
612 92700 : } while (l <= r);
613 : }
614 19800 : iter = iter->next;
615 19800 : } while (iter != end);
616 : return 0;
617 : }
618 :
619 : /*
620 : Search for a swig_type_info structure for either a mangled name or a human readable name.
621 : It first searches the mangled names of the types, which is a O(log #types)
622 : If a type is not found it then searches the human readable names, which is O(#types).
623 :
624 : We start searching at module start, and finish searching when start == end.
625 : Note: if start == end at the beginning of the function, we go all the way around
626 : the circular list.
627 : */
628 : SWIGRUNTIME swig_type_info *
629 0 : SWIG_TypeQueryModule(swig_module_info *start,
630 : swig_module_info *end,
631 : const char *name) {
632 : /* STEP 1: Search the name field using binary search */
633 0 : swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
634 0 : if (ret) {
635 : return ret;
636 : } else {
637 : /* STEP 2: If the type hasn't been found, do a complete search
638 : of the str field (the human readable name) */
639 : swig_module_info *iter = start;
640 0 : do {
641 0 : size_t i = 0;
642 0 : for (; i < iter->size; ++i) {
643 0 : if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
644 0 : return iter->types[i];
645 : }
646 0 : iter = iter->next;
647 0 : } while (iter != end);
648 : }
649 :
650 : /* neither found a match */
651 : return 0;
652 : }
653 :
654 : /*
655 : Pack binary data into a string
656 : */
657 : SWIGRUNTIME char *
658 0 : SWIG_PackData(char *c, void *ptr, size_t sz) {
659 0 : static const char hex[17] = "0123456789abcdef";
660 0 : const unsigned char *u = (unsigned char *) ptr;
661 0 : const unsigned char *eu = u + sz;
662 0 : for (; u != eu; ++u) {
663 0 : unsigned char uu = *u;
664 0 : *(c++) = hex[(uu & 0xf0) >> 4];
665 0 : *(c++) = hex[uu & 0xf];
666 : }
667 0 : return c;
668 : }
669 :
670 : /*
671 : Unpack binary data from a string
672 : */
673 : SWIGRUNTIME const char *
674 : SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
675 : unsigned char *u = (unsigned char *) ptr;
676 : const unsigned char *eu = u + sz;
677 : for (; u != eu; ++u) {
678 : char d = *(c++);
679 : unsigned char uu;
680 : if ((d >= '0') && (d <= '9'))
681 : uu = (unsigned char)((d - '0') << 4);
682 : else if ((d >= 'a') && (d <= 'f'))
683 : uu = (unsigned char)((d - ('a'-10)) << 4);
684 : else
685 : return (char *) 0;
686 : d = *(c++);
687 : if ((d >= '0') && (d <= '9'))
688 : uu |= (unsigned char)(d - '0');
689 : else if ((d >= 'a') && (d <= 'f'))
690 : uu |= (unsigned char)(d - ('a'-10));
691 : else
692 : return (char *) 0;
693 : *u = uu;
694 : }
695 : return c;
696 : }
697 :
698 : /*
699 : Pack 'void *' into a string buffer.
700 : */
701 : SWIGRUNTIME char *
702 0 : SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
703 0 : char *r = buff;
704 0 : if ((2*sizeof(void *) + 2) > bsz) return 0;
705 0 : *(r++) = '_';
706 0 : r = SWIG_PackData(r,&ptr,sizeof(void *));
707 0 : if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
708 0 : strcpy(r,name);
709 0 : return buff;
710 : }
711 :
712 : SWIGRUNTIME const char *
713 : SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
714 : if (*c != '_') {
715 : if (strcmp(c,"NULL") == 0) {
716 : *ptr = (void *) 0;
717 : return name;
718 : } else {
719 : return 0;
720 : }
721 : }
722 : return SWIG_UnpackData(++c,ptr,sizeof(void *));
723 : }
724 :
725 : SWIGRUNTIME char *
726 0 : SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
727 0 : char *r = buff;
728 0 : size_t lname = (name ? strlen(name) : 0);
729 0 : if ((2*sz + 2 + lname) > bsz) return 0;
730 0 : *(r++) = '_';
731 0 : r = SWIG_PackData(r,ptr,sz);
732 0 : if (lname) {
733 0 : strncpy(r,name,lname+1);
734 : } else {
735 0 : *r = 0;
736 : }
737 : return buff;
738 : }
739 :
740 : SWIGRUNTIME const char *
741 : SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
742 : if (*c != '_') {
743 : if (strcmp(c,"NULL") == 0) {
744 : memset(ptr,0,sz);
745 : return name;
746 : } else {
747 : return 0;
748 : }
749 : }
750 : return SWIG_UnpackData(++c,ptr,sz);
751 : }
752 :
753 : #ifdef __cplusplus
754 : }
755 : #endif
756 :
757 : /* Errors in SWIG */
758 : #define SWIG_UnknownError -1
759 : #define SWIG_IOError -2
760 : #define SWIG_RuntimeError -3
761 : #define SWIG_IndexError -4
762 : #define SWIG_TypeError -5
763 : #define SWIG_DivisionByZero -6
764 : #define SWIG_OverflowError -7
765 : #define SWIG_SyntaxError -8
766 : #define SWIG_ValueError -9
767 : #define SWIG_SystemError -10
768 : #define SWIG_AttributeError -11
769 : #define SWIG_MemoryError -12
770 : #define SWIG_NullReferenceError -13
771 :
772 :
773 :
774 : /* Compatibility macros for Python 3 */
775 : #if PY_VERSION_HEX >= 0x03000000
776 :
777 : #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
778 : #define PyInt_Check(x) PyLong_Check(x)
779 : #define PyInt_AsLong(x) PyLong_AsLong(x)
780 : #define PyInt_FromLong(x) PyLong_FromLong(x)
781 : #define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
782 : #define PyString_Check(name) PyBytes_Check(name)
783 : #define PyString_FromString(x) PyUnicode_FromString(x)
784 : #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
785 : #define PyString_AsString(str) PyBytes_AsString(str)
786 : #define PyString_Size(str) PyBytes_Size(str)
787 : #define PyString_InternFromString(key) PyUnicode_InternFromString(key)
788 : #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
789 : #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
790 : #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
791 :
792 : #endif
793 :
794 : #ifndef Py_TYPE
795 : # define Py_TYPE(op) ((op)->ob_type)
796 : #endif
797 :
798 : /* SWIG APIs for compatibility of both Python 2 & 3 */
799 :
800 : #if PY_VERSION_HEX >= 0x03000000
801 : # define SWIG_Python_str_FromFormat PyUnicode_FromFormat
802 : #else
803 : # define SWIG_Python_str_FromFormat PyString_FromFormat
804 : #endif
805 :
806 :
807 : /* Warning: This function will allocate a new string in Python 3,
808 : * so please call SWIG_Python_str_DelForPy3(x) to free the space.
809 : */
810 : SWIGINTERN char*
811 : SWIG_Python_str_AsChar(PyObject *str)
812 : {
813 : #if PY_VERSION_HEX >= 0x03000000
814 : char *newstr = 0;
815 : str = PyUnicode_AsUTF8String(str);
816 : if (str) {
817 : char *cstr;
818 : Py_ssize_t len;
819 : PyBytes_AsStringAndSize(str, &cstr, &len);
820 : newstr = (char *) malloc(len+1);
821 : memcpy(newstr, cstr, len+1);
822 : Py_XDECREF(str);
823 : }
824 : return newstr;
825 : #else
826 : return PyString_AsString(str);
827 : #endif
828 : }
829 :
830 : #if PY_VERSION_HEX >= 0x03000000
831 : # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
832 : #else
833 : # define SWIG_Python_str_DelForPy3(x)
834 : #endif
835 :
836 :
837 : SWIGINTERN PyObject*
838 225 : SWIG_Python_str_FromChar(const char *c)
839 : {
840 : #if PY_VERSION_HEX >= 0x03000000
841 225 : return PyUnicode_FromString(c);
842 : #else
843 : return PyString_FromString(c);
844 : #endif
845 : }
846 :
847 : #ifndef PyObject_DEL
848 : # define PyObject_DEL PyObject_Del
849 : #endif
850 :
851 : // SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user
852 : // interface files check for it.
853 : # define SWIGPY_USE_CAPSULE
854 : # define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
855 :
856 : #if PY_VERSION_HEX < 0x03020000
857 : #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
858 : #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
859 : #define Py_hash_t long
860 : #endif
861 :
862 : /* -----------------------------------------------------------------------------
863 : * error manipulation
864 : * ----------------------------------------------------------------------------- */
865 :
866 : SWIGRUNTIME PyObject*
867 11 : SWIG_Python_ErrorType(int code) {
868 11 : PyObject* type = 0;
869 2 : switch(code) {
870 0 : case SWIG_MemoryError:
871 0 : type = PyExc_MemoryError;
872 0 : break;
873 0 : case SWIG_IOError:
874 0 : type = PyExc_IOError;
875 0 : break;
876 5 : case SWIG_RuntimeError:
877 5 : type = PyExc_RuntimeError;
878 0 : break;
879 0 : case SWIG_IndexError:
880 0 : type = PyExc_IndexError;
881 0 : break;
882 2 : case SWIG_TypeError:
883 2 : type = PyExc_TypeError;
884 2 : break;
885 0 : case SWIG_DivisionByZero:
886 0 : type = PyExc_ZeroDivisionError;
887 0 : break;
888 0 : case SWIG_OverflowError:
889 0 : type = PyExc_OverflowError;
890 0 : break;
891 0 : case SWIG_SyntaxError:
892 0 : type = PyExc_SyntaxError;
893 0 : break;
894 4 : case SWIG_ValueError:
895 4 : type = PyExc_ValueError;
896 0 : break;
897 0 : case SWIG_SystemError:
898 0 : type = PyExc_SystemError;
899 0 : break;
900 0 : case SWIG_AttributeError:
901 0 : type = PyExc_AttributeError;
902 0 : break;
903 0 : default:
904 0 : type = PyExc_RuntimeError;
905 : }
906 11 : return type;
907 : }
908 :
909 :
910 : SWIGRUNTIME void
911 : SWIG_Python_AddErrorMsg(const char* mesg)
912 : {
913 : PyObject *type = 0;
914 : PyObject *value = 0;
915 : PyObject *traceback = 0;
916 :
917 : if (PyErr_Occurred())
918 : PyErr_Fetch(&type, &value, &traceback);
919 : if (value) {
920 : PyObject *old_str = PyObject_Str(value);
921 : const char *tmp = SWIG_Python_str_AsChar(old_str);
922 : PyErr_Clear();
923 : Py_XINCREF(type);
924 : if (tmp)
925 : PyErr_Format(type, "%s %s", tmp, mesg);
926 : else
927 : PyErr_Format(type, "%s", mesg);
928 : SWIG_Python_str_DelForPy3(tmp);
929 : Py_DECREF(old_str);
930 : Py_DECREF(value);
931 : } else {
932 : PyErr_SetString(PyExc_RuntimeError, mesg);
933 : }
934 : }
935 :
936 : SWIGRUNTIME int
937 0 : SWIG_Python_TypeErrorOccurred(PyObject *obj)
938 : {
939 0 : PyObject *error;
940 0 : if (obj)
941 : return 0;
942 0 : error = PyErr_Occurred();
943 0 : return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError);
944 : }
945 :
946 : SWIGRUNTIME void
947 0 : SWIG_Python_RaiseOrModifyTypeError(const char *message)
948 : {
949 0 : if (SWIG_Python_TypeErrorOccurred(NULL)) {
950 : /* Use existing TypeError to preserve stacktrace and enhance with given message */
951 0 : PyObject *newvalue;
952 0 : PyObject *type = NULL, *value = NULL, *traceback = NULL;
953 0 : PyErr_Fetch(&type, &value, &traceback);
954 : #if PY_VERSION_HEX >= 0x03000000
955 0 : newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message);
956 : #else
957 : newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message);
958 : #endif
959 0 : Py_XDECREF(value);
960 0 : PyErr_Restore(type, newvalue, traceback);
961 : } else {
962 : /* Raise TypeError using given message */
963 0 : PyErr_SetString(PyExc_TypeError, message);
964 : }
965 0 : }
966 :
967 : #if defined(SWIG_PYTHON_NO_THREADS)
968 : # if defined(SWIG_PYTHON_THREADS)
969 : # undef SWIG_PYTHON_THREADS
970 : # endif
971 : #endif
972 : #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
973 : # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
974 : # define SWIG_PYTHON_USE_GIL
975 : # endif
976 : # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
977 : # ifndef SWIG_PYTHON_INITIALIZE_THREADS
978 : # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
979 : # endif
980 : # ifdef __cplusplus /* C++ code */
981 : class SWIG_Python_Thread_Block {
982 : bool status;
983 : PyGILState_STATE state;
984 : public:
985 902 : void end() { if (status) { PyGILState_Release(state); status = false;} }
986 638 : SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
987 264 : ~SWIG_Python_Thread_Block() { end(); }
988 : };
989 : class SWIG_Python_Thread_Allow {
990 : bool status;
991 : PyThreadState *save;
992 : public:
993 68458 : void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
994 68458 : SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
995 0 : ~SWIG_Python_Thread_Allow() { end(); }
996 : };
997 : # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
998 : # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
999 : # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
1000 : # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
1001 : # else /* C code */
1002 : # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
1003 : # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
1004 : # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
1005 : # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
1006 : # endif
1007 : # else /* Old thread way, not implemented, user must provide it */
1008 : # if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
1009 : # define SWIG_PYTHON_INITIALIZE_THREADS
1010 : # endif
1011 : # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
1012 : # define SWIG_PYTHON_THREAD_BEGIN_BLOCK
1013 : # endif
1014 : # if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
1015 : # define SWIG_PYTHON_THREAD_END_BLOCK
1016 : # endif
1017 : # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
1018 : # define SWIG_PYTHON_THREAD_BEGIN_ALLOW
1019 : # endif
1020 : # if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
1021 : # define SWIG_PYTHON_THREAD_END_ALLOW
1022 : # endif
1023 : # endif
1024 : #else /* No thread support */
1025 : # define SWIG_PYTHON_INITIALIZE_THREADS
1026 : # define SWIG_PYTHON_THREAD_BEGIN_BLOCK
1027 : # define SWIG_PYTHON_THREAD_END_BLOCK
1028 : # define SWIG_PYTHON_THREAD_BEGIN_ALLOW
1029 : # define SWIG_PYTHON_THREAD_END_ALLOW
1030 : #endif
1031 :
1032 : /* -----------------------------------------------------------------------------
1033 : * Python API portion that goes into the runtime
1034 : * ----------------------------------------------------------------------------- */
1035 :
1036 : #ifdef __cplusplus
1037 : extern "C" {
1038 : #endif
1039 :
1040 : /* -----------------------------------------------------------------------------
1041 : * Constant declarations
1042 : * ----------------------------------------------------------------------------- */
1043 :
1044 : /* Constant Types */
1045 : #define SWIG_PY_POINTER 4
1046 : #define SWIG_PY_BINARY 5
1047 :
1048 : /* Constant information structure */
1049 : typedef struct swig_const_info {
1050 : int type;
1051 : const char *name;
1052 : long lvalue;
1053 : double dvalue;
1054 : void *pvalue;
1055 : swig_type_info **ptype;
1056 : } swig_const_info;
1057 :
1058 : #ifdef __cplusplus
1059 : }
1060 : #endif
1061 :
1062 :
1063 : /* -----------------------------------------------------------------------------
1064 : * pyrun.swg
1065 : *
1066 : * This file contains the runtime support for Python modules
1067 : * and includes code for managing global variables and pointer
1068 : * type checking.
1069 : *
1070 : * ----------------------------------------------------------------------------- */
1071 :
1072 : #if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */
1073 : # error "This version of SWIG only supports Python >= 2.7"
1074 : #endif
1075 :
1076 : #if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000
1077 : # error "This version of SWIG only supports Python 3 >= 3.2"
1078 : #endif
1079 :
1080 : /* Common SWIG API */
1081 :
1082 : /* for raw pointers */
1083 : #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1084 : #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
1085 : #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1086 :
1087 : #ifdef SWIGPYTHON_BUILTIN
1088 : #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
1089 : #else
1090 : #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
1091 : #endif
1092 :
1093 : #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
1094 :
1095 : #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
1096 : #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
1097 : #define swig_owntype int
1098 :
1099 : /* for raw packed data */
1100 : #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1101 : #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
1102 :
1103 : /* for class or struct pointers */
1104 : #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
1105 : #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
1106 :
1107 : /* for C or C++ function pointers */
1108 : #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
1109 : #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
1110 :
1111 : /* for C++ member pointers, ie, member methods */
1112 : #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1113 : #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
1114 :
1115 :
1116 : /* Runtime API */
1117 :
1118 : #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata)
1119 : #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
1120 : #define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
1121 :
1122 : #define SWIG_SetErrorObj SWIG_Python_SetErrorObj
1123 : #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
1124 : #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
1125 : #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
1126 : #define SWIG_fail goto fail
1127 :
1128 :
1129 : /* Runtime API implementation */
1130 :
1131 : /* Error manipulation */
1132 :
1133 : SWIGINTERN void
1134 : SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
1135 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1136 : PyErr_SetObject(errtype, obj);
1137 : Py_DECREF(obj);
1138 : SWIG_PYTHON_THREAD_END_BLOCK;
1139 : }
1140 :
1141 : SWIGINTERN void
1142 11 : SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
1143 11 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1144 11 : PyErr_SetString(errtype, msg);
1145 11 : SWIG_PYTHON_THREAD_END_BLOCK;
1146 11 : }
1147 :
1148 : #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
1149 :
1150 : /* Set a constant value */
1151 :
1152 : #if defined(SWIGPYTHON_BUILTIN)
1153 :
1154 : SWIGINTERN void
1155 : SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
1156 : PyObject *s = PyString_InternFromString(key);
1157 : PyList_Append(seq, s);
1158 : Py_DECREF(s);
1159 : }
1160 :
1161 : SWIGINTERN void
1162 : SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
1163 : PyDict_SetItemString(d, name, obj);
1164 : Py_DECREF(obj);
1165 : if (public_interface)
1166 : SwigPyBuiltin_AddPublicSymbol(public_interface, name);
1167 : }
1168 :
1169 : #else
1170 :
1171 : SWIGINTERN void
1172 : SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
1173 : PyDict_SetItemString(d, name, obj);
1174 : Py_DECREF(obj);
1175 : }
1176 :
1177 : #endif
1178 :
1179 : /* Append a value to the result obj */
1180 :
1181 : SWIGINTERN PyObject*
1182 : SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
1183 : if (!result) {
1184 : result = obj;
1185 : } else if (result == Py_None) {
1186 : Py_DECREF(result);
1187 : result = obj;
1188 : } else {
1189 : if (!PyList_Check(result)) {
1190 : PyObject *o2 = result;
1191 : result = PyList_New(1);
1192 : PyList_SetItem(result, 0, o2);
1193 : }
1194 : PyList_Append(result,obj);
1195 : Py_DECREF(obj);
1196 : }
1197 : return result;
1198 : }
1199 :
1200 : /* Unpack the argument tuple */
1201 :
1202 : SWIGINTERN Py_ssize_t
1203 830 : SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
1204 : {
1205 830 : if (!args) {
1206 31 : if (!min && !max) {
1207 : return 1;
1208 : } else {
1209 0 : PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
1210 : name, (min == max ? "" : "at least "), (int)min);
1211 0 : return 0;
1212 : }
1213 : }
1214 799 : if (!PyTuple_Check(args)) {
1215 225 : if (min <= 1 && max >= 1) {
1216 225 : Py_ssize_t i;
1217 225 : objs[0] = args;
1218 225 : for (i = 1; i < max; ++i) {
1219 0 : objs[i] = 0;
1220 : }
1221 : return 2;
1222 : }
1223 0 : PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
1224 0 : return 0;
1225 : } else {
1226 574 : Py_ssize_t l = PyTuple_GET_SIZE(args);
1227 574 : if (l < min) {
1228 0 : PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
1229 : name, (min == max ? "" : "at least "), (int)min, (int)l);
1230 0 : return 0;
1231 574 : } else if (l > max) {
1232 0 : PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
1233 : name, (min == max ? "" : "at most "), (int)max, (int)l);
1234 0 : return 0;
1235 : } else {
1236 : Py_ssize_t i;
1237 2503 : for (i = 0; i < l; ++i) {
1238 1929 : objs[i] = PyTuple_GET_ITEM(args, i);
1239 : }
1240 574 : for (; l < max; ++l) {
1241 0 : objs[l] = 0;
1242 : }
1243 574 : return i + 1;
1244 : }
1245 : }
1246 : }
1247 :
1248 : /* A functor is a function object with one single object argument */
1249 : #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
1250 :
1251 : /*
1252 : Helper for static pointer initialization for both C and C++ code, for example
1253 : static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
1254 : */
1255 : #ifdef __cplusplus
1256 : #define SWIG_STATIC_POINTER(var) var
1257 : #else
1258 : #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
1259 : #endif
1260 :
1261 : /* -----------------------------------------------------------------------------
1262 : * Pointer declarations
1263 : * ----------------------------------------------------------------------------- */
1264 :
1265 : /* Flags for new pointer objects */
1266 : #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
1267 : #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
1268 :
1269 : #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
1270 :
1271 : #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
1272 : #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
1273 :
1274 : #ifdef __cplusplus
1275 : extern "C" {
1276 : #endif
1277 :
1278 : /* The python void return value */
1279 :
1280 : SWIGRUNTIMEINLINE PyObject *
1281 19683 : SWIG_Py_Void(void)
1282 : {
1283 19683 : PyObject *none = Py_None;
1284 0 : Py_INCREF(none);
1285 230 : return none;
1286 : }
1287 :
1288 : /* SwigPyClientData */
1289 :
1290 : typedef struct {
1291 : PyObject *klass;
1292 : PyObject *newraw;
1293 : PyObject *newargs;
1294 : PyObject *destroy;
1295 : int delargs;
1296 : int implicitconv;
1297 : PyTypeObject *pytype;
1298 : } SwigPyClientData;
1299 :
1300 : SWIGRUNTIMEINLINE int
1301 : SWIG_Python_CheckImplicit(swig_type_info *ty)
1302 : {
1303 : SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
1304 : int fail = data ? data->implicitconv : 0;
1305 : if (fail)
1306 : PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors.");
1307 : return fail;
1308 : }
1309 :
1310 : SWIGRUNTIMEINLINE PyObject *
1311 : SWIG_Python_ExceptionType(swig_type_info *desc) {
1312 : SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
1313 : PyObject *klass = data ? data->klass : 0;
1314 : return (klass ? klass : PyExc_RuntimeError);
1315 : }
1316 :
1317 :
1318 : SWIGRUNTIME SwigPyClientData *
1319 225 : SwigPyClientData_New(PyObject* obj)
1320 : {
1321 225 : if (!obj) {
1322 : return 0;
1323 : } else {
1324 225 : SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
1325 : /* the klass element */
1326 225 : data->klass = obj;
1327 225 : Py_INCREF(data->klass);
1328 : /* the newraw method and newargs arguments used to create a new raw instance */
1329 225 : if (PyClass_Check(obj)) {
1330 225 : data->newraw = 0;
1331 225 : data->newargs = obj;
1332 225 : Py_INCREF(obj);
1333 : } else {
1334 0 : data->newraw = PyObject_GetAttrString(data->klass, "__new__");
1335 0 : if (data->newraw) {
1336 0 : Py_INCREF(data->newraw);
1337 0 : data->newargs = PyTuple_New(1);
1338 0 : PyTuple_SetItem(data->newargs, 0, obj);
1339 : } else {
1340 0 : data->newargs = obj;
1341 : }
1342 0 : Py_INCREF(data->newargs);
1343 : }
1344 : /* the destroy method, aka as the C++ delete method */
1345 225 : data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
1346 225 : if (PyErr_Occurred()) {
1347 0 : PyErr_Clear();
1348 0 : data->destroy = 0;
1349 : }
1350 225 : if (data->destroy) {
1351 225 : int flags;
1352 225 : Py_INCREF(data->destroy);
1353 225 : flags = PyCFunction_GET_FLAGS(data->destroy);
1354 225 : data->delargs = !(flags & (METH_O));
1355 : } else {
1356 0 : data->delargs = 0;
1357 : }
1358 225 : data->implicitconv = 0;
1359 225 : data->pytype = 0;
1360 225 : return data;
1361 : }
1362 : }
1363 :
1364 : SWIGRUNTIME void
1365 0 : SwigPyClientData_Del(SwigPyClientData *data) {
1366 0 : Py_XDECREF(data->newraw);
1367 0 : Py_XDECREF(data->newargs);
1368 0 : Py_XDECREF(data->destroy);
1369 0 : }
1370 :
1371 : /* =============== SwigPyObject =====================*/
1372 :
1373 : typedef struct {
1374 : PyObject_HEAD
1375 : void *ptr;
1376 : swig_type_info *ty;
1377 : int own;
1378 : PyObject *next;
1379 : #ifdef SWIGPYTHON_BUILTIN
1380 : PyObject *dict;
1381 : #endif
1382 : } SwigPyObject;
1383 :
1384 :
1385 : #ifdef SWIGPYTHON_BUILTIN
1386 :
1387 : SWIGRUNTIME PyObject *
1388 : SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
1389 : {
1390 : SwigPyObject *sobj = (SwigPyObject *)v;
1391 :
1392 : if (!sobj->dict)
1393 : sobj->dict = PyDict_New();
1394 :
1395 : Py_INCREF(sobj->dict);
1396 : return sobj->dict;
1397 : }
1398 :
1399 : #endif
1400 :
1401 : SWIGRUNTIME PyObject *
1402 0 : SwigPyObject_long(SwigPyObject *v)
1403 : {
1404 0 : return PyLong_FromVoidPtr(v->ptr);
1405 : }
1406 :
1407 : SWIGRUNTIME PyObject *
1408 : SwigPyObject_format(const char* fmt, SwigPyObject *v)
1409 : {
1410 : PyObject *res = NULL;
1411 : PyObject *args = PyTuple_New(1);
1412 : if (args) {
1413 : if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
1414 : PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
1415 : if (ofmt) {
1416 : #if PY_VERSION_HEX >= 0x03000000
1417 : res = PyUnicode_Format(ofmt,args);
1418 : #else
1419 : res = PyString_Format(ofmt,args);
1420 : #endif
1421 : Py_DECREF(ofmt);
1422 : }
1423 : Py_DECREF(args);
1424 : }
1425 : }
1426 : return res;
1427 : }
1428 :
1429 : SWIGRUNTIME PyObject *
1430 : SwigPyObject_oct(SwigPyObject *v)
1431 : {
1432 : return SwigPyObject_format("%o",v);
1433 : }
1434 :
1435 : SWIGRUNTIME PyObject *
1436 : SwigPyObject_hex(SwigPyObject *v)
1437 : {
1438 : return SwigPyObject_format("%x",v);
1439 : }
1440 :
1441 : SWIGRUNTIME PyObject *
1442 0 : SwigPyObject_repr(SwigPyObject *v)
1443 : {
1444 0 : const char *name = SWIG_TypePrettyName(v->ty);
1445 0 : PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
1446 0 : if (v->next) {
1447 0 : PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
1448 : # if PY_VERSION_HEX >= 0x03000000
1449 0 : PyObject *joined = PyUnicode_Concat(repr, nrep);
1450 0 : Py_DecRef(repr);
1451 0 : Py_DecRef(nrep);
1452 0 : repr = joined;
1453 : # else
1454 : PyString_ConcatAndDel(&repr,nrep);
1455 : # endif
1456 : }
1457 0 : return repr;
1458 : }
1459 :
1460 : /* We need a version taking two PyObject* parameters so it's a valid
1461 : * PyCFunction to use in swigobject_methods[]. */
1462 : SWIGRUNTIME PyObject *
1463 0 : SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
1464 : {
1465 0 : return SwigPyObject_repr((SwigPyObject*)v);
1466 : }
1467 :
1468 : SWIGRUNTIME int
1469 0 : SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
1470 : {
1471 0 : void *i = v->ptr;
1472 0 : void *j = w->ptr;
1473 0 : return (i < j) ? -1 : ((i > j) ? 1 : 0);
1474 : }
1475 :
1476 : /* Added for Python 3.x, would it also be useful for Python 2.x? */
1477 : SWIGRUNTIME PyObject*
1478 0 : SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
1479 : {
1480 0 : PyObject* res;
1481 0 : if( op != Py_EQ && op != Py_NE ) {
1482 0 : Py_INCREF(Py_NotImplemented);
1483 0 : return Py_NotImplemented;
1484 : }
1485 0 : res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
1486 0 : return res;
1487 : }
1488 :
1489 :
1490 : SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
1491 :
1492 : #ifdef SWIGPYTHON_BUILTIN
1493 : static swig_type_info *SwigPyObject_stype = 0;
1494 : SWIGRUNTIME PyTypeObject*
1495 : SwigPyObject_type(void) {
1496 : SwigPyClientData *cd;
1497 : assert(SwigPyObject_stype);
1498 : cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
1499 : assert(cd);
1500 : assert(cd->pytype);
1501 : return cd->pytype;
1502 : }
1503 : #else
1504 : SWIGRUNTIME PyTypeObject*
1505 30734 : SwigPyObject_type(void) {
1506 30734 : static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
1507 30734 : return type;
1508 : }
1509 : #endif
1510 :
1511 : SWIGRUNTIMEINLINE int
1512 : SwigPyObject_Check(PyObject *op) {
1513 : #ifdef SWIGPYTHON_BUILTIN
1514 : PyTypeObject *target_tp = SwigPyObject_type();
1515 : if (PyType_IsSubtype(op->ob_type, target_tp))
1516 : return 1;
1517 : return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
1518 : #else
1519 : return (Py_TYPE(op) == SwigPyObject_type())
1520 : || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
1521 : #endif
1522 : }
1523 :
1524 : SWIGRUNTIME PyObject *
1525 : SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
1526 :
1527 : SWIGRUNTIME void
1528 44 : SwigPyObject_dealloc(PyObject *v)
1529 : {
1530 44 : SwigPyObject *sobj = (SwigPyObject *) v;
1531 44 : PyObject *next = sobj->next;
1532 44 : if (sobj->own == SWIG_POINTER_OWN) {
1533 43 : swig_type_info *ty = sobj->ty;
1534 43 : SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
1535 43 : PyObject *destroy = data ? data->destroy : 0;
1536 43 : if (destroy) {
1537 : /* destroy is always a VARARGS method */
1538 43 : PyObject *res;
1539 :
1540 : /* PyObject_CallFunction() has the potential to silently drop
1541 : the active exception. In cases of unnamed temporary
1542 : variable or where we just finished iterating over a generator
1543 : StopIteration will be active right now, and this needs to
1544 : remain true upon return from SwigPyObject_dealloc. So save
1545 : and restore. */
1546 :
1547 43 : PyObject *type = NULL, *value = NULL, *traceback = NULL;
1548 43 : PyErr_Fetch(&type, &value, &traceback);
1549 :
1550 43 : if (data->delargs) {
1551 : /* we need to create a temporary object to carry the destroy operation */
1552 0 : PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
1553 0 : res = SWIG_Python_CallFunctor(destroy, tmp);
1554 0 : Py_DECREF(tmp);
1555 : } else {
1556 43 : PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
1557 43 : PyObject *mself = PyCFunction_GET_SELF(destroy);
1558 43 : res = ((*meth)(mself, v));
1559 : }
1560 43 : if (!res)
1561 0 : PyErr_WriteUnraisable(destroy);
1562 :
1563 43 : PyErr_Restore(type, value, traceback);
1564 :
1565 86 : Py_XDECREF(res);
1566 : }
1567 : #if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
1568 : else {
1569 : const char *name = SWIG_TypePrettyName(ty);
1570 : printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
1571 : }
1572 : #endif
1573 : }
1574 44 : Py_XDECREF(next);
1575 44 : PyObject_DEL(v);
1576 44 : }
1577 :
1578 : SWIGRUNTIME PyObject*
1579 0 : SwigPyObject_append(PyObject* v, PyObject* next)
1580 : {
1581 0 : SwigPyObject *sobj = (SwigPyObject *) v;
1582 0 : if (!SwigPyObject_Check(next)) {
1583 0 : PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
1584 0 : return NULL;
1585 : }
1586 0 : sobj->next = next;
1587 0 : Py_INCREF(next);
1588 0 : return SWIG_Py_Void();
1589 : }
1590 :
1591 : SWIGRUNTIME PyObject*
1592 0 : SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1593 : {
1594 0 : SwigPyObject *sobj = (SwigPyObject *) v;
1595 0 : if (sobj->next) {
1596 0 : Py_INCREF(sobj->next);
1597 0 : return sobj->next;
1598 : } else {
1599 0 : return SWIG_Py_Void();
1600 : }
1601 : }
1602 :
1603 : SWIGINTERN PyObject*
1604 0 : SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1605 : {
1606 0 : SwigPyObject *sobj = (SwigPyObject *)v;
1607 0 : sobj->own = 0;
1608 0 : return SWIG_Py_Void();
1609 : }
1610 :
1611 : SWIGINTERN PyObject*
1612 0 : SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1613 : {
1614 0 : SwigPyObject *sobj = (SwigPyObject *)v;
1615 0 : sobj->own = SWIG_POINTER_OWN;
1616 0 : return SWIG_Py_Void();
1617 : }
1618 :
1619 : SWIGINTERN PyObject*
1620 0 : SwigPyObject_own(PyObject *v, PyObject *args)
1621 : {
1622 0 : PyObject *val = 0;
1623 0 : if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) {
1624 : return NULL;
1625 : } else {
1626 0 : SwigPyObject *sobj = (SwigPyObject *)v;
1627 0 : PyObject *obj = PyBool_FromLong(sobj->own);
1628 0 : if (val) {
1629 0 : if (PyObject_IsTrue(val)) {
1630 0 : SwigPyObject_acquire(v,args);
1631 : } else {
1632 0 : SwigPyObject_disown(v,args);
1633 : }
1634 : }
1635 0 : return obj;
1636 : }
1637 : }
1638 :
1639 : static PyMethodDef
1640 : swigobject_methods[] = {
1641 : {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"},
1642 : {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"},
1643 : {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"},
1644 : {"append", SwigPyObject_append, METH_O, "appends another 'this' object"},
1645 : {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"},
1646 : {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"},
1647 : {0, 0, 0, 0}
1648 : };
1649 :
1650 : SWIGRUNTIME PyTypeObject*
1651 225 : SwigPyObject_TypeOnce(void) {
1652 225 : static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
1653 :
1654 225 : static PyNumberMethods SwigPyObject_as_number = {
1655 : (binaryfunc)0, /*nb_add*/
1656 : (binaryfunc)0, /*nb_subtract*/
1657 : (binaryfunc)0, /*nb_multiply*/
1658 : /* nb_divide removed in Python 3 */
1659 : #if PY_VERSION_HEX < 0x03000000
1660 : (binaryfunc)0, /*nb_divide*/
1661 : #endif
1662 : (binaryfunc)0, /*nb_remainder*/
1663 : (binaryfunc)0, /*nb_divmod*/
1664 : (ternaryfunc)0,/*nb_power*/
1665 : (unaryfunc)0, /*nb_negative*/
1666 : (unaryfunc)0, /*nb_positive*/
1667 : (unaryfunc)0, /*nb_absolute*/
1668 : (inquiry)0, /*nb_nonzero*/
1669 : 0, /*nb_invert*/
1670 : 0, /*nb_lshift*/
1671 : 0, /*nb_rshift*/
1672 : 0, /*nb_and*/
1673 : 0, /*nb_xor*/
1674 : 0, /*nb_or*/
1675 : #if PY_VERSION_HEX < 0x03000000
1676 : 0, /*nb_coerce*/
1677 : #endif
1678 : (unaryfunc)SwigPyObject_long, /*nb_int*/
1679 : #if PY_VERSION_HEX < 0x03000000
1680 : (unaryfunc)SwigPyObject_long, /*nb_long*/
1681 : #else
1682 : 0, /*nb_reserved*/
1683 : #endif
1684 : (unaryfunc)0, /*nb_float*/
1685 : #if PY_VERSION_HEX < 0x03000000
1686 : (unaryfunc)SwigPyObject_oct, /*nb_oct*/
1687 : (unaryfunc)SwigPyObject_hex, /*nb_hex*/
1688 : #endif
1689 : #if PY_VERSION_HEX >= 0x03050000 /* 3.5 */
1690 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
1691 : #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */
1692 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
1693 : #else
1694 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
1695 : #endif
1696 : };
1697 :
1698 225 : static PyTypeObject swigpyobject_type;
1699 225 : static int type_init = 0;
1700 225 : if (!type_init) {
1701 225 : const PyTypeObject tmp = {
1702 : #if PY_VERSION_HEX >= 0x03000000
1703 : PyVarObject_HEAD_INIT(NULL, 0)
1704 : #else
1705 : PyObject_HEAD_INIT(NULL)
1706 : 0, /* ob_size */
1707 : #endif
1708 : "SwigPyObject", /* tp_name */
1709 : sizeof(SwigPyObject), /* tp_basicsize */
1710 : 0, /* tp_itemsize */
1711 : (destructor)SwigPyObject_dealloc, /* tp_dealloc */
1712 : 0, /* tp_print */
1713 : (getattrfunc)0, /* tp_getattr */
1714 : (setattrfunc)0, /* tp_setattr */
1715 : #if PY_VERSION_HEX >= 0x03000000
1716 : 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
1717 : #else
1718 : (cmpfunc)SwigPyObject_compare, /* tp_compare */
1719 : #endif
1720 : (reprfunc)SwigPyObject_repr, /* tp_repr */
1721 : &SwigPyObject_as_number, /* tp_as_number */
1722 : 0, /* tp_as_sequence */
1723 : 0, /* tp_as_mapping */
1724 : (hashfunc)0, /* tp_hash */
1725 : (ternaryfunc)0, /* tp_call */
1726 : 0, /* tp_str */
1727 : PyObject_GenericGetAttr, /* tp_getattro */
1728 : 0, /* tp_setattro */
1729 : 0, /* tp_as_buffer */
1730 : Py_TPFLAGS_DEFAULT, /* tp_flags */
1731 : swigobject_doc, /* tp_doc */
1732 : 0, /* tp_traverse */
1733 : 0, /* tp_clear */
1734 : (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
1735 : 0, /* tp_weaklistoffset */
1736 : 0, /* tp_iter */
1737 : 0, /* tp_iternext */
1738 : swigobject_methods, /* tp_methods */
1739 : 0, /* tp_members */
1740 : 0, /* tp_getset */
1741 : 0, /* tp_base */
1742 : 0, /* tp_dict */
1743 : 0, /* tp_descr_get */
1744 : 0, /* tp_descr_set */
1745 : 0, /* tp_dictoffset */
1746 : 0, /* tp_init */
1747 : 0, /* tp_alloc */
1748 : 0, /* tp_new */
1749 : 0, /* tp_free */
1750 : 0, /* tp_is_gc */
1751 : 0, /* tp_bases */
1752 : 0, /* tp_mro */
1753 : 0, /* tp_cache */
1754 : 0, /* tp_subclasses */
1755 : 0, /* tp_weaklist */
1756 : 0, /* tp_del */
1757 : 0, /* tp_version_tag */
1758 : #if PY_VERSION_HEX >= 0x03040000
1759 : 0, /* tp_finalize */
1760 : #endif
1761 : #ifdef COUNT_ALLOCS
1762 : 0, /* tp_allocs */
1763 : 0, /* tp_frees */
1764 : 0, /* tp_maxalloc */
1765 : 0, /* tp_prev */
1766 : 0 /* tp_next */
1767 : #endif
1768 : };
1769 225 : swigpyobject_type = tmp;
1770 225 : type_init = 1;
1771 225 : if (PyType_Ready(&swigpyobject_type) < 0)
1772 0 : return NULL;
1773 : }
1774 : return &swigpyobject_type;
1775 : }
1776 :
1777 : SWIGRUNTIME PyObject *
1778 268 : SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
1779 : {
1780 268 : SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
1781 268 : if (sobj) {
1782 268 : sobj->ptr = ptr;
1783 268 : sobj->ty = ty;
1784 268 : sobj->own = own;
1785 268 : sobj->next = 0;
1786 : }
1787 268 : return (PyObject *)sobj;
1788 : }
1789 :
1790 : /* -----------------------------------------------------------------------------
1791 : * Implements a simple Swig Packed type, and use it instead of string
1792 : * ----------------------------------------------------------------------------- */
1793 :
1794 : typedef struct {
1795 : PyObject_HEAD
1796 : void *pack;
1797 : swig_type_info *ty;
1798 : size_t size;
1799 : } SwigPyPacked;
1800 :
1801 : SWIGRUNTIME PyObject *
1802 0 : SwigPyPacked_repr(SwigPyPacked *v)
1803 : {
1804 0 : char result[SWIG_BUFFER_SIZE];
1805 0 : if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
1806 0 : return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
1807 : } else {
1808 0 : return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
1809 : }
1810 : }
1811 :
1812 : SWIGRUNTIME PyObject *
1813 0 : SwigPyPacked_str(SwigPyPacked *v)
1814 : {
1815 0 : char result[SWIG_BUFFER_SIZE];
1816 0 : if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
1817 0 : return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
1818 : } else {
1819 0 : return SWIG_Python_str_FromChar(v->ty->name);
1820 : }
1821 : }
1822 :
1823 : SWIGRUNTIME int
1824 : SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
1825 : {
1826 : size_t i = v->size;
1827 : size_t j = w->size;
1828 : int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
1829 : return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size);
1830 : }
1831 :
1832 : SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
1833 :
1834 : SWIGRUNTIME PyTypeObject*
1835 225 : SwigPyPacked_type(void) {
1836 225 : static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
1837 225 : return type;
1838 : }
1839 :
1840 : SWIGRUNTIMEINLINE int
1841 : SwigPyPacked_Check(PyObject *op) {
1842 : return ((op)->ob_type == SwigPyPacked_TypeOnce())
1843 : || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
1844 : }
1845 :
1846 : SWIGRUNTIME void
1847 0 : SwigPyPacked_dealloc(PyObject *v)
1848 : {
1849 0 : if (SwigPyPacked_Check(v)) {
1850 0 : SwigPyPacked *sobj = (SwigPyPacked *) v;
1851 0 : free(sobj->pack);
1852 : }
1853 0 : PyObject_DEL(v);
1854 0 : }
1855 :
1856 : SWIGRUNTIME PyTypeObject*
1857 225 : SwigPyPacked_TypeOnce(void) {
1858 225 : static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
1859 225 : static PyTypeObject swigpypacked_type;
1860 225 : static int type_init = 0;
1861 225 : if (!type_init) {
1862 225 : const PyTypeObject tmp = {
1863 : #if PY_VERSION_HEX>=0x03000000
1864 : PyVarObject_HEAD_INIT(NULL, 0)
1865 : #else
1866 : PyObject_HEAD_INIT(NULL)
1867 : 0, /* ob_size */
1868 : #endif
1869 : "SwigPyPacked", /* tp_name */
1870 : sizeof(SwigPyPacked), /* tp_basicsize */
1871 : 0, /* tp_itemsize */
1872 : (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
1873 : 0, /* tp_print */
1874 : (getattrfunc)0, /* tp_getattr */
1875 : (setattrfunc)0, /* tp_setattr */
1876 : #if PY_VERSION_HEX>=0x03000000
1877 : 0, /* tp_reserved in 3.0.1 */
1878 : #else
1879 : (cmpfunc)SwigPyPacked_compare, /* tp_compare */
1880 : #endif
1881 : (reprfunc)SwigPyPacked_repr, /* tp_repr */
1882 : 0, /* tp_as_number */
1883 : 0, /* tp_as_sequence */
1884 : 0, /* tp_as_mapping */
1885 : (hashfunc)0, /* tp_hash */
1886 : (ternaryfunc)0, /* tp_call */
1887 : (reprfunc)SwigPyPacked_str, /* tp_str */
1888 : PyObject_GenericGetAttr, /* tp_getattro */
1889 : 0, /* tp_setattro */
1890 : 0, /* tp_as_buffer */
1891 : Py_TPFLAGS_DEFAULT, /* tp_flags */
1892 : swigpacked_doc, /* tp_doc */
1893 : 0, /* tp_traverse */
1894 : 0, /* tp_clear */
1895 : 0, /* tp_richcompare */
1896 : 0, /* tp_weaklistoffset */
1897 : 0, /* tp_iter */
1898 : 0, /* tp_iternext */
1899 : 0, /* tp_methods */
1900 : 0, /* tp_members */
1901 : 0, /* tp_getset */
1902 : 0, /* tp_base */
1903 : 0, /* tp_dict */
1904 : 0, /* tp_descr_get */
1905 : 0, /* tp_descr_set */
1906 : 0, /* tp_dictoffset */
1907 : 0, /* tp_init */
1908 : 0, /* tp_alloc */
1909 : 0, /* tp_new */
1910 : 0, /* tp_free */
1911 : 0, /* tp_is_gc */
1912 : 0, /* tp_bases */
1913 : 0, /* tp_mro */
1914 : 0, /* tp_cache */
1915 : 0, /* tp_subclasses */
1916 : 0, /* tp_weaklist */
1917 : 0, /* tp_del */
1918 : 0, /* tp_version_tag */
1919 : #if PY_VERSION_HEX >= 0x03040000
1920 : 0, /* tp_finalize */
1921 : #endif
1922 : #ifdef COUNT_ALLOCS
1923 : 0, /* tp_allocs */
1924 : 0, /* tp_frees */
1925 : 0, /* tp_maxalloc */
1926 : 0, /* tp_prev */
1927 : 0 /* tp_next */
1928 : #endif
1929 : };
1930 225 : swigpypacked_type = tmp;
1931 225 : type_init = 1;
1932 225 : if (PyType_Ready(&swigpypacked_type) < 0)
1933 0 : return NULL;
1934 : }
1935 : return &swigpypacked_type;
1936 : }
1937 :
1938 : SWIGRUNTIME PyObject *
1939 0 : SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
1940 : {
1941 0 : SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
1942 0 : if (sobj) {
1943 0 : void *pack = malloc(size);
1944 0 : if (pack) {
1945 0 : memcpy(pack, ptr, size);
1946 0 : sobj->pack = pack;
1947 0 : sobj->ty = ty;
1948 0 : sobj->size = size;
1949 : } else {
1950 0 : PyObject_DEL((PyObject *) sobj);
1951 0 : sobj = 0;
1952 : }
1953 : }
1954 0 : return (PyObject *) sobj;
1955 : }
1956 :
1957 : SWIGRUNTIME swig_type_info *
1958 : SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
1959 : {
1960 : if (SwigPyPacked_Check(obj)) {
1961 : SwigPyPacked *sobj = (SwigPyPacked *)obj;
1962 : if (sobj->size != size) return 0;
1963 : memcpy(ptr, sobj->pack, size);
1964 : return sobj->ty;
1965 : } else {
1966 : return 0;
1967 : }
1968 : }
1969 :
1970 : /* -----------------------------------------------------------------------------
1971 : * pointers/data manipulation
1972 : * ----------------------------------------------------------------------------- */
1973 :
1974 : static PyObject *Swig_This_global = NULL;
1975 :
1976 : SWIGRUNTIME PyObject *
1977 15201 : SWIG_This(void)
1978 : {
1979 15201 : if (Swig_This_global == NULL)
1980 225 : Swig_This_global = SWIG_Python_str_FromChar("this");
1981 15201 : return Swig_This_global;
1982 : }
1983 :
1984 : /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
1985 :
1986 : /* TODO: I don't know how to implement the fast getset in Python 3 right now */
1987 : #if PY_VERSION_HEX>=0x03000000
1988 : #define SWIG_PYTHON_SLOW_GETSET_THIS
1989 : #endif
1990 :
1991 : SWIGRUNTIME SwigPyObject *
1992 15004 : SWIG_Python_GetSwigThis(PyObject *pyobj)
1993 : {
1994 15004 : PyObject *obj;
1995 :
1996 15004 : if (SwigPyObject_Check(pyobj))
1997 : return (SwigPyObject *) pyobj;
1998 :
1999 : #ifdef SWIGPYTHON_BUILTIN
2000 : (void)obj;
2001 : # ifdef PyWeakref_CheckProxy
2002 : if (PyWeakref_CheckProxy(pyobj)) {
2003 : pyobj = PyWeakref_GET_OBJECT(pyobj);
2004 : if (pyobj && SwigPyObject_Check(pyobj))
2005 : return (SwigPyObject*) pyobj;
2006 : }
2007 : # endif
2008 : return NULL;
2009 : #else
2010 :
2011 14976 : obj = 0;
2012 :
2013 : #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2014 : if (PyInstance_Check(pyobj)) {
2015 : obj = _PyInstance_Lookup(pyobj, SWIG_This());
2016 : } else {
2017 : PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
2018 : if (dictptr != NULL) {
2019 : PyObject *dict = *dictptr;
2020 : obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
2021 : } else {
2022 : #ifdef PyWeakref_CheckProxy
2023 : if (PyWeakref_CheckProxy(pyobj)) {
2024 : PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
2025 : return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
2026 : }
2027 : #endif
2028 : obj = PyObject_GetAttr(pyobj,SWIG_This());
2029 : if (obj) {
2030 : Py_DECREF(obj);
2031 : } else {
2032 : if (PyErr_Occurred()) PyErr_Clear();
2033 : return 0;
2034 : }
2035 : }
2036 : }
2037 : #else
2038 14976 : obj = PyObject_GetAttr(pyobj,SWIG_This());
2039 14976 : if (obj) {
2040 14969 : Py_DECREF(obj);
2041 : } else {
2042 7 : if (PyErr_Occurred()) PyErr_Clear();
2043 7 : return 0;
2044 : }
2045 : #endif
2046 14969 : if (obj && !SwigPyObject_Check(obj)) {
2047 : /* a PyObject is called 'this', try to get the 'real this'
2048 : SwigPyObject from it */
2049 : return SWIG_Python_GetSwigThis(obj);
2050 : }
2051 : return (SwigPyObject *)obj;
2052 : #endif
2053 : }
2054 :
2055 : /* Acquire a pointer value */
2056 :
2057 : SWIGRUNTIME int
2058 : SWIG_Python_AcquirePtr(PyObject *obj, int own) {
2059 : if (own == SWIG_POINTER_OWN) {
2060 : SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
2061 : if (sobj) {
2062 : int oldown = sobj->own;
2063 : sobj->own = own;
2064 : return oldown;
2065 : }
2066 : }
2067 : return 0;
2068 : }
2069 :
2070 : /* Convert a pointer value */
2071 :
2072 : SWIGRUNTIME int
2073 15004 : SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
2074 15004 : int res;
2075 15004 : SwigPyObject *sobj;
2076 15004 : int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
2077 :
2078 15004 : if (!obj)
2079 : return SWIG_ERROR;
2080 15004 : if (obj == Py_None && !implicit_conv) {
2081 0 : if (ptr)
2082 0 : *ptr = 0;
2083 0 : return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
2084 : }
2085 :
2086 15004 : res = SWIG_ERROR;
2087 :
2088 15004 : sobj = SWIG_Python_GetSwigThis(obj);
2089 15004 : if (own)
2090 0 : *own = 0;
2091 15004 : while (sobj) {
2092 14997 : void *vptr = sobj->ptr;
2093 14997 : if (ty) {
2094 14997 : swig_type_info *to = sobj->ty;
2095 14997 : if (to == ty) {
2096 : /* no type cast needed */
2097 14997 : if (ptr) *ptr = vptr;
2098 : break;
2099 : } else {
2100 0 : swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
2101 0 : if (!tc) {
2102 0 : sobj = (SwigPyObject *)sobj->next;
2103 : } else {
2104 0 : if (ptr) {
2105 0 : int newmemory = 0;
2106 0 : *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2107 0 : if (newmemory == SWIG_CAST_NEW_MEMORY) {
2108 0 : assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
2109 0 : if (own)
2110 0 : *own = *own | SWIG_CAST_NEW_MEMORY;
2111 : }
2112 : }
2113 : break;
2114 : }
2115 : }
2116 : } else {
2117 0 : if (ptr) *ptr = vptr;
2118 : break;
2119 : }
2120 : }
2121 15004 : if (sobj) {
2122 14997 : if (own)
2123 0 : *own = *own | sobj->own;
2124 14997 : if (flags & SWIG_POINTER_DISOWN) {
2125 28 : sobj->own = 0;
2126 : }
2127 : res = SWIG_OK;
2128 : } else {
2129 7 : if (implicit_conv) {
2130 0 : SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
2131 0 : if (data && !data->implicitconv) {
2132 0 : PyObject *klass = data->klass;
2133 0 : if (klass) {
2134 0 : PyObject *impconv;
2135 0 : data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
2136 0 : impconv = SWIG_Python_CallFunctor(klass, obj);
2137 0 : data->implicitconv = 0;
2138 0 : if (PyErr_Occurred()) {
2139 0 : PyErr_Clear();
2140 0 : impconv = 0;
2141 : }
2142 0 : if (impconv) {
2143 0 : SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
2144 0 : if (iobj) {
2145 0 : void *vptr;
2146 0 : res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
2147 0 : if (SWIG_IsOK(res)) {
2148 0 : if (ptr) {
2149 0 : *ptr = vptr;
2150 : /* transfer the ownership to 'ptr' */
2151 0 : iobj->own = 0;
2152 0 : res = SWIG_AddCast(res);
2153 0 : res = SWIG_AddNewMask(res);
2154 : } else {
2155 : res = SWIG_AddCast(res);
2156 : }
2157 : }
2158 : }
2159 0 : Py_DECREF(impconv);
2160 : }
2161 : }
2162 : }
2163 0 : if (!SWIG_IsOK(res) && obj == Py_None) {
2164 0 : if (ptr)
2165 0 : *ptr = 0;
2166 0 : if (PyErr_Occurred())
2167 0 : PyErr_Clear();
2168 : res = SWIG_OK;
2169 : }
2170 : }
2171 : }
2172 : return res;
2173 : }
2174 :
2175 : /* Convert a function ptr value */
2176 :
2177 : SWIGRUNTIME int
2178 : SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
2179 : if (!PyCFunction_Check(obj)) {
2180 : return SWIG_ConvertPtr(obj, ptr, ty, 0);
2181 : } else {
2182 : void *vptr = 0;
2183 : swig_cast_info *tc;
2184 :
2185 : /* here we get the method pointer for callbacks */
2186 : const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
2187 : const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
2188 : if (desc)
2189 : desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
2190 : if (!desc)
2191 : return SWIG_ERROR;
2192 : tc = SWIG_TypeCheck(desc,ty);
2193 : if (tc) {
2194 : int newmemory = 0;
2195 : *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2196 : assert(!newmemory); /* newmemory handling not yet implemented */
2197 : } else {
2198 : return SWIG_ERROR;
2199 : }
2200 : return SWIG_OK;
2201 : }
2202 : }
2203 :
2204 : /* Convert a packed pointer value */
2205 :
2206 : SWIGRUNTIME int
2207 : SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
2208 : swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
2209 : if (!to) return SWIG_ERROR;
2210 : if (ty) {
2211 : if (to != ty) {
2212 : /* check type cast? */
2213 : swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
2214 : if (!tc) return SWIG_ERROR;
2215 : }
2216 : }
2217 : return SWIG_OK;
2218 : }
2219 :
2220 : /* -----------------------------------------------------------------------------
2221 : * Create a new pointer object
2222 : * ----------------------------------------------------------------------------- */
2223 :
2224 : /*
2225 : Create a new instance object, without calling __init__, and set the
2226 : 'this' attribute.
2227 : */
2228 :
2229 : SWIGRUNTIME PyObject*
2230 : SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
2231 : {
2232 : PyObject *inst = 0;
2233 : PyObject *newraw = data->newraw;
2234 : if (newraw) {
2235 : inst = PyObject_Call(newraw, data->newargs, NULL);
2236 : if (inst) {
2237 : #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2238 : PyObject **dictptr = _PyObject_GetDictPtr(inst);
2239 : if (dictptr != NULL) {
2240 : PyObject *dict = *dictptr;
2241 : if (dict == NULL) {
2242 : dict = PyDict_New();
2243 : *dictptr = dict;
2244 : PyDict_SetItem(dict, SWIG_This(), swig_this);
2245 : }
2246 : }
2247 : #else
2248 : PyObject *key = SWIG_This();
2249 : PyObject_SetAttr(inst, key, swig_this);
2250 : #endif
2251 : }
2252 : } else {
2253 : #if PY_VERSION_HEX >= 0x03000000
2254 : PyObject *empty_args = PyTuple_New(0);
2255 : if (empty_args) {
2256 : PyObject *empty_kwargs = PyDict_New();
2257 : if (empty_kwargs) {
2258 : inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs);
2259 : Py_DECREF(empty_kwargs);
2260 : if (inst) {
2261 : PyObject_SetAttr(inst, SWIG_This(), swig_this);
2262 : Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
2263 : }
2264 : }
2265 : Py_DECREF(empty_args);
2266 : }
2267 : #else
2268 : PyObject *dict = PyDict_New();
2269 : if (dict) {
2270 : PyDict_SetItem(dict, SWIG_This(), swig_this);
2271 : inst = PyInstance_NewRaw(data->newargs, dict);
2272 : Py_DECREF(dict);
2273 : }
2274 : #endif
2275 : }
2276 : return inst;
2277 : }
2278 :
2279 : SWIGRUNTIME void
2280 : SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
2281 : {
2282 : PyObject *dict;
2283 : #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2284 : PyObject **dictptr = _PyObject_GetDictPtr(inst);
2285 : if (dictptr != NULL) {
2286 : dict = *dictptr;
2287 : if (dict == NULL) {
2288 : dict = PyDict_New();
2289 : *dictptr = dict;
2290 : }
2291 : PyDict_SetItem(dict, SWIG_This(), swig_this);
2292 : return;
2293 : }
2294 : #endif
2295 : dict = PyObject_GetAttrString(inst, "__dict__");
2296 : PyDict_SetItem(dict, SWIG_This(), swig_this);
2297 : Py_DECREF(dict);
2298 : }
2299 :
2300 :
2301 : SWIGINTERN PyObject *
2302 : SWIG_Python_InitShadowInstance(PyObject *args) {
2303 : PyObject *obj[2];
2304 : if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
2305 : return NULL;
2306 : } else {
2307 : SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
2308 : if (sthis) {
2309 : SwigPyObject_append((PyObject*) sthis, obj[1]);
2310 : } else {
2311 : SWIG_Python_SetSwigThis(obj[0], obj[1]);
2312 : }
2313 : return SWIG_Py_Void();
2314 : }
2315 : }
2316 :
2317 : /* Create a new pointer object */
2318 :
2319 : SWIGRUNTIME PyObject *
2320 273 : SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
2321 273 : SwigPyClientData *clientdata;
2322 273 : PyObject * robj;
2323 273 : int own;
2324 :
2325 273 : if (!ptr)
2326 5 : return SWIG_Py_Void();
2327 :
2328 268 : clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
2329 268 : own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2330 268 : if (clientdata && clientdata->pytype) {
2331 0 : SwigPyObject *newobj;
2332 0 : if (flags & SWIG_BUILTIN_TP_INIT) {
2333 0 : newobj = (SwigPyObject*) self;
2334 0 : if (newobj->ptr) {
2335 0 : PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
2336 0 : while (newobj->next)
2337 : newobj = (SwigPyObject *) newobj->next;
2338 0 : newobj->next = next_self;
2339 0 : newobj = (SwigPyObject *)next_self;
2340 : #ifdef SWIGPYTHON_BUILTIN
2341 : newobj->dict = 0;
2342 : #endif
2343 : }
2344 : } else {
2345 0 : newobj = PyObject_New(SwigPyObject, clientdata->pytype);
2346 : #ifdef SWIGPYTHON_BUILTIN
2347 : newobj->dict = 0;
2348 : #endif
2349 : }
2350 0 : if (newobj) {
2351 0 : newobj->ptr = ptr;
2352 0 : newobj->ty = type;
2353 0 : newobj->own = own;
2354 0 : newobj->next = 0;
2355 0 : return (PyObject*) newobj;
2356 : }
2357 0 : return SWIG_Py_Void();
2358 : }
2359 :
2360 268 : assert(!(flags & SWIG_BUILTIN_TP_INIT));
2361 :
2362 268 : robj = SwigPyObject_New(ptr, type, own);
2363 268 : if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2364 43 : PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2365 43 : Py_DECREF(robj);
2366 : robj = inst;
2367 : }
2368 : return robj;
2369 : }
2370 :
2371 : /* Create a new packed object */
2372 :
2373 : SWIGRUNTIMEINLINE PyObject *
2374 0 : SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
2375 0 : return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
2376 : }
2377 :
2378 : /* -----------------------------------------------------------------------------*
2379 : * Get type list
2380 : * -----------------------------------------------------------------------------*/
2381 :
2382 : #ifdef SWIG_LINK_RUNTIME
2383 : void *SWIG_ReturnGlobalTypeList(void *);
2384 : #endif
2385 :
2386 : SWIGRUNTIME swig_module_info *
2387 : SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
2388 : static void *type_pointer = (void *)0;
2389 : /* first check if module already created */
2390 : if (!type_pointer) {
2391 : #ifdef SWIG_LINK_RUNTIME
2392 : type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
2393 : #else
2394 : type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
2395 : if (PyErr_Occurred()) {
2396 : PyErr_Clear();
2397 : type_pointer = (void *)0;
2398 : }
2399 : #endif
2400 : }
2401 : return (swig_module_info *) type_pointer;
2402 : }
2403 :
2404 : SWIGRUNTIME void
2405 0 : SWIG_Python_DestroyModule(PyObject *obj)
2406 : {
2407 0 : swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
2408 0 : swig_type_info **types = swig_module->types;
2409 0 : size_t i;
2410 0 : for (i =0; i < swig_module->size; ++i) {
2411 0 : swig_type_info *ty = types[i];
2412 0 : if (ty->owndata) {
2413 0 : SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
2414 0 : if (data) SwigPyClientData_Del(data);
2415 : }
2416 : }
2417 0 : Py_DECREF(SWIG_This());
2418 0 : Swig_This_global = NULL;
2419 0 : }
2420 :
2421 : SWIGRUNTIME void
2422 0 : SWIG_Python_SetModule(swig_module_info *swig_module) {
2423 : #if PY_VERSION_HEX >= 0x03000000
2424 : /* Add a dummy module object into sys.modules */
2425 0 : PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION);
2426 : #else
2427 : static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
2428 : PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
2429 : #endif
2430 0 : PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
2431 0 : if (pointer && module) {
2432 0 : PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
2433 : } else {
2434 0 : Py_XDECREF(pointer);
2435 : }
2436 0 : }
2437 :
2438 : /* The python cached type query */
2439 : SWIGRUNTIME PyObject *
2440 225 : SWIG_Python_TypeCache(void) {
2441 225 : static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
2442 225 : return cache;
2443 : }
2444 :
2445 : SWIGRUNTIME swig_type_info *
2446 0 : SWIG_Python_TypeQuery(const char *type)
2447 : {
2448 0 : PyObject *cache = SWIG_Python_TypeCache();
2449 0 : PyObject *key = SWIG_Python_str_FromChar(type);
2450 0 : PyObject *obj = PyDict_GetItem(cache, key);
2451 0 : swig_type_info *descriptor;
2452 0 : if (obj) {
2453 0 : descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
2454 : } else {
2455 0 : swig_module_info *swig_module = SWIG_GetModule(0);
2456 0 : descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
2457 0 : if (descriptor) {
2458 0 : obj = PyCapsule_New((void*) descriptor, NULL, NULL);
2459 0 : PyDict_SetItem(cache, key, obj);
2460 0 : Py_DECREF(obj);
2461 : }
2462 : }
2463 0 : Py_DECREF(key);
2464 0 : return descriptor;
2465 : }
2466 :
2467 : /*
2468 : For backward compatibility only
2469 : */
2470 : #define SWIG_POINTER_EXCEPTION 0
2471 : #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
2472 : #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
2473 :
2474 : SWIGRUNTIME int
2475 : SWIG_Python_AddErrMesg(const char* mesg, int infront)
2476 : {
2477 : if (PyErr_Occurred()) {
2478 : PyObject *type = 0;
2479 : PyObject *value = 0;
2480 : PyObject *traceback = 0;
2481 : PyErr_Fetch(&type, &value, &traceback);
2482 : if (value) {
2483 : PyObject *old_str = PyObject_Str(value);
2484 : const char *tmp = SWIG_Python_str_AsChar(old_str);
2485 : const char *errmesg = tmp ? tmp : "Invalid error message";
2486 : Py_XINCREF(type);
2487 : PyErr_Clear();
2488 : if (infront) {
2489 : PyErr_Format(type, "%s %s", mesg, errmesg);
2490 : } else {
2491 : PyErr_Format(type, "%s %s", errmesg, mesg);
2492 : }
2493 : SWIG_Python_str_DelForPy3(tmp);
2494 : Py_DECREF(old_str);
2495 : }
2496 : return 1;
2497 : } else {
2498 : return 0;
2499 : }
2500 : }
2501 :
2502 : SWIGRUNTIME int
2503 : SWIG_Python_ArgFail(int argnum)
2504 : {
2505 : if (PyErr_Occurred()) {
2506 : /* add information about failing argument */
2507 : char mesg[256];
2508 : PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
2509 : return SWIG_Python_AddErrMesg(mesg, 1);
2510 : } else {
2511 : return 0;
2512 : }
2513 : }
2514 :
2515 : SWIGRUNTIMEINLINE const char *
2516 : SwigPyObject_GetDesc(PyObject *self)
2517 : {
2518 : SwigPyObject *v = (SwigPyObject *)self;
2519 : swig_type_info *ty = v ? v->ty : 0;
2520 : return ty ? ty->str : "";
2521 : }
2522 :
2523 : SWIGRUNTIME void
2524 : SWIG_Python_TypeError(const char *type, PyObject *obj)
2525 : {
2526 : if (type) {
2527 : #if defined(SWIG_COBJECT_TYPES)
2528 : if (obj && SwigPyObject_Check(obj)) {
2529 : const char *otype = (const char *) SwigPyObject_GetDesc(obj);
2530 : if (otype) {
2531 : PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
2532 : type, otype);
2533 : return;
2534 : }
2535 : } else
2536 : #endif
2537 : {
2538 : const char *otype = (obj ? obj->ob_type->tp_name : 0);
2539 : if (otype) {
2540 : PyObject *str = PyObject_Str(obj);
2541 : const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
2542 : if (cstr) {
2543 : PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
2544 : type, otype, cstr);
2545 : SWIG_Python_str_DelForPy3(cstr);
2546 : } else {
2547 : PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
2548 : type, otype);
2549 : }
2550 : Py_XDECREF(str);
2551 : return;
2552 : }
2553 : }
2554 : PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
2555 : } else {
2556 : PyErr_Format(PyExc_TypeError, "unexpected type is received");
2557 : }
2558 : }
2559 :
2560 :
2561 : /* Convert a pointer value, signal an exception on a type mismatch */
2562 : SWIGRUNTIME void *
2563 : SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
2564 : void *result;
2565 : if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
2566 : PyErr_Clear();
2567 : #if SWIG_POINTER_EXCEPTION
2568 : if (flags) {
2569 : SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
2570 : SWIG_Python_ArgFail(argnum);
2571 : }
2572 : #endif
2573 : }
2574 : return result;
2575 : }
2576 :
2577 : #ifdef SWIGPYTHON_BUILTIN
2578 : SWIGRUNTIME int
2579 : SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
2580 : PyTypeObject *tp = obj->ob_type;
2581 : PyObject *descr;
2582 : PyObject *encoded_name;
2583 : descrsetfunc f;
2584 : int res = -1;
2585 :
2586 : # ifdef Py_USING_UNICODE
2587 : if (PyString_Check(name)) {
2588 : name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
2589 : if (!name)
2590 : return -1;
2591 : } else if (!PyUnicode_Check(name))
2592 : # else
2593 : if (!PyString_Check(name))
2594 : # endif
2595 : {
2596 : PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
2597 : return -1;
2598 : } else {
2599 : Py_INCREF(name);
2600 : }
2601 :
2602 : if (!tp->tp_dict) {
2603 : if (PyType_Ready(tp) < 0)
2604 : goto done;
2605 : }
2606 :
2607 : descr = _PyType_Lookup(tp, name);
2608 : f = NULL;
2609 : if (descr != NULL)
2610 : f = descr->ob_type->tp_descr_set;
2611 : if (!f) {
2612 : if (PyString_Check(name)) {
2613 : encoded_name = name;
2614 : Py_INCREF(name);
2615 : } else {
2616 : encoded_name = PyUnicode_AsUTF8String(name);
2617 : if (!encoded_name)
2618 : return -1;
2619 : }
2620 : PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
2621 : Py_DECREF(encoded_name);
2622 : } else {
2623 : res = f(descr, obj, value);
2624 : }
2625 :
2626 : done:
2627 : Py_DECREF(name);
2628 : return res;
2629 : }
2630 : #endif
2631 :
2632 :
2633 : #ifdef __cplusplus
2634 : }
2635 : #endif
2636 :
2637 :
2638 :
2639 : #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
2640 :
2641 : #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
2642 :
2643 :
2644 :
2645 : #ifdef __cplusplus
2646 : extern "C" {
2647 : #endif
2648 :
2649 : /* Method creation and docstring support functions */
2650 :
2651 : SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
2652 : SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
2653 : SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
2654 :
2655 : #ifdef __cplusplus
2656 : }
2657 : #endif
2658 :
2659 :
2660 : #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0)
2661 :
2662 :
2663 : /* -------- TYPES TABLE (BEGIN) -------- */
2664 :
2665 : #define SWIGTYPE_p_ArrowArray swig_types[0]
2666 : #define SWIGTYPE_p_ArrowSchema swig_types[1]
2667 : #define SWIGTYPE_p_CPLVirtualMemShadow swig_types[2]
2668 : #define SWIGTYPE_p_GDALDataType swig_types[3]
2669 : #define SWIGTYPE_p_GDALDatasetShadow swig_types[4]
2670 : #define SWIGTYPE_p_GDALExtendedDataTypeHS swig_types[5]
2671 : #define SWIGTYPE_p_GDALMDArrayHS swig_types[6]
2672 : #define SWIGTYPE_p_GDALProgressFunc swig_types[7]
2673 : #define SWIGTYPE_p_GDALRasterAttributeTableShadow swig_types[8]
2674 : #define SWIGTYPE_p_GDALRasterBandShadow swig_types[9]
2675 : #define SWIGTYPE_p_GIntBig swig_types[10]
2676 : #define SWIGTYPE_p_GUIntBig swig_types[11]
2677 : #define SWIGTYPE_p_PyArrayObject swig_types[12]
2678 : #define SWIGTYPE_p_char swig_types[13]
2679 : #define SWIGTYPE_p_f_double_p_q_const__char_p_void__int swig_types[14]
2680 : #define SWIGTYPE_p_int swig_types[15]
2681 : #define SWIGTYPE_p_p_CPLVirtualMemShadow swig_types[16]
2682 : #define SWIGTYPE_p_p_void swig_types[17]
2683 : #define SWIGTYPE_p_size_t swig_types[18]
2684 : #define SWIGTYPE_p_std__string swig_types[19]
2685 : static swig_type_info *swig_types[21];
2686 : static swig_module_info swig_module = {swig_types, 20, 0, 0, 0, 0};
2687 : #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
2688 : #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
2689 :
2690 : /* -------- TYPES TABLE (END) -------- */
2691 :
2692 : #ifdef SWIG_TypeQuery
2693 : # undef SWIG_TypeQuery
2694 : #endif
2695 : #define SWIG_TypeQuery SWIG_Python_TypeQuery
2696 :
2697 : /*-----------------------------------------------
2698 : @(target):= _gdal_array.so
2699 : ------------------------------------------------*/
2700 : #if PY_VERSION_HEX >= 0x03000000
2701 : # define SWIG_init PyInit__gdal_array
2702 :
2703 : #else
2704 : # define SWIG_init init_gdal_array
2705 :
2706 : #endif
2707 : #define SWIG_name "_gdal_array"
2708 :
2709 : #define SWIGVERSION 0x040001
2710 : #define SWIG_VERSION SWIGVERSION
2711 :
2712 :
2713 : #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
2714 : #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
2715 :
2716 :
2717 : #include <stdexcept>
2718 :
2719 :
2720 : namespace swig {
2721 : class SwigPtr_PyObject {
2722 : protected:
2723 : PyObject *_obj;
2724 :
2725 : public:
2726 : SwigPtr_PyObject() :_obj(0)
2727 : {
2728 : }
2729 :
2730 : SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
2731 : {
2732 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2733 : Py_XINCREF(_obj);
2734 : SWIG_PYTHON_THREAD_END_BLOCK;
2735 : }
2736 :
2737 : SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
2738 : {
2739 : if (initial_ref) {
2740 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2741 : Py_XINCREF(_obj);
2742 : SWIG_PYTHON_THREAD_END_BLOCK;
2743 : }
2744 : }
2745 :
2746 : SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
2747 : {
2748 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2749 : Py_XINCREF(item._obj);
2750 : Py_XDECREF(_obj);
2751 : _obj = item._obj;
2752 : SWIG_PYTHON_THREAD_END_BLOCK;
2753 : return *this;
2754 : }
2755 :
2756 : ~SwigPtr_PyObject()
2757 : {
2758 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2759 : Py_XDECREF(_obj);
2760 : SWIG_PYTHON_THREAD_END_BLOCK;
2761 : }
2762 :
2763 : operator PyObject *() const
2764 : {
2765 : return _obj;
2766 : }
2767 :
2768 : PyObject *operator->() const
2769 : {
2770 : return _obj;
2771 : }
2772 : };
2773 : }
2774 :
2775 :
2776 : namespace swig {
2777 : struct SwigVar_PyObject : SwigPtr_PyObject {
2778 : SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
2779 :
2780 : SwigVar_PyObject & operator = (PyObject* obj)
2781 : {
2782 : Py_XDECREF(_obj);
2783 : _obj = obj;
2784 : return *this;
2785 : }
2786 : };
2787 : }
2788 :
2789 :
2790 : #include "gdal.h"
2791 :
2792 : typedef struct
2793 : {
2794 : CPLVirtualMem *vmem;
2795 : int bAuto;
2796 : GDALDataType eBufType;
2797 : int bIsBandSequential;
2798 : int bReadOnly;
2799 : int nBufXSize;
2800 : int nBufYSize;
2801 : int nBandCount;
2802 : GDALTileOrganization eTileOrganization;
2803 : int nTileXSize;
2804 : int nTileYSize;
2805 : int nPixelSpace; /* if bAuto == TRUE */
2806 : GIntBig nLineSpace; /* if bAuto == TRUE */
2807 : } CPLVirtualMemShadow;
2808 :
2809 :
2810 28 : SWIGINTERN void delete_CPLVirtualMemShadow(CPLVirtualMemShadow *self){
2811 28 : CPLVirtualMemFree( self->vmem );
2812 28 : free(self);
2813 : }
2814 0 : SWIGINTERN void CPLVirtualMemShadow_GetAddr(CPLVirtualMemShadow *self,void **pptr,size_t *pnsize,GDALDataType *pdatatype,int *preadonly){
2815 0 : *pptr = CPLVirtualMemGetAddr( self->vmem );
2816 0 : *pnsize = CPLVirtualMemGetSize( self->vmem );
2817 0 : *pdatatype = self->eBufType;
2818 0 : *preadonly = self->bReadOnly;
2819 : }
2820 :
2821 : SWIGINTERN int
2822 58928 : SWIG_AsVal_double (PyObject *obj, double *val)
2823 : {
2824 58928 : int res = SWIG_TypeError;
2825 58928 : if (PyFloat_Check(obj)) {
2826 278 : if (val) *val = PyFloat_AsDouble(obj);
2827 278 : return SWIG_OK;
2828 : #if PY_VERSION_HEX < 0x03000000
2829 : } else if (PyInt_Check(obj)) {
2830 : if (val) *val = (double) PyInt_AsLong(obj);
2831 : return SWIG_OK;
2832 : #endif
2833 58650 : } else if (PyLong_Check(obj)) {
2834 58650 : double v = PyLong_AsDouble(obj);
2835 58650 : if (!PyErr_Occurred()) {
2836 58650 : if (val) *val = v;
2837 58650 : return SWIG_OK;
2838 : } else {
2839 0 : PyErr_Clear();
2840 : }
2841 : }
2842 : #ifdef SWIG_PYTHON_CAST_MODE
2843 : {
2844 : int dispatch = 0;
2845 : double d = PyFloat_AsDouble(obj);
2846 : if (!PyErr_Occurred()) {
2847 : if (val) *val = d;
2848 : return SWIG_AddCast(SWIG_OK);
2849 : } else {
2850 : PyErr_Clear();
2851 : }
2852 : if (!dispatch) {
2853 : long v = PyLong_AsLong(obj);
2854 : if (!PyErr_Occurred()) {
2855 : if (val) *val = v;
2856 : return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
2857 : } else {
2858 : PyErr_Clear();
2859 : }
2860 : }
2861 : }
2862 : #endif
2863 : return res;
2864 : }
2865 :
2866 :
2867 : #include <float.h>
2868 :
2869 :
2870 : #include <math.h>
2871 :
2872 :
2873 : SWIGINTERNINLINE int
2874 : SWIG_CanCastAsInteger(double *d, double min, double max) {
2875 : double x = *d;
2876 : if ((min <= x && x <= max)) {
2877 : double fx = floor(x);
2878 : double cx = ceil(x);
2879 : double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
2880 : if ((errno == EDOM) || (errno == ERANGE)) {
2881 : errno = 0;
2882 : } else {
2883 : double summ, reps, diff;
2884 : if (rd < x) {
2885 : diff = x - rd;
2886 : } else if (rd > x) {
2887 : diff = rd - x;
2888 : } else {
2889 : return 1;
2890 : }
2891 : summ = rd + x;
2892 : reps = diff/summ;
2893 : if (reps < 8*DBL_EPSILON) {
2894 : *d = rd;
2895 : return 1;
2896 : }
2897 : }
2898 : }
2899 : return 0;
2900 : }
2901 :
2902 :
2903 : SWIGINTERN int
2904 0 : SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
2905 : {
2906 : #if PY_VERSION_HEX < 0x03000000
2907 : if (PyInt_Check(obj)) {
2908 : long v = PyInt_AsLong(obj);
2909 : if (v >= 0) {
2910 : if (val) *val = v;
2911 : return SWIG_OK;
2912 : } else {
2913 : return SWIG_OverflowError;
2914 : }
2915 : } else
2916 : #endif
2917 0 : if (PyLong_Check(obj)) {
2918 0 : unsigned long v = PyLong_AsUnsignedLong(obj);
2919 0 : if (!PyErr_Occurred()) {
2920 0 : if (val) *val = v;
2921 0 : return SWIG_OK;
2922 : } else {
2923 0 : PyErr_Clear();
2924 0 : return SWIG_OverflowError;
2925 : }
2926 : }
2927 : #ifdef SWIG_PYTHON_CAST_MODE
2928 : {
2929 : int dispatch = 0;
2930 : unsigned long v = PyLong_AsUnsignedLong(obj);
2931 : if (!PyErr_Occurred()) {
2932 : if (val) *val = v;
2933 : return SWIG_AddCast(SWIG_OK);
2934 : } else {
2935 : PyErr_Clear();
2936 : }
2937 : if (!dispatch) {
2938 : double d;
2939 : int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
2940 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
2941 : if (val) *val = (unsigned long)(d);
2942 : return res;
2943 : }
2944 : }
2945 : }
2946 : #endif
2947 : return SWIG_TypeError;
2948 : }
2949 :
2950 :
2951 : #include <limits.h>
2952 : #if !defined(SWIG_NO_LLONG_MAX)
2953 : # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
2954 : # define LLONG_MAX __LONG_LONG_MAX__
2955 : # define LLONG_MIN (-LLONG_MAX - 1LL)
2956 : # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
2957 : # endif
2958 : #endif
2959 :
2960 :
2961 : #if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
2962 : # define SWIG_LONG_LONG_AVAILABLE
2963 : #endif
2964 :
2965 :
2966 : #ifdef SWIG_LONG_LONG_AVAILABLE
2967 : SWIGINTERN int
2968 : SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val)
2969 : {
2970 : int res = SWIG_TypeError;
2971 : if (PyLong_Check(obj)) {
2972 : unsigned long long v = PyLong_AsUnsignedLongLong(obj);
2973 : if (!PyErr_Occurred()) {
2974 : if (val) *val = v;
2975 : return SWIG_OK;
2976 : } else {
2977 : PyErr_Clear();
2978 : res = SWIG_OverflowError;
2979 : }
2980 : } else {
2981 : unsigned long v;
2982 : res = SWIG_AsVal_unsigned_SS_long (obj,&v);
2983 : if (SWIG_IsOK(res)) {
2984 : if (val) *val = v;
2985 : return res;
2986 : }
2987 : }
2988 : #ifdef SWIG_PYTHON_CAST_MODE
2989 : {
2990 : const double mant_max = 1LL << DBL_MANT_DIG;
2991 : double d;
2992 : res = SWIG_AsVal_double (obj,&d);
2993 : if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
2994 : return SWIG_OverflowError;
2995 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
2996 : if (val) *val = (unsigned long long)(d);
2997 : return SWIG_AddCast(res);
2998 : }
2999 : res = SWIG_TypeError;
3000 : }
3001 : #endif
3002 : return res;
3003 : }
3004 : #endif
3005 :
3006 :
3007 : SWIGINTERNINLINE int
3008 0 : SWIG_AsVal_size_t (PyObject * obj, size_t *val)
3009 : {
3010 0 : int res = SWIG_TypeError;
3011 : #ifdef SWIG_LONG_LONG_AVAILABLE
3012 0 : if (sizeof(size_t) <= sizeof(unsigned long)) {
3013 : #endif
3014 0 : unsigned long v;
3015 0 : res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
3016 0 : if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
3017 : #ifdef SWIG_LONG_LONG_AVAILABLE
3018 : } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
3019 : unsigned long long v;
3020 : res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0);
3021 : if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
3022 : }
3023 : #endif
3024 0 : return res;
3025 : }
3026 :
3027 :
3028 : SWIGINTERN int
3029 63708 : SWIG_AsVal_long (PyObject *obj, long* val)
3030 : {
3031 : #if PY_VERSION_HEX < 0x03000000
3032 : if (PyInt_Check(obj)) {
3033 : if (val) *val = PyInt_AsLong(obj);
3034 : return SWIG_OK;
3035 : } else
3036 : #endif
3037 63708 : if (PyLong_Check(obj)) {
3038 63706 : long v = PyLong_AsLong(obj);
3039 63706 : if (!PyErr_Occurred()) {
3040 63706 : if (val) *val = v;
3041 63706 : return SWIG_OK;
3042 : } else {
3043 0 : PyErr_Clear();
3044 0 : return SWIG_OverflowError;
3045 : }
3046 : }
3047 : #ifdef SWIG_PYTHON_CAST_MODE
3048 : {
3049 : int dispatch = 0;
3050 : long v = PyInt_AsLong(obj);
3051 : if (!PyErr_Occurred()) {
3052 : if (val) *val = v;
3053 : return SWIG_AddCast(SWIG_OK);
3054 : } else {
3055 : PyErr_Clear();
3056 : }
3057 : if (!dispatch) {
3058 : double d;
3059 : int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
3060 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
3061 : if (val) *val = (long)(d);
3062 : return res;
3063 : }
3064 : }
3065 : }
3066 : #endif
3067 : return SWIG_TypeError;
3068 : }
3069 :
3070 :
3071 : SWIGINTERN int
3072 63708 : SWIG_AsVal_int (PyObject * obj, int *val)
3073 : {
3074 63708 : long v;
3075 127416 : int res = SWIG_AsVal_long (obj, &v);
3076 63708 : if (SWIG_IsOK(res)) {
3077 63706 : if ((v < INT_MIN || v > INT_MAX)) {
3078 : return SWIG_OverflowError;
3079 : } else {
3080 63706 : if (val) *val = static_cast< int >(v);
3081 : }
3082 : }
3083 : return res;
3084 : }
3085 :
3086 : SWIGINTERN void CPLVirtualMemShadow_Pin__SWIG_0(CPLVirtualMemShadow *self,size_t start_offset=0,size_t nsize=0,int bWriteOp=0){
3087 : if( nsize == 0 || start_offset + nsize >= CPLVirtualMemGetSize( self->vmem ) )
3088 : nsize = CPLVirtualMemGetSize( self->vmem ) - start_offset;
3089 : char* start_addr = (char*)CPLVirtualMemGetAddr( self->vmem ) + start_offset;
3090 : CPLVirtualMemPin(self->vmem, start_addr, nsize, bWriteOp);
3091 : }
3092 :
3093 : #include "cpl_string.h"
3094 : #include "cpl_conv.h"
3095 :
3096 : static int bUseExceptions=0;
3097 : static int bUserHasSpecifiedIfUsingExceptions = FALSE;
3098 : static thread_local int bUseExceptionsLocal = -1;
3099 :
3100 14901 : struct PythonBindingErrorHandlerContext
3101 : {
3102 : std::string osInitialMsg{};
3103 : std::string osFailureMsg{};
3104 : CPLErrorNum nLastCode = CPLE_None;
3105 : bool bMemoryError = false;
3106 : };
3107 :
3108 : static void CPL_STDCALL
3109 308 : PythonBindingErrorHandler(CPLErr eclass, CPLErrorNum err_no, const char *msg )
3110 : {
3111 308 : PythonBindingErrorHandlerContext* ctxt = static_cast<
3112 308 : PythonBindingErrorHandlerContext*>(CPLGetErrorHandlerUserData());
3113 :
3114 : /*
3115 : ** Generally we want to suppress error reporting if we have exceptions
3116 : ** enabled as the error message will be in the exception thrown in
3117 : ** Python.
3118 : */
3119 :
3120 : /* If the error class is CE_Fatal, we want to have a message issued
3121 : because the CPL support code does an abort() before any exception
3122 : can be generated */
3123 308 : if (eclass == CE_Fatal ) {
3124 0 : CPLCallPreviousHandler(eclass, err_no, msg );
3125 : }
3126 :
3127 : /*
3128 : ** We do not want to interfere with non-failure messages since
3129 : ** they won't be translated into exceptions.
3130 : */
3131 308 : else if (eclass != CE_Failure ) {
3132 302 : CPLCallPreviousHandler(eclass, err_no, msg );
3133 : }
3134 : else {
3135 6 : ctxt->nLastCode = err_no;
3136 6 : try
3137 : {
3138 6 : if( ctxt->osFailureMsg.empty() ) {
3139 5 : ctxt->osFailureMsg = msg;
3140 5 : ctxt->osInitialMsg = ctxt->osFailureMsg;
3141 : } else {
3142 1 : if( ctxt->osFailureMsg.size() < 10000 ) {
3143 2 : std::string osTmp(msg);
3144 1 : osTmp += "\nMay be caused by: ";
3145 1 : osTmp += ctxt->osFailureMsg;
3146 1 : ctxt->osFailureMsg = std::move(osTmp);
3147 1 : ctxt->osInitialMsg = ctxt->osFailureMsg;
3148 : }
3149 : else
3150 : {
3151 0 : std::string osTmp(msg);
3152 0 : osTmp += "\n[...]\nMay be caused by: ";
3153 0 : osTmp += ctxt->osInitialMsg;
3154 0 : ctxt->osFailureMsg = std::move(osTmp);
3155 : }
3156 : }
3157 : }
3158 0 : catch( const std::exception& )
3159 : {
3160 0 : ctxt->bMemoryError = true;
3161 : }
3162 : }
3163 308 : }
3164 :
3165 :
3166 :
3167 :
3168 : static
3169 50239 : int GetUseExceptions() {
3170 11941 : return bUseExceptionsLocal >= 0 ? bUseExceptionsLocal : bUseExceptions;
3171 : }
3172 :
3173 0 : static int _GetExceptionsLocal()
3174 : {
3175 0 : return bUseExceptionsLocal;
3176 : }
3177 :
3178 19366 : static void _SetExceptionsLocal(int bVal)
3179 : {
3180 19366 : bUseExceptionsLocal = bVal;
3181 : }
3182 :
3183 : static
3184 26 : void _UseExceptions() {
3185 26 : CPLErrorReset();
3186 26 : bUserHasSpecifiedIfUsingExceptions = TRUE;
3187 26 : if( !bUseExceptions )
3188 : {
3189 25 : bUseExceptions = 1;
3190 : }
3191 : }
3192 :
3193 : static
3194 5 : void _DontUseExceptions() {
3195 5 : CPLErrorReset();
3196 5 : bUserHasSpecifiedIfUsingExceptions = TRUE;
3197 5 : if( bUseExceptions )
3198 : {
3199 0 : bUseExceptions = 0;
3200 : }
3201 : }
3202 :
3203 0 : static int _UserHasSpecifiedIfUsingExceptions()
3204 : {
3205 0 : return bUserHasSpecifiedIfUsingExceptions || bUseExceptionsLocal >= 0;
3206 : }
3207 :
3208 :
3209 :
3210 : SWIGINTERNINLINE PyObject*
3211 14817 : SWIG_From_int (int value)
3212 : {
3213 14817 : return PyInt_FromLong((long) value);
3214 : }
3215 :
3216 :
3217 : /* Completely unrelated: just to avoid Coverity warnings */
3218 :
3219 : static int bReturnSame = 1;
3220 :
3221 0 : void NeverCallMePlease() {
3222 0 : bReturnSame = 0;
3223 0 : }
3224 :
3225 : /* Some SWIG code generates dead code, which Coverity warns about */
3226 54195 : template<class T> static T ReturnSame(T x)
3227 : {
3228 54195 : if( bReturnSame )
3229 : return x;
3230 : return 0;
3231 : }
3232 :
3233 14901 : static void pushErrorHandler()
3234 : {
3235 14901 : CPLErrorReset();
3236 14901 : PythonBindingErrorHandlerContext* ctxt = new PythonBindingErrorHandlerContext();
3237 14901 : CPLPushErrorHandlerEx(PythonBindingErrorHandler, ctxt);
3238 14901 : }
3239 :
3240 14901 : static void popErrorHandler()
3241 : {
3242 14901 : PythonBindingErrorHandlerContext* ctxt = static_cast<
3243 14901 : PythonBindingErrorHandlerContext*>(CPLGetErrorHandlerUserData());
3244 14901 : CPLPopErrorHandler();
3245 14901 : if( ctxt->bMemoryError )
3246 : {
3247 0 : CPLErrorSetState(
3248 : CE_Failure, CPLE_OutOfMemory, "Out of memory");
3249 : }
3250 14901 : else if( !ctxt->osFailureMsg.empty() )
3251 : {
3252 5 : CPLErrorSetState(
3253 5 : CPLGetLastErrorType() == CE_Failure ? CE_Failure: CE_Warning,
3254 : ctxt->nLastCode, ctxt->osFailureMsg.c_str());
3255 : }
3256 14901 : delete ctxt;
3257 14901 : }
3258 :
3259 :
3260 :
3261 :
3262 : /* Return a PyObject* from a NULL terminated C String */
3263 : static PyObject* GDALPythonObjectFromCStr(const char *pszStr) CPL_UNUSED;
3264 2 : static PyObject* GDALPythonObjectFromCStr(const char *pszStr)
3265 : {
3266 2 : const unsigned char* pszIter = (const unsigned char*) pszStr;
3267 46 : while(*pszIter != 0)
3268 : {
3269 44 : if (*pszIter > 127)
3270 : {
3271 0 : PyObject* pyObj = PyUnicode_DecodeUTF8(pszStr, strlen(pszStr), "strict");
3272 0 : if (pyObj != NULL && !PyErr_Occurred())
3273 : return pyObj;
3274 0 : PyErr_Clear();
3275 0 : return PyBytes_FromString(pszStr);
3276 : }
3277 44 : pszIter ++;
3278 : }
3279 2 : return PyUnicode_FromString(pszStr);
3280 : }
3281 :
3282 : /* Return a NULL terminated c String from a PyObject */
3283 : /* Result must be freed with GDALPythonFreeCStr */
3284 : static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree) CPL_UNUSED;
3285 : static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree)
3286 : {
3287 : *pbToFree = 0;
3288 : if (PyUnicode_Check(pyObject))
3289 : {
3290 : char *pszStr;
3291 : char *pszNewStr;
3292 : Py_ssize_t nLen;
3293 : PyObject* pyUTF8Str = PyUnicode_AsUTF8String(pyObject);
3294 : if( pyUTF8Str == NULL )
3295 : return NULL;
3296 : PyBytes_AsStringAndSize(pyUTF8Str, &pszStr, &nLen);
3297 : pszNewStr = (char *) malloc(nLen+1);
3298 : if( pszNewStr == NULL )
3299 : {
3300 : CPLError(CE_Failure, CPLE_OutOfMemory, "Failed to allocate %llu bytes",
3301 : (unsigned long long)(nLen + 1));
3302 : Py_XDECREF(pyUTF8Str);
3303 : return NULL;
3304 : }
3305 : memcpy(pszNewStr, pszStr, nLen+1);
3306 : Py_XDECREF(pyUTF8Str);
3307 : *pbToFree = 1;
3308 : return pszNewStr;
3309 : }
3310 : else if( PyBytes_Check(pyObject) )
3311 : {
3312 : char* ret = PyBytes_AsString(pyObject);
3313 :
3314 : // Check if there are \0 bytes inside the string
3315 : const Py_ssize_t size = PyBytes_Size(pyObject);
3316 : for( Py_ssize_t i = 0; i < size; i++ )
3317 : {
3318 : if( ret[i] == 0 )
3319 : {
3320 : CPLError(CE_Failure, CPLE_AppDefined,
3321 : "bytes object cast as string contains a zero-byte.");
3322 : return NULL;
3323 : }
3324 : }
3325 :
3326 : return ret;
3327 : }
3328 : else
3329 : {
3330 : CPLError(CE_Failure, CPLE_AppDefined,
3331 : "Passed object is neither of type string nor bytes");
3332 : return NULL;
3333 : }
3334 : }
3335 :
3336 : static char * GDALPythonPathToCStr(PyObject* pyObject, int* pbToFree) CPL_UNUSED;
3337 : static char * GDALPythonPathToCStr(PyObject* pyObject, int* pbToFree)
3338 : {
3339 : PyObject* os = PyImport_ImportModule("os");
3340 : if (os == NULL)
3341 : {
3342 : return NULL;
3343 : }
3344 :
3345 : PyObject* pathLike = PyObject_GetAttrString(os, "PathLike");
3346 : if (pathLike == NULL)
3347 : {
3348 : Py_DECREF(os);
3349 : return NULL;
3350 : }
3351 :
3352 : if (!PyObject_IsInstance(pyObject, pathLike))
3353 : {
3354 : Py_DECREF(pathLike);
3355 : Py_DECREF(os);
3356 : return NULL;
3357 : }
3358 :
3359 : PyObject* str = PyObject_Str(pyObject);
3360 : char* ret = NULL;
3361 : if (str != NULL)
3362 : {
3363 : ret = GDALPythonObjectToCStr(str, pbToFree);
3364 : Py_DECREF(str);
3365 : }
3366 :
3367 : Py_DECREF(pathLike);
3368 : Py_DECREF(os);
3369 :
3370 : return ret;
3371 : }
3372 :
3373 :
3374 : static void GDALPythonFreeCStr(void* ptr, int bToFree) CPL_UNUSED;
3375 : static void GDALPythonFreeCStr(void* ptr, int bToFree)
3376 : {
3377 : if (bToFree)
3378 : free(ptr);
3379 : }
3380 :
3381 :
3382 :
3383 : #include <vector>
3384 : #include "gdal_priv.h"
3385 : #include "ogr_recordbatch.h"
3386 :
3387 : #ifdef _DEBUG
3388 : #undef _DEBUG
3389 : #include "Python.h"
3390 : #include "datetime.h"
3391 : #define _DEBUG
3392 : #else
3393 : #include "Python.h"
3394 : #include "datetime.h"
3395 : #endif
3396 : #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
3397 : #include "numpy/arrayobject.h"
3398 :
3399 : #ifdef DEBUG
3400 : typedef struct GDALRasterBandHS GDALRasterBandShadow;
3401 : typedef struct GDALDatasetHS GDALDatasetShadow;
3402 : typedef struct RasterAttributeTableHS GDALRasterAttributeTableShadow;
3403 : #else
3404 : typedef void GDALRasterBandShadow;
3405 : typedef void GDALDatasetShadow;
3406 : typedef void GDALRasterAttributeTableShadow;
3407 : #endif
3408 :
3409 : // Declaration from memmultidim.h
3410 : std::shared_ptr<GDALMDArray> CPL_DLL MEMGroupCreateMDArray(GDALGroup* poGroup,
3411 : const std::string& osName,
3412 : const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
3413 : const GDALExtendedDataType& oDataType,
3414 : void* pData,
3415 : CSLConstList papszOptions);
3416 :
3417 :
3418 : CPL_C_START
3419 :
3420 : GDALRasterBandH CPL_DLL MEMCreateRasterBandEx( GDALDataset *, int, GByte *,
3421 : GDALDataType, GSpacing, GSpacing, int );
3422 : CPL_C_END
3423 :
3424 : typedef char retStringAndCPLFree;
3425 :
3426 : class NUMPYDataset : public GDALDataset
3427 : {
3428 : PyArrayObject *psArray;
3429 :
3430 : int bValidGeoTransform;
3431 : double adfGeoTransform[6];
3432 : OGRSpatialReference m_oSRS{};
3433 :
3434 : int nGCPCount;
3435 : GDAL_GCP *pasGCPList;
3436 : OGRSpatialReference m_oGCPSRS{};;
3437 :
3438 : public:
3439 : NUMPYDataset();
3440 : ~NUMPYDataset();
3441 :
3442 : const OGRSpatialReference* GetSpatialRef() const override;
3443 : CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override;
3444 :
3445 : virtual CPLErr GetGeoTransform( double * ) override;
3446 : virtual CPLErr SetGeoTransform( double * ) override;
3447 :
3448 : virtual int GetGCPCount() override;
3449 : const OGRSpatialReference* GetGCPSpatialRef() const override;
3450 : virtual const GDAL_GCP *GetGCPs() override;
3451 : CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
3452 : const OGRSpatialReference* poSRS ) override;
3453 :
3454 : static GDALDataset *Open( PyArrayObject *psArray, bool binterleave = true );
3455 : static GDALDataset *Open( GDALOpenInfo * );
3456 : };
3457 :
3458 :
3459 : /************************************************************************/
3460 : /* GDALRegister_NUMPY() */
3461 : /************************************************************************/
3462 :
3463 227 : static void GDALRegister_NUMPY(void)
3464 :
3465 : {
3466 227 : GDALDriver *poDriver;
3467 227 : if (! GDAL_CHECK_VERSION("NUMPY driver"))
3468 : return;
3469 227 : if( GDALGetDriverByName( "NUMPY" ) == NULL )
3470 : {
3471 225 : poDriver = static_cast<GDALDriver*>(GDALCreateDriver());
3472 :
3473 225 : poDriver->SetDescription( "NUMPY" );
3474 225 : poDriver->SetMetadataItem( GDAL_DMD_LONGNAME,
3475 225 : "Numeric Python Array" );
3476 225 : poDriver->SetMetadataItem( GDAL_DCAP_RASTER, "YES" );
3477 :
3478 225 : poDriver->pfnOpen = NUMPYDataset::Open;
3479 :
3480 225 : GetGDALDriverManager()->RegisterDriver( poDriver );
3481 :
3482 : }
3483 : }
3484 :
3485 : /************************************************************************/
3486 : /* NUMPYDataset() */
3487 : /************************************************************************/
3488 :
3489 24 : NUMPYDataset::NUMPYDataset()
3490 :
3491 : {
3492 24 : psArray = NULL;
3493 24 : bValidGeoTransform = FALSE;
3494 24 : adfGeoTransform[0] = 0.0;
3495 24 : adfGeoTransform[1] = 1.0;
3496 24 : adfGeoTransform[2] = 0.0;
3497 24 : adfGeoTransform[3] = 0.0;
3498 24 : adfGeoTransform[4] = 0.0;
3499 24 : adfGeoTransform[5] = 1.0;
3500 :
3501 24 : nGCPCount = 0;
3502 24 : pasGCPList = NULL;
3503 24 : }
3504 :
3505 : /************************************************************************/
3506 : /* ~NUMPYDataset() */
3507 : /************************************************************************/
3508 :
3509 48 : NUMPYDataset::~NUMPYDataset()
3510 :
3511 : {
3512 24 : if( nGCPCount > 0 )
3513 : {
3514 0 : GDALDeinitGCPs( nGCPCount, pasGCPList );
3515 0 : CPLFree( pasGCPList );
3516 : }
3517 :
3518 24 : FlushCache(true);
3519 :
3520 : // Although the module has thread disabled, we go here from GDALClose()
3521 24 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3522 :
3523 24 : Py_DECREF( psArray );
3524 :
3525 24 : SWIG_PYTHON_THREAD_END_BLOCK;
3526 48 : }
3527 :
3528 : /************************************************************************/
3529 : /* GetSpatialRef() */
3530 : /************************************************************************/
3531 :
3532 0 : const OGRSpatialReference *NUMPYDataset::GetSpatialRef() const
3533 :
3534 : {
3535 0 : return m_oSRS.IsEmpty() ? nullptr: &m_oSRS;
3536 : }
3537 :
3538 : /************************************************************************/
3539 : /* SetSpatialRef() */
3540 : /************************************************************************/
3541 :
3542 0 : CPLErr NUMPYDataset::SetSpatialRef( const OGRSpatialReference* poSRS )
3543 :
3544 : {
3545 0 : m_oSRS.Clear();
3546 0 : if( poSRS )
3547 0 : m_oSRS = *poSRS;
3548 :
3549 0 : return CE_None;
3550 : }
3551 :
3552 : /************************************************************************/
3553 : /* GetGeoTransform() */
3554 : /************************************************************************/
3555 :
3556 2 : CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform )
3557 :
3558 : {
3559 2 : memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 );
3560 2 : if( bValidGeoTransform )
3561 : return CE_None;
3562 : else
3563 1 : return CE_Failure;
3564 : }
3565 :
3566 : /************************************************************************/
3567 : /* SetGeoTransform() */
3568 : /************************************************************************/
3569 :
3570 1 : CPLErr NUMPYDataset::SetGeoTransform( double * padfTransform )
3571 :
3572 : {
3573 1 : bValidGeoTransform = TRUE;
3574 1 : memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 );
3575 1 : return( CE_None );
3576 : }
3577 :
3578 : /************************************************************************/
3579 : /* GetGCPCount() */
3580 : /************************************************************************/
3581 :
3582 0 : int NUMPYDataset::GetGCPCount()
3583 :
3584 : {
3585 0 : return nGCPCount;
3586 : }
3587 :
3588 : /************************************************************************/
3589 : /* GetGCPSpatialRef() */
3590 : /************************************************************************/
3591 :
3592 0 : const OGRSpatialReference *NUMPYDataset::GetGCPSpatialRef() const
3593 :
3594 : {
3595 0 : return m_oGCPSRS.IsEmpty() ? nullptr: &m_oGCPSRS;
3596 : }
3597 :
3598 : /************************************************************************/
3599 : /* GetGCPs() */
3600 : /************************************************************************/
3601 :
3602 0 : const GDAL_GCP *NUMPYDataset::GetGCPs()
3603 :
3604 : {
3605 0 : return pasGCPList;
3606 : }
3607 :
3608 : /************************************************************************/
3609 : /* SetGCPs() */
3610 : /************************************************************************/
3611 :
3612 0 : CPLErr NUMPYDataset::SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
3613 : const OGRSpatialReference* poSRS )
3614 :
3615 : {
3616 0 : m_oGCPSRS.Clear();
3617 0 : if( poSRS )
3618 0 : m_oGCPSRS = *poSRS;
3619 :
3620 0 : if( this->nGCPCount > 0 )
3621 : {
3622 0 : GDALDeinitGCPs( this->nGCPCount, this->pasGCPList );
3623 0 : CPLFree( this->pasGCPList );
3624 : }
3625 :
3626 0 : this->nGCPCount = nGCPCount;
3627 :
3628 0 : this->pasGCPList = GDALDuplicateGCPs( nGCPCount, pasGCPList );
3629 :
3630 0 : return CE_None;
3631 : }
3632 :
3633 : /************************************************************************/
3634 : /* Open() */
3635 : /************************************************************************/
3636 :
3637 25315 : GDALDataset *NUMPYDataset::Open( GDALOpenInfo * poOpenInfo )
3638 :
3639 : {
3640 25315 : PyArrayObject *psArray;
3641 :
3642 : /* -------------------------------------------------------------------- */
3643 : /* Is this a numpy dataset name? */
3644 : /* -------------------------------------------------------------------- */
3645 25315 : if( !EQUALN(poOpenInfo->pszFilename,"NUMPY:::",8)
3646 3 : || poOpenInfo->fpL != NULL )
3647 : return NULL;
3648 :
3649 3 : psArray = NULL;
3650 3 : sscanf( poOpenInfo->pszFilename+8, "%p", &(psArray) );
3651 3 : if( psArray == NULL )
3652 : {
3653 1 : CPLError( CE_Failure, CPLE_AppDefined,
3654 : "Failed to parse meaningful pointer value from NUMPY name\n"
3655 : "string: %s\n",
3656 : poOpenInfo->pszFilename );
3657 1 : return NULL;
3658 : }
3659 :
3660 2 : if( !CPLTestBool(CPLGetConfigOption("GDAL_ARRAY_OPEN_BY_FILENAME",
3661 : "FALSE")) )
3662 : {
3663 1 : if( CPLGetConfigOption("GDAL_ARRAY_OPEN_BY_FILENAME", NULL) == NULL )
3664 : {
3665 1 : CPLError(CE_Failure, CPLE_NotSupported,
3666 : "Opening a NumPy array through gdal.Open(gdal_array.GetArrayFilename()) "
3667 : "is no longer supported by default unless the GDAL_ARRAY_OPEN_BY_FILENAME "
3668 : "configuration option is set to TRUE. The recommended way is to use "
3669 : "gdal_array.OpenArray() instead.");
3670 : }
3671 1 : return NULL;
3672 : }
3673 :
3674 1 : return Open(psArray);
3675 : }
3676 :
3677 46 : static GDALDataType NumpyTypeToGDALType(PyArrayObject *psArray)
3678 : {
3679 46 : switch( PyArray_DESCR(psArray)->type_num )
3680 : {
3681 : case NPY_CDOUBLE:
3682 : return GDT_CFloat64;
3683 :
3684 5 : case NPY_CFLOAT:
3685 5 : return GDT_CFloat32;
3686 :
3687 3 : case NPY_DOUBLE:
3688 3 : return GDT_Float64;
3689 :
3690 3 : case NPY_FLOAT:
3691 3 : return GDT_Float32;
3692 :
3693 3 : case NPY_INT32:
3694 3 : return GDT_Int32;
3695 :
3696 3 : case NPY_UINT32:
3697 3 : return GDT_UInt32;
3698 :
3699 1 : case NPY_INT64:
3700 1 : return GDT_Int64;
3701 :
3702 1 : case NPY_UINT64:
3703 1 : return GDT_UInt64;
3704 :
3705 3 : case NPY_INT16:
3706 3 : return GDT_Int16;
3707 :
3708 3 : case NPY_UINT16:
3709 3 : return GDT_UInt16;
3710 :
3711 2 : case NPY_BYTE:
3712 2 : return GDT_Int8;
3713 :
3714 14 : case NPY_UBYTE:
3715 14 : return GDT_Byte;
3716 :
3717 2 : default:
3718 2 : CPLError( CE_Failure, CPLE_AppDefined,
3719 : "Unable to access numpy arrays of typecode `%c'.",
3720 2 : PyArray_DESCR(psArray)->type );
3721 2 : return GDT_Unknown;
3722 : }
3723 : }
3724 :
3725 : /************************************************************************/
3726 : /* Open() */
3727 : /************************************************************************/
3728 :
3729 28 : GDALDataset* NUMPYDataset::Open( PyArrayObject *psArray, bool binterleave )
3730 : {
3731 28 : GDALDataType eType;
3732 28 : int nBands;
3733 :
3734 : /* -------------------------------------------------------------------- */
3735 : /* Is this a directly mappable Python array? Verify rank, and */
3736 : /* data type. */
3737 : /* -------------------------------------------------------------------- */
3738 :
3739 28 : if( PyArray_NDIM(psArray) < 2 || PyArray_NDIM(psArray) > 3 )
3740 : {
3741 3 : CPLError( CE_Failure, CPLE_AppDefined,
3742 : "Illegal numpy array rank %d.",
3743 : PyArray_NDIM(psArray) );
3744 3 : return NULL;
3745 : }
3746 :
3747 25 : eType = NumpyTypeToGDALType(psArray);
3748 25 : if( eType == GDT_Unknown )
3749 : {
3750 : return NULL;
3751 : }
3752 :
3753 : /* -------------------------------------------------------------------- */
3754 : /* Create the new NUMPYDataset object. */
3755 : /* -------------------------------------------------------------------- */
3756 24 : NUMPYDataset *poDS;
3757 :
3758 24 : poDS = new NUMPYDataset();
3759 24 : poDS->poDriver = static_cast<GDALDriver*>(GDALGetDriverByName("NUMPY"));
3760 :
3761 24 : poDS->psArray = psArray;
3762 :
3763 24 : poDS->eAccess = (PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) ? GA_Update : GA_ReadOnly;
3764 :
3765 : /* -------------------------------------------------------------------- */
3766 : /* Add a reference to the array. */
3767 : /* -------------------------------------------------------------------- */
3768 24 : Py_INCREF( psArray );
3769 :
3770 : /* -------------------------------------------------------------------- */
3771 : /* Workout the data layout. */
3772 : /* -------------------------------------------------------------------- */
3773 24 : npy_intp nBandOffset;
3774 24 : npy_intp nPixelOffset;
3775 24 : npy_intp nLineOffset;
3776 :
3777 24 : int xdim = binterleave ? 2 : 1;
3778 24 : int ydim = binterleave ? 1 : 0;
3779 24 : int bdim = binterleave ? 0 : 2;
3780 :
3781 24 : if( PyArray_NDIM(psArray) == 3 )
3782 : {
3783 5 : if( PyArray_DIMS(psArray)[0] > INT_MAX ||
3784 5 : PyArray_DIMS(psArray)[1] > INT_MAX ||
3785 15 : PyArray_DIMS(psArray)[2] > INT_MAX ||
3786 5 : !GDALCheckBandCount(static_cast<int>(PyArray_DIMS(psArray)[bdim]), 0) )
3787 : {
3788 0 : CPLError(CE_Failure, CPLE_NotSupported,
3789 : "Too big array dimensions");
3790 0 : delete poDS;
3791 0 : return NULL;
3792 : }
3793 5 : nBands = static_cast<int>(PyArray_DIMS(psArray)[bdim]);
3794 5 : nBandOffset = PyArray_STRIDES(psArray)[bdim];
3795 5 : poDS->nRasterXSize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
3796 5 : nPixelOffset = PyArray_STRIDES(psArray)[xdim];
3797 5 : poDS->nRasterYSize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
3798 5 : nLineOffset = PyArray_STRIDES(psArray)[ydim];
3799 : }
3800 : else
3801 : {
3802 19 : if( PyArray_DIMS(psArray)[0] > INT_MAX ||
3803 19 : PyArray_DIMS(psArray)[1] > INT_MAX )
3804 : {
3805 0 : delete poDS;
3806 0 : return NULL;
3807 : }
3808 19 : nBands = 1;
3809 19 : nBandOffset = 0;
3810 19 : poDS->nRasterXSize = static_cast<int>(PyArray_DIMS(psArray)[1]);
3811 19 : nPixelOffset = PyArray_STRIDES(psArray)[1];
3812 19 : poDS->nRasterYSize = static_cast<int>(PyArray_DIMS(psArray)[0]);
3813 19 : nLineOffset = PyArray_STRIDES(psArray)[0];
3814 : }
3815 :
3816 : /* -------------------------------------------------------------------- */
3817 : /* Create band information objects. */
3818 : /* -------------------------------------------------------------------- */
3819 54 : for( int iBand = 0; iBand < nBands; iBand++ )
3820 : {
3821 30 : poDS->SetBand( iBand+1,
3822 : (GDALRasterBand *)
3823 30 : MEMCreateRasterBandEx( poDS, iBand+1,
3824 30 : (GByte *) PyArray_DATA(psArray) + nBandOffset*iBand,
3825 : eType, nPixelOffset, nLineOffset,
3826 : FALSE ) );
3827 : }
3828 :
3829 : /* -------------------------------------------------------------------- */
3830 : /* Try to return a regular handle on the file. */
3831 : /* -------------------------------------------------------------------- */
3832 : return poDS;
3833 : }
3834 :
3835 : /************************************************************************/
3836 : /* NUMPYMultiDimensionalDataset */
3837 : /************************************************************************/
3838 :
3839 : class NUMPYMultiDimensionalDataset : public GDALDataset
3840 : {
3841 : PyArrayObject *psArray = nullptr;
3842 : std::unique_ptr<GDALDataset> poMEMDS{};
3843 :
3844 : NUMPYMultiDimensionalDataset();
3845 : ~NUMPYMultiDimensionalDataset();
3846 :
3847 : public:
3848 : static GDALDataset *Open( PyArrayObject *psArray );
3849 :
3850 20 : std::shared_ptr<GDALGroup> GetRootGroup() const override { return poMEMDS->GetRootGroup(); }
3851 : };
3852 :
3853 : /************************************************************************/
3854 : /* NUMPYMultiDimensionalDataset() */
3855 : /************************************************************************/
3856 :
3857 20 : NUMPYMultiDimensionalDataset::NUMPYMultiDimensionalDataset()
3858 : {
3859 20 : }
3860 :
3861 : /************************************************************************/
3862 : /* ~NUMPYMultiDimensionalDataset() */
3863 : /************************************************************************/
3864 :
3865 40 : NUMPYMultiDimensionalDataset::~NUMPYMultiDimensionalDataset()
3866 : {
3867 : // Although the module has thread disabled, we go here from GDALClose()
3868 20 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3869 :
3870 20 : Py_DECREF( psArray );
3871 :
3872 20 : SWIG_PYTHON_THREAD_END_BLOCK;
3873 40 : }
3874 :
3875 : /************************************************************************/
3876 : /* Open() */
3877 : /************************************************************************/
3878 :
3879 21 : GDALDataset* NUMPYMultiDimensionalDataset::Open( PyArrayObject *psArray )
3880 : {
3881 21 : const auto eType = NumpyTypeToGDALType(psArray);
3882 21 : if( eType == GDT_Unknown )
3883 : {
3884 : return nullptr;
3885 : }
3886 20 : auto poMemDriver = GDALDriver::FromHandle(GDALGetDriverByName("MEM"));
3887 20 : if( !poMemDriver )
3888 : {
3889 0 : CPLError(CE_Failure, CPLE_AppDefined,
3890 : "MEM driver not available");
3891 0 : return nullptr;
3892 : }
3893 :
3894 20 : auto poMEMDS = poMemDriver->CreateMultiDimensional("", nullptr, nullptr);
3895 20 : assert(poMEMDS);
3896 41 : auto poGroup = poMEMDS->GetRootGroup();
3897 20 : assert(poGroup);
3898 40 : std::vector<std::shared_ptr<GDALDimension>> apoDims;
3899 20 : const auto ndims = PyArray_NDIM(psArray);
3900 40 : CPLString strides;
3901 60 : for( int i = 0; i < ndims; i++ )
3902 : {
3903 80 : auto poDim = poGroup->CreateDimension(std::string(CPLSPrintf("dim%d", i)),
3904 40 : std::string(),
3905 40 : std::string(),
3906 40 : PyArray_DIMS(psArray)[i],
3907 120 : nullptr);
3908 40 : apoDims.push_back(poDim);
3909 40 : if( i > 0 )
3910 20 : strides += ',';
3911 40 : strides += CPLSPrintf(CPL_FRMT_GIB,
3912 40 : static_cast<GIntBig>(PyArray_STRIDES(psArray)[i]));
3913 : }
3914 40 : CPLStringList aosOptions;
3915 20 : aosOptions.SetNameValue("STRIDES", strides.c_str());
3916 20 : auto mdArray = MEMGroupCreateMDArray(poGroup.get(), "array",
3917 : apoDims,
3918 20 : GDALExtendedDataType::Create(eType),
3919 : PyArray_DATA(psArray),
3920 60 : aosOptions.List());
3921 20 : if( !mdArray )
3922 : {
3923 0 : delete poMEMDS;
3924 0 : return nullptr;
3925 : }
3926 :
3927 20 : auto poDS = new NUMPYMultiDimensionalDataset();
3928 20 : poDS->poDriver = GDALDriver::FromHandle(GDALGetDriverByName("NUMPY"));
3929 20 : poDS->psArray = psArray;
3930 20 : Py_INCREF( psArray );
3931 20 : poDS->eAccess = GA_ReadOnly;
3932 20 : poDS->poMEMDS.reset(poMEMDS);
3933 : return poDS;
3934 : }
3935 :
3936 :
3937 :
3938 0 : int GDALTermProgress_nocb( double dfProgress, const char * pszMessage=NULL, void *pData=NULL ) {
3939 0 : return GDALTermProgress( dfProgress, pszMessage, pData);
3940 : }
3941 :
3942 :
3943 : SWIGINTERN swig_type_info*
3944 0 : SWIG_pchar_descriptor(void)
3945 : {
3946 0 : static int init = 0;
3947 0 : static swig_type_info* info = 0;
3948 0 : if (!init) {
3949 0 : info = SWIG_TypeQuery("_p_char");
3950 0 : init = 1;
3951 : }
3952 0 : return info;
3953 : }
3954 :
3955 :
3956 : SWIGINTERN int
3957 0 : SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
3958 : {
3959 : #if PY_VERSION_HEX>=0x03000000
3960 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3961 : if (PyBytes_Check(obj))
3962 : #else
3963 0 : if (PyUnicode_Check(obj))
3964 : #endif
3965 : #else
3966 : if (PyString_Check(obj))
3967 : #endif
3968 : {
3969 0 : char *cstr; Py_ssize_t len;
3970 0 : int ret = SWIG_OK;
3971 : #if PY_VERSION_HEX>=0x03000000
3972 : #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3973 0 : if (!alloc && cptr) {
3974 : /* We can't allow converting without allocation, since the internal
3975 : representation of string in Python 3 is UCS-2/UCS-4 but we require
3976 : a UTF-8 representation.
3977 : TODO(bhy) More detailed explanation */
3978 : return SWIG_RuntimeError;
3979 : }
3980 0 : obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
3981 0 : if (!obj)
3982 : return SWIG_TypeError;
3983 0 : if (alloc)
3984 0 : *alloc = SWIG_NEWOBJ;
3985 : #endif
3986 0 : PyBytes_AsStringAndSize(obj, &cstr, &len);
3987 : #else
3988 : PyString_AsStringAndSize(obj, &cstr, &len);
3989 : #endif
3990 0 : if (cptr) {
3991 0 : if (alloc) {
3992 0 : if (*alloc == SWIG_NEWOBJ) {
3993 0 : *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
3994 0 : *alloc = SWIG_NEWOBJ;
3995 : } else {
3996 0 : *cptr = cstr;
3997 0 : *alloc = SWIG_OLDOBJ;
3998 : }
3999 : } else {
4000 : #if PY_VERSION_HEX>=0x03000000
4001 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4002 : *cptr = PyBytes_AsString(obj);
4003 : #else
4004 : assert(0); /* Should never reach here with Unicode strings in Python 3 */
4005 : #endif
4006 : #else
4007 : *cptr = SWIG_Python_str_AsChar(obj);
4008 : if (!*cptr)
4009 : ret = SWIG_TypeError;
4010 : #endif
4011 : }
4012 : }
4013 0 : if (psize) *psize = len + 1;
4014 : #if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4015 0 : Py_XDECREF(obj);
4016 : #endif
4017 0 : return ret;
4018 : } else {
4019 : #if defined(SWIG_PYTHON_2_UNICODE)
4020 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4021 : #error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
4022 : #endif
4023 : #if PY_VERSION_HEX<0x03000000
4024 : if (PyUnicode_Check(obj)) {
4025 : char *cstr; Py_ssize_t len;
4026 : if (!alloc && cptr) {
4027 : return SWIG_RuntimeError;
4028 : }
4029 : obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
4030 : if (!obj)
4031 : return SWIG_TypeError;
4032 : if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
4033 : if (cptr) {
4034 : if (alloc) *alloc = SWIG_NEWOBJ;
4035 : *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
4036 : }
4037 : if (psize) *psize = len + 1;
4038 :
4039 : Py_XDECREF(obj);
4040 : return SWIG_OK;
4041 : } else {
4042 : Py_XDECREF(obj);
4043 : }
4044 : }
4045 : #endif
4046 : #endif
4047 :
4048 0 : swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
4049 0 : if (pchar_descriptor) {
4050 0 : void* vptr = 0;
4051 0 : if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
4052 0 : if (cptr) *cptr = (char *) vptr;
4053 0 : if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
4054 0 : if (alloc) *alloc = SWIG_OLDOBJ;
4055 0 : return SWIG_OK;
4056 : }
4057 : }
4058 : }
4059 : return SWIG_TypeError;
4060 : }
4061 :
4062 :
4063 :
4064 :
4065 :
4066 :
4067 : typedef struct {
4068 : PyObject *psPyCallback;
4069 : PyObject *psPyCallbackData;
4070 : int nLastReported;
4071 : } PyProgressData;
4072 :
4073 : /************************************************************************/
4074 : /* PyProgressProxy() */
4075 : /************************************************************************/
4076 :
4077 :
4078 : static int CPL_STDCALL
4079 : PyProgressProxy( double dfComplete, const char *pszMessage, void *pData ) CPL_UNUSED;
4080 :
4081 : static int CPL_STDCALL
4082 362 : PyProgressProxy( double dfComplete, const char *pszMessage, void *pData )
4083 :
4084 : {
4085 362 : PyProgressData *psInfo = (PyProgressData *) pData;
4086 362 : PyObject *psArgs, *psResult;
4087 362 : int bContinue = TRUE;
4088 :
4089 362 : if( dfComplete > 0 && psInfo->nLastReported == (int) (100.0 * dfComplete) )
4090 : return TRUE;
4091 :
4092 264 : if( psInfo->psPyCallback == NULL || psInfo->psPyCallback == Py_None )
4093 : return TRUE;
4094 :
4095 264 : psInfo->nLastReported = (int) (100.0 * dfComplete);
4096 :
4097 264 : if( pszMessage == NULL )
4098 0 : pszMessage = "";
4099 :
4100 626 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
4101 :
4102 264 : if( psInfo->psPyCallbackData == NULL )
4103 0 : psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage, Py_None );
4104 : else
4105 264 : psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage,
4106 : psInfo->psPyCallbackData );
4107 :
4108 264 : psResult = PyObject_CallObject( psInfo->psPyCallback, psArgs);
4109 264 : Py_XDECREF(psArgs);
4110 :
4111 264 : if( PyErr_Occurred() != NULL )
4112 : {
4113 0 : PyErr_Print();
4114 0 : PyErr_Clear();
4115 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4116 : return FALSE;
4117 : }
4118 :
4119 264 : if( psResult == NULL )
4120 : {
4121 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4122 : return TRUE;
4123 : }
4124 :
4125 264 : if( psResult == Py_None )
4126 : {
4127 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4128 : return TRUE;
4129 : }
4130 :
4131 264 : if( !PyArg_Parse( psResult, "i", &bContinue ) )
4132 : {
4133 0 : PyErr_Clear();
4134 0 : CPLError(CE_Failure, CPLE_AppDefined, "bad progress return value");
4135 0 : Py_XDECREF(psResult);
4136 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4137 : return FALSE;
4138 : }
4139 :
4140 264 : Py_XDECREF(psResult);
4141 264 : SWIG_PYTHON_THREAD_END_BLOCK;
4142 :
4143 264 : return bContinue;
4144 : }
4145 :
4146 :
4147 27 : GDALDatasetShadow* OpenNumPyArray(PyArrayObject *psArray, bool binterleave)
4148 : {
4149 27 : return NUMPYDataset::Open( psArray, binterleave );
4150 : }
4151 :
4152 :
4153 : SWIGINTERN int
4154 134 : SWIG_AsVal_bool (PyObject *obj, bool *val)
4155 : {
4156 134 : int r;
4157 134 : if (!PyBool_Check(obj))
4158 : return SWIG_ERROR;
4159 134 : r = PyObject_IsTrue(obj);
4160 134 : if (r == -1)
4161 : return SWIG_ERROR;
4162 134 : if (val) *val = r ? true : false;
4163 : return SWIG_OK;
4164 : }
4165 :
4166 :
4167 21 : GDALDatasetShadow* OpenMultiDimensionalNumPyArray(PyArrayObject *psArray)
4168 : {
4169 21 : return NUMPYMultiDimensionalDataset::Open( psArray );
4170 : }
4171 :
4172 :
4173 2 : retStringAndCPLFree* GetArrayFilename(PyArrayObject *psArray)
4174 : {
4175 2 : char szString[128];
4176 :
4177 2 : GDALRegister_NUMPY();
4178 :
4179 : /* I wish I had a safe way of checking the type */
4180 2 : snprintf( szString, sizeof(szString), "NUMPY:::%p", psArray );
4181 2 : return CPLStrdup(szString);
4182 : }
4183 :
4184 :
4185 14697 : CPLErr BandRasterIONumPy( GDALRasterBandShadow* band, int bWrite, double xoff, double yoff, double xsize, double ysize,
4186 : PyArrayObject *psArray,
4187 : GDALDataType buf_type,
4188 : GDALRIOResampleAlg resample_alg,
4189 : GDALProgressFunc callback = NULL,
4190 : void* callback_data = NULL) {
4191 :
4192 14697 : if( PyArray_NDIM(psArray) < 2 || PyArray_NDIM(psArray) > 3 )
4193 : {
4194 0 : CPLError( CE_Failure, CPLE_AppDefined,
4195 : "Illegal numpy array rank %d.\n",
4196 : PyArray_NDIM(psArray) );
4197 0 : return CE_Failure;
4198 : }
4199 :
4200 14697 : if( !bWrite && !(PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) )
4201 : {
4202 2 : CPLError( CE_Failure, CPLE_AppDefined,
4203 : "Cannot read in a non-writeable array." );
4204 2 : return CE_Failure;
4205 : }
4206 :
4207 14695 : int xdim = ( PyArray_NDIM(psArray) == 2) ? 1 : 2;
4208 14695 : int ydim = ( PyArray_NDIM(psArray) == 2) ? 0 : 1;
4209 :
4210 14695 : if( PyArray_DIMS(psArray)[xdim] > INT_MAX ||
4211 14695 : PyArray_DIMS(psArray)[ydim] > INT_MAX )
4212 : {
4213 0 : CPLError(CE_Failure, CPLE_NotSupported,
4214 : "Too big array dimensions");
4215 0 : return CE_Failure;
4216 : }
4217 14695 : int nxsize, nysize;
4218 14695 : GSpacing pixel_space, line_space;
4219 14695 : nxsize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
4220 14695 : nysize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
4221 14695 : pixel_space = PyArray_STRIDES(psArray)[xdim];
4222 14695 : line_space = PyArray_STRIDES(psArray)[ydim];
4223 :
4224 14695 : GDALRasterIOExtraArg sExtraArg;
4225 14695 : INIT_RASTERIO_EXTRA_ARG(sExtraArg);
4226 14695 : sExtraArg.eResampleAlg = resample_alg;
4227 14695 : sExtraArg.pfnProgress = callback;
4228 14695 : sExtraArg.pProgressData = callback_data;
4229 14695 : int nXOff = (int)(xoff + 0.5);
4230 14695 : int nYOff = (int)(yoff + 0.5);
4231 14695 : int nXSize = (int)(xsize + 0.5);
4232 14695 : int nYSize = (int)(ysize + 0.5);
4233 14695 : if( fabs(xoff-nXOff) > 1e-8 || fabs(yoff-nYOff) > 1e-8 ||
4234 14634 : fabs(xsize-nXSize) > 1e-8 || fabs(ysize-nYSize) > 1e-8 )
4235 : {
4236 61 : sExtraArg.bFloatingPointWindowValidity = TRUE;
4237 61 : sExtraArg.dfXOff = xoff;
4238 61 : sExtraArg.dfYOff = yoff;
4239 61 : sExtraArg.dfXSize = xsize;
4240 61 : sExtraArg.dfYSize = ysize;
4241 : }
4242 :
4243 20459 : return GDALRasterIOEx( band, (bWrite) ? GF_Write : GF_Read, nXOff, nYOff, nXSize, nYSize,
4244 : PyArray_DATA(psArray), nxsize, nysize,
4245 : buf_type, pixel_space, line_space, &sExtraArg );
4246 : }
4247 :
4248 :
4249 29 : CPLErr DatasetIONumPy( GDALDatasetShadow* ds, int bWrite, double xoff, double yoff, double xsize, double ysize,
4250 : PyArrayObject *psArray,
4251 : GDALDataType buf_type,
4252 : GDALRIOResampleAlg resample_alg,
4253 : GDALProgressFunc callback = NULL,
4254 : void* callback_data = NULL,
4255 : bool binterleave = true,
4256 : int band_list = 0, int *pband_list = 0 )
4257 : {
4258 29 : if( PyArray_NDIM(psArray) != 3 )
4259 : {
4260 0 : CPLError( CE_Failure, CPLE_AppDefined,
4261 : "Illegal numpy array rank %d.",
4262 : PyArray_NDIM(psArray) );
4263 0 : return CE_Failure;
4264 : }
4265 :
4266 29 : if( !bWrite && !(PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) )
4267 : {
4268 0 : CPLError( CE_Failure, CPLE_AppDefined,
4269 : "Cannot read in a non-writeable array." );
4270 0 : return CE_Failure;
4271 : }
4272 :
4273 29 : int xdim = binterleave ? 2 : 1;
4274 29 : int ydim = binterleave ? 1 : 0;
4275 29 : int bdim = binterleave ? 0 : 2;
4276 29 : if( PyArray_DIMS(psArray)[xdim] > INT_MAX ||
4277 29 : PyArray_DIMS(psArray)[ydim] > INT_MAX ||
4278 29 : PyArray_DIMS(psArray)[bdim] > INT_MAX )
4279 : {
4280 0 : CPLError(CE_Failure, CPLE_NotSupported,
4281 : "Too big array dimensions");
4282 0 : return CE_Failure;
4283 : }
4284 :
4285 29 : int bandsize, nxsize, nysize;
4286 29 : GIntBig pixel_space, line_space, band_space;
4287 29 : nxsize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
4288 29 : nysize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
4289 29 : bandsize = static_cast<int>(PyArray_DIMS(psArray)[bdim]);
4290 29 : int bandcount = band_list ? band_list : GDALGetRasterCount(ds);
4291 29 : if( bandsize != bandcount )
4292 : {
4293 0 : CPLError( CE_Failure, CPLE_AppDefined,
4294 : "Illegal numpy array band dimension %d. Expected value: %d",
4295 : bandsize, bandcount );
4296 0 : return CE_Failure;
4297 : }
4298 29 : pixel_space = PyArray_STRIDES(psArray)[xdim];
4299 29 : line_space = PyArray_STRIDES(psArray)[ydim];
4300 29 : band_space = PyArray_STRIDES(psArray)[bdim];
4301 :
4302 29 : GDALRasterIOExtraArg sExtraArg;
4303 29 : INIT_RASTERIO_EXTRA_ARG(sExtraArg);
4304 29 : sExtraArg.eResampleAlg = resample_alg;
4305 29 : sExtraArg.pfnProgress = callback;
4306 29 : sExtraArg.pProgressData = callback_data;
4307 29 : int nXOff = (int)(xoff + 0.5);
4308 29 : int nYOff = (int)(yoff + 0.5);
4309 29 : int nXSize = (int)(xsize + 0.5);
4310 29 : int nYSize = (int)(ysize + 0.5);
4311 29 : if( fabs(xoff-nXOff) > 1e-8 || fabs(yoff-nYOff) > 1e-8 ||
4312 28 : fabs(xsize-nXSize) > 1e-8 || fabs(ysize-nYSize) > 1e-8 )
4313 : {
4314 1 : sExtraArg.bFloatingPointWindowValidity = TRUE;
4315 1 : sExtraArg.dfXOff = xoff;
4316 1 : sExtraArg.dfYOff = yoff;
4317 1 : sExtraArg.dfXSize = xsize;
4318 1 : sExtraArg.dfYSize = ysize;
4319 : }
4320 :
4321 54 : return GDALDatasetRasterIOEx( ds, (bWrite) ? GF_Write : GF_Read, nXOff, nYOff, nXSize, nYSize,
4322 : PyArray_DATA(psArray), nxsize, nysize,
4323 : buf_type,
4324 : bandcount, pband_list,
4325 : pixel_space, line_space, band_space, &sExtraArg );
4326 : }
4327 :
4328 :
4329 : static int*
4330 29 : CreateCIntListFromSequence( PyObject* pySeq, int* pnSize ) {
4331 : /* check if is List */
4332 29 : if ( !PySequence_Check(pySeq) ) {
4333 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4334 0 : *pnSize = -1;
4335 0 : return NULL;
4336 : }
4337 29 : Py_ssize_t size = PySequence_Size(pySeq);
4338 29 : if( size > (Py_ssize_t)INT_MAX ) {
4339 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4340 0 : *pnSize = -1;
4341 0 : return NULL;
4342 : }
4343 29 : if( (size_t)size > SIZE_MAX / sizeof(int) ) {
4344 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4345 0 : *pnSize = -1;
4346 0 : return NULL;
4347 : }
4348 29 : *pnSize = (int)size;
4349 29 : int* ret = (int*) malloc((*pnSize)*sizeof(int));
4350 29 : if( !ret ) {
4351 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4352 0 : *pnSize = -1;
4353 0 : return NULL;
4354 : }
4355 106 : for( int i = 0; i<*pnSize; i++ ) {
4356 77 : PyObject *o = PySequence_GetItem(pySeq,i);
4357 77 : if ( !PyArg_Parse(o,"i",&ret[i]) ) {
4358 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4359 0 : Py_DECREF(o);
4360 0 : free(ret);
4361 0 : *pnSize = -1;
4362 0 : return NULL;
4363 : }
4364 77 : Py_DECREF(o);
4365 : }
4366 : return ret;
4367 : }
4368 :
4369 :
4370 84 : static bool CheckNumericDataType(GDALExtendedDataTypeHS* dt)
4371 : {
4372 84 : auto klass = GDALExtendedDataTypeGetClass(dt);
4373 84 : if( klass == GEDTC_NUMERIC )
4374 : return true;
4375 3 : if( klass == GEDTC_STRING )
4376 : return false;
4377 3 : CPLAssert( klass == GEDTC_COMPOUND );
4378 3 : size_t nCount = 0;
4379 3 : GDALEDTComponentH* comps = GDALExtendedDataTypeGetComponents(dt, &nCount);
4380 : bool ret = true;
4381 9 : for( size_t i = 0; i < nCount; i++ )
4382 : {
4383 6 : auto tmpType = GDALEDTComponentGetType(comps[i]);
4384 6 : ret = CheckNumericDataType(tmpType);
4385 6 : GDALExtendedDataTypeRelease(tmpType);
4386 6 : if( !ret )
4387 : break;
4388 : }
4389 3 : GDALExtendedDataTypeFreeComponents(comps, nCount);
4390 : return ret;
4391 : }
4392 :
4393 :
4394 78 : CPLErr MDArrayIONumPy( bool bWrite,
4395 : GDALMDArrayHS* mdarray,
4396 : PyArrayObject *psArray,
4397 : int nDims1, GUIntBig* array_start_idx,
4398 : int nDims3, GIntBig* array_step,
4399 : GDALExtendedDataTypeHS* buffer_datatype) {
4400 :
4401 78 : if( !CheckNumericDataType(buffer_datatype) )
4402 : {
4403 0 : CPLError(CE_Failure, CPLE_NotSupported,
4404 : "String buffer data type not supported in SWIG bindings");
4405 0 : return CE_Failure;
4406 : }
4407 78 : const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(mdarray);
4408 78 : if( PyArray_NDIM(psArray) != nExpectedDims )
4409 : {
4410 0 : CPLError( CE_Failure, CPLE_AppDefined,
4411 : "Illegal numpy array rank %d.",
4412 : PyArray_NDIM(psArray) );
4413 0 : return CE_Failure;
4414 : }
4415 :
4416 156 : std::vector<size_t> count_internal(nExpectedDims+1);
4417 156 : std::vector<GPtrDiff_t> buffer_stride_internal(nExpectedDims+1);
4418 78 : const size_t nDTSize = GDALExtendedDataTypeGetSize(buffer_datatype);
4419 78 : if( nDTSize == 0 )
4420 : {
4421 : return CE_Failure;
4422 : }
4423 196 : for( int i = 0; i < nExpectedDims; i++ )
4424 : {
4425 118 : count_internal[i] = PyArray_DIMS(psArray)[i];
4426 118 : if( (PyArray_STRIDES(psArray)[i] % nDTSize) != 0 )
4427 : {
4428 0 : CPLError( CE_Failure, CPLE_AppDefined,
4429 : "Stride[%d] not a multiple of data type size",
4430 : i );
4431 : return CE_Failure;
4432 : }
4433 118 : buffer_stride_internal[i] = PyArray_STRIDES(psArray)[i] / nDTSize;
4434 : }
4435 :
4436 78 : if( bWrite )
4437 : {
4438 14 : return GDALMDArrayWrite( mdarray,
4439 : array_start_idx,
4440 14 : &count_internal[0],
4441 : array_step,
4442 14 : &buffer_stride_internal[0],
4443 : buffer_datatype,
4444 14 : PyArray_DATA(psArray),
4445 14 : NULL, 0) ? CE_None : CE_Failure;
4446 : }
4447 : else
4448 : {
4449 64 : return GDALMDArrayRead( mdarray,
4450 : array_start_idx,
4451 64 : &count_internal[0],
4452 : array_step,
4453 64 : &buffer_stride_internal[0],
4454 : buffer_datatype,
4455 : PyArray_DATA(psArray),
4456 64 : NULL, 0) ? CE_None : CE_Failure;
4457 : }
4458 : }
4459 :
4460 :
4461 : static GUIntBig*
4462 78 : CreateCGUIntBigListFromSequence( PyObject* pySeq, int* pnSize ) {
4463 : /* check if is List */
4464 78 : if ( !PySequence_Check(pySeq) ) {
4465 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4466 0 : *pnSize = -1;
4467 0 : return NULL;
4468 : }
4469 78 : Py_ssize_t size = PySequence_Size(pySeq);
4470 78 : if( size > (Py_ssize_t)INT_MAX ) {
4471 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4472 0 : *pnSize = -1;
4473 0 : return NULL;
4474 : }
4475 78 : if( (size_t)size > SIZE_MAX / sizeof(GUIntBig) ) {
4476 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4477 0 : *pnSize = -1;
4478 0 : return NULL;
4479 : }
4480 78 : *pnSize = (int)size;
4481 78 : GUIntBig* ret = (GUIntBig*) malloc((*pnSize)*sizeof(GUIntBig));
4482 78 : if( !ret ) {
4483 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4484 0 : *pnSize = -1;
4485 0 : return NULL;
4486 : }
4487 196 : for( int i = 0; i<*pnSize; i++ ) {
4488 118 : PyObject *o = PySequence_GetItem(pySeq,i);
4489 118 : if ( !PyArg_Parse(o,"K",&ret[i]) ) {
4490 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4491 0 : Py_DECREF(o);
4492 0 : free(ret);
4493 0 : *pnSize = -1;
4494 0 : return NULL;
4495 : }
4496 118 : Py_DECREF(o);
4497 : }
4498 : return ret;
4499 : }
4500 :
4501 :
4502 : static GIntBig*
4503 78 : CreateCGIntBigListFromSequence( PyObject* pySeq, int* pnSize ) {
4504 : /* check if is List */
4505 78 : if ( !PySequence_Check(pySeq) ) {
4506 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4507 0 : *pnSize = -1;
4508 0 : return NULL;
4509 : }
4510 78 : Py_ssize_t size = PySequence_Size(pySeq);
4511 78 : if( size > (Py_ssize_t)INT_MAX ) {
4512 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4513 0 : *pnSize = -1;
4514 0 : return NULL;
4515 : }
4516 78 : if( (size_t)size > SIZE_MAX / sizeof(GIntBig) ) {
4517 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4518 0 : *pnSize = -1;
4519 0 : return NULL;
4520 : }
4521 78 : *pnSize = (int)size;
4522 78 : GIntBig* ret = (GIntBig*) malloc((*pnSize)*sizeof(GIntBig));
4523 78 : if( !ret ) {
4524 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4525 0 : *pnSize = -1;
4526 0 : return NULL;
4527 : }
4528 196 : for( int i = 0; i<*pnSize; i++ ) {
4529 118 : PyObject *o = PySequence_GetItem(pySeq,i);
4530 118 : if ( !PyArg_Parse(o,"L",&ret[i]) ) {
4531 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4532 0 : Py_DECREF(o);
4533 0 : free(ret);
4534 0 : *pnSize = -1;
4535 0 : return NULL;
4536 : }
4537 118 : Py_DECREF(o);
4538 : }
4539 : return ret;
4540 : }
4541 :
4542 :
4543 : typedef void* VoidPtrAsLong;
4544 :
4545 7624 : static bool AddNumpyArrayToDict(PyObject *dict,
4546 : const struct ArrowSchema* schemaField,
4547 : const struct ArrowArray* arrayField,
4548 : const std::string& osPrefix,
4549 : PyObject* pointerArrayKeeper)
4550 : {
4551 7624 : npy_intp dims = arrayField->length;
4552 7624 : const char* arrowType = schemaField->format;
4553 7624 : int typenum = -1;
4554 7624 : int sizeOfType = 0;
4555 7624 : const struct
4556 : {
4557 : char arrowType;
4558 : int numpyType;
4559 : int sizeOfType;
4560 7624 : } MapArrowTypeToNumpyType[] = {
4561 : { 'b', NPY_BOOL, 1 },
4562 : { 'C', NPY_UINT8, 1 },
4563 : { 'c', NPY_INT8, 1 },
4564 : { 'S', NPY_UINT16, 2 },
4565 : { 's', NPY_INT16, 2 },
4566 : { 'I', NPY_UINT32, 4 },
4567 : { 'i', NPY_INT32, 4 },
4568 : { 'L', NPY_UINT64, 8 },
4569 : { 'l', NPY_INT64, 8 },
4570 : { 'e', NPY_FLOAT16, 2 },
4571 : { 'f', NPY_FLOAT32, 4 },
4572 : { 'g', NPY_FLOAT64, 8 },
4573 : };
4574 7624 : const size_t nEltsInMapArrowTypeToNumpyType =
4575 : sizeof(MapArrowTypeToNumpyType) / sizeof(MapArrowTypeToNumpyType[0]);
4576 17622 : const bool bIsLargeList = (arrowType[0] == '+' &&
4577 2374 : arrowType[1] == 'L' &&
4578 7779 : arrowType[2] == '\0' &&
4579 155 : schemaField->n_children == 1);
4580 17622 : const bool bIsList = (arrowType[0] == '+' &&
4581 2374 : arrowType[1] == 'l' &&
4582 8897 : arrowType[2] == '\0' &&
4583 1273 : schemaField->n_children == 1);
4584 17622 : const bool bIsFixedSizeList = (arrowType[0] == '+' &&
4585 2374 : arrowType[1] == 'w' &&
4586 8404 : arrowType[2] == ':' &&
4587 780 : schemaField->n_children == 1);
4588 72217 : for( size_t j = 0; j < nEltsInMapArrowTypeToNumpyType; ++j )
4589 : {
4590 69157 : if( arrowType[0] == MapArrowTypeToNumpyType[j].arrowType &&
4591 2769 : arrowType[1] == '\0' )
4592 : {
4593 2769 : typenum = MapArrowTypeToNumpyType[j].numpyType;
4594 2769 : sizeOfType = MapArrowTypeToNumpyType[j].sizeOfType;
4595 2769 : break;
4596 : }
4597 66388 : else if( (bIsList || bIsLargeList || bIsFixedSizeList) &&
4598 16998 : schemaField->children[0]->format[0] == MapArrowTypeToNumpyType[j].arrowType &&
4599 1795 : schemaField->children[0]->format[1] == '\0' )
4600 : {
4601 1795 : typenum = MapArrowTypeToNumpyType[j].numpyType;
4602 1795 : sizeOfType = MapArrowTypeToNumpyType[j].sizeOfType;
4603 1795 : break;
4604 : }
4605 : }
4606 :
4607 7624 : PyObject* numpyArray = NULL;
4608 7624 : if( typenum != -1 && !bIsList && !bIsLargeList && schemaField->n_children == 0 )
4609 : {
4610 2769 : if( arrayField->n_buffers != 2 )
4611 : {
4612 0 : CPLError(CE_Failure, CPLE_AppDefined,
4613 : "Field %s: arrayField->n_buffers != 2",
4614 0 : schemaField->name);
4615 0 : return false;
4616 : }
4617 2769 : if( typenum == NPY_BOOL )
4618 : {
4619 156 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_BOOL);
4620 478 : for( npy_intp j = 0; j < dims; j++ )
4621 : {
4622 322 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4623 322 : uint8_t val = (((uint8_t*)arrayField->buffers[1])[srcOffset/8] >> (srcOffset % 8)) & 1;
4624 322 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) = val;
4625 : }
4626 : }
4627 : else
4628 : {
4629 2613 : numpyArray = PyArray_SimpleNewFromData(1, &dims, typenum,
4630 : (char*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset) * sizeOfType);
4631 :
4632 : /* Keep a reference to the owner object */
4633 : #if NPY_API_VERSION >= 0x00000007
4634 2613 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
4635 : #else
4636 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
4637 : #endif
4638 2613 : Py_INCREF(pointerArrayKeeper);
4639 : }
4640 : }
4641 4855 : else if( typenum != -1 && (bIsList || bIsLargeList) )
4642 : {
4643 1080 : if( arrayField->n_buffers != 2 )
4644 : {
4645 0 : CPLError(CE_Failure, CPLE_AppDefined,
4646 : "Field %s: arrayField->n_buffers != 2",
4647 0 : schemaField->name);
4648 0 : return false;
4649 : }
4650 1080 : if( arrayField->n_children != 1 )
4651 : {
4652 0 : CPLError(CE_Failure, CPLE_AppDefined,
4653 : "Field %s: arrayField->n_children != 1",
4654 0 : schemaField->name);
4655 0 : return false;
4656 : }
4657 1080 : if( arrayField->children[0]->n_buffers != 2 )
4658 : {
4659 0 : CPLError(CE_Failure, CPLE_AppDefined,
4660 : "Field %s: arrayField->children[0]->n_buffers != 2",
4661 0 : schemaField->name);
4662 0 : return false;
4663 : }
4664 1080 : const int32_t* offsets = bIsList ? (const int32_t*)arrayField->buffers[1] + arrayField->offset : NULL;
4665 1080 : const int64_t* largeOffsets = bIsLargeList ? (const int64_t*)arrayField->buffers[1] + arrayField->offset : NULL;
4666 1080 : if( arrayField->children[0]->length < (offsets ? offsets[arrayField->length] : largeOffsets[arrayField->length]) )
4667 : {
4668 0 : CPLError(CE_Failure, CPLE_AppDefined,
4669 : "Field %s: arrayField->children[0]->length (=%d) < offsets[arrayField->length] (=%d)",
4670 0 : schemaField->name,
4671 : int(arrayField->children[0]->length),
4672 0 : int(offsets ? offsets[arrayField->length] : largeOffsets[arrayField->length]));
4673 0 : return false;
4674 : }
4675 1080 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4676 3062 : for( npy_intp j = 0; j < dims; j++ )
4677 : {
4678 1982 : npy_intp nvalues = offsets ? offsets[j+1] - offsets[j] : (npy_intp)(largeOffsets[j+1] - largeOffsets[j]);
4679 1982 : PyObject* subObj;
4680 1982 : if( typenum == NPY_BOOL )
4681 : {
4682 214 : subObj = PyArray_SimpleNew(1, &nvalues, NPY_BOOL);
4683 632 : for( npy_intp k = 0; k < nvalues; k++ )
4684 : {
4685 418 : size_t srcOffset = static_cast<size_t>(arrayField->children[0]->offset + (offsets ? offsets[j] : largeOffsets[j]) + k);
4686 418 : uint8_t val = (((uint8_t*)arrayField->children[0]->buffers[1])[srcOffset / 8] >> (srcOffset % 8)) & 1;
4687 418 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) subObj, k) = val;
4688 : }
4689 : }
4690 : else
4691 : {
4692 1768 : subObj = PyArray_SimpleNewFromData(
4693 : 1, &nvalues, typenum,
4694 : (char*)arrayField->children[0]->buffers[1] + (static_cast<size_t>(arrayField->children[0]->offset) + (offsets ? offsets[j] : largeOffsets[j])) * sizeOfType);
4695 : /* Keep a reference to the owner object */
4696 : #if NPY_API_VERSION >= 0x00000007
4697 1768 : PyArray_SetBaseObject((PyArrayObject *) subObj, pointerArrayKeeper);
4698 : #else
4699 : PyArray_BASE((PyArrayObject *) subObj) = pointerArrayKeeper;
4700 : #endif
4701 1768 : Py_INCREF(pointerArrayKeeper);
4702 : }
4703 1982 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4704 : &subObj,
4705 : sizeof(PyObject*));
4706 : }
4707 : }
4708 3775 : else if( typenum != -1 && bIsFixedSizeList )
4709 : {
4710 715 : if( arrayField->n_buffers != 1 )
4711 : {
4712 0 : CPLError(CE_Failure, CPLE_AppDefined,
4713 : "Field %s: arrayField->n_buffers != 1",
4714 0 : schemaField->name);
4715 0 : return false;
4716 : }
4717 715 : if( arrayField->n_children != 1 )
4718 : {
4719 0 : CPLError(CE_Failure, CPLE_AppDefined,
4720 : "Field %s: arrayField->n_children != 1",
4721 0 : schemaField->name);
4722 0 : return false;
4723 : }
4724 715 : const struct ArrowArray* psChildArray = arrayField->children[0];
4725 715 : if( psChildArray->n_buffers != 2 )
4726 : {
4727 0 : CPLError(CE_Failure, CPLE_AppDefined,
4728 : "Field %s: psChildArray->n_buffers != 2",
4729 0 : schemaField->name);
4730 0 : return false;
4731 : }
4732 715 : const int nLength = atoi(arrowType + strlen("+w:"));
4733 715 : if( psChildArray->length < nLength * arrayField->length )
4734 : {
4735 0 : CPLError(CE_Failure, CPLE_AppDefined,
4736 : "Field %s: psChildArray->length < nLength * arrayField->length",
4737 0 : schemaField->name);
4738 0 : return false;
4739 : }
4740 715 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4741 1936 : for( npy_intp j = 0; j < dims; j++ )
4742 : {
4743 1221 : PyObject* subObj;
4744 1221 : npy_intp nvalues = nLength;
4745 1221 : if( typenum == NPY_BOOL )
4746 : {
4747 111 : subObj = PyArray_SimpleNew(1, &nvalues, NPY_BOOL);
4748 333 : for( npy_intp k = 0; k < nvalues; k++ )
4749 : {
4750 222 : size_t srcOffset = static_cast<size_t>(psChildArray->offset + (j + arrayField->offset) * nLength + k);
4751 222 : uint8_t val = (((uint8_t*)psChildArray->buffers[1])[srcOffset / 8] >> (srcOffset % 8)) & 1;
4752 222 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) subObj, k) = val;
4753 : }
4754 : }
4755 : else
4756 : {
4757 1110 : subObj = PyArray_SimpleNewFromData(
4758 : 1, &nvalues, typenum,
4759 : (char*)psChildArray->buffers[1] + static_cast<size_t>((psChildArray->offset + (j + arrayField->offset) * nLength) * sizeOfType));
4760 : /* Keep a reference to the owner object */
4761 : #if NPY_API_VERSION >= 0x00000007
4762 1110 : PyArray_SetBaseObject((PyArrayObject *) subObj, pointerArrayKeeper);
4763 : #else
4764 : PyArray_BASE((PyArrayObject *) subObj) = pointerArrayKeeper;
4765 : #endif
4766 1110 : Py_INCREF(pointerArrayKeeper);
4767 : }
4768 1221 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4769 : &subObj,
4770 : sizeof(PyObject*));
4771 : }
4772 : }
4773 3060 : else if( (arrowType[0] == 'u' || /* string */
4774 1243 : arrowType[0] == 'z' /* binary */) && arrowType[1] == '\0' &&
4775 1243 : schemaField->n_children == 0 )
4776 : {
4777 1243 : if( arrayField->n_buffers != 3 )
4778 : {
4779 0 : CPLError(CE_Failure, CPLE_AppDefined,
4780 : "Field %s: arrayField->n_buffers != 3",
4781 0 : schemaField->name);
4782 0 : return false;
4783 : }
4784 1243 : const int32_t* offsets = (const int32_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
4785 : // numpy can't deal with zero length strings
4786 1243 : int32_t maxLength = 1;
4787 1243 : int32_t minLength = 0x7FFFFFFF;
4788 1243 : int64_t averageLength = 0;
4789 8053 : for( npy_intp j = 0; j < dims; j++ )
4790 : {
4791 6810 : const int32_t nLength = offsets[j+1] - offsets[j];
4792 6810 : if( nLength < minLength )
4793 : minLength = nLength;
4794 6810 : if( nLength > maxLength )
4795 : maxLength = nLength;
4796 6810 : averageLength += nLength;
4797 : }
4798 1243 : if( dims )
4799 1243 : averageLength /= dims;
4800 :
4801 :
4802 1243 : if( arrowType[0] == 'z' && (minLength == 0 || minLength != maxLength) )
4803 : {
4804 806 : const uint8_t* panNotNulls =
4805 403 : arrayField->null_count == 0 ? NULL :
4806 : (const uint8_t*)arrayField->buffers[0];
4807 403 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4808 1391 : for( npy_intp j = 0; j < dims; j++ )
4809 : {
4810 988 : PyObject* subObj;
4811 988 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4812 988 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4813 : {
4814 810 : subObj = Py_None;
4815 810 : Py_INCREF(subObj);
4816 : }
4817 : else
4818 : {
4819 178 : const int32_t nLength = offsets[j+1] - offsets[j];
4820 178 : subObj = PyBytes_FromStringAndSize(
4821 178 : ((const char*)arrayField->buffers[2]) + offsets[j],
4822 : nLength);
4823 : }
4824 988 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4825 : &subObj,
4826 : sizeof(PyObject*));
4827 : }
4828 : }
4829 840 : else if( arrowType[0] == 'u' && dims > 0 && maxLength > 32 &&
4830 67 : maxLength > 100 * 1000 / dims &&
4831 1 : maxLength > averageLength * 2 )
4832 : {
4833 : // If the maximum string size is significantly large, and
4834 : // larger than the average one, then do not use fixed size
4835 : // strings, but create an array of string objects to save memory
4836 2 : const uint8_t* panNotNulls =
4837 1 : arrayField->null_count == 0 ? NULL :
4838 : (const uint8_t*)arrayField->buffers[0];
4839 1 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4840 4 : for( npy_intp j = 0; j < dims; j++ )
4841 : {
4842 3 : PyObject* subObj;
4843 3 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4844 3 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4845 : {
4846 1 : subObj = Py_None;
4847 1 : Py_INCREF(subObj);
4848 : }
4849 : else
4850 : {
4851 2 : const int32_t nLength = offsets[j+1] - offsets[j];
4852 2 : subObj = PyUnicode_FromStringAndSize(
4853 2 : ((const char*)arrayField->buffers[2]) + offsets[j],
4854 : nLength);
4855 : }
4856 3 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4857 : &subObj,
4858 : sizeof(PyObject*));
4859 : }
4860 : }
4861 : else
4862 : {
4863 : // create the dtype string
4864 1179 : PyObject *pDTypeString = PyUnicode_FromFormat("%c%u",
4865 : arrowType[0] == 'u' ? 'S' : 'V', maxLength);
4866 : // out type description object
4867 839 : PyArray_Descr *pDescr = NULL;
4868 839 : PyArray_DescrConverter(pDTypeString, &pDescr);
4869 839 : Py_DECREF(pDTypeString);
4870 :
4871 839 : if( minLength == maxLength )
4872 : {
4873 1050 : numpyArray = PyArray_NewFromDescr(
4874 : &PyArray_Type, pDescr, 1, &dims, NULL,
4875 525 : (char*)arrayField->buffers[2] + offsets[0], 0, NULL);
4876 :
4877 : /* Keep a reference to the owner object */
4878 : #if NPY_API_VERSION >= 0x00000007
4879 525 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
4880 : #else
4881 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
4882 : #endif
4883 525 : Py_INCREF(pointerArrayKeeper);
4884 : }
4885 : else
4886 : {
4887 : // create array
4888 314 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
4889 1151 : for( npy_intp j = 0; j < dims; j++ )
4890 : {
4891 837 : const int32_t nLength = offsets[j+1] - offsets[j];
4892 837 : if( nLength > 0 )
4893 : {
4894 1220 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4895 383 : ((const char*)arrayField->buffers[2]) + offsets[j],
4896 : nLength);
4897 : }
4898 837 : if( nLength < maxLength )
4899 : {
4900 837 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j)) + nLength,
4901 : 0,
4902 700 : maxLength - nLength);
4903 : }
4904 : }
4905 : }
4906 : }
4907 : }
4908 1817 : else if( (arrowType[0] == 'U' || /* string */
4909 228 : arrowType[0] == 'Z' /* binary */) && arrowType[1] == '\0' &&
4910 228 : schemaField->n_children == 0 )
4911 : {
4912 228 : if( arrayField->n_buffers != 3 )
4913 : {
4914 0 : CPLError(CE_Failure, CPLE_AppDefined,
4915 : "Field %s: arrayField->n_buffers != 3",
4916 0 : schemaField->name);
4917 0 : return false;
4918 : }
4919 228 : const int64_t* offsets = (const int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
4920 : // numpy can't deal with zero length strings
4921 228 : int64_t maxLength = 1;
4922 228 : int64_t minLength = ((int64_t)0x7FFFFFFF << 32) | 0xFFFFFFFF;
4923 228 : int64_t averageLength = 0;
4924 634 : for( npy_intp j = 0; j < dims; j++ )
4925 : {
4926 406 : const int64_t nLength = offsets[j+1] - offsets[j];
4927 406 : if( nLength < minLength )
4928 : minLength = nLength;
4929 406 : if( nLength > maxLength )
4930 : maxLength = nLength;
4931 406 : averageLength += nLength;
4932 : }
4933 228 : if( dims )
4934 208 : averageLength /= dims;
4935 :
4936 228 : if( arrowType[0] == 'Z' && (minLength == 0 || minLength != maxLength || maxLength > 0x7FFFFFFF) )
4937 : {
4938 90 : const uint8_t* panNotNulls =
4939 45 : arrayField->null_count == 0 ? NULL :
4940 : (const uint8_t*)arrayField->buffers[0];
4941 45 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4942 141 : for( npy_intp j = 0; j < dims; j++ )
4943 : {
4944 96 : PyObject* subObj;
4945 96 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4946 96 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4947 : {
4948 8 : subObj = Py_None;
4949 8 : Py_INCREF(subObj);
4950 : }
4951 : else
4952 : {
4953 88 : const int64_t nLength = offsets[j+1] - offsets[j];
4954 88 : subObj = PyBytes_FromStringAndSize(
4955 88 : ((const char*)arrayField->buffers[2]) + offsets[j],
4956 : static_cast<size_t>(nLength));
4957 : }
4958 96 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4959 : &subObj,
4960 : sizeof(PyObject*));
4961 : }
4962 : }
4963 183 : else if( arrowType[0] == 'U' && dims > 0 && maxLength > 32 &&
4964 0 : maxLength <= 0x7FFFFFFF &&
4965 0 : maxLength > 100 * 1000 / dims &&
4966 0 : maxLength > averageLength * 2 )
4967 : {
4968 : // If the maximum string size is significantly large, and
4969 : // larger than the average one, then do not use fixed size
4970 : // strings, but create an array of string objects to save memory
4971 0 : const uint8_t* panNotNulls =
4972 0 : arrayField->null_count == 0 ? NULL :
4973 : (const uint8_t*)arrayField->buffers[0];
4974 0 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4975 0 : for( npy_intp j = 0; j < dims; j++ )
4976 : {
4977 0 : PyObject* subObj;
4978 0 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4979 0 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4980 : {
4981 0 : subObj = Py_None;
4982 0 : Py_INCREF(subObj);
4983 : }
4984 : else
4985 : {
4986 0 : const int32_t nLength = int(offsets[j+1] - offsets[j]);
4987 0 : subObj = PyUnicode_FromStringAndSize(
4988 0 : ((const char*)arrayField->buffers[2]) + offsets[j],
4989 : nLength);
4990 : }
4991 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4992 : &subObj,
4993 : sizeof(PyObject*));
4994 : }
4995 : }
4996 : else
4997 : {
4998 : // We could possibly handle this...
4999 183 : if( maxLength > 0x7FFFFFFF )
5000 : {
5001 0 : CPLError(CE_Failure, CPLE_AppDefined,
5002 : "Field %s: too large value",
5003 0 : schemaField->name);
5004 0 : return false;
5005 : }
5006 :
5007 : // create the dtype string
5008 272 : PyObject *pDTypeString = PyUnicode_FromFormat("%c%u",
5009 : arrowType[0] == 'U' ? 'S' : 'V', static_cast<int32_t>(maxLength));
5010 : // out type description object
5011 183 : PyArray_Descr *pDescr = NULL;
5012 183 : PyArray_DescrConverter(pDTypeString, &pDescr);
5013 183 : Py_DECREF(pDTypeString);
5014 :
5015 183 : if( minLength == maxLength )
5016 : {
5017 262 : numpyArray = PyArray_NewFromDescr(
5018 : &PyArray_Type, pDescr, 1, &dims, NULL,
5019 131 : (char*)arrayField->buffers[2] + offsets[0], 0, NULL);
5020 :
5021 : /* Keep a reference to the owner object */
5022 : #if NPY_API_VERSION >= 0x00000007
5023 131 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
5024 : #else
5025 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
5026 : #endif
5027 131 : Py_INCREF(pointerArrayKeeper);
5028 : }
5029 : else
5030 : {
5031 : // create array
5032 52 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5033 159 : for( npy_intp j = 0; j < dims; j++ )
5034 : {
5035 107 : const int32_t nLength = static_cast<int32_t>(offsets[j+1] - offsets[j]);
5036 107 : if( nLength > 0 )
5037 : {
5038 157 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5039 50 : ((const char*)arrayField->buffers[2]) + offsets[j],
5040 : nLength);
5041 : }
5042 107 : if( nLength < maxLength )
5043 : {
5044 107 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j)) + nLength,
5045 : 0,
5046 74 : static_cast<int32_t>(maxLength) - nLength);
5047 : }
5048 : }
5049 : }
5050 : }
5051 : }
5052 1589 : else if( arrowType[0] == 'w' && arrowType[1] == ':' &&
5053 68 : schemaField->n_children == 0 )
5054 : {
5055 : // Fixed width binary
5056 68 : if( arrayField->n_buffers != 2 )
5057 : {
5058 0 : CPLError(CE_Failure, CPLE_AppDefined,
5059 : "field %s:arrayField->n_buffers != 2",
5060 0 : schemaField->name);
5061 0 : return false;
5062 : }
5063 68 : const int nLength = atoi(arrowType + strlen("w:"));
5064 68 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5065 187 : for( npy_intp j = 0; j < dims; j++ )
5066 : {
5067 119 : PyObject* subObj = PyBytes_FromStringAndSize(
5068 119 : ((const char*)arrayField->buffers[1]) + static_cast<size_t>(arrayField->offset + j) * nLength,
5069 119 : nLength);
5070 119 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5071 : &subObj,
5072 : sizeof(PyObject*));
5073 : }
5074 : }
5075 1521 : else if( bIsList &&
5076 348 : schemaField->children[0]->format[0] == 'u' &&
5077 88 : schemaField->children[0]->format[1] == '\0' )
5078 : {
5079 : // List of strings
5080 88 : if( arrayField->n_buffers != 2 )
5081 : {
5082 0 : CPLError(CE_Failure, CPLE_AppDefined,
5083 : "Field %s: arrayField->n_buffers != 2",
5084 0 : schemaField->name);
5085 0 : return false;
5086 : }
5087 88 : if( arrayField->n_children != 1 )
5088 : {
5089 0 : CPLError(CE_Failure, CPLE_AppDefined,
5090 : "Field %s: arrayField->n_children != 1",
5091 0 : schemaField->name);
5092 0 : return false;
5093 : }
5094 88 : if( arrayField->children[0]->n_buffers != 3 )
5095 : {
5096 0 : CPLError(CE_Failure, CPLE_AppDefined,
5097 : "Field %s: arrayField->children[0]->n_buffers != 3",
5098 0 : schemaField->name);
5099 0 : return false;
5100 : }
5101 88 : const int32_t* offsets = (const int32_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
5102 88 : if( arrayField->children[0]->length < offsets[arrayField->length] )
5103 : {
5104 0 : CPLError(CE_Failure, CPLE_AppDefined,
5105 : "Field %s: arrayField->children[0]->length = (%d) < offsets[arrayField->length] (=%d)",
5106 0 : schemaField->name,
5107 : int(arrayField->children[0]->length),
5108 : int(offsets[arrayField->length]));
5109 0 : return false;
5110 : }
5111 88 : const int32_t* offsetsToBytes = (const int32_t*)arrayField->children[0]->buffers[1] + static_cast<size_t>(arrayField->children[0]->offset);
5112 88 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5113 88 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5114 245 : for( npy_intp j = 0; j < dims; j++ )
5115 : {
5116 157 : npy_intp nStrings = offsets[j+1] - offsets[j];
5117 157 : int32_t maxLength = 1;
5118 317 : for( npy_intp k = 0; k < nStrings; k++ )
5119 : {
5120 160 : const int32_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5121 160 : if( nLength > maxLength )
5122 : maxLength = nLength;
5123 : }
5124 :
5125 : // create the dtype string
5126 157 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", maxLength);
5127 : // out type description object
5128 157 : PyArray_Descr *pDescr = NULL;
5129 157 : PyArray_DescrConverter(pDTypeString, &pDescr);
5130 157 : Py_DECREF(pDTypeString);
5131 :
5132 157 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStrings, pDescr);
5133 317 : for( npy_intp k = 0; k < nStrings; k++ )
5134 : {
5135 160 : const int32_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5136 160 : if( nLength > 0 )
5137 : {
5138 295 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5139 135 : bytes + offsetsToBytes[offsets[j] + k],
5140 : nLength);
5141 : }
5142 160 : if( nLength < maxLength )
5143 : {
5144 160 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5145 : 0,
5146 84 : maxLength - nLength);
5147 : }
5148 : }
5149 :
5150 157 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5151 : &subArray,
5152 : sizeof(PyObject*));
5153 : }
5154 : }
5155 1433 : else if( bIsLargeList &&
5156 0 : schemaField->children[0]->format[0] == 'U' &&
5157 0 : schemaField->children[0]->format[1] == '\0' )
5158 : {
5159 : // List of strings
5160 0 : if( arrayField->n_buffers != 2 )
5161 : {
5162 0 : CPLError(CE_Failure, CPLE_AppDefined,
5163 : "Field %s: arrayField->n_buffers != 2",
5164 0 : schemaField->name);
5165 0 : return false;
5166 : }
5167 0 : if( arrayField->n_children != 1 )
5168 : {
5169 0 : CPLError(CE_Failure, CPLE_AppDefined,
5170 : "Field %s: arrayField->n_children != 1",
5171 0 : schemaField->name);
5172 0 : return false;
5173 : }
5174 0 : if( arrayField->children[0]->n_buffers != 3 )
5175 : {
5176 0 : CPLError(CE_Failure, CPLE_AppDefined,
5177 : "Field %s: arrayField->children[0]->n_buffers != 3",
5178 0 : schemaField->name);
5179 0 : return false;
5180 : }
5181 0 : const int64_t* offsets = (const int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
5182 0 : if( arrayField->children[0]->length < offsets[arrayField->length] )
5183 : {
5184 0 : CPLError(CE_Failure, CPLE_AppDefined,
5185 : "Field %s: arrayField->children[0]->length = (%d) < offsets[arrayField->length] (=%d)",
5186 0 : schemaField->name,
5187 : int(arrayField->children[0]->length),
5188 : int(offsets[arrayField->length]));
5189 0 : return false;
5190 : }
5191 0 : const int64_t* offsetsToBytes = (const int64_t*)arrayField->children[0]->buffers[1] + static_cast<size_t>(arrayField->children[0]->offset);
5192 0 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5193 0 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5194 0 : for( npy_intp j = 0; j < dims; j++ )
5195 : {
5196 0 : npy_intp nStrings = offsets[j+1] - offsets[j];
5197 0 : int64_t maxLength = 1;
5198 0 : for( npy_intp k = 0; k < nStrings; k++ )
5199 : {
5200 0 : const int64_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5201 0 : if( nLength > maxLength )
5202 : maxLength = nLength;
5203 : }
5204 0 : if( maxLength >= INT_MAX )
5205 : {
5206 0 : CPLError(CE_Failure, CPLE_AppDefined, "Too large string");
5207 0 : return false;
5208 : }
5209 :
5210 : // create the dtype string
5211 0 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", int(maxLength));
5212 : // out type description object
5213 0 : PyArray_Descr *pDescr = NULL;
5214 0 : PyArray_DescrConverter(pDTypeString, &pDescr);
5215 0 : Py_DECREF(pDTypeString);
5216 :
5217 0 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStrings, pDescr);
5218 0 : for( npy_intp k = 0; k < nStrings; k++ )
5219 : {
5220 0 : const int64_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5221 0 : if( nLength > 0 )
5222 : {
5223 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5224 0 : bytes + offsetsToBytes[offsets[j] + k],
5225 : int(nLength));
5226 : }
5227 0 : if( nLength < maxLength )
5228 : {
5229 0 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5230 : 0,
5231 0 : int(maxLength - nLength));
5232 : }
5233 : }
5234 :
5235 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5236 : &subArray,
5237 : sizeof(PyObject*));
5238 : }
5239 : }
5240 1433 : else if( bIsFixedSizeList &&
5241 65 : schemaField->children[0]->format[0] == 'u' &&
5242 65 : schemaField->children[0]->format[1] == '\0' )
5243 : {
5244 : // Fixed size list of strings
5245 65 : const int nStrings = atoi(arrowType + strlen("+w:"));
5246 65 : if( arrayField->n_buffers != 1 )
5247 : {
5248 0 : CPLError(CE_Failure, CPLE_AppDefined,
5249 : "Field %s: arrayField->n_buffers != 1",
5250 0 : schemaField->name);
5251 0 : return false;
5252 : }
5253 65 : if( arrayField->n_children != 1 )
5254 : {
5255 0 : CPLError(CE_Failure, CPLE_AppDefined,
5256 : "Field %s: arrayField->n_children != 1",
5257 0 : schemaField->name);
5258 0 : return false;
5259 : }
5260 65 : if( arrayField->children[0]->n_buffers != 3 )
5261 : {
5262 0 : CPLError(CE_Failure, CPLE_AppDefined,
5263 : "Field %s: arrayField->children[0]->n_buffers != 3",
5264 0 : schemaField->name);
5265 0 : return false;
5266 : }
5267 65 : if( arrayField->children[0]->length < nStrings * arrayField->length )
5268 : {
5269 0 : CPLError(CE_Failure, CPLE_AppDefined,
5270 : "Field %s: arrayField->children[0]->length < nStrings * arrayField->length",
5271 0 : schemaField->name);
5272 0 : return false;
5273 : }
5274 65 : const int32_t* offsetsToBytes = (const int32_t*)arrayField->children[0]->buffers[1] + arrayField->offset * nStrings + static_cast<size_t>(arrayField->children[0]->offset);
5275 65 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5276 65 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5277 176 : for( npy_intp j = 0; j < dims; j++ )
5278 : {
5279 : int32_t maxLength = 1;
5280 333 : for( int k = 0; k < nStrings; k++ )
5281 : {
5282 222 : const int32_t nLength = offsetsToBytes[j * nStrings + k + 1] - offsetsToBytes[j * nStrings + k];
5283 222 : if( nLength > maxLength )
5284 : maxLength = nLength;
5285 : }
5286 :
5287 : // create the dtype string
5288 111 : PyObject *pDTypeString = PyUnicode_FromFormat("S%u", maxLength);
5289 : // out type description object
5290 111 : PyArray_Descr *pDescr = NULL;
5291 111 : PyArray_DescrConverter(pDTypeString, &pDescr);
5292 111 : Py_DECREF(pDTypeString);
5293 :
5294 111 : npy_intp nStringsNpyIntp = nStrings;
5295 111 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStringsNpyIntp, pDescr);
5296 333 : for( int k = 0; k < nStrings; k++ )
5297 : {
5298 222 : const int32_t nLength = offsetsToBytes[j * nStrings + k + 1] - offsetsToBytes[j * nStrings + k];
5299 222 : if( nLength > 0 )
5300 : {
5301 444 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5302 222 : bytes + offsetsToBytes[j * nStrings + k],
5303 : nLength);
5304 : }
5305 222 : if( nLength < maxLength )
5306 : {
5307 222 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5308 : 0,
5309 0 : maxLength - nLength);
5310 : }
5311 : }
5312 :
5313 111 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5314 : &subArray,
5315 : sizeof(PyObject*));
5316 : }
5317 : }
5318 1368 : else if( strcmp(arrowType, "tdD") == 0 &&
5319 203 : schemaField->n_children == 0 )
5320 : {
5321 : // Date(32) in days since Epoch
5322 203 : if( arrayField->n_buffers != 2 )
5323 : {
5324 0 : CPLError(CE_Failure, CPLE_AppDefined,
5325 : "Field %s: arrayField->n_buffers != 2",
5326 0 : schemaField->name);
5327 0 : return false;
5328 : }
5329 :
5330 : // create the dtype string
5331 203 : PyObject *pDTypeString = PyUnicode_FromString("datetime64[D]");
5332 : // out type description object
5333 203 : PyArray_Descr *pDescr = NULL;
5334 203 : PyArray_DescrConverter(pDTypeString, &pDescr);
5335 203 : Py_DECREF(pDTypeString);
5336 203 : CPLAssert(pDescr);
5337 :
5338 : // create array
5339 203 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5340 557 : for( npy_intp j = 0; j < dims; j++ )
5341 : {
5342 354 : *(int64_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) =
5343 354 : ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5344 203 : }
5345 : }
5346 1165 : else if( strcmp(arrowType, "ttm") == 0 &&
5347 183 : schemaField->n_children == 0 )
5348 : {
5349 : // Time(32) in milliseconds
5350 183 : if( arrayField->n_buffers != 2 )
5351 : {
5352 0 : CPLError(CE_Failure, CPLE_AppDefined,
5353 : "Field %s: arrayField->n_buffers != 2",
5354 0 : schemaField->name);
5355 0 : return false;
5356 : }
5357 : #if 0
5358 : // create the dtype string
5359 : PyObject *pDTypeString = PyUnicode_FromString("datetime64[ms]");
5360 : // out type description object
5361 : PyArray_Descr *pDescr = NULL;
5362 : PyArray_DescrConverter(pDTypeString, &pDescr);
5363 : Py_DECREF(pDTypeString);
5364 : CPLAssert(pDescr);
5365 :
5366 : // create array
5367 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5368 : for( npy_intp j = 0; j < dims; j++ )
5369 : {
5370 : *(int64_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) =
5371 : ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5372 : }
5373 : #else
5374 : // create array
5375 183 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5376 508 : for( npy_intp j = 0; j < dims; j++ )
5377 : {
5378 325 : int timeMs = ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5379 325 : PyObject* subObj = PyTime_FromTime((timeMs / 1000) / 3600,
5380 : ((timeMs / 1000) % 3600) / 60,
5381 : ((timeMs / 1000) % 3600) % 60,
5382 : (timeMs % 1000) * 1000);
5383 325 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5384 : &subObj,
5385 : sizeof(PyObject*));
5386 : }
5387 : #endif
5388 : }
5389 982 : else if( strcmp(arrowType, "ttu") == 0 &&
5390 65 : schemaField->n_children == 0 )
5391 : {
5392 : // Time(64) in microseconds
5393 65 : if( arrayField->n_buffers != 2 )
5394 : {
5395 0 : CPLError(CE_Failure, CPLE_AppDefined,
5396 : "Field %s: arrayField->n_buffers != 2",
5397 0 : schemaField->name);
5398 0 : return false;
5399 : }
5400 :
5401 : // create array
5402 65 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5403 176 : for( npy_intp j = 0; j < dims; j++ )
5404 : {
5405 111 : const int64_t timeUs = ((int64_t*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5406 111 : PyObject* subObj = PyTime_FromTime(static_cast<int>((timeUs / 1000000) / 3600),
5407 : static_cast<int>(((timeUs / 1000000) % 3600) / 60),
5408 : static_cast<int>(((timeUs / 1000000) % 3600) % 60),
5409 : static_cast<int>(timeUs % 1000000));
5410 111 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5411 : &subObj,
5412 : sizeof(PyObject*));
5413 : }
5414 : }
5415 917 : else if( (strncmp(arrowType, "tsm:", 4) == 0 || // DateTime in milliseconds
5416 562 : strncmp(arrowType, "tsu:", 4) == 0 || // DateTime in microseconds
5417 432 : strncmp(arrowType, "tsn:", 4) == 0) && // DateTime in nanoseconds
5418 485 : schemaField->n_children == 0 )
5419 : {
5420 : // DateTime(64)
5421 485 : if( arrayField->n_buffers != 2 )
5422 : {
5423 0 : CPLError(CE_Failure, CPLE_AppDefined,
5424 : "Field %s: arrayField->n_buffers != 2",
5425 0 : schemaField->name);
5426 0 : return false;
5427 : }
5428 :
5429 : // create the dtype string
5430 615 : PyObject *pDTypeString = PyUnicode_FromString(
5431 : strncmp(arrowType, "tsm:", 4) == 0 ? "datetime64[ms]" :
5432 130 : strncmp(arrowType, "tsu:", 4) == 0 ? "datetime64[us]" :
5433 : "datetime64[ns]");
5434 : // out type description object
5435 485 : PyArray_Descr *pDescr = NULL;
5436 485 : PyArray_DescrConverter(pDTypeString, &pDescr);
5437 485 : Py_DECREF(pDTypeString);
5438 485 : CPLAssert(pDescr);
5439 :
5440 : // create array
5441 970 : numpyArray = PyArray_NewFromDescr(
5442 : &PyArray_Type, pDescr, 1, &dims, NULL,
5443 485 : (int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset), 0, NULL);
5444 :
5445 : /* Keep a reference to the owner object */
5446 : #if NPY_API_VERSION >= 0x00000007
5447 485 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
5448 : #else
5449 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
5450 : #endif
5451 485 : Py_INCREF(pointerArrayKeeper);
5452 : }
5453 432 : else if( strcmp(arrowType, "+s") == 0 )
5454 : {
5455 585 : for( int iField = 0; iField < arrayField->n_children; iField++ )
5456 : {
5457 455 : const struct ArrowArray* childArray = arrayField ->children[iField];
5458 455 : const struct ArrowSchema* childSchema = schemaField->children[iField];
5459 :
5460 455 : if( !AddNumpyArrayToDict(dict, childSchema, childArray,
5461 910 : osPrefix + schemaField->name + ".",
5462 : pointerArrayKeeper) )
5463 : {
5464 : return false;
5465 : }
5466 : }
5467 : }
5468 : else
5469 : {
5470 302 : if( strcmp(arrowType, "+l") == 0 || strcmp(arrowType, "+L") == 0 )
5471 : {
5472 260 : CPLError(CE_Warning, CPLE_AppDefined,
5473 : "Field %s: Unhandled arrow type: %s %s",
5474 0 : (osPrefix + schemaField->name).c_str(),
5475 260 : arrowType, schemaField->children[0]->format);
5476 : }
5477 : else
5478 : {
5479 42 : CPLError(CE_Warning, CPLE_AppDefined,
5480 : "Field %s: Unhandled arrow type: %s",
5481 42 : (osPrefix + schemaField->name).c_str(),
5482 : arrowType);
5483 : }
5484 : }
5485 :
5486 7624 : if( numpyArray )
5487 : {
5488 7192 : const uint8_t* panNotNulls = (const uint8_t*)arrayField->buffers[0];
5489 7192 : if( panNotNulls && arrayField->null_count != 0 )
5490 : {
5491 2889 : PyObject* maskArray = PyArray_SimpleNew(1, &dims, NPY_BOOL);
5492 8268 : for( npy_intp j = 0; j < dims; j++ )
5493 : {
5494 5379 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
5495 : // Inverse convention between arrow not-null bitmap, where
5496 : // 1 means valid, and numpy masks where 1 means invalid
5497 5379 : *(char*)PyArray_GETPTR1((PyArrayObject *) maskArray, j) =
5498 5379 : ((panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0) ? 1 : 0;
5499 : }
5500 2889 : PyObject *subdict = PyDict_New();
5501 2889 : PyDict_SetItemString( subdict, "mask", maskArray );
5502 2889 : PyDict_SetItemString( subdict, "data", numpyArray );
5503 2889 : PyDict_SetItemString( dict, (osPrefix + schemaField->name).c_str(), subdict);
5504 2889 : Py_DECREF(maskArray);
5505 2889 : Py_DECREF(subdict);
5506 : }
5507 : else
5508 : {
5509 8606 : PyDict_SetItemString( dict, (osPrefix + schemaField->name).c_str(), numpyArray );
5510 : }
5511 7624 : Py_DECREF(numpyArray);
5512 : }
5513 :
5514 : return true;
5515 : }
5516 :
5517 : /* Internal method used by ogr.Layer.GetNextRecordBatchAsNumpy() */
5518 469 : PyObject* _RecordBatchAsNumpy(VoidPtrAsLong recordBatchPtr,
5519 : VoidPtrAsLong schemaPtr,
5520 : PyObject* pointerArrayKeeper)
5521 : {
5522 469 : const struct ArrowSchema* schema = (const struct ArrowSchema* )schemaPtr;
5523 469 : const struct ArrowArray* array = (const struct ArrowArray* )recordBatchPtr;
5524 469 : if( strcmp(schema->format, "+s") != 0 )
5525 : {
5526 0 : CPLError(CE_Failure, CPLE_AppDefined, "schema->format != '+s'");
5527 0 : Py_RETURN_NONE;
5528 : }
5529 469 : if( schema->n_children != array->n_children )
5530 : {
5531 0 : CPLError(CE_Failure, CPLE_AppDefined,
5532 : "schema->n_children(=%d) != array->n_children(=%d)",
5533 : static_cast<int>(schema->n_children),
5534 : static_cast<int>(array->n_children));
5535 0 : Py_RETURN_NONE;
5536 : }
5537 469 : PyObject *dict = PyDict_New();
5538 7638 : for( int iField = 0; iField < array->n_children; iField++ )
5539 : {
5540 7169 : const struct ArrowArray* childArray = array->children[iField];
5541 7169 : const struct ArrowSchema* childSchema = schema->children[iField];
5542 :
5543 7169 : if( !AddNumpyArrayToDict(dict, childSchema, childArray, std::string(), pointerArrayKeeper) )
5544 : {
5545 0 : Py_DECREF(dict);
5546 0 : Py_RETURN_NONE;
5547 : }
5548 : }
5549 : return dict;
5550 : }
5551 :
5552 :
5553 :
5554 : SWIGINTERNINLINE PyObject*
5555 0 : SWIG_From_bool (bool value)
5556 : {
5557 0 : return PyBool_FromLong(value ? 1 : 0);
5558 : }
5559 :
5560 :
5561 28 : void VirtualMemGetArray(CPLVirtualMemShadow* virtualmem, CPLVirtualMemShadow** pvirtualmem, int numpytypemap)
5562 : {
5563 28 : *pvirtualmem = virtualmem;
5564 28 : }
5565 :
5566 :
5567 : // need different functions for read and write
5568 : // since reading strings requires us to know the
5569 : // length of the longest string before creating array
5570 13 : CPLErr RATValuesIONumPyWrite( GDALRasterAttributeTableShadow* poRAT, int nField, int nStart,
5571 : PyArrayObject *psArray) {
5572 :
5573 13 : if( PyArray_NDIM(psArray) != 1 )
5574 : {
5575 0 : CPLError( CE_Failure, CPLE_AppDefined,
5576 : "Illegal numpy array rank %d.\n",
5577 : PyArray_NDIM(psArray) );
5578 0 : return CE_Failure;
5579 : }
5580 13 : if( PyArray_DIM(psArray, 0) > INT_MAX )
5581 : {
5582 0 : CPLError( CE_Failure, CPLE_NotSupported,
5583 : "Too big array dimension");
5584 0 : return CE_Failure;
5585 : }
5586 :
5587 13 : int nLength = static_cast<int>(PyArray_DIM(psArray, 0));
5588 13 : int nType = PyArray_TYPE(psArray);
5589 13 : CPLErr retval = CE_None;
5590 :
5591 13 : if( nType == NPY_INT32 )
5592 : {
5593 4 : retval = GDALRATValuesIOAsInteger(poRAT, GF_Write, nField, nStart, nLength,
5594 4 : (int*)PyArray_DATA(psArray) );
5595 : }
5596 9 : else if( nType == NPY_DOUBLE )
5597 : {
5598 4 : retval = GDALRATValuesIOAsDouble(poRAT, GF_Write, nField, nStart, nLength,
5599 4 : (double*)PyArray_DATA(psArray) );
5600 : }
5601 5 : else if( nType == NPY_STRING )
5602 : {
5603 : // max size of string
5604 5 : const size_t nMaxLen = PyArray_ITEMSIZE(psArray);
5605 5 : char *pszBuffer = (char*)VSIMalloc(nMaxLen+1);
5606 5 : if (!pszBuffer)
5607 : {
5608 0 : CPLError( CE_Failure, CPLE_OutOfMemory,
5609 : "Out of memory in RATValuesIONumPyWrite()" );
5610 0 : return CE_Failure;
5611 : }
5612 : // make sure there is a null char on the end
5613 : // as there won't be if this string is the maximum size
5614 5 : pszBuffer[nMaxLen] = '\0';
5615 :
5616 : // have to convert array of strings to a char **
5617 5 : char **papszStringData = (char**)CPLCalloc(sizeof(char*), nLength);
5618 :
5619 : // we can't just use the memory location in the array
5620 : // since long strings won't be null terminated
5621 55 : for( int i = 0; i < nLength; i++ )
5622 : {
5623 50 : strncpy(pszBuffer, (char*)PyArray_GETPTR1(psArray, i), nMaxLen);
5624 50 : papszStringData[i] = CPLStrdup(pszBuffer);
5625 : }
5626 5 : CPLFree(pszBuffer);
5627 :
5628 5 : retval = GDALRATValuesIOAsString(poRAT, GF_Write, nField, nStart, nLength,
5629 : papszStringData);
5630 :
5631 55 : for( int i = 0; i < nLength; i++ )
5632 : {
5633 50 : CPLFree(papszStringData[i]);
5634 : }
5635 5 : CPLFree(papszStringData);
5636 : }
5637 : else
5638 : {
5639 0 : CPLError( CE_Failure, CPLE_AppDefined,
5640 : "Illegal numpy array type %d.\n",
5641 : nType );
5642 0 : return CE_Failure;
5643 : }
5644 : return retval;
5645 : }
5646 :
5647 :
5648 : // need different functions for read and write
5649 : // since reading strings requires us to know the
5650 : // length of the longest string before creating array
5651 40 : PyObject *RATValuesIONumPyRead( GDALRasterAttributeTableShadow* poRAT, int nField, int nStart,
5652 : int nLength) {
5653 :
5654 40 : GDALRATFieldType colType = GDALRATGetTypeOfCol(poRAT, nField);
5655 40 : npy_intp dims = nLength;
5656 40 : PyObject *pOutArray = NULL;
5657 40 : if( colType == GFT_Integer )
5658 : {
5659 13 : pOutArray = PyArray_SimpleNew(1, &dims, NPY_INT32);
5660 13 : if( GDALRATValuesIOAsInteger(poRAT, GF_Read, nField, nStart, nLength,
5661 13 : (int*)PyArray_DATA((PyArrayObject *) pOutArray)) != CE_None)
5662 : {
5663 0 : Py_DECREF(pOutArray);
5664 0 : Py_RETURN_NONE;
5665 : }
5666 : }
5667 27 : else if( colType == GFT_Real )
5668 : {
5669 13 : pOutArray = PyArray_SimpleNew(1, &dims, NPY_DOUBLE);
5670 13 : if( GDALRATValuesIOAsDouble(poRAT, GF_Read, nField, nStart, nLength,
5671 13 : (double*)PyArray_DATA((PyArrayObject *) pOutArray)) != CE_None)
5672 : {
5673 0 : Py_DECREF(pOutArray);
5674 0 : Py_RETURN_NONE;
5675 : }
5676 : }
5677 14 : else if( colType == GFT_String )
5678 : {
5679 : // must read the data first to work out max size
5680 : // of strings to create array
5681 14 : int n;
5682 14 : char **papszStringList = (char**)CPLCalloc(sizeof(char*), nLength);
5683 14 : if( GDALRATValuesIOAsString(poRAT, GF_Read, nField, nStart, nLength, papszStringList) != CE_None )
5684 : {
5685 0 : CPLFree(papszStringList);
5686 0 : Py_RETURN_NONE;
5687 : }
5688 : int nMaxLen = 0, nLen;
5689 154 : for( n = 0; n < nLength; n++ )
5690 : {
5691 : // note strlen doesn't include null char
5692 : // but that is what numpy expects so all good
5693 140 : nLen = static_cast<int>(strlen(papszStringList[n]));
5694 140 : if( nLen > nMaxLen )
5695 : nMaxLen = nLen;
5696 : }
5697 14 : int bZeroLength = FALSE;
5698 : // numpy can't deal with zero length strings
5699 14 : if( nMaxLen == 0 )
5700 : {
5701 0 : nMaxLen = 1;
5702 0 : bZeroLength = TRUE;
5703 : }
5704 :
5705 : // create the dtype string
5706 14 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", nMaxLen);
5707 : // out type description object
5708 14 : PyArray_Descr *pDescr;
5709 14 : PyArray_DescrConverter(pDTypeString, &pDescr);
5710 14 : Py_DECREF(pDTypeString);
5711 :
5712 : // create array
5713 14 : pOutArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5714 :
5715 : // copy data in
5716 14 : if( !bZeroLength )
5717 : {
5718 154 : for( n = 0; n < nLength; n++ )
5719 : {
5720 : // we use strncpy so that we don't go over nMaxLen
5721 : // which we would if the null char is copied
5722 : // (which we don't want as numpy 'knows' to interpret the string as nMaxLen long)
5723 140 : strncpy((char*)PyArray_GETPTR1((PyArrayObject *) pOutArray, n), papszStringList[n], nMaxLen);
5724 : }
5725 : }
5726 : else
5727 : {
5728 : // so there isn't rubbish in the 1 char strings
5729 0 : PyArray_FILLWBYTE((PyArrayObject *) pOutArray, 0);
5730 : }
5731 :
5732 : // free strings
5733 154 : for( n = 0; n < nLength; n++ )
5734 : {
5735 140 : CPLFree(papszStringList[n]);
5736 : }
5737 14 : CPLFree(papszStringList);
5738 : }
5739 : return pOutArray;
5740 : }
5741 :
5742 : #ifdef __cplusplus
5743 : extern "C" {
5744 : #endif
5745 28 : SWIGINTERN PyObject *_wrap_delete_VirtualMem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
5746 28 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5747 28 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5748 28 : void *argp1 = 0 ;
5749 28 : int res1 = 0 ;
5750 28 : PyObject *swig_obj[1] ;
5751 :
5752 28 : if (!args) SWIG_fail;
5753 28 : swig_obj[0] = args;
5754 28 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, SWIG_POINTER_DISOWN | 0 );
5755 28 : if (!SWIG_IsOK(res1)) {
5756 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VirtualMem" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5757 : }
5758 28 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5759 28 : {
5760 28 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5761 28 : delete_CPLVirtualMemShadow(arg1);
5762 28 : SWIG_PYTHON_THREAD_END_ALLOW;
5763 : }
5764 28 : resultobj = SWIG_Py_Void();
5765 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
5766 : return resultobj;
5767 : fail:
5768 : return NULL;
5769 : }
5770 :
5771 :
5772 0 : SWIGINTERN PyObject *_wrap_VirtualMem_GetAddr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
5773 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5774 0 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5775 0 : void **arg2 = (void **) 0 ;
5776 0 : size_t *arg3 = (size_t *) 0 ;
5777 0 : GDALDataType *arg4 = (GDALDataType *) 0 ;
5778 0 : int *arg5 = (int *) 0 ;
5779 0 : void *argp1 = 0 ;
5780 0 : int res1 = 0 ;
5781 0 : void *ptr2 ;
5782 0 : size_t nsize2 ;
5783 0 : GDALDataType datatype2 ;
5784 0 : int readonly2 ;
5785 0 : PyObject *swig_obj[1] ;
5786 :
5787 0 : {
5788 : /* %typemap(in,numinputs=0) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly) */
5789 0 : arg2 = &ptr2;
5790 0 : arg3 = &nsize2;
5791 0 : arg4 = &datatype2;
5792 0 : arg5 = &readonly2;
5793 : }
5794 0 : if (!args) SWIG_fail;
5795 0 : swig_obj[0] = args;
5796 0 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5797 0 : if (!SWIG_IsOK(res1)) {
5798 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_GetAddr" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5799 : }
5800 0 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5801 0 : {
5802 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5803 0 : CPLVirtualMemShadow_GetAddr(arg1,arg2,arg3,arg4,arg5);
5804 0 : SWIG_PYTHON_THREAD_END_ALLOW;
5805 : }
5806 0 : resultobj = SWIG_Py_Void();
5807 0 : {
5808 : /* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
5809 0 : Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
5810 :
5811 0 : if (PyBuffer_FillInfo(buf, swig_obj[0], *(arg2), *(arg3), *(arg5), PyBUF_ND)) {
5812 : // error, handle
5813 : }
5814 0 : if( *(arg4) == GDT_Byte )
5815 : {
5816 0 : buf->format = (char*) "B";
5817 0 : buf->itemsize = 1;
5818 : }
5819 0 : else if( *(arg4) == GDT_Int16 )
5820 : {
5821 0 : buf->format = (char*) "h";
5822 0 : buf->itemsize = 2;
5823 : }
5824 0 : else if( *(arg4) == GDT_UInt16 )
5825 : {
5826 0 : buf->format = (char*) "H";
5827 0 : buf->itemsize = 2;
5828 : }
5829 0 : else if( *(arg4) == GDT_Int32 )
5830 : {
5831 0 : buf->format = (char*) "i";
5832 0 : buf->itemsize = 4;
5833 : }
5834 0 : else if( *(arg4) == GDT_UInt32 )
5835 : {
5836 0 : buf->format = (char*) "I";
5837 0 : buf->itemsize = 4;
5838 : }
5839 0 : else if( *(arg4) == GDT_Float32 )
5840 : {
5841 0 : buf->format = (char*) "f";
5842 0 : buf->itemsize = 4;
5843 : }
5844 0 : else if( *(arg4) == GDT_Float64 )
5845 : {
5846 0 : buf->format = (char*) "F";
5847 0 : buf->itemsize = 8;
5848 : }
5849 : else
5850 : {
5851 0 : buf->format = (char*) "B";
5852 0 : buf->itemsize = 1;
5853 : }
5854 0 : Py_DECREF(resultobj);
5855 0 : resultobj = PyMemoryView_FromBuffer(buf);
5856 : }
5857 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
5858 : return resultobj;
5859 : fail:
5860 : return NULL;
5861 : }
5862 :
5863 :
5864 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5865 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5866 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5867 : size_t arg2 ;
5868 : size_t arg3 ;
5869 : int arg4 ;
5870 : void *argp1 = 0 ;
5871 : int res1 = 0 ;
5872 : size_t val2 ;
5873 : int ecode2 = 0 ;
5874 : size_t val3 ;
5875 : int ecode3 = 0 ;
5876 : int val4 ;
5877 : int ecode4 = 0 ;
5878 :
5879 : if ((nobjs < 4) || (nobjs > 4)) SWIG_fail;
5880 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5881 : if (!SWIG_IsOK(res1)) {
5882 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5883 : }
5884 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5885 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5886 : if (!SWIG_IsOK(ecode2)) {
5887 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5888 : }
5889 : arg2 = static_cast< size_t >(val2);
5890 : ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3);
5891 : if (!SWIG_IsOK(ecode3)) {
5892 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VirtualMem_Pin" "', argument " "3"" of type '" "size_t""'");
5893 : }
5894 : arg3 = static_cast< size_t >(val3);
5895 : ecode4 = SWIG_AsVal_int(swig_obj[3], &val4);
5896 : if (!SWIG_IsOK(ecode4)) {
5897 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "VirtualMem_Pin" "', argument " "4"" of type '" "int""'");
5898 : }
5899 : arg4 = static_cast< int >(val4);
5900 : {
5901 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5902 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2,arg3,arg4);
5903 : SWIG_PYTHON_THREAD_END_ALLOW;
5904 : }
5905 : resultobj = SWIG_Py_Void();
5906 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
5907 : return resultobj;
5908 : fail:
5909 : return NULL;
5910 : }
5911 :
5912 :
5913 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5914 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5915 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5916 : size_t arg2 ;
5917 : size_t arg3 ;
5918 : void *argp1 = 0 ;
5919 : int res1 = 0 ;
5920 : size_t val2 ;
5921 : int ecode2 = 0 ;
5922 : size_t val3 ;
5923 : int ecode3 = 0 ;
5924 :
5925 : if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
5926 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5927 : if (!SWIG_IsOK(res1)) {
5928 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5929 : }
5930 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5931 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5932 : if (!SWIG_IsOK(ecode2)) {
5933 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5934 : }
5935 : arg2 = static_cast< size_t >(val2);
5936 : ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3);
5937 : if (!SWIG_IsOK(ecode3)) {
5938 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VirtualMem_Pin" "', argument " "3"" of type '" "size_t""'");
5939 : }
5940 : arg3 = static_cast< size_t >(val3);
5941 : {
5942 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5943 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2,arg3);
5944 : SWIG_PYTHON_THREAD_END_ALLOW;
5945 : }
5946 : resultobj = SWIG_Py_Void();
5947 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
5948 : return resultobj;
5949 : fail:
5950 : return NULL;
5951 : }
5952 :
5953 :
5954 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5955 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5956 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5957 : size_t arg2 ;
5958 : void *argp1 = 0 ;
5959 : int res1 = 0 ;
5960 : size_t val2 ;
5961 : int ecode2 = 0 ;
5962 :
5963 : if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
5964 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5965 : if (!SWIG_IsOK(res1)) {
5966 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5967 : }
5968 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5969 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5970 : if (!SWIG_IsOK(ecode2)) {
5971 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5972 : }
5973 : arg2 = static_cast< size_t >(val2);
5974 : {
5975 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5976 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2);
5977 : SWIG_PYTHON_THREAD_END_ALLOW;
5978 : }
5979 : resultobj = SWIG_Py_Void();
5980 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
5981 : return resultobj;
5982 : fail:
5983 : return NULL;
5984 : }
5985 :
5986 :
5987 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5988 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5989 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5990 : void *argp1 = 0 ;
5991 : int res1 = 0 ;
5992 :
5993 : if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
5994 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5995 : if (!SWIG_IsOK(res1)) {
5996 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5997 : }
5998 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5999 : {
6000 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6001 : CPLVirtualMemShadow_Pin__SWIG_0(arg1);
6002 : SWIG_PYTHON_THREAD_END_ALLOW;
6003 : }
6004 : resultobj = SWIG_Py_Void();
6005 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6006 : return resultobj;
6007 : fail:
6008 : return NULL;
6009 : }
6010 :
6011 :
6012 0 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin(PyObject *self, PyObject *args) {
6013 0 : Py_ssize_t argc;
6014 0 : PyObject *argv[5] = {
6015 : 0
6016 : };
6017 :
6018 0 : if (!(argc = SWIG_Python_UnpackTuple(args, "VirtualMem_Pin", 0, 4, argv))) SWIG_fail;
6019 0 : --argc;
6020 0 : if (argc == 1) {
6021 0 : int _v;
6022 0 : void *vptr = 0;
6023 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6024 0 : _v = SWIG_CheckState(res);
6025 0 : if (_v) {
6026 0 : return _wrap_VirtualMem_Pin__SWIG_3(self, argc, argv);
6027 : }
6028 : }
6029 0 : if (argc == 2) {
6030 0 : int _v;
6031 0 : void *vptr = 0;
6032 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6033 0 : _v = SWIG_CheckState(res);
6034 0 : if (_v) {
6035 0 : {
6036 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6037 0 : _v = SWIG_CheckState(res);
6038 : }
6039 0 : if (_v) {
6040 0 : return _wrap_VirtualMem_Pin__SWIG_2(self, argc, argv);
6041 : }
6042 : }
6043 : }
6044 0 : if (argc == 3) {
6045 0 : int _v;
6046 0 : void *vptr = 0;
6047 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6048 0 : _v = SWIG_CheckState(res);
6049 0 : if (_v) {
6050 0 : {
6051 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6052 0 : _v = SWIG_CheckState(res);
6053 : }
6054 0 : if (_v) {
6055 0 : {
6056 0 : int res = SWIG_AsVal_size_t(argv[2], NULL);
6057 0 : _v = SWIG_CheckState(res);
6058 : }
6059 0 : if (_v) {
6060 0 : return _wrap_VirtualMem_Pin__SWIG_1(self, argc, argv);
6061 : }
6062 : }
6063 : }
6064 : }
6065 0 : if (argc == 4) {
6066 0 : int _v;
6067 0 : void *vptr = 0;
6068 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6069 0 : _v = SWIG_CheckState(res);
6070 0 : if (_v) {
6071 0 : {
6072 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6073 0 : _v = SWIG_CheckState(res);
6074 : }
6075 0 : if (_v) {
6076 0 : {
6077 0 : int res = SWIG_AsVal_size_t(argv[2], NULL);
6078 0 : _v = SWIG_CheckState(res);
6079 : }
6080 0 : if (_v) {
6081 0 : {
6082 0 : int res = SWIG_AsVal_int(argv[3], NULL);
6083 0 : _v = SWIG_CheckState(res);
6084 : }
6085 0 : if (_v) {
6086 0 : return _wrap_VirtualMem_Pin__SWIG_0(self, argc, argv);
6087 : }
6088 : }
6089 : }
6090 : }
6091 : }
6092 :
6093 0 : fail:
6094 0 : SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'VirtualMem_Pin'.\n"
6095 : " Possible C/C++ prototypes are:\n"
6096 : " CPLVirtualMemShadow::Pin(size_t,size_t,int)\n"
6097 : " CPLVirtualMemShadow::Pin(size_t,size_t)\n"
6098 : " CPLVirtualMemShadow::Pin(size_t)\n"
6099 : " CPLVirtualMemShadow::Pin()\n");
6100 : return 0;
6101 : }
6102 :
6103 :
6104 225 : SWIGINTERN PyObject *VirtualMem_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6105 225 : PyObject *obj;
6106 225 : if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
6107 225 : SWIG_TypeNewClientData(SWIGTYPE_p_CPLVirtualMemShadow, SWIG_NewClientData(obj));
6108 225 : return SWIG_Py_Void();
6109 : }
6110 :
6111 0 : SWIGINTERN PyObject *_wrap_GetUseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6112 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6113 0 : int result;
6114 :
6115 0 : if (!SWIG_Python_UnpackTuple(args, "GetUseExceptions", 0, 0, 0)) SWIG_fail;
6116 0 : {
6117 : #ifdef SED_HACKS
6118 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6119 : #endif
6120 0 : result = GetUseExceptions();
6121 : }
6122 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6123 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6124 : return resultobj;
6125 0 : fail:
6126 0 : return NULL;
6127 : }
6128 :
6129 :
6130 0 : SWIGINTERN PyObject *_wrap__GetExceptionsLocal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6131 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6132 0 : int result;
6133 :
6134 0 : if (!SWIG_Python_UnpackTuple(args, "_GetExceptionsLocal", 0, 0, 0)) SWIG_fail;
6135 0 : {
6136 : #ifdef SED_HACKS
6137 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6138 : #endif
6139 0 : {
6140 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6141 0 : result = (int)_GetExceptionsLocal();
6142 0 : SWIG_PYTHON_THREAD_END_ALLOW;
6143 : }
6144 : }
6145 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6146 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6147 : return resultobj;
6148 0 : fail:
6149 0 : return NULL;
6150 : }
6151 :
6152 :
6153 19366 : SWIGINTERN PyObject *_wrap__SetExceptionsLocal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6154 19366 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6155 19366 : int arg1 ;
6156 19366 : int val1 ;
6157 19366 : int ecode1 = 0 ;
6158 19366 : PyObject *swig_obj[1] ;
6159 :
6160 19366 : if (!args) SWIG_fail;
6161 19366 : swig_obj[0] = args;
6162 19366 : ecode1 = SWIG_AsVal_int(swig_obj[0], &val1);
6163 19366 : if (!SWIG_IsOK(ecode1)) {
6164 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "_SetExceptionsLocal" "', argument " "1"" of type '" "int""'");
6165 : }
6166 19366 : arg1 = static_cast< int >(val1);
6167 19366 : {
6168 : #ifdef SED_HACKS
6169 19366 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6170 : #endif
6171 19366 : {
6172 19366 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6173 19366 : _SetExceptionsLocal(arg1);
6174 19366 : SWIG_PYTHON_THREAD_END_ALLOW;
6175 : }
6176 : }
6177 19366 : resultobj = SWIG_Py_Void();
6178 19366 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6179 : return resultobj;
6180 : fail:
6181 : return NULL;
6182 : }
6183 :
6184 :
6185 26 : SWIGINTERN PyObject *_wrap__UseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6186 26 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6187 :
6188 26 : if (!SWIG_Python_UnpackTuple(args, "_UseExceptions", 0, 0, 0)) SWIG_fail;
6189 26 : {
6190 26 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6191 26 : _UseExceptions();
6192 26 : SWIG_PYTHON_THREAD_END_ALLOW;
6193 : }
6194 26 : resultobj = SWIG_Py_Void();
6195 26 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6196 : return resultobj;
6197 0 : fail:
6198 0 : return NULL;
6199 : }
6200 :
6201 :
6202 5 : SWIGINTERN PyObject *_wrap__DontUseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6203 5 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6204 :
6205 5 : if (!SWIG_Python_UnpackTuple(args, "_DontUseExceptions", 0, 0, 0)) SWIG_fail;
6206 5 : {
6207 5 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6208 5 : _DontUseExceptions();
6209 5 : SWIG_PYTHON_THREAD_END_ALLOW;
6210 : }
6211 5 : resultobj = SWIG_Py_Void();
6212 5 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6213 : return resultobj;
6214 0 : fail:
6215 0 : return NULL;
6216 : }
6217 :
6218 :
6219 0 : SWIGINTERN PyObject *_wrap__UserHasSpecifiedIfUsingExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6220 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6221 0 : int result;
6222 :
6223 0 : if (!SWIG_Python_UnpackTuple(args, "_UserHasSpecifiedIfUsingExceptions", 0, 0, 0)) SWIG_fail;
6224 0 : {
6225 : #ifdef SED_HACKS
6226 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6227 : #endif
6228 0 : {
6229 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6230 0 : result = (int)_UserHasSpecifiedIfUsingExceptions();
6231 0 : SWIG_PYTHON_THREAD_END_ALLOW;
6232 : }
6233 : }
6234 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6235 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6236 : return resultobj;
6237 0 : fail:
6238 0 : return NULL;
6239 : }
6240 :
6241 :
6242 0 : SWIGINTERN PyObject *_wrap_TermProgress_nocb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6243 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6244 0 : double arg1 ;
6245 0 : char *arg2 = (char *) NULL ;
6246 0 : void *arg3 = (void *) NULL ;
6247 0 : double val1 ;
6248 0 : int ecode1 = 0 ;
6249 0 : int res2 ;
6250 0 : char *buf2 = 0 ;
6251 0 : int alloc2 = 0 ;
6252 0 : int res3 ;
6253 0 : PyObject * obj0 = 0 ;
6254 0 : PyObject * obj1 = 0 ;
6255 0 : PyObject * obj2 = 0 ;
6256 0 : char * kwnames[] = {
6257 : (char *)"dfProgress", (char *)"pszMessage", (char *)"pData", NULL
6258 : };
6259 0 : int result;
6260 :
6261 0 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:TermProgress_nocb", kwnames, &obj0, &obj1, &obj2)) SWIG_fail;
6262 0 : ecode1 = SWIG_AsVal_double(obj0, &val1);
6263 0 : if (!SWIG_IsOK(ecode1)) {
6264 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "TermProgress_nocb" "', argument " "1"" of type '" "double""'");
6265 : }
6266 0 : arg1 = static_cast< double >(val1);
6267 0 : if (obj1) {
6268 0 : res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
6269 0 : if (!SWIG_IsOK(res2)) {
6270 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TermProgress_nocb" "', argument " "2"" of type '" "char const *""'");
6271 : }
6272 0 : arg2 = reinterpret_cast< char * >(buf2);
6273 : }
6274 0 : if (obj2) {
6275 0 : res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
6276 0 : if (!SWIG_IsOK(res3)) {
6277 0 : SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TermProgress_nocb" "', argument " "3"" of type '" "void *""'");
6278 : }
6279 : }
6280 0 : {
6281 0 : const int bLocalUseExceptions = GetUseExceptions();
6282 0 : if ( bLocalUseExceptions ) {
6283 0 : pushErrorHandler();
6284 : }
6285 0 : result = (int)GDALTermProgress_nocb(arg1,(char const *)arg2,arg3);
6286 0 : if ( bLocalUseExceptions ) {
6287 0 : popErrorHandler();
6288 : }
6289 : #ifndef SED_HACKS
6290 : if ( bLocalUseExceptions ) {
6291 : CPLErr eclass = CPLGetLastErrorType();
6292 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6293 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6294 : }
6295 : }
6296 : #endif
6297 : }
6298 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6299 0 : if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
6300 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6301 : return resultobj;
6302 0 : fail:
6303 0 : if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
6304 : return NULL;
6305 : }
6306 :
6307 :
6308 27 : SWIGINTERN PyObject *_wrap_OpenNumPyArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6309 27 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6310 27 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6311 27 : bool arg2 ;
6312 27 : bool val2 ;
6313 27 : int ecode2 = 0 ;
6314 27 : PyObject *swig_obj[2] ;
6315 27 : GDALDatasetShadow *result = 0 ;
6316 :
6317 27 : if (!SWIG_Python_UnpackTuple(args, "OpenNumPyArray", 2, 2, swig_obj)) SWIG_fail;
6318 27 : {
6319 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6320 27 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6321 : {
6322 27 : arg1 = (PyArrayObject*)(swig_obj[0]);
6323 : }
6324 : else
6325 : {
6326 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6327 0 : SWIG_fail;
6328 : }
6329 : }
6330 27 : ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2);
6331 27 : if (!SWIG_IsOK(ecode2)) {
6332 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OpenNumPyArray" "', argument " "2"" of type '" "bool""'");
6333 : }
6334 27 : arg2 = static_cast< bool >(val2);
6335 27 : {
6336 27 : const int bLocalUseExceptions = GetUseExceptions();
6337 27 : if ( bLocalUseExceptions ) {
6338 1 : pushErrorHandler();
6339 : }
6340 27 : result = (GDALDatasetShadow *)OpenNumPyArray(arg1,arg2);
6341 27 : if ( bLocalUseExceptions ) {
6342 1 : popErrorHandler();
6343 : }
6344 : #ifndef SED_HACKS
6345 : if( result == NULL && bLocalUseExceptions ) {
6346 : CPLErr eclass = CPLGetLastErrorType();
6347 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6348 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6349 : }
6350 : }
6351 : #endif
6352 27 : if( result != NULL && bLocalUseExceptions ) {
6353 : #ifdef SED_HACKS
6354 0 : bLocalUseExceptionsCode = FALSE;
6355 : #endif
6356 : }
6357 : }
6358 27 : resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 );
6359 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6360 : return resultobj;
6361 : fail:
6362 : return NULL;
6363 : }
6364 :
6365 :
6366 21 : SWIGINTERN PyObject *_wrap_OpenMultiDimensionalNumPyArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6367 21 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6368 21 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6369 21 : PyObject *swig_obj[1] ;
6370 21 : GDALDatasetShadow *result = 0 ;
6371 :
6372 21 : if (!args) SWIG_fail;
6373 21 : swig_obj[0] = args;
6374 21 : {
6375 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6376 21 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6377 : {
6378 21 : arg1 = (PyArrayObject*)(swig_obj[0]);
6379 : }
6380 : else
6381 : {
6382 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6383 0 : SWIG_fail;
6384 : }
6385 : }
6386 21 : {
6387 21 : const int bLocalUseExceptions = GetUseExceptions();
6388 21 : if ( bLocalUseExceptions ) {
6389 21 : pushErrorHandler();
6390 : }
6391 21 : result = (GDALDatasetShadow *)OpenMultiDimensionalNumPyArray(arg1);
6392 21 : if ( bLocalUseExceptions ) {
6393 21 : popErrorHandler();
6394 : }
6395 : #ifndef SED_HACKS
6396 : if( result == NULL && bLocalUseExceptions ) {
6397 : CPLErr eclass = CPLGetLastErrorType();
6398 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6399 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6400 : }
6401 : }
6402 : #endif
6403 21 : if( result != NULL && bLocalUseExceptions ) {
6404 : #ifdef SED_HACKS
6405 20 : bLocalUseExceptionsCode = FALSE;
6406 : #endif
6407 : }
6408 : }
6409 21 : resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 );
6410 22 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6411 : return resultobj;
6412 : fail:
6413 : return NULL;
6414 : }
6415 :
6416 :
6417 2 : SWIGINTERN PyObject *_wrap_GetArrayFilename(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6418 2 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6419 2 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6420 2 : PyObject *swig_obj[1] ;
6421 2 : retStringAndCPLFree *result = 0 ;
6422 :
6423 2 : if (!args) SWIG_fail;
6424 2 : swig_obj[0] = args;
6425 2 : {
6426 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6427 2 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6428 : {
6429 2 : arg1 = (PyArrayObject*)(swig_obj[0]);
6430 : }
6431 : else
6432 : {
6433 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6434 0 : SWIG_fail;
6435 : }
6436 : }
6437 2 : {
6438 2 : const int bLocalUseExceptions = GetUseExceptions();
6439 2 : if ( bLocalUseExceptions ) {
6440 0 : pushErrorHandler();
6441 : }
6442 2 : result = (retStringAndCPLFree *)GetArrayFilename(arg1);
6443 2 : if ( bLocalUseExceptions ) {
6444 0 : popErrorHandler();
6445 : }
6446 : #ifndef SED_HACKS
6447 : if ( bLocalUseExceptions ) {
6448 : CPLErr eclass = CPLGetLastErrorType();
6449 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6450 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6451 : }
6452 : }
6453 : #endif
6454 : }
6455 2 : {
6456 : /* %typemap(out) (retStringAndCPLFree*) */
6457 2 : Py_XDECREF(resultobj);
6458 2 : if(result)
6459 : {
6460 2 : resultobj = GDALPythonObjectFromCStr( (const char *)result);
6461 2 : CPLFree(result);
6462 : }
6463 : else
6464 : {
6465 0 : resultobj = Py_None;
6466 0 : Py_INCREF(resultobj);
6467 : }
6468 : }
6469 2 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6470 : return resultobj;
6471 : fail:
6472 : return NULL;
6473 : }
6474 :
6475 :
6476 14703 : SWIGINTERN PyObject *_wrap_BandRasterIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6477 14703 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6478 14703 : GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ;
6479 14703 : int arg2 ;
6480 14703 : double arg3 ;
6481 14703 : double arg4 ;
6482 14703 : double arg5 ;
6483 14703 : double arg6 ;
6484 14703 : PyArrayObject *arg7 = (PyArrayObject *) 0 ;
6485 14703 : GDALDataType arg8 ;
6486 14703 : GDALRIOResampleAlg arg9 ;
6487 14703 : GDALProgressFunc arg10 = (GDALProgressFunc) NULL ;
6488 14703 : void *arg11 = (void *) NULL ;
6489 14703 : void *argp1 = 0 ;
6490 14703 : int res1 = 0 ;
6491 14703 : int val2 ;
6492 14703 : int ecode2 = 0 ;
6493 14703 : double val3 ;
6494 14703 : int ecode3 = 0 ;
6495 14703 : double val4 ;
6496 14703 : int ecode4 = 0 ;
6497 14703 : double val5 ;
6498 14703 : int ecode5 = 0 ;
6499 14703 : double val6 ;
6500 14703 : int ecode6 = 0 ;
6501 14703 : PyObject * obj0 = 0 ;
6502 14703 : PyObject * obj1 = 0 ;
6503 14703 : PyObject * obj2 = 0 ;
6504 14703 : PyObject * obj3 = 0 ;
6505 14703 : PyObject * obj4 = 0 ;
6506 14703 : PyObject * obj5 = 0 ;
6507 14703 : PyObject * obj6 = 0 ;
6508 14703 : PyObject * obj7 = 0 ;
6509 14703 : PyObject * obj8 = 0 ;
6510 14703 : PyObject * obj9 = 0 ;
6511 14703 : PyObject * obj10 = 0 ;
6512 14703 : char * kwnames[] = {
6513 : (char *)"band", (char *)"bWrite", (char *)"xoff", (char *)"yoff", (char *)"xsize", (char *)"ysize", (char *)"psArray", (char *)"buf_type", (char *)"resample_alg", (char *)"callback", (char *)"callback_data", NULL
6514 : };
6515 14703 : CPLErr result;
6516 :
6517 : /* %typemap(arginit) ( const char* callback_data=NULL) */
6518 14703 : PyProgressData *psProgressInfo;
6519 14703 : psProgressInfo = (PyProgressData *) CPLCalloc(1,sizeof(PyProgressData));
6520 14703 : psProgressInfo->nLastReported = -1;
6521 14703 : psProgressInfo->psPyCallback = NULL;
6522 14703 : psProgressInfo->psPyCallbackData = NULL;
6523 14703 : arg11 = psProgressInfo;
6524 14703 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOOOO|OO:BandRasterIONumPy", kwnames, &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6, &obj7, &obj8, &obj9, &obj10)) SWIG_fail;
6525 14703 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 );
6526 14703 : if (!SWIG_IsOK(res1)) {
6527 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BandRasterIONumPy" "', argument " "1"" of type '" "GDALRasterBandShadow *""'");
6528 : }
6529 14703 : arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1);
6530 14703 : ecode2 = SWIG_AsVal_int(obj1, &val2);
6531 14703 : if (!SWIG_IsOK(ecode2)) {
6532 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BandRasterIONumPy" "', argument " "2"" of type '" "int""'");
6533 : }
6534 14703 : arg2 = static_cast< int >(val2);
6535 14703 : ecode3 = SWIG_AsVal_double(obj2, &val3);
6536 14703 : if (!SWIG_IsOK(ecode3)) {
6537 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "BandRasterIONumPy" "', argument " "3"" of type '" "double""'");
6538 : }
6539 14703 : arg3 = static_cast< double >(val3);
6540 14703 : ecode4 = SWIG_AsVal_double(obj3, &val4);
6541 14703 : if (!SWIG_IsOK(ecode4)) {
6542 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "BandRasterIONumPy" "', argument " "4"" of type '" "double""'");
6543 : }
6544 14703 : arg4 = static_cast< double >(val4);
6545 14703 : ecode5 = SWIG_AsVal_double(obj4, &val5);
6546 14703 : if (!SWIG_IsOK(ecode5)) {
6547 0 : SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "BandRasterIONumPy" "', argument " "5"" of type '" "double""'");
6548 : }
6549 14703 : arg5 = static_cast< double >(val5);
6550 14703 : ecode6 = SWIG_AsVal_double(obj5, &val6);
6551 14703 : if (!SWIG_IsOK(ecode6)) {
6552 0 : SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "BandRasterIONumPy" "', argument " "6"" of type '" "double""'");
6553 : }
6554 14703 : arg6 = static_cast< double >(val6);
6555 14703 : {
6556 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6557 14703 : if (obj6 != NULL && PyArray_Check(obj6))
6558 : {
6559 14703 : arg7 = (PyArrayObject*)(obj6);
6560 : }
6561 : else
6562 : {
6563 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6564 0 : SWIG_fail;
6565 : }
6566 : }
6567 14703 : {
6568 : // %typemap(in) GDALDataType
6569 14703 : int val = 0;
6570 14703 : int ecode = SWIG_AsVal_int(obj7, &val);
6571 14703 : if (!SWIG_IsOK(ecode)) {
6572 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALDataType");
6573 : }
6574 14703 : if( val < GDT_Unknown || val >= GDT_TypeCount )
6575 : {
6576 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for GDALDataType");
6577 : }
6578 14703 : arg8 = static_cast<GDALDataType>(val);
6579 : }
6580 14703 : {
6581 : // %typemap(in) GDALRIOResampleAlg
6582 14703 : int val = 0;
6583 14703 : int ecode = SWIG_AsVal_int(obj8, &val);
6584 14703 : if (!SWIG_IsOK(ecode)) {
6585 2 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALRIOResampleAlg");
6586 : }
6587 14701 : if( val < 0 ||
6588 14699 : ( val >= static_cast<int>(GRIORA_RESERVED_START) &&
6589 14697 : val <= static_cast<int>(GRIORA_RESERVED_END) ) ||
6590 : val > static_cast<int>(GRIORA_LAST) )
6591 : {
6592 4 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for resample_alg");
6593 : }
6594 14697 : arg9 = static_cast< GDALRIOResampleAlg >(val);
6595 : }
6596 14697 : if (obj9) {
6597 14697 : {
6598 : /* %typemap(in) (GDALProgressFunc callback = NULL) */
6599 : /* callback_func typemap */
6600 :
6601 : /* In some cases 0 is passed instead of None. */
6602 : /* See https://github.com/OSGeo/gdal/pull/219 */
6603 14697 : if ( PyLong_Check(obj9) || PyInt_Check(obj9) )
6604 : {
6605 0 : if( PyLong_AsLong(obj9) == 0 )
6606 : {
6607 0 : obj9 = Py_None;
6608 : }
6609 : }
6610 :
6611 14697 : if (obj9 && obj9 != Py_None ) {
6612 4 : void* cbfunction = NULL;
6613 4 : CPL_IGNORE_RET_VAL(SWIG_ConvertPtr( obj9,
6614 : (void**)&cbfunction,
6615 : SWIGTYPE_p_f_double_p_q_const__char_p_void__int,
6616 : SWIG_POINTER_EXCEPTION | 0 ));
6617 :
6618 4 : if ( cbfunction == GDALTermProgress ) {
6619 : arg10 = GDALTermProgress;
6620 : } else {
6621 4 : if (!PyCallable_Check(obj9)) {
6622 0 : PyErr_SetString( PyExc_RuntimeError,
6623 : "Object given is not a Python function" );
6624 0 : SWIG_fail;
6625 : }
6626 4 : psProgressInfo->psPyCallback = obj9;
6627 4 : arg10 = PyProgressProxy;
6628 : }
6629 :
6630 : }
6631 :
6632 : }
6633 : }
6634 14697 : if (obj10) {
6635 14697 : {
6636 : /* %typemap(in) ( void* callback_data=NULL) */
6637 14697 : psProgressInfo->psPyCallbackData = obj10 ;
6638 : }
6639 : }
6640 14697 : {
6641 14697 : const int bLocalUseExceptions = GetUseExceptions();
6642 14697 : if ( bLocalUseExceptions ) {
6643 14557 : pushErrorHandler();
6644 : }
6645 14697 : {
6646 14697 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6647 14697 : result = (CPLErr)BandRasterIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
6648 14697 : SWIG_PYTHON_THREAD_END_ALLOW;
6649 : }
6650 14697 : if ( bLocalUseExceptions ) {
6651 14557 : popErrorHandler();
6652 : }
6653 : #ifndef SED_HACKS
6654 : if ( bLocalUseExceptions ) {
6655 : CPLErr eclass = CPLGetLastErrorType();
6656 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6657 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6658 : }
6659 : }
6660 : #endif
6661 : }
6662 14697 : resultobj = SWIG_From_int(static_cast< int >(result));
6663 14697 : {
6664 : /* %typemap(freearg) ( void* callback_data=NULL) */
6665 :
6666 14697 : CPLFree(psProgressInfo);
6667 :
6668 : }
6669 14705 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6670 : return resultobj;
6671 6 : fail:
6672 6 : {
6673 : /* %typemap(freearg) ( void* callback_data=NULL) */
6674 :
6675 6 : CPLFree(psProgressInfo);
6676 :
6677 : }
6678 : return NULL;
6679 : }
6680 :
6681 :
6682 29 : SWIGINTERN PyObject *_wrap_DatasetIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6683 29 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6684 29 : GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ;
6685 29 : int arg2 ;
6686 29 : double arg3 ;
6687 29 : double arg4 ;
6688 29 : double arg5 ;
6689 29 : double arg6 ;
6690 29 : PyArrayObject *arg7 = (PyArrayObject *) 0 ;
6691 29 : GDALDataType arg8 ;
6692 29 : GDALRIOResampleAlg arg9 ;
6693 29 : GDALProgressFunc arg10 = (GDALProgressFunc) NULL ;
6694 29 : void *arg11 = (void *) NULL ;
6695 29 : bool arg12 = (bool) true ;
6696 29 : int arg13 = (int) 0 ;
6697 29 : int *arg14 = (int *) 0 ;
6698 29 : void *argp1 = 0 ;
6699 29 : int res1 = 0 ;
6700 29 : int val2 ;
6701 29 : int ecode2 = 0 ;
6702 29 : double val3 ;
6703 29 : int ecode3 = 0 ;
6704 29 : double val4 ;
6705 29 : int ecode4 = 0 ;
6706 29 : double val5 ;
6707 29 : int ecode5 = 0 ;
6708 29 : double val6 ;
6709 29 : int ecode6 = 0 ;
6710 29 : bool val12 ;
6711 29 : int ecode12 = 0 ;
6712 29 : PyObject * obj0 = 0 ;
6713 29 : PyObject * obj1 = 0 ;
6714 29 : PyObject * obj2 = 0 ;
6715 29 : PyObject * obj3 = 0 ;
6716 29 : PyObject * obj4 = 0 ;
6717 29 : PyObject * obj5 = 0 ;
6718 29 : PyObject * obj6 = 0 ;
6719 29 : PyObject * obj7 = 0 ;
6720 29 : PyObject * obj8 = 0 ;
6721 29 : PyObject * obj9 = 0 ;
6722 29 : PyObject * obj10 = 0 ;
6723 29 : PyObject * obj11 = 0 ;
6724 29 : PyObject * obj12 = 0 ;
6725 29 : char * kwnames[] = {
6726 : (char *)"ds", (char *)"bWrite", (char *)"xoff", (char *)"yoff", (char *)"xsize", (char *)"ysize", (char *)"psArray", (char *)"buf_type", (char *)"resample_alg", (char *)"callback", (char *)"callback_data", (char *)"binterleave", (char *)"band_list", NULL
6727 : };
6728 29 : CPLErr result;
6729 :
6730 : /* %typemap(arginit) ( const char* callback_data=NULL) */
6731 29 : PyProgressData *psProgressInfo;
6732 29 : psProgressInfo = (PyProgressData *) CPLCalloc(1,sizeof(PyProgressData));
6733 29 : psProgressInfo->nLastReported = -1;
6734 29 : psProgressInfo->psPyCallback = NULL;
6735 29 : psProgressInfo->psPyCallbackData = NULL;
6736 29 : arg11 = psProgressInfo;
6737 29 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOOOO|OOOO:DatasetIONumPy", kwnames, &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6, &obj7, &obj8, &obj9, &obj10, &obj11, &obj12)) SWIG_fail;
6738 29 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 );
6739 29 : if (!SWIG_IsOK(res1)) {
6740 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DatasetIONumPy" "', argument " "1"" of type '" "GDALDatasetShadow *""'");
6741 : }
6742 29 : arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1);
6743 29 : ecode2 = SWIG_AsVal_int(obj1, &val2);
6744 29 : if (!SWIG_IsOK(ecode2)) {
6745 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DatasetIONumPy" "', argument " "2"" of type '" "int""'");
6746 : }
6747 29 : arg2 = static_cast< int >(val2);
6748 29 : ecode3 = SWIG_AsVal_double(obj2, &val3);
6749 29 : if (!SWIG_IsOK(ecode3)) {
6750 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DatasetIONumPy" "', argument " "3"" of type '" "double""'");
6751 : }
6752 29 : arg3 = static_cast< double >(val3);
6753 29 : ecode4 = SWIG_AsVal_double(obj3, &val4);
6754 29 : if (!SWIG_IsOK(ecode4)) {
6755 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "DatasetIONumPy" "', argument " "4"" of type '" "double""'");
6756 : }
6757 29 : arg4 = static_cast< double >(val4);
6758 29 : ecode5 = SWIG_AsVal_double(obj4, &val5);
6759 29 : if (!SWIG_IsOK(ecode5)) {
6760 0 : SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "DatasetIONumPy" "', argument " "5"" of type '" "double""'");
6761 : }
6762 29 : arg5 = static_cast< double >(val5);
6763 29 : ecode6 = SWIG_AsVal_double(obj5, &val6);
6764 29 : if (!SWIG_IsOK(ecode6)) {
6765 0 : SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "DatasetIONumPy" "', argument " "6"" of type '" "double""'");
6766 : }
6767 29 : arg6 = static_cast< double >(val6);
6768 29 : {
6769 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6770 29 : if (obj6 != NULL && PyArray_Check(obj6))
6771 : {
6772 29 : arg7 = (PyArrayObject*)(obj6);
6773 : }
6774 : else
6775 : {
6776 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6777 0 : SWIG_fail;
6778 : }
6779 : }
6780 29 : {
6781 : // %typemap(in) GDALDataType
6782 29 : int val = 0;
6783 29 : int ecode = SWIG_AsVal_int(obj7, &val);
6784 29 : if (!SWIG_IsOK(ecode)) {
6785 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALDataType");
6786 : }
6787 29 : if( val < GDT_Unknown || val >= GDT_TypeCount )
6788 : {
6789 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for GDALDataType");
6790 : }
6791 29 : arg8 = static_cast<GDALDataType>(val);
6792 : }
6793 29 : {
6794 : // %typemap(in) GDALRIOResampleAlg
6795 29 : int val = 0;
6796 29 : int ecode = SWIG_AsVal_int(obj8, &val);
6797 29 : if (!SWIG_IsOK(ecode)) {
6798 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALRIOResampleAlg");
6799 : }
6800 29 : if( val < 0 ||
6801 29 : ( val >= static_cast<int>(GRIORA_RESERVED_START) &&
6802 29 : val <= static_cast<int>(GRIORA_RESERVED_END) ) ||
6803 : val > static_cast<int>(GRIORA_LAST) )
6804 : {
6805 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for resample_alg");
6806 : }
6807 29 : arg9 = static_cast< GDALRIOResampleAlg >(val);
6808 : }
6809 29 : if (obj9) {
6810 29 : {
6811 : /* %typemap(in) (GDALProgressFunc callback = NULL) */
6812 : /* callback_func typemap */
6813 :
6814 : /* In some cases 0 is passed instead of None. */
6815 : /* See https://github.com/OSGeo/gdal/pull/219 */
6816 29 : if ( PyLong_Check(obj9) || PyInt_Check(obj9) )
6817 : {
6818 0 : if( PyLong_AsLong(obj9) == 0 )
6819 : {
6820 0 : obj9 = Py_None;
6821 : }
6822 : }
6823 :
6824 29 : if (obj9 && obj9 != Py_None ) {
6825 3 : void* cbfunction = NULL;
6826 3 : CPL_IGNORE_RET_VAL(SWIG_ConvertPtr( obj9,
6827 : (void**)&cbfunction,
6828 : SWIGTYPE_p_f_double_p_q_const__char_p_void__int,
6829 : SWIG_POINTER_EXCEPTION | 0 ));
6830 :
6831 3 : if ( cbfunction == GDALTermProgress ) {
6832 : arg10 = GDALTermProgress;
6833 : } else {
6834 3 : if (!PyCallable_Check(obj9)) {
6835 0 : PyErr_SetString( PyExc_RuntimeError,
6836 : "Object given is not a Python function" );
6837 0 : SWIG_fail;
6838 : }
6839 3 : psProgressInfo->psPyCallback = obj9;
6840 3 : arg10 = PyProgressProxy;
6841 : }
6842 :
6843 : }
6844 :
6845 : }
6846 : }
6847 29 : if (obj10) {
6848 29 : {
6849 : /* %typemap(in) ( void* callback_data=NULL) */
6850 29 : psProgressInfo->psPyCallbackData = obj10 ;
6851 : }
6852 : }
6853 29 : if (obj11) {
6854 29 : ecode12 = SWIG_AsVal_bool(obj11, &val12);
6855 29 : if (!SWIG_IsOK(ecode12)) {
6856 0 : SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "DatasetIONumPy" "', argument " "12"" of type '" "bool""'");
6857 : }
6858 : arg12 = static_cast< bool >(val12);
6859 : }
6860 29 : if (obj12) {
6861 29 : {
6862 : /* %typemap(in,numinputs=1) (int nList, int* pList)*/
6863 29 : arg14 = CreateCIntListFromSequence(obj12, &arg13);
6864 29 : if( arg13 < 0 ) {
6865 0 : SWIG_fail;
6866 : }
6867 : }
6868 : }
6869 29 : {
6870 29 : const int bLocalUseExceptions = GetUseExceptions();
6871 29 : if ( bLocalUseExceptions ) {
6872 7 : pushErrorHandler();
6873 : }
6874 29 : {
6875 29 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6876 29 : result = (CPLErr)DatasetIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
6877 29 : SWIG_PYTHON_THREAD_END_ALLOW;
6878 : }
6879 29 : if ( bLocalUseExceptions ) {
6880 7 : popErrorHandler();
6881 : }
6882 : #ifndef SED_HACKS
6883 : if ( bLocalUseExceptions ) {
6884 : CPLErr eclass = CPLGetLastErrorType();
6885 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6886 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6887 : }
6888 : }
6889 : #endif
6890 : }
6891 29 : resultobj = SWIG_From_int(static_cast< int >(result));
6892 29 : {
6893 : /* %typemap(freearg) ( void* callback_data=NULL) */
6894 :
6895 29 : CPLFree(psProgressInfo);
6896 :
6897 : }
6898 29 : {
6899 : /* %typemap(freearg) (int nList, int* pList) */
6900 29 : free(arg14);
6901 : }
6902 30 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
6903 : return resultobj;
6904 0 : fail:
6905 0 : {
6906 : /* %typemap(freearg) ( void* callback_data=NULL) */
6907 :
6908 0 : CPLFree(psProgressInfo);
6909 :
6910 : }
6911 0 : {
6912 : /* %typemap(freearg) (int nList, int* pList) */
6913 0 : free(arg14);
6914 : }
6915 0 : return NULL;
6916 : }
6917 :
6918 :
6919 78 : SWIGINTERN PyObject *_wrap_MDArrayIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6920 78 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6921 78 : bool arg1 ;
6922 78 : GDALMDArrayHS *arg2 = (GDALMDArrayHS *) 0 ;
6923 78 : PyArrayObject *arg3 = (PyArrayObject *) 0 ;
6924 78 : int arg4 ;
6925 78 : GUIntBig *arg5 = (GUIntBig *) 0 ;
6926 78 : int arg6 ;
6927 78 : GIntBig *arg7 = (GIntBig *) 0 ;
6928 78 : GDALExtendedDataTypeHS *arg8 = (GDALExtendedDataTypeHS *) 0 ;
6929 78 : bool val1 ;
6930 78 : int ecode1 = 0 ;
6931 78 : void *argp2 = 0 ;
6932 78 : int res2 = 0 ;
6933 78 : void *argp8 = 0 ;
6934 78 : int res8 = 0 ;
6935 78 : PyObject *swig_obj[6] ;
6936 78 : CPLErr result;
6937 :
6938 78 : if (!SWIG_Python_UnpackTuple(args, "MDArrayIONumPy", 6, 6, swig_obj)) SWIG_fail;
6939 78 : ecode1 = SWIG_AsVal_bool(swig_obj[0], &val1);
6940 78 : if (!SWIG_IsOK(ecode1)) {
6941 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MDArrayIONumPy" "', argument " "1"" of type '" "bool""'");
6942 : }
6943 78 : arg1 = static_cast< bool >(val1);
6944 78 : res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_GDALMDArrayHS, 0 | 0 );
6945 78 : if (!SWIG_IsOK(res2)) {
6946 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MDArrayIONumPy" "', argument " "2"" of type '" "GDALMDArrayHS *""'");
6947 : }
6948 78 : arg2 = reinterpret_cast< GDALMDArrayHS * >(argp2);
6949 78 : {
6950 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6951 78 : if (swig_obj[2] != NULL && PyArray_Check(swig_obj[2]))
6952 : {
6953 78 : arg3 = (PyArrayObject*)(swig_obj[2]);
6954 : }
6955 : else
6956 : {
6957 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6958 0 : SWIG_fail;
6959 : }
6960 : }
6961 78 : {
6962 : /* %typemap(in,numinputs=1) (int nList, GUIntBig* pList)*/
6963 78 : arg5 = CreateCGUIntBigListFromSequence(swig_obj[3], &arg4);
6964 78 : if( arg4 < 0 ) {
6965 0 : SWIG_fail;
6966 : }
6967 : }
6968 78 : {
6969 : /* %typemap(in,numinputs=1) (int nList, GIntBig* pList)*/
6970 78 : arg7 = CreateCGIntBigListFromSequence(swig_obj[4], &arg6);
6971 78 : if( arg6 < 0 ) {
6972 0 : SWIG_fail;
6973 : }
6974 : }
6975 78 : res8 = SWIG_ConvertPtr(swig_obj[5], &argp8,SWIGTYPE_p_GDALExtendedDataTypeHS, 0 | 0 );
6976 78 : if (!SWIG_IsOK(res8)) {
6977 0 : SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "MDArrayIONumPy" "', argument " "8"" of type '" "GDALExtendedDataTypeHS *""'");
6978 : }
6979 78 : arg8 = reinterpret_cast< GDALExtendedDataTypeHS * >(argp8);
6980 78 : {
6981 78 : const int bLocalUseExceptions = GetUseExceptions();
6982 78 : if ( bLocalUseExceptions ) {
6983 76 : pushErrorHandler();
6984 : }
6985 78 : {
6986 78 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6987 78 : result = (CPLErr)MDArrayIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
6988 78 : SWIG_PYTHON_THREAD_END_ALLOW;
6989 : }
6990 78 : if ( bLocalUseExceptions ) {
6991 76 : popErrorHandler();
6992 : }
6993 : #ifndef SED_HACKS
6994 : if ( bLocalUseExceptions ) {
6995 : CPLErr eclass = CPLGetLastErrorType();
6996 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6997 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6998 : }
6999 : }
7000 : #endif
7001 : }
7002 78 : resultobj = SWIG_From_int(static_cast< int >(result));
7003 78 : {
7004 : /* %typemap(freearg) (int nList, GUIntBig* pList) */
7005 78 : free(arg5);
7006 : }
7007 78 : {
7008 : /* %typemap(freearg) (int nList, GIntBig* pList) */
7009 78 : free(arg7);
7010 : }
7011 78 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7012 : return resultobj;
7013 0 : fail:
7014 0 : {
7015 : /* %typemap(freearg) (int nList, GUIntBig* pList) */
7016 0 : free(arg5);
7017 : }
7018 0 : {
7019 : /* %typemap(freearg) (int nList, GIntBig* pList) */
7020 0 : free(arg7);
7021 : }
7022 0 : return NULL;
7023 : }
7024 :
7025 :
7026 0 : SWIGINTERN PyObject *_wrap_AddNumpyArrayToDict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7027 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7028 0 : PyObject *arg1 = (PyObject *) 0 ;
7029 0 : ArrowSchema *arg2 = (ArrowSchema *) 0 ;
7030 0 : ArrowArray *arg3 = (ArrowArray *) 0 ;
7031 0 : std::string *arg4 = 0 ;
7032 0 : PyObject *arg5 = (PyObject *) 0 ;
7033 0 : void *argp2 = 0 ;
7034 0 : int res2 = 0 ;
7035 0 : void *argp3 = 0 ;
7036 0 : int res3 = 0 ;
7037 0 : void *argp4 = 0 ;
7038 0 : int res4 = 0 ;
7039 0 : PyObject *swig_obj[5] ;
7040 0 : bool result;
7041 :
7042 0 : if (!SWIG_Python_UnpackTuple(args, "AddNumpyArrayToDict", 5, 5, swig_obj)) SWIG_fail;
7043 0 : arg1 = swig_obj[0];
7044 0 : res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ArrowSchema, 0 | 0 );
7045 0 : if (!SWIG_IsOK(res2)) {
7046 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AddNumpyArrayToDict" "', argument " "2"" of type '" "ArrowSchema const *""'");
7047 : }
7048 0 : arg2 = reinterpret_cast< ArrowSchema * >(argp2);
7049 0 : res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ArrowArray, 0 | 0 );
7050 0 : if (!SWIG_IsOK(res3)) {
7051 0 : SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "AddNumpyArrayToDict" "', argument " "3"" of type '" "ArrowArray const *""'");
7052 : }
7053 0 : arg3 = reinterpret_cast< ArrowArray * >(argp3);
7054 0 : res4 = SWIG_ConvertPtr(swig_obj[3], &argp4, SWIGTYPE_p_std__string, 0 | 0);
7055 0 : if (!SWIG_IsOK(res4)) {
7056 0 : SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AddNumpyArrayToDict" "', argument " "4"" of type '" "std::string const &""'");
7057 : }
7058 0 : if (!argp4) {
7059 0 : SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AddNumpyArrayToDict" "', argument " "4"" of type '" "std::string const &""'");
7060 : }
7061 0 : arg4 = reinterpret_cast< std::string * >(argp4);
7062 0 : arg5 = swig_obj[4];
7063 0 : {
7064 0 : const int bLocalUseExceptions = GetUseExceptions();
7065 0 : if ( bLocalUseExceptions ) {
7066 0 : pushErrorHandler();
7067 : }
7068 0 : result = (bool)AddNumpyArrayToDict(arg1,(ArrowSchema const *)arg2,(ArrowArray const *)arg3,(std::string const &)*arg4,arg5);
7069 0 : if ( bLocalUseExceptions ) {
7070 0 : popErrorHandler();
7071 : }
7072 : #ifndef SED_HACKS
7073 : if ( bLocalUseExceptions ) {
7074 : CPLErr eclass = CPLGetLastErrorType();
7075 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7076 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7077 : }
7078 : }
7079 : #endif
7080 : }
7081 0 : resultobj = SWIG_From_bool(static_cast< bool >(result));
7082 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7083 : return resultobj;
7084 : fail:
7085 : return NULL;
7086 : }
7087 :
7088 :
7089 469 : SWIGINTERN PyObject *_wrap__RecordBatchAsNumpy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7090 469 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7091 469 : VoidPtrAsLong arg1 = (VoidPtrAsLong) 0 ;
7092 469 : VoidPtrAsLong arg2 = (VoidPtrAsLong) 0 ;
7093 469 : PyObject *arg3 = (PyObject *) 0 ;
7094 469 : PyObject *swig_obj[3] ;
7095 469 : PyObject *result = 0 ;
7096 :
7097 469 : if (!SWIG_Python_UnpackTuple(args, "_RecordBatchAsNumpy", 3, 3, swig_obj)) SWIG_fail;
7098 469 : {
7099 469 : arg1 = PyLong_AsVoidPtr(swig_obj[0]);
7100 : }
7101 469 : {
7102 469 : arg2 = PyLong_AsVoidPtr(swig_obj[1]);
7103 : }
7104 469 : arg3 = swig_obj[2];
7105 469 : {
7106 469 : const int bLocalUseExceptions = GetUseExceptions();
7107 469 : if ( bLocalUseExceptions ) {
7108 158 : pushErrorHandler();
7109 : }
7110 469 : result = (PyObject *)_RecordBatchAsNumpy(arg1,arg2,arg3);
7111 469 : if ( bLocalUseExceptions ) {
7112 158 : popErrorHandler();
7113 : }
7114 : #ifndef SED_HACKS
7115 : if ( bLocalUseExceptions ) {
7116 : CPLErr eclass = CPLGetLastErrorType();
7117 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7118 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7119 : }
7120 : }
7121 : #endif
7122 : }
7123 469 : resultobj = result;
7124 469 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7125 : return resultobj;
7126 0 : fail:
7127 0 : return NULL;
7128 : }
7129 :
7130 :
7131 28 : SWIGINTERN PyObject *_wrap_VirtualMemGetArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7132 28 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7133 28 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
7134 28 : CPLVirtualMemShadow **arg2 = (CPLVirtualMemShadow **) 0 ;
7135 28 : int arg3 ;
7136 28 : void *argp1 = 0 ;
7137 28 : int res1 = 0 ;
7138 28 : CPLVirtualMemShadow *virtualmem2 ;
7139 28 : PyObject *swig_obj[1] ;
7140 :
7141 28 : {
7142 28 : arg2 = &virtualmem2;
7143 28 : arg3 = 0;
7144 : }
7145 28 : if (!args) SWIG_fail;
7146 28 : swig_obj[0] = args;
7147 28 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
7148 28 : if (!SWIG_IsOK(res1)) {
7149 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMemGetArray" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
7150 : }
7151 28 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
7152 28 : {
7153 28 : if (!arg1) {
7154 0 : SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
7155 : }
7156 : }
7157 28 : {
7158 28 : const int bLocalUseExceptions = GetUseExceptions();
7159 28 : if ( bLocalUseExceptions ) {
7160 28 : pushErrorHandler();
7161 : }
7162 28 : VirtualMemGetArray(arg1,arg2,arg3);
7163 28 : if ( bLocalUseExceptions ) {
7164 28 : popErrorHandler();
7165 : }
7166 : #ifndef SED_HACKS
7167 : if ( bLocalUseExceptions ) {
7168 : CPLErr eclass = CPLGetLastErrorType();
7169 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7170 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7171 : }
7172 : }
7173 : #endif
7174 : }
7175 28 : resultobj = SWIG_Py_Void();
7176 28 : {
7177 28 : CPLVirtualMemShadow* virtualmem = *(arg2);
7178 28 : void* ptr = CPLVirtualMemGetAddr( virtualmem->vmem );
7179 : /*size_t nsize = CPLVirtualMemGetSize( virtualmem->vmem );*/
7180 28 : GDALDataType datatype = virtualmem->eBufType;
7181 28 : int readonly = virtualmem->bReadOnly;
7182 28 : GIntBig nBufXSize = virtualmem->nBufXSize;
7183 28 : GIntBig nBufYSize = virtualmem->nBufYSize;
7184 28 : int nBandCount = virtualmem->nBandCount;
7185 28 : int bIsBandSequential = virtualmem->bIsBandSequential;
7186 28 : GDALTileOrganization eTileOrganization = virtualmem->eTileOrganization;
7187 28 : int nTileXSize = virtualmem->nTileXSize;
7188 28 : int nTileYSize = virtualmem->nTileYSize;
7189 28 : int bAuto = virtualmem->bAuto;
7190 28 : int nPixelSpace = virtualmem->nPixelSpace; /* if bAuto == TRUE */
7191 28 : GIntBig nLineSpace = virtualmem->nLineSpace; /* if bAuto == TRUE */
7192 28 : int numpytype;
7193 :
7194 28 : if( datatype == GDT_CInt16 || datatype == GDT_CInt32 )
7195 : {
7196 0 : PyErr_SetString( PyExc_RuntimeError, "GDT_CInt16 and GDT_CInt32 not supported for now" );
7197 0 : SWIG_fail;
7198 : }
7199 :
7200 28 : switch(datatype)
7201 : {
7202 : case GDT_Byte: numpytype = NPY_UBYTE; break;
7203 : case GDT_Int8: numpytype = NPY_INT8; break;
7204 : case GDT_Int16: numpytype = NPY_INT16; break;
7205 : case GDT_UInt16: numpytype = NPY_UINT16; break;
7206 : case GDT_Int32: numpytype = NPY_INT32; break;
7207 : case GDT_UInt32: numpytype = NPY_UINT32; break;
7208 : case GDT_Int64: numpytype = NPY_INT64; break;
7209 : case GDT_UInt64: numpytype = NPY_UINT64; break;
7210 : case GDT_Float32: numpytype = NPY_FLOAT32; break;
7211 : case GDT_Float64: numpytype = NPY_FLOAT64; break;
7212 : //case GDT_CInt16: numpytype = NPY_INT16; break;
7213 : //case GDT_CInt32: numpytype = NPY_INT32; break;
7214 : case GDT_CFloat32: numpytype = NPY_CFLOAT; break;
7215 : case GDT_CFloat64: numpytype = NPY_CDOUBLE; break;
7216 : default: numpytype = NPY_UBYTE; break;
7217 : }
7218 28 : PyArrayObject* ar;
7219 28 : int flags = (readonly) ? 0x1 : 0x1 | 0x0400;
7220 28 : int nDataTypeSize = GDALGetDataTypeSize(datatype) / 8;
7221 28 : if( bAuto )
7222 : {
7223 20 : if( nBandCount == 1 )
7224 : {
7225 20 : npy_intp shape[2], stride[2];
7226 20 : shape[0] = nBufYSize;
7227 20 : shape[1] = nBufXSize;
7228 20 : stride[1] = nPixelSpace;
7229 20 : stride[0] = nLineSpace;
7230 20 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 2, shape,
7231 : numpytype, stride, ptr, 0, flags , NULL);
7232 : }
7233 : else
7234 : {
7235 0 : PyErr_SetString( PyExc_RuntimeError, "Code update needed for bAuto and nBandCount > 1 !" );
7236 0 : SWIG_fail;
7237 : }
7238 : }
7239 8 : else if( bIsBandSequential >= 0 )
7240 : {
7241 4 : if( nBandCount == 1 )
7242 : {
7243 2 : npy_intp shape[2], stride[2];
7244 2 : shape[0] = nBufYSize;
7245 2 : shape[1] = nBufXSize;
7246 2 : stride[1] = nDataTypeSize;
7247 2 : stride[0] = stride[1] * nBufXSize;
7248 2 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 2, shape,
7249 : numpytype, stride, ptr, 0, flags , NULL);
7250 : }
7251 : else
7252 : {
7253 2 : npy_intp shape[3], stride[3];
7254 2 : if( bIsBandSequential )
7255 : {
7256 1 : shape[0] = nBandCount;
7257 1 : shape[1] = nBufYSize;
7258 1 : shape[2] = nBufXSize;
7259 1 : stride[2] = nDataTypeSize;
7260 1 : stride[1] = stride[2] * nBufXSize;
7261 1 : stride[0] = stride[1] * nBufYSize;
7262 : }
7263 : else
7264 : {
7265 1 : shape[0] = nBufYSize;
7266 1 : shape[1] = nBufXSize;
7267 1 : shape[2] = nBandCount;
7268 1 : stride[2] = nDataTypeSize;
7269 1 : stride[1] = stride[2] * nBandCount;
7270 1 : stride[0] = stride[1] * nBufXSize;
7271 : }
7272 2 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 3, shape,
7273 : numpytype, stride, ptr, 0, flags , NULL);
7274 : }
7275 : }
7276 : else
7277 : {
7278 4 : npy_intp nTilesPerRow = static_cast<npy_intp>((nBufXSize + nTileXSize - 1) / nTileXSize);
7279 4 : npy_intp nTilesPerCol = static_cast<npy_intp>((nBufYSize + nTileYSize - 1) / nTileYSize);
7280 4 : npy_intp shape[5], stride[5];
7281 4 : if( nBandCount == 1 )
7282 : {
7283 1 : shape[0] = nTilesPerCol;
7284 1 : shape[1] = nTilesPerRow;
7285 1 : shape[2] = nTileYSize;
7286 1 : shape[3] = nTileXSize;
7287 1 : stride[3] = nDataTypeSize;
7288 1 : stride[2] = stride[3] * nTileXSize;
7289 1 : stride[1] = stride[2] * nTileYSize;
7290 1 : stride[0] = stride[1] * nTilesPerRow;
7291 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 4, shape,
7292 : numpytype, stride, ptr, 0, flags , NULL);
7293 : }
7294 3 : else if( eTileOrganization == GTO_TIP )
7295 : {
7296 1 : shape[0] = nTilesPerCol;
7297 1 : shape[1] = nTilesPerRow;
7298 1 : shape[2] = nTileYSize;
7299 1 : shape[3] = nTileXSize;
7300 1 : shape[4] = nBandCount;
7301 1 : stride[4] = nDataTypeSize;
7302 1 : stride[3] = stride[4] * nBandCount;
7303 1 : stride[2] = stride[3] * nTileXSize;
7304 1 : stride[1] = stride[2] * nTileYSize;
7305 1 : stride[0] = stride[1] * nTilesPerRow;
7306 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7307 : numpytype, stride, ptr, 0, flags , NULL);
7308 : }
7309 2 : else if( eTileOrganization == GTO_BIT )
7310 : {
7311 1 : shape[0] = nTilesPerCol;
7312 1 : shape[1] = nTilesPerRow;
7313 1 : shape[2] = nBandCount;
7314 1 : shape[3] = nTileYSize;
7315 1 : shape[4] = nTileXSize;
7316 1 : stride[4] = nDataTypeSize;
7317 1 : stride[3] = stride[4] * nTileXSize;
7318 1 : stride[2] = stride[3] * nTileYSize;
7319 1 : stride[1] = stride[2] * nBandCount;
7320 1 : stride[0] = stride[1] * nTilesPerRow;
7321 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7322 : numpytype, stride, ptr, 0, flags , NULL);
7323 : }
7324 : else /* GTO_BSQ */
7325 : {
7326 1 : shape[0] = nBandCount;
7327 1 : shape[1] = nTilesPerCol;
7328 1 : shape[2] = nTilesPerRow;
7329 1 : shape[3] = nTileYSize;
7330 1 : shape[4] = nTileXSize;
7331 1 : stride[4] = nDataTypeSize;
7332 1 : stride[3] = stride[4] * nTileXSize;
7333 1 : stride[2] = stride[3] * nTileYSize;
7334 1 : stride[1] = stride[2] * nTilesPerRow;
7335 1 : stride[0] = stride[1] * nTilesPerCol;
7336 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7337 : numpytype, stride, ptr, 0, flags , NULL);
7338 : }
7339 : }
7340 :
7341 : /* Keep a reference to the VirtualMem object */
7342 : #if NPY_API_VERSION >= 0x00000007
7343 28 : PyArray_SetBaseObject(ar, swig_obj[0]);
7344 : #else
7345 : PyArray_BASE(ar) = swig_obj[0];
7346 : #endif
7347 28 : Py_INCREF(swig_obj[0]);
7348 28 : Py_DECREF(resultobj);
7349 28 : resultobj = (PyObject*) ar;
7350 : }
7351 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7352 : return resultobj;
7353 : fail:
7354 : return NULL;
7355 : }
7356 :
7357 :
7358 13 : SWIGINTERN PyObject *_wrap_RATValuesIONumPyWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
7359 13 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7360 13 : GDALRasterAttributeTableShadow *arg1 = (GDALRasterAttributeTableShadow *) 0 ;
7361 13 : int arg2 ;
7362 13 : int arg3 ;
7363 13 : PyArrayObject *arg4 = (PyArrayObject *) 0 ;
7364 13 : void *argp1 = 0 ;
7365 13 : int res1 = 0 ;
7366 13 : int val2 ;
7367 13 : int ecode2 = 0 ;
7368 13 : int val3 ;
7369 13 : int ecode3 = 0 ;
7370 13 : PyObject * obj0 = 0 ;
7371 13 : PyObject * obj1 = 0 ;
7372 13 : PyObject * obj2 = 0 ;
7373 13 : PyObject * obj3 = 0 ;
7374 13 : char * kwnames[] = {
7375 : (char *)"poRAT", (char *)"nField", (char *)"nStart", (char *)"psArray", NULL
7376 : };
7377 13 : CPLErr result;
7378 :
7379 13 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:RATValuesIONumPyWrite", kwnames, &obj0, &obj1, &obj2, &obj3)) SWIG_fail;
7380 13 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterAttributeTableShadow, 0 | 0 );
7381 13 : if (!SWIG_IsOK(res1)) {
7382 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RATValuesIONumPyWrite" "', argument " "1"" of type '" "GDALRasterAttributeTableShadow *""'");
7383 : }
7384 13 : arg1 = reinterpret_cast< GDALRasterAttributeTableShadow * >(argp1);
7385 13 : ecode2 = SWIG_AsVal_int(obj1, &val2);
7386 13 : if (!SWIG_IsOK(ecode2)) {
7387 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RATValuesIONumPyWrite" "', argument " "2"" of type '" "int""'");
7388 : }
7389 13 : arg2 = static_cast< int >(val2);
7390 13 : ecode3 = SWIG_AsVal_int(obj2, &val3);
7391 13 : if (!SWIG_IsOK(ecode3)) {
7392 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RATValuesIONumPyWrite" "', argument " "3"" of type '" "int""'");
7393 : }
7394 13 : arg3 = static_cast< int >(val3);
7395 13 : {
7396 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
7397 13 : if (obj3 != NULL && PyArray_Check(obj3))
7398 : {
7399 13 : arg4 = (PyArrayObject*)(obj3);
7400 : }
7401 : else
7402 : {
7403 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
7404 0 : SWIG_fail;
7405 : }
7406 : }
7407 13 : {
7408 13 : const int bLocalUseExceptions = GetUseExceptions();
7409 13 : if ( bLocalUseExceptions ) {
7410 13 : pushErrorHandler();
7411 : }
7412 13 : result = (CPLErr)RATValuesIONumPyWrite(arg1,arg2,arg3,arg4);
7413 13 : if ( bLocalUseExceptions ) {
7414 13 : popErrorHandler();
7415 : }
7416 : #ifndef SED_HACKS
7417 : if ( bLocalUseExceptions ) {
7418 : CPLErr eclass = CPLGetLastErrorType();
7419 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7420 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7421 : }
7422 : }
7423 : #endif
7424 : }
7425 13 : resultobj = SWIG_From_int(static_cast< int >(result));
7426 13 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7427 : return resultobj;
7428 : fail:
7429 : return NULL;
7430 : }
7431 :
7432 :
7433 40 : SWIGINTERN PyObject *_wrap_RATValuesIONumPyRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
7434 40 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7435 40 : GDALRasterAttributeTableShadow *arg1 = (GDALRasterAttributeTableShadow *) 0 ;
7436 40 : int arg2 ;
7437 40 : int arg3 ;
7438 40 : int arg4 ;
7439 40 : void *argp1 = 0 ;
7440 40 : int res1 = 0 ;
7441 40 : int val2 ;
7442 40 : int ecode2 = 0 ;
7443 40 : int val3 ;
7444 40 : int ecode3 = 0 ;
7445 40 : int val4 ;
7446 40 : int ecode4 = 0 ;
7447 40 : PyObject * obj0 = 0 ;
7448 40 : PyObject * obj1 = 0 ;
7449 40 : PyObject * obj2 = 0 ;
7450 40 : PyObject * obj3 = 0 ;
7451 40 : char * kwnames[] = {
7452 : (char *)"poRAT", (char *)"nField", (char *)"nStart", (char *)"nLength", NULL
7453 : };
7454 40 : PyObject *result = 0 ;
7455 :
7456 40 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:RATValuesIONumPyRead", kwnames, &obj0, &obj1, &obj2, &obj3)) SWIG_fail;
7457 40 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterAttributeTableShadow, 0 | 0 );
7458 40 : if (!SWIG_IsOK(res1)) {
7459 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RATValuesIONumPyRead" "', argument " "1"" of type '" "GDALRasterAttributeTableShadow *""'");
7460 : }
7461 40 : arg1 = reinterpret_cast< GDALRasterAttributeTableShadow * >(argp1);
7462 40 : ecode2 = SWIG_AsVal_int(obj1, &val2);
7463 40 : if (!SWIG_IsOK(ecode2)) {
7464 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RATValuesIONumPyRead" "', argument " "2"" of type '" "int""'");
7465 : }
7466 40 : arg2 = static_cast< int >(val2);
7467 40 : ecode3 = SWIG_AsVal_int(obj2, &val3);
7468 40 : if (!SWIG_IsOK(ecode3)) {
7469 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RATValuesIONumPyRead" "', argument " "3"" of type '" "int""'");
7470 : }
7471 40 : arg3 = static_cast< int >(val3);
7472 40 : ecode4 = SWIG_AsVal_int(obj3, &val4);
7473 40 : if (!SWIG_IsOK(ecode4)) {
7474 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "RATValuesIONumPyRead" "', argument " "4"" of type '" "int""'");
7475 : }
7476 40 : arg4 = static_cast< int >(val4);
7477 40 : {
7478 40 : const int bLocalUseExceptions = GetUseExceptions();
7479 40 : if ( bLocalUseExceptions ) {
7480 40 : pushErrorHandler();
7481 : }
7482 40 : result = (PyObject *)RATValuesIONumPyRead(arg1,arg2,arg3,arg4);
7483 40 : if ( bLocalUseExceptions ) {
7484 40 : popErrorHandler();
7485 : }
7486 : #ifndef SED_HACKS
7487 : if ( bLocalUseExceptions ) {
7488 : CPLErr eclass = CPLGetLastErrorType();
7489 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7490 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7491 : }
7492 : }
7493 : #endif
7494 : }
7495 40 : resultobj = result;
7496 40 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, CPLGetLastErrorMsg() ); return NULL; } }
7497 : return resultobj;
7498 : fail:
7499 : return NULL;
7500 : }
7501 :
7502 :
7503 : static PyMethodDef SwigMethods[] = {
7504 : { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL},
7505 : { "delete_VirtualMem", _wrap_delete_VirtualMem, METH_O, "delete_VirtualMem(VirtualMem self)"},
7506 : { "VirtualMem_GetAddr", _wrap_VirtualMem_GetAddr, METH_O, "VirtualMem_GetAddr(VirtualMem self)"},
7507 : { "VirtualMem_Pin", _wrap_VirtualMem_Pin, METH_VARARGS, "VirtualMem_Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)"},
7508 : { "VirtualMem_swigregister", VirtualMem_swigregister, METH_O, NULL},
7509 : { "GetUseExceptions", _wrap_GetUseExceptions, METH_NOARGS, "GetUseExceptions() -> int"},
7510 : { "_GetExceptionsLocal", _wrap__GetExceptionsLocal, METH_NOARGS, "_GetExceptionsLocal() -> int"},
7511 : { "_SetExceptionsLocal", _wrap__SetExceptionsLocal, METH_O, "_SetExceptionsLocal(int bVal)"},
7512 : { "_UseExceptions", _wrap__UseExceptions, METH_NOARGS, "_UseExceptions()"},
7513 : { "_DontUseExceptions", _wrap__DontUseExceptions, METH_NOARGS, "_DontUseExceptions()"},
7514 : { "_UserHasSpecifiedIfUsingExceptions", _wrap__UserHasSpecifiedIfUsingExceptions, METH_NOARGS, "_UserHasSpecifiedIfUsingExceptions() -> int"},
7515 : { "TermProgress_nocb", (PyCFunction)(void(*)(void))_wrap_TermProgress_nocb, METH_VARARGS|METH_KEYWORDS, "TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) -> int"},
7516 : { "OpenNumPyArray", _wrap_OpenNumPyArray, METH_VARARGS, "OpenNumPyArray(PyArrayObject * psArray, bool binterleave) -> Dataset"},
7517 : { "OpenMultiDimensionalNumPyArray", _wrap_OpenMultiDimensionalNumPyArray, METH_O, "OpenMultiDimensionalNumPyArray(PyArrayObject * psArray) -> Dataset"},
7518 : { "GetArrayFilename", _wrap_GetArrayFilename, METH_O, "GetArrayFilename(PyArrayObject * psArray) -> retStringAndCPLFree *"},
7519 : { "BandRasterIONumPy", (PyCFunction)(void(*)(void))_wrap_BandRasterIONumPy, METH_VARARGS|METH_KEYWORDS, "BandRasterIONumPy(Band band, int bWrite, double xoff, double yoff, double xsize, double ysize, PyArrayObject * psArray, GDALDataType buf_type, GDALRIOResampleAlg resample_alg, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"},
7520 : { "DatasetIONumPy", (PyCFunction)(void(*)(void))_wrap_DatasetIONumPy, METH_VARARGS|METH_KEYWORDS, "DatasetIONumPy(Dataset ds, int bWrite, double xoff, double yoff, double xsize, double ysize, PyArrayObject * psArray, GDALDataType buf_type, GDALRIOResampleAlg resample_alg, GDALProgressFunc callback=0, void * callback_data=None, bool binterleave=True, int band_list=0) -> CPLErr"},
7521 : { "MDArrayIONumPy", _wrap_MDArrayIONumPy, METH_VARARGS, "MDArrayIONumPy(bool bWrite, GDALMDArrayHS * mdarray, PyArrayObject * psArray, int nDims1, int nDims3, GDALExtendedDataTypeHS * buffer_datatype) -> CPLErr"},
7522 : { "AddNumpyArrayToDict", _wrap_AddNumpyArrayToDict, METH_VARARGS, "AddNumpyArrayToDict(PyObject * dict, ArrowSchema const * schemaField, ArrowArray const * arrayField, std::string const & osPrefix, PyObject * pointerArrayKeeper) -> bool"},
7523 : { "_RecordBatchAsNumpy", _wrap__RecordBatchAsNumpy, METH_VARARGS, "_RecordBatchAsNumpy(VoidPtrAsLong recordBatchPtr, VoidPtrAsLong schemaPtr, PyObject * pointerArrayKeeper) -> PyObject *"},
7524 : { "VirtualMemGetArray", _wrap_VirtualMemGetArray, METH_O, "VirtualMemGetArray(VirtualMem virtualmem)"},
7525 : { "RATValuesIONumPyWrite", (PyCFunction)(void(*)(void))_wrap_RATValuesIONumPyWrite, METH_VARARGS|METH_KEYWORDS, "RATValuesIONumPyWrite(RasterAttributeTable poRAT, int nField, int nStart, PyArrayObject * psArray) -> CPLErr"},
7526 : { "RATValuesIONumPyRead", (PyCFunction)(void(*)(void))_wrap_RATValuesIONumPyRead, METH_VARARGS|METH_KEYWORDS, "RATValuesIONumPyRead(RasterAttributeTable poRAT, int nField, int nStart, int nLength) -> PyObject *"},
7527 : { NULL, NULL, 0, NULL }
7528 : };
7529 :
7530 : static PyMethodDef SwigMethods_proxydocs[] = {
7531 : { NULL, NULL, 0, NULL }
7532 : };
7533 :
7534 :
7535 : /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
7536 :
7537 : static swig_type_info _swigt__p_ArrowArray = {"_p_ArrowArray", "ArrowArray *", 0, 0, (void*)0, 0};
7538 : static swig_type_info _swigt__p_ArrowSchema = {"_p_ArrowSchema", "ArrowSchema *", 0, 0, (void*)0, 0};
7539 : static swig_type_info _swigt__p_CPLVirtualMemShadow = {"_p_CPLVirtualMemShadow", "CPLVirtualMemShadow *", 0, 0, (void*)0, 0};
7540 : static swig_type_info _swigt__p_GDALDataType = {"_p_GDALDataType", "GDALDataType *", 0, 0, (void*)0, 0};
7541 : static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, (void*)0, 0};
7542 : static swig_type_info _swigt__p_GDALExtendedDataTypeHS = {"_p_GDALExtendedDataTypeHS", "GDALExtendedDataTypeHS *", 0, 0, (void*)0, 0};
7543 : static swig_type_info _swigt__p_GDALMDArrayHS = {"_p_GDALMDArrayHS", "GDALMDArrayHS *", 0, 0, (void*)0, 0};
7544 : static swig_type_info _swigt__p_GDALProgressFunc = {"_p_GDALProgressFunc", "GDALProgressFunc *", 0, 0, (void*)0, 0};
7545 : static swig_type_info _swigt__p_GDALRasterAttributeTableShadow = {"_p_GDALRasterAttributeTableShadow", "GDALRasterAttributeTableShadow *", 0, 0, (void*)0, 0};
7546 : static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, (void*)0, 0};
7547 : static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, (void*)0, 0};
7548 : static swig_type_info _swigt__p_GUIntBig = {"_p_GUIntBig", "GUIntBig *", 0, 0, (void*)0, 0};
7549 : static swig_type_info _swigt__p_PyArrayObject = {"_p_PyArrayObject", "PyArrayObject *", 0, 0, (void*)0, 0};
7550 : static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
7551 : static swig_type_info _swigt__p_f_double_p_q_const__char_p_void__int = {"_p_f_double_p_q_const__char_p_void__int", "int (*)(double,char const *,void *)", 0, 0, (void*)0, 0};
7552 : static swig_type_info _swigt__p_int = {"_p_int", "GDALRATFieldType *|CPLErr *|int *|GDALRATTableType *|GDALRATFieldUsage *|GDALRIOResampleAlg *", 0, 0, (void*)0, 0};
7553 : static swig_type_info _swigt__p_p_CPLVirtualMemShadow = {"_p_p_CPLVirtualMemShadow", "CPLVirtualMemShadow **", 0, 0, (void*)0, 0};
7554 : static swig_type_info _swigt__p_p_void = {"_p_p_void", "void **", 0, 0, (void*)0, 0};
7555 : static swig_type_info _swigt__p_size_t = {"_p_size_t", "size_t *", 0, 0, (void*)0, 0};
7556 : static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0};
7557 :
7558 : static swig_type_info *swig_type_initial[] = {
7559 : &_swigt__p_ArrowArray,
7560 : &_swigt__p_ArrowSchema,
7561 : &_swigt__p_CPLVirtualMemShadow,
7562 : &_swigt__p_GDALDataType,
7563 : &_swigt__p_GDALDatasetShadow,
7564 : &_swigt__p_GDALExtendedDataTypeHS,
7565 : &_swigt__p_GDALMDArrayHS,
7566 : &_swigt__p_GDALProgressFunc,
7567 : &_swigt__p_GDALRasterAttributeTableShadow,
7568 : &_swigt__p_GDALRasterBandShadow,
7569 : &_swigt__p_GIntBig,
7570 : &_swigt__p_GUIntBig,
7571 : &_swigt__p_PyArrayObject,
7572 : &_swigt__p_char,
7573 : &_swigt__p_f_double_p_q_const__char_p_void__int,
7574 : &_swigt__p_int,
7575 : &_swigt__p_p_CPLVirtualMemShadow,
7576 : &_swigt__p_p_void,
7577 : &_swigt__p_size_t,
7578 : &_swigt__p_std__string,
7579 : };
7580 :
7581 : static swig_cast_info _swigc__p_ArrowArray[] = { {&_swigt__p_ArrowArray, 0, 0, 0},{0, 0, 0, 0}};
7582 : static swig_cast_info _swigc__p_ArrowSchema[] = { {&_swigt__p_ArrowSchema, 0, 0, 0},{0, 0, 0, 0}};
7583 : static swig_cast_info _swigc__p_CPLVirtualMemShadow[] = { {&_swigt__p_CPLVirtualMemShadow, 0, 0, 0},{0, 0, 0, 0}};
7584 : static swig_cast_info _swigc__p_GDALDataType[] = { {&_swigt__p_GDALDataType, 0, 0, 0},{0, 0, 0, 0}};
7585 : static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}};
7586 : static swig_cast_info _swigc__p_GDALExtendedDataTypeHS[] = { {&_swigt__p_GDALExtendedDataTypeHS, 0, 0, 0},{0, 0, 0, 0}};
7587 : static swig_cast_info _swigc__p_GDALMDArrayHS[] = { {&_swigt__p_GDALMDArrayHS, 0, 0, 0},{0, 0, 0, 0}};
7588 : static swig_cast_info _swigc__p_GDALProgressFunc[] = { {&_swigt__p_GDALProgressFunc, 0, 0, 0},{0, 0, 0, 0}};
7589 : static swig_cast_info _swigc__p_GDALRasterAttributeTableShadow[] = { {&_swigt__p_GDALRasterAttributeTableShadow, 0, 0, 0},{0, 0, 0, 0}};
7590 : static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}};
7591 : static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}};
7592 : static swig_cast_info _swigc__p_GUIntBig[] = { {&_swigt__p_GUIntBig, 0, 0, 0},{0, 0, 0, 0}};
7593 : static swig_cast_info _swigc__p_PyArrayObject[] = { {&_swigt__p_PyArrayObject, 0, 0, 0},{0, 0, 0, 0}};
7594 : static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
7595 : static swig_cast_info _swigc__p_f_double_p_q_const__char_p_void__int[] = { {&_swigt__p_f_double_p_q_const__char_p_void__int, 0, 0, 0},{0, 0, 0, 0}};
7596 : static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
7597 : static swig_cast_info _swigc__p_p_CPLVirtualMemShadow[] = { {&_swigt__p_p_CPLVirtualMemShadow, 0, 0, 0},{0, 0, 0, 0}};
7598 : static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}};
7599 : static swig_cast_info _swigc__p_size_t[] = { {&_swigt__p_size_t, 0, 0, 0},{0, 0, 0, 0}};
7600 : static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}};
7601 :
7602 : static swig_cast_info *swig_cast_initial[] = {
7603 : _swigc__p_ArrowArray,
7604 : _swigc__p_ArrowSchema,
7605 : _swigc__p_CPLVirtualMemShadow,
7606 : _swigc__p_GDALDataType,
7607 : _swigc__p_GDALDatasetShadow,
7608 : _swigc__p_GDALExtendedDataTypeHS,
7609 : _swigc__p_GDALMDArrayHS,
7610 : _swigc__p_GDALProgressFunc,
7611 : _swigc__p_GDALRasterAttributeTableShadow,
7612 : _swigc__p_GDALRasterBandShadow,
7613 : _swigc__p_GIntBig,
7614 : _swigc__p_GUIntBig,
7615 : _swigc__p_PyArrayObject,
7616 : _swigc__p_char,
7617 : _swigc__p_f_double_p_q_const__char_p_void__int,
7618 : _swigc__p_int,
7619 : _swigc__p_p_CPLVirtualMemShadow,
7620 : _swigc__p_p_void,
7621 : _swigc__p_size_t,
7622 : _swigc__p_std__string,
7623 : };
7624 :
7625 :
7626 : /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
7627 :
7628 : static swig_const_info swig_const_table[] = {
7629 : { SWIG_PY_POINTER, "TermProgress", 0, 0, (void *)((int (*)(double,char const *,void *))(GDALTermProgress)), &SWIGTYPE_p_f_double_p_q_const__char_p_void__int },
7630 : {0, 0, 0, 0.0, 0, 0}};
7631 :
7632 : #ifdef __cplusplus
7633 : }
7634 : #endif
7635 : /* -----------------------------------------------------------------------------
7636 : * Type initialization:
7637 : * This problem is tough by the requirement that no dynamic
7638 : * memory is used. Also, since swig_type_info structures store pointers to
7639 : * swig_cast_info structures and swig_cast_info structures store pointers back
7640 : * to swig_type_info structures, we need some lookup code at initialization.
7641 : * The idea is that swig generates all the structures that are needed.
7642 : * The runtime then collects these partially filled structures.
7643 : * The SWIG_InitializeModule function takes these initial arrays out of
7644 : * swig_module, and does all the lookup, filling in the swig_module.types
7645 : * array with the correct data and linking the correct swig_cast_info
7646 : * structures together.
7647 : *
7648 : * The generated swig_type_info structures are assigned statically to an initial
7649 : * array. We just loop through that array, and handle each type individually.
7650 : * First we lookup if this type has been already loaded, and if so, use the
7651 : * loaded structure instead of the generated one. Then we have to fill in the
7652 : * cast linked list. The cast data is initially stored in something like a
7653 : * two-dimensional array. Each row corresponds to a type (there are the same
7654 : * number of rows as there are in the swig_type_initial array). Each entry in
7655 : * a column is one of the swig_cast_info structures for that type.
7656 : * The cast_initial array is actually an array of arrays, because each row has
7657 : * a variable number of columns. So to actually build the cast linked list,
7658 : * we find the array of casts associated with the type, and loop through it
7659 : * adding the casts to the list. The one last trick we need to do is making
7660 : * sure the type pointer in the swig_cast_info struct is correct.
7661 : *
7662 : * First off, we lookup the cast->type name to see if it is already loaded.
7663 : * There are three cases to handle:
7664 : * 1) If the cast->type has already been loaded AND the type we are adding
7665 : * casting info to has not been loaded (it is in this module), THEN we
7666 : * replace the cast->type pointer with the type pointer that has already
7667 : * been loaded.
7668 : * 2) If BOTH types (the one we are adding casting info to, and the
7669 : * cast->type) are loaded, THEN the cast info has already been loaded by
7670 : * the previous module so we just ignore it.
7671 : * 3) Finally, if cast->type has not already been loaded, then we add that
7672 : * swig_cast_info to the linked list (because the cast->type) pointer will
7673 : * be correct.
7674 : * ----------------------------------------------------------------------------- */
7675 :
7676 : #ifdef __cplusplus
7677 : extern "C" {
7678 : #if 0
7679 : } /* c-mode */
7680 : #endif
7681 : #endif
7682 :
7683 : #if 0
7684 : #define SWIGRUNTIME_DEBUG
7685 : #endif
7686 :
7687 :
7688 : SWIGRUNTIME void
7689 : SWIG_InitializeModule(void *clientdata) {
7690 : size_t i;
7691 : swig_module_info *module_head, *iter;
7692 : int init;
7693 :
7694 : /* check to see if the circular list has been setup, if not, set it up */
7695 : if (swig_module.next==0) {
7696 : /* Initialize the swig_module */
7697 : swig_module.type_initial = swig_type_initial;
7698 : swig_module.cast_initial = swig_cast_initial;
7699 : swig_module.next = &swig_module;
7700 : init = 1;
7701 : } else {
7702 : init = 0;
7703 : }
7704 :
7705 : /* Try and load any already created modules */
7706 : module_head = SWIG_GetModule(clientdata);
7707 : if (!module_head) {
7708 : /* This is the first module loaded for this interpreter */
7709 : /* so set the swig module into the interpreter */
7710 : SWIG_SetModule(clientdata, &swig_module);
7711 : } else {
7712 : /* the interpreter has loaded a SWIG module, but has it loaded this one? */
7713 : iter=module_head;
7714 : do {
7715 : if (iter==&swig_module) {
7716 : /* Our module is already in the list, so there's nothing more to do. */
7717 : return;
7718 : }
7719 : iter=iter->next;
7720 : } while (iter!= module_head);
7721 :
7722 : /* otherwise we must add our module into the list */
7723 : swig_module.next = module_head->next;
7724 : module_head->next = &swig_module;
7725 : }
7726 :
7727 : /* When multiple interpreters are used, a module could have already been initialized in
7728 : a different interpreter, but not yet have a pointer in this interpreter.
7729 : In this case, we do not want to continue adding types... everything should be
7730 : set up already */
7731 : if (init == 0) return;
7732 :
7733 : /* Now work on filling in swig_module.types */
7734 : #ifdef SWIGRUNTIME_DEBUG
7735 : printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size);
7736 : #endif
7737 : for (i = 0; i < swig_module.size; ++i) {
7738 : swig_type_info *type = 0;
7739 : swig_type_info *ret;
7740 : swig_cast_info *cast;
7741 :
7742 : #ifdef SWIGRUNTIME_DEBUG
7743 : printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
7744 : #endif
7745 :
7746 : /* if there is another module already loaded */
7747 : if (swig_module.next != &swig_module) {
7748 : type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
7749 : }
7750 : if (type) {
7751 : /* Overwrite clientdata field */
7752 : #ifdef SWIGRUNTIME_DEBUG
7753 : printf("SWIG_InitializeModule: found type %s\n", type->name);
7754 : #endif
7755 : if (swig_module.type_initial[i]->clientdata) {
7756 : type->clientdata = swig_module.type_initial[i]->clientdata;
7757 : #ifdef SWIGRUNTIME_DEBUG
7758 : printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
7759 : #endif
7760 : }
7761 : } else {
7762 : type = swig_module.type_initial[i];
7763 : }
7764 :
7765 : /* Insert casting types */
7766 : cast = swig_module.cast_initial[i];
7767 : while (cast->type) {
7768 : /* Don't need to add information already in the list */
7769 : ret = 0;
7770 : #ifdef SWIGRUNTIME_DEBUG
7771 : printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
7772 : #endif
7773 : if (swig_module.next != &swig_module) {
7774 : ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
7775 : #ifdef SWIGRUNTIME_DEBUG
7776 : if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
7777 : #endif
7778 : }
7779 : if (ret) {
7780 : if (type == swig_module.type_initial[i]) {
7781 : #ifdef SWIGRUNTIME_DEBUG
7782 : printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
7783 : #endif
7784 : cast->type = ret;
7785 : ret = 0;
7786 : } else {
7787 : /* Check for casting already in the list */
7788 : swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
7789 : #ifdef SWIGRUNTIME_DEBUG
7790 : if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
7791 : #endif
7792 : if (!ocast) ret = 0;
7793 : }
7794 : }
7795 :
7796 : if (!ret) {
7797 : #ifdef SWIGRUNTIME_DEBUG
7798 : printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
7799 : #endif
7800 : if (type->cast) {
7801 : type->cast->prev = cast;
7802 : cast->next = type->cast;
7803 : }
7804 : type->cast = cast;
7805 : }
7806 : cast++;
7807 : }
7808 : /* Set entry in modules->types array equal to the type */
7809 : swig_module.types[i] = type;
7810 : }
7811 : swig_module.types[i] = 0;
7812 :
7813 : #ifdef SWIGRUNTIME_DEBUG
7814 : printf("**** SWIG_InitializeModule: Cast List ******\n");
7815 : for (i = 0; i < swig_module.size; ++i) {
7816 : int j = 0;
7817 : swig_cast_info *cast = swig_module.cast_initial[i];
7818 : printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
7819 : while (cast->type) {
7820 : printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
7821 : cast++;
7822 : ++j;
7823 : }
7824 : printf("---- Total casts: %d\n",j);
7825 : }
7826 : printf("**** SWIG_InitializeModule: Cast List ******\n");
7827 : #endif
7828 : }
7829 :
7830 : /* This function will propagate the clientdata field of type to
7831 : * any new swig_type_info structures that have been added into the list
7832 : * of equivalent types. It is like calling
7833 : * SWIG_TypeClientData(type, clientdata) a second time.
7834 : */
7835 : SWIGRUNTIME void
7836 : SWIG_PropagateClientData(void) {
7837 : size_t i;
7838 : swig_cast_info *equiv;
7839 : static int init_run = 0;
7840 :
7841 : if (init_run) return;
7842 : init_run = 1;
7843 :
7844 : for (i = 0; i < swig_module.size; i++) {
7845 : if (swig_module.types[i]->clientdata) {
7846 : equiv = swig_module.types[i]->cast;
7847 : while (equiv) {
7848 : if (!equiv->converter) {
7849 : if (equiv->type && !equiv->type->clientdata)
7850 : SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
7851 : }
7852 : equiv = equiv->next;
7853 : }
7854 : }
7855 : }
7856 : }
7857 :
7858 : #ifdef __cplusplus
7859 : #if 0
7860 : {
7861 : /* c-mode */
7862 : #endif
7863 : }
7864 : #endif
7865 :
7866 :
7867 :
7868 : #ifdef __cplusplus
7869 : extern "C" {
7870 : #endif
7871 :
7872 : /* Python-specific SWIG API */
7873 : #define SWIG_newvarlink() SWIG_Python_newvarlink()
7874 : #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
7875 : #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
7876 :
7877 : /* -----------------------------------------------------------------------------
7878 : * global variable support code.
7879 : * ----------------------------------------------------------------------------- */
7880 :
7881 : typedef struct swig_globalvar {
7882 : char *name; /* Name of global variable */
7883 : PyObject *(*get_attr)(void); /* Return the current value */
7884 : int (*set_attr)(PyObject *); /* Set the value */
7885 : struct swig_globalvar *next;
7886 : } swig_globalvar;
7887 :
7888 : typedef struct swig_varlinkobject {
7889 : PyObject_HEAD
7890 : swig_globalvar *vars;
7891 : } swig_varlinkobject;
7892 :
7893 : SWIGINTERN PyObject *
7894 : swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
7895 : #if PY_VERSION_HEX >= 0x03000000
7896 : return PyUnicode_InternFromString("<Swig global variables>");
7897 : #else
7898 : return PyString_FromString("<Swig global variables>");
7899 : #endif
7900 : }
7901 :
7902 : SWIGINTERN PyObject *
7903 : swig_varlink_str(swig_varlinkobject *v) {
7904 : #if PY_VERSION_HEX >= 0x03000000
7905 : PyObject *str = PyUnicode_InternFromString("(");
7906 : PyObject *tail;
7907 : PyObject *joined;
7908 : swig_globalvar *var;
7909 : for (var = v->vars; var; var=var->next) {
7910 : tail = PyUnicode_FromString(var->name);
7911 : joined = PyUnicode_Concat(str, tail);
7912 : Py_DecRef(str);
7913 : Py_DecRef(tail);
7914 : str = joined;
7915 : if (var->next) {
7916 : tail = PyUnicode_InternFromString(", ");
7917 : joined = PyUnicode_Concat(str, tail);
7918 : Py_DecRef(str);
7919 : Py_DecRef(tail);
7920 : str = joined;
7921 : }
7922 : }
7923 : tail = PyUnicode_InternFromString(")");
7924 : joined = PyUnicode_Concat(str, tail);
7925 : Py_DecRef(str);
7926 : Py_DecRef(tail);
7927 : str = joined;
7928 : #else
7929 : PyObject *str = PyString_FromString("(");
7930 : swig_globalvar *var;
7931 : for (var = v->vars; var; var=var->next) {
7932 : PyString_ConcatAndDel(&str,PyString_FromString(var->name));
7933 : if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
7934 : }
7935 : PyString_ConcatAndDel(&str,PyString_FromString(")"));
7936 : #endif
7937 : return str;
7938 : }
7939 :
7940 : SWIGINTERN void
7941 : swig_varlink_dealloc(swig_varlinkobject *v) {
7942 : swig_globalvar *var = v->vars;
7943 : while (var) {
7944 : swig_globalvar *n = var->next;
7945 : free(var->name);
7946 : free(var);
7947 : var = n;
7948 : }
7949 : }
7950 :
7951 : SWIGINTERN PyObject *
7952 : swig_varlink_getattr(swig_varlinkobject *v, char *n) {
7953 : PyObject *res = NULL;
7954 : swig_globalvar *var = v->vars;
7955 : while (var) {
7956 : if (strcmp(var->name,n) == 0) {
7957 : res = (*var->get_attr)();
7958 : break;
7959 : }
7960 : var = var->next;
7961 : }
7962 : if (res == NULL && !PyErr_Occurred()) {
7963 : PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
7964 : }
7965 : return res;
7966 : }
7967 :
7968 : SWIGINTERN int
7969 : swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
7970 : int res = 1;
7971 : swig_globalvar *var = v->vars;
7972 : while (var) {
7973 : if (strcmp(var->name,n) == 0) {
7974 : res = (*var->set_attr)(p);
7975 : break;
7976 : }
7977 : var = var->next;
7978 : }
7979 : if (res == 1 && !PyErr_Occurred()) {
7980 : PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
7981 : }
7982 : return res;
7983 : }
7984 :
7985 : SWIGINTERN PyTypeObject*
7986 : swig_varlink_type(void) {
7987 : static char varlink__doc__[] = "Swig var link object";
7988 : static PyTypeObject varlink_type;
7989 : static int type_init = 0;
7990 : if (!type_init) {
7991 : const PyTypeObject tmp = {
7992 : #if PY_VERSION_HEX >= 0x03000000
7993 : PyVarObject_HEAD_INIT(NULL, 0)
7994 : #else
7995 : PyObject_HEAD_INIT(NULL)
7996 : 0, /* ob_size */
7997 : #endif
7998 : "swigvarlink", /* tp_name */
7999 : sizeof(swig_varlinkobject), /* tp_basicsize */
8000 : 0, /* tp_itemsize */
8001 : (destructor) swig_varlink_dealloc, /* tp_dealloc */
8002 : 0, /* tp_print */
8003 : (getattrfunc) swig_varlink_getattr, /* tp_getattr */
8004 : (setattrfunc) swig_varlink_setattr, /* tp_setattr */
8005 : 0, /* tp_compare */
8006 : (reprfunc) swig_varlink_repr, /* tp_repr */
8007 : 0, /* tp_as_number */
8008 : 0, /* tp_as_sequence */
8009 : 0, /* tp_as_mapping */
8010 : 0, /* tp_hash */
8011 : 0, /* tp_call */
8012 : (reprfunc) swig_varlink_str, /* tp_str */
8013 : 0, /* tp_getattro */
8014 : 0, /* tp_setattro */
8015 : 0, /* tp_as_buffer */
8016 : 0, /* tp_flags */
8017 : varlink__doc__, /* tp_doc */
8018 : 0, /* tp_traverse */
8019 : 0, /* tp_clear */
8020 : 0, /* tp_richcompare */
8021 : 0, /* tp_weaklistoffset */
8022 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
8023 : 0, /* tp_del */
8024 : 0, /* tp_version_tag */
8025 : #if PY_VERSION_HEX >= 0x03040000
8026 : 0, /* tp_finalize */
8027 : #endif
8028 : #ifdef COUNT_ALLOCS
8029 : 0, /* tp_allocs */
8030 : 0, /* tp_frees */
8031 : 0, /* tp_maxalloc */
8032 : 0, /* tp_prev */
8033 : 0 /* tp_next */
8034 : #endif
8035 : };
8036 : varlink_type = tmp;
8037 : type_init = 1;
8038 : if (PyType_Ready(&varlink_type) < 0)
8039 : return NULL;
8040 : }
8041 : return &varlink_type;
8042 : }
8043 :
8044 : /* Create a variable linking object for use later */
8045 : SWIGINTERN PyObject *
8046 : SWIG_Python_newvarlink(void) {
8047 : swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
8048 : if (result) {
8049 : result->vars = 0;
8050 : }
8051 : return ((PyObject*) result);
8052 : }
8053 :
8054 : SWIGINTERN void
8055 : SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
8056 : swig_varlinkobject *v = (swig_varlinkobject *) p;
8057 : swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
8058 : if (gv) {
8059 : size_t size = strlen(name)+1;
8060 : gv->name = (char *)malloc(size);
8061 : if (gv->name) {
8062 : memcpy(gv->name, name, size);
8063 : gv->get_attr = get_attr;
8064 : gv->set_attr = set_attr;
8065 : gv->next = v->vars;
8066 : }
8067 : }
8068 : v->vars = gv;
8069 : }
8070 :
8071 : SWIGINTERN PyObject *
8072 : SWIG_globals(void) {
8073 : static PyObject *globals = 0;
8074 : if (!globals) {
8075 : globals = SWIG_newvarlink();
8076 : }
8077 : return globals;
8078 : }
8079 :
8080 : /* -----------------------------------------------------------------------------
8081 : * constants/methods manipulation
8082 : * ----------------------------------------------------------------------------- */
8083 :
8084 : /* Install Constants */
8085 : SWIGINTERN void
8086 225 : SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
8087 225 : PyObject *obj = 0;
8088 225 : size_t i;
8089 450 : for (i = 0; constants[i].type; ++i) {
8090 225 : switch(constants[i].type) {
8091 225 : case SWIG_PY_POINTER:
8092 225 : obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
8093 225 : break;
8094 0 : case SWIG_PY_BINARY:
8095 0 : obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
8096 : break;
8097 : default:
8098 : obj = 0;
8099 : break;
8100 : }
8101 225 : if (obj) {
8102 225 : PyDict_SetItemString(d, constants[i].name, obj);
8103 225 : Py_DECREF(obj);
8104 : }
8105 : }
8106 225 : }
8107 :
8108 : /* -----------------------------------------------------------------------------*/
8109 : /* Fix SwigMethods to carry the callback ptrs when needed */
8110 : /* -----------------------------------------------------------------------------*/
8111 :
8112 : SWIGINTERN void
8113 225 : SWIG_Python_FixMethods(PyMethodDef *methods,
8114 : swig_const_info *const_table,
8115 : swig_type_info **types,
8116 : swig_type_info **types_initial) {
8117 225 : size_t i;
8118 5400 : for (i = 0; methods[i].ml_name; ++i) {
8119 5175 : const char *c = methods[i].ml_doc;
8120 5175 : if (!c) continue;
8121 4725 : c = strstr(c, "swig_ptr: ");
8122 4725 : if (c) {
8123 0 : int j;
8124 0 : swig_const_info *ci = 0;
8125 0 : const char *name = c + 10;
8126 0 : for (j = 0; const_table[j].type; ++j) {
8127 0 : if (strncmp(const_table[j].name, name,
8128 : strlen(const_table[j].name)) == 0) {
8129 : ci = &(const_table[j]);
8130 : break;
8131 : }
8132 : }
8133 0 : if (ci) {
8134 5175 : void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
8135 0 : if (ptr) {
8136 0 : size_t shift = (ci->ptype) - types;
8137 0 : swig_type_info *ty = types_initial[shift];
8138 0 : size_t ldoc = (c - methods[i].ml_doc);
8139 0 : size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
8140 0 : char *ndoc = (char*)malloc(ldoc + lptr + 10);
8141 0 : if (ndoc) {
8142 0 : char *buff = ndoc;
8143 0 : memcpy(buff, methods[i].ml_doc, ldoc);
8144 0 : buff += ldoc;
8145 0 : memcpy(buff, "swig_ptr: ", 10);
8146 0 : buff += 10;
8147 0 : SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
8148 0 : methods[i].ml_doc = ndoc;
8149 : }
8150 : }
8151 : }
8152 : }
8153 : }
8154 225 : }
8155 :
8156 : /* -----------------------------------------------------------------------------
8157 : * Method creation and docstring support functions
8158 : * ----------------------------------------------------------------------------- */
8159 :
8160 : /* -----------------------------------------------------------------------------
8161 : * Function to find the method definition with the correct docstring for the
8162 : * proxy module as opposed to the low-level API
8163 : * ----------------------------------------------------------------------------- */
8164 :
8165 0 : SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) {
8166 : /* Find the function in the modified method table */
8167 0 : size_t offset = 0;
8168 0 : int found = 0;
8169 0 : while (SwigMethods_proxydocs[offset].ml_meth != NULL) {
8170 0 : if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {
8171 : found = 1;
8172 : break;
8173 : }
8174 0 : offset++;
8175 : }
8176 : /* Use the copy with the modified docstring if available */
8177 0 : return found ? &SwigMethods_proxydocs[offset] : NULL;
8178 : }
8179 :
8180 : /* -----------------------------------------------------------------------------
8181 : * Wrapper of PyInstanceMethod_New() used in Python 3
8182 : * It is exported to the generated module, used for -fastproxy
8183 : * ----------------------------------------------------------------------------- */
8184 :
8185 0 : SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
8186 0 : if (PyCFunction_Check(func)) {
8187 0 : PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
8188 0 : PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
8189 0 : if (ml)
8190 0 : func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
8191 : }
8192 : #if PY_VERSION_HEX >= 0x03000000
8193 0 : return PyInstanceMethod_New(func);
8194 : #else
8195 : return PyMethod_New(func, NULL, NULL);
8196 : #endif
8197 : }
8198 :
8199 : /* -----------------------------------------------------------------------------
8200 : * Wrapper of PyStaticMethod_New()
8201 : * It is exported to the generated module, used for -fastproxy
8202 : * ----------------------------------------------------------------------------- */
8203 :
8204 : SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
8205 : if (PyCFunction_Check(func)) {
8206 : PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
8207 : PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
8208 : if (ml)
8209 : func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
8210 : }
8211 : return PyStaticMethod_New(func);
8212 : }
8213 :
8214 : #ifdef __cplusplus
8215 : }
8216 : #endif
8217 :
8218 : /* -----------------------------------------------------------------------------*
8219 : * Partial Init method
8220 : * -----------------------------------------------------------------------------*/
8221 :
8222 : #ifdef __cplusplus
8223 : extern "C"
8224 : #endif
8225 :
8226 : SWIGEXPORT
8227 : #if PY_VERSION_HEX >= 0x03000000
8228 : PyObject*
8229 : #else
8230 : void
8231 : #endif
8232 225 : SWIG_init(void) {
8233 225 : PyObject *m, *d, *md, *globals;
8234 :
8235 : #if PY_VERSION_HEX >= 0x03000000
8236 225 : static struct PyModuleDef SWIG_module = {
8237 : PyModuleDef_HEAD_INIT,
8238 : SWIG_name,
8239 : NULL,
8240 : -1,
8241 : SwigMethods,
8242 : NULL,
8243 : NULL,
8244 : NULL,
8245 : NULL
8246 : };
8247 : #endif
8248 :
8249 : #if defined(SWIGPYTHON_BUILTIN)
8250 : static SwigPyClientData SwigPyObject_clientdata = {
8251 : 0, 0, 0, 0, 0, 0, 0
8252 : };
8253 : static PyGetSetDef this_getset_def = {
8254 : (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
8255 : };
8256 : static SwigPyGetSet thisown_getset_closure = {
8257 : SwigPyObject_own,
8258 : SwigPyObject_own
8259 : };
8260 : static PyGetSetDef thisown_getset_def = {
8261 : (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
8262 : };
8263 : PyTypeObject *builtin_pytype;
8264 : int builtin_base_count;
8265 : swig_type_info *builtin_basetype;
8266 : PyObject *tuple;
8267 : PyGetSetDescrObject *static_getset;
8268 : PyTypeObject *metatype;
8269 : PyTypeObject *swigpyobject;
8270 : SwigPyClientData *cd;
8271 : PyObject *public_interface, *public_symbol;
8272 : PyObject *this_descr;
8273 : PyObject *thisown_descr;
8274 : PyObject *self = 0;
8275 : int i;
8276 :
8277 : (void)builtin_pytype;
8278 : (void)builtin_base_count;
8279 : (void)builtin_basetype;
8280 : (void)tuple;
8281 : (void)static_getset;
8282 : (void)self;
8283 :
8284 : /* Metaclass is used to implement static member variables */
8285 : metatype = SwigPyObjectType();
8286 : assert(metatype);
8287 : #endif
8288 :
8289 225 : (void)globals;
8290 :
8291 : /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */
8292 225 : SWIG_This();
8293 225 : SWIG_Python_TypeCache();
8294 225 : SwigPyPacked_type();
8295 : #ifndef SWIGPYTHON_BUILTIN
8296 225 : SwigPyObject_type();
8297 : #endif
8298 :
8299 : /* Fix SwigMethods to carry the callback ptrs when needed */
8300 225 : SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
8301 :
8302 : #if PY_VERSION_HEX >= 0x03000000
8303 225 : m = PyModule_Create(&SWIG_module);
8304 : #else
8305 : m = Py_InitModule(SWIG_name, SwigMethods);
8306 : #endif
8307 :
8308 225 : md = d = PyModule_GetDict(m);
8309 225 : (void)md;
8310 :
8311 225 : SWIG_InitializeModule(0);
8312 :
8313 : #ifdef SWIGPYTHON_BUILTIN
8314 : swigpyobject = SwigPyObject_TypeOnce();
8315 :
8316 : SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
8317 : assert(SwigPyObject_stype);
8318 : cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
8319 : if (!cd) {
8320 : SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
8321 : SwigPyObject_clientdata.pytype = swigpyobject;
8322 : } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) {
8323 : PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
8324 : # if PY_VERSION_HEX >= 0x03000000
8325 : return NULL;
8326 : # else
8327 : return;
8328 : # endif
8329 : }
8330 :
8331 : /* All objects have a 'this' attribute */
8332 : this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
8333 : (void)this_descr;
8334 :
8335 : /* All objects have a 'thisown' attribute */
8336 : thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
8337 : (void)thisown_descr;
8338 :
8339 : public_interface = PyList_New(0);
8340 : public_symbol = 0;
8341 : (void)public_symbol;
8342 :
8343 : PyDict_SetItemString(md, "__all__", public_interface);
8344 : Py_DECREF(public_interface);
8345 : for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
8346 : SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
8347 : for (i = 0; swig_const_table[i].name != 0; ++i)
8348 : SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
8349 : #endif
8350 :
8351 225 : SWIG_InstallConstants(d,swig_const_table);
8352 :
8353 :
8354 225 : import_array();
8355 225 : PyDateTime_IMPORT;
8356 225 : GDALRegister_NUMPY();
8357 :
8358 :
8359 :
8360 : /* Initialize threading */
8361 225 : SWIG_PYTHON_INITIALIZE_THREADS;
8362 : #if PY_VERSION_HEX >= 0x03000000
8363 225 : return m;
8364 : #else
8365 : return;
8366 : #endif
8367 : }
8368 :
|