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