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