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 4032 : SWIG_TypeCheck(const char *c, swig_type_info *ty) {
449 4032 : if (ty) {
450 4032 : swig_cast_info *iter = ty->cast;
451 4480 : while (iter) {
452 4480 : if (strcmp(iter->type->name, c) == 0) {
453 4032 : if (iter == ty->cast)
454 : return iter;
455 : /* Move iter to the top of the linked list */
456 448 : iter->prev->next = iter->next;
457 448 : if (iter->next)
458 0 : iter->next->prev = iter->prev;
459 448 : iter->next = ty->cast;
460 448 : iter->prev = 0;
461 448 : if (ty->cast) ty->cast->prev = iter;
462 448 : ty->cast = iter;
463 448 : return iter;
464 : }
465 448 : 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 224 : SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
571 224 : SWIG_TypeClientData(ti, clientdata);
572 224 : 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 9632 : SWIG_MangledTypeQueryModule(swig_module_info *start,
585 : swig_module_info *end,
586 : const char *name) {
587 9632 : swig_module_info *iter = start;
588 29568 : do {
589 29568 : if (iter->size) {
590 29568 : size_t l = 0;
591 29568 : size_t r = iter->size - 1;
592 116256 : do {
593 : /* since l+r >= 0, we can (>> 1) instead (/ 2) */
594 116256 : size_t i = (l + r) >> 1;
595 116256 : const char *iname = iter->types[i]->name;
596 116256 : if (iname) {
597 116256 : int compare = strcmp(name, iname);
598 116256 : if (compare == 0) {
599 7840 : return iter->types[i];
600 108416 : } else if (compare < 0) {
601 60928 : if (i) {
602 50624 : r = i - 1;
603 : } else {
604 : break;
605 : }
606 47488 : } else if (compare > 0) {
607 47488 : l = i + 1;
608 : }
609 : } else {
610 : break; /* should never happen */
611 : }
612 98112 : } while (l <= r);
613 : }
614 21728 : iter = iter->next;
615 21728 : } 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 224 : SWIG_Python_str_FromChar(const char *c)
839 : {
840 : #if PY_VERSION_HEX >= 0x03000000
841 224 : 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 32 : SWIG_Python_ErrorType(int code) {
868 32 : 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 26 : case SWIG_RuntimeError:
877 26 : 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 26 : 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 950 : void end() { if (status) { PyGILState_Release(state); status = false;} }
986 686 : 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 84352 : void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
994 84352 : 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 32 : SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
1143 32 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1144 32 : PyErr_SetString(errtype, msg);
1145 32 : SWIG_PYTHON_THREAD_END_BLOCK;
1146 32 : }
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 840 : SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
1204 : {
1205 840 : if (!args) {
1206 33 : 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 807 : if (!PyTuple_Check(args)) {
1215 224 : if (min <= 1 && max >= 1) {
1216 224 : Py_ssize_t i;
1217 224 : objs[0] = args;
1218 224 : 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 583 : Py_ssize_t l = PyTuple_GET_SIZE(args);
1227 583 : 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 583 : } 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 2536 : for (i = 0; i < l; ++i) {
1238 1953 : objs[i] = PyTuple_GET_ITEM(args, i);
1239 : }
1240 583 : for (; l < max; ++l) {
1241 0 : objs[l] = 0;
1242 : }
1243 583 : 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 23026 : SWIG_Py_Void(void)
1282 : {
1283 23026 : PyObject *none = Py_None;
1284 0 : Py_INCREF(none);
1285 229 : 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 224 : SwigPyClientData_New(PyObject* obj)
1320 : {
1321 224 : if (!obj) {
1322 : return 0;
1323 : } else {
1324 224 : SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
1325 : /* the klass element */
1326 224 : data->klass = obj;
1327 224 : Py_INCREF(data->klass);
1328 : /* the newraw method and newargs arguments used to create a new raw instance */
1329 224 : if (PyClass_Check(obj)) {
1330 224 : data->newraw = 0;
1331 224 : data->newargs = obj;
1332 224 : 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 224 : data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
1346 224 : if (PyErr_Occurred()) {
1347 0 : PyErr_Clear();
1348 0 : data->destroy = 0;
1349 : }
1350 224 : if (data->destroy) {
1351 224 : int flags;
1352 224 : Py_INCREF(data->destroy);
1353 224 : flags = PyCFunction_GET_FLAGS(data->destroy);
1354 224 : data->delargs = !(flags & (METH_O));
1355 : } else {
1356 0 : data->delargs = 0;
1357 : }
1358 224 : data->implicitconv = 0;
1359 224 : data->pytype = 0;
1360 224 : 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 39943 : SwigPyObject_type(void) {
1506 39943 : static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
1507 39943 : 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 47 : SwigPyObject_dealloc(PyObject *v)
1529 : {
1530 47 : SwigPyObject *sobj = (SwigPyObject *) v;
1531 47 : PyObject *next = sobj->next;
1532 47 : if (sobj->own == SWIG_POINTER_OWN) {
1533 46 : swig_type_info *ty = sobj->ty;
1534 46 : SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
1535 46 : PyObject *destroy = data ? data->destroy : 0;
1536 46 : if (destroy) {
1537 : /* destroy is always a VARARGS method */
1538 46 : 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 46 : PyObject *type = NULL, *value = NULL, *traceback = NULL;
1548 46 : PyErr_Fetch(&type, &value, &traceback);
1549 :
1550 46 : 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 46 : PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
1557 46 : PyObject *mself = PyCFunction_GET_SELF(destroy);
1558 46 : res = ((*meth)(mself, v));
1559 : }
1560 46 : if (!res)
1561 0 : PyErr_WriteUnraisable(destroy);
1562 :
1563 46 : PyErr_Restore(type, value, traceback);
1564 :
1565 92 : 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 47 : Py_XDECREF(next);
1575 47 : PyObject_DEL(v);
1576 47 : }
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 224 : SwigPyObject_TypeOnce(void) {
1652 224 : static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
1653 :
1654 224 : 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 224 : static PyTypeObject swigpyobject_type;
1699 224 : static int type_init = 0;
1700 224 : if (!type_init) {
1701 224 : 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 224 : swigpyobject_type = tmp;
1770 224 : type_init = 1;
1771 224 : if (PyType_Ready(&swigpyobject_type) < 0)
1772 0 : return NULL;
1773 : }
1774 : return &swigpyobject_type;
1775 : }
1776 :
1777 : SWIGRUNTIME PyObject *
1778 270 : SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
1779 : {
1780 270 : SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
1781 270 : if (sobj) {
1782 270 : sobj->ptr = ptr;
1783 270 : sobj->ty = ty;
1784 270 : sobj->own = own;
1785 270 : sobj->next = 0;
1786 : }
1787 270 : 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 224 : SwigPyPacked_type(void) {
1836 224 : static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
1837 224 : 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 224 : SwigPyPacked_TypeOnce(void) {
1858 224 : static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
1859 224 : static PyTypeObject swigpypacked_type;
1860 224 : static int type_init = 0;
1861 224 : if (!type_init) {
1862 224 : 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 224 : swigpypacked_type = tmp;
1931 224 : type_init = 1;
1932 224 : 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 19803 : SWIG_This(void)
1978 : {
1979 19803 : if (Swig_This_global == NULL)
1980 224 : Swig_This_global = SWIG_Python_str_FromChar("this");
1981 19803 : 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 19607 : SWIG_Python_GetSwigThis(PyObject *pyobj)
1993 : {
1994 19607 : PyObject *obj;
1995 :
1996 19607 : 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 19579 : 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 19579 : obj = PyObject_GetAttr(pyobj,SWIG_This());
2039 19579 : if (obj) {
2040 19572 : Py_DECREF(obj);
2041 : } else {
2042 7 : if (PyErr_Occurred()) PyErr_Clear();
2043 7 : return 0;
2044 : }
2045 : #endif
2046 19572 : 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 19607 : SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
2074 19607 : int res;
2075 19607 : SwigPyObject *sobj;
2076 19607 : int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
2077 :
2078 19607 : if (!obj)
2079 : return SWIG_ERROR;
2080 19607 : 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 19607 : res = SWIG_ERROR;
2087 :
2088 19607 : sobj = SWIG_Python_GetSwigThis(obj);
2089 19607 : if (own)
2090 0 : *own = 0;
2091 19607 : while (sobj) {
2092 19600 : void *vptr = sobj->ptr;
2093 19600 : if (ty) {
2094 19600 : swig_type_info *to = sobj->ty;
2095 19600 : if (to == ty) {
2096 : /* no type cast needed */
2097 19600 : 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 19607 : if (sobj) {
2122 19600 : if (own)
2123 0 : *own = *own | sobj->own;
2124 19600 : 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 275 : SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
2321 275 : SwigPyClientData *clientdata;
2322 275 : PyObject * robj;
2323 275 : int own;
2324 :
2325 275 : if (!ptr)
2326 5 : return SWIG_Py_Void();
2327 :
2328 270 : clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
2329 270 : own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2330 270 : 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 270 : assert(!(flags & SWIG_BUILTIN_TP_INIT));
2361 :
2362 270 : robj = SwigPyObject_New(ptr, type, own);
2363 270 : if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2364 46 : PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2365 46 : 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 224 : SWIG_Python_TypeCache(void) {
2441 224 : static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
2442 224 : 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_GDALComputedRasterBandShadow swig_types[3]
2669 : #define SWIGTYPE_p_GDALDataType swig_types[4]
2670 : #define SWIGTYPE_p_GDALDatasetShadow swig_types[5]
2671 : #define SWIGTYPE_p_GDALExtendedDataTypeHS swig_types[6]
2672 : #define SWIGTYPE_p_GDALMDArrayHS swig_types[7]
2673 : #define SWIGTYPE_p_GDALProgressFunc swig_types[8]
2674 : #define SWIGTYPE_p_GDALRasterAttributeTableShadow swig_types[9]
2675 : #define SWIGTYPE_p_GDALRasterBandShadow swig_types[10]
2676 : #define SWIGTYPE_p_GIntBig swig_types[11]
2677 : #define SWIGTYPE_p_GUIntBig swig_types[12]
2678 : #define SWIGTYPE_p_PyArrayObject swig_types[13]
2679 : #define SWIGTYPE_p_char swig_types[14]
2680 : #define SWIGTYPE_p_f_double_p_q_const__char_p_void__int swig_types[15]
2681 : #define SWIGTYPE_p_int swig_types[16]
2682 : #define SWIGTYPE_p_p_CPLVirtualMemShadow swig_types[17]
2683 : #define SWIGTYPE_p_p_void swig_types[18]
2684 : #define SWIGTYPE_p_size_t swig_types[19]
2685 : #define SWIGTYPE_p_std__string swig_types[20]
2686 : static swig_type_info *swig_types[22];
2687 : static swig_module_info swig_module = {swig_types, 21, 0, 0, 0, 0};
2688 : #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
2689 : #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
2690 :
2691 : /* -------- TYPES TABLE (END) -------- */
2692 :
2693 : #ifdef SWIG_TypeQuery
2694 : # undef SWIG_TypeQuery
2695 : #endif
2696 : #define SWIG_TypeQuery SWIG_Python_TypeQuery
2697 :
2698 : /*-----------------------------------------------
2699 : @(target):= _gdal_array.so
2700 : ------------------------------------------------*/
2701 : #if PY_VERSION_HEX >= 0x03000000
2702 : # define SWIG_init PyInit__gdal_array
2703 :
2704 : #else
2705 : # define SWIG_init init_gdal_array
2706 :
2707 : #endif
2708 : #define SWIG_name "_gdal_array"
2709 :
2710 : #define SWIGVERSION 0x040001
2711 : #define SWIG_VERSION SWIGVERSION
2712 :
2713 :
2714 : #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
2715 : #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
2716 :
2717 :
2718 : #include <stdexcept>
2719 :
2720 :
2721 : namespace swig {
2722 : class SwigPtr_PyObject {
2723 : protected:
2724 : PyObject *_obj;
2725 :
2726 : public:
2727 : SwigPtr_PyObject() :_obj(0)
2728 : {
2729 : }
2730 :
2731 : SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
2732 : {
2733 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2734 : Py_XINCREF(_obj);
2735 : SWIG_PYTHON_THREAD_END_BLOCK;
2736 : }
2737 :
2738 : SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
2739 : {
2740 : if (initial_ref) {
2741 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2742 : Py_XINCREF(_obj);
2743 : SWIG_PYTHON_THREAD_END_BLOCK;
2744 : }
2745 : }
2746 :
2747 : SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
2748 : {
2749 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2750 : Py_XINCREF(item._obj);
2751 : Py_XDECREF(_obj);
2752 : _obj = item._obj;
2753 : SWIG_PYTHON_THREAD_END_BLOCK;
2754 : return *this;
2755 : }
2756 :
2757 : ~SwigPtr_PyObject()
2758 : {
2759 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
2760 : Py_XDECREF(_obj);
2761 : SWIG_PYTHON_THREAD_END_BLOCK;
2762 : }
2763 :
2764 : operator PyObject *() const
2765 : {
2766 : return _obj;
2767 : }
2768 :
2769 : PyObject *operator->() const
2770 : {
2771 : return _obj;
2772 : }
2773 : };
2774 : }
2775 :
2776 :
2777 : namespace swig {
2778 : struct SwigVar_PyObject : SwigPtr_PyObject {
2779 : SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
2780 :
2781 : SwigVar_PyObject & operator = (PyObject* obj)
2782 : {
2783 : Py_XDECREF(_obj);
2784 : _obj = obj;
2785 : return *this;
2786 : }
2787 : };
2788 : }
2789 :
2790 :
2791 : #include "gdal.h"
2792 :
2793 : typedef struct
2794 : {
2795 : CPLVirtualMem *vmem;
2796 : int bAuto;
2797 : GDALDataType eBufType;
2798 : int bIsBandSequential;
2799 : int bReadOnly;
2800 : int nBufXSize;
2801 : int nBufYSize;
2802 : int nBandCount;
2803 : GDALTileOrganization eTileOrganization;
2804 : int nTileXSize;
2805 : int nTileYSize;
2806 : int nPixelSpace; /* if bAuto == TRUE */
2807 : GIntBig nLineSpace; /* if bAuto == TRUE */
2808 : } CPLVirtualMemShadow;
2809 :
2810 :
2811 28 : SWIGINTERN void delete_CPLVirtualMemShadow(CPLVirtualMemShadow *self){
2812 28 : CPLVirtualMemFree( self->vmem );
2813 28 : free(self);
2814 : }
2815 0 : SWIGINTERN void CPLVirtualMemShadow_GetAddr(CPLVirtualMemShadow *self,void **pptr,size_t *pnsize,GDALDataType *pdatatype,int *preadonly){
2816 0 : *pptr = CPLVirtualMemGetAddr( self->vmem );
2817 0 : *pnsize = CPLVirtualMemGetSize( self->vmem );
2818 0 : *pdatatype = self->eBufType;
2819 0 : *preadonly = self->bReadOnly;
2820 : }
2821 :
2822 : SWIGINTERN int
2823 77340 : SWIG_AsVal_double (PyObject *obj, double *val)
2824 : {
2825 77340 : int res = SWIG_TypeError;
2826 77340 : if (PyFloat_Check(obj)) {
2827 278 : if (val) *val = PyFloat_AsDouble(obj);
2828 278 : return SWIG_OK;
2829 : #if PY_VERSION_HEX < 0x03000000
2830 : } else if (PyInt_Check(obj)) {
2831 : if (val) *val = (double) PyInt_AsLong(obj);
2832 : return SWIG_OK;
2833 : #endif
2834 77062 : } else if (PyLong_Check(obj)) {
2835 77062 : double v = PyLong_AsDouble(obj);
2836 77062 : if (!PyErr_Occurred()) {
2837 77062 : if (val) *val = v;
2838 77062 : return SWIG_OK;
2839 : } else {
2840 0 : PyErr_Clear();
2841 : }
2842 : }
2843 : #ifdef SWIG_PYTHON_CAST_MODE
2844 : {
2845 : int dispatch = 0;
2846 : double d = PyFloat_AsDouble(obj);
2847 : if (!PyErr_Occurred()) {
2848 : if (val) *val = d;
2849 : return SWIG_AddCast(SWIG_OK);
2850 : } else {
2851 : PyErr_Clear();
2852 : }
2853 : if (!dispatch) {
2854 : long v = PyLong_AsLong(obj);
2855 : if (!PyErr_Occurred()) {
2856 : if (val) *val = v;
2857 : return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
2858 : } else {
2859 : PyErr_Clear();
2860 : }
2861 : }
2862 : }
2863 : #endif
2864 : return res;
2865 : }
2866 :
2867 :
2868 : #include <float.h>
2869 :
2870 :
2871 : #include <math.h>
2872 :
2873 :
2874 : SWIGINTERNINLINE int
2875 : SWIG_CanCastAsInteger(double *d, double min, double max) {
2876 : double x = *d;
2877 : if ((min <= x && x <= max)) {
2878 : double fx = floor(x);
2879 : double cx = ceil(x);
2880 : double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
2881 : if ((errno == EDOM) || (errno == ERANGE)) {
2882 : errno = 0;
2883 : } else {
2884 : double summ, reps, diff;
2885 : if (rd < x) {
2886 : diff = x - rd;
2887 : } else if (rd > x) {
2888 : diff = rd - x;
2889 : } else {
2890 : return 1;
2891 : }
2892 : summ = rd + x;
2893 : reps = diff/summ;
2894 : if (reps < 8*DBL_EPSILON) {
2895 : *d = rd;
2896 : return 1;
2897 : }
2898 : }
2899 : }
2900 : return 0;
2901 : }
2902 :
2903 :
2904 : SWIGINTERN int
2905 0 : SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
2906 : {
2907 : #if PY_VERSION_HEX < 0x03000000
2908 : if (PyInt_Check(obj)) {
2909 : long v = PyInt_AsLong(obj);
2910 : if (v >= 0) {
2911 : if (val) *val = v;
2912 : return SWIG_OK;
2913 : } else {
2914 : return SWIG_OverflowError;
2915 : }
2916 : } else
2917 : #endif
2918 0 : if (PyLong_Check(obj)) {
2919 0 : unsigned long v = PyLong_AsUnsignedLong(obj);
2920 0 : if (!PyErr_Occurred()) {
2921 0 : if (val) *val = v;
2922 0 : return SWIG_OK;
2923 : } else {
2924 0 : PyErr_Clear();
2925 0 : return SWIG_OverflowError;
2926 : }
2927 : }
2928 : #ifdef SWIG_PYTHON_CAST_MODE
2929 : {
2930 : int dispatch = 0;
2931 : unsigned long v = PyLong_AsUnsignedLong(obj);
2932 : if (!PyErr_Occurred()) {
2933 : if (val) *val = v;
2934 : return SWIG_AddCast(SWIG_OK);
2935 : } else {
2936 : PyErr_Clear();
2937 : }
2938 : if (!dispatch) {
2939 : double d;
2940 : int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
2941 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
2942 : if (val) *val = (unsigned long)(d);
2943 : return res;
2944 : }
2945 : }
2946 : }
2947 : #endif
2948 : return SWIG_TypeError;
2949 : }
2950 :
2951 :
2952 : #include <limits.h>
2953 : #if !defined(SWIG_NO_LLONG_MAX)
2954 : # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
2955 : # define LLONG_MAX __LONG_LONG_MAX__
2956 : # define LLONG_MIN (-LLONG_MAX - 1LL)
2957 : # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
2958 : # endif
2959 : #endif
2960 :
2961 :
2962 : #if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
2963 : # define SWIG_LONG_LONG_AVAILABLE
2964 : #endif
2965 :
2966 :
2967 : #ifdef SWIG_LONG_LONG_AVAILABLE
2968 : SWIGINTERN int
2969 : SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val)
2970 : {
2971 : int res = SWIG_TypeError;
2972 : if (PyLong_Check(obj)) {
2973 : unsigned long long v = PyLong_AsUnsignedLongLong(obj);
2974 : if (!PyErr_Occurred()) {
2975 : if (val) *val = v;
2976 : return SWIG_OK;
2977 : } else {
2978 : PyErr_Clear();
2979 : res = SWIG_OverflowError;
2980 : }
2981 : } else {
2982 : unsigned long v;
2983 : res = SWIG_AsVal_unsigned_SS_long (obj,&v);
2984 : if (SWIG_IsOK(res)) {
2985 : if (val) *val = v;
2986 : return res;
2987 : }
2988 : }
2989 : #ifdef SWIG_PYTHON_CAST_MODE
2990 : {
2991 : const double mant_max = 1LL << DBL_MANT_DIG;
2992 : double d;
2993 : res = SWIG_AsVal_double (obj,&d);
2994 : if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
2995 : return SWIG_OverflowError;
2996 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
2997 : if (val) *val = (unsigned long long)(d);
2998 : return SWIG_AddCast(res);
2999 : }
3000 : res = SWIG_TypeError;
3001 : }
3002 : #endif
3003 : return res;
3004 : }
3005 : #endif
3006 :
3007 :
3008 : SWIGINTERNINLINE int
3009 0 : SWIG_AsVal_size_t (PyObject * obj, size_t *val)
3010 : {
3011 0 : int res = SWIG_TypeError;
3012 : #ifdef SWIG_LONG_LONG_AVAILABLE
3013 0 : if (sizeof(size_t) <= sizeof(unsigned long)) {
3014 : #endif
3015 0 : unsigned long v;
3016 0 : res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
3017 0 : if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
3018 : #ifdef SWIG_LONG_LONG_AVAILABLE
3019 : } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
3020 : unsigned long long v;
3021 : res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0);
3022 : if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
3023 : }
3024 : #endif
3025 0 : return res;
3026 : }
3027 :
3028 :
3029 : SWIGINTERN int
3030 80859 : SWIG_AsVal_long (PyObject *obj, long* val)
3031 : {
3032 : #if PY_VERSION_HEX < 0x03000000
3033 : if (PyInt_Check(obj)) {
3034 : if (val) *val = PyInt_AsLong(obj);
3035 : return SWIG_OK;
3036 : } else
3037 : #endif
3038 80859 : if (PyLong_Check(obj)) {
3039 80857 : long v = PyLong_AsLong(obj);
3040 80857 : if (!PyErr_Occurred()) {
3041 80857 : if (val) *val = v;
3042 80857 : return SWIG_OK;
3043 : } else {
3044 0 : PyErr_Clear();
3045 0 : return SWIG_OverflowError;
3046 : }
3047 : }
3048 : #ifdef SWIG_PYTHON_CAST_MODE
3049 : {
3050 : int dispatch = 0;
3051 : long v = PyInt_AsLong(obj);
3052 : if (!PyErr_Occurred()) {
3053 : if (val) *val = v;
3054 : return SWIG_AddCast(SWIG_OK);
3055 : } else {
3056 : PyErr_Clear();
3057 : }
3058 : if (!dispatch) {
3059 : double d;
3060 : int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
3061 : if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
3062 : if (val) *val = (long)(d);
3063 : return res;
3064 : }
3065 : }
3066 : }
3067 : #endif
3068 : return SWIG_TypeError;
3069 : }
3070 :
3071 :
3072 : SWIGINTERN int
3073 80859 : SWIG_AsVal_int (PyObject * obj, int *val)
3074 : {
3075 80859 : long v;
3076 161718 : int res = SWIG_AsVal_long (obj, &v);
3077 80859 : if (SWIG_IsOK(res)) {
3078 80857 : if ((v < INT_MIN || v > INT_MAX)) {
3079 : return SWIG_OverflowError;
3080 : } else {
3081 80857 : if (val) *val = static_cast< int >(v);
3082 : }
3083 : }
3084 : return res;
3085 : }
3086 :
3087 : SWIGINTERN void CPLVirtualMemShadow_Pin__SWIG_0(CPLVirtualMemShadow *self,size_t start_offset=0,size_t nsize=0,int bWriteOp=0){
3088 : if( nsize == 0 || start_offset + nsize >= CPLVirtualMemGetSize( self->vmem ) )
3089 : nsize = CPLVirtualMemGetSize( self->vmem ) - start_offset;
3090 : char* start_addr = (char*)CPLVirtualMemGetAddr( self->vmem ) + start_offset;
3091 : CPLVirtualMemPin(self->vmem, start_addr, nsize, bWriteOp);
3092 : }
3093 :
3094 : #include "cpl_string.h"
3095 : #include "cpl_conv.h"
3096 :
3097 : static int bUseExceptions=0;
3098 : static int bUserHasSpecifiedIfUsingExceptions = FALSE;
3099 : static thread_local int bUseExceptionsLocal = -1;
3100 :
3101 16676 : struct PythonBindingErrorHandlerContext
3102 : {
3103 : std::string osInitialMsg{};
3104 : std::string osFailureMsg{};
3105 : CPLErrorNum nLastCode = CPLE_None;
3106 : bool bMemoryError = false;
3107 : };
3108 :
3109 : static void CPL_STDCALL
3110 337 : PythonBindingErrorHandler(CPLErr eclass, CPLErrorNum err_no, const char *msg )
3111 : {
3112 337 : PythonBindingErrorHandlerContext* ctxt = static_cast<
3113 337 : PythonBindingErrorHandlerContext*>(CPLGetErrorHandlerUserData());
3114 :
3115 : /*
3116 : ** Generally we want to suppress error reporting if we have exceptions
3117 : ** enabled as the error message will be in the exception thrown in
3118 : ** Python.
3119 : */
3120 :
3121 : /* If the error class is CE_Fatal, we want to have a message issued
3122 : because the CPL support code does an abort() before any exception
3123 : can be generated */
3124 337 : if (eclass == CE_Fatal ) {
3125 0 : CPLCallPreviousHandler(eclass, err_no, msg );
3126 : }
3127 :
3128 : /*
3129 : ** We do not want to interfere with non-failure messages since
3130 : ** they won't be translated into exceptions.
3131 : */
3132 337 : else if (eclass != CE_Failure ) {
3133 302 : CPLCallPreviousHandler(eclass, err_no, msg );
3134 : }
3135 : else {
3136 35 : ctxt->nLastCode = err_no;
3137 35 : try
3138 : {
3139 35 : if( ctxt->osFailureMsg.empty() ) {
3140 26 : ctxt->osFailureMsg = msg;
3141 26 : ctxt->osInitialMsg = ctxt->osFailureMsg;
3142 : } else {
3143 9 : if( ctxt->osFailureMsg.size() < 10000 ) {
3144 18 : std::string osTmp(msg);
3145 9 : osTmp += "\nMay be caused by: ";
3146 9 : osTmp += ctxt->osFailureMsg;
3147 9 : ctxt->osFailureMsg = std::move(osTmp);
3148 9 : ctxt->osInitialMsg = ctxt->osFailureMsg;
3149 : }
3150 : else
3151 : {
3152 0 : std::string osTmp(msg);
3153 0 : osTmp += "\n[...]\nMay be caused by: ";
3154 0 : osTmp += ctxt->osInitialMsg;
3155 0 : ctxt->osFailureMsg = std::move(osTmp);
3156 : }
3157 : }
3158 : }
3159 0 : catch( const std::exception& )
3160 : {
3161 0 : ctxt->bMemoryError = true;
3162 : }
3163 : }
3164 337 : }
3165 :
3166 :
3167 :
3168 :
3169 : static
3170 62807 : int GetUseExceptions() {
3171 9566 : return bUseExceptionsLocal >= 0 ? bUseExceptionsLocal : bUseExceptions;
3172 : }
3173 :
3174 0 : static int _GetExceptionsLocal()
3175 : {
3176 0 : return bUseExceptionsLocal;
3177 : }
3178 :
3179 22708 : static void _SetExceptionsLocal(int bVal)
3180 : {
3181 22708 : bUseExceptionsLocal = bVal;
3182 : }
3183 :
3184 : static
3185 28 : void _UseExceptions() {
3186 28 : CPLErrorReset();
3187 28 : bUserHasSpecifiedIfUsingExceptions = TRUE;
3188 28 : if( !bUseExceptions )
3189 : {
3190 25 : bUseExceptions = 1;
3191 : }
3192 : }
3193 :
3194 : static
3195 5 : void _DontUseExceptions() {
3196 5 : CPLErrorReset();
3197 5 : bUserHasSpecifiedIfUsingExceptions = TRUE;
3198 5 : if( bUseExceptions )
3199 : {
3200 0 : bUseExceptions = 0;
3201 : }
3202 : }
3203 :
3204 0 : static int _UserHasSpecifiedIfUsingExceptions()
3205 : {
3206 0 : return bUserHasSpecifiedIfUsingExceptions || bUseExceptionsLocal >= 0;
3207 : }
3208 :
3209 :
3210 :
3211 : SWIGINTERNINLINE PyObject*
3212 19420 : SWIG_From_int (int value)
3213 : {
3214 19420 : return PyInt_FromLong((long) value);
3215 : }
3216 :
3217 :
3218 : /* Completely unrelated: just to avoid Coverity warnings */
3219 :
3220 : static int bReturnSame = 1;
3221 :
3222 0 : void NeverCallMePlease() {
3223 0 : bReturnSame = 0;
3224 0 : }
3225 :
3226 : /* Some SWIG code generates dead code, which Coverity warns about */
3227 65493 : template<class T> static T ReturnSame(T x)
3228 : {
3229 65493 : if( bReturnSame )
3230 : return x;
3231 : return 0;
3232 : }
3233 :
3234 16676 : static void pushErrorHandler()
3235 : {
3236 16676 : CPLErrorReset();
3237 16676 : PythonBindingErrorHandlerContext* ctxt = new PythonBindingErrorHandlerContext();
3238 16676 : CPLPushErrorHandlerEx(PythonBindingErrorHandler, ctxt);
3239 16676 : }
3240 :
3241 16676 : static void popErrorHandler()
3242 : {
3243 16676 : PythonBindingErrorHandlerContext* ctxt = static_cast<
3244 16676 : PythonBindingErrorHandlerContext*>(CPLGetErrorHandlerUserData());
3245 16676 : CPLPopErrorHandler();
3246 16676 : if( ctxt->bMemoryError )
3247 : {
3248 0 : CPLErrorSetState(
3249 : CE_Failure, CPLE_OutOfMemory, "Out of memory");
3250 : }
3251 16676 : else if( !ctxt->osFailureMsg.empty() )
3252 : {
3253 26 : CPLErrorSetState(
3254 26 : CPLGetLastErrorType() == CE_Failure ? CE_Failure: CE_Warning,
3255 : ctxt->nLastCode, ctxt->osFailureMsg.c_str());
3256 : }
3257 16676 : delete ctxt;
3258 16676 : }
3259 :
3260 :
3261 :
3262 :
3263 : /* Return a PyObject* from a NULL terminated C String */
3264 : static PyObject* GDALPythonObjectFromCStr(const char *pszStr) CPL_UNUSED;
3265 2 : static PyObject* GDALPythonObjectFromCStr(const char *pszStr)
3266 : {
3267 2 : const unsigned char* pszIter = (const unsigned char*) pszStr;
3268 46 : while(*pszIter != 0)
3269 : {
3270 44 : if (*pszIter > 127)
3271 : {
3272 0 : PyObject* pyObj = PyUnicode_DecodeUTF8(pszStr, strlen(pszStr), "strict");
3273 0 : if (pyObj != NULL && !PyErr_Occurred())
3274 : return pyObj;
3275 0 : PyErr_Clear();
3276 0 : return PyBytes_FromString(pszStr);
3277 : }
3278 44 : pszIter ++;
3279 : }
3280 2 : return PyUnicode_FromString(pszStr);
3281 : }
3282 :
3283 : /* Return a NULL terminated c String from a PyObject */
3284 : /* Result must be freed with GDALPythonFreeCStr */
3285 : static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree) CPL_UNUSED;
3286 : static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree)
3287 : {
3288 : *pbToFree = 0;
3289 : if (PyUnicode_Check(pyObject))
3290 : {
3291 : char *pszStr;
3292 : char *pszNewStr;
3293 : Py_ssize_t nLen;
3294 : PyObject* pyUTF8Str = PyUnicode_AsUTF8String(pyObject);
3295 : if( pyUTF8Str == NULL )
3296 : return NULL;
3297 : PyBytes_AsStringAndSize(pyUTF8Str, &pszStr, &nLen);
3298 : pszNewStr = (char *) malloc(nLen+1);
3299 : if( pszNewStr == NULL )
3300 : {
3301 : CPLError(CE_Failure, CPLE_OutOfMemory, "Failed to allocate %llu bytes",
3302 : (unsigned long long)(nLen + 1));
3303 : Py_XDECREF(pyUTF8Str);
3304 : return NULL;
3305 : }
3306 : memcpy(pszNewStr, pszStr, nLen+1);
3307 : Py_XDECREF(pyUTF8Str);
3308 : *pbToFree = 1;
3309 : return pszNewStr;
3310 : }
3311 : else if( PyBytes_Check(pyObject) )
3312 : {
3313 : char* ret = PyBytes_AsString(pyObject);
3314 :
3315 : // Check if there are \0 bytes inside the string
3316 : const Py_ssize_t size = PyBytes_Size(pyObject);
3317 : for( Py_ssize_t i = 0; i < size; i++ )
3318 : {
3319 : if( ret[i] == 0 )
3320 : {
3321 : CPLError(CE_Failure, CPLE_AppDefined,
3322 : "bytes object cast as string contains a zero-byte.");
3323 : return NULL;
3324 : }
3325 : }
3326 :
3327 : return ret;
3328 : }
3329 : else
3330 : {
3331 : CPLError(CE_Failure, CPLE_AppDefined,
3332 : "Passed object is neither of type string nor bytes");
3333 : return NULL;
3334 : }
3335 : }
3336 :
3337 : static char * GDALPythonPathToCStr(PyObject* pyObject, int* pbToFree) CPL_UNUSED;
3338 : static char * GDALPythonPathToCStr(PyObject* pyObject, int* pbToFree)
3339 : {
3340 : PyObject* os = PyImport_ImportModule("os");
3341 : if (os == NULL)
3342 : {
3343 : return NULL;
3344 : }
3345 :
3346 : PyObject* pathLike = PyObject_GetAttrString(os, "PathLike");
3347 : if (pathLike == NULL)
3348 : {
3349 : Py_DECREF(os);
3350 : return NULL;
3351 : }
3352 :
3353 : if (!PyObject_IsInstance(pyObject, pathLike))
3354 : {
3355 : Py_DECREF(pathLike);
3356 : Py_DECREF(os);
3357 : return NULL;
3358 : }
3359 :
3360 : PyObject* str = PyObject_Str(pyObject);
3361 : char* ret = NULL;
3362 : if (str != NULL)
3363 : {
3364 : ret = GDALPythonObjectToCStr(str, pbToFree);
3365 : Py_DECREF(str);
3366 : }
3367 :
3368 : Py_DECREF(pathLike);
3369 : Py_DECREF(os);
3370 :
3371 : return ret;
3372 : }
3373 :
3374 :
3375 : static void GDALPythonFreeCStr(void* ptr, int bToFree) CPL_UNUSED;
3376 : static void GDALPythonFreeCStr(void* ptr, int bToFree)
3377 : {
3378 : if (bToFree)
3379 : free(ptr);
3380 : }
3381 :
3382 :
3383 :
3384 : #include <vector>
3385 : #include "gdal_priv.h"
3386 : #include "ogr_recordbatch.h"
3387 :
3388 : #ifdef _DEBUG
3389 : #undef _DEBUG
3390 : #include "Python.h"
3391 : #include "datetime.h"
3392 : #define _DEBUG
3393 : #else
3394 : #include "Python.h"
3395 : #include "datetime.h"
3396 : #endif
3397 : #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
3398 : #include "numpy/arrayobject.h"
3399 :
3400 : #ifdef DEBUG
3401 : typedef struct GDALRasterBandHS GDALRasterBandShadow;
3402 : typedef struct GDALDatasetHS GDALDatasetShadow;
3403 : typedef struct RasterAttributeTableHS GDALRasterAttributeTableShadow;
3404 : #else
3405 : typedef void GDALRasterBandShadow;
3406 : typedef void GDALDatasetShadow;
3407 : typedef void GDALRasterAttributeTableShadow;
3408 : #endif
3409 : typedef void GDALComputedRasterBandShadow;
3410 :
3411 : // Declaration from memmultidim.h
3412 : std::shared_ptr<GDALMDArray> CPL_DLL MEMGroupCreateMDArray(GDALGroup* poGroup,
3413 : const std::string& osName,
3414 : const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
3415 : const GDALExtendedDataType& oDataType,
3416 : void* pData,
3417 : CSLConstList papszOptions);
3418 :
3419 :
3420 : CPL_C_START
3421 :
3422 : GDALRasterBandH CPL_DLL MEMCreateRasterBandEx( GDALDataset *, int, GByte *,
3423 : GDALDataType, GSpacing, GSpacing, int );
3424 : CPL_C_END
3425 :
3426 : typedef char retStringAndCPLFree;
3427 :
3428 : class NUMPYDataset : public GDALDataset
3429 : {
3430 : PyArrayObject *psArray = nullptr;
3431 :
3432 : bool bValidGeoTransform = false;
3433 : GDALGeoTransform m_gt{};
3434 : OGRSpatialReference m_oSRS{};
3435 :
3436 : int nGCPCount = 0;
3437 : GDAL_GCP *pasGCPList = nullptr;
3438 : OGRSpatialReference m_oGCPSRS{};
3439 :
3440 : public:
3441 27 : NUMPYDataset() = default;
3442 : ~NUMPYDataset();
3443 :
3444 : const OGRSpatialReference* GetSpatialRef() const override;
3445 : CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override;
3446 :
3447 : virtual CPLErr GetGeoTransform( GDALGeoTransform& gt ) const override;
3448 : virtual CPLErr SetGeoTransform( const GDALGeoTransform& gt ) override;
3449 :
3450 : virtual int GetGCPCount() override;
3451 : const OGRSpatialReference* GetGCPSpatialRef() const override;
3452 : virtual const GDAL_GCP *GetGCPs() override;
3453 : CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
3454 : const OGRSpatialReference* poSRS ) override;
3455 :
3456 : static GDALDataset *Open( PyArrayObject *psArray, bool binterleave = true );
3457 : static GDALDataset *Open( GDALOpenInfo * );
3458 : };
3459 :
3460 :
3461 : /************************************************************************/
3462 : /* GDALRegister_NUMPY() */
3463 : /************************************************************************/
3464 :
3465 226 : static void GDALRegister_NUMPY(void)
3466 :
3467 : {
3468 226 : GDALDriver *poDriver;
3469 226 : if (! GDAL_CHECK_VERSION("NUMPY driver"))
3470 : return;
3471 226 : if( GDALGetDriverByName( "NUMPY" ) == NULL )
3472 : {
3473 224 : poDriver = static_cast<GDALDriver*>(GDALCreateDriver());
3474 :
3475 224 : poDriver->SetDescription( "NUMPY" );
3476 224 : poDriver->SetMetadataItem( GDAL_DMD_LONGNAME,
3477 224 : "Numeric Python Array" );
3478 224 : poDriver->SetMetadataItem( GDAL_DCAP_RASTER, "YES" );
3479 :
3480 224 : poDriver->pfnOpen = NUMPYDataset::Open;
3481 :
3482 224 : GetGDALDriverManager()->RegisterDriver( poDriver );
3483 :
3484 : }
3485 : }
3486 :
3487 : /************************************************************************/
3488 : /* ~NUMPYDataset() */
3489 : /************************************************************************/
3490 :
3491 54 : NUMPYDataset::~NUMPYDataset()
3492 :
3493 : {
3494 27 : if( nGCPCount > 0 )
3495 : {
3496 0 : GDALDeinitGCPs( nGCPCount, pasGCPList );
3497 0 : CPLFree( pasGCPList );
3498 : }
3499 :
3500 27 : FlushCache(true);
3501 :
3502 : // Although the module has thread disabled, we go here from GDALClose()
3503 27 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3504 :
3505 27 : Py_DECREF( psArray );
3506 :
3507 27 : SWIG_PYTHON_THREAD_END_BLOCK;
3508 54 : }
3509 :
3510 : /************************************************************************/
3511 : /* GetSpatialRef() */
3512 : /************************************************************************/
3513 :
3514 0 : const OGRSpatialReference *NUMPYDataset::GetSpatialRef() const
3515 :
3516 : {
3517 0 : return m_oSRS.IsEmpty() ? nullptr: &m_oSRS;
3518 : }
3519 :
3520 : /************************************************************************/
3521 : /* SetSpatialRef() */
3522 : /************************************************************************/
3523 :
3524 0 : CPLErr NUMPYDataset::SetSpatialRef( const OGRSpatialReference* poSRS )
3525 :
3526 : {
3527 0 : m_oSRS.Clear();
3528 0 : if( poSRS )
3529 0 : m_oSRS = *poSRS;
3530 :
3531 0 : return CE_None;
3532 : }
3533 :
3534 : /************************************************************************/
3535 : /* GetGeoTransform() */
3536 : /************************************************************************/
3537 :
3538 2 : CPLErr NUMPYDataset::GetGeoTransform(GDALGeoTransform >) const
3539 :
3540 : {
3541 2 : gt = m_gt;
3542 2 : if( bValidGeoTransform )
3543 : return CE_None;
3544 : else
3545 1 : return CE_Failure;
3546 : }
3547 :
3548 : /************************************************************************/
3549 : /* SetGeoTransform() */
3550 : /************************************************************************/
3551 :
3552 1 : CPLErr NUMPYDataset::SetGeoTransform(const GDALGeoTransform& gt)
3553 :
3554 : {
3555 1 : bValidGeoTransform = true;
3556 1 : m_gt = gt;
3557 1 : return( CE_None );
3558 : }
3559 :
3560 : /************************************************************************/
3561 : /* GetGCPCount() */
3562 : /************************************************************************/
3563 :
3564 0 : int NUMPYDataset::GetGCPCount()
3565 :
3566 : {
3567 0 : return nGCPCount;
3568 : }
3569 :
3570 : /************************************************************************/
3571 : /* GetGCPSpatialRef() */
3572 : /************************************************************************/
3573 :
3574 0 : const OGRSpatialReference *NUMPYDataset::GetGCPSpatialRef() const
3575 :
3576 : {
3577 0 : return m_oGCPSRS.IsEmpty() ? nullptr: &m_oGCPSRS;
3578 : }
3579 :
3580 : /************************************************************************/
3581 : /* GetGCPs() */
3582 : /************************************************************************/
3583 :
3584 0 : const GDAL_GCP *NUMPYDataset::GetGCPs()
3585 :
3586 : {
3587 0 : return pasGCPList;
3588 : }
3589 :
3590 : /************************************************************************/
3591 : /* SetGCPs() */
3592 : /************************************************************************/
3593 :
3594 0 : CPLErr NUMPYDataset::SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
3595 : const OGRSpatialReference* poSRS )
3596 :
3597 : {
3598 0 : m_oGCPSRS.Clear();
3599 0 : if( poSRS )
3600 0 : m_oGCPSRS = *poSRS;
3601 :
3602 0 : if( this->nGCPCount > 0 )
3603 : {
3604 0 : GDALDeinitGCPs( this->nGCPCount, this->pasGCPList );
3605 0 : CPLFree( this->pasGCPList );
3606 : }
3607 :
3608 0 : this->nGCPCount = nGCPCount;
3609 :
3610 0 : this->pasGCPList = GDALDuplicateGCPs( nGCPCount, pasGCPList );
3611 :
3612 0 : return CE_None;
3613 : }
3614 :
3615 : /************************************************************************/
3616 : /* Open() */
3617 : /************************************************************************/
3618 :
3619 28095 : GDALDataset *NUMPYDataset::Open( GDALOpenInfo * poOpenInfo )
3620 :
3621 : {
3622 28095 : PyArrayObject *psArray;
3623 :
3624 : /* -------------------------------------------------------------------- */
3625 : /* Is this a numpy dataset name? */
3626 : /* -------------------------------------------------------------------- */
3627 28095 : if( !EQUALN(poOpenInfo->pszFilename,"NUMPY:::",8)
3628 3 : || poOpenInfo->fpL != NULL )
3629 : return NULL;
3630 :
3631 3 : psArray = NULL;
3632 3 : sscanf( poOpenInfo->pszFilename+8, "%p", &(psArray) );
3633 3 : if( psArray == NULL )
3634 : {
3635 1 : CPLError( CE_Failure, CPLE_AppDefined,
3636 : "Failed to parse meaningful pointer value from NUMPY name\n"
3637 : "string: %s\n",
3638 : poOpenInfo->pszFilename );
3639 1 : return NULL;
3640 : }
3641 :
3642 2 : if( !CPLTestBool(CPLGetConfigOption("GDAL_ARRAY_OPEN_BY_FILENAME",
3643 : "FALSE")) )
3644 : {
3645 1 : if( CPLGetConfigOption("GDAL_ARRAY_OPEN_BY_FILENAME", NULL) == NULL )
3646 : {
3647 1 : CPLError(CE_Failure, CPLE_NotSupported,
3648 : "Opening a NumPy array through gdal.Open(gdal_array.GetArrayFilename()) "
3649 : "is no longer supported by default unless the GDAL_ARRAY_OPEN_BY_FILENAME "
3650 : "configuration option is set to TRUE. The recommended way is to use "
3651 : "gdal_array.OpenArray() instead.");
3652 : }
3653 1 : return NULL;
3654 : }
3655 :
3656 1 : return Open(psArray);
3657 : }
3658 :
3659 49 : static GDALDataType NumpyTypeToGDALType(PyArrayObject *psArray)
3660 : {
3661 49 : switch( PyArray_DESCR(psArray)->type_num )
3662 : {
3663 : case NPY_CDOUBLE:
3664 : return GDT_CFloat64;
3665 :
3666 5 : case NPY_CFLOAT:
3667 5 : return GDT_CFloat32;
3668 :
3669 : // case NPY_CHALF
3670 : // return GDT_CFloat16;
3671 :
3672 5 : case NPY_DOUBLE:
3673 5 : return GDT_Float64;
3674 :
3675 3 : case NPY_FLOAT:
3676 3 : return GDT_Float32;
3677 :
3678 0 : case NPY_HALF:
3679 0 : return GDT_Float16;
3680 :
3681 3 : case NPY_INT32:
3682 3 : return GDT_Int32;
3683 :
3684 3 : case NPY_UINT32:
3685 3 : return GDT_UInt32;
3686 :
3687 1 : case NPY_INT64:
3688 1 : return GDT_Int64;
3689 :
3690 1 : case NPY_UINT64:
3691 1 : return GDT_UInt64;
3692 :
3693 3 : case NPY_INT16:
3694 3 : return GDT_Int16;
3695 :
3696 3 : case NPY_UINT16:
3697 3 : return GDT_UInt16;
3698 :
3699 2 : case NPY_BYTE:
3700 2 : return GDT_Int8;
3701 :
3702 15 : case NPY_UBYTE:
3703 15 : return GDT_Byte;
3704 :
3705 2 : default:
3706 2 : CPLError( CE_Failure, CPLE_AppDefined,
3707 : "Unable to access numpy arrays of typecode `%c'.",
3708 2 : PyArray_DESCR(psArray)->type );
3709 2 : return GDT_Unknown;
3710 : }
3711 : }
3712 :
3713 : /************************************************************************/
3714 : /* Open() */
3715 : /************************************************************************/
3716 :
3717 31 : GDALDataset* NUMPYDataset::Open( PyArrayObject *psArray, bool binterleave )
3718 : {
3719 31 : GDALDataType eType;
3720 31 : int nBands;
3721 :
3722 : /* -------------------------------------------------------------------- */
3723 : /* Is this a directly mappable Python array? Verify rank, and */
3724 : /* data type. */
3725 : /* -------------------------------------------------------------------- */
3726 :
3727 31 : if( PyArray_NDIM(psArray) < 2 || PyArray_NDIM(psArray) > 3 )
3728 : {
3729 3 : CPLError( CE_Failure, CPLE_AppDefined,
3730 : "Illegal numpy array rank %d.",
3731 : PyArray_NDIM(psArray) );
3732 3 : return NULL;
3733 : }
3734 :
3735 28 : eType = NumpyTypeToGDALType(psArray);
3736 28 : if( eType == GDT_Unknown )
3737 : {
3738 : return NULL;
3739 : }
3740 :
3741 : /* -------------------------------------------------------------------- */
3742 : /* Create the new NUMPYDataset object. */
3743 : /* -------------------------------------------------------------------- */
3744 27 : NUMPYDataset *poDS;
3745 :
3746 27 : poDS = new NUMPYDataset();
3747 27 : poDS->poDriver = static_cast<GDALDriver*>(GDALGetDriverByName("NUMPY"));
3748 :
3749 27 : poDS->psArray = psArray;
3750 :
3751 27 : poDS->eAccess = (PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) ? GA_Update : GA_ReadOnly;
3752 :
3753 : /* -------------------------------------------------------------------- */
3754 : /* Add a reference to the array. */
3755 : /* -------------------------------------------------------------------- */
3756 27 : Py_INCREF( psArray );
3757 :
3758 : /* -------------------------------------------------------------------- */
3759 : /* Workout the data layout. */
3760 : /* -------------------------------------------------------------------- */
3761 27 : npy_intp nBandOffset;
3762 27 : npy_intp nPixelOffset;
3763 27 : npy_intp nLineOffset;
3764 :
3765 27 : int xdim = binterleave ? 2 : 1;
3766 27 : int ydim = binterleave ? 1 : 0;
3767 27 : int bdim = binterleave ? 0 : 2;
3768 :
3769 27 : if( PyArray_NDIM(psArray) == 3 )
3770 : {
3771 6 : if( PyArray_DIMS(psArray)[0] > INT_MAX ||
3772 6 : PyArray_DIMS(psArray)[1] > INT_MAX ||
3773 18 : PyArray_DIMS(psArray)[2] > INT_MAX ||
3774 6 : !GDALCheckBandCount(static_cast<int>(PyArray_DIMS(psArray)[bdim]), 0) )
3775 : {
3776 0 : CPLError(CE_Failure, CPLE_NotSupported,
3777 : "Too big array dimensions");
3778 0 : delete poDS;
3779 0 : return NULL;
3780 : }
3781 6 : nBands = static_cast<int>(PyArray_DIMS(psArray)[bdim]);
3782 6 : nBandOffset = PyArray_STRIDES(psArray)[bdim];
3783 6 : poDS->nRasterXSize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
3784 6 : nPixelOffset = PyArray_STRIDES(psArray)[xdim];
3785 6 : poDS->nRasterYSize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
3786 6 : nLineOffset = PyArray_STRIDES(psArray)[ydim];
3787 : }
3788 : else
3789 : {
3790 21 : if( PyArray_DIMS(psArray)[0] > INT_MAX ||
3791 21 : PyArray_DIMS(psArray)[1] > INT_MAX )
3792 : {
3793 0 : delete poDS;
3794 0 : return NULL;
3795 : }
3796 21 : nBands = 1;
3797 21 : nBandOffset = 0;
3798 21 : poDS->nRasterXSize = static_cast<int>(PyArray_DIMS(psArray)[1]);
3799 21 : nPixelOffset = PyArray_STRIDES(psArray)[1];
3800 21 : poDS->nRasterYSize = static_cast<int>(PyArray_DIMS(psArray)[0]);
3801 21 : nLineOffset = PyArray_STRIDES(psArray)[0];
3802 : }
3803 :
3804 : /* -------------------------------------------------------------------- */
3805 : /* Create band information objects. */
3806 : /* -------------------------------------------------------------------- */
3807 62 : for( int iBand = 0; iBand < nBands; iBand++ )
3808 : {
3809 35 : poDS->SetBand( iBand+1,
3810 : (GDALRasterBand *)
3811 35 : MEMCreateRasterBandEx( poDS, iBand+1,
3812 35 : (GByte *) PyArray_DATA(psArray) + nBandOffset*iBand,
3813 : eType, nPixelOffset, nLineOffset,
3814 : FALSE ) );
3815 : }
3816 :
3817 : /* -------------------------------------------------------------------- */
3818 : /* Try to return a regular handle on the file. */
3819 : /* -------------------------------------------------------------------- */
3820 : return poDS;
3821 : }
3822 :
3823 : /************************************************************************/
3824 : /* NUMPYMultiDimensionalDataset */
3825 : /************************************************************************/
3826 :
3827 : class NUMPYMultiDimensionalDataset : public GDALDataset
3828 : {
3829 : PyArrayObject *psArray = nullptr;
3830 : std::unique_ptr<GDALDataset> poMEMDS{};
3831 :
3832 : NUMPYMultiDimensionalDataset();
3833 : ~NUMPYMultiDimensionalDataset();
3834 :
3835 : public:
3836 : static GDALDataset *Open( PyArrayObject *psArray );
3837 :
3838 20 : std::shared_ptr<GDALGroup> GetRootGroup() const override { return poMEMDS->GetRootGroup(); }
3839 : };
3840 :
3841 : /************************************************************************/
3842 : /* NUMPYMultiDimensionalDataset() */
3843 : /************************************************************************/
3844 :
3845 20 : NUMPYMultiDimensionalDataset::NUMPYMultiDimensionalDataset()
3846 : {
3847 20 : }
3848 :
3849 : /************************************************************************/
3850 : /* ~NUMPYMultiDimensionalDataset() */
3851 : /************************************************************************/
3852 :
3853 40 : NUMPYMultiDimensionalDataset::~NUMPYMultiDimensionalDataset()
3854 : {
3855 : // Although the module has thread disabled, we go here from GDALClose()
3856 20 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3857 :
3858 20 : Py_DECREF( psArray );
3859 :
3860 20 : SWIG_PYTHON_THREAD_END_BLOCK;
3861 40 : }
3862 :
3863 : /************************************************************************/
3864 : /* Open() */
3865 : /************************************************************************/
3866 :
3867 21 : GDALDataset* NUMPYMultiDimensionalDataset::Open( PyArrayObject *psArray )
3868 : {
3869 21 : const auto eType = NumpyTypeToGDALType(psArray);
3870 21 : if( eType == GDT_Unknown )
3871 : {
3872 : return nullptr;
3873 : }
3874 20 : auto poMemDriver = GDALDriver::FromHandle(GDALGetDriverByName("MEM"));
3875 20 : if( !poMemDriver )
3876 : {
3877 0 : CPLError(CE_Failure, CPLE_AppDefined,
3878 : "MEM driver not available");
3879 0 : return nullptr;
3880 : }
3881 :
3882 20 : auto poMEMDS = poMemDriver->CreateMultiDimensional("", nullptr, nullptr);
3883 20 : assert(poMEMDS);
3884 41 : auto poGroup = poMEMDS->GetRootGroup();
3885 20 : assert(poGroup);
3886 40 : std::vector<std::shared_ptr<GDALDimension>> apoDims;
3887 20 : const auto ndims = PyArray_NDIM(psArray);
3888 40 : CPLString strides;
3889 60 : for( int i = 0; i < ndims; i++ )
3890 : {
3891 80 : auto poDim = poGroup->CreateDimension(std::string(CPLSPrintf("dim%d", i)),
3892 40 : std::string(),
3893 40 : std::string(),
3894 40 : PyArray_DIMS(psArray)[i],
3895 120 : nullptr);
3896 40 : apoDims.push_back(poDim);
3897 40 : if( i > 0 )
3898 20 : strides += ',';
3899 40 : strides += CPLSPrintf(CPL_FRMT_GIB,
3900 40 : static_cast<GIntBig>(PyArray_STRIDES(psArray)[i]));
3901 : }
3902 40 : CPLStringList aosOptions;
3903 20 : aosOptions.SetNameValue("STRIDES", strides.c_str());
3904 20 : auto mdArray = MEMGroupCreateMDArray(poGroup.get(), "array",
3905 : apoDims,
3906 20 : GDALExtendedDataType::Create(eType),
3907 : PyArray_DATA(psArray),
3908 60 : aosOptions.List());
3909 20 : if( !mdArray )
3910 : {
3911 0 : delete poMEMDS;
3912 0 : return nullptr;
3913 : }
3914 :
3915 20 : auto poDS = new NUMPYMultiDimensionalDataset();
3916 20 : poDS->poDriver = GDALDriver::FromHandle(GDALGetDriverByName("NUMPY"));
3917 20 : poDS->psArray = psArray;
3918 20 : Py_INCREF( psArray );
3919 20 : poDS->eAccess = GA_ReadOnly;
3920 20 : poDS->poMEMDS.reset(poMEMDS);
3921 : return poDS;
3922 : }
3923 :
3924 :
3925 :
3926 0 : int GDALTermProgress_nocb( double dfProgress, const char * pszMessage=NULL, void *pData=NULL ) {
3927 0 : return GDALTermProgress( dfProgress, pszMessage, pData);
3928 : }
3929 :
3930 :
3931 : SWIGINTERN swig_type_info*
3932 0 : SWIG_pchar_descriptor(void)
3933 : {
3934 0 : static int init = 0;
3935 0 : static swig_type_info* info = 0;
3936 0 : if (!init) {
3937 0 : info = SWIG_TypeQuery("_p_char");
3938 0 : init = 1;
3939 : }
3940 0 : return info;
3941 : }
3942 :
3943 :
3944 : SWIGINTERN int
3945 0 : SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
3946 : {
3947 : #if PY_VERSION_HEX>=0x03000000
3948 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3949 : if (PyBytes_Check(obj))
3950 : #else
3951 0 : if (PyUnicode_Check(obj))
3952 : #endif
3953 : #else
3954 : if (PyString_Check(obj))
3955 : #endif
3956 : {
3957 0 : char *cstr; Py_ssize_t len;
3958 0 : int ret = SWIG_OK;
3959 : #if PY_VERSION_HEX>=0x03000000
3960 : #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3961 0 : if (!alloc && cptr) {
3962 : /* We can't allow converting without allocation, since the internal
3963 : representation of string in Python 3 is UCS-2/UCS-4 but we require
3964 : a UTF-8 representation.
3965 : TODO(bhy) More detailed explanation */
3966 : return SWIG_RuntimeError;
3967 : }
3968 0 : obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
3969 0 : if (!obj)
3970 : return SWIG_TypeError;
3971 0 : if (alloc)
3972 0 : *alloc = SWIG_NEWOBJ;
3973 : #endif
3974 0 : PyBytes_AsStringAndSize(obj, &cstr, &len);
3975 : #else
3976 : PyString_AsStringAndSize(obj, &cstr, &len);
3977 : #endif
3978 0 : if (cptr) {
3979 0 : if (alloc) {
3980 0 : if (*alloc == SWIG_NEWOBJ) {
3981 0 : *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
3982 0 : *alloc = SWIG_NEWOBJ;
3983 : } else {
3984 0 : *cptr = cstr;
3985 0 : *alloc = SWIG_OLDOBJ;
3986 : }
3987 : } else {
3988 : #if PY_VERSION_HEX>=0x03000000
3989 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3990 : *cptr = PyBytes_AsString(obj);
3991 : #else
3992 : assert(0); /* Should never reach here with Unicode strings in Python 3 */
3993 : #endif
3994 : #else
3995 : *cptr = SWIG_Python_str_AsChar(obj);
3996 : if (!*cptr)
3997 : ret = SWIG_TypeError;
3998 : #endif
3999 : }
4000 : }
4001 0 : if (psize) *psize = len + 1;
4002 : #if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4003 0 : Py_XDECREF(obj);
4004 : #endif
4005 0 : return ret;
4006 : } else {
4007 : #if defined(SWIG_PYTHON_2_UNICODE)
4008 : #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4009 : #error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
4010 : #endif
4011 : #if PY_VERSION_HEX<0x03000000
4012 : if (PyUnicode_Check(obj)) {
4013 : char *cstr; Py_ssize_t len;
4014 : if (!alloc && cptr) {
4015 : return SWIG_RuntimeError;
4016 : }
4017 : obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
4018 : if (!obj)
4019 : return SWIG_TypeError;
4020 : if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
4021 : if (cptr) {
4022 : if (alloc) *alloc = SWIG_NEWOBJ;
4023 : *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
4024 : }
4025 : if (psize) *psize = len + 1;
4026 :
4027 : Py_XDECREF(obj);
4028 : return SWIG_OK;
4029 : } else {
4030 : Py_XDECREF(obj);
4031 : }
4032 : }
4033 : #endif
4034 : #endif
4035 :
4036 0 : swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
4037 0 : if (pchar_descriptor) {
4038 0 : void* vptr = 0;
4039 0 : if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
4040 0 : if (cptr) *cptr = (char *) vptr;
4041 0 : if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
4042 0 : if (alloc) *alloc = SWIG_OLDOBJ;
4043 0 : return SWIG_OK;
4044 : }
4045 : }
4046 : }
4047 : return SWIG_TypeError;
4048 : }
4049 :
4050 :
4051 :
4052 :
4053 :
4054 :
4055 : typedef struct {
4056 : PyObject *psPyCallback;
4057 : PyObject *psPyCallbackData;
4058 : int nLastReported;
4059 : } PyProgressData;
4060 :
4061 : /************************************************************************/
4062 : /* PyProgressProxy() */
4063 : /************************************************************************/
4064 :
4065 :
4066 : static int CPL_STDCALL
4067 : PyProgressProxy( double dfComplete, const char *pszMessage, void *pData ) CPL_UNUSED;
4068 :
4069 : static int CPL_STDCALL
4070 362 : PyProgressProxy( double dfComplete, const char *pszMessage, void *pData )
4071 :
4072 : {
4073 362 : PyProgressData *psInfo = (PyProgressData *) pData;
4074 362 : PyObject *psArgs, *psResult;
4075 362 : int bContinue = TRUE;
4076 :
4077 362 : if( dfComplete > 0 && psInfo->nLastReported == (int) (100.0 * dfComplete) )
4078 : return TRUE;
4079 :
4080 264 : if( psInfo->psPyCallback == NULL || psInfo->psPyCallback == Py_None )
4081 : return TRUE;
4082 :
4083 264 : psInfo->nLastReported = (int) (100.0 * dfComplete);
4084 :
4085 264 : if( pszMessage == NULL )
4086 0 : pszMessage = "";
4087 :
4088 626 : SWIG_PYTHON_THREAD_BEGIN_BLOCK;
4089 :
4090 264 : if( psInfo->psPyCallbackData == NULL )
4091 0 : psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage, Py_None );
4092 : else
4093 264 : psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage,
4094 : psInfo->psPyCallbackData );
4095 :
4096 264 : psResult = PyObject_CallObject( psInfo->psPyCallback, psArgs);
4097 264 : Py_XDECREF(psArgs);
4098 :
4099 264 : if( PyErr_Occurred() != NULL )
4100 : {
4101 0 : PyErr_Print();
4102 0 : PyErr_Clear();
4103 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4104 : return FALSE;
4105 : }
4106 :
4107 264 : if( psResult == NULL )
4108 : {
4109 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4110 : return TRUE;
4111 : }
4112 :
4113 264 : if( psResult == Py_None )
4114 : {
4115 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4116 : return TRUE;
4117 : }
4118 :
4119 264 : if( !PyArg_Parse( psResult, "i", &bContinue ) )
4120 : {
4121 0 : PyErr_Clear();
4122 0 : CPLError(CE_Failure, CPLE_AppDefined, "bad progress return value");
4123 0 : Py_XDECREF(psResult);
4124 0 : SWIG_PYTHON_THREAD_END_BLOCK;
4125 : return FALSE;
4126 : }
4127 :
4128 264 : Py_XDECREF(psResult);
4129 264 : SWIG_PYTHON_THREAD_END_BLOCK;
4130 :
4131 264 : return bContinue;
4132 : }
4133 :
4134 :
4135 30 : GDALDatasetShadow* OpenNumPyArray(PyArrayObject *psArray, bool binterleave)
4136 : {
4137 30 : return NUMPYDataset::Open( psArray, binterleave );
4138 : }
4139 :
4140 :
4141 : SWIGINTERN int
4142 211 : SWIG_AsVal_bool (PyObject *obj, bool *val)
4143 : {
4144 211 : int r;
4145 211 : if (!PyBool_Check(obj))
4146 : return SWIG_ERROR;
4147 211 : r = PyObject_IsTrue(obj);
4148 211 : if (r == -1)
4149 : return SWIG_ERROR;
4150 211 : if (val) *val = r ? true : false;
4151 : return SWIG_OK;
4152 : }
4153 :
4154 :
4155 21 : GDALDatasetShadow* OpenMultiDimensionalNumPyArray(PyArrayObject *psArray)
4156 : {
4157 21 : return NUMPYMultiDimensionalDataset::Open( psArray );
4158 : }
4159 :
4160 :
4161 2 : retStringAndCPLFree* GetArrayFilename(PyArrayObject *psArray)
4162 : {
4163 2 : char szString[128];
4164 :
4165 2 : GDALRegister_NUMPY();
4166 :
4167 : /* I wish I had a safe way of checking the type */
4168 2 : snprintf( szString, sizeof(szString), "NUMPY:::%p", psArray );
4169 2 : return CPLStrdup(szString);
4170 : }
4171 :
4172 :
4173 19226 : CPLErr BandRasterIONumPy( GDALRasterBandShadow* band, int bWrite, double xoff, double yoff, double xsize, double ysize,
4174 : PyArrayObject *psArray,
4175 : GDALDataType buf_type,
4176 : GDALRIOResampleAlg resample_alg,
4177 : GDALProgressFunc callback = NULL,
4178 : void* callback_data = NULL) {
4179 :
4180 19226 : if( PyArray_NDIM(psArray) < 2 || PyArray_NDIM(psArray) > 3 )
4181 : {
4182 0 : CPLError( CE_Failure, CPLE_AppDefined,
4183 : "Illegal numpy array rank %d.\n",
4184 : PyArray_NDIM(psArray) );
4185 0 : return CE_Failure;
4186 : }
4187 :
4188 19226 : if( !bWrite && !(PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) )
4189 : {
4190 2 : CPLError( CE_Failure, CPLE_AppDefined,
4191 : "Cannot read in a non-writeable array." );
4192 2 : return CE_Failure;
4193 : }
4194 :
4195 19224 : int xdim = ( PyArray_NDIM(psArray) == 2) ? 1 : 2;
4196 19224 : int ydim = ( PyArray_NDIM(psArray) == 2) ? 0 : 1;
4197 :
4198 19224 : if( PyArray_DIMS(psArray)[xdim] > INT_MAX ||
4199 19224 : PyArray_DIMS(psArray)[ydim] > INT_MAX )
4200 : {
4201 0 : CPLError(CE_Failure, CPLE_NotSupported,
4202 : "Too big array dimensions");
4203 0 : return CE_Failure;
4204 : }
4205 19224 : int nxsize, nysize;
4206 19224 : GSpacing pixel_space, line_space;
4207 19224 : nxsize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
4208 19224 : nysize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
4209 19224 : pixel_space = PyArray_STRIDES(psArray)[xdim];
4210 19224 : line_space = PyArray_STRIDES(psArray)[ydim];
4211 :
4212 19224 : GDALRasterIOExtraArg sExtraArg;
4213 19224 : INIT_RASTERIO_EXTRA_ARG(sExtraArg);
4214 19224 : sExtraArg.eResampleAlg = resample_alg;
4215 19224 : sExtraArg.pfnProgress = callback;
4216 19224 : sExtraArg.pProgressData = callback_data;
4217 19224 : int nXOff = (int)(xoff + 0.5);
4218 19224 : int nYOff = (int)(yoff + 0.5);
4219 19224 : int nXSize = (int)(xsize + 0.5);
4220 19224 : int nYSize = (int)(ysize + 0.5);
4221 19224 : if( fabs(xoff-nXOff) > 1e-8 || fabs(yoff-nYOff) > 1e-8 ||
4222 19163 : fabs(xsize-nXSize) > 1e-8 || fabs(ysize-nYSize) > 1e-8 )
4223 : {
4224 61 : sExtraArg.bFloatingPointWindowValidity = TRUE;
4225 61 : sExtraArg.dfXOff = xoff;
4226 61 : sExtraArg.dfYOff = yoff;
4227 61 : sExtraArg.dfXSize = xsize;
4228 61 : sExtraArg.dfYSize = ysize;
4229 : }
4230 :
4231 26821 : return GDALRasterIOEx( band, (bWrite) ? GF_Write : GF_Read, nXOff, nYOff, nXSize, nYSize,
4232 : PyArray_DATA(psArray), nxsize, nysize,
4233 : buf_type, pixel_space, line_space, &sExtraArg );
4234 : }
4235 :
4236 :
4237 103 : CPLErr DatasetIONumPy( GDALDatasetShadow* ds, int bWrite, double xoff, double yoff, double xsize, double ysize,
4238 : PyArrayObject *psArray,
4239 : GDALDataType buf_type,
4240 : GDALRIOResampleAlg resample_alg,
4241 : GDALProgressFunc callback = NULL,
4242 : void* callback_data = NULL,
4243 : bool binterleave = true,
4244 : int band_list = 0, int *pband_list = 0 )
4245 : {
4246 103 : if( PyArray_NDIM(psArray) != 3 )
4247 : {
4248 0 : CPLError( CE_Failure, CPLE_AppDefined,
4249 : "Illegal numpy array rank %d.",
4250 : PyArray_NDIM(psArray) );
4251 0 : return CE_Failure;
4252 : }
4253 :
4254 103 : if( !bWrite && !(PyArray_FLAGS(psArray) & NPY_ARRAY_WRITEABLE) )
4255 : {
4256 0 : CPLError( CE_Failure, CPLE_AppDefined,
4257 : "Cannot read in a non-writeable array." );
4258 0 : return CE_Failure;
4259 : }
4260 :
4261 103 : int xdim = binterleave ? 2 : 1;
4262 103 : int ydim = binterleave ? 1 : 0;
4263 103 : int bdim = binterleave ? 0 : 2;
4264 103 : if( PyArray_DIMS(psArray)[xdim] > INT_MAX ||
4265 103 : PyArray_DIMS(psArray)[ydim] > INT_MAX ||
4266 103 : PyArray_DIMS(psArray)[bdim] > INT_MAX )
4267 : {
4268 0 : CPLError(CE_Failure, CPLE_NotSupported,
4269 : "Too big array dimensions");
4270 0 : return CE_Failure;
4271 : }
4272 :
4273 103 : int bandsize, nxsize, nysize;
4274 103 : GIntBig pixel_space, line_space, band_space;
4275 103 : nxsize = static_cast<int>(PyArray_DIMS(psArray)[xdim]);
4276 103 : nysize = static_cast<int>(PyArray_DIMS(psArray)[ydim]);
4277 103 : bandsize = static_cast<int>(PyArray_DIMS(psArray)[bdim]);
4278 103 : int bandcount = band_list ? band_list : GDALGetRasterCount(ds);
4279 103 : if( bandsize != bandcount )
4280 : {
4281 0 : CPLError( CE_Failure, CPLE_AppDefined,
4282 : "Illegal numpy array band dimension %d. Expected value: %d",
4283 : bandsize, bandcount );
4284 0 : return CE_Failure;
4285 : }
4286 103 : pixel_space = PyArray_STRIDES(psArray)[xdim];
4287 103 : line_space = PyArray_STRIDES(psArray)[ydim];
4288 103 : band_space = PyArray_STRIDES(psArray)[bdim];
4289 :
4290 103 : GDALRasterIOExtraArg sExtraArg;
4291 103 : INIT_RASTERIO_EXTRA_ARG(sExtraArg);
4292 103 : sExtraArg.eResampleAlg = resample_alg;
4293 103 : sExtraArg.pfnProgress = callback;
4294 103 : sExtraArg.pProgressData = callback_data;
4295 103 : int nXOff = (int)(xoff + 0.5);
4296 103 : int nYOff = (int)(yoff + 0.5);
4297 103 : int nXSize = (int)(xsize + 0.5);
4298 103 : int nYSize = (int)(ysize + 0.5);
4299 103 : if( fabs(xoff-nXOff) > 1e-8 || fabs(yoff-nYOff) > 1e-8 ||
4300 102 : fabs(xsize-nXSize) > 1e-8 || fabs(ysize-nYSize) > 1e-8 )
4301 : {
4302 1 : sExtraArg.bFloatingPointWindowValidity = TRUE;
4303 1 : sExtraArg.dfXOff = xoff;
4304 1 : sExtraArg.dfYOff = yoff;
4305 1 : sExtraArg.dfXSize = xsize;
4306 1 : sExtraArg.dfYSize = ysize;
4307 : }
4308 :
4309 168 : return GDALDatasetRasterIOEx( ds, (bWrite) ? GF_Write : GF_Read, nXOff, nYOff, nXSize, nYSize,
4310 : PyArray_DATA(psArray), nxsize, nysize,
4311 : buf_type,
4312 : bandcount, pband_list,
4313 : pixel_space, line_space, band_space, &sExtraArg );
4314 : }
4315 :
4316 :
4317 : static int*
4318 103 : CreateCIntListFromSequence( PyObject* pySeq, int* pnSize ) {
4319 : /* check if is List */
4320 103 : if ( !PySequence_Check(pySeq) ) {
4321 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4322 0 : *pnSize = -1;
4323 0 : return NULL;
4324 : }
4325 103 : Py_ssize_t size = PySequence_Size(pySeq);
4326 103 : if( size > (Py_ssize_t)INT_MAX ) {
4327 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4328 0 : *pnSize = -1;
4329 0 : return NULL;
4330 : }
4331 103 : if( (size_t)size > SIZE_MAX / sizeof(int) ) {
4332 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4333 0 : *pnSize = -1;
4334 0 : return NULL;
4335 : }
4336 103 : *pnSize = (int)size;
4337 103 : int* ret = (int*) malloc((*pnSize)*sizeof(int));
4338 103 : if( !ret ) {
4339 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4340 0 : *pnSize = -1;
4341 0 : return NULL;
4342 : }
4343 485 : for( int i = 0; i<*pnSize; i++ ) {
4344 382 : PyObject *o = PySequence_GetItem(pySeq,i);
4345 382 : if ( !PyArg_Parse(o,"i",&ret[i]) ) {
4346 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4347 0 : Py_DECREF(o);
4348 0 : free(ret);
4349 0 : *pnSize = -1;
4350 0 : return NULL;
4351 : }
4352 382 : Py_DECREF(o);
4353 : }
4354 : return ret;
4355 : }
4356 :
4357 :
4358 84 : static bool CheckNumericDataType(GDALExtendedDataTypeHS* dt)
4359 : {
4360 84 : auto klass = GDALExtendedDataTypeGetClass(dt);
4361 84 : if( klass == GEDTC_NUMERIC )
4362 : return true;
4363 3 : if( klass == GEDTC_STRING )
4364 : return false;
4365 3 : CPLAssert( klass == GEDTC_COMPOUND );
4366 3 : size_t nCount = 0;
4367 3 : GDALEDTComponentH* comps = GDALExtendedDataTypeGetComponents(dt, &nCount);
4368 : bool ret = true;
4369 9 : for( size_t i = 0; i < nCount; i++ )
4370 : {
4371 6 : auto tmpType = GDALEDTComponentGetType(comps[i]);
4372 6 : ret = CheckNumericDataType(tmpType);
4373 6 : GDALExtendedDataTypeRelease(tmpType);
4374 6 : if( !ret )
4375 : break;
4376 : }
4377 3 : GDALExtendedDataTypeFreeComponents(comps, nCount);
4378 : return ret;
4379 : }
4380 :
4381 :
4382 78 : CPLErr MDArrayIONumPy( bool bWrite,
4383 : GDALMDArrayHS* mdarray,
4384 : PyArrayObject *psArray,
4385 : int nDims1, GUIntBig* array_start_idx,
4386 : int nDims3, GIntBig* array_step,
4387 : GDALExtendedDataTypeHS* buffer_datatype) {
4388 :
4389 78 : if( !CheckNumericDataType(buffer_datatype) )
4390 : {
4391 0 : CPLError(CE_Failure, CPLE_NotSupported,
4392 : "String buffer data type not supported in SWIG bindings");
4393 0 : return CE_Failure;
4394 : }
4395 78 : const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(mdarray);
4396 78 : if( PyArray_NDIM(psArray) != nExpectedDims )
4397 : {
4398 0 : CPLError( CE_Failure, CPLE_AppDefined,
4399 : "Illegal numpy array rank %d.",
4400 : PyArray_NDIM(psArray) );
4401 0 : return CE_Failure;
4402 : }
4403 :
4404 156 : std::vector<size_t> count_internal(nExpectedDims+1);
4405 156 : std::vector<GPtrDiff_t> buffer_stride_internal(nExpectedDims+1);
4406 78 : const size_t nDTSize = GDALExtendedDataTypeGetSize(buffer_datatype);
4407 78 : if( nDTSize == 0 )
4408 : {
4409 : return CE_Failure;
4410 : }
4411 196 : for( int i = 0; i < nExpectedDims; i++ )
4412 : {
4413 118 : count_internal[i] = PyArray_DIMS(psArray)[i];
4414 118 : if( (PyArray_STRIDES(psArray)[i] % nDTSize) != 0 )
4415 : {
4416 0 : CPLError( CE_Failure, CPLE_AppDefined,
4417 : "Stride[%d] not a multiple of data type size",
4418 : i );
4419 : return CE_Failure;
4420 : }
4421 118 : buffer_stride_internal[i] = PyArray_STRIDES(psArray)[i] / nDTSize;
4422 : }
4423 :
4424 78 : if( bWrite )
4425 : {
4426 14 : return GDALMDArrayWrite( mdarray,
4427 : array_start_idx,
4428 14 : &count_internal[0],
4429 : array_step,
4430 14 : &buffer_stride_internal[0],
4431 : buffer_datatype,
4432 14 : PyArray_DATA(psArray),
4433 14 : NULL, 0) ? CE_None : CE_Failure;
4434 : }
4435 : else
4436 : {
4437 64 : return GDALMDArrayRead( mdarray,
4438 : array_start_idx,
4439 64 : &count_internal[0],
4440 : array_step,
4441 64 : &buffer_stride_internal[0],
4442 : buffer_datatype,
4443 : PyArray_DATA(psArray),
4444 64 : NULL, 0) ? CE_None : CE_Failure;
4445 : }
4446 : }
4447 :
4448 :
4449 : static GUIntBig*
4450 78 : CreateCGUIntBigListFromSequence( PyObject* pySeq, int* pnSize ) {
4451 : /* check if is List */
4452 78 : if ( !PySequence_Check(pySeq) ) {
4453 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4454 0 : *pnSize = -1;
4455 0 : return NULL;
4456 : }
4457 78 : Py_ssize_t size = PySequence_Size(pySeq);
4458 78 : if( size > (Py_ssize_t)INT_MAX ) {
4459 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4460 0 : *pnSize = -1;
4461 0 : return NULL;
4462 : }
4463 78 : if( (size_t)size > SIZE_MAX / sizeof(GUIntBig) ) {
4464 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4465 0 : *pnSize = -1;
4466 0 : return NULL;
4467 : }
4468 78 : *pnSize = (int)size;
4469 78 : GUIntBig* ret = (GUIntBig*) malloc((*pnSize)*sizeof(GUIntBig));
4470 78 : if( !ret ) {
4471 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4472 0 : *pnSize = -1;
4473 0 : return NULL;
4474 : }
4475 196 : for( int i = 0; i<*pnSize; i++ ) {
4476 118 : PyObject *o = PySequence_GetItem(pySeq,i);
4477 118 : if ( !PyArg_Parse(o,"K",&ret[i]) ) {
4478 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4479 0 : Py_DECREF(o);
4480 0 : free(ret);
4481 0 : *pnSize = -1;
4482 0 : return NULL;
4483 : }
4484 118 : Py_DECREF(o);
4485 : }
4486 : return ret;
4487 : }
4488 :
4489 :
4490 : static GIntBig*
4491 78 : CreateCGIntBigListFromSequence( PyObject* pySeq, int* pnSize ) {
4492 : /* check if is List */
4493 78 : if ( !PySequence_Check(pySeq) ) {
4494 0 : PyErr_SetString(PyExc_TypeError, "not a sequence");
4495 0 : *pnSize = -1;
4496 0 : return NULL;
4497 : }
4498 78 : Py_ssize_t size = PySequence_Size(pySeq);
4499 78 : if( size > (Py_ssize_t)INT_MAX ) {
4500 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4501 0 : *pnSize = -1;
4502 0 : return NULL;
4503 : }
4504 78 : if( (size_t)size > SIZE_MAX / sizeof(GIntBig) ) {
4505 0 : PyErr_SetString(PyExc_RuntimeError, "too big sequence");
4506 0 : *pnSize = -1;
4507 0 : return NULL;
4508 : }
4509 78 : *pnSize = (int)size;
4510 78 : GIntBig* ret = (GIntBig*) malloc((*pnSize)*sizeof(GIntBig));
4511 78 : if( !ret ) {
4512 0 : PyErr_SetString(PyExc_MemoryError, "cannot allocate temporary buffer");
4513 0 : *pnSize = -1;
4514 0 : return NULL;
4515 : }
4516 196 : for( int i = 0; i<*pnSize; i++ ) {
4517 118 : PyObject *o = PySequence_GetItem(pySeq,i);
4518 118 : if ( !PyArg_Parse(o,"L",&ret[i]) ) {
4519 0 : PyErr_SetString(PyExc_TypeError, "not an integer");
4520 0 : Py_DECREF(o);
4521 0 : free(ret);
4522 0 : *pnSize = -1;
4523 0 : return NULL;
4524 : }
4525 118 : Py_DECREF(o);
4526 : }
4527 : return ret;
4528 : }
4529 :
4530 :
4531 : typedef void* VoidPtrAsLong;
4532 :
4533 7724 : static bool AddNumpyArrayToDict(PyObject *dict,
4534 : const struct ArrowSchema* schemaField,
4535 : const struct ArrowArray* arrayField,
4536 : const std::string& osPrefix,
4537 : PyObject* pointerArrayKeeper)
4538 : {
4539 7724 : npy_intp dims = arrayField->length;
4540 7724 : const char* arrowType = schemaField->format;
4541 7724 : int typenum = -1;
4542 7724 : int sizeOfType = 0;
4543 7724 : const struct
4544 : {
4545 : char arrowType;
4546 : int numpyType;
4547 : int sizeOfType;
4548 7724 : } MapArrowTypeToNumpyType[] = {
4549 : { 'b', NPY_BOOL, 1 },
4550 : { 'C', NPY_UINT8, 1 },
4551 : { 'c', NPY_INT8, 1 },
4552 : { 'S', NPY_UINT16, 2 },
4553 : { 's', NPY_INT16, 2 },
4554 : { 'I', NPY_UINT32, 4 },
4555 : { 'i', NPY_INT32, 4 },
4556 : { 'L', NPY_UINT64, 8 },
4557 : { 'l', NPY_INT64, 8 },
4558 : { 'e', NPY_FLOAT16, 2 },
4559 : { 'f', NPY_FLOAT32, 4 },
4560 : { 'g', NPY_FLOAT64, 8 },
4561 : // { 'E', NPY_COMPLEX32, 4 },
4562 : // { 'F', NPY_COMPLEX64, 8 },
4563 : // { 'G', NPY_COMPLEX128, 16 },
4564 : };
4565 7724 : const size_t nEltsInMapArrowTypeToNumpyType =
4566 : sizeof(MapArrowTypeToNumpyType) / sizeof(MapArrowTypeToNumpyType[0]);
4567 17850 : const bool bIsLargeList = (arrowType[0] == '+' &&
4568 2402 : arrowType[1] == 'L' &&
4569 7879 : arrowType[2] == '\0' &&
4570 155 : schemaField->n_children == 1);
4571 17850 : const bool bIsList = (arrowType[0] == '+' &&
4572 2402 : arrowType[1] == 'l' &&
4573 9025 : arrowType[2] == '\0' &&
4574 1301 : schemaField->n_children == 1);
4575 17850 : const bool bIsFixedSizeList = (arrowType[0] == '+' &&
4576 2402 : arrowType[1] == 'w' &&
4577 8504 : arrowType[2] == ':' &&
4578 780 : schemaField->n_children == 1);
4579 73298 : for( size_t j = 0; j < nEltsInMapArrowTypeToNumpyType; ++j )
4580 : {
4581 70188 : if( arrowType[0] == MapArrowTypeToNumpyType[j].arrowType &&
4582 2794 : arrowType[1] == '\0' )
4583 : {
4584 2794 : typenum = MapArrowTypeToNumpyType[j].numpyType;
4585 2794 : sizeOfType = MapArrowTypeToNumpyType[j].sizeOfType;
4586 2794 : break;
4587 : }
4588 67394 : else if( (bIsList || bIsLargeList || bIsFixedSizeList) &&
4589 17245 : schemaField->children[0]->format[0] == MapArrowTypeToNumpyType[j].arrowType &&
4590 1820 : schemaField->children[0]->format[1] == '\0' )
4591 : {
4592 1820 : typenum = MapArrowTypeToNumpyType[j].numpyType;
4593 1820 : sizeOfType = MapArrowTypeToNumpyType[j].sizeOfType;
4594 1820 : break;
4595 : }
4596 : }
4597 :
4598 7724 : PyObject* numpyArray = NULL;
4599 7724 : if( typenum != -1 && !bIsList && !bIsLargeList && schemaField->n_children == 0 )
4600 : {
4601 2794 : if( arrayField->n_buffers != 2 )
4602 : {
4603 0 : CPLError(CE_Failure, CPLE_AppDefined,
4604 : "Field %s: arrayField->n_buffers != 2",
4605 0 : schemaField->name);
4606 0 : return false;
4607 : }
4608 2794 : if( typenum == NPY_BOOL )
4609 : {
4610 157 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_BOOL);
4611 484 : for( npy_intp j = 0; j < dims; j++ )
4612 : {
4613 327 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4614 327 : uint8_t val = (((uint8_t*)arrayField->buffers[1])[srcOffset/8] >> (srcOffset % 8)) & 1;
4615 327 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) = val;
4616 : }
4617 : }
4618 : else
4619 : {
4620 2637 : numpyArray = PyArray_SimpleNewFromData(1, &dims, typenum,
4621 : (char*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset) * sizeOfType);
4622 :
4623 : /* Keep a reference to the owner object */
4624 : #if NPY_API_VERSION >= 0x00000007
4625 2637 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
4626 : #else
4627 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
4628 : #endif
4629 2637 : Py_INCREF(pointerArrayKeeper);
4630 : }
4631 : }
4632 4930 : else if( typenum != -1 && (bIsList || bIsLargeList) )
4633 : {
4634 1105 : if( arrayField->n_buffers != 2 )
4635 : {
4636 0 : CPLError(CE_Failure, CPLE_AppDefined,
4637 : "Field %s: arrayField->n_buffers != 2",
4638 0 : schemaField->name);
4639 0 : return false;
4640 : }
4641 1105 : if( arrayField->n_children != 1 )
4642 : {
4643 0 : CPLError(CE_Failure, CPLE_AppDefined,
4644 : "Field %s: arrayField->n_children != 1",
4645 0 : schemaField->name);
4646 0 : return false;
4647 : }
4648 1105 : if( arrayField->children[0]->n_buffers != 2 )
4649 : {
4650 0 : CPLError(CE_Failure, CPLE_AppDefined,
4651 : "Field %s: arrayField->children[0]->n_buffers != 2",
4652 0 : schemaField->name);
4653 0 : return false;
4654 : }
4655 1105 : const int32_t* offsets = bIsList ? (const int32_t*)arrayField->buffers[1] + arrayField->offset : NULL;
4656 1105 : const int64_t* largeOffsets = bIsLargeList ? (const int64_t*)arrayField->buffers[1] + arrayField->offset : NULL;
4657 1105 : if( arrayField->children[0]->length < (offsets ? offsets[arrayField->length] : largeOffsets[arrayField->length]) )
4658 : {
4659 0 : CPLError(CE_Failure, CPLE_AppDefined,
4660 : "Field %s: arrayField->children[0]->length (=%d) < offsets[arrayField->length] (=%d)",
4661 0 : schemaField->name,
4662 : int(arrayField->children[0]->length),
4663 0 : int(offsets ? offsets[arrayField->length] : largeOffsets[arrayField->length]));
4664 0 : return false;
4665 : }
4666 1105 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4667 3212 : for( npy_intp j = 0; j < dims; j++ )
4668 : {
4669 2107 : npy_intp nvalues = offsets ? offsets[j+1] - offsets[j] : (npy_intp)(largeOffsets[j+1] - largeOffsets[j]);
4670 2107 : PyObject* subObj;
4671 2107 : if( typenum == NPY_BOOL )
4672 : {
4673 224 : subObj = PyArray_SimpleNew(1, &nvalues, NPY_BOOL);
4674 660 : for( npy_intp k = 0; k < nvalues; k++ )
4675 : {
4676 436 : size_t srcOffset = static_cast<size_t>(arrayField->children[0]->offset + (offsets ? offsets[j] : largeOffsets[j]) + k);
4677 436 : uint8_t val = (((uint8_t*)arrayField->children[0]->buffers[1])[srcOffset / 8] >> (srcOffset % 8)) & 1;
4678 436 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) subObj, k) = val;
4679 : }
4680 : }
4681 : else
4682 : {
4683 1883 : subObj = PyArray_SimpleNewFromData(
4684 : 1, &nvalues, typenum,
4685 : (char*)arrayField->children[0]->buffers[1] + (static_cast<size_t>(arrayField->children[0]->offset) + (offsets ? offsets[j] : largeOffsets[j])) * sizeOfType);
4686 : /* Keep a reference to the owner object */
4687 : #if NPY_API_VERSION >= 0x00000007
4688 1883 : PyArray_SetBaseObject((PyArrayObject *) subObj, pointerArrayKeeper);
4689 : #else
4690 : PyArray_BASE((PyArrayObject *) subObj) = pointerArrayKeeper;
4691 : #endif
4692 1883 : Py_INCREF(pointerArrayKeeper);
4693 : }
4694 2107 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4695 : &subObj,
4696 : sizeof(PyObject*));
4697 : }
4698 : }
4699 3825 : else if( typenum != -1 && bIsFixedSizeList )
4700 : {
4701 715 : if( arrayField->n_buffers != 1 )
4702 : {
4703 0 : CPLError(CE_Failure, CPLE_AppDefined,
4704 : "Field %s: arrayField->n_buffers != 1",
4705 0 : schemaField->name);
4706 0 : return false;
4707 : }
4708 715 : if( arrayField->n_children != 1 )
4709 : {
4710 0 : CPLError(CE_Failure, CPLE_AppDefined,
4711 : "Field %s: arrayField->n_children != 1",
4712 0 : schemaField->name);
4713 0 : return false;
4714 : }
4715 715 : const struct ArrowArray* psChildArray = arrayField->children[0];
4716 715 : if( psChildArray->n_buffers != 2 )
4717 : {
4718 0 : CPLError(CE_Failure, CPLE_AppDefined,
4719 : "Field %s: psChildArray->n_buffers != 2",
4720 0 : schemaField->name);
4721 0 : return false;
4722 : }
4723 715 : const int nLength = atoi(arrowType + strlen("+w:"));
4724 715 : if( psChildArray->length < nLength * arrayField->length )
4725 : {
4726 0 : CPLError(CE_Failure, CPLE_AppDefined,
4727 : "Field %s: psChildArray->length < nLength * arrayField->length",
4728 0 : schemaField->name);
4729 0 : return false;
4730 : }
4731 715 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4732 1936 : for( npy_intp j = 0; j < dims; j++ )
4733 : {
4734 1221 : PyObject* subObj;
4735 1221 : npy_intp nvalues = nLength;
4736 1221 : if( typenum == NPY_BOOL )
4737 : {
4738 111 : subObj = PyArray_SimpleNew(1, &nvalues, NPY_BOOL);
4739 333 : for( npy_intp k = 0; k < nvalues; k++ )
4740 : {
4741 222 : size_t srcOffset = static_cast<size_t>(psChildArray->offset + (j + arrayField->offset) * nLength + k);
4742 222 : uint8_t val = (((uint8_t*)psChildArray->buffers[1])[srcOffset / 8] >> (srcOffset % 8)) & 1;
4743 222 : *(uint8_t*)PyArray_GETPTR1((PyArrayObject *) subObj, k) = val;
4744 : }
4745 : }
4746 : else
4747 : {
4748 1110 : subObj = PyArray_SimpleNewFromData(
4749 : 1, &nvalues, typenum,
4750 : (char*)psChildArray->buffers[1] + static_cast<size_t>((psChildArray->offset + (j + arrayField->offset) * nLength) * sizeOfType));
4751 : /* Keep a reference to the owner object */
4752 : #if NPY_API_VERSION >= 0x00000007
4753 1110 : PyArray_SetBaseObject((PyArrayObject *) subObj, pointerArrayKeeper);
4754 : #else
4755 : PyArray_BASE((PyArrayObject *) subObj) = pointerArrayKeeper;
4756 : #endif
4757 1110 : Py_INCREF(pointerArrayKeeper);
4758 : }
4759 1221 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4760 : &subObj,
4761 : sizeof(PyObject*));
4762 : }
4763 : }
4764 3110 : else if( (arrowType[0] == 'u' || /* string */
4765 1285 : arrowType[0] == 'z' /* binary */) && arrowType[1] == '\0' &&
4766 1285 : schemaField->n_children == 0 )
4767 : {
4768 1285 : if( arrayField->n_buffers != 3 )
4769 : {
4770 0 : CPLError(CE_Failure, CPLE_AppDefined,
4771 : "Field %s: arrayField->n_buffers != 3",
4772 0 : schemaField->name);
4773 0 : return false;
4774 : }
4775 1285 : const int32_t* offsets = (const int32_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
4776 : // numpy can't deal with zero length strings
4777 1285 : int32_t maxLength = 1;
4778 1285 : int32_t minLength = 0x7FFFFFFF;
4779 1285 : int64_t averageLength = 0;
4780 8295 : for( npy_intp j = 0; j < dims; j++ )
4781 : {
4782 7010 : const int32_t nLength = offsets[j+1] - offsets[j];
4783 7010 : if( nLength < minLength )
4784 : minLength = nLength;
4785 7010 : if( nLength > maxLength )
4786 : maxLength = nLength;
4787 7010 : averageLength += nLength;
4788 : }
4789 1285 : if( dims )
4790 1285 : averageLength /= dims;
4791 :
4792 :
4793 1285 : if( arrowType[0] == 'z' && (minLength == 0 || minLength != maxLength) )
4794 : {
4795 816 : const uint8_t* panNotNulls =
4796 408 : arrayField->null_count == 0 ? NULL :
4797 : (const uint8_t*)arrayField->buffers[0];
4798 408 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4799 1417 : for( npy_intp j = 0; j < dims; j++ )
4800 : {
4801 1009 : PyObject* subObj;
4802 1009 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4803 1009 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4804 : {
4805 827 : subObj = Py_None;
4806 827 : Py_INCREF(subObj);
4807 : }
4808 : else
4809 : {
4810 182 : const int32_t nLength = offsets[j+1] - offsets[j];
4811 182 : subObj = PyBytes_FromStringAndSize(
4812 182 : ((const char*)arrayField->buffers[2]) + offsets[j],
4813 : nLength);
4814 : }
4815 1009 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4816 : &subObj,
4817 : sizeof(PyObject*));
4818 : }
4819 : }
4820 877 : else if( arrowType[0] == 'u' && dims > 0 && maxLength > 32 &&
4821 69 : maxLength > 100 * 1000 / dims &&
4822 1 : maxLength > averageLength * 2 )
4823 : {
4824 : // If the maximum string size is significantly large, and
4825 : // larger than the average one, then do not use fixed size
4826 : // strings, but create an array of string objects to save memory
4827 2 : const uint8_t* panNotNulls =
4828 1 : arrayField->null_count == 0 ? NULL :
4829 : (const uint8_t*)arrayField->buffers[0];
4830 1 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4831 4 : for( npy_intp j = 0; j < dims; j++ )
4832 : {
4833 3 : PyObject* subObj;
4834 3 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4835 3 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4836 : {
4837 1 : subObj = Py_None;
4838 1 : Py_INCREF(subObj);
4839 : }
4840 : else
4841 : {
4842 2 : const int32_t nLength = offsets[j+1] - offsets[j];
4843 2 : subObj = PyUnicode_FromStringAndSize(
4844 2 : ((const char*)arrayField->buffers[2]) + offsets[j],
4845 : nLength);
4846 : }
4847 3 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4848 : &subObj,
4849 : sizeof(PyObject*));
4850 : }
4851 : }
4852 : else
4853 : {
4854 : // create the dtype string
4855 1219 : PyObject *pDTypeString = PyUnicode_FromFormat("%c%u",
4856 : arrowType[0] == 'u' ? 'S' : 'V', maxLength);
4857 : // out type description object
4858 876 : PyArray_Descr *pDescr = NULL;
4859 876 : PyArray_DescrConverter(pDTypeString, &pDescr);
4860 876 : Py_DECREF(pDTypeString);
4861 :
4862 876 : if( minLength == maxLength )
4863 : {
4864 1070 : numpyArray = PyArray_NewFromDescr(
4865 : &PyArray_Type, pDescr, 1, &dims, NULL,
4866 535 : (char*)arrayField->buffers[2] + offsets[0], 0, NULL);
4867 :
4868 : /* Keep a reference to the owner object */
4869 : #if NPY_API_VERSION >= 0x00000007
4870 535 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
4871 : #else
4872 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
4873 : #endif
4874 535 : Py_INCREF(pointerArrayKeeper);
4875 : }
4876 : else
4877 : {
4878 : // create array
4879 341 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
4880 1308 : for( npy_intp j = 0; j < dims; j++ )
4881 : {
4882 967 : const int32_t nLength = offsets[j+1] - offsets[j];
4883 967 : if( nLength > 0 )
4884 : {
4885 1453 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4886 486 : ((const char*)arrayField->buffers[2]) + offsets[j],
4887 : nLength);
4888 : }
4889 967 : if( nLength < maxLength )
4890 : {
4891 967 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j)) + nLength,
4892 : 0,
4893 803 : maxLength - nLength);
4894 : }
4895 : }
4896 : }
4897 : }
4898 : }
4899 1825 : else if( (arrowType[0] == 'U' || /* string */
4900 228 : arrowType[0] == 'Z' /* binary */) && arrowType[1] == '\0' &&
4901 228 : schemaField->n_children == 0 )
4902 : {
4903 228 : if( arrayField->n_buffers != 3 )
4904 : {
4905 0 : CPLError(CE_Failure, CPLE_AppDefined,
4906 : "Field %s: arrayField->n_buffers != 3",
4907 0 : schemaField->name);
4908 0 : return false;
4909 : }
4910 228 : const int64_t* offsets = (const int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
4911 : // numpy can't deal with zero length strings
4912 228 : int64_t maxLength = 1;
4913 228 : int64_t minLength = ((int64_t)0x7FFFFFFF << 32) | 0xFFFFFFFF;
4914 228 : int64_t averageLength = 0;
4915 634 : for( npy_intp j = 0; j < dims; j++ )
4916 : {
4917 406 : const int64_t nLength = offsets[j+1] - offsets[j];
4918 406 : if( nLength < minLength )
4919 : minLength = nLength;
4920 406 : if( nLength > maxLength )
4921 : maxLength = nLength;
4922 406 : averageLength += nLength;
4923 : }
4924 228 : if( dims )
4925 208 : averageLength /= dims;
4926 :
4927 228 : if( arrowType[0] == 'Z' && (minLength == 0 || minLength != maxLength || maxLength > 0x7FFFFFFF) )
4928 : {
4929 90 : const uint8_t* panNotNulls =
4930 45 : arrayField->null_count == 0 ? NULL :
4931 : (const uint8_t*)arrayField->buffers[0];
4932 45 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4933 141 : for( npy_intp j = 0; j < dims; j++ )
4934 : {
4935 96 : PyObject* subObj;
4936 96 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4937 96 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4938 : {
4939 8 : subObj = Py_None;
4940 8 : Py_INCREF(subObj);
4941 : }
4942 : else
4943 : {
4944 88 : const int64_t nLength = offsets[j+1] - offsets[j];
4945 88 : subObj = PyBytes_FromStringAndSize(
4946 88 : ((const char*)arrayField->buffers[2]) + offsets[j],
4947 : static_cast<size_t>(nLength));
4948 : }
4949 96 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4950 : &subObj,
4951 : sizeof(PyObject*));
4952 : }
4953 : }
4954 183 : else if( arrowType[0] == 'U' && dims > 0 && maxLength > 32 &&
4955 0 : maxLength <= 0x7FFFFFFF &&
4956 0 : maxLength > 100 * 1000 / dims &&
4957 0 : maxLength > averageLength * 2 )
4958 : {
4959 : // If the maximum string size is significantly large, and
4960 : // larger than the average one, then do not use fixed size
4961 : // strings, but create an array of string objects to save memory
4962 0 : const uint8_t* panNotNulls =
4963 0 : arrayField->null_count == 0 ? NULL :
4964 : (const uint8_t*)arrayField->buffers[0];
4965 0 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
4966 0 : for( npy_intp j = 0; j < dims; j++ )
4967 : {
4968 0 : PyObject* subObj;
4969 0 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
4970 0 : if( panNotNulls && (panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0 )
4971 : {
4972 0 : subObj = Py_None;
4973 0 : Py_INCREF(subObj);
4974 : }
4975 : else
4976 : {
4977 0 : const int32_t nLength = int(offsets[j+1] - offsets[j]);
4978 0 : subObj = PyUnicode_FromStringAndSize(
4979 0 : ((const char*)arrayField->buffers[2]) + offsets[j],
4980 : nLength);
4981 : }
4982 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
4983 : &subObj,
4984 : sizeof(PyObject*));
4985 : }
4986 : }
4987 : else
4988 : {
4989 : // We could possibly handle this...
4990 183 : if( maxLength > 0x7FFFFFFF )
4991 : {
4992 0 : CPLError(CE_Failure, CPLE_AppDefined,
4993 : "Field %s: too large value",
4994 0 : schemaField->name);
4995 0 : return false;
4996 : }
4997 :
4998 : // create the dtype string
4999 272 : PyObject *pDTypeString = PyUnicode_FromFormat("%c%u",
5000 : arrowType[0] == 'U' ? 'S' : 'V', static_cast<int32_t>(maxLength));
5001 : // out type description object
5002 183 : PyArray_Descr *pDescr = NULL;
5003 183 : PyArray_DescrConverter(pDTypeString, &pDescr);
5004 183 : Py_DECREF(pDTypeString);
5005 :
5006 183 : if( minLength == maxLength )
5007 : {
5008 262 : numpyArray = PyArray_NewFromDescr(
5009 : &PyArray_Type, pDescr, 1, &dims, NULL,
5010 131 : (char*)arrayField->buffers[2] + offsets[0], 0, NULL);
5011 :
5012 : /* Keep a reference to the owner object */
5013 : #if NPY_API_VERSION >= 0x00000007
5014 131 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
5015 : #else
5016 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
5017 : #endif
5018 131 : Py_INCREF(pointerArrayKeeper);
5019 : }
5020 : else
5021 : {
5022 : // create array
5023 52 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5024 159 : for( npy_intp j = 0; j < dims; j++ )
5025 : {
5026 107 : const int32_t nLength = static_cast<int32_t>(offsets[j+1] - offsets[j]);
5027 107 : if( nLength > 0 )
5028 : {
5029 157 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5030 50 : ((const char*)arrayField->buffers[2]) + offsets[j],
5031 : nLength);
5032 : }
5033 107 : if( nLength < maxLength )
5034 : {
5035 107 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j)) + nLength,
5036 : 0,
5037 74 : static_cast<int32_t>(maxLength) - nLength);
5038 : }
5039 : }
5040 : }
5041 : }
5042 : }
5043 1597 : else if( arrowType[0] == 'w' && arrowType[1] == ':' &&
5044 69 : schemaField->n_children == 0 )
5045 : {
5046 : // Fixed width binary
5047 69 : if( arrayField->n_buffers != 2 )
5048 : {
5049 0 : CPLError(CE_Failure, CPLE_AppDefined,
5050 : "field %s:arrayField->n_buffers != 2",
5051 0 : schemaField->name);
5052 0 : return false;
5053 : }
5054 69 : const int nLength = atoi(arrowType + strlen("w:"));
5055 69 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5056 193 : for( npy_intp j = 0; j < dims; j++ )
5057 : {
5058 124 : PyObject* subObj = PyBytes_FromStringAndSize(
5059 124 : ((const char*)arrayField->buffers[1]) + static_cast<size_t>(arrayField->offset + j) * nLength,
5060 124 : nLength);
5061 124 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5062 : &subObj,
5063 : sizeof(PyObject*));
5064 : }
5065 : }
5066 1528 : else if( bIsList &&
5067 351 : schemaField->children[0]->format[0] == 'u' &&
5068 91 : schemaField->children[0]->format[1] == '\0' )
5069 : {
5070 : // List of strings
5071 91 : if( arrayField->n_buffers != 2 )
5072 : {
5073 0 : CPLError(CE_Failure, CPLE_AppDefined,
5074 : "Field %s: arrayField->n_buffers != 2",
5075 0 : schemaField->name);
5076 0 : return false;
5077 : }
5078 91 : if( arrayField->n_children != 1 )
5079 : {
5080 0 : CPLError(CE_Failure, CPLE_AppDefined,
5081 : "Field %s: arrayField->n_children != 1",
5082 0 : schemaField->name);
5083 0 : return false;
5084 : }
5085 91 : if( arrayField->children[0]->n_buffers != 3 )
5086 : {
5087 0 : CPLError(CE_Failure, CPLE_AppDefined,
5088 : "Field %s: arrayField->children[0]->n_buffers != 3",
5089 0 : schemaField->name);
5090 0 : return false;
5091 : }
5092 91 : const int32_t* offsets = (const int32_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
5093 91 : if( arrayField->children[0]->length < offsets[arrayField->length] )
5094 : {
5095 0 : CPLError(CE_Failure, CPLE_AppDefined,
5096 : "Field %s: arrayField->children[0]->length = (%d) < offsets[arrayField->length] (=%d)",
5097 0 : schemaField->name,
5098 : int(arrayField->children[0]->length),
5099 : int(offsets[arrayField->length]));
5100 0 : return false;
5101 : }
5102 91 : const int32_t* offsetsToBytes = (const int32_t*)arrayField->children[0]->buffers[1] + static_cast<size_t>(arrayField->children[0]->offset);
5103 91 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5104 91 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5105 263 : for( npy_intp j = 0; j < dims; j++ )
5106 : {
5107 172 : npy_intp nStrings = offsets[j+1] - offsets[j];
5108 172 : int32_t maxLength = 1;
5109 352 : for( npy_intp k = 0; k < nStrings; k++ )
5110 : {
5111 180 : const int32_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5112 180 : if( nLength > maxLength )
5113 : maxLength = nLength;
5114 : }
5115 :
5116 : // create the dtype string
5117 172 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", maxLength);
5118 : // out type description object
5119 172 : PyArray_Descr *pDescr = NULL;
5120 172 : PyArray_DescrConverter(pDTypeString, &pDescr);
5121 172 : Py_DECREF(pDTypeString);
5122 :
5123 172 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStrings, pDescr);
5124 352 : for( npy_intp k = 0; k < nStrings; k++ )
5125 : {
5126 180 : const int32_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5127 180 : if( nLength > 0 )
5128 : {
5129 333 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5130 153 : bytes + offsetsToBytes[offsets[j] + k],
5131 : nLength);
5132 : }
5133 180 : if( nLength < maxLength )
5134 : {
5135 180 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5136 : 0,
5137 90 : maxLength - nLength);
5138 : }
5139 : }
5140 :
5141 172 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5142 : &subArray,
5143 : sizeof(PyObject*));
5144 : }
5145 : }
5146 1437 : else if( bIsLargeList &&
5147 0 : schemaField->children[0]->format[0] == 'U' &&
5148 0 : schemaField->children[0]->format[1] == '\0' )
5149 : {
5150 : // List of strings
5151 0 : if( arrayField->n_buffers != 2 )
5152 : {
5153 0 : CPLError(CE_Failure, CPLE_AppDefined,
5154 : "Field %s: arrayField->n_buffers != 2",
5155 0 : schemaField->name);
5156 0 : return false;
5157 : }
5158 0 : if( arrayField->n_children != 1 )
5159 : {
5160 0 : CPLError(CE_Failure, CPLE_AppDefined,
5161 : "Field %s: arrayField->n_children != 1",
5162 0 : schemaField->name);
5163 0 : return false;
5164 : }
5165 0 : if( arrayField->children[0]->n_buffers != 3 )
5166 : {
5167 0 : CPLError(CE_Failure, CPLE_AppDefined,
5168 : "Field %s: arrayField->children[0]->n_buffers != 3",
5169 0 : schemaField->name);
5170 0 : return false;
5171 : }
5172 0 : const int64_t* offsets = (const int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset);
5173 0 : if( arrayField->children[0]->length < offsets[arrayField->length] )
5174 : {
5175 0 : CPLError(CE_Failure, CPLE_AppDefined,
5176 : "Field %s: arrayField->children[0]->length = (%d) < offsets[arrayField->length] (=%d)",
5177 0 : schemaField->name,
5178 : int(arrayField->children[0]->length),
5179 : int(offsets[arrayField->length]));
5180 0 : return false;
5181 : }
5182 0 : const int64_t* offsetsToBytes = (const int64_t*)arrayField->children[0]->buffers[1] + static_cast<size_t>(arrayField->children[0]->offset);
5183 0 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5184 0 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5185 0 : for( npy_intp j = 0; j < dims; j++ )
5186 : {
5187 0 : npy_intp nStrings = offsets[j+1] - offsets[j];
5188 0 : int64_t maxLength = 1;
5189 0 : for( npy_intp k = 0; k < nStrings; k++ )
5190 : {
5191 0 : const int64_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5192 0 : if( nLength > maxLength )
5193 : maxLength = nLength;
5194 : }
5195 0 : if( maxLength >= INT_MAX )
5196 : {
5197 0 : CPLError(CE_Failure, CPLE_AppDefined, "Too large string");
5198 0 : return false;
5199 : }
5200 :
5201 : // create the dtype string
5202 0 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", int(maxLength));
5203 : // out type description object
5204 0 : PyArray_Descr *pDescr = NULL;
5205 0 : PyArray_DescrConverter(pDTypeString, &pDescr);
5206 0 : Py_DECREF(pDTypeString);
5207 :
5208 0 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStrings, pDescr);
5209 0 : for( npy_intp k = 0; k < nStrings; k++ )
5210 : {
5211 0 : const int64_t nLength = offsetsToBytes[offsets[j] + k + 1] - offsetsToBytes[offsets[j] + k];
5212 0 : if( nLength > 0 )
5213 : {
5214 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5215 0 : bytes + offsetsToBytes[offsets[j] + k],
5216 : int(nLength));
5217 : }
5218 0 : if( nLength < maxLength )
5219 : {
5220 0 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5221 : 0,
5222 0 : int(maxLength - nLength));
5223 : }
5224 : }
5225 :
5226 0 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5227 : &subArray,
5228 : sizeof(PyObject*));
5229 : }
5230 : }
5231 1437 : else if( bIsFixedSizeList &&
5232 65 : schemaField->children[0]->format[0] == 'u' &&
5233 65 : schemaField->children[0]->format[1] == '\0' )
5234 : {
5235 : // Fixed size list of strings
5236 65 : const int nStrings = atoi(arrowType + strlen("+w:"));
5237 65 : if( arrayField->n_buffers != 1 )
5238 : {
5239 0 : CPLError(CE_Failure, CPLE_AppDefined,
5240 : "Field %s: arrayField->n_buffers != 1",
5241 0 : schemaField->name);
5242 0 : return false;
5243 : }
5244 65 : if( arrayField->n_children != 1 )
5245 : {
5246 0 : CPLError(CE_Failure, CPLE_AppDefined,
5247 : "Field %s: arrayField->n_children != 1",
5248 0 : schemaField->name);
5249 0 : return false;
5250 : }
5251 65 : if( arrayField->children[0]->n_buffers != 3 )
5252 : {
5253 0 : CPLError(CE_Failure, CPLE_AppDefined,
5254 : "Field %s: arrayField->children[0]->n_buffers != 3",
5255 0 : schemaField->name);
5256 0 : return false;
5257 : }
5258 65 : if( arrayField->children[0]->length < nStrings * arrayField->length )
5259 : {
5260 0 : CPLError(CE_Failure, CPLE_AppDefined,
5261 : "Field %s: arrayField->children[0]->length < nStrings * arrayField->length",
5262 0 : schemaField->name);
5263 0 : return false;
5264 : }
5265 65 : const int32_t* offsetsToBytes = (const int32_t*)arrayField->children[0]->buffers[1] + arrayField->offset * nStrings + static_cast<size_t>(arrayField->children[0]->offset);
5266 65 : const char* bytes = (const char*)arrayField->children[0]->buffers[2];
5267 65 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5268 176 : for( npy_intp j = 0; j < dims; j++ )
5269 : {
5270 : int32_t maxLength = 1;
5271 333 : for( int k = 0; k < nStrings; k++ )
5272 : {
5273 222 : const int32_t nLength = offsetsToBytes[j * nStrings + k + 1] - offsetsToBytes[j * nStrings + k];
5274 222 : if( nLength > maxLength )
5275 : maxLength = nLength;
5276 : }
5277 :
5278 : // create the dtype string
5279 111 : PyObject *pDTypeString = PyUnicode_FromFormat("S%u", maxLength);
5280 : // out type description object
5281 111 : PyArray_Descr *pDescr = NULL;
5282 111 : PyArray_DescrConverter(pDTypeString, &pDescr);
5283 111 : Py_DECREF(pDTypeString);
5284 :
5285 111 : npy_intp nStringsNpyIntp = nStrings;
5286 111 : PyObject* subArray = PyArray_SimpleNewFromDescr(1, &nStringsNpyIntp, pDescr);
5287 333 : for( int k = 0; k < nStrings; k++ )
5288 : {
5289 222 : const int32_t nLength = offsetsToBytes[j * nStrings + k + 1] - offsetsToBytes[j * nStrings + k];
5290 222 : if( nLength > 0 )
5291 : {
5292 444 : memcpy(PyArray_GETPTR1((PyArrayObject *) subArray, k),
5293 222 : bytes + offsetsToBytes[j * nStrings + k],
5294 : nLength);
5295 : }
5296 222 : if( nLength < maxLength )
5297 : {
5298 222 : memset(((char*)PyArray_GETPTR1((PyArrayObject *) subArray, k)) + nLength,
5299 : 0,
5300 0 : maxLength - nLength);
5301 : }
5302 : }
5303 :
5304 111 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5305 : &subArray,
5306 : sizeof(PyObject*));
5307 : }
5308 : }
5309 1372 : else if( strcmp(arrowType, "tdD") == 0 &&
5310 205 : schemaField->n_children == 0 )
5311 : {
5312 : // Date(32) in days since Epoch
5313 205 : if( arrayField->n_buffers != 2 )
5314 : {
5315 0 : CPLError(CE_Failure, CPLE_AppDefined,
5316 : "Field %s: arrayField->n_buffers != 2",
5317 0 : schemaField->name);
5318 0 : return false;
5319 : }
5320 :
5321 : // create the dtype string
5322 205 : PyObject *pDTypeString = PyUnicode_FromString("datetime64[D]");
5323 : // out type description object
5324 205 : PyArray_Descr *pDescr = NULL;
5325 205 : PyArray_DescrConverter(pDTypeString, &pDescr);
5326 205 : Py_DECREF(pDTypeString);
5327 205 : CPLAssert(pDescr);
5328 :
5329 : // create array
5330 205 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5331 569 : for( npy_intp j = 0; j < dims; j++ )
5332 : {
5333 364 : *(int64_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) =
5334 364 : ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5335 205 : }
5336 : }
5337 1167 : else if( strcmp(arrowType, "ttm") == 0 &&
5338 185 : schemaField->n_children == 0 )
5339 : {
5340 : // Time(32) in milliseconds
5341 185 : if( arrayField->n_buffers != 2 )
5342 : {
5343 0 : CPLError(CE_Failure, CPLE_AppDefined,
5344 : "Field %s: arrayField->n_buffers != 2",
5345 0 : schemaField->name);
5346 0 : return false;
5347 : }
5348 : #if 0
5349 : // create the dtype string
5350 : PyObject *pDTypeString = PyUnicode_FromString("datetime64[ms]");
5351 : // out type description object
5352 : PyArray_Descr *pDescr = NULL;
5353 : PyArray_DescrConverter(pDTypeString, &pDescr);
5354 : Py_DECREF(pDTypeString);
5355 : CPLAssert(pDescr);
5356 :
5357 : // create array
5358 : numpyArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5359 : for( npy_intp j = 0; j < dims; j++ )
5360 : {
5361 : *(int64_t*)PyArray_GETPTR1((PyArrayObject *) numpyArray, j) =
5362 : ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5363 : }
5364 : #else
5365 : // create array
5366 185 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5367 520 : for( npy_intp j = 0; j < dims; j++ )
5368 : {
5369 335 : int timeMs = ((int*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5370 335 : PyObject* subObj = PyTime_FromTime((timeMs / 1000) / 3600,
5371 : ((timeMs / 1000) % 3600) / 60,
5372 : ((timeMs / 1000) % 3600) % 60,
5373 : (timeMs % 1000) * 1000);
5374 335 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5375 : &subObj,
5376 : sizeof(PyObject*));
5377 : }
5378 : #endif
5379 : }
5380 982 : else if( strcmp(arrowType, "ttu") == 0 &&
5381 65 : schemaField->n_children == 0 )
5382 : {
5383 : // Time(64) in microseconds
5384 65 : if( arrayField->n_buffers != 2 )
5385 : {
5386 0 : CPLError(CE_Failure, CPLE_AppDefined,
5387 : "Field %s: arrayField->n_buffers != 2",
5388 0 : schemaField->name);
5389 0 : return false;
5390 : }
5391 :
5392 : // create array
5393 65 : numpyArray = PyArray_SimpleNew(1, &dims, NPY_OBJECT);
5394 176 : for( npy_intp j = 0; j < dims; j++ )
5395 : {
5396 111 : const int64_t timeUs = ((int64_t*)arrayField->buffers[1])[j + static_cast<size_t>(arrayField->offset)];
5397 111 : PyObject* subObj = PyTime_FromTime(static_cast<int>((timeUs / 1000000) / 3600),
5398 : static_cast<int>(((timeUs / 1000000) % 3600) / 60),
5399 : static_cast<int>(((timeUs / 1000000) % 3600) % 60),
5400 : static_cast<int>(timeUs % 1000000));
5401 111 : memcpy(PyArray_GETPTR1((PyArrayObject *) numpyArray, j),
5402 : &subObj,
5403 : sizeof(PyObject*));
5404 : }
5405 : }
5406 917 : else if( (strncmp(arrowType, "tsm:", 4) == 0 || // DateTime in milliseconds
5407 562 : strncmp(arrowType, "tsu:", 4) == 0 || // DateTime in microseconds
5408 432 : strncmp(arrowType, "tsn:", 4) == 0) && // DateTime in nanoseconds
5409 485 : schemaField->n_children == 0 )
5410 : {
5411 : // DateTime(64)
5412 485 : if( arrayField->n_buffers != 2 )
5413 : {
5414 0 : CPLError(CE_Failure, CPLE_AppDefined,
5415 : "Field %s: arrayField->n_buffers != 2",
5416 0 : schemaField->name);
5417 0 : return false;
5418 : }
5419 :
5420 : // create the dtype string
5421 615 : PyObject *pDTypeString = PyUnicode_FromString(
5422 : strncmp(arrowType, "tsm:", 4) == 0 ? "datetime64[ms]" :
5423 130 : strncmp(arrowType, "tsu:", 4) == 0 ? "datetime64[us]" :
5424 : "datetime64[ns]");
5425 : // out type description object
5426 485 : PyArray_Descr *pDescr = NULL;
5427 485 : PyArray_DescrConverter(pDTypeString, &pDescr);
5428 485 : Py_DECREF(pDTypeString);
5429 485 : CPLAssert(pDescr);
5430 :
5431 : // create array
5432 970 : numpyArray = PyArray_NewFromDescr(
5433 : &PyArray_Type, pDescr, 1, &dims, NULL,
5434 485 : (int64_t*)arrayField->buffers[1] + static_cast<size_t>(arrayField->offset), 0, NULL);
5435 :
5436 : /* Keep a reference to the owner object */
5437 : #if NPY_API_VERSION >= 0x00000007
5438 485 : PyArray_SetBaseObject((PyArrayObject *) numpyArray, pointerArrayKeeper);
5439 : #else
5440 : PyArray_BASE((PyArrayObject *) numpyArray) = pointerArrayKeeper;
5441 : #endif
5442 485 : Py_INCREF(pointerArrayKeeper);
5443 : }
5444 432 : else if( strcmp(arrowType, "+s") == 0 )
5445 : {
5446 585 : for( int iField = 0; iField < arrayField->n_children; iField++ )
5447 : {
5448 455 : const struct ArrowArray* childArray = arrayField ->children[iField];
5449 455 : const struct ArrowSchema* childSchema = schemaField->children[iField];
5450 :
5451 455 : if( !AddNumpyArrayToDict(dict, childSchema, childArray,
5452 910 : osPrefix + schemaField->name + ".",
5453 : pointerArrayKeeper) )
5454 : {
5455 : return false;
5456 : }
5457 : }
5458 : }
5459 : else
5460 : {
5461 302 : if( strcmp(arrowType, "+l") == 0 || strcmp(arrowType, "+L") == 0 )
5462 : {
5463 260 : CPLError(CE_Warning, CPLE_AppDefined,
5464 : "Field %s: Unhandled arrow type: %s %s",
5465 0 : (osPrefix + schemaField->name).c_str(),
5466 260 : arrowType, schemaField->children[0]->format);
5467 : }
5468 : else
5469 : {
5470 42 : CPLError(CE_Warning, CPLE_AppDefined,
5471 : "Field %s: Unhandled arrow type: %s",
5472 42 : (osPrefix + schemaField->name).c_str(),
5473 : arrowType);
5474 : }
5475 : }
5476 :
5477 7724 : if( numpyArray )
5478 : {
5479 7292 : const uint8_t* panNotNulls = (const uint8_t*)arrayField->buffers[0];
5480 7292 : if( panNotNulls && arrayField->null_count != 0 )
5481 : {
5482 2950 : PyObject* maskArray = PyArray_SimpleNew(1, &dims, NPY_BOOL);
5483 8625 : for( npy_intp j = 0; j < dims; j++ )
5484 : {
5485 5675 : size_t srcOffset = static_cast<size_t>(arrayField->offset + j);
5486 : // Inverse convention between arrow not-null bitmap, where
5487 : // 1 means valid, and numpy masks where 1 means invalid
5488 5675 : *(char*)PyArray_GETPTR1((PyArrayObject *) maskArray, j) =
5489 5675 : ((panNotNulls[srcOffset / 8] & (1 << (srcOffset%8))) == 0) ? 1 : 0;
5490 : }
5491 2950 : PyObject *subdict = PyDict_New();
5492 2950 : PyDict_SetItemString( subdict, "mask", maskArray );
5493 2950 : PyDict_SetItemString( subdict, "data", numpyArray );
5494 2950 : PyDict_SetItemString( dict, (osPrefix + schemaField->name).c_str(), subdict);
5495 2950 : Py_DECREF(maskArray);
5496 2950 : Py_DECREF(subdict);
5497 : }
5498 : else
5499 : {
5500 8684 : PyDict_SetItemString( dict, (osPrefix + schemaField->name).c_str(), numpyArray );
5501 : }
5502 7724 : Py_DECREF(numpyArray);
5503 : }
5504 :
5505 : return true;
5506 : }
5507 :
5508 : /* Internal method used by ogr.Layer.GetNextRecordBatchAsNumpy() */
5509 475 : PyObject* _RecordBatchAsNumpy(VoidPtrAsLong recordBatchPtr,
5510 : VoidPtrAsLong schemaPtr,
5511 : PyObject* pointerArrayKeeper)
5512 : {
5513 475 : const struct ArrowSchema* schema = (const struct ArrowSchema* )schemaPtr;
5514 475 : const struct ArrowArray* array = (const struct ArrowArray* )recordBatchPtr;
5515 475 : if( strcmp(schema->format, "+s") != 0 )
5516 : {
5517 0 : CPLError(CE_Failure, CPLE_AppDefined, "schema->format != '+s'");
5518 0 : Py_RETURN_NONE;
5519 : }
5520 475 : if( schema->n_children != array->n_children )
5521 : {
5522 0 : CPLError(CE_Failure, CPLE_AppDefined,
5523 : "schema->n_children(=%d) != array->n_children(=%d)",
5524 : static_cast<int>(schema->n_children),
5525 : static_cast<int>(array->n_children));
5526 0 : Py_RETURN_NONE;
5527 : }
5528 475 : PyObject *dict = PyDict_New();
5529 7744 : for( int iField = 0; iField < array->n_children; iField++ )
5530 : {
5531 7269 : const struct ArrowArray* childArray = array->children[iField];
5532 7269 : const struct ArrowSchema* childSchema = schema->children[iField];
5533 :
5534 7269 : if( !AddNumpyArrayToDict(dict, childSchema, childArray, std::string(), pointerArrayKeeper) )
5535 : {
5536 0 : Py_DECREF(dict);
5537 0 : Py_RETURN_NONE;
5538 : }
5539 : }
5540 : return dict;
5541 : }
5542 :
5543 :
5544 :
5545 : SWIGINTERNINLINE PyObject*
5546 0 : SWIG_From_bool (bool value)
5547 : {
5548 0 : return PyBool_FromLong(value ? 1 : 0);
5549 : }
5550 :
5551 :
5552 28 : void VirtualMemGetArray(CPLVirtualMemShadow* virtualmem, CPLVirtualMemShadow** pvirtualmem, int numpytypemap)
5553 : {
5554 28 : *pvirtualmem = virtualmem;
5555 28 : }
5556 :
5557 :
5558 : // need different functions for read and write
5559 : // since reading strings requires us to know the
5560 : // length of the longest string before creating array
5561 13 : CPLErr RATValuesIONumPyWrite( GDALRasterAttributeTableShadow* poRAT, int nField, int nStart,
5562 : PyArrayObject *psArray) {
5563 :
5564 13 : if( PyArray_NDIM(psArray) != 1 )
5565 : {
5566 0 : CPLError( CE_Failure, CPLE_AppDefined,
5567 : "Illegal numpy array rank %d.\n",
5568 : PyArray_NDIM(psArray) );
5569 0 : return CE_Failure;
5570 : }
5571 13 : if( PyArray_DIM(psArray, 0) > INT_MAX )
5572 : {
5573 0 : CPLError( CE_Failure, CPLE_NotSupported,
5574 : "Too big array dimension");
5575 0 : return CE_Failure;
5576 : }
5577 :
5578 13 : int nLength = static_cast<int>(PyArray_DIM(psArray, 0));
5579 13 : int nType = PyArray_TYPE(psArray);
5580 13 : CPLErr retval = CE_None;
5581 :
5582 13 : if( nType == NPY_INT32 )
5583 : {
5584 4 : retval = GDALRATValuesIOAsInteger(poRAT, GF_Write, nField, nStart, nLength,
5585 4 : (int*)PyArray_DATA(psArray) );
5586 : }
5587 9 : else if( nType == NPY_DOUBLE )
5588 : {
5589 4 : retval = GDALRATValuesIOAsDouble(poRAT, GF_Write, nField, nStart, nLength,
5590 4 : (double*)PyArray_DATA(psArray) );
5591 : }
5592 5 : else if( nType == NPY_STRING )
5593 : {
5594 : // max size of string
5595 5 : const size_t nMaxLen = PyArray_ITEMSIZE(psArray);
5596 5 : char *pszBuffer = (char*)VSIMalloc(nMaxLen+1);
5597 5 : if (!pszBuffer)
5598 : {
5599 0 : CPLError( CE_Failure, CPLE_OutOfMemory,
5600 : "Out of memory in RATValuesIONumPyWrite()" );
5601 0 : return CE_Failure;
5602 : }
5603 : // make sure there is a null char on the end
5604 : // as there won't be if this string is the maximum size
5605 5 : pszBuffer[nMaxLen] = '\0';
5606 :
5607 : // have to convert array of strings to a char **
5608 5 : char **papszStringData = (char**)CPLCalloc(sizeof(char*), nLength);
5609 :
5610 : // we can't just use the memory location in the array
5611 : // since long strings won't be null terminated
5612 55 : for( int i = 0; i < nLength; i++ )
5613 : {
5614 50 : strncpy(pszBuffer, (char*)PyArray_GETPTR1(psArray, i), nMaxLen);
5615 50 : papszStringData[i] = CPLStrdup(pszBuffer);
5616 : }
5617 5 : CPLFree(pszBuffer);
5618 :
5619 5 : retval = GDALRATValuesIOAsString(poRAT, GF_Write, nField, nStart, nLength,
5620 : papszStringData);
5621 :
5622 55 : for( int i = 0; i < nLength; i++ )
5623 : {
5624 50 : CPLFree(papszStringData[i]);
5625 : }
5626 5 : CPLFree(papszStringData);
5627 : }
5628 : else
5629 : {
5630 0 : CPLError( CE_Failure, CPLE_AppDefined,
5631 : "Illegal numpy array type %d.\n",
5632 : nType );
5633 0 : return CE_Failure;
5634 : }
5635 : return retval;
5636 : }
5637 :
5638 :
5639 : // need different functions for read and write
5640 : // since reading strings requires us to know the
5641 : // length of the longest string before creating array
5642 40 : PyObject *RATValuesIONumPyRead( GDALRasterAttributeTableShadow* poRAT, int nField, int nStart,
5643 : int nLength) {
5644 :
5645 40 : GDALRATFieldType colType = GDALRATGetTypeOfCol(poRAT, nField);
5646 40 : npy_intp dims = nLength;
5647 40 : PyObject *pOutArray = NULL;
5648 40 : if( colType == GFT_Integer )
5649 : {
5650 13 : pOutArray = PyArray_SimpleNew(1, &dims, NPY_INT32);
5651 13 : if( GDALRATValuesIOAsInteger(poRAT, GF_Read, nField, nStart, nLength,
5652 13 : (int*)PyArray_DATA((PyArrayObject *) pOutArray)) != CE_None)
5653 : {
5654 0 : Py_DECREF(pOutArray);
5655 0 : Py_RETURN_NONE;
5656 : }
5657 : }
5658 27 : else if( colType == GFT_Real )
5659 : {
5660 13 : pOutArray = PyArray_SimpleNew(1, &dims, NPY_DOUBLE);
5661 13 : if( GDALRATValuesIOAsDouble(poRAT, GF_Read, nField, nStart, nLength,
5662 13 : (double*)PyArray_DATA((PyArrayObject *) pOutArray)) != CE_None)
5663 : {
5664 0 : Py_DECREF(pOutArray);
5665 0 : Py_RETURN_NONE;
5666 : }
5667 : }
5668 14 : else if( colType == GFT_String )
5669 : {
5670 : // must read the data first to work out max size
5671 : // of strings to create array
5672 14 : int n;
5673 14 : char **papszStringList = (char**)CPLCalloc(sizeof(char*), nLength);
5674 14 : if( GDALRATValuesIOAsString(poRAT, GF_Read, nField, nStart, nLength, papszStringList) != CE_None )
5675 : {
5676 0 : CPLFree(papszStringList);
5677 0 : Py_RETURN_NONE;
5678 : }
5679 : int nMaxLen = 0, nLen;
5680 154 : for( n = 0; n < nLength; n++ )
5681 : {
5682 : // note strlen doesn't include null char
5683 : // but that is what numpy expects so all good
5684 140 : nLen = static_cast<int>(strlen(papszStringList[n]));
5685 140 : if( nLen > nMaxLen )
5686 : nMaxLen = nLen;
5687 : }
5688 14 : int bZeroLength = FALSE;
5689 : // numpy can't deal with zero length strings
5690 14 : if( nMaxLen == 0 )
5691 : {
5692 0 : nMaxLen = 1;
5693 0 : bZeroLength = TRUE;
5694 : }
5695 :
5696 : // create the dtype string
5697 14 : PyObject *pDTypeString = PyUnicode_FromFormat("S%d", nMaxLen);
5698 : // out type description object
5699 14 : PyArray_Descr *pDescr;
5700 14 : PyArray_DescrConverter(pDTypeString, &pDescr);
5701 14 : Py_DECREF(pDTypeString);
5702 :
5703 : // create array
5704 14 : pOutArray = PyArray_SimpleNewFromDescr(1, &dims, pDescr);
5705 :
5706 : // copy data in
5707 14 : if( !bZeroLength )
5708 : {
5709 154 : for( n = 0; n < nLength; n++ )
5710 : {
5711 : // we use strncpy so that we don't go over nMaxLen
5712 : // which we would if the null char is copied
5713 : // (which we don't want as numpy 'knows' to interpret the string as nMaxLen long)
5714 140 : strncpy((char*)PyArray_GETPTR1((PyArrayObject *) pOutArray, n), papszStringList[n], nMaxLen);
5715 : }
5716 : }
5717 : else
5718 : {
5719 : // so there isn't rubbish in the 1 char strings
5720 0 : PyArray_FILLWBYTE((PyArrayObject *) pOutArray, 0);
5721 : }
5722 :
5723 : // free strings
5724 154 : for( n = 0; n < nLength; n++ )
5725 : {
5726 140 : CPLFree(papszStringList[n]);
5727 : }
5728 14 : CPLFree(papszStringList);
5729 : }
5730 : return pOutArray;
5731 : }
5732 :
5733 : #ifdef __cplusplus
5734 : extern "C" {
5735 : #endif
5736 28 : SWIGINTERN PyObject *_wrap_delete_VirtualMem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
5737 28 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5738 28 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5739 28 : void *argp1 = 0 ;
5740 28 : int res1 = 0 ;
5741 28 : PyObject *swig_obj[1] ;
5742 :
5743 28 : if (!args) SWIG_fail;
5744 28 : swig_obj[0] = args;
5745 28 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, SWIG_POINTER_DISOWN | 0 );
5746 28 : if (!SWIG_IsOK(res1)) {
5747 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VirtualMem" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5748 : }
5749 28 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5750 28 : {
5751 28 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5752 28 : delete_CPLVirtualMemShadow(arg1);
5753 28 : SWIG_PYTHON_THREAD_END_ALLOW;
5754 : }
5755 28 : resultobj = SWIG_Py_Void();
5756 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
5757 : return resultobj;
5758 : fail:
5759 : return NULL;
5760 : }
5761 :
5762 :
5763 0 : SWIGINTERN PyObject *_wrap_VirtualMem_GetAddr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
5764 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5765 0 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5766 0 : void **arg2 = (void **) 0 ;
5767 0 : size_t *arg3 = (size_t *) 0 ;
5768 0 : GDALDataType *arg4 = (GDALDataType *) 0 ;
5769 0 : int *arg5 = (int *) 0 ;
5770 0 : void *argp1 = 0 ;
5771 0 : int res1 = 0 ;
5772 0 : void *ptr2 ;
5773 0 : size_t nsize2 ;
5774 0 : GDALDataType datatype2 ;
5775 0 : int readonly2 ;
5776 0 : PyObject *swig_obj[1] ;
5777 :
5778 0 : {
5779 : /* %typemap(in,numinputs=0) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly) */
5780 0 : arg2 = &ptr2;
5781 0 : arg3 = &nsize2;
5782 0 : arg4 = &datatype2;
5783 0 : arg5 = &readonly2;
5784 : }
5785 0 : if (!args) SWIG_fail;
5786 0 : swig_obj[0] = args;
5787 0 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5788 0 : if (!SWIG_IsOK(res1)) {
5789 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_GetAddr" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5790 : }
5791 0 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5792 0 : {
5793 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5794 0 : CPLVirtualMemShadow_GetAddr(arg1,arg2,arg3,arg4,arg5);
5795 0 : SWIG_PYTHON_THREAD_END_ALLOW;
5796 : }
5797 0 : resultobj = SWIG_Py_Void();
5798 0 : {
5799 : /* %typemap(argout) (void** pptr, size_t* pnsize, GDALDataType* pdatatype, int* preadonly)*/
5800 0 : Py_buffer *buf=(Py_buffer*)malloc(sizeof(Py_buffer));
5801 :
5802 0 : if (PyBuffer_FillInfo(buf, swig_obj[0], *(arg2), *(arg3), *(arg5), PyBUF_ND)) {
5803 : // error, handle
5804 : }
5805 0 : if( *(arg4) == GDT_Byte )
5806 : {
5807 0 : buf->format = (char*) "B";
5808 0 : buf->itemsize = 1;
5809 : }
5810 0 : else if( *(arg4) == GDT_Int16 )
5811 : {
5812 0 : buf->format = (char*) "h";
5813 0 : buf->itemsize = 2;
5814 : }
5815 0 : else if( *(arg4) == GDT_UInt16 )
5816 : {
5817 0 : buf->format = (char*) "H";
5818 0 : buf->itemsize = 2;
5819 : }
5820 0 : else if( *(arg4) == GDT_Int32 )
5821 : {
5822 0 : buf->format = (char*) "i";
5823 0 : buf->itemsize = 4;
5824 : }
5825 0 : else if( *(arg4) == GDT_UInt32 )
5826 : {
5827 0 : buf->format = (char*) "I";
5828 0 : buf->itemsize = 4;
5829 : }
5830 0 : else if( *(arg4) == GDT_Float16 )
5831 : {
5832 0 : buf->format = (char*) "f";
5833 0 : buf->itemsize = 2;
5834 : }
5835 0 : else if( *(arg4) == GDT_Float32 )
5836 : {
5837 0 : buf->format = (char*) "f";
5838 0 : buf->itemsize = 4;
5839 : }
5840 0 : else if( *(arg4) == GDT_Float64 )
5841 : {
5842 0 : buf->format = (char*) "F";
5843 0 : buf->itemsize = 8;
5844 : }
5845 : else
5846 : {
5847 0 : buf->format = (char*) "B";
5848 0 : buf->itemsize = 1;
5849 : }
5850 0 : Py_DECREF(resultobj);
5851 0 : resultobj = PyMemoryView_FromBuffer(buf);
5852 : }
5853 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
5854 : return resultobj;
5855 : fail:
5856 : return NULL;
5857 : }
5858 :
5859 :
5860 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5861 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5862 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5863 : size_t arg2 ;
5864 : size_t arg3 ;
5865 : int arg4 ;
5866 : void *argp1 = 0 ;
5867 : int res1 = 0 ;
5868 : size_t val2 ;
5869 : int ecode2 = 0 ;
5870 : size_t val3 ;
5871 : int ecode3 = 0 ;
5872 : int val4 ;
5873 : int ecode4 = 0 ;
5874 :
5875 : if ((nobjs < 4) || (nobjs > 4)) SWIG_fail;
5876 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5877 : if (!SWIG_IsOK(res1)) {
5878 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5879 : }
5880 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5881 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5882 : if (!SWIG_IsOK(ecode2)) {
5883 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5884 : }
5885 : arg2 = static_cast< size_t >(val2);
5886 : ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3);
5887 : if (!SWIG_IsOK(ecode3)) {
5888 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VirtualMem_Pin" "', argument " "3"" of type '" "size_t""'");
5889 : }
5890 : arg3 = static_cast< size_t >(val3);
5891 : ecode4 = SWIG_AsVal_int(swig_obj[3], &val4);
5892 : if (!SWIG_IsOK(ecode4)) {
5893 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "VirtualMem_Pin" "', argument " "4"" of type '" "int""'");
5894 : }
5895 : arg4 = static_cast< int >(val4);
5896 : {
5897 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5898 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2,arg3,arg4);
5899 : SWIG_PYTHON_THREAD_END_ALLOW;
5900 : }
5901 : resultobj = SWIG_Py_Void();
5902 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
5903 : return resultobj;
5904 : fail:
5905 : return NULL;
5906 : }
5907 :
5908 :
5909 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5910 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5911 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5912 : size_t arg2 ;
5913 : size_t arg3 ;
5914 : void *argp1 = 0 ;
5915 : int res1 = 0 ;
5916 : size_t val2 ;
5917 : int ecode2 = 0 ;
5918 : size_t val3 ;
5919 : int ecode3 = 0 ;
5920 :
5921 : if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
5922 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5923 : if (!SWIG_IsOK(res1)) {
5924 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5925 : }
5926 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5927 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5928 : if (!SWIG_IsOK(ecode2)) {
5929 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5930 : }
5931 : arg2 = static_cast< size_t >(val2);
5932 : ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3);
5933 : if (!SWIG_IsOK(ecode3)) {
5934 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VirtualMem_Pin" "', argument " "3"" of type '" "size_t""'");
5935 : }
5936 : arg3 = static_cast< size_t >(val3);
5937 : {
5938 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5939 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2,arg3);
5940 : SWIG_PYTHON_THREAD_END_ALLOW;
5941 : }
5942 : resultobj = SWIG_Py_Void();
5943 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
5944 : return resultobj;
5945 : fail:
5946 : return NULL;
5947 : }
5948 :
5949 :
5950 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5951 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5952 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5953 : size_t arg2 ;
5954 : void *argp1 = 0 ;
5955 : int res1 = 0 ;
5956 : size_t val2 ;
5957 : int ecode2 = 0 ;
5958 :
5959 : if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
5960 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5961 : if (!SWIG_IsOK(res1)) {
5962 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5963 : }
5964 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5965 : ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
5966 : if (!SWIG_IsOK(ecode2)) {
5967 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VirtualMem_Pin" "', argument " "2"" of type '" "size_t""'");
5968 : }
5969 : arg2 = static_cast< size_t >(val2);
5970 : {
5971 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5972 : CPLVirtualMemShadow_Pin__SWIG_0(arg1,arg2);
5973 : SWIG_PYTHON_THREAD_END_ALLOW;
5974 : }
5975 : resultobj = SWIG_Py_Void();
5976 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
5977 : return resultobj;
5978 : fail:
5979 : return NULL;
5980 : }
5981 :
5982 :
5983 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
5984 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
5985 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
5986 : void *argp1 = 0 ;
5987 : int res1 = 0 ;
5988 :
5989 : if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
5990 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
5991 : if (!SWIG_IsOK(res1)) {
5992 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMem_Pin" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
5993 : }
5994 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
5995 : {
5996 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5997 : CPLVirtualMemShadow_Pin__SWIG_0(arg1);
5998 : SWIG_PYTHON_THREAD_END_ALLOW;
5999 : }
6000 : resultobj = SWIG_Py_Void();
6001 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6002 : return resultobj;
6003 : fail:
6004 : return NULL;
6005 : }
6006 :
6007 :
6008 0 : SWIGINTERN PyObject *_wrap_VirtualMem_Pin(PyObject *self, PyObject *args) {
6009 0 : Py_ssize_t argc;
6010 0 : PyObject *argv[5] = {
6011 : 0
6012 : };
6013 :
6014 0 : if (!(argc = SWIG_Python_UnpackTuple(args, "VirtualMem_Pin", 0, 4, argv))) SWIG_fail;
6015 0 : --argc;
6016 0 : if (argc == 1) {
6017 0 : int _v;
6018 0 : void *vptr = 0;
6019 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6020 0 : _v = SWIG_CheckState(res);
6021 0 : if (_v) {
6022 0 : return _wrap_VirtualMem_Pin__SWIG_3(self, argc, argv);
6023 : }
6024 : }
6025 0 : if (argc == 2) {
6026 0 : int _v;
6027 0 : void *vptr = 0;
6028 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6029 0 : _v = SWIG_CheckState(res);
6030 0 : if (_v) {
6031 0 : {
6032 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6033 0 : _v = SWIG_CheckState(res);
6034 : }
6035 0 : if (_v) {
6036 0 : return _wrap_VirtualMem_Pin__SWIG_2(self, argc, argv);
6037 : }
6038 : }
6039 : }
6040 0 : if (argc == 3) {
6041 0 : int _v;
6042 0 : void *vptr = 0;
6043 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6044 0 : _v = SWIG_CheckState(res);
6045 0 : if (_v) {
6046 0 : {
6047 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6048 0 : _v = SWIG_CheckState(res);
6049 : }
6050 0 : if (_v) {
6051 0 : {
6052 0 : int res = SWIG_AsVal_size_t(argv[2], NULL);
6053 0 : _v = SWIG_CheckState(res);
6054 : }
6055 0 : if (_v) {
6056 0 : return _wrap_VirtualMem_Pin__SWIG_1(self, argc, argv);
6057 : }
6058 : }
6059 : }
6060 : }
6061 0 : if (argc == 4) {
6062 0 : int _v;
6063 0 : void *vptr = 0;
6064 0 : int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLVirtualMemShadow, 0);
6065 0 : _v = SWIG_CheckState(res);
6066 0 : if (_v) {
6067 0 : {
6068 0 : int res = SWIG_AsVal_size_t(argv[1], NULL);
6069 0 : _v = SWIG_CheckState(res);
6070 : }
6071 0 : if (_v) {
6072 0 : {
6073 0 : int res = SWIG_AsVal_size_t(argv[2], NULL);
6074 0 : _v = SWIG_CheckState(res);
6075 : }
6076 0 : if (_v) {
6077 0 : {
6078 0 : int res = SWIG_AsVal_int(argv[3], NULL);
6079 0 : _v = SWIG_CheckState(res);
6080 : }
6081 0 : if (_v) {
6082 0 : return _wrap_VirtualMem_Pin__SWIG_0(self, argc, argv);
6083 : }
6084 : }
6085 : }
6086 : }
6087 : }
6088 :
6089 0 : fail:
6090 0 : SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'VirtualMem_Pin'.\n"
6091 : " Possible C/C++ prototypes are:\n"
6092 : " CPLVirtualMemShadow::Pin(size_t,size_t,int)\n"
6093 : " CPLVirtualMemShadow::Pin(size_t,size_t)\n"
6094 : " CPLVirtualMemShadow::Pin(size_t)\n"
6095 : " CPLVirtualMemShadow::Pin()\n");
6096 : return 0;
6097 : }
6098 :
6099 :
6100 224 : SWIGINTERN PyObject *VirtualMem_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6101 224 : PyObject *obj;
6102 224 : if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
6103 224 : SWIG_TypeNewClientData(SWIGTYPE_p_CPLVirtualMemShadow, SWIG_NewClientData(obj));
6104 224 : return SWIG_Py_Void();
6105 : }
6106 :
6107 0 : SWIGINTERN PyObject *_wrap_GetUseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6108 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6109 0 : int result;
6110 :
6111 0 : if (!SWIG_Python_UnpackTuple(args, "GetUseExceptions", 0, 0, 0)) SWIG_fail;
6112 0 : {
6113 : #ifdef SED_HACKS
6114 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6115 : #endif
6116 0 : result = GetUseExceptions();
6117 : }
6118 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6119 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6120 : return resultobj;
6121 0 : fail:
6122 0 : return NULL;
6123 : }
6124 :
6125 :
6126 0 : SWIGINTERN PyObject *_wrap__GetExceptionsLocal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6127 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6128 0 : int result;
6129 :
6130 0 : if (!SWIG_Python_UnpackTuple(args, "_GetExceptionsLocal", 0, 0, 0)) SWIG_fail;
6131 0 : {
6132 : #ifdef SED_HACKS
6133 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6134 : #endif
6135 0 : {
6136 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6137 0 : result = (int)_GetExceptionsLocal();
6138 0 : SWIG_PYTHON_THREAD_END_ALLOW;
6139 : }
6140 : }
6141 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6142 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6143 : return resultobj;
6144 0 : fail:
6145 0 : return NULL;
6146 : }
6147 :
6148 :
6149 22708 : SWIGINTERN PyObject *_wrap__SetExceptionsLocal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6150 22708 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6151 22708 : int arg1 ;
6152 22708 : int val1 ;
6153 22708 : int ecode1 = 0 ;
6154 22708 : PyObject *swig_obj[1] ;
6155 :
6156 22708 : if (!args) SWIG_fail;
6157 22708 : swig_obj[0] = args;
6158 22708 : ecode1 = SWIG_AsVal_int(swig_obj[0], &val1);
6159 22708 : if (!SWIG_IsOK(ecode1)) {
6160 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "_SetExceptionsLocal" "', argument " "1"" of type '" "int""'");
6161 : }
6162 22708 : arg1 = static_cast< int >(val1);
6163 22708 : {
6164 : #ifdef SED_HACKS
6165 22708 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6166 : #endif
6167 22708 : {
6168 22708 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6169 22708 : _SetExceptionsLocal(arg1);
6170 22708 : SWIG_PYTHON_THREAD_END_ALLOW;
6171 : }
6172 : }
6173 22708 : resultobj = SWIG_Py_Void();
6174 22708 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6175 : return resultobj;
6176 : fail:
6177 : return NULL;
6178 : }
6179 :
6180 :
6181 28 : SWIGINTERN PyObject *_wrap__UseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6182 28 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6183 :
6184 28 : if (!SWIG_Python_UnpackTuple(args, "_UseExceptions", 0, 0, 0)) SWIG_fail;
6185 28 : {
6186 28 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6187 28 : _UseExceptions();
6188 28 : SWIG_PYTHON_THREAD_END_ALLOW;
6189 : }
6190 28 : resultobj = SWIG_Py_Void();
6191 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6192 : return resultobj;
6193 0 : fail:
6194 0 : return NULL;
6195 : }
6196 :
6197 :
6198 5 : SWIGINTERN PyObject *_wrap__DontUseExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6199 5 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6200 :
6201 5 : if (!SWIG_Python_UnpackTuple(args, "_DontUseExceptions", 0, 0, 0)) SWIG_fail;
6202 5 : {
6203 5 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6204 5 : _DontUseExceptions();
6205 5 : SWIG_PYTHON_THREAD_END_ALLOW;
6206 : }
6207 5 : resultobj = SWIG_Py_Void();
6208 5 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6209 : return resultobj;
6210 0 : fail:
6211 0 : return NULL;
6212 : }
6213 :
6214 :
6215 0 : SWIGINTERN PyObject *_wrap__UserHasSpecifiedIfUsingExceptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6216 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6217 0 : int result;
6218 :
6219 0 : if (!SWIG_Python_UnpackTuple(args, "_UserHasSpecifiedIfUsingExceptions", 0, 0, 0)) SWIG_fail;
6220 0 : {
6221 : #ifdef SED_HACKS
6222 0 : if( ReturnSame(TRUE) ) bLocalUseExceptionsCode = FALSE;
6223 : #endif
6224 0 : {
6225 0 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6226 0 : result = (int)_UserHasSpecifiedIfUsingExceptions();
6227 0 : SWIG_PYTHON_THREAD_END_ALLOW;
6228 : }
6229 : }
6230 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6231 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6232 : return resultobj;
6233 0 : fail:
6234 0 : return NULL;
6235 : }
6236 :
6237 :
6238 0 : SWIGINTERN PyObject *_wrap_TermProgress_nocb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6239 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6240 0 : double arg1 ;
6241 0 : char *arg2 = (char *) NULL ;
6242 0 : void *arg3 = (void *) NULL ;
6243 0 : double val1 ;
6244 0 : int ecode1 = 0 ;
6245 0 : int res2 ;
6246 0 : char *buf2 = 0 ;
6247 0 : int alloc2 = 0 ;
6248 0 : int res3 ;
6249 0 : PyObject * obj0 = 0 ;
6250 0 : PyObject * obj1 = 0 ;
6251 0 : PyObject * obj2 = 0 ;
6252 0 : char * kwnames[] = {
6253 : (char *)"dfProgress", (char *)"pszMessage", (char *)"pData", NULL
6254 : };
6255 0 : int result;
6256 :
6257 0 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:TermProgress_nocb", kwnames, &obj0, &obj1, &obj2)) SWIG_fail;
6258 0 : ecode1 = SWIG_AsVal_double(obj0, &val1);
6259 0 : if (!SWIG_IsOK(ecode1)) {
6260 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "TermProgress_nocb" "', argument " "1"" of type '" "double""'");
6261 : }
6262 0 : arg1 = static_cast< double >(val1);
6263 0 : if (obj1) {
6264 0 : res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
6265 0 : if (!SWIG_IsOK(res2)) {
6266 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TermProgress_nocb" "', argument " "2"" of type '" "char const *""'");
6267 : }
6268 0 : arg2 = reinterpret_cast< char * >(buf2);
6269 : }
6270 0 : if (obj2) {
6271 0 : res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
6272 0 : if (!SWIG_IsOK(res3)) {
6273 0 : SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TermProgress_nocb" "', argument " "3"" of type '" "void *""'");
6274 : }
6275 : }
6276 0 : {
6277 0 : const int bLocalUseExceptions = GetUseExceptions();
6278 0 : if ( bLocalUseExceptions ) {
6279 0 : pushErrorHandler();
6280 : }
6281 0 : result = (int)GDALTermProgress_nocb(arg1,(char const *)arg2,arg3);
6282 0 : if ( bLocalUseExceptions ) {
6283 0 : popErrorHandler();
6284 : }
6285 : #ifndef SED_HACKS
6286 : if ( bLocalUseExceptions ) {
6287 : CPLErr eclass = CPLGetLastErrorType();
6288 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6289 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6290 : }
6291 : }
6292 : #endif
6293 : }
6294 0 : resultobj = SWIG_From_int(static_cast< int >(result));
6295 0 : if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
6296 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6297 : return resultobj;
6298 0 : fail:
6299 0 : if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
6300 : return NULL;
6301 : }
6302 :
6303 :
6304 30 : SWIGINTERN PyObject *_wrap_OpenNumPyArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6305 30 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6306 30 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6307 30 : bool arg2 ;
6308 30 : bool val2 ;
6309 30 : int ecode2 = 0 ;
6310 30 : PyObject *swig_obj[2] ;
6311 30 : GDALDatasetShadow *result = 0 ;
6312 :
6313 30 : if (!SWIG_Python_UnpackTuple(args, "OpenNumPyArray", 2, 2, swig_obj)) SWIG_fail;
6314 30 : {
6315 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6316 30 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6317 : {
6318 30 : arg1 = (PyArrayObject*)(swig_obj[0]);
6319 : }
6320 : else
6321 : {
6322 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6323 0 : SWIG_fail;
6324 : }
6325 : }
6326 30 : ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2);
6327 30 : if (!SWIG_IsOK(ecode2)) {
6328 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OpenNumPyArray" "', argument " "2"" of type '" "bool""'");
6329 : }
6330 30 : arg2 = static_cast< bool >(val2);
6331 30 : {
6332 30 : const int bLocalUseExceptions = GetUseExceptions();
6333 30 : if ( bLocalUseExceptions ) {
6334 4 : pushErrorHandler();
6335 : }
6336 30 : result = (GDALDatasetShadow *)OpenNumPyArray(arg1,arg2);
6337 30 : if ( bLocalUseExceptions ) {
6338 4 : popErrorHandler();
6339 : }
6340 : #ifndef SED_HACKS
6341 : if( result == NULL && bLocalUseExceptions ) {
6342 : CPLErr eclass = CPLGetLastErrorType();
6343 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6344 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6345 : }
6346 : }
6347 : #endif
6348 30 : if( result != NULL && bLocalUseExceptions ) {
6349 : #ifdef SED_HACKS
6350 3 : bLocalUseExceptionsCode = FALSE;
6351 : #endif
6352 : }
6353 : }
6354 30 : resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 );
6355 32 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6356 : return resultobj;
6357 : fail:
6358 : return NULL;
6359 : }
6360 :
6361 :
6362 21 : SWIGINTERN PyObject *_wrap_OpenMultiDimensionalNumPyArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6363 21 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6364 21 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6365 21 : PyObject *swig_obj[1] ;
6366 21 : GDALDatasetShadow *result = 0 ;
6367 :
6368 21 : if (!args) SWIG_fail;
6369 21 : swig_obj[0] = args;
6370 21 : {
6371 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6372 21 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6373 : {
6374 21 : arg1 = (PyArrayObject*)(swig_obj[0]);
6375 : }
6376 : else
6377 : {
6378 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6379 0 : SWIG_fail;
6380 : }
6381 : }
6382 21 : {
6383 21 : const int bLocalUseExceptions = GetUseExceptions();
6384 21 : if ( bLocalUseExceptions ) {
6385 21 : pushErrorHandler();
6386 : }
6387 21 : result = (GDALDatasetShadow *)OpenMultiDimensionalNumPyArray(arg1);
6388 21 : if ( bLocalUseExceptions ) {
6389 21 : popErrorHandler();
6390 : }
6391 : #ifndef SED_HACKS
6392 : if( result == NULL && bLocalUseExceptions ) {
6393 : CPLErr eclass = CPLGetLastErrorType();
6394 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6395 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6396 : }
6397 : }
6398 : #endif
6399 21 : if( result != NULL && bLocalUseExceptions ) {
6400 : #ifdef SED_HACKS
6401 20 : bLocalUseExceptionsCode = FALSE;
6402 : #endif
6403 : }
6404 : }
6405 21 : resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 );
6406 23 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6407 : return resultobj;
6408 : fail:
6409 : return NULL;
6410 : }
6411 :
6412 :
6413 2 : SWIGINTERN PyObject *_wrap_GetArrayFilename(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6414 2 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6415 2 : PyArrayObject *arg1 = (PyArrayObject *) 0 ;
6416 2 : PyObject *swig_obj[1] ;
6417 2 : retStringAndCPLFree *result = 0 ;
6418 :
6419 2 : if (!args) SWIG_fail;
6420 2 : swig_obj[0] = args;
6421 2 : {
6422 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6423 2 : if (swig_obj[0] != NULL && PyArray_Check(swig_obj[0]))
6424 : {
6425 2 : arg1 = (PyArrayObject*)(swig_obj[0]);
6426 : }
6427 : else
6428 : {
6429 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6430 0 : SWIG_fail;
6431 : }
6432 : }
6433 2 : {
6434 2 : const int bLocalUseExceptions = GetUseExceptions();
6435 2 : if ( bLocalUseExceptions ) {
6436 0 : pushErrorHandler();
6437 : }
6438 2 : result = (retStringAndCPLFree *)GetArrayFilename(arg1);
6439 2 : if ( bLocalUseExceptions ) {
6440 0 : popErrorHandler();
6441 : }
6442 : #ifndef SED_HACKS
6443 : if ( bLocalUseExceptions ) {
6444 : CPLErr eclass = CPLGetLastErrorType();
6445 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6446 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6447 : }
6448 : }
6449 : #endif
6450 : }
6451 2 : {
6452 : /* %typemap(out) (retStringAndCPLFree*) */
6453 2 : Py_XDECREF(resultobj);
6454 2 : if(result)
6455 : {
6456 2 : resultobj = GDALPythonObjectFromCStr( (const char *)result);
6457 2 : CPLFree(result);
6458 : }
6459 : else
6460 : {
6461 0 : resultobj = Py_None;
6462 0 : Py_INCREF(resultobj);
6463 : }
6464 : }
6465 2 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6466 : return resultobj;
6467 : fail:
6468 : return NULL;
6469 : }
6470 :
6471 :
6472 19232 : SWIGINTERN PyObject *_wrap_BandRasterIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6473 19232 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6474 19232 : GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ;
6475 19232 : int arg2 ;
6476 19232 : double arg3 ;
6477 19232 : double arg4 ;
6478 19232 : double arg5 ;
6479 19232 : double arg6 ;
6480 19232 : PyArrayObject *arg7 = (PyArrayObject *) 0 ;
6481 19232 : GDALDataType arg8 ;
6482 19232 : GDALRIOResampleAlg arg9 ;
6483 19232 : GDALProgressFunc arg10 = (GDALProgressFunc) NULL ;
6484 19232 : void *arg11 = (void *) NULL ;
6485 19232 : void *argp1 = 0 ;
6486 19232 : int res1 = 0 ;
6487 19232 : int val2 ;
6488 19232 : int ecode2 = 0 ;
6489 19232 : double val3 ;
6490 19232 : int ecode3 = 0 ;
6491 19232 : double val4 ;
6492 19232 : int ecode4 = 0 ;
6493 19232 : double val5 ;
6494 19232 : int ecode5 = 0 ;
6495 19232 : double val6 ;
6496 19232 : int ecode6 = 0 ;
6497 19232 : PyObject * obj0 = 0 ;
6498 19232 : PyObject * obj1 = 0 ;
6499 19232 : PyObject * obj2 = 0 ;
6500 19232 : PyObject * obj3 = 0 ;
6501 19232 : PyObject * obj4 = 0 ;
6502 19232 : PyObject * obj5 = 0 ;
6503 19232 : PyObject * obj6 = 0 ;
6504 19232 : PyObject * obj7 = 0 ;
6505 19232 : PyObject * obj8 = 0 ;
6506 19232 : PyObject * obj9 = 0 ;
6507 19232 : PyObject * obj10 = 0 ;
6508 19232 : char * kwnames[] = {
6509 : (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
6510 : };
6511 19232 : CPLErr result;
6512 :
6513 : /* %typemap(arginit) ( const char* callback_data=NULL) */
6514 19232 : PyProgressData *psProgressInfo;
6515 19232 : psProgressInfo = (PyProgressData *) CPLCalloc(1,sizeof(PyProgressData));
6516 19232 : psProgressInfo->nLastReported = -1;
6517 19232 : psProgressInfo->psPyCallback = NULL;
6518 19232 : psProgressInfo->psPyCallbackData = NULL;
6519 19232 : arg11 = psProgressInfo;
6520 19232 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOOOO|OO:BandRasterIONumPy", kwnames, &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6, &obj7, &obj8, &obj9, &obj10)) SWIG_fail;
6521 19232 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 );
6522 19232 : if (!SWIG_IsOK(res1)) {
6523 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BandRasterIONumPy" "', argument " "1"" of type '" "GDALRasterBandShadow *""'");
6524 : }
6525 19232 : arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1);
6526 19232 : ecode2 = SWIG_AsVal_int(obj1, &val2);
6527 19232 : if (!SWIG_IsOK(ecode2)) {
6528 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BandRasterIONumPy" "', argument " "2"" of type '" "int""'");
6529 : }
6530 19232 : arg2 = static_cast< int >(val2);
6531 19232 : ecode3 = SWIG_AsVal_double(obj2, &val3);
6532 19232 : if (!SWIG_IsOK(ecode3)) {
6533 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "BandRasterIONumPy" "', argument " "3"" of type '" "double""'");
6534 : }
6535 19232 : arg3 = static_cast< double >(val3);
6536 19232 : ecode4 = SWIG_AsVal_double(obj3, &val4);
6537 19232 : if (!SWIG_IsOK(ecode4)) {
6538 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "BandRasterIONumPy" "', argument " "4"" of type '" "double""'");
6539 : }
6540 19232 : arg4 = static_cast< double >(val4);
6541 19232 : ecode5 = SWIG_AsVal_double(obj4, &val5);
6542 19232 : if (!SWIG_IsOK(ecode5)) {
6543 0 : SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "BandRasterIONumPy" "', argument " "5"" of type '" "double""'");
6544 : }
6545 19232 : arg5 = static_cast< double >(val5);
6546 19232 : ecode6 = SWIG_AsVal_double(obj5, &val6);
6547 19232 : if (!SWIG_IsOK(ecode6)) {
6548 0 : SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "BandRasterIONumPy" "', argument " "6"" of type '" "double""'");
6549 : }
6550 19232 : arg6 = static_cast< double >(val6);
6551 19232 : {
6552 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6553 19232 : if (obj6 != NULL && PyArray_Check(obj6))
6554 : {
6555 19232 : arg7 = (PyArrayObject*)(obj6);
6556 : }
6557 : else
6558 : {
6559 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6560 0 : SWIG_fail;
6561 : }
6562 : }
6563 19232 : {
6564 : // %typemap(in) GDALDataType
6565 19232 : int val = 0;
6566 19232 : int ecode = SWIG_AsVal_int(obj7, &val);
6567 19232 : if (!SWIG_IsOK(ecode)) {
6568 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALDataType");
6569 : }
6570 19232 : if( val < GDT_Unknown || val >= GDT_TypeCount )
6571 : {
6572 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for GDALDataType");
6573 : }
6574 19232 : arg8 = static_cast<GDALDataType>(val);
6575 : }
6576 19232 : {
6577 : // %typemap(in) GDALRIOResampleAlg
6578 19232 : int val = 0;
6579 19232 : int ecode = SWIG_AsVal_int(obj8, &val);
6580 19232 : if (!SWIG_IsOK(ecode)) {
6581 2 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALRIOResampleAlg");
6582 : }
6583 19230 : if( val < 0 ||
6584 19228 : ( val >= static_cast<int>(GRIORA_RESERVED_START) &&
6585 19226 : val <= static_cast<int>(GRIORA_RESERVED_END) ) ||
6586 : val > static_cast<int>(GRIORA_LAST) )
6587 : {
6588 4 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for resample_alg");
6589 : }
6590 19226 : arg9 = static_cast< GDALRIOResampleAlg >(val);
6591 : }
6592 19226 : if (obj9) {
6593 19226 : {
6594 : /* %typemap(in) (GDALProgressFunc callback = NULL) */
6595 : /* callback_func typemap */
6596 :
6597 : /* In some cases 0 is passed instead of None. */
6598 : /* See https://github.com/OSGeo/gdal/pull/219 */
6599 19226 : if ( PyLong_Check(obj9) || PyInt_Check(obj9) )
6600 : {
6601 0 : if( PyLong_AsLong(obj9) == 0 )
6602 : {
6603 0 : obj9 = Py_None;
6604 : }
6605 : }
6606 :
6607 19226 : if (obj9 && obj9 != Py_None ) {
6608 4 : void* cbfunction = NULL;
6609 4 : CPL_IGNORE_RET_VAL(SWIG_ConvertPtr( obj9,
6610 : (void**)&cbfunction,
6611 : SWIGTYPE_p_f_double_p_q_const__char_p_void__int,
6612 : SWIG_POINTER_EXCEPTION | 0 ));
6613 :
6614 4 : if ( cbfunction == GDALTermProgress ) {
6615 : arg10 = GDALTermProgress;
6616 : } else {
6617 4 : if (!PyCallable_Check(obj9)) {
6618 0 : PyErr_SetString( PyExc_RuntimeError,
6619 : "Object given is not a Python function" );
6620 0 : SWIG_fail;
6621 : }
6622 4 : psProgressInfo->psPyCallback = obj9;
6623 4 : arg10 = PyProgressProxy;
6624 : }
6625 :
6626 : }
6627 :
6628 : }
6629 : }
6630 19226 : if (obj10) {
6631 19226 : {
6632 : /* %typemap(in) ( void* callback_data=NULL) */
6633 19226 : psProgressInfo->psPyCallbackData = obj10 ;
6634 : }
6635 : }
6636 19226 : {
6637 19226 : const int bLocalUseExceptions = GetUseExceptions();
6638 19226 : if ( bLocalUseExceptions ) {
6639 16261 : pushErrorHandler();
6640 : }
6641 19226 : {
6642 19226 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6643 19226 : result = (CPLErr)BandRasterIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
6644 19226 : SWIG_PYTHON_THREAD_END_ALLOW;
6645 : }
6646 19226 : if ( bLocalUseExceptions ) {
6647 16261 : popErrorHandler();
6648 : }
6649 : #ifndef SED_HACKS
6650 : if ( bLocalUseExceptions ) {
6651 : CPLErr eclass = CPLGetLastErrorType();
6652 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6653 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6654 : }
6655 : }
6656 : #endif
6657 : }
6658 19226 : resultobj = SWIG_From_int(static_cast< int >(result));
6659 19226 : {
6660 : /* %typemap(freearg) ( void* callback_data=NULL) */
6661 :
6662 19226 : CPLFree(psProgressInfo);
6663 :
6664 : }
6665 19270 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6666 : return resultobj;
6667 6 : fail:
6668 6 : {
6669 : /* %typemap(freearg) ( void* callback_data=NULL) */
6670 :
6671 6 : CPLFree(psProgressInfo);
6672 :
6673 : }
6674 : return NULL;
6675 : }
6676 :
6677 :
6678 103 : SWIGINTERN PyObject *_wrap_DatasetIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
6679 103 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6680 103 : GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ;
6681 103 : int arg2 ;
6682 103 : double arg3 ;
6683 103 : double arg4 ;
6684 103 : double arg5 ;
6685 103 : double arg6 ;
6686 103 : PyArrayObject *arg7 = (PyArrayObject *) 0 ;
6687 103 : GDALDataType arg8 ;
6688 103 : GDALRIOResampleAlg arg9 ;
6689 103 : GDALProgressFunc arg10 = (GDALProgressFunc) NULL ;
6690 103 : void *arg11 = (void *) NULL ;
6691 103 : bool arg12 = (bool) true ;
6692 103 : int arg13 = (int) 0 ;
6693 103 : int *arg14 = (int *) 0 ;
6694 103 : void *argp1 = 0 ;
6695 103 : int res1 = 0 ;
6696 103 : int val2 ;
6697 103 : int ecode2 = 0 ;
6698 103 : double val3 ;
6699 103 : int ecode3 = 0 ;
6700 103 : double val4 ;
6701 103 : int ecode4 = 0 ;
6702 103 : double val5 ;
6703 103 : int ecode5 = 0 ;
6704 103 : double val6 ;
6705 103 : int ecode6 = 0 ;
6706 103 : bool val12 ;
6707 103 : int ecode12 = 0 ;
6708 103 : PyObject * obj0 = 0 ;
6709 103 : PyObject * obj1 = 0 ;
6710 103 : PyObject * obj2 = 0 ;
6711 103 : PyObject * obj3 = 0 ;
6712 103 : PyObject * obj4 = 0 ;
6713 103 : PyObject * obj5 = 0 ;
6714 103 : PyObject * obj6 = 0 ;
6715 103 : PyObject * obj7 = 0 ;
6716 103 : PyObject * obj8 = 0 ;
6717 103 : PyObject * obj9 = 0 ;
6718 103 : PyObject * obj10 = 0 ;
6719 103 : PyObject * obj11 = 0 ;
6720 103 : PyObject * obj12 = 0 ;
6721 103 : char * kwnames[] = {
6722 : (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
6723 : };
6724 103 : CPLErr result;
6725 :
6726 : /* %typemap(arginit) ( const char* callback_data=NULL) */
6727 103 : PyProgressData *psProgressInfo;
6728 103 : psProgressInfo = (PyProgressData *) CPLCalloc(1,sizeof(PyProgressData));
6729 103 : psProgressInfo->nLastReported = -1;
6730 103 : psProgressInfo->psPyCallback = NULL;
6731 103 : psProgressInfo->psPyCallbackData = NULL;
6732 103 : arg11 = psProgressInfo;
6733 103 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOOOO|OOOO:DatasetIONumPy", kwnames, &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6, &obj7, &obj8, &obj9, &obj10, &obj11, &obj12)) SWIG_fail;
6734 103 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 );
6735 103 : if (!SWIG_IsOK(res1)) {
6736 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DatasetIONumPy" "', argument " "1"" of type '" "GDALDatasetShadow *""'");
6737 : }
6738 103 : arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1);
6739 103 : ecode2 = SWIG_AsVal_int(obj1, &val2);
6740 103 : if (!SWIG_IsOK(ecode2)) {
6741 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DatasetIONumPy" "', argument " "2"" of type '" "int""'");
6742 : }
6743 103 : arg2 = static_cast< int >(val2);
6744 103 : ecode3 = SWIG_AsVal_double(obj2, &val3);
6745 103 : if (!SWIG_IsOK(ecode3)) {
6746 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DatasetIONumPy" "', argument " "3"" of type '" "double""'");
6747 : }
6748 103 : arg3 = static_cast< double >(val3);
6749 103 : ecode4 = SWIG_AsVal_double(obj3, &val4);
6750 103 : if (!SWIG_IsOK(ecode4)) {
6751 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "DatasetIONumPy" "', argument " "4"" of type '" "double""'");
6752 : }
6753 103 : arg4 = static_cast< double >(val4);
6754 103 : ecode5 = SWIG_AsVal_double(obj4, &val5);
6755 103 : if (!SWIG_IsOK(ecode5)) {
6756 0 : SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "DatasetIONumPy" "', argument " "5"" of type '" "double""'");
6757 : }
6758 103 : arg5 = static_cast< double >(val5);
6759 103 : ecode6 = SWIG_AsVal_double(obj5, &val6);
6760 103 : if (!SWIG_IsOK(ecode6)) {
6761 0 : SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "DatasetIONumPy" "', argument " "6"" of type '" "double""'");
6762 : }
6763 103 : arg6 = static_cast< double >(val6);
6764 103 : {
6765 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6766 103 : if (obj6 != NULL && PyArray_Check(obj6))
6767 : {
6768 103 : arg7 = (PyArrayObject*)(obj6);
6769 : }
6770 : else
6771 : {
6772 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6773 0 : SWIG_fail;
6774 : }
6775 : }
6776 103 : {
6777 : // %typemap(in) GDALDataType
6778 103 : int val = 0;
6779 103 : int ecode = SWIG_AsVal_int(obj7, &val);
6780 103 : if (!SWIG_IsOK(ecode)) {
6781 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALDataType");
6782 : }
6783 103 : if( val < GDT_Unknown || val >= GDT_TypeCount )
6784 : {
6785 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for GDALDataType");
6786 : }
6787 103 : arg8 = static_cast<GDALDataType>(val);
6788 : }
6789 103 : {
6790 : // %typemap(in) GDALRIOResampleAlg
6791 103 : int val = 0;
6792 103 : int ecode = SWIG_AsVal_int(obj8, &val);
6793 103 : if (!SWIG_IsOK(ecode)) {
6794 0 : SWIG_exception_fail(SWIG_ArgError(ecode), "invalid value for GDALRIOResampleAlg");
6795 : }
6796 103 : if( val < 0 ||
6797 103 : ( val >= static_cast<int>(GRIORA_RESERVED_START) &&
6798 103 : val <= static_cast<int>(GRIORA_RESERVED_END) ) ||
6799 : val > static_cast<int>(GRIORA_LAST) )
6800 : {
6801 0 : SWIG_exception_fail(SWIG_ValueError, "Invalid value for resample_alg");
6802 : }
6803 103 : arg9 = static_cast< GDALRIOResampleAlg >(val);
6804 : }
6805 103 : if (obj9) {
6806 103 : {
6807 : /* %typemap(in) (GDALProgressFunc callback = NULL) */
6808 : /* callback_func typemap */
6809 :
6810 : /* In some cases 0 is passed instead of None. */
6811 : /* See https://github.com/OSGeo/gdal/pull/219 */
6812 103 : if ( PyLong_Check(obj9) || PyInt_Check(obj9) )
6813 : {
6814 0 : if( PyLong_AsLong(obj9) == 0 )
6815 : {
6816 0 : obj9 = Py_None;
6817 : }
6818 : }
6819 :
6820 103 : if (obj9 && obj9 != Py_None ) {
6821 3 : void* cbfunction = NULL;
6822 3 : CPL_IGNORE_RET_VAL(SWIG_ConvertPtr( obj9,
6823 : (void**)&cbfunction,
6824 : SWIGTYPE_p_f_double_p_q_const__char_p_void__int,
6825 : SWIG_POINTER_EXCEPTION | 0 ));
6826 :
6827 3 : if ( cbfunction == GDALTermProgress ) {
6828 : arg10 = GDALTermProgress;
6829 : } else {
6830 3 : if (!PyCallable_Check(obj9)) {
6831 0 : PyErr_SetString( PyExc_RuntimeError,
6832 : "Object given is not a Python function" );
6833 0 : SWIG_fail;
6834 : }
6835 3 : psProgressInfo->psPyCallback = obj9;
6836 3 : arg10 = PyProgressProxy;
6837 : }
6838 :
6839 : }
6840 :
6841 : }
6842 : }
6843 103 : if (obj10) {
6844 103 : {
6845 : /* %typemap(in) ( void* callback_data=NULL) */
6846 103 : psProgressInfo->psPyCallbackData = obj10 ;
6847 : }
6848 : }
6849 103 : if (obj11) {
6850 103 : ecode12 = SWIG_AsVal_bool(obj11, &val12);
6851 103 : if (!SWIG_IsOK(ecode12)) {
6852 0 : SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "DatasetIONumPy" "', argument " "12"" of type '" "bool""'");
6853 : }
6854 : arg12 = static_cast< bool >(val12);
6855 : }
6856 103 : if (obj12) {
6857 103 : {
6858 : /* %typemap(in,numinputs=1) (int nList, int* pList)*/
6859 103 : arg14 = CreateCIntListFromSequence(obj12, &arg13);
6860 103 : if( arg13 < 0 ) {
6861 0 : SWIG_fail;
6862 : }
6863 : }
6864 : }
6865 103 : {
6866 103 : const int bLocalUseExceptions = GetUseExceptions();
6867 103 : if ( bLocalUseExceptions ) {
6868 73 : pushErrorHandler();
6869 : }
6870 103 : {
6871 103 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6872 103 : result = (CPLErr)DatasetIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
6873 103 : SWIG_PYTHON_THREAD_END_ALLOW;
6874 : }
6875 103 : if ( bLocalUseExceptions ) {
6876 73 : popErrorHandler();
6877 : }
6878 : #ifndef SED_HACKS
6879 : if ( bLocalUseExceptions ) {
6880 : CPLErr eclass = CPLGetLastErrorType();
6881 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6882 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6883 : }
6884 : }
6885 : #endif
6886 : }
6887 103 : resultobj = SWIG_From_int(static_cast< int >(result));
6888 103 : {
6889 : /* %typemap(freearg) ( void* callback_data=NULL) */
6890 :
6891 103 : CPLFree(psProgressInfo);
6892 :
6893 : }
6894 103 : {
6895 : /* %typemap(freearg) (int nList, int* pList) */
6896 103 : free(arg14);
6897 : }
6898 113 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
6899 : return resultobj;
6900 0 : fail:
6901 0 : {
6902 : /* %typemap(freearg) ( void* callback_data=NULL) */
6903 :
6904 0 : CPLFree(psProgressInfo);
6905 :
6906 : }
6907 0 : {
6908 : /* %typemap(freearg) (int nList, int* pList) */
6909 0 : free(arg14);
6910 : }
6911 0 : return NULL;
6912 : }
6913 :
6914 :
6915 78 : SWIGINTERN PyObject *_wrap_MDArrayIONumPy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
6916 78 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
6917 78 : bool arg1 ;
6918 78 : GDALMDArrayHS *arg2 = (GDALMDArrayHS *) 0 ;
6919 78 : PyArrayObject *arg3 = (PyArrayObject *) 0 ;
6920 78 : int arg4 ;
6921 78 : GUIntBig *arg5 = (GUIntBig *) 0 ;
6922 78 : int arg6 ;
6923 78 : GIntBig *arg7 = (GIntBig *) 0 ;
6924 78 : GDALExtendedDataTypeHS *arg8 = (GDALExtendedDataTypeHS *) 0 ;
6925 78 : bool val1 ;
6926 78 : int ecode1 = 0 ;
6927 78 : void *argp2 = 0 ;
6928 78 : int res2 = 0 ;
6929 78 : void *argp8 = 0 ;
6930 78 : int res8 = 0 ;
6931 78 : PyObject *swig_obj[6] ;
6932 78 : CPLErr result;
6933 :
6934 78 : if (!SWIG_Python_UnpackTuple(args, "MDArrayIONumPy", 6, 6, swig_obj)) SWIG_fail;
6935 78 : ecode1 = SWIG_AsVal_bool(swig_obj[0], &val1);
6936 78 : if (!SWIG_IsOK(ecode1)) {
6937 0 : SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MDArrayIONumPy" "', argument " "1"" of type '" "bool""'");
6938 : }
6939 78 : arg1 = static_cast< bool >(val1);
6940 78 : res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_GDALMDArrayHS, 0 | 0 );
6941 78 : if (!SWIG_IsOK(res2)) {
6942 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MDArrayIONumPy" "', argument " "2"" of type '" "GDALMDArrayHS *""'");
6943 : }
6944 78 : arg2 = reinterpret_cast< GDALMDArrayHS * >(argp2);
6945 78 : {
6946 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
6947 78 : if (swig_obj[2] != NULL && PyArray_Check(swig_obj[2]))
6948 : {
6949 78 : arg3 = (PyArrayObject*)(swig_obj[2]);
6950 : }
6951 : else
6952 : {
6953 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
6954 0 : SWIG_fail;
6955 : }
6956 : }
6957 78 : {
6958 : /* %typemap(in,numinputs=1) (int nList, GUIntBig* pList)*/
6959 78 : arg5 = CreateCGUIntBigListFromSequence(swig_obj[3], &arg4);
6960 78 : if( arg4 < 0 ) {
6961 0 : SWIG_fail;
6962 : }
6963 : }
6964 78 : {
6965 : /* %typemap(in,numinputs=1) (int nList, GIntBig* pList)*/
6966 78 : arg7 = CreateCGIntBigListFromSequence(swig_obj[4], &arg6);
6967 78 : if( arg6 < 0 ) {
6968 0 : SWIG_fail;
6969 : }
6970 : }
6971 78 : res8 = SWIG_ConvertPtr(swig_obj[5], &argp8,SWIGTYPE_p_GDALExtendedDataTypeHS, 0 | 0 );
6972 78 : if (!SWIG_IsOK(res8)) {
6973 0 : SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "MDArrayIONumPy" "', argument " "8"" of type '" "GDALExtendedDataTypeHS *""'");
6974 : }
6975 78 : arg8 = reinterpret_cast< GDALExtendedDataTypeHS * >(argp8);
6976 78 : {
6977 78 : const int bLocalUseExceptions = GetUseExceptions();
6978 78 : if ( bLocalUseExceptions ) {
6979 76 : pushErrorHandler();
6980 : }
6981 78 : {
6982 78 : SWIG_PYTHON_THREAD_BEGIN_ALLOW;
6983 78 : result = (CPLErr)MDArrayIONumPy(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
6984 78 : SWIG_PYTHON_THREAD_END_ALLOW;
6985 : }
6986 78 : if ( bLocalUseExceptions ) {
6987 76 : popErrorHandler();
6988 : }
6989 : #ifndef SED_HACKS
6990 : if ( bLocalUseExceptions ) {
6991 : CPLErr eclass = CPLGetLastErrorType();
6992 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
6993 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
6994 : }
6995 : }
6996 : #endif
6997 : }
6998 78 : resultobj = SWIG_From_int(static_cast< int >(result));
6999 78 : {
7000 : /* %typemap(freearg) (int nList, GUIntBig* pList) */
7001 78 : free(arg5);
7002 : }
7003 78 : {
7004 : /* %typemap(freearg) (int nList, GIntBig* pList) */
7005 78 : free(arg7);
7006 : }
7007 78 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7008 : return resultobj;
7009 0 : fail:
7010 0 : {
7011 : /* %typemap(freearg) (int nList, GUIntBig* pList) */
7012 0 : free(arg5);
7013 : }
7014 0 : {
7015 : /* %typemap(freearg) (int nList, GIntBig* pList) */
7016 0 : free(arg7);
7017 : }
7018 0 : return NULL;
7019 : }
7020 :
7021 :
7022 0 : SWIGINTERN PyObject *_wrap_AddNumpyArrayToDict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7023 0 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7024 0 : PyObject *arg1 = (PyObject *) 0 ;
7025 0 : ArrowSchema *arg2 = (ArrowSchema *) 0 ;
7026 0 : ArrowArray *arg3 = (ArrowArray *) 0 ;
7027 0 : std::string *arg4 = 0 ;
7028 0 : PyObject *arg5 = (PyObject *) 0 ;
7029 0 : void *argp2 = 0 ;
7030 0 : int res2 = 0 ;
7031 0 : void *argp3 = 0 ;
7032 0 : int res3 = 0 ;
7033 0 : void *argp4 = 0 ;
7034 0 : int res4 = 0 ;
7035 0 : PyObject *swig_obj[5] ;
7036 0 : bool result;
7037 :
7038 0 : if (!SWIG_Python_UnpackTuple(args, "AddNumpyArrayToDict", 5, 5, swig_obj)) SWIG_fail;
7039 0 : arg1 = swig_obj[0];
7040 0 : res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ArrowSchema, 0 | 0 );
7041 0 : if (!SWIG_IsOK(res2)) {
7042 0 : SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AddNumpyArrayToDict" "', argument " "2"" of type '" "ArrowSchema const *""'");
7043 : }
7044 0 : arg2 = reinterpret_cast< ArrowSchema * >(argp2);
7045 0 : res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ArrowArray, 0 | 0 );
7046 0 : if (!SWIG_IsOK(res3)) {
7047 0 : SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "AddNumpyArrayToDict" "', argument " "3"" of type '" "ArrowArray const *""'");
7048 : }
7049 0 : arg3 = reinterpret_cast< ArrowArray * >(argp3);
7050 0 : res4 = SWIG_ConvertPtr(swig_obj[3], &argp4, SWIGTYPE_p_std__string, 0 | 0);
7051 0 : if (!SWIG_IsOK(res4)) {
7052 0 : SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AddNumpyArrayToDict" "', argument " "4"" of type '" "std::string const &""'");
7053 : }
7054 0 : if (!argp4) {
7055 0 : SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AddNumpyArrayToDict" "', argument " "4"" of type '" "std::string const &""'");
7056 : }
7057 0 : arg4 = reinterpret_cast< std::string * >(argp4);
7058 0 : arg5 = swig_obj[4];
7059 0 : {
7060 0 : const int bLocalUseExceptions = GetUseExceptions();
7061 0 : if ( bLocalUseExceptions ) {
7062 0 : pushErrorHandler();
7063 : }
7064 0 : result = (bool)AddNumpyArrayToDict(arg1,(ArrowSchema const *)arg2,(ArrowArray const *)arg3,(std::string const &)*arg4,arg5);
7065 0 : if ( bLocalUseExceptions ) {
7066 0 : popErrorHandler();
7067 : }
7068 : #ifndef SED_HACKS
7069 : if ( bLocalUseExceptions ) {
7070 : CPLErr eclass = CPLGetLastErrorType();
7071 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7072 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7073 : }
7074 : }
7075 : #endif
7076 : }
7077 0 : resultobj = SWIG_From_bool(static_cast< bool >(result));
7078 0 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7079 : return resultobj;
7080 : fail:
7081 : return NULL;
7082 : }
7083 :
7084 :
7085 475 : SWIGINTERN PyObject *_wrap__RecordBatchAsNumpy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7086 475 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7087 475 : VoidPtrAsLong arg1 = (VoidPtrAsLong) 0 ;
7088 475 : VoidPtrAsLong arg2 = (VoidPtrAsLong) 0 ;
7089 475 : PyObject *arg3 = (PyObject *) 0 ;
7090 475 : PyObject *swig_obj[3] ;
7091 475 : PyObject *result = 0 ;
7092 :
7093 475 : if (!SWIG_Python_UnpackTuple(args, "_RecordBatchAsNumpy", 3, 3, swig_obj)) SWIG_fail;
7094 475 : {
7095 475 : arg1 = PyLong_AsVoidPtr(swig_obj[0]);
7096 : }
7097 475 : {
7098 475 : arg2 = PyLong_AsVoidPtr(swig_obj[1]);
7099 : }
7100 475 : arg3 = swig_obj[2];
7101 475 : {
7102 475 : const int bLocalUseExceptions = GetUseExceptions();
7103 475 : if ( bLocalUseExceptions ) {
7104 160 : pushErrorHandler();
7105 : }
7106 475 : result = (PyObject *)_RecordBatchAsNumpy(arg1,arg2,arg3);
7107 475 : if ( bLocalUseExceptions ) {
7108 160 : popErrorHandler();
7109 : }
7110 : #ifndef SED_HACKS
7111 : if ( bLocalUseExceptions ) {
7112 : CPLErr eclass = CPLGetLastErrorType();
7113 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7114 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7115 : }
7116 : }
7117 : #endif
7118 : }
7119 475 : resultobj = result;
7120 475 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7121 : return resultobj;
7122 0 : fail:
7123 0 : return NULL;
7124 : }
7125 :
7126 :
7127 28 : SWIGINTERN PyObject *_wrap_VirtualMemGetArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
7128 28 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7129 28 : CPLVirtualMemShadow *arg1 = (CPLVirtualMemShadow *) 0 ;
7130 28 : CPLVirtualMemShadow **arg2 = (CPLVirtualMemShadow **) 0 ;
7131 28 : int arg3 ;
7132 28 : void *argp1 = 0 ;
7133 28 : int res1 = 0 ;
7134 28 : CPLVirtualMemShadow *virtualmem2 ;
7135 28 : PyObject *swig_obj[1] ;
7136 :
7137 28 : {
7138 28 : arg2 = &virtualmem2;
7139 28 : arg3 = 0;
7140 : }
7141 28 : if (!args) SWIG_fail;
7142 28 : swig_obj[0] = args;
7143 28 : res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_CPLVirtualMemShadow, 0 | 0 );
7144 28 : if (!SWIG_IsOK(res1)) {
7145 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VirtualMemGetArray" "', argument " "1"" of type '" "CPLVirtualMemShadow *""'");
7146 : }
7147 28 : arg1 = reinterpret_cast< CPLVirtualMemShadow * >(argp1);
7148 28 : {
7149 28 : if (!arg1) {
7150 0 : SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
7151 : }
7152 : }
7153 28 : {
7154 28 : const int bLocalUseExceptions = GetUseExceptions();
7155 28 : if ( bLocalUseExceptions ) {
7156 28 : pushErrorHandler();
7157 : }
7158 28 : VirtualMemGetArray(arg1,arg2,arg3);
7159 28 : if ( bLocalUseExceptions ) {
7160 28 : popErrorHandler();
7161 : }
7162 : #ifndef SED_HACKS
7163 : if ( bLocalUseExceptions ) {
7164 : CPLErr eclass = CPLGetLastErrorType();
7165 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7166 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7167 : }
7168 : }
7169 : #endif
7170 : }
7171 28 : resultobj = SWIG_Py_Void();
7172 28 : {
7173 28 : CPLVirtualMemShadow* virtualmem = *(arg2);
7174 28 : void* ptr = CPLVirtualMemGetAddr( virtualmem->vmem );
7175 : /*size_t nsize = CPLVirtualMemGetSize( virtualmem->vmem );*/
7176 28 : GDALDataType datatype = virtualmem->eBufType;
7177 28 : int readonly = virtualmem->bReadOnly;
7178 28 : GIntBig nBufXSize = virtualmem->nBufXSize;
7179 28 : GIntBig nBufYSize = virtualmem->nBufYSize;
7180 28 : int nBandCount = virtualmem->nBandCount;
7181 28 : int bIsBandSequential = virtualmem->bIsBandSequential;
7182 28 : GDALTileOrganization eTileOrganization = virtualmem->eTileOrganization;
7183 28 : int nTileXSize = virtualmem->nTileXSize;
7184 28 : int nTileYSize = virtualmem->nTileYSize;
7185 28 : int bAuto = virtualmem->bAuto;
7186 28 : int nPixelSpace = virtualmem->nPixelSpace; /* if bAuto == TRUE */
7187 28 : GIntBig nLineSpace = virtualmem->nLineSpace; /* if bAuto == TRUE */
7188 28 : int numpytype;
7189 :
7190 28 : if( datatype == GDT_CInt16 || datatype == GDT_CInt32 || datatype == GDT_CFloat16 )
7191 : {
7192 0 : PyErr_SetString( PyExc_RuntimeError, "GDT_CInt16, GDT_CInt32, and GDT_CFloat16 not supported for now" );
7193 0 : SWIG_fail;
7194 : }
7195 :
7196 28 : switch(datatype)
7197 : {
7198 : case GDT_Byte: numpytype = NPY_UBYTE; break;
7199 : case GDT_Int8: numpytype = NPY_INT8; break;
7200 : case GDT_Int16: numpytype = NPY_INT16; break;
7201 : case GDT_UInt16: numpytype = NPY_UINT16; break;
7202 : case GDT_Int32: numpytype = NPY_INT32; break;
7203 : case GDT_UInt32: numpytype = NPY_UINT32; break;
7204 : case GDT_Int64: numpytype = NPY_INT64; break;
7205 : case GDT_UInt64: numpytype = NPY_UINT64; break;
7206 : case GDT_Float16: numpytype = NPY_FLOAT16; break;
7207 : case GDT_Float32: numpytype = NPY_FLOAT32; break;
7208 : case GDT_Float64: numpytype = NPY_FLOAT64; break;
7209 : //case GDT_CInt16: numpytype = NPY_INT16; break;
7210 : //case GDT_CInt32: numpytype = NPY_INT32; break;
7211 : //case GDT_CFloat16: numpytype = NPY_CHALF; break;
7212 : case GDT_CFloat32: numpytype = NPY_CFLOAT; break;
7213 : case GDT_CFloat64: numpytype = NPY_CDOUBLE; break;
7214 : default: numpytype = NPY_UBYTE; break;
7215 : }
7216 28 : PyArrayObject* ar;
7217 28 : int flags = (readonly) ? 0x1 : 0x1 | 0x0400;
7218 28 : int nDataTypeSize = GDALGetDataTypeSizeBytes(datatype);
7219 28 : if( bAuto )
7220 : {
7221 20 : if( nBandCount == 1 )
7222 : {
7223 20 : npy_intp shape[2], stride[2];
7224 20 : shape[0] = nBufYSize;
7225 20 : shape[1] = nBufXSize;
7226 20 : stride[1] = nPixelSpace;
7227 20 : stride[0] = nLineSpace;
7228 20 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 2, shape,
7229 : numpytype, stride, ptr, 0, flags , NULL);
7230 : }
7231 : else
7232 : {
7233 0 : PyErr_SetString( PyExc_RuntimeError, "Code update needed for bAuto and nBandCount > 1 !" );
7234 0 : SWIG_fail;
7235 : }
7236 : }
7237 8 : else if( bIsBandSequential >= 0 )
7238 : {
7239 4 : if( nBandCount == 1 )
7240 : {
7241 2 : npy_intp shape[2], stride[2];
7242 2 : shape[0] = nBufYSize;
7243 2 : shape[1] = nBufXSize;
7244 2 : stride[1] = nDataTypeSize;
7245 2 : stride[0] = stride[1] * nBufXSize;
7246 2 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 2, shape,
7247 : numpytype, stride, ptr, 0, flags , NULL);
7248 : }
7249 : else
7250 : {
7251 2 : npy_intp shape[3], stride[3];
7252 2 : if( bIsBandSequential )
7253 : {
7254 1 : shape[0] = nBandCount;
7255 1 : shape[1] = nBufYSize;
7256 1 : shape[2] = nBufXSize;
7257 1 : stride[2] = nDataTypeSize;
7258 1 : stride[1] = stride[2] * nBufXSize;
7259 1 : stride[0] = stride[1] * nBufYSize;
7260 : }
7261 : else
7262 : {
7263 1 : shape[0] = nBufYSize;
7264 1 : shape[1] = nBufXSize;
7265 1 : shape[2] = nBandCount;
7266 1 : stride[2] = nDataTypeSize;
7267 1 : stride[1] = stride[2] * nBandCount;
7268 1 : stride[0] = stride[1] * nBufXSize;
7269 : }
7270 2 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 3, shape,
7271 : numpytype, stride, ptr, 0, flags , NULL);
7272 : }
7273 : }
7274 : else
7275 : {
7276 4 : npy_intp nTilesPerRow = static_cast<npy_intp>(DIV_ROUND_UP(nBufXSize, nTileXSize));
7277 4 : npy_intp nTilesPerCol = static_cast<npy_intp>(DIV_ROUND_UP(nBufYSize, nTileYSize));
7278 4 : npy_intp shape[5], stride[5];
7279 4 : if( nBandCount == 1 )
7280 : {
7281 1 : shape[0] = nTilesPerCol;
7282 1 : shape[1] = nTilesPerRow;
7283 1 : shape[2] = nTileYSize;
7284 1 : shape[3] = nTileXSize;
7285 1 : stride[3] = nDataTypeSize;
7286 1 : stride[2] = stride[3] * nTileXSize;
7287 1 : stride[1] = stride[2] * nTileYSize;
7288 1 : stride[0] = stride[1] * nTilesPerRow;
7289 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 4, shape,
7290 : numpytype, stride, ptr, 0, flags , NULL);
7291 : }
7292 3 : else if( eTileOrganization == GTO_TIP )
7293 : {
7294 1 : shape[0] = nTilesPerCol;
7295 1 : shape[1] = nTilesPerRow;
7296 1 : shape[2] = nTileYSize;
7297 1 : shape[3] = nTileXSize;
7298 1 : shape[4] = nBandCount;
7299 1 : stride[4] = nDataTypeSize;
7300 1 : stride[3] = stride[4] * nBandCount;
7301 1 : stride[2] = stride[3] * nTileXSize;
7302 1 : stride[1] = stride[2] * nTileYSize;
7303 1 : stride[0] = stride[1] * nTilesPerRow;
7304 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7305 : numpytype, stride, ptr, 0, flags , NULL);
7306 : }
7307 2 : else if( eTileOrganization == GTO_BIT )
7308 : {
7309 1 : shape[0] = nTilesPerCol;
7310 1 : shape[1] = nTilesPerRow;
7311 1 : shape[2] = nBandCount;
7312 1 : shape[3] = nTileYSize;
7313 1 : shape[4] = nTileXSize;
7314 1 : stride[4] = nDataTypeSize;
7315 1 : stride[3] = stride[4] * nTileXSize;
7316 1 : stride[2] = stride[3] * nTileYSize;
7317 1 : stride[1] = stride[2] * nBandCount;
7318 1 : stride[0] = stride[1] * nTilesPerRow;
7319 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7320 : numpytype, stride, ptr, 0, flags , NULL);
7321 : }
7322 : else /* GTO_BSQ */
7323 : {
7324 1 : shape[0] = nBandCount;
7325 1 : shape[1] = nTilesPerCol;
7326 1 : shape[2] = nTilesPerRow;
7327 1 : shape[3] = nTileYSize;
7328 1 : shape[4] = nTileXSize;
7329 1 : stride[4] = nDataTypeSize;
7330 1 : stride[3] = stride[4] * nTileXSize;
7331 1 : stride[2] = stride[3] * nTileYSize;
7332 1 : stride[1] = stride[2] * nTilesPerRow;
7333 1 : stride[0] = stride[1] * nTilesPerCol;
7334 1 : ar = (PyArrayObject*) PyArray_New(&PyArray_Type, 5, shape,
7335 : numpytype, stride, ptr, 0, flags , NULL);
7336 : }
7337 : }
7338 :
7339 : /* Keep a reference to the VirtualMem object */
7340 : #if NPY_API_VERSION >= 0x00000007
7341 28 : PyArray_SetBaseObject(ar, swig_obj[0]);
7342 : #else
7343 : PyArray_BASE(ar) = swig_obj[0];
7344 : #endif
7345 28 : Py_INCREF(swig_obj[0]);
7346 28 : Py_DECREF(resultobj);
7347 28 : resultobj = (PyObject*) ar;
7348 : }
7349 28 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7350 : return resultobj;
7351 : fail:
7352 : return NULL;
7353 : }
7354 :
7355 :
7356 13 : SWIGINTERN PyObject *_wrap_RATValuesIONumPyWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
7357 13 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7358 13 : GDALRasterAttributeTableShadow *arg1 = (GDALRasterAttributeTableShadow *) 0 ;
7359 13 : int arg2 ;
7360 13 : int arg3 ;
7361 13 : PyArrayObject *arg4 = (PyArrayObject *) 0 ;
7362 13 : void *argp1 = 0 ;
7363 13 : int res1 = 0 ;
7364 13 : int val2 ;
7365 13 : int ecode2 = 0 ;
7366 13 : int val3 ;
7367 13 : int ecode3 = 0 ;
7368 13 : PyObject * obj0 = 0 ;
7369 13 : PyObject * obj1 = 0 ;
7370 13 : PyObject * obj2 = 0 ;
7371 13 : PyObject * obj3 = 0 ;
7372 13 : char * kwnames[] = {
7373 : (char *)"poRAT", (char *)"nField", (char *)"nStart", (char *)"psArray", NULL
7374 : };
7375 13 : CPLErr result;
7376 :
7377 13 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:RATValuesIONumPyWrite", kwnames, &obj0, &obj1, &obj2, &obj3)) SWIG_fail;
7378 13 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterAttributeTableShadow, 0 | 0 );
7379 13 : if (!SWIG_IsOK(res1)) {
7380 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RATValuesIONumPyWrite" "', argument " "1"" of type '" "GDALRasterAttributeTableShadow *""'");
7381 : }
7382 13 : arg1 = reinterpret_cast< GDALRasterAttributeTableShadow * >(argp1);
7383 13 : ecode2 = SWIG_AsVal_int(obj1, &val2);
7384 13 : if (!SWIG_IsOK(ecode2)) {
7385 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RATValuesIONumPyWrite" "', argument " "2"" of type '" "int""'");
7386 : }
7387 13 : arg2 = static_cast< int >(val2);
7388 13 : ecode3 = SWIG_AsVal_int(obj2, &val3);
7389 13 : if (!SWIG_IsOK(ecode3)) {
7390 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RATValuesIONumPyWrite" "', argument " "3"" of type '" "int""'");
7391 : }
7392 13 : arg3 = static_cast< int >(val3);
7393 13 : {
7394 : /* %typemap(in,numinputs=1) (PyArrayObject *psArray) */
7395 13 : if (obj3 != NULL && PyArray_Check(obj3))
7396 : {
7397 13 : arg4 = (PyArrayObject*)(obj3);
7398 : }
7399 : else
7400 : {
7401 0 : PyErr_SetString(PyExc_TypeError, "not a numpy array");
7402 0 : SWIG_fail;
7403 : }
7404 : }
7405 13 : {
7406 13 : const int bLocalUseExceptions = GetUseExceptions();
7407 13 : if ( bLocalUseExceptions ) {
7408 13 : pushErrorHandler();
7409 : }
7410 13 : result = (CPLErr)RATValuesIONumPyWrite(arg1,arg2,arg3,arg4);
7411 13 : if ( bLocalUseExceptions ) {
7412 13 : popErrorHandler();
7413 : }
7414 : #ifndef SED_HACKS
7415 : if ( bLocalUseExceptions ) {
7416 : CPLErr eclass = CPLGetLastErrorType();
7417 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7418 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7419 : }
7420 : }
7421 : #endif
7422 : }
7423 13 : resultobj = SWIG_From_int(static_cast< int >(result));
7424 13 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7425 : return resultobj;
7426 : fail:
7427 : return NULL;
7428 : }
7429 :
7430 :
7431 40 : SWIGINTERN PyObject *_wrap_RATValuesIONumPyRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
7432 40 : PyObject *resultobj = 0; int bLocalUseExceptionsCode = GetUseExceptions();
7433 40 : GDALRasterAttributeTableShadow *arg1 = (GDALRasterAttributeTableShadow *) 0 ;
7434 40 : int arg2 ;
7435 40 : int arg3 ;
7436 40 : int arg4 ;
7437 40 : void *argp1 = 0 ;
7438 40 : int res1 = 0 ;
7439 40 : int val2 ;
7440 40 : int ecode2 = 0 ;
7441 40 : int val3 ;
7442 40 : int ecode3 = 0 ;
7443 40 : int val4 ;
7444 40 : int ecode4 = 0 ;
7445 40 : PyObject * obj0 = 0 ;
7446 40 : PyObject * obj1 = 0 ;
7447 40 : PyObject * obj2 = 0 ;
7448 40 : PyObject * obj3 = 0 ;
7449 40 : char * kwnames[] = {
7450 : (char *)"poRAT", (char *)"nField", (char *)"nStart", (char *)"nLength", NULL
7451 : };
7452 40 : PyObject *result = 0 ;
7453 :
7454 40 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:RATValuesIONumPyRead", kwnames, &obj0, &obj1, &obj2, &obj3)) SWIG_fail;
7455 40 : res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterAttributeTableShadow, 0 | 0 );
7456 40 : if (!SWIG_IsOK(res1)) {
7457 0 : SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RATValuesIONumPyRead" "', argument " "1"" of type '" "GDALRasterAttributeTableShadow *""'");
7458 : }
7459 40 : arg1 = reinterpret_cast< GDALRasterAttributeTableShadow * >(argp1);
7460 40 : ecode2 = SWIG_AsVal_int(obj1, &val2);
7461 40 : if (!SWIG_IsOK(ecode2)) {
7462 0 : SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RATValuesIONumPyRead" "', argument " "2"" of type '" "int""'");
7463 : }
7464 40 : arg2 = static_cast< int >(val2);
7465 40 : ecode3 = SWIG_AsVal_int(obj2, &val3);
7466 40 : if (!SWIG_IsOK(ecode3)) {
7467 0 : SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RATValuesIONumPyRead" "', argument " "3"" of type '" "int""'");
7468 : }
7469 40 : arg3 = static_cast< int >(val3);
7470 40 : ecode4 = SWIG_AsVal_int(obj3, &val4);
7471 40 : if (!SWIG_IsOK(ecode4)) {
7472 0 : SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "RATValuesIONumPyRead" "', argument " "4"" of type '" "int""'");
7473 : }
7474 40 : arg4 = static_cast< int >(val4);
7475 40 : {
7476 40 : const int bLocalUseExceptions = GetUseExceptions();
7477 40 : if ( bLocalUseExceptions ) {
7478 40 : pushErrorHandler();
7479 : }
7480 40 : result = (PyObject *)RATValuesIONumPyRead(arg1,arg2,arg3,arg4);
7481 40 : if ( bLocalUseExceptions ) {
7482 40 : popErrorHandler();
7483 : }
7484 : #ifndef SED_HACKS
7485 : if ( bLocalUseExceptions ) {
7486 : CPLErr eclass = CPLGetLastErrorType();
7487 : if ( eclass == CE_Failure || eclass == CE_Fatal ) {
7488 : SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
7489 : }
7490 : }
7491 : #endif
7492 : }
7493 40 : resultobj = result;
7494 40 : if ( ReturnSame(bLocalUseExceptionsCode) ) { CPLErr eclass = CPLGetLastErrorType(); if ( eclass == CE_Failure || eclass == CE_Fatal ) { std::string osMsg = CPLGetLastErrorMsg(); Py_XDECREF(resultobj); SWIG_Error( SWIG_RuntimeError, osMsg.c_str() ); return NULL; } }
7495 : return resultobj;
7496 : fail:
7497 : return NULL;
7498 : }
7499 :
7500 :
7501 : static PyMethodDef SwigMethods[] = {
7502 : { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL},
7503 : { "delete_VirtualMem", _wrap_delete_VirtualMem, METH_O, "delete_VirtualMem(VirtualMem self)"},
7504 : { "VirtualMem_GetAddr", _wrap_VirtualMem_GetAddr, METH_O, "VirtualMem_GetAddr(VirtualMem self)"},
7505 : { "VirtualMem_Pin", _wrap_VirtualMem_Pin, METH_VARARGS, "VirtualMem_Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)"},
7506 : { "VirtualMem_swigregister", VirtualMem_swigregister, METH_O, NULL},
7507 : { "GetUseExceptions", _wrap_GetUseExceptions, METH_NOARGS, "GetUseExceptions() -> int"},
7508 : { "_GetExceptionsLocal", _wrap__GetExceptionsLocal, METH_NOARGS, "_GetExceptionsLocal() -> int"},
7509 : { "_SetExceptionsLocal", _wrap__SetExceptionsLocal, METH_O, "_SetExceptionsLocal(int bVal)"},
7510 : { "_UseExceptions", _wrap__UseExceptions, METH_NOARGS, "_UseExceptions()"},
7511 : { "_DontUseExceptions", _wrap__DontUseExceptions, METH_NOARGS, "_DontUseExceptions()"},
7512 : { "_UserHasSpecifiedIfUsingExceptions", _wrap__UserHasSpecifiedIfUsingExceptions, METH_NOARGS, "_UserHasSpecifiedIfUsingExceptions() -> int"},
7513 : { "TermProgress_nocb", (PyCFunction)(void(*)(void))_wrap_TermProgress_nocb, METH_VARARGS|METH_KEYWORDS, "TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) -> int"},
7514 : { "OpenNumPyArray", _wrap_OpenNumPyArray, METH_VARARGS, "OpenNumPyArray(PyArrayObject * psArray, bool binterleave) -> Dataset"},
7515 : { "OpenMultiDimensionalNumPyArray", _wrap_OpenMultiDimensionalNumPyArray, METH_O, "OpenMultiDimensionalNumPyArray(PyArrayObject * psArray) -> Dataset"},
7516 : { "GetArrayFilename", _wrap_GetArrayFilename, METH_O, "GetArrayFilename(PyArrayObject * psArray) -> retStringAndCPLFree *"},
7517 : { "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"},
7518 : { "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"},
7519 : { "MDArrayIONumPy", _wrap_MDArrayIONumPy, METH_VARARGS, "MDArrayIONumPy(bool bWrite, GDALMDArrayHS * mdarray, PyArrayObject * psArray, int nDims1, int nDims3, GDALExtendedDataTypeHS * buffer_datatype) -> CPLErr"},
7520 : { "AddNumpyArrayToDict", _wrap_AddNumpyArrayToDict, METH_VARARGS, "AddNumpyArrayToDict(PyObject * dict, ArrowSchema const * schemaField, ArrowArray const * arrayField, std::string const & osPrefix, PyObject * pointerArrayKeeper) -> bool"},
7521 : { "_RecordBatchAsNumpy", _wrap__RecordBatchAsNumpy, METH_VARARGS, "_RecordBatchAsNumpy(VoidPtrAsLong recordBatchPtr, VoidPtrAsLong schemaPtr, PyObject * pointerArrayKeeper) -> PyObject *"},
7522 : { "VirtualMemGetArray", _wrap_VirtualMemGetArray, METH_O, "VirtualMemGetArray(VirtualMem virtualmem)"},
7523 : { "RATValuesIONumPyWrite", (PyCFunction)(void(*)(void))_wrap_RATValuesIONumPyWrite, METH_VARARGS|METH_KEYWORDS, "RATValuesIONumPyWrite(RasterAttributeTable poRAT, int nField, int nStart, PyArrayObject * psArray) -> CPLErr"},
7524 : { "RATValuesIONumPyRead", (PyCFunction)(void(*)(void))_wrap_RATValuesIONumPyRead, METH_VARARGS|METH_KEYWORDS, "RATValuesIONumPyRead(RasterAttributeTable poRAT, int nField, int nStart, int nLength) -> PyObject *"},
7525 : { NULL, NULL, 0, NULL }
7526 : };
7527 :
7528 : static PyMethodDef SwigMethods_proxydocs[] = {
7529 : { NULL, NULL, 0, NULL }
7530 : };
7531 :
7532 :
7533 : /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
7534 :
7535 0 : static void *_p_GDALComputedRasterBandShadowTo_p_GDALRasterBandShadow(void *x, int *SWIGUNUSEDPARM(newmemory)) {
7536 0 : return (void *)((GDALRasterBandShadow *) ((GDALComputedRasterBandShadow *) x));
7537 : }
7538 : static swig_type_info _swigt__p_ArrowArray = {"_p_ArrowArray", "ArrowArray *", 0, 0, (void*)0, 0};
7539 : static swig_type_info _swigt__p_ArrowSchema = {"_p_ArrowSchema", "ArrowSchema *", 0, 0, (void*)0, 0};
7540 : static swig_type_info _swigt__p_CPLVirtualMemShadow = {"_p_CPLVirtualMemShadow", "CPLVirtualMemShadow *", 0, 0, (void*)0, 0};
7541 : static swig_type_info _swigt__p_GDALDataType = {"_p_GDALDataType", "GDALDataType *", 0, 0, (void*)0, 0};
7542 : static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, (void*)0, 0};
7543 : static swig_type_info _swigt__p_GDALExtendedDataTypeHS = {"_p_GDALExtendedDataTypeHS", "GDALExtendedDataTypeHS *", 0, 0, (void*)0, 0};
7544 : static swig_type_info _swigt__p_GDALMDArrayHS = {"_p_GDALMDArrayHS", "GDALMDArrayHS *", 0, 0, (void*)0, 0};
7545 : static swig_type_info _swigt__p_GDALProgressFunc = {"_p_GDALProgressFunc", "GDALProgressFunc *", 0, 0, (void*)0, 0};
7546 : static swig_type_info _swigt__p_GDALRasterAttributeTableShadow = {"_p_GDALRasterAttributeTableShadow", "GDALRasterAttributeTableShadow *", 0, 0, (void*)0, 0};
7547 : static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, (void*)0, 0};
7548 : static swig_type_info _swigt__p_GDALComputedRasterBandShadow = {"_p_GDALComputedRasterBandShadow", 0, 0, 0, 0, 0};
7549 : static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, (void*)0, 0};
7550 : static swig_type_info _swigt__p_GUIntBig = {"_p_GUIntBig", "GUIntBig *", 0, 0, (void*)0, 0};
7551 : static swig_type_info _swigt__p_PyArrayObject = {"_p_PyArrayObject", "PyArrayObject *", 0, 0, (void*)0, 0};
7552 : static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
7553 : 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};
7554 : static swig_type_info _swigt__p_int = {"_p_int", "GDALRATFieldType *|CPLErr *|int *|GDALRATTableType *|GDALRATFieldUsage *|GDALRIOResampleAlg *", 0, 0, (void*)0, 0};
7555 : static swig_type_info _swigt__p_p_CPLVirtualMemShadow = {"_p_p_CPLVirtualMemShadow", "CPLVirtualMemShadow **", 0, 0, (void*)0, 0};
7556 : static swig_type_info _swigt__p_p_void = {"_p_p_void", "void **", 0, 0, (void*)0, 0};
7557 : static swig_type_info _swigt__p_size_t = {"_p_size_t", "size_t *", 0, 0, (void*)0, 0};
7558 : static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0};
7559 :
7560 : static swig_type_info *swig_type_initial[] = {
7561 : &_swigt__p_ArrowArray,
7562 : &_swigt__p_ArrowSchema,
7563 : &_swigt__p_CPLVirtualMemShadow,
7564 : &_swigt__p_GDALComputedRasterBandShadow,
7565 : &_swigt__p_GDALDataType,
7566 : &_swigt__p_GDALDatasetShadow,
7567 : &_swigt__p_GDALExtendedDataTypeHS,
7568 : &_swigt__p_GDALMDArrayHS,
7569 : &_swigt__p_GDALProgressFunc,
7570 : &_swigt__p_GDALRasterAttributeTableShadow,
7571 : &_swigt__p_GDALRasterBandShadow,
7572 : &_swigt__p_GIntBig,
7573 : &_swigt__p_GUIntBig,
7574 : &_swigt__p_PyArrayObject,
7575 : &_swigt__p_char,
7576 : &_swigt__p_f_double_p_q_const__char_p_void__int,
7577 : &_swigt__p_int,
7578 : &_swigt__p_p_CPLVirtualMemShadow,
7579 : &_swigt__p_p_void,
7580 : &_swigt__p_size_t,
7581 : &_swigt__p_std__string,
7582 : };
7583 :
7584 : static swig_cast_info _swigc__p_ArrowArray[] = { {&_swigt__p_ArrowArray, 0, 0, 0},{0, 0, 0, 0}};
7585 : static swig_cast_info _swigc__p_ArrowSchema[] = { {&_swigt__p_ArrowSchema, 0, 0, 0},{0, 0, 0, 0}};
7586 : static swig_cast_info _swigc__p_CPLVirtualMemShadow[] = { {&_swigt__p_CPLVirtualMemShadow, 0, 0, 0},{0, 0, 0, 0}};
7587 : static swig_cast_info _swigc__p_GDALDataType[] = { {&_swigt__p_GDALDataType, 0, 0, 0},{0, 0, 0, 0}};
7588 : static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}};
7589 : static swig_cast_info _swigc__p_GDALExtendedDataTypeHS[] = { {&_swigt__p_GDALExtendedDataTypeHS, 0, 0, 0},{0, 0, 0, 0}};
7590 : static swig_cast_info _swigc__p_GDALMDArrayHS[] = { {&_swigt__p_GDALMDArrayHS, 0, 0, 0},{0, 0, 0, 0}};
7591 : static swig_cast_info _swigc__p_GDALProgressFunc[] = { {&_swigt__p_GDALProgressFunc, 0, 0, 0},{0, 0, 0, 0}};
7592 : static swig_cast_info _swigc__p_GDALRasterAttributeTableShadow[] = { {&_swigt__p_GDALRasterAttributeTableShadow, 0, 0, 0},{0, 0, 0, 0}};
7593 : static swig_cast_info _swigc__p_GDALComputedRasterBandShadow[] = {{&_swigt__p_GDALComputedRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}};
7594 : static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0}, {&_swigt__p_GDALComputedRasterBandShadow, _p_GDALComputedRasterBandShadowTo_p_GDALRasterBandShadow, 0, 0},{0, 0, 0, 0}};
7595 : static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}};
7596 : static swig_cast_info _swigc__p_GUIntBig[] = { {&_swigt__p_GUIntBig, 0, 0, 0},{0, 0, 0, 0}};
7597 : static swig_cast_info _swigc__p_PyArrayObject[] = { {&_swigt__p_PyArrayObject, 0, 0, 0},{0, 0, 0, 0}};
7598 : static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
7599 : 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}};
7600 : static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
7601 : static swig_cast_info _swigc__p_p_CPLVirtualMemShadow[] = { {&_swigt__p_p_CPLVirtualMemShadow, 0, 0, 0},{0, 0, 0, 0}};
7602 : static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}};
7603 : static swig_cast_info _swigc__p_size_t[] = { {&_swigt__p_size_t, 0, 0, 0},{0, 0, 0, 0}};
7604 : static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}};
7605 :
7606 : static swig_cast_info *swig_cast_initial[] = {
7607 : _swigc__p_ArrowArray,
7608 : _swigc__p_ArrowSchema,
7609 : _swigc__p_CPLVirtualMemShadow,
7610 : _swigc__p_GDALComputedRasterBandShadow,
7611 : _swigc__p_GDALDataType,
7612 : _swigc__p_GDALDatasetShadow,
7613 : _swigc__p_GDALExtendedDataTypeHS,
7614 : _swigc__p_GDALMDArrayHS,
7615 : _swigc__p_GDALProgressFunc,
7616 : _swigc__p_GDALRasterAttributeTableShadow,
7617 : _swigc__p_GDALRasterBandShadow,
7618 : _swigc__p_GIntBig,
7619 : _swigc__p_GUIntBig,
7620 : _swigc__p_PyArrayObject,
7621 : _swigc__p_char,
7622 : _swigc__p_f_double_p_q_const__char_p_void__int,
7623 : _swigc__p_int,
7624 : _swigc__p_p_CPLVirtualMemShadow,
7625 : _swigc__p_p_void,
7626 : _swigc__p_size_t,
7627 : _swigc__p_std__string,
7628 : };
7629 :
7630 :
7631 : /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
7632 :
7633 : static swig_const_info swig_const_table[] = {
7634 : { SWIG_PY_POINTER, "TermProgress", 0, 0, (void *)((int (*)(double,char const *,void *))(GDALTermProgress)), &SWIGTYPE_p_f_double_p_q_const__char_p_void__int },
7635 : {0, 0, 0, 0.0, 0, 0}};
7636 :
7637 : #ifdef __cplusplus
7638 : }
7639 : #endif
7640 : /* -----------------------------------------------------------------------------
7641 : * Type initialization:
7642 : * This problem is tough by the requirement that no dynamic
7643 : * memory is used. Also, since swig_type_info structures store pointers to
7644 : * swig_cast_info structures and swig_cast_info structures store pointers back
7645 : * to swig_type_info structures, we need some lookup code at initialization.
7646 : * The idea is that swig generates all the structures that are needed.
7647 : * The runtime then collects these partially filled structures.
7648 : * The SWIG_InitializeModule function takes these initial arrays out of
7649 : * swig_module, and does all the lookup, filling in the swig_module.types
7650 : * array with the correct data and linking the correct swig_cast_info
7651 : * structures together.
7652 : *
7653 : * The generated swig_type_info structures are assigned statically to an initial
7654 : * array. We just loop through that array, and handle each type individually.
7655 : * First we lookup if this type has been already loaded, and if so, use the
7656 : * loaded structure instead of the generated one. Then we have to fill in the
7657 : * cast linked list. The cast data is initially stored in something like a
7658 : * two-dimensional array. Each row corresponds to a type (there are the same
7659 : * number of rows as there are in the swig_type_initial array). Each entry in
7660 : * a column is one of the swig_cast_info structures for that type.
7661 : * The cast_initial array is actually an array of arrays, because each row has
7662 : * a variable number of columns. So to actually build the cast linked list,
7663 : * we find the array of casts associated with the type, and loop through it
7664 : * adding the casts to the list. The one last trick we need to do is making
7665 : * sure the type pointer in the swig_cast_info struct is correct.
7666 : *
7667 : * First off, we lookup the cast->type name to see if it is already loaded.
7668 : * There are three cases to handle:
7669 : * 1) If the cast->type has already been loaded AND the type we are adding
7670 : * casting info to has not been loaded (it is in this module), THEN we
7671 : * replace the cast->type pointer with the type pointer that has already
7672 : * been loaded.
7673 : * 2) If BOTH types (the one we are adding casting info to, and the
7674 : * cast->type) are loaded, THEN the cast info has already been loaded by
7675 : * the previous module so we just ignore it.
7676 : * 3) Finally, if cast->type has not already been loaded, then we add that
7677 : * swig_cast_info to the linked list (because the cast->type) pointer will
7678 : * be correct.
7679 : * ----------------------------------------------------------------------------- */
7680 :
7681 : #ifdef __cplusplus
7682 : extern "C" {
7683 : #if 0
7684 : } /* c-mode */
7685 : #endif
7686 : #endif
7687 :
7688 : #if 0
7689 : #define SWIGRUNTIME_DEBUG
7690 : #endif
7691 :
7692 :
7693 : SWIGRUNTIME void
7694 : SWIG_InitializeModule(void *clientdata) {
7695 : size_t i;
7696 : swig_module_info *module_head, *iter;
7697 : int init;
7698 :
7699 : /* check to see if the circular list has been setup, if not, set it up */
7700 : if (swig_module.next==0) {
7701 : /* Initialize the swig_module */
7702 : swig_module.type_initial = swig_type_initial;
7703 : swig_module.cast_initial = swig_cast_initial;
7704 : swig_module.next = &swig_module;
7705 : init = 1;
7706 : } else {
7707 : init = 0;
7708 : }
7709 :
7710 : /* Try and load any already created modules */
7711 : module_head = SWIG_GetModule(clientdata);
7712 : if (!module_head) {
7713 : /* This is the first module loaded for this interpreter */
7714 : /* so set the swig module into the interpreter */
7715 : SWIG_SetModule(clientdata, &swig_module);
7716 : } else {
7717 : /* the interpreter has loaded a SWIG module, but has it loaded this one? */
7718 : iter=module_head;
7719 : do {
7720 : if (iter==&swig_module) {
7721 : /* Our module is already in the list, so there's nothing more to do. */
7722 : return;
7723 : }
7724 : iter=iter->next;
7725 : } while (iter!= module_head);
7726 :
7727 : /* otherwise we must add our module into the list */
7728 : swig_module.next = module_head->next;
7729 : module_head->next = &swig_module;
7730 : }
7731 :
7732 : /* When multiple interpreters are used, a module could have already been initialized in
7733 : a different interpreter, but not yet have a pointer in this interpreter.
7734 : In this case, we do not want to continue adding types... everything should be
7735 : set up already */
7736 : if (init == 0) return;
7737 :
7738 : /* Now work on filling in swig_module.types */
7739 : #ifdef SWIGRUNTIME_DEBUG
7740 : printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size);
7741 : #endif
7742 : for (i = 0; i < swig_module.size; ++i) {
7743 : swig_type_info *type = 0;
7744 : swig_type_info *ret;
7745 : swig_cast_info *cast;
7746 :
7747 : #ifdef SWIGRUNTIME_DEBUG
7748 : printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
7749 : #endif
7750 :
7751 : /* if there is another module already loaded */
7752 : if (swig_module.next != &swig_module) {
7753 : type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
7754 : }
7755 : if (type) {
7756 : /* Overwrite clientdata field */
7757 : #ifdef SWIGRUNTIME_DEBUG
7758 : printf("SWIG_InitializeModule: found type %s\n", type->name);
7759 : #endif
7760 : if (swig_module.type_initial[i]->clientdata) {
7761 : type->clientdata = swig_module.type_initial[i]->clientdata;
7762 : #ifdef SWIGRUNTIME_DEBUG
7763 : printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
7764 : #endif
7765 : }
7766 : } else {
7767 : type = swig_module.type_initial[i];
7768 : }
7769 :
7770 : /* Insert casting types */
7771 : cast = swig_module.cast_initial[i];
7772 : while (cast->type) {
7773 : /* Don't need to add information already in the list */
7774 : ret = 0;
7775 : #ifdef SWIGRUNTIME_DEBUG
7776 : printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
7777 : #endif
7778 : if (swig_module.next != &swig_module) {
7779 : ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
7780 : #ifdef SWIGRUNTIME_DEBUG
7781 : if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
7782 : #endif
7783 : }
7784 : if (ret) {
7785 : if (type == swig_module.type_initial[i]) {
7786 : #ifdef SWIGRUNTIME_DEBUG
7787 : printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
7788 : #endif
7789 : cast->type = ret;
7790 : ret = 0;
7791 : } else {
7792 : /* Check for casting already in the list */
7793 : swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
7794 : #ifdef SWIGRUNTIME_DEBUG
7795 : if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
7796 : #endif
7797 : if (!ocast) ret = 0;
7798 : }
7799 : }
7800 :
7801 : if (!ret) {
7802 : #ifdef SWIGRUNTIME_DEBUG
7803 : printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
7804 : #endif
7805 : if (type->cast) {
7806 : type->cast->prev = cast;
7807 : cast->next = type->cast;
7808 : }
7809 : type->cast = cast;
7810 : }
7811 : cast++;
7812 : }
7813 : /* Set entry in modules->types array equal to the type */
7814 : swig_module.types[i] = type;
7815 : }
7816 : swig_module.types[i] = 0;
7817 :
7818 : #ifdef SWIGRUNTIME_DEBUG
7819 : printf("**** SWIG_InitializeModule: Cast List ******\n");
7820 : for (i = 0; i < swig_module.size; ++i) {
7821 : int j = 0;
7822 : swig_cast_info *cast = swig_module.cast_initial[i];
7823 : printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
7824 : while (cast->type) {
7825 : printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
7826 : cast++;
7827 : ++j;
7828 : }
7829 : printf("---- Total casts: %d\n",j);
7830 : }
7831 : printf("**** SWIG_InitializeModule: Cast List ******\n");
7832 : #endif
7833 : }
7834 :
7835 : /* This function will propagate the clientdata field of type to
7836 : * any new swig_type_info structures that have been added into the list
7837 : * of equivalent types. It is like calling
7838 : * SWIG_TypeClientData(type, clientdata) a second time.
7839 : */
7840 : SWIGRUNTIME void
7841 : SWIG_PropagateClientData(void) {
7842 : size_t i;
7843 : swig_cast_info *equiv;
7844 : static int init_run = 0;
7845 :
7846 : if (init_run) return;
7847 : init_run = 1;
7848 :
7849 : for (i = 0; i < swig_module.size; i++) {
7850 : if (swig_module.types[i]->clientdata) {
7851 : equiv = swig_module.types[i]->cast;
7852 : while (equiv) {
7853 : if (!equiv->converter) {
7854 : if (equiv->type && !equiv->type->clientdata)
7855 : SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
7856 : }
7857 : equiv = equiv->next;
7858 : }
7859 : }
7860 : }
7861 : }
7862 :
7863 : #ifdef __cplusplus
7864 : #if 0
7865 : {
7866 : /* c-mode */
7867 : #endif
7868 : }
7869 : #endif
7870 :
7871 :
7872 :
7873 : #ifdef __cplusplus
7874 : extern "C" {
7875 : #endif
7876 :
7877 : /* Python-specific SWIG API */
7878 : #define SWIG_newvarlink() SWIG_Python_newvarlink()
7879 : #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
7880 : #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
7881 :
7882 : /* -----------------------------------------------------------------------------
7883 : * global variable support code.
7884 : * ----------------------------------------------------------------------------- */
7885 :
7886 : typedef struct swig_globalvar {
7887 : char *name; /* Name of global variable */
7888 : PyObject *(*get_attr)(void); /* Return the current value */
7889 : int (*set_attr)(PyObject *); /* Set the value */
7890 : struct swig_globalvar *next;
7891 : } swig_globalvar;
7892 :
7893 : typedef struct swig_varlinkobject {
7894 : PyObject_HEAD
7895 : swig_globalvar *vars;
7896 : } swig_varlinkobject;
7897 :
7898 : SWIGINTERN PyObject *
7899 : swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
7900 : #if PY_VERSION_HEX >= 0x03000000
7901 : return PyUnicode_InternFromString("<Swig global variables>");
7902 : #else
7903 : return PyString_FromString("<Swig global variables>");
7904 : #endif
7905 : }
7906 :
7907 : SWIGINTERN PyObject *
7908 : swig_varlink_str(swig_varlinkobject *v) {
7909 : #if PY_VERSION_HEX >= 0x03000000
7910 : PyObject *str = PyUnicode_InternFromString("(");
7911 : PyObject *tail;
7912 : PyObject *joined;
7913 : swig_globalvar *var;
7914 : for (var = v->vars; var; var=var->next) {
7915 : tail = PyUnicode_FromString(var->name);
7916 : joined = PyUnicode_Concat(str, tail);
7917 : Py_DecRef(str);
7918 : Py_DecRef(tail);
7919 : str = joined;
7920 : if (var->next) {
7921 : tail = PyUnicode_InternFromString(", ");
7922 : joined = PyUnicode_Concat(str, tail);
7923 : Py_DecRef(str);
7924 : Py_DecRef(tail);
7925 : str = joined;
7926 : }
7927 : }
7928 : tail = PyUnicode_InternFromString(")");
7929 : joined = PyUnicode_Concat(str, tail);
7930 : Py_DecRef(str);
7931 : Py_DecRef(tail);
7932 : str = joined;
7933 : #else
7934 : PyObject *str = PyString_FromString("(");
7935 : swig_globalvar *var;
7936 : for (var = v->vars; var; var=var->next) {
7937 : PyString_ConcatAndDel(&str,PyString_FromString(var->name));
7938 : if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
7939 : }
7940 : PyString_ConcatAndDel(&str,PyString_FromString(")"));
7941 : #endif
7942 : return str;
7943 : }
7944 :
7945 : SWIGINTERN void
7946 : swig_varlink_dealloc(swig_varlinkobject *v) {
7947 : swig_globalvar *var = v->vars;
7948 : while (var) {
7949 : swig_globalvar *n = var->next;
7950 : free(var->name);
7951 : free(var);
7952 : var = n;
7953 : }
7954 : }
7955 :
7956 : SWIGINTERN PyObject *
7957 : swig_varlink_getattr(swig_varlinkobject *v, char *n) {
7958 : PyObject *res = NULL;
7959 : swig_globalvar *var = v->vars;
7960 : while (var) {
7961 : if (strcmp(var->name,n) == 0) {
7962 : res = (*var->get_attr)();
7963 : break;
7964 : }
7965 : var = var->next;
7966 : }
7967 : if (res == NULL && !PyErr_Occurred()) {
7968 : PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
7969 : }
7970 : return res;
7971 : }
7972 :
7973 : SWIGINTERN int
7974 : swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
7975 : int res = 1;
7976 : swig_globalvar *var = v->vars;
7977 : while (var) {
7978 : if (strcmp(var->name,n) == 0) {
7979 : res = (*var->set_attr)(p);
7980 : break;
7981 : }
7982 : var = var->next;
7983 : }
7984 : if (res == 1 && !PyErr_Occurred()) {
7985 : PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
7986 : }
7987 : return res;
7988 : }
7989 :
7990 : SWIGINTERN PyTypeObject*
7991 : swig_varlink_type(void) {
7992 : static char varlink__doc__[] = "Swig var link object";
7993 : static PyTypeObject varlink_type;
7994 : static int type_init = 0;
7995 : if (!type_init) {
7996 : const PyTypeObject tmp = {
7997 : #if PY_VERSION_HEX >= 0x03000000
7998 : PyVarObject_HEAD_INIT(NULL, 0)
7999 : #else
8000 : PyObject_HEAD_INIT(NULL)
8001 : 0, /* ob_size */
8002 : #endif
8003 : "swigvarlink", /* tp_name */
8004 : sizeof(swig_varlinkobject), /* tp_basicsize */
8005 : 0, /* tp_itemsize */
8006 : (destructor) swig_varlink_dealloc, /* tp_dealloc */
8007 : 0, /* tp_print */
8008 : (getattrfunc) swig_varlink_getattr, /* tp_getattr */
8009 : (setattrfunc) swig_varlink_setattr, /* tp_setattr */
8010 : 0, /* tp_compare */
8011 : (reprfunc) swig_varlink_repr, /* tp_repr */
8012 : 0, /* tp_as_number */
8013 : 0, /* tp_as_sequence */
8014 : 0, /* tp_as_mapping */
8015 : 0, /* tp_hash */
8016 : 0, /* tp_call */
8017 : (reprfunc) swig_varlink_str, /* tp_str */
8018 : 0, /* tp_getattro */
8019 : 0, /* tp_setattro */
8020 : 0, /* tp_as_buffer */
8021 : 0, /* tp_flags */
8022 : varlink__doc__, /* tp_doc */
8023 : 0, /* tp_traverse */
8024 : 0, /* tp_clear */
8025 : 0, /* tp_richcompare */
8026 : 0, /* tp_weaklistoffset */
8027 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
8028 : 0, /* tp_del */
8029 : 0, /* tp_version_tag */
8030 : #if PY_VERSION_HEX >= 0x03040000
8031 : 0, /* tp_finalize */
8032 : #endif
8033 : #ifdef COUNT_ALLOCS
8034 : 0, /* tp_allocs */
8035 : 0, /* tp_frees */
8036 : 0, /* tp_maxalloc */
8037 : 0, /* tp_prev */
8038 : 0 /* tp_next */
8039 : #endif
8040 : };
8041 : varlink_type = tmp;
8042 : type_init = 1;
8043 : if (PyType_Ready(&varlink_type) < 0)
8044 : return NULL;
8045 : }
8046 : return &varlink_type;
8047 : }
8048 :
8049 : /* Create a variable linking object for use later */
8050 : SWIGINTERN PyObject *
8051 : SWIG_Python_newvarlink(void) {
8052 : swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
8053 : if (result) {
8054 : result->vars = 0;
8055 : }
8056 : return ((PyObject*) result);
8057 : }
8058 :
8059 : SWIGINTERN void
8060 : SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
8061 : swig_varlinkobject *v = (swig_varlinkobject *) p;
8062 : swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
8063 : if (gv) {
8064 : size_t size = strlen(name)+1;
8065 : gv->name = (char *)malloc(size);
8066 : if (gv->name) {
8067 : memcpy(gv->name, name, size);
8068 : gv->get_attr = get_attr;
8069 : gv->set_attr = set_attr;
8070 : gv->next = v->vars;
8071 : }
8072 : }
8073 : v->vars = gv;
8074 : }
8075 :
8076 : SWIGINTERN PyObject *
8077 : SWIG_globals(void) {
8078 : static PyObject *globals = 0;
8079 : if (!globals) {
8080 : globals = SWIG_newvarlink();
8081 : }
8082 : return globals;
8083 : }
8084 :
8085 : /* -----------------------------------------------------------------------------
8086 : * constants/methods manipulation
8087 : * ----------------------------------------------------------------------------- */
8088 :
8089 : /* Install Constants */
8090 : SWIGINTERN void
8091 224 : SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
8092 224 : PyObject *obj = 0;
8093 224 : size_t i;
8094 448 : for (i = 0; constants[i].type; ++i) {
8095 224 : switch(constants[i].type) {
8096 224 : case SWIG_PY_POINTER:
8097 224 : obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
8098 224 : break;
8099 0 : case SWIG_PY_BINARY:
8100 0 : obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
8101 : break;
8102 : default:
8103 : obj = 0;
8104 : break;
8105 : }
8106 224 : if (obj) {
8107 224 : PyDict_SetItemString(d, constants[i].name, obj);
8108 224 : Py_DECREF(obj);
8109 : }
8110 : }
8111 224 : }
8112 :
8113 : /* -----------------------------------------------------------------------------*/
8114 : /* Fix SwigMethods to carry the callback ptrs when needed */
8115 : /* -----------------------------------------------------------------------------*/
8116 :
8117 : SWIGINTERN void
8118 224 : SWIG_Python_FixMethods(PyMethodDef *methods,
8119 : swig_const_info *const_table,
8120 : swig_type_info **types,
8121 : swig_type_info **types_initial) {
8122 224 : size_t i;
8123 5376 : for (i = 0; methods[i].ml_name; ++i) {
8124 5152 : const char *c = methods[i].ml_doc;
8125 5152 : if (!c) continue;
8126 4704 : c = strstr(c, "swig_ptr: ");
8127 4704 : if (c) {
8128 0 : int j;
8129 0 : swig_const_info *ci = 0;
8130 0 : const char *name = c + 10;
8131 0 : for (j = 0; const_table[j].type; ++j) {
8132 0 : if (strncmp(const_table[j].name, name,
8133 : strlen(const_table[j].name)) == 0) {
8134 : ci = &(const_table[j]);
8135 : break;
8136 : }
8137 : }
8138 0 : if (ci) {
8139 5152 : void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
8140 0 : if (ptr) {
8141 0 : size_t shift = (ci->ptype) - types;
8142 0 : swig_type_info *ty = types_initial[shift];
8143 0 : size_t ldoc = (c - methods[i].ml_doc);
8144 0 : size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
8145 0 : char *ndoc = (char*)malloc(ldoc + lptr + 10);
8146 0 : if (ndoc) {
8147 0 : char *buff = ndoc;
8148 0 : memcpy(buff, methods[i].ml_doc, ldoc);
8149 0 : buff += ldoc;
8150 0 : memcpy(buff, "swig_ptr: ", 10);
8151 0 : buff += 10;
8152 0 : SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
8153 0 : methods[i].ml_doc = ndoc;
8154 : }
8155 : }
8156 : }
8157 : }
8158 : }
8159 224 : }
8160 :
8161 : /* -----------------------------------------------------------------------------
8162 : * Method creation and docstring support functions
8163 : * ----------------------------------------------------------------------------- */
8164 :
8165 : /* -----------------------------------------------------------------------------
8166 : * Function to find the method definition with the correct docstring for the
8167 : * proxy module as opposed to the low-level API
8168 : * ----------------------------------------------------------------------------- */
8169 :
8170 0 : SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) {
8171 : /* Find the function in the modified method table */
8172 0 : size_t offset = 0;
8173 0 : int found = 0;
8174 0 : while (SwigMethods_proxydocs[offset].ml_meth != NULL) {
8175 0 : if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {
8176 : found = 1;
8177 : break;
8178 : }
8179 0 : offset++;
8180 : }
8181 : /* Use the copy with the modified docstring if available */
8182 0 : return found ? &SwigMethods_proxydocs[offset] : NULL;
8183 : }
8184 :
8185 : /* -----------------------------------------------------------------------------
8186 : * Wrapper of PyInstanceMethod_New() used in Python 3
8187 : * It is exported to the generated module, used for -fastproxy
8188 : * ----------------------------------------------------------------------------- */
8189 :
8190 0 : SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
8191 0 : if (PyCFunction_Check(func)) {
8192 0 : PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
8193 0 : PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
8194 0 : if (ml)
8195 0 : func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
8196 : }
8197 : #if PY_VERSION_HEX >= 0x03000000
8198 0 : return PyInstanceMethod_New(func);
8199 : #else
8200 : return PyMethod_New(func, NULL, NULL);
8201 : #endif
8202 : }
8203 :
8204 : /* -----------------------------------------------------------------------------
8205 : * Wrapper of PyStaticMethod_New()
8206 : * It is exported to the generated module, used for -fastproxy
8207 : * ----------------------------------------------------------------------------- */
8208 :
8209 : SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
8210 : if (PyCFunction_Check(func)) {
8211 : PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
8212 : PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
8213 : if (ml)
8214 : func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
8215 : }
8216 : return PyStaticMethod_New(func);
8217 : }
8218 :
8219 : #ifdef __cplusplus
8220 : }
8221 : #endif
8222 :
8223 : /* -----------------------------------------------------------------------------*
8224 : * Partial Init method
8225 : * -----------------------------------------------------------------------------*/
8226 :
8227 : #ifdef __cplusplus
8228 : extern "C"
8229 : #endif
8230 :
8231 : SWIGEXPORT
8232 : #if PY_VERSION_HEX >= 0x03000000
8233 : PyObject*
8234 : #else
8235 : void
8236 : #endif
8237 224 : SWIG_init(void) {
8238 224 : PyObject *m, *d, *md, *globals;
8239 :
8240 : #if PY_VERSION_HEX >= 0x03000000
8241 224 : static struct PyModuleDef SWIG_module = {
8242 : PyModuleDef_HEAD_INIT,
8243 : SWIG_name,
8244 : NULL,
8245 : -1,
8246 : SwigMethods,
8247 : NULL,
8248 : NULL,
8249 : NULL,
8250 : NULL
8251 : };
8252 : #endif
8253 :
8254 : #if defined(SWIGPYTHON_BUILTIN)
8255 : static SwigPyClientData SwigPyObject_clientdata = {
8256 : 0, 0, 0, 0, 0, 0, 0
8257 : };
8258 : static PyGetSetDef this_getset_def = {
8259 : (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
8260 : };
8261 : static SwigPyGetSet thisown_getset_closure = {
8262 : SwigPyObject_own,
8263 : SwigPyObject_own
8264 : };
8265 : static PyGetSetDef thisown_getset_def = {
8266 : (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
8267 : };
8268 : PyTypeObject *builtin_pytype;
8269 : int builtin_base_count;
8270 : swig_type_info *builtin_basetype;
8271 : PyObject *tuple;
8272 : PyGetSetDescrObject *static_getset;
8273 : PyTypeObject *metatype;
8274 : PyTypeObject *swigpyobject;
8275 : SwigPyClientData *cd;
8276 : PyObject *public_interface, *public_symbol;
8277 : PyObject *this_descr;
8278 : PyObject *thisown_descr;
8279 : PyObject *self = 0;
8280 : int i;
8281 :
8282 : (void)builtin_pytype;
8283 : (void)builtin_base_count;
8284 : (void)builtin_basetype;
8285 : (void)tuple;
8286 : (void)static_getset;
8287 : (void)self;
8288 :
8289 : /* Metaclass is used to implement static member variables */
8290 : metatype = SwigPyObjectType();
8291 : assert(metatype);
8292 : #endif
8293 :
8294 224 : (void)globals;
8295 :
8296 : /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */
8297 224 : SWIG_This();
8298 224 : SWIG_Python_TypeCache();
8299 224 : SwigPyPacked_type();
8300 : #ifndef SWIGPYTHON_BUILTIN
8301 224 : SwigPyObject_type();
8302 : #endif
8303 :
8304 : /* Fix SwigMethods to carry the callback ptrs when needed */
8305 224 : SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
8306 :
8307 : #if PY_VERSION_HEX >= 0x03000000
8308 224 : m = PyModule_Create(&SWIG_module);
8309 : #else
8310 : m = Py_InitModule(SWIG_name, SwigMethods);
8311 : #endif
8312 :
8313 224 : md = d = PyModule_GetDict(m);
8314 224 : (void)md;
8315 :
8316 224 : SWIG_InitializeModule(0);
8317 :
8318 : #ifdef SWIGPYTHON_BUILTIN
8319 : swigpyobject = SwigPyObject_TypeOnce();
8320 :
8321 : SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
8322 : assert(SwigPyObject_stype);
8323 : cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
8324 : if (!cd) {
8325 : SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
8326 : SwigPyObject_clientdata.pytype = swigpyobject;
8327 : } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) {
8328 : PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
8329 : # if PY_VERSION_HEX >= 0x03000000
8330 : return NULL;
8331 : # else
8332 : return;
8333 : # endif
8334 : }
8335 :
8336 : /* All objects have a 'this' attribute */
8337 : this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
8338 : (void)this_descr;
8339 :
8340 : /* All objects have a 'thisown' attribute */
8341 : thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
8342 : (void)thisown_descr;
8343 :
8344 : public_interface = PyList_New(0);
8345 : public_symbol = 0;
8346 : (void)public_symbol;
8347 :
8348 : PyDict_SetItemString(md, "__all__", public_interface);
8349 : Py_DECREF(public_interface);
8350 : for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
8351 : SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
8352 : for (i = 0; swig_const_table[i].name != 0; ++i)
8353 : SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
8354 : #endif
8355 :
8356 224 : SWIG_InstallConstants(d,swig_const_table);
8357 :
8358 :
8359 : #if SWIG_VERSION >= 0x040400
8360 : import_array1(-1);
8361 : #else
8362 224 : import_array();
8363 : #endif
8364 224 : PyDateTime_IMPORT;
8365 224 : GDALRegister_NUMPY();
8366 :
8367 :
8368 :
8369 : /* Initialize threading */
8370 224 : SWIG_PYTHON_INITIALIZE_THREADS;
8371 : #if PY_VERSION_HEX >= 0x03000000
8372 224 : return m;
8373 : #else
8374 : return;
8375 : #endif
8376 : }
8377 :
|