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