1 /* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (http://www.swig.org).
3 * Version 3.0.12
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;
SwigMovePointerSwigValueWrapper::SwigMovePointer26 SwigMovePointer(T *p) : ptr(p) { }
~SwigMovePointerSwigValueWrapper::SwigMovePointer27 ~SwigMovePointer() { delete ptr; }
operator =SwigValueWrapper::SwigMovePointer28 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:
SwigValueWrapper()33 SwigValueWrapper() : pointer(0) { }
operator =(const T & t)34 SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
operator T&() const35 operator T&() const { return *pointer.ptr; }
operator &()36 T *operator&() { return pointer.ptr; }
37 };
38
SwigValueInit()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(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
170 /* Use debug wrappers with the Python release dll */
171 # undef _DEBUG
172 # include <Python.h>
173 # define _DEBUG
174 #else
175 # include <Python.h>
176 #endif
177
178 /* -----------------------------------------------------------------------------
179 * swigrun.swg
180 *
181 * This file contains generic C API SWIG runtime support for pointer
182 * type checking.
183 * ----------------------------------------------------------------------------- */
184
185 /* This should only be incremented when either the layout of swig_type_info changes,
186 or for whatever reason, the runtime changes incompatibly */
187 #define SWIG_RUNTIME_VERSION "4"
188
189 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
190 #ifdef SWIG_TYPE_TABLE
191 # define SWIG_QUOTE_STRING(x) #x
192 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
193 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
194 #else
195 # define SWIG_TYPE_TABLE_NAME
196 #endif
197
198 /*
199 You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
200 creating a static or dynamic library from the SWIG runtime code.
201 In 99.9% of the cases, SWIG just needs to declare them as 'static'.
202
203 But only do this if strictly necessary, ie, if you have problems
204 with your compiler or suchlike.
205 */
206
207 #ifndef SWIGRUNTIME
208 # define SWIGRUNTIME SWIGINTERN
209 #endif
210
211 #ifndef SWIGRUNTIMEINLINE
212 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
213 #endif
214
215 /* Generic buffer size */
216 #ifndef SWIG_BUFFER_SIZE
217 # define SWIG_BUFFER_SIZE 1024
218 #endif
219
220 /* Flags for pointer conversions */
221 #define SWIG_POINTER_DISOWN 0x1
222 #define SWIG_CAST_NEW_MEMORY 0x2
223
224 /* Flags for new pointer objects */
225 #define SWIG_POINTER_OWN 0x1
226
227
228 /*
229 Flags/methods for returning states.
230
231 The SWIG conversion methods, as ConvertPtr, return an integer
232 that tells if the conversion was successful or not. And if not,
233 an error code can be returned (see swigerrors.swg for the codes).
234
235 Use the following macros/flags to set or process the returning
236 states.
237
238 In old versions of SWIG, code such as the following was usually written:
239
240 if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
241 // success code
242 } else {
243 //fail code
244 }
245
246 Now you can be more explicit:
247
248 int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
249 if (SWIG_IsOK(res)) {
250 // success code
251 } else {
252 // fail code
253 }
254
255 which is the same really, but now you can also do
256
257 Type *ptr;
258 int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
259 if (SWIG_IsOK(res)) {
260 // success code
261 if (SWIG_IsNewObj(res) {
262 ...
263 delete *ptr;
264 } else {
265 ...
266 }
267 } else {
268 // fail code
269 }
270
271 I.e., now SWIG_ConvertPtr can return new objects and you can
272 identify the case and take care of the deallocation. Of course that
273 also requires SWIG_ConvertPtr to return new result values, such as
274
275 int SWIG_ConvertPtr(obj, ptr,...) {
276 if (<obj is ok>) {
277 if (<need new object>) {
278 *ptr = <ptr to new allocated object>;
279 return SWIG_NEWOBJ;
280 } else {
281 *ptr = <ptr to old object>;
282 return SWIG_OLDOBJ;
283 }
284 } else {
285 return SWIG_BADOBJ;
286 }
287 }
288
289 Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
290 more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
291 SWIG errors code.
292
293 Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
294 allows to return the 'cast rank', for example, if you have this
295
296 int food(double)
297 int fooi(int);
298
299 and you call
300
301 food(1) // cast rank '1' (1 -> 1.0)
302 fooi(1) // cast rank '0'
303
304 just use the SWIG_AddCast()/SWIG_CheckState()
305 */
306
307 #define SWIG_OK (0)
308 #define SWIG_ERROR (-1)
309 #define SWIG_IsOK(r) (r >= 0)
310 #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
311
312 /* The CastRankLimit says how many bits are used for the cast rank */
313 #define SWIG_CASTRANKLIMIT (1 << 8)
314 /* The NewMask denotes the object was created (using new/malloc) */
315 #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
316 /* The TmpMask is for in/out typemaps that use temporal objects */
317 #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
318 /* Simple returning values */
319 #define SWIG_BADOBJ (SWIG_ERROR)
320 #define SWIG_OLDOBJ (SWIG_OK)
321 #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
322 #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
323 /* Check, add and del mask methods */
324 #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
325 #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
326 #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
327 #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
328 #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
329 #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
330
331 /* Cast-Rank Mode */
332 #if defined(SWIG_CASTRANK_MODE)
333 # ifndef SWIG_TypeRank
334 # define SWIG_TypeRank unsigned long
335 # endif
336 # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
337 # define SWIG_MAXCASTRANK (2)
338 # endif
339 # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
340 # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
SWIG_AddCast(int r)341 SWIGINTERNINLINE int SWIG_AddCast(int r) {
342 return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
343 }
SWIG_CheckState(int r)344 SWIGINTERNINLINE int SWIG_CheckState(int r) {
345 return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
346 }
347 #else /* no cast-rank mode */
348 # define SWIG_AddCast(r) (r)
349 # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
350 #endif
351
352
353 #include <string.h>
354
355 #ifdef __cplusplus
356 extern "C" {
357 #endif
358
359 typedef void *(*swig_converter_func)(void *, int *);
360 typedef struct swig_type_info *(*swig_dycast_func)(void **);
361
362 /* Structure to store information on one type */
363 typedef struct swig_type_info {
364 const char *name; /* mangled name of this type */
365 const char *str; /* human readable name of this type */
366 swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
367 struct swig_cast_info *cast; /* linked list of types that can cast into this type */
368 void *clientdata; /* language specific type data */
369 int owndata; /* flag if the structure owns the clientdata */
370 } swig_type_info;
371
372 /* Structure to store a type and conversion function used for casting */
373 typedef struct swig_cast_info {
374 swig_type_info *type; /* pointer to type that is equivalent to this type */
375 swig_converter_func converter; /* function to cast the void pointers */
376 struct swig_cast_info *next; /* pointer to next cast in linked list */
377 struct swig_cast_info *prev; /* pointer to the previous cast */
378 } swig_cast_info;
379
380 /* Structure used to store module information
381 * Each module generates one structure like this, and the runtime collects
382 * all of these structures and stores them in a circularly linked list.*/
383 typedef struct swig_module_info {
384 swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
385 size_t size; /* Number of types in this module */
386 struct swig_module_info *next; /* Pointer to next element in circularly linked list */
387 swig_type_info **type_initial; /* Array of initially generated type structures */
388 swig_cast_info **cast_initial; /* Array of initially generated casting structures */
389 void *clientdata; /* Language specific module data */
390 } swig_module_info;
391
392 /*
393 Compare two type names skipping the space characters, therefore
394 "char*" == "char *" and "Class<int>" == "Class<int >", etc.
395
396 Return 0 when the two name types are equivalent, as in
397 strncmp, but skipping ' '.
398 */
399 SWIGRUNTIME int
SWIG_TypeNameComp(const char * f1,const char * l1,const char * f2,const char * l2)400 SWIG_TypeNameComp(const char *f1, const char *l1,
401 const char *f2, const char *l2) {
402 for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
403 while ((*f1 == ' ') && (f1 != l1)) ++f1;
404 while ((*f2 == ' ') && (f2 != l2)) ++f2;
405 if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
406 }
407 return (int)((l1 - f1) - (l2 - f2));
408 }
409
410 /*
411 Check type equivalence in a name list like <name1>|<name2>|...
412 Return 0 if equal, -1 if nb < tb, 1 if nb > tb
413 */
414 SWIGRUNTIME int
SWIG_TypeCmp(const char * nb,const char * tb)415 SWIG_TypeCmp(const char *nb, const char *tb) {
416 int equiv = 1;
417 const char* te = tb + strlen(tb);
418 const char* ne = nb;
419 while (equiv != 0 && *ne) {
420 for (nb = ne; *ne; ++ne) {
421 if (*ne == '|') break;
422 }
423 equiv = SWIG_TypeNameComp(nb, ne, tb, te);
424 if (*ne) ++ne;
425 }
426 return equiv;
427 }
428
429 /*
430 Check type equivalence in a name list like <name1>|<name2>|...
431 Return 0 if not equal, 1 if equal
432 */
433 SWIGRUNTIME int
SWIG_TypeEquiv(const char * nb,const char * tb)434 SWIG_TypeEquiv(const char *nb, const char *tb) {
435 return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
436 }
437
438 /*
439 Check the typename
440 */
441 SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char * c,swig_type_info * ty)442 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
443 if (ty) {
444 swig_cast_info *iter = ty->cast;
445 while (iter) {
446 if (strcmp(iter->type->name, c) == 0) {
447 if (iter == ty->cast)
448 return iter;
449 /* Move iter to the top of the linked list */
450 iter->prev->next = iter->next;
451 if (iter->next)
452 iter->next->prev = iter->prev;
453 iter->next = ty->cast;
454 iter->prev = 0;
455 if (ty->cast) ty->cast->prev = iter;
456 ty->cast = iter;
457 return iter;
458 }
459 iter = iter->next;
460 }
461 }
462 return 0;
463 }
464
465 /*
466 Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
467 */
468 SWIGRUNTIME swig_cast_info *
SWIG_TypeCheckStruct(swig_type_info * from,swig_type_info * ty)469 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
470 if (ty) {
471 swig_cast_info *iter = ty->cast;
472 while (iter) {
473 if (iter->type == from) {
474 if (iter == ty->cast)
475 return iter;
476 /* Move iter to the top of the linked list */
477 iter->prev->next = iter->next;
478 if (iter->next)
479 iter->next->prev = iter->prev;
480 iter->next = ty->cast;
481 iter->prev = 0;
482 if (ty->cast) ty->cast->prev = iter;
483 ty->cast = iter;
484 return iter;
485 }
486 iter = iter->next;
487 }
488 }
489 return 0;
490 }
491
492 /*
493 Cast a pointer up an inheritance hierarchy
494 */
495 SWIGRUNTIMEINLINE void *
SWIG_TypeCast(swig_cast_info * ty,void * ptr,int * newmemory)496 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
497 return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
498 }
499
500 /*
501 Dynamic pointer casting. Down an inheritance hierarchy
502 */
503 SWIGRUNTIME swig_type_info *
SWIG_TypeDynamicCast(swig_type_info * ty,void ** ptr)504 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
505 swig_type_info *lastty = ty;
506 if (!ty || !ty->dcast) return ty;
507 while (ty && (ty->dcast)) {
508 ty = (*ty->dcast)(ptr);
509 if (ty) lastty = ty;
510 }
511 return lastty;
512 }
513
514 /*
515 Return the name associated with this type
516 */
517 SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info * ty)518 SWIG_TypeName(const swig_type_info *ty) {
519 return ty->name;
520 }
521
522 /*
523 Return the pretty name associated with this type,
524 that is an unmangled type name in a form presentable to the user.
525 */
526 SWIGRUNTIME const char *
SWIG_TypePrettyName(const swig_type_info * type)527 SWIG_TypePrettyName(const swig_type_info *type) {
528 /* The "str" field contains the equivalent pretty names of the
529 type, separated by vertical-bar characters. We choose
530 to print the last name, as it is often (?) the most
531 specific. */
532 if (!type) return NULL;
533 if (type->str != NULL) {
534 const char *last_name = type->str;
535 const char *s;
536 for (s = type->str; *s; s++)
537 if (*s == '|') last_name = s+1;
538 return last_name;
539 }
540 else
541 return type->name;
542 }
543
544 /*
545 Set the clientdata field for a type
546 */
547 SWIGRUNTIME void
SWIG_TypeClientData(swig_type_info * ti,void * clientdata)548 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
549 swig_cast_info *cast = ti->cast;
550 /* if (ti->clientdata == clientdata) return; */
551 ti->clientdata = clientdata;
552
553 while (cast) {
554 if (!cast->converter) {
555 swig_type_info *tc = cast->type;
556 if (!tc->clientdata) {
557 SWIG_TypeClientData(tc, clientdata);
558 }
559 }
560 cast = cast->next;
561 }
562 }
563 SWIGRUNTIME void
SWIG_TypeNewClientData(swig_type_info * ti,void * clientdata)564 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
565 SWIG_TypeClientData(ti, clientdata);
566 ti->owndata = 1;
567 }
568
569 /*
570 Search for a swig_type_info structure only by mangled name
571 Search is a O(log #types)
572
573 We start searching at module start, and finish searching when start == end.
574 Note: if start == end at the beginning of the function, we go all the way around
575 the circular list.
576 */
577 SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info * start,swig_module_info * end,const char * name)578 SWIG_MangledTypeQueryModule(swig_module_info *start,
579 swig_module_info *end,
580 const char *name) {
581 swig_module_info *iter = start;
582 do {
583 if (iter->size) {
584 size_t l = 0;
585 size_t r = iter->size - 1;
586 do {
587 /* since l+r >= 0, we can (>> 1) instead (/ 2) */
588 size_t i = (l + r) >> 1;
589 const char *iname = iter->types[i]->name;
590 if (iname) {
591 int compare = strcmp(name, iname);
592 if (compare == 0) {
593 return iter->types[i];
594 } else if (compare < 0) {
595 if (i) {
596 r = i - 1;
597 } else {
598 break;
599 }
600 } else if (compare > 0) {
601 l = i + 1;
602 }
603 } else {
604 break; /* should never happen */
605 }
606 } while (l <= r);
607 }
608 iter = iter->next;
609 } while (iter != end);
610 return 0;
611 }
612
613 /*
614 Search for a swig_type_info structure for either a mangled name or a human readable name.
615 It first searches the mangled names of the types, which is a O(log #types)
616 If a type is not found it then searches the human readable names, which is O(#types).
617
618 We start searching at module start, and finish searching when start == end.
619 Note: if start == end at the beginning of the function, we go all the way around
620 the circular list.
621 */
622 SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info * start,swig_module_info * end,const char * name)623 SWIG_TypeQueryModule(swig_module_info *start,
624 swig_module_info *end,
625 const char *name) {
626 /* STEP 1: Search the name field using binary search */
627 swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
628 if (ret) {
629 return ret;
630 } else {
631 /* STEP 2: If the type hasn't been found, do a complete search
632 of the str field (the human readable name) */
633 swig_module_info *iter = start;
634 do {
635 size_t i = 0;
636 for (; i < iter->size; ++i) {
637 if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
638 return iter->types[i];
639 }
640 iter = iter->next;
641 } while (iter != end);
642 }
643
644 /* neither found a match */
645 return 0;
646 }
647
648 /*
649 Pack binary data into a string
650 */
651 SWIGRUNTIME char *
SWIG_PackData(char * c,void * ptr,size_t sz)652 SWIG_PackData(char *c, void *ptr, size_t sz) {
653 static const char hex[17] = "0123456789abcdef";
654 const unsigned char *u = (unsigned char *) ptr;
655 const unsigned char *eu = u + sz;
656 for (; u != eu; ++u) {
657 unsigned char uu = *u;
658 *(c++) = hex[(uu & 0xf0) >> 4];
659 *(c++) = hex[uu & 0xf];
660 }
661 return c;
662 }
663
664 /*
665 Unpack binary data from a string
666 */
667 SWIGRUNTIME const char *
SWIG_UnpackData(const char * c,void * ptr,size_t sz)668 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
669 unsigned char *u = (unsigned char *) ptr;
670 const unsigned char *eu = u + sz;
671 for (; u != eu; ++u) {
672 char d = *(c++);
673 unsigned char uu;
674 if ((d >= '0') && (d <= '9'))
675 uu = (unsigned char)((d - '0') << 4);
676 else if ((d >= 'a') && (d <= 'f'))
677 uu = (unsigned char)((d - ('a'-10)) << 4);
678 else
679 return (char *) 0;
680 d = *(c++);
681 if ((d >= '0') && (d <= '9'))
682 uu |= (unsigned char)(d - '0');
683 else if ((d >= 'a') && (d <= 'f'))
684 uu |= (unsigned char)(d - ('a'-10));
685 else
686 return (char *) 0;
687 *u = uu;
688 }
689 return c;
690 }
691
692 /*
693 Pack 'void *' into a string buffer.
694 */
695 SWIGRUNTIME char *
SWIG_PackVoidPtr(char * buff,void * ptr,const char * name,size_t bsz)696 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
697 char *r = buff;
698 if ((2*sizeof(void *) + 2) > bsz) return 0;
699 *(r++) = '_';
700 r = SWIG_PackData(r,&ptr,sizeof(void *));
701 if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
702 strcpy(r,name);
703 return buff;
704 }
705
706 SWIGRUNTIME const char *
SWIG_UnpackVoidPtr(const char * c,void ** ptr,const char * name)707 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
708 if (*c != '_') {
709 if (strcmp(c,"NULL") == 0) {
710 *ptr = (void *) 0;
711 return name;
712 } else {
713 return 0;
714 }
715 }
716 return SWIG_UnpackData(++c,ptr,sizeof(void *));
717 }
718
719 SWIGRUNTIME char *
SWIG_PackDataName(char * buff,void * ptr,size_t sz,const char * name,size_t bsz)720 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
721 char *r = buff;
722 size_t lname = (name ? strlen(name) : 0);
723 if ((2*sz + 2 + lname) > bsz) return 0;
724 *(r++) = '_';
725 r = SWIG_PackData(r,ptr,sz);
726 if (lname) {
727 strncpy(r,name,lname+1);
728 } else {
729 *r = 0;
730 }
731 return buff;
732 }
733
734 SWIGRUNTIME const char *
SWIG_UnpackDataName(const char * c,void * ptr,size_t sz,const char * name)735 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
736 if (*c != '_') {
737 if (strcmp(c,"NULL") == 0) {
738 memset(ptr,0,sz);
739 return name;
740 } else {
741 return 0;
742 }
743 }
744 return SWIG_UnpackData(++c,ptr,sz);
745 }
746
747 #ifdef __cplusplus
748 }
749 #endif
750
751 /* Errors in SWIG */
752 #define SWIG_UnknownError -1
753 #define SWIG_IOError -2
754 #define SWIG_RuntimeError -3
755 #define SWIG_IndexError -4
756 #define SWIG_TypeError -5
757 #define SWIG_DivisionByZero -6
758 #define SWIG_OverflowError -7
759 #define SWIG_SyntaxError -8
760 #define SWIG_ValueError -9
761 #define SWIG_SystemError -10
762 #define SWIG_AttributeError -11
763 #define SWIG_MemoryError -12
764 #define SWIG_NullReferenceError -13
765
766
767
768 /* Compatibility macros for Python 3 */
769 #if PY_VERSION_HEX >= 0x03000000
770
771 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
772 #define PyInt_Check(x) PyLong_Check(x)
773 #define PyInt_AsLong(x) PyLong_AsLong(x)
774 #define PyInt_FromLong(x) PyLong_FromLong(x)
775 #define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
776 #define PyString_Check(name) PyBytes_Check(name)
777 #define PyString_FromString(x) PyUnicode_FromString(x)
778 #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
779 #define PyString_AsString(str) PyBytes_AsString(str)
780 #define PyString_Size(str) PyBytes_Size(str)
781 #define PyString_InternFromString(key) PyUnicode_InternFromString(key)
782 #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
783 #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
784 #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
785
786 #endif
787
788 #ifndef Py_TYPE
789 # define Py_TYPE(op) ((op)->ob_type)
790 #endif
791
792 /* SWIG APIs for compatibility of both Python 2 & 3 */
793
794 #if PY_VERSION_HEX >= 0x03000000
795 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat
796 #else
797 # define SWIG_Python_str_FromFormat PyString_FromFormat
798 #endif
799
800
801 /* Warning: This function will allocate a new string in Python 3,
802 * so please call SWIG_Python_str_DelForPy3(x) to free the space.
803 */
804 SWIGINTERN char*
SWIG_Python_str_AsChar(PyObject * str)805 SWIG_Python_str_AsChar(PyObject *str)
806 {
807 #if PY_VERSION_HEX >= 0x03000000
808 char *cstr;
809 char *newstr;
810 Py_ssize_t len;
811 str = PyUnicode_AsUTF8String(str);
812 PyBytes_AsStringAndSize(str, &cstr, &len);
813 newstr = (char *) malloc(len+1);
814 memcpy(newstr, cstr, len+1);
815 Py_XDECREF(str);
816 return newstr;
817 #else
818 return PyString_AsString(str);
819 #endif
820 }
821
822 #if PY_VERSION_HEX >= 0x03000000
823 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
824 #else
825 # define SWIG_Python_str_DelForPy3(x)
826 #endif
827
828
829 SWIGINTERN PyObject*
SWIG_Python_str_FromChar(const char * c)830 SWIG_Python_str_FromChar(const char *c)
831 {
832 #if PY_VERSION_HEX >= 0x03000000
833 return PyUnicode_FromString(c);
834 #else
835 return PyString_FromString(c);
836 #endif
837 }
838
839 /* Add PyOS_snprintf for old Pythons */
840 #if PY_VERSION_HEX < 0x02020000
841 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
842 # define PyOS_snprintf _snprintf
843 # else
844 # define PyOS_snprintf snprintf
845 # endif
846 #endif
847
848 /* A crude PyString_FromFormat implementation for old Pythons */
849 #if PY_VERSION_HEX < 0x02020000
850
851 #ifndef SWIG_PYBUFFER_SIZE
852 # define SWIG_PYBUFFER_SIZE 1024
853 #endif
854
855 static PyObject *
PyString_FromFormat(const char * fmt,...)856 PyString_FromFormat(const char *fmt, ...) {
857 va_list ap;
858 char buf[SWIG_PYBUFFER_SIZE * 2];
859 int res;
860 va_start(ap, fmt);
861 res = vsnprintf(buf, sizeof(buf), fmt, ap);
862 va_end(ap);
863 return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
864 }
865 #endif
866
867 #ifndef PyObject_DEL
868 # define PyObject_DEL PyObject_Del
869 #endif
870
871 /* A crude PyExc_StopIteration exception for old Pythons */
872 #if PY_VERSION_HEX < 0x02020000
873 # ifndef PyExc_StopIteration
874 # define PyExc_StopIteration PyExc_RuntimeError
875 # endif
876 # ifndef PyObject_GenericGetAttr
877 # define PyObject_GenericGetAttr 0
878 # endif
879 #endif
880
881 /* Py_NotImplemented is defined in 2.1 and up. */
882 #if PY_VERSION_HEX < 0x02010000
883 # ifndef Py_NotImplemented
884 # define Py_NotImplemented PyExc_RuntimeError
885 # endif
886 #endif
887
888 /* A crude PyString_AsStringAndSize implementation for old Pythons */
889 #if PY_VERSION_HEX < 0x02010000
890 # ifndef PyString_AsStringAndSize
891 # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
892 # endif
893 #endif
894
895 /* PySequence_Size for old Pythons */
896 #if PY_VERSION_HEX < 0x02000000
897 # ifndef PySequence_Size
898 # define PySequence_Size PySequence_Length
899 # endif
900 #endif
901
902 /* PyBool_FromLong for old Pythons */
903 #if PY_VERSION_HEX < 0x02030000
904 static
PyBool_FromLong(long ok)905 PyObject *PyBool_FromLong(long ok)
906 {
907 PyObject *result = ok ? Py_True : Py_False;
908 Py_INCREF(result);
909 return result;
910 }
911 #endif
912
913 /* Py_ssize_t for old Pythons */
914 /* This code is as recommended by: */
915 /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
916 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
917 typedef int Py_ssize_t;
918 # define PY_SSIZE_T_MAX INT_MAX
919 # define PY_SSIZE_T_MIN INT_MIN
920 typedef inquiry lenfunc;
921 typedef intargfunc ssizeargfunc;
922 typedef intintargfunc ssizessizeargfunc;
923 typedef intobjargproc ssizeobjargproc;
924 typedef intintobjargproc ssizessizeobjargproc;
925 typedef getreadbufferproc readbufferproc;
926 typedef getwritebufferproc writebufferproc;
927 typedef getsegcountproc segcountproc;
928 typedef getcharbufferproc charbufferproc;
PyNumber_AsSsize_t(PyObject * x,void * SWIGUNUSEDPARM (exc))929 static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
930 {
931 long result = 0;
932 PyObject *i = PyNumber_Int(x);
933 if (i) {
934 result = PyInt_AsLong(i);
935 Py_DECREF(i);
936 }
937 return result;
938 }
939 #endif
940
941 #if PY_VERSION_HEX < 0x02050000
942 #define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
943 #endif
944
945 #if PY_VERSION_HEX < 0x02040000
946 #define Py_VISIT(op) \
947 do { \
948 if (op) { \
949 int vret = visit((op), arg); \
950 if (vret) \
951 return vret; \
952 } \
953 } while (0)
954 #endif
955
956 #if PY_VERSION_HEX < 0x02030000
957 typedef struct {
958 PyTypeObject type;
959 PyNumberMethods as_number;
960 PyMappingMethods as_mapping;
961 PySequenceMethods as_sequence;
962 PyBufferProcs as_buffer;
963 PyObject *name, *slots;
964 } PyHeapTypeObject;
965 #endif
966
967 #if PY_VERSION_HEX < 0x02030000
968 typedef destructor freefunc;
969 #endif
970
971 #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
972 (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
973 (PY_MAJOR_VERSION > 3))
974 # define SWIGPY_USE_CAPSULE
975 # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
976 #endif
977
978 #if PY_VERSION_HEX < 0x03020000
979 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
980 #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
981 #define Py_hash_t long
982 #endif
983
984 /* -----------------------------------------------------------------------------
985 * error manipulation
986 * ----------------------------------------------------------------------------- */
987
988 SWIGRUNTIME PyObject*
SWIG_Python_ErrorType(int code)989 SWIG_Python_ErrorType(int code) {
990 PyObject* type = 0;
991 switch(code) {
992 case SWIG_MemoryError:
993 type = PyExc_MemoryError;
994 break;
995 case SWIG_IOError:
996 type = PyExc_IOError;
997 break;
998 case SWIG_RuntimeError:
999 type = PyExc_RuntimeError;
1000 break;
1001 case SWIG_IndexError:
1002 type = PyExc_IndexError;
1003 break;
1004 case SWIG_TypeError:
1005 type = PyExc_TypeError;
1006 break;
1007 case SWIG_DivisionByZero:
1008 type = PyExc_ZeroDivisionError;
1009 break;
1010 case SWIG_OverflowError:
1011 type = PyExc_OverflowError;
1012 break;
1013 case SWIG_SyntaxError:
1014 type = PyExc_SyntaxError;
1015 break;
1016 case SWIG_ValueError:
1017 type = PyExc_ValueError;
1018 break;
1019 case SWIG_SystemError:
1020 type = PyExc_SystemError;
1021 break;
1022 case SWIG_AttributeError:
1023 type = PyExc_AttributeError;
1024 break;
1025 default:
1026 type = PyExc_RuntimeError;
1027 }
1028 return type;
1029 }
1030
1031
1032 SWIGRUNTIME void
SWIG_Python_AddErrorMsg(const char * mesg)1033 SWIG_Python_AddErrorMsg(const char* mesg)
1034 {
1035 PyObject *type = 0;
1036 PyObject *value = 0;
1037 PyObject *traceback = 0;
1038
1039 if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
1040 if (value) {
1041 char *tmp;
1042 PyObject *old_str = PyObject_Str(value);
1043 PyErr_Clear();
1044 Py_XINCREF(type);
1045
1046 PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
1047 SWIG_Python_str_DelForPy3(tmp);
1048 Py_DECREF(old_str);
1049 Py_DECREF(value);
1050 } else {
1051 PyErr_SetString(PyExc_RuntimeError, mesg);
1052 }
1053 }
1054
1055 #if defined(SWIG_PYTHON_NO_THREADS)
1056 # if defined(SWIG_PYTHON_THREADS)
1057 # undef SWIG_PYTHON_THREADS
1058 # endif
1059 #endif
1060 #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
1061 # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
1062 # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
1063 # define SWIG_PYTHON_USE_GIL
1064 # endif
1065 # endif
1066 # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
1067 # ifndef SWIG_PYTHON_INITIALIZE_THREADS
1068 # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
1069 # endif
1070 # ifdef __cplusplus /* C++ code */
1071 class SWIG_Python_Thread_Block {
1072 bool status;
1073 PyGILState_STATE state;
1074 public:
end()1075 void end() { if (status) { PyGILState_Release(state); status = false;} }
SWIG_Python_Thread_Block()1076 SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
~SWIG_Python_Thread_Block()1077 ~SWIG_Python_Thread_Block() { end(); }
1078 };
1079 class SWIG_Python_Thread_Allow {
1080 bool status;
1081 PyThreadState *save;
1082 public:
end()1083 void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
SWIG_Python_Thread_Allow()1084 SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
~SWIG_Python_Thread_Allow()1085 ~SWIG_Python_Thread_Allow() { end(); }
1086 };
1087 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
1088 # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
1089 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
1090 # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
1091 # else /* C code */
1092 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
1093 # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
1094 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
1095 # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
1096 # endif
1097 # else /* Old thread way, not implemented, user must provide it */
1098 # if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
1099 # define SWIG_PYTHON_INITIALIZE_THREADS
1100 # endif
1101 # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
1102 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK
1103 # endif
1104 # if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
1105 # define SWIG_PYTHON_THREAD_END_BLOCK
1106 # endif
1107 # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
1108 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW
1109 # endif
1110 # if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
1111 # define SWIG_PYTHON_THREAD_END_ALLOW
1112 # endif
1113 # endif
1114 #else /* No thread support */
1115 # define SWIG_PYTHON_INITIALIZE_THREADS
1116 # define SWIG_PYTHON_THREAD_BEGIN_BLOCK
1117 # define SWIG_PYTHON_THREAD_END_BLOCK
1118 # define SWIG_PYTHON_THREAD_BEGIN_ALLOW
1119 # define SWIG_PYTHON_THREAD_END_ALLOW
1120 #endif
1121
1122 /* -----------------------------------------------------------------------------
1123 * Python API portion that goes into the runtime
1124 * ----------------------------------------------------------------------------- */
1125
1126 #ifdef __cplusplus
1127 extern "C" {
1128 #endif
1129
1130 /* -----------------------------------------------------------------------------
1131 * Constant declarations
1132 * ----------------------------------------------------------------------------- */
1133
1134 /* Constant Types */
1135 #define SWIG_PY_POINTER 4
1136 #define SWIG_PY_BINARY 5
1137
1138 /* Constant information structure */
1139 typedef struct swig_const_info {
1140 int type;
1141 char *name;
1142 long lvalue;
1143 double dvalue;
1144 void *pvalue;
1145 swig_type_info **ptype;
1146 } swig_const_info;
1147
1148
1149 /* -----------------------------------------------------------------------------
1150 * Wrapper of PyInstanceMethod_New() used in Python 3
1151 * It is exported to the generated module, used for -fastproxy
1152 * ----------------------------------------------------------------------------- */
1153 #if PY_VERSION_HEX >= 0x03000000
SWIG_PyInstanceMethod_New(PyObject * SWIGUNUSEDPARM (self),PyObject * func)1154 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)
1155 {
1156 return PyInstanceMethod_New(func);
1157 }
1158 #else
SWIG_PyInstanceMethod_New(PyObject * SWIGUNUSEDPARM (self),PyObject * SWIGUNUSEDPARM (func))1159 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
1160 {
1161 return NULL;
1162 }
1163 #endif
1164
1165 #ifdef __cplusplus
1166 }
1167 #endif
1168
1169
1170 /* -----------------------------------------------------------------------------
1171 * pyrun.swg
1172 *
1173 * This file contains the runtime support for Python modules
1174 * and includes code for managing global variables and pointer
1175 * type checking.
1176 *
1177 * ----------------------------------------------------------------------------- */
1178
1179 /* Common SWIG API */
1180
1181 /* for raw pointers */
1182 #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1183 #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
1184 #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1185
1186 #ifdef SWIGPYTHON_BUILTIN
1187 #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
1188 #else
1189 #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
1190 #endif
1191
1192 #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
1193
1194 #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
1195 #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
1196 #define swig_owntype int
1197
1198 /* for raw packed data */
1199 #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1200 #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
1201
1202 /* for class or struct pointers */
1203 #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
1204 #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
1205
1206 /* for C or C++ function pointers */
1207 #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
1208 #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
1209
1210 /* for C++ member pointers, ie, member methods */
1211 #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1212 #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
1213
1214
1215 /* Runtime API */
1216
1217 #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata)
1218 #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
1219 #define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
1220
1221 #define SWIG_SetErrorObj SWIG_Python_SetErrorObj
1222 #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
1223 #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
1224 #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
1225 #define SWIG_fail goto fail
1226
1227
1228 /* Runtime API implementation */
1229
1230 /* Error manipulation */
1231
1232 SWIGINTERN void
SWIG_Python_SetErrorObj(PyObject * errtype,PyObject * obj)1233 SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
1234 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1235 PyErr_SetObject(errtype, obj);
1236 Py_DECREF(obj);
1237 SWIG_PYTHON_THREAD_END_BLOCK;
1238 }
1239
1240 SWIGINTERN void
SWIG_Python_SetErrorMsg(PyObject * errtype,const char * msg)1241 SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
1242 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1243 PyErr_SetString(errtype, msg);
1244 SWIG_PYTHON_THREAD_END_BLOCK;
1245 }
1246
1247 #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
1248
1249 /* Set a constant value */
1250
1251 #if defined(SWIGPYTHON_BUILTIN)
1252
1253 SWIGINTERN void
SwigPyBuiltin_AddPublicSymbol(PyObject * seq,const char * key)1254 SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
1255 PyObject *s = PyString_InternFromString(key);
1256 PyList_Append(seq, s);
1257 Py_DECREF(s);
1258 }
1259
1260 SWIGINTERN void
SWIG_Python_SetConstant(PyObject * d,PyObject * public_interface,const char * name,PyObject * obj)1261 SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
1262 #if PY_VERSION_HEX < 0x02030000
1263 PyDict_SetItemString(d, (char *)name, obj);
1264 #else
1265 PyDict_SetItemString(d, name, obj);
1266 #endif
1267 Py_DECREF(obj);
1268 if (public_interface)
1269 SwigPyBuiltin_AddPublicSymbol(public_interface, name);
1270 }
1271
1272 #else
1273
1274 SWIGINTERN void
SWIG_Python_SetConstant(PyObject * d,const char * name,PyObject * obj)1275 SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
1276 #if PY_VERSION_HEX < 0x02030000
1277 PyDict_SetItemString(d, (char *)name, obj);
1278 #else
1279 PyDict_SetItemString(d, name, obj);
1280 #endif
1281 Py_DECREF(obj);
1282 }
1283
1284 #endif
1285
1286 /* Append a value to the result obj */
1287
1288 SWIGINTERN PyObject*
SWIG_Python_AppendOutput(PyObject * result,PyObject * obj)1289 SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
1290 #if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
1291 if (!result) {
1292 result = obj;
1293 } else if (result == Py_None) {
1294 Py_DECREF(result);
1295 result = obj;
1296 } else {
1297 if (!PyList_Check(result)) {
1298 PyObject *o2 = result;
1299 result = PyList_New(1);
1300 PyList_SetItem(result, 0, o2);
1301 }
1302 PyList_Append(result,obj);
1303 Py_DECREF(obj);
1304 }
1305 return result;
1306 #else
1307 PyObject* o2;
1308 PyObject* o3;
1309 if (!result) {
1310 result = obj;
1311 } else if (result == Py_None) {
1312 Py_DECREF(result);
1313 result = obj;
1314 } else {
1315 if (!PyTuple_Check(result)) {
1316 o2 = result;
1317 result = PyTuple_New(1);
1318 PyTuple_SET_ITEM(result, 0, o2);
1319 }
1320 o3 = PyTuple_New(1);
1321 PyTuple_SET_ITEM(o3, 0, obj);
1322 o2 = result;
1323 result = PySequence_Concat(o2, o3);
1324 Py_DECREF(o2);
1325 Py_DECREF(o3);
1326 }
1327 return result;
1328 #endif
1329 }
1330
1331 /* Unpack the argument tuple */
1332
1333 SWIGINTERN Py_ssize_t
SWIG_Python_UnpackTuple(PyObject * args,const char * name,Py_ssize_t min,Py_ssize_t max,PyObject ** objs)1334 SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
1335 {
1336 if (!args) {
1337 if (!min && !max) {
1338 return 1;
1339 } else {
1340 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
1341 name, (min == max ? "" : "at least "), (int)min);
1342 return 0;
1343 }
1344 }
1345 if (!PyTuple_Check(args)) {
1346 if (min <= 1 && max >= 1) {
1347 Py_ssize_t i;
1348 objs[0] = args;
1349 for (i = 1; i < max; ++i) {
1350 objs[i] = 0;
1351 }
1352 return 2;
1353 }
1354 PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
1355 return 0;
1356 } else {
1357 Py_ssize_t l = PyTuple_GET_SIZE(args);
1358 if (l < min) {
1359 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
1360 name, (min == max ? "" : "at least "), (int)min, (int)l);
1361 return 0;
1362 } else if (l > max) {
1363 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
1364 name, (min == max ? "" : "at most "), (int)max, (int)l);
1365 return 0;
1366 } else {
1367 Py_ssize_t i;
1368 for (i = 0; i < l; ++i) {
1369 objs[i] = PyTuple_GET_ITEM(args, i);
1370 }
1371 for (; l < max; ++l) {
1372 objs[l] = 0;
1373 }
1374 return i + 1;
1375 }
1376 }
1377 }
1378
1379 /* A functor is a function object with one single object argument */
1380 #if PY_VERSION_HEX >= 0x02020000
1381 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
1382 #else
1383 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
1384 #endif
1385
1386 /*
1387 Helper for static pointer initialization for both C and C++ code, for example
1388 static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
1389 */
1390 #ifdef __cplusplus
1391 #define SWIG_STATIC_POINTER(var) var
1392 #else
1393 #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
1394 #endif
1395
1396 /* -----------------------------------------------------------------------------
1397 * Pointer declarations
1398 * ----------------------------------------------------------------------------- */
1399
1400 /* Flags for new pointer objects */
1401 #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
1402 #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
1403
1404 #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
1405
1406 #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
1407 #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
1408
1409 #ifdef __cplusplus
1410 extern "C" {
1411 #endif
1412
1413 /* How to access Py_None */
1414 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
1415 # ifndef SWIG_PYTHON_NO_BUILD_NONE
1416 # ifndef SWIG_PYTHON_BUILD_NONE
1417 # define SWIG_PYTHON_BUILD_NONE
1418 # endif
1419 # endif
1420 #endif
1421
1422 #ifdef SWIG_PYTHON_BUILD_NONE
1423 # ifdef Py_None
1424 # undef Py_None
1425 # define Py_None SWIG_Py_None()
1426 # endif
1427 SWIGRUNTIMEINLINE PyObject *
_SWIG_Py_None(void)1428 _SWIG_Py_None(void)
1429 {
1430 PyObject *none = Py_BuildValue((char*)"");
1431 Py_DECREF(none);
1432 return none;
1433 }
1434 SWIGRUNTIME PyObject *
SWIG_Py_None(void)1435 SWIG_Py_None(void)
1436 {
1437 static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
1438 return none;
1439 }
1440 #endif
1441
1442 /* The python void return value */
1443
1444 SWIGRUNTIMEINLINE PyObject *
SWIG_Py_Void(void)1445 SWIG_Py_Void(void)
1446 {
1447 PyObject *none = Py_None;
1448 Py_INCREF(none);
1449 return none;
1450 }
1451
1452 /* SwigPyClientData */
1453
1454 typedef struct {
1455 PyObject *klass;
1456 PyObject *newraw;
1457 PyObject *newargs;
1458 PyObject *destroy;
1459 int delargs;
1460 int implicitconv;
1461 PyTypeObject *pytype;
1462 } SwigPyClientData;
1463
1464 SWIGRUNTIMEINLINE int
SWIG_Python_CheckImplicit(swig_type_info * ty)1465 SWIG_Python_CheckImplicit(swig_type_info *ty)
1466 {
1467 SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
1468 return data ? data->implicitconv : 0;
1469 }
1470
1471 SWIGRUNTIMEINLINE PyObject *
SWIG_Python_ExceptionType(swig_type_info * desc)1472 SWIG_Python_ExceptionType(swig_type_info *desc) {
1473 SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
1474 PyObject *klass = data ? data->klass : 0;
1475 return (klass ? klass : PyExc_RuntimeError);
1476 }
1477
1478
1479 SWIGRUNTIME SwigPyClientData *
SwigPyClientData_New(PyObject * obj)1480 SwigPyClientData_New(PyObject* obj)
1481 {
1482 if (!obj) {
1483 return 0;
1484 } else {
1485 SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
1486 /* the klass element */
1487 data->klass = obj;
1488 Py_INCREF(data->klass);
1489 /* the newraw method and newargs arguments used to create a new raw instance */
1490 if (PyClass_Check(obj)) {
1491 data->newraw = 0;
1492 data->newargs = obj;
1493 Py_INCREF(obj);
1494 } else {
1495 #if (PY_VERSION_HEX < 0x02020000)
1496 data->newraw = 0;
1497 #else
1498 data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
1499 #endif
1500 if (data->newraw) {
1501 Py_INCREF(data->newraw);
1502 data->newargs = PyTuple_New(1);
1503 PyTuple_SetItem(data->newargs, 0, obj);
1504 } else {
1505 data->newargs = obj;
1506 }
1507 Py_INCREF(data->newargs);
1508 }
1509 /* the destroy method, aka as the C++ delete method */
1510 data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
1511 if (PyErr_Occurred()) {
1512 PyErr_Clear();
1513 data->destroy = 0;
1514 }
1515 if (data->destroy) {
1516 int flags;
1517 Py_INCREF(data->destroy);
1518 flags = PyCFunction_GET_FLAGS(data->destroy);
1519 #ifdef METH_O
1520 data->delargs = !(flags & (METH_O));
1521 #else
1522 data->delargs = 0;
1523 #endif
1524 } else {
1525 data->delargs = 0;
1526 }
1527 data->implicitconv = 0;
1528 data->pytype = 0;
1529 return data;
1530 }
1531 }
1532
1533 SWIGRUNTIME void
SwigPyClientData_Del(SwigPyClientData * data)1534 SwigPyClientData_Del(SwigPyClientData *data) {
1535 Py_XDECREF(data->newraw);
1536 Py_XDECREF(data->newargs);
1537 Py_XDECREF(data->destroy);
1538 }
1539
1540 /* =============== SwigPyObject =====================*/
1541
1542 typedef struct {
1543 PyObject_HEAD
1544 void *ptr;
1545 swig_type_info *ty;
1546 int own;
1547 PyObject *next;
1548 #ifdef SWIGPYTHON_BUILTIN
1549 PyObject *dict;
1550 #endif
1551 } SwigPyObject;
1552
1553
1554 #ifdef SWIGPYTHON_BUILTIN
1555
1556 SWIGRUNTIME PyObject *
SwigPyObject_get___dict__(PyObject * v,PyObject * SWIGUNUSEDPARM (args))1557 SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
1558 {
1559 SwigPyObject *sobj = (SwigPyObject *)v;
1560
1561 if (!sobj->dict)
1562 sobj->dict = PyDict_New();
1563
1564 Py_INCREF(sobj->dict);
1565 return sobj->dict;
1566 }
1567
1568 #endif
1569
1570 SWIGRUNTIME PyObject *
SwigPyObject_long(SwigPyObject * v)1571 SwigPyObject_long(SwigPyObject *v)
1572 {
1573 return PyLong_FromVoidPtr(v->ptr);
1574 }
1575
1576 SWIGRUNTIME PyObject *
SwigPyObject_format(const char * fmt,SwigPyObject * v)1577 SwigPyObject_format(const char* fmt, SwigPyObject *v)
1578 {
1579 PyObject *res = NULL;
1580 PyObject *args = PyTuple_New(1);
1581 if (args) {
1582 if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
1583 PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
1584 if (ofmt) {
1585 #if PY_VERSION_HEX >= 0x03000000
1586 res = PyUnicode_Format(ofmt,args);
1587 #else
1588 res = PyString_Format(ofmt,args);
1589 #endif
1590 Py_DECREF(ofmt);
1591 }
1592 Py_DECREF(args);
1593 }
1594 }
1595 return res;
1596 }
1597
1598 SWIGRUNTIME PyObject *
SwigPyObject_oct(SwigPyObject * v)1599 SwigPyObject_oct(SwigPyObject *v)
1600 {
1601 return SwigPyObject_format("%o",v);
1602 }
1603
1604 SWIGRUNTIME PyObject *
SwigPyObject_hex(SwigPyObject * v)1605 SwigPyObject_hex(SwigPyObject *v)
1606 {
1607 return SwigPyObject_format("%x",v);
1608 }
1609
1610 SWIGRUNTIME PyObject *
1611 #ifdef METH_NOARGS
SwigPyObject_repr(SwigPyObject * v)1612 SwigPyObject_repr(SwigPyObject *v)
1613 #else
1614 SwigPyObject_repr(SwigPyObject *v, PyObject *args)
1615 #endif
1616 {
1617 const char *name = SWIG_TypePrettyName(v->ty);
1618 PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
1619 if (v->next) {
1620 # ifdef METH_NOARGS
1621 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
1622 # else
1623 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
1624 # endif
1625 # if PY_VERSION_HEX >= 0x03000000
1626 PyObject *joined = PyUnicode_Concat(repr, nrep);
1627 Py_DecRef(repr);
1628 Py_DecRef(nrep);
1629 repr = joined;
1630 # else
1631 PyString_ConcatAndDel(&repr,nrep);
1632 # endif
1633 }
1634 return repr;
1635 }
1636
1637 SWIGRUNTIME int
SwigPyObject_compare(SwigPyObject * v,SwigPyObject * w)1638 SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
1639 {
1640 void *i = v->ptr;
1641 void *j = w->ptr;
1642 return (i < j) ? -1 : ((i > j) ? 1 : 0);
1643 }
1644
1645 /* Added for Python 3.x, would it also be useful for Python 2.x? */
1646 SWIGRUNTIME PyObject*
SwigPyObject_richcompare(SwigPyObject * v,SwigPyObject * w,int op)1647 SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
1648 {
1649 PyObject* res;
1650 if( op != Py_EQ && op != Py_NE ) {
1651 Py_INCREF(Py_NotImplemented);
1652 return Py_NotImplemented;
1653 }
1654 res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
1655 return res;
1656 }
1657
1658
1659 SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
1660
1661 #ifdef SWIGPYTHON_BUILTIN
1662 static swig_type_info *SwigPyObject_stype = 0;
1663 SWIGRUNTIME PyTypeObject*
SwigPyObject_type(void)1664 SwigPyObject_type(void) {
1665 SwigPyClientData *cd;
1666 assert(SwigPyObject_stype);
1667 cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
1668 assert(cd);
1669 assert(cd->pytype);
1670 return cd->pytype;
1671 }
1672 #else
1673 SWIGRUNTIME PyTypeObject*
SwigPyObject_type(void)1674 SwigPyObject_type(void) {
1675 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
1676 return type;
1677 }
1678 #endif
1679
1680 SWIGRUNTIMEINLINE int
SwigPyObject_Check(PyObject * op)1681 SwigPyObject_Check(PyObject *op) {
1682 #ifdef SWIGPYTHON_BUILTIN
1683 PyTypeObject *target_tp = SwigPyObject_type();
1684 if (PyType_IsSubtype(op->ob_type, target_tp))
1685 return 1;
1686 return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
1687 #else
1688 return (Py_TYPE(op) == SwigPyObject_type())
1689 || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
1690 #endif
1691 }
1692
1693 SWIGRUNTIME PyObject *
1694 SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
1695
1696 SWIGRUNTIME void
SwigPyObject_dealloc(PyObject * v)1697 SwigPyObject_dealloc(PyObject *v)
1698 {
1699 SwigPyObject *sobj = (SwigPyObject *) v;
1700 PyObject *next = sobj->next;
1701 if (sobj->own == SWIG_POINTER_OWN) {
1702 swig_type_info *ty = sobj->ty;
1703 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
1704 PyObject *destroy = data ? data->destroy : 0;
1705 if (destroy) {
1706 /* destroy is always a VARARGS method */
1707 PyObject *res;
1708
1709 /* PyObject_CallFunction() has the potential to silently drop
1710 the active active exception. In cases of unnamed temporary
1711 variable or where we just finished iterating over a generator
1712 StopIteration will be active right now, and this needs to
1713 remain true upon return from SwigPyObject_dealloc. So save
1714 and restore. */
1715
1716 PyObject *val = NULL, *type = NULL, *tb = NULL;
1717 PyErr_Fetch(&val, &type, &tb);
1718
1719 if (data->delargs) {
1720 /* we need to create a temporary object to carry the destroy operation */
1721 PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
1722 res = SWIG_Python_CallFunctor(destroy, tmp);
1723 Py_DECREF(tmp);
1724 } else {
1725 PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
1726 PyObject *mself = PyCFunction_GET_SELF(destroy);
1727 res = ((*meth)(mself, v));
1728 }
1729 if (!res)
1730 PyErr_WriteUnraisable(destroy);
1731
1732 PyErr_Restore(val, type, tb);
1733
1734 Py_XDECREF(res);
1735 }
1736 #if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
1737 else {
1738 const char *name = SWIG_TypePrettyName(ty);
1739 printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
1740 }
1741 #endif
1742 }
1743 Py_XDECREF(next);
1744 PyObject_DEL(v);
1745 }
1746
1747 SWIGRUNTIME PyObject*
SwigPyObject_append(PyObject * v,PyObject * next)1748 SwigPyObject_append(PyObject* v, PyObject* next)
1749 {
1750 SwigPyObject *sobj = (SwigPyObject *) v;
1751 #ifndef METH_O
1752 PyObject *tmp = 0;
1753 if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
1754 next = tmp;
1755 #endif
1756 if (!SwigPyObject_Check(next)) {
1757 PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
1758 return NULL;
1759 }
1760 sobj->next = next;
1761 Py_INCREF(next);
1762 return SWIG_Py_Void();
1763 }
1764
1765 SWIGRUNTIME PyObject*
1766 #ifdef METH_NOARGS
SwigPyObject_next(PyObject * v)1767 SwigPyObject_next(PyObject* v)
1768 #else
1769 SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1770 #endif
1771 {
1772 SwigPyObject *sobj = (SwigPyObject *) v;
1773 if (sobj->next) {
1774 Py_INCREF(sobj->next);
1775 return sobj->next;
1776 } else {
1777 return SWIG_Py_Void();
1778 }
1779 }
1780
1781 SWIGINTERN PyObject*
1782 #ifdef METH_NOARGS
SwigPyObject_disown(PyObject * v)1783 SwigPyObject_disown(PyObject *v)
1784 #else
1785 SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1786 #endif
1787 {
1788 SwigPyObject *sobj = (SwigPyObject *)v;
1789 sobj->own = 0;
1790 return SWIG_Py_Void();
1791 }
1792
1793 SWIGINTERN PyObject*
1794 #ifdef METH_NOARGS
SwigPyObject_acquire(PyObject * v)1795 SwigPyObject_acquire(PyObject *v)
1796 #else
1797 SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1798 #endif
1799 {
1800 SwigPyObject *sobj = (SwigPyObject *)v;
1801 sobj->own = SWIG_POINTER_OWN;
1802 return SWIG_Py_Void();
1803 }
1804
1805 SWIGINTERN PyObject*
SwigPyObject_own(PyObject * v,PyObject * args)1806 SwigPyObject_own(PyObject *v, PyObject *args)
1807 {
1808 PyObject *val = 0;
1809 #if (PY_VERSION_HEX < 0x02020000)
1810 if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
1811 #elif (PY_VERSION_HEX < 0x02050000)
1812 if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
1813 #else
1814 if (!PyArg_UnpackTuple(args, "own", 0, 1, &val))
1815 #endif
1816 {
1817 return NULL;
1818 }
1819 else
1820 {
1821 SwigPyObject *sobj = (SwigPyObject *)v;
1822 PyObject *obj = PyBool_FromLong(sobj->own);
1823 if (val) {
1824 #ifdef METH_NOARGS
1825 if (PyObject_IsTrue(val)) {
1826 SwigPyObject_acquire(v);
1827 } else {
1828 SwigPyObject_disown(v);
1829 }
1830 #else
1831 if (PyObject_IsTrue(val)) {
1832 SwigPyObject_acquire(v,args);
1833 } else {
1834 SwigPyObject_disown(v,args);
1835 }
1836 #endif
1837 }
1838 return obj;
1839 }
1840 }
1841
1842 #ifdef METH_O
1843 static PyMethodDef
1844 swigobject_methods[] = {
1845 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
1846 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"},
1847 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
1848 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
1849 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
1850 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
1851 {0, 0, 0, 0}
1852 };
1853 #else
1854 static PyMethodDef
1855 swigobject_methods[] = {
1856 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
1857 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"},
1858 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
1859 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
1860 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
1861 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
1862 {0, 0, 0, 0}
1863 };
1864 #endif
1865
1866 #if PY_VERSION_HEX < 0x02020000
1867 SWIGINTERN PyObject *
SwigPyObject_getattr(SwigPyObject * sobj,char * name)1868 SwigPyObject_getattr(SwigPyObject *sobj,char *name)
1869 {
1870 return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
1871 }
1872 #endif
1873
1874 SWIGRUNTIME PyTypeObject*
SwigPyObject_TypeOnce(void)1875 SwigPyObject_TypeOnce(void) {
1876 static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
1877
1878 static PyNumberMethods SwigPyObject_as_number = {
1879 (binaryfunc)0, /*nb_add*/
1880 (binaryfunc)0, /*nb_subtract*/
1881 (binaryfunc)0, /*nb_multiply*/
1882 /* nb_divide removed in Python 3 */
1883 #if PY_VERSION_HEX < 0x03000000
1884 (binaryfunc)0, /*nb_divide*/
1885 #endif
1886 (binaryfunc)0, /*nb_remainder*/
1887 (binaryfunc)0, /*nb_divmod*/
1888 (ternaryfunc)0,/*nb_power*/
1889 (unaryfunc)0, /*nb_negative*/
1890 (unaryfunc)0, /*nb_positive*/
1891 (unaryfunc)0, /*nb_absolute*/
1892 (inquiry)0, /*nb_nonzero*/
1893 0, /*nb_invert*/
1894 0, /*nb_lshift*/
1895 0, /*nb_rshift*/
1896 0, /*nb_and*/
1897 0, /*nb_xor*/
1898 0, /*nb_or*/
1899 #if PY_VERSION_HEX < 0x03000000
1900 0, /*nb_coerce*/
1901 #endif
1902 (unaryfunc)SwigPyObject_long, /*nb_int*/
1903 #if PY_VERSION_HEX < 0x03000000
1904 (unaryfunc)SwigPyObject_long, /*nb_long*/
1905 #else
1906 0, /*nb_reserved*/
1907 #endif
1908 (unaryfunc)0, /*nb_float*/
1909 #if PY_VERSION_HEX < 0x03000000
1910 (unaryfunc)SwigPyObject_oct, /*nb_oct*/
1911 (unaryfunc)SwigPyObject_hex, /*nb_hex*/
1912 #endif
1913 #if PY_VERSION_HEX >= 0x03050000 /* 3.5 */
1914 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
1915 #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */
1916 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
1917 #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
1918 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
1919 #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
1920 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
1921 #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
1922 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
1923 #endif
1924 };
1925
1926 static PyTypeObject swigpyobject_type;
1927 static int type_init = 0;
1928 if (!type_init) {
1929 const PyTypeObject tmp = {
1930 #if PY_VERSION_HEX >= 0x03000000
1931 PyVarObject_HEAD_INIT(NULL, 0)
1932 #else
1933 PyObject_HEAD_INIT(NULL)
1934 0, /* ob_size */
1935 #endif
1936 (char *)"SwigPyObject", /* tp_name */
1937 sizeof(SwigPyObject), /* tp_basicsize */
1938 0, /* tp_itemsize */
1939 (destructor)SwigPyObject_dealloc, /* tp_dealloc */
1940 0, /* tp_print */
1941 #if PY_VERSION_HEX < 0x02020000
1942 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
1943 #else
1944 (getattrfunc)0, /* tp_getattr */
1945 #endif
1946 (setattrfunc)0, /* tp_setattr */
1947 #if PY_VERSION_HEX >= 0x03000000
1948 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
1949 #else
1950 (cmpfunc)SwigPyObject_compare, /* tp_compare */
1951 #endif
1952 (reprfunc)SwigPyObject_repr, /* tp_repr */
1953 &SwigPyObject_as_number, /* tp_as_number */
1954 0, /* tp_as_sequence */
1955 0, /* tp_as_mapping */
1956 (hashfunc)0, /* tp_hash */
1957 (ternaryfunc)0, /* tp_call */
1958 0, /* tp_str */
1959 PyObject_GenericGetAttr, /* tp_getattro */
1960 0, /* tp_setattro */
1961 0, /* tp_as_buffer */
1962 Py_TPFLAGS_DEFAULT, /* tp_flags */
1963 swigobject_doc, /* tp_doc */
1964 0, /* tp_traverse */
1965 0, /* tp_clear */
1966 (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
1967 0, /* tp_weaklistoffset */
1968 #if PY_VERSION_HEX >= 0x02020000
1969 0, /* tp_iter */
1970 0, /* tp_iternext */
1971 swigobject_methods, /* tp_methods */
1972 0, /* tp_members */
1973 0, /* tp_getset */
1974 0, /* tp_base */
1975 0, /* tp_dict */
1976 0, /* tp_descr_get */
1977 0, /* tp_descr_set */
1978 0, /* tp_dictoffset */
1979 0, /* tp_init */
1980 0, /* tp_alloc */
1981 0, /* tp_new */
1982 0, /* tp_free */
1983 0, /* tp_is_gc */
1984 0, /* tp_bases */
1985 0, /* tp_mro */
1986 0, /* tp_cache */
1987 0, /* tp_subclasses */
1988 0, /* tp_weaklist */
1989 #endif
1990 #if PY_VERSION_HEX >= 0x02030000
1991 0, /* tp_del */
1992 #endif
1993 #if PY_VERSION_HEX >= 0x02060000
1994 0, /* tp_version_tag */
1995 #endif
1996 #if PY_VERSION_HEX >= 0x03040000
1997 0, /* tp_finalize */
1998 #endif
1999 #ifdef COUNT_ALLOCS
2000 0, /* tp_allocs */
2001 0, /* tp_frees */
2002 0, /* tp_maxalloc */
2003 #if PY_VERSION_HEX >= 0x02050000
2004 0, /* tp_prev */
2005 #endif
2006 0 /* tp_next */
2007 #endif
2008 };
2009 swigpyobject_type = tmp;
2010 type_init = 1;
2011 #if PY_VERSION_HEX < 0x02020000
2012 swigpyobject_type.ob_type = &PyType_Type;
2013 #else
2014 if (PyType_Ready(&swigpyobject_type) < 0)
2015 return NULL;
2016 #endif
2017 }
2018 return &swigpyobject_type;
2019 }
2020
2021 SWIGRUNTIME PyObject *
SwigPyObject_New(void * ptr,swig_type_info * ty,int own)2022 SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
2023 {
2024 SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
2025 if (sobj) {
2026 sobj->ptr = ptr;
2027 sobj->ty = ty;
2028 sobj->own = own;
2029 sobj->next = 0;
2030 }
2031 return (PyObject *)sobj;
2032 }
2033
2034 /* -----------------------------------------------------------------------------
2035 * Implements a simple Swig Packed type, and use it instead of string
2036 * ----------------------------------------------------------------------------- */
2037
2038 typedef struct {
2039 PyObject_HEAD
2040 void *pack;
2041 swig_type_info *ty;
2042 size_t size;
2043 } SwigPyPacked;
2044
2045 SWIGRUNTIME int
SwigPyPacked_print(SwigPyPacked * v,FILE * fp,int SWIGUNUSEDPARM (flags))2046 SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
2047 {
2048 char result[SWIG_BUFFER_SIZE];
2049 fputs("<Swig Packed ", fp);
2050 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
2051 fputs("at ", fp);
2052 fputs(result, fp);
2053 }
2054 fputs(v->ty->name,fp);
2055 fputs(">", fp);
2056 return 0;
2057 }
2058
2059 SWIGRUNTIME PyObject *
SwigPyPacked_repr(SwigPyPacked * v)2060 SwigPyPacked_repr(SwigPyPacked *v)
2061 {
2062 char result[SWIG_BUFFER_SIZE];
2063 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
2064 return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
2065 } else {
2066 return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
2067 }
2068 }
2069
2070 SWIGRUNTIME PyObject *
SwigPyPacked_str(SwigPyPacked * v)2071 SwigPyPacked_str(SwigPyPacked *v)
2072 {
2073 char result[SWIG_BUFFER_SIZE];
2074 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
2075 return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
2076 } else {
2077 return SWIG_Python_str_FromChar(v->ty->name);
2078 }
2079 }
2080
2081 SWIGRUNTIME int
SwigPyPacked_compare(SwigPyPacked * v,SwigPyPacked * w)2082 SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
2083 {
2084 size_t i = v->size;
2085 size_t j = w->size;
2086 int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
2087 return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
2088 }
2089
2090 SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
2091
2092 SWIGRUNTIME PyTypeObject*
SwigPyPacked_type(void)2093 SwigPyPacked_type(void) {
2094 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
2095 return type;
2096 }
2097
2098 SWIGRUNTIMEINLINE int
SwigPyPacked_Check(PyObject * op)2099 SwigPyPacked_Check(PyObject *op) {
2100 return ((op)->ob_type == SwigPyPacked_TypeOnce())
2101 || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
2102 }
2103
2104 SWIGRUNTIME void
SwigPyPacked_dealloc(PyObject * v)2105 SwigPyPacked_dealloc(PyObject *v)
2106 {
2107 if (SwigPyPacked_Check(v)) {
2108 SwigPyPacked *sobj = (SwigPyPacked *) v;
2109 free(sobj->pack);
2110 }
2111 PyObject_DEL(v);
2112 }
2113
2114 SWIGRUNTIME PyTypeObject*
SwigPyPacked_TypeOnce(void)2115 SwigPyPacked_TypeOnce(void) {
2116 static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
2117 static PyTypeObject swigpypacked_type;
2118 static int type_init = 0;
2119 if (!type_init) {
2120 const PyTypeObject tmp = {
2121 #if PY_VERSION_HEX>=0x03000000
2122 PyVarObject_HEAD_INIT(NULL, 0)
2123 #else
2124 PyObject_HEAD_INIT(NULL)
2125 0, /* ob_size */
2126 #endif
2127 (char *)"SwigPyPacked", /* tp_name */
2128 sizeof(SwigPyPacked), /* tp_basicsize */
2129 0, /* tp_itemsize */
2130 (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
2131 (printfunc)SwigPyPacked_print, /* tp_print */
2132 (getattrfunc)0, /* tp_getattr */
2133 (setattrfunc)0, /* tp_setattr */
2134 #if PY_VERSION_HEX>=0x03000000
2135 0, /* tp_reserved in 3.0.1 */
2136 #else
2137 (cmpfunc)SwigPyPacked_compare, /* tp_compare */
2138 #endif
2139 (reprfunc)SwigPyPacked_repr, /* tp_repr */
2140 0, /* tp_as_number */
2141 0, /* tp_as_sequence */
2142 0, /* tp_as_mapping */
2143 (hashfunc)0, /* tp_hash */
2144 (ternaryfunc)0, /* tp_call */
2145 (reprfunc)SwigPyPacked_str, /* tp_str */
2146 PyObject_GenericGetAttr, /* tp_getattro */
2147 0, /* tp_setattro */
2148 0, /* tp_as_buffer */
2149 Py_TPFLAGS_DEFAULT, /* tp_flags */
2150 swigpacked_doc, /* tp_doc */
2151 0, /* tp_traverse */
2152 0, /* tp_clear */
2153 0, /* tp_richcompare */
2154 0, /* tp_weaklistoffset */
2155 #if PY_VERSION_HEX >= 0x02020000
2156 0, /* tp_iter */
2157 0, /* tp_iternext */
2158 0, /* tp_methods */
2159 0, /* tp_members */
2160 0, /* tp_getset */
2161 0, /* tp_base */
2162 0, /* tp_dict */
2163 0, /* tp_descr_get */
2164 0, /* tp_descr_set */
2165 0, /* tp_dictoffset */
2166 0, /* tp_init */
2167 0, /* tp_alloc */
2168 0, /* tp_new */
2169 0, /* tp_free */
2170 0, /* tp_is_gc */
2171 0, /* tp_bases */
2172 0, /* tp_mro */
2173 0, /* tp_cache */
2174 0, /* tp_subclasses */
2175 0, /* tp_weaklist */
2176 #endif
2177 #if PY_VERSION_HEX >= 0x02030000
2178 0, /* tp_del */
2179 #endif
2180 #if PY_VERSION_HEX >= 0x02060000
2181 0, /* tp_version_tag */
2182 #endif
2183 #if PY_VERSION_HEX >= 0x03040000
2184 0, /* tp_finalize */
2185 #endif
2186 #ifdef COUNT_ALLOCS
2187 0, /* tp_allocs */
2188 0, /* tp_frees */
2189 0, /* tp_maxalloc */
2190 #if PY_VERSION_HEX >= 0x02050000
2191 0, /* tp_prev */
2192 #endif
2193 0 /* tp_next */
2194 #endif
2195 };
2196 swigpypacked_type = tmp;
2197 type_init = 1;
2198 #if PY_VERSION_HEX < 0x02020000
2199 swigpypacked_type.ob_type = &PyType_Type;
2200 #else
2201 if (PyType_Ready(&swigpypacked_type) < 0)
2202 return NULL;
2203 #endif
2204 }
2205 return &swigpypacked_type;
2206 }
2207
2208 SWIGRUNTIME PyObject *
SwigPyPacked_New(void * ptr,size_t size,swig_type_info * ty)2209 SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
2210 {
2211 SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
2212 if (sobj) {
2213 void *pack = malloc(size);
2214 if (pack) {
2215 memcpy(pack, ptr, size);
2216 sobj->pack = pack;
2217 sobj->ty = ty;
2218 sobj->size = size;
2219 } else {
2220 PyObject_DEL((PyObject *) sobj);
2221 sobj = 0;
2222 }
2223 }
2224 return (PyObject *) sobj;
2225 }
2226
2227 SWIGRUNTIME swig_type_info *
SwigPyPacked_UnpackData(PyObject * obj,void * ptr,size_t size)2228 SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
2229 {
2230 if (SwigPyPacked_Check(obj)) {
2231 SwigPyPacked *sobj = (SwigPyPacked *)obj;
2232 if (sobj->size != size) return 0;
2233 memcpy(ptr, sobj->pack, size);
2234 return sobj->ty;
2235 } else {
2236 return 0;
2237 }
2238 }
2239
2240 /* -----------------------------------------------------------------------------
2241 * pointers/data manipulation
2242 * ----------------------------------------------------------------------------- */
2243
2244 SWIGRUNTIMEINLINE PyObject *
_SWIG_This(void)2245 _SWIG_This(void)
2246 {
2247 return SWIG_Python_str_FromChar("this");
2248 }
2249
2250 static PyObject *swig_this = NULL;
2251
2252 SWIGRUNTIME PyObject *
SWIG_This(void)2253 SWIG_This(void)
2254 {
2255 if (swig_this == NULL)
2256 swig_this = _SWIG_This();
2257 return swig_this;
2258 }
2259
2260 /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
2261
2262 /* TODO: I don't know how to implement the fast getset in Python 3 right now */
2263 #if PY_VERSION_HEX>=0x03000000
2264 #define SWIG_PYTHON_SLOW_GETSET_THIS
2265 #endif
2266
2267 SWIGRUNTIME SwigPyObject *
SWIG_Python_GetSwigThis(PyObject * pyobj)2268 SWIG_Python_GetSwigThis(PyObject *pyobj)
2269 {
2270 PyObject *obj;
2271
2272 if (SwigPyObject_Check(pyobj))
2273 return (SwigPyObject *) pyobj;
2274
2275 #ifdef SWIGPYTHON_BUILTIN
2276 (void)obj;
2277 # ifdef PyWeakref_CheckProxy
2278 if (PyWeakref_CheckProxy(pyobj)) {
2279 pyobj = PyWeakref_GET_OBJECT(pyobj);
2280 if (pyobj && SwigPyObject_Check(pyobj))
2281 return (SwigPyObject*) pyobj;
2282 }
2283 # endif
2284 return NULL;
2285 #else
2286
2287 obj = 0;
2288
2289 #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
2290 if (PyInstance_Check(pyobj)) {
2291 obj = _PyInstance_Lookup(pyobj, SWIG_This());
2292 } else {
2293 PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
2294 if (dictptr != NULL) {
2295 PyObject *dict = *dictptr;
2296 obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
2297 } else {
2298 #ifdef PyWeakref_CheckProxy
2299 if (PyWeakref_CheckProxy(pyobj)) {
2300 PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
2301 return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
2302 }
2303 #endif
2304 obj = PyObject_GetAttr(pyobj,SWIG_This());
2305 if (obj) {
2306 Py_DECREF(obj);
2307 } else {
2308 if (PyErr_Occurred()) PyErr_Clear();
2309 return 0;
2310 }
2311 }
2312 }
2313 #else
2314 obj = PyObject_GetAttr(pyobj,SWIG_This());
2315 if (obj) {
2316 Py_DECREF(obj);
2317 } else {
2318 if (PyErr_Occurred()) PyErr_Clear();
2319 return 0;
2320 }
2321 #endif
2322 if (obj && !SwigPyObject_Check(obj)) {
2323 /* a PyObject is called 'this', try to get the 'real this'
2324 SwigPyObject from it */
2325 return SWIG_Python_GetSwigThis(obj);
2326 }
2327 return (SwigPyObject *)obj;
2328 #endif
2329 }
2330
2331 /* Acquire a pointer value */
2332
2333 SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject * obj,int own)2334 SWIG_Python_AcquirePtr(PyObject *obj, int own) {
2335 if (own == SWIG_POINTER_OWN) {
2336 SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
2337 if (sobj) {
2338 int oldown = sobj->own;
2339 sobj->own = own;
2340 return oldown;
2341 }
2342 }
2343 return 0;
2344 }
2345
2346 /* Convert a pointer value */
2347
2348 SWIGRUNTIME int
SWIG_Python_ConvertPtrAndOwn(PyObject * obj,void ** ptr,swig_type_info * ty,int flags,int * own)2349 SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
2350 int res;
2351 SwigPyObject *sobj;
2352 int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
2353
2354 if (!obj)
2355 return SWIG_ERROR;
2356 if (obj == Py_None && !implicit_conv) {
2357 if (ptr)
2358 *ptr = 0;
2359 return SWIG_OK;
2360 }
2361
2362 res = SWIG_ERROR;
2363
2364 sobj = SWIG_Python_GetSwigThis(obj);
2365 if (own)
2366 *own = 0;
2367 while (sobj) {
2368 void *vptr = sobj->ptr;
2369 if (ty) {
2370 swig_type_info *to = sobj->ty;
2371 if (to == ty) {
2372 /* no type cast needed */
2373 if (ptr) *ptr = vptr;
2374 break;
2375 } else {
2376 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
2377 if (!tc) {
2378 sobj = (SwigPyObject *)sobj->next;
2379 } else {
2380 if (ptr) {
2381 int newmemory = 0;
2382 *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2383 if (newmemory == SWIG_CAST_NEW_MEMORY) {
2384 assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
2385 if (own)
2386 *own = *own | SWIG_CAST_NEW_MEMORY;
2387 }
2388 }
2389 break;
2390 }
2391 }
2392 } else {
2393 if (ptr) *ptr = vptr;
2394 break;
2395 }
2396 }
2397 if (sobj) {
2398 if (own)
2399 *own = *own | sobj->own;
2400 if (flags & SWIG_POINTER_DISOWN) {
2401 sobj->own = 0;
2402 }
2403 res = SWIG_OK;
2404 } else {
2405 if (implicit_conv) {
2406 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
2407 if (data && !data->implicitconv) {
2408 PyObject *klass = data->klass;
2409 if (klass) {
2410 PyObject *impconv;
2411 data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
2412 impconv = SWIG_Python_CallFunctor(klass, obj);
2413 data->implicitconv = 0;
2414 if (PyErr_Occurred()) {
2415 PyErr_Clear();
2416 impconv = 0;
2417 }
2418 if (impconv) {
2419 SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
2420 if (iobj) {
2421 void *vptr;
2422 res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
2423 if (SWIG_IsOK(res)) {
2424 if (ptr) {
2425 *ptr = vptr;
2426 /* transfer the ownership to 'ptr' */
2427 iobj->own = 0;
2428 res = SWIG_AddCast(res);
2429 res = SWIG_AddNewMask(res);
2430 } else {
2431 res = SWIG_AddCast(res);
2432 }
2433 }
2434 }
2435 Py_DECREF(impconv);
2436 }
2437 }
2438 }
2439 }
2440 if (!SWIG_IsOK(res) && obj == Py_None) {
2441 if (ptr)
2442 *ptr = 0;
2443 if (PyErr_Occurred())
2444 PyErr_Clear();
2445 res = SWIG_OK;
2446 }
2447 }
2448 return res;
2449 }
2450
2451 /* Convert a function ptr value */
2452
2453 SWIGRUNTIME int
SWIG_Python_ConvertFunctionPtr(PyObject * obj,void ** ptr,swig_type_info * ty)2454 SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
2455 if (!PyCFunction_Check(obj)) {
2456 return SWIG_ConvertPtr(obj, ptr, ty, 0);
2457 } else {
2458 void *vptr = 0;
2459
2460 /* here we get the method pointer for callbacks */
2461 const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
2462 const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
2463 if (desc)
2464 desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
2465 if (!desc)
2466 return SWIG_ERROR;
2467 if (ty) {
2468 swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
2469 if (tc) {
2470 int newmemory = 0;
2471 *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2472 assert(!newmemory); /* newmemory handling not yet implemented */
2473 } else {
2474 return SWIG_ERROR;
2475 }
2476 } else {
2477 *ptr = vptr;
2478 }
2479 return SWIG_OK;
2480 }
2481 }
2482
2483 /* Convert a packed value value */
2484
2485 SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject * obj,void * ptr,size_t sz,swig_type_info * ty)2486 SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
2487 swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
2488 if (!to) return SWIG_ERROR;
2489 if (ty) {
2490 if (to != ty) {
2491 /* check type cast? */
2492 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
2493 if (!tc) return SWIG_ERROR;
2494 }
2495 }
2496 return SWIG_OK;
2497 }
2498
2499 /* -----------------------------------------------------------------------------
2500 * Create a new pointer object
2501 * ----------------------------------------------------------------------------- */
2502
2503 /*
2504 Create a new instance object, without calling __init__, and set the
2505 'this' attribute.
2506 */
2507
2508 SWIGRUNTIME PyObject*
SWIG_Python_NewShadowInstance(SwigPyClientData * data,PyObject * swig_this)2509 SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
2510 {
2511 #if (PY_VERSION_HEX >= 0x02020000)
2512 PyObject *inst = 0;
2513 PyObject *newraw = data->newraw;
2514 if (newraw) {
2515 inst = PyObject_Call(newraw, data->newargs, NULL);
2516 if (inst) {
2517 #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2518 PyObject **dictptr = _PyObject_GetDictPtr(inst);
2519 if (dictptr != NULL) {
2520 PyObject *dict = *dictptr;
2521 if (dict == NULL) {
2522 dict = PyDict_New();
2523 *dictptr = dict;
2524 PyDict_SetItem(dict, SWIG_This(), swig_this);
2525 }
2526 }
2527 #else
2528 PyObject *key = SWIG_This();
2529 PyObject_SetAttr(inst, key, swig_this);
2530 #endif
2531 }
2532 } else {
2533 #if PY_VERSION_HEX >= 0x03000000
2534 inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
2535 if (inst) {
2536 PyObject_SetAttr(inst, SWIG_This(), swig_this);
2537 Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
2538 }
2539 #else
2540 PyObject *dict = PyDict_New();
2541 if (dict) {
2542 PyDict_SetItem(dict, SWIG_This(), swig_this);
2543 inst = PyInstance_NewRaw(data->newargs, dict);
2544 Py_DECREF(dict);
2545 }
2546 #endif
2547 }
2548 return inst;
2549 #else
2550 #if (PY_VERSION_HEX >= 0x02010000)
2551 PyObject *inst = 0;
2552 PyObject *dict = PyDict_New();
2553 if (dict) {
2554 PyDict_SetItem(dict, SWIG_This(), swig_this);
2555 inst = PyInstance_NewRaw(data->newargs, dict);
2556 Py_DECREF(dict);
2557 }
2558 return (PyObject *) inst;
2559 #else
2560 PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
2561 if (inst == NULL) {
2562 return NULL;
2563 }
2564 inst->in_class = (PyClassObject *)data->newargs;
2565 Py_INCREF(inst->in_class);
2566 inst->in_dict = PyDict_New();
2567 if (inst->in_dict == NULL) {
2568 Py_DECREF(inst);
2569 return NULL;
2570 }
2571 #ifdef Py_TPFLAGS_HAVE_WEAKREFS
2572 inst->in_weakreflist = NULL;
2573 #endif
2574 #ifdef Py_TPFLAGS_GC
2575 PyObject_GC_Init(inst);
2576 #endif
2577 PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
2578 return (PyObject *) inst;
2579 #endif
2580 #endif
2581 }
2582
2583 SWIGRUNTIME void
SWIG_Python_SetSwigThis(PyObject * inst,PyObject * swig_this)2584 SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
2585 {
2586 PyObject *dict;
2587 #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2588 PyObject **dictptr = _PyObject_GetDictPtr(inst);
2589 if (dictptr != NULL) {
2590 dict = *dictptr;
2591 if (dict == NULL) {
2592 dict = PyDict_New();
2593 *dictptr = dict;
2594 }
2595 PyDict_SetItem(dict, SWIG_This(), swig_this);
2596 return;
2597 }
2598 #endif
2599 dict = PyObject_GetAttrString(inst, (char*)"__dict__");
2600 PyDict_SetItem(dict, SWIG_This(), swig_this);
2601 Py_DECREF(dict);
2602 }
2603
2604
2605 SWIGINTERN PyObject *
SWIG_Python_InitShadowInstance(PyObject * args)2606 SWIG_Python_InitShadowInstance(PyObject *args) {
2607 PyObject *obj[2];
2608 if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
2609 return NULL;
2610 } else {
2611 SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
2612 if (sthis) {
2613 SwigPyObject_append((PyObject*) sthis, obj[1]);
2614 } else {
2615 SWIG_Python_SetSwigThis(obj[0], obj[1]);
2616 }
2617 return SWIG_Py_Void();
2618 }
2619 }
2620
2621 /* Create a new pointer object */
2622
2623 SWIGRUNTIME PyObject *
SWIG_Python_NewPointerObj(PyObject * self,void * ptr,swig_type_info * type,int flags)2624 SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
2625 SwigPyClientData *clientdata;
2626 PyObject * robj;
2627 int own;
2628
2629 if (!ptr)
2630 return SWIG_Py_Void();
2631
2632 clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
2633 own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2634 if (clientdata && clientdata->pytype) {
2635 SwigPyObject *newobj;
2636 if (flags & SWIG_BUILTIN_TP_INIT) {
2637 newobj = (SwigPyObject*) self;
2638 if (newobj->ptr) {
2639 PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
2640 while (newobj->next)
2641 newobj = (SwigPyObject *) newobj->next;
2642 newobj->next = next_self;
2643 newobj = (SwigPyObject *)next_self;
2644 #ifdef SWIGPYTHON_BUILTIN
2645 newobj->dict = 0;
2646 #endif
2647 }
2648 } else {
2649 newobj = PyObject_New(SwigPyObject, clientdata->pytype);
2650 #ifdef SWIGPYTHON_BUILTIN
2651 newobj->dict = 0;
2652 #endif
2653 }
2654 if (newobj) {
2655 newobj->ptr = ptr;
2656 newobj->ty = type;
2657 newobj->own = own;
2658 newobj->next = 0;
2659 return (PyObject*) newobj;
2660 }
2661 return SWIG_Py_Void();
2662 }
2663
2664 assert(!(flags & SWIG_BUILTIN_TP_INIT));
2665
2666 robj = SwigPyObject_New(ptr, type, own);
2667 if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2668 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2669 Py_DECREF(robj);
2670 robj = inst;
2671 }
2672 return robj;
2673 }
2674
2675 /* Create a new packed object */
2676
2677 SWIGRUNTIMEINLINE PyObject *
SWIG_Python_NewPackedObj(void * ptr,size_t sz,swig_type_info * type)2678 SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
2679 return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
2680 }
2681
2682 /* -----------------------------------------------------------------------------*
2683 * Get type list
2684 * -----------------------------------------------------------------------------*/
2685
2686 #ifdef SWIG_LINK_RUNTIME
2687 void *SWIG_ReturnGlobalTypeList(void *);
2688 #endif
2689
2690 SWIGRUNTIME swig_module_info *
SWIG_Python_GetModule(void * SWIGUNUSEDPARM (clientdata))2691 SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
2692 static void *type_pointer = (void *)0;
2693 /* first check if module already created */
2694 if (!type_pointer) {
2695 #ifdef SWIG_LINK_RUNTIME
2696 type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
2697 #else
2698 # ifdef SWIGPY_USE_CAPSULE
2699 type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
2700 # else
2701 type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
2702 (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
2703 # endif
2704 if (PyErr_Occurred()) {
2705 PyErr_Clear();
2706 type_pointer = (void *)0;
2707 }
2708 #endif
2709 }
2710 return (swig_module_info *) type_pointer;
2711 }
2712
2713 #if PY_MAJOR_VERSION < 2
2714 /* PyModule_AddObject function was introduced in Python 2.0. The following function
2715 is copied out of Python/modsupport.c in python version 2.3.4 */
2716 SWIGINTERN int
PyModule_AddObject(PyObject * m,char * name,PyObject * o)2717 PyModule_AddObject(PyObject *m, char *name, PyObject *o)
2718 {
2719 PyObject *dict;
2720 if (!PyModule_Check(m)) {
2721 PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg");
2722 return SWIG_ERROR;
2723 }
2724 if (!o) {
2725 PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
2726 return SWIG_ERROR;
2727 }
2728
2729 dict = PyModule_GetDict(m);
2730 if (dict == NULL) {
2731 /* Internal error -- modules must have a dict! */
2732 PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
2733 PyModule_GetName(m));
2734 return SWIG_ERROR;
2735 }
2736 if (PyDict_SetItemString(dict, name, o))
2737 return SWIG_ERROR;
2738 Py_DECREF(o);
2739 return SWIG_OK;
2740 }
2741 #endif
2742
2743 SWIGRUNTIME void
2744 #ifdef SWIGPY_USE_CAPSULE
SWIG_Python_DestroyModule(PyObject * obj)2745 SWIG_Python_DestroyModule(PyObject *obj)
2746 #else
2747 SWIG_Python_DestroyModule(void *vptr)
2748 #endif
2749 {
2750 #ifdef SWIGPY_USE_CAPSULE
2751 swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
2752 #else
2753 swig_module_info *swig_module = (swig_module_info *) vptr;
2754 #endif
2755 swig_type_info **types = swig_module->types;
2756 size_t i;
2757 for (i =0; i < swig_module->size; ++i) {
2758 swig_type_info *ty = types[i];
2759 if (ty->owndata) {
2760 SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
2761 if (data) SwigPyClientData_Del(data);
2762 }
2763 }
2764 Py_DECREF(SWIG_This());
2765 swig_this = NULL;
2766 }
2767
2768 SWIGRUNTIME void
SWIG_Python_SetModule(swig_module_info * swig_module)2769 SWIG_Python_SetModule(swig_module_info *swig_module) {
2770 #if PY_VERSION_HEX >= 0x03000000
2771 /* Add a dummy module object into sys.modules */
2772 PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
2773 #else
2774 static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
2775 PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
2776 #endif
2777 #ifdef SWIGPY_USE_CAPSULE
2778 PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
2779 if (pointer && module) {
2780 PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
2781 } else {
2782 Py_XDECREF(pointer);
2783 }
2784 #else
2785 PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
2786 if (pointer && module) {
2787 PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
2788 } else {
2789 Py_XDECREF(pointer);
2790 }
2791 #endif
2792 }
2793
2794 /* The python cached type query */
2795 SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void)2796 SWIG_Python_TypeCache(void) {
2797 static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
2798 return cache;
2799 }
2800
2801 SWIGRUNTIME swig_type_info *
SWIG_Python_TypeQuery(const char * type)2802 SWIG_Python_TypeQuery(const char *type)
2803 {
2804 PyObject *cache = SWIG_Python_TypeCache();
2805 PyObject *key = SWIG_Python_str_FromChar(type);
2806 PyObject *obj = PyDict_GetItem(cache, key);
2807 swig_type_info *descriptor;
2808 if (obj) {
2809 #ifdef SWIGPY_USE_CAPSULE
2810 descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
2811 #else
2812 descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
2813 #endif
2814 } else {
2815 swig_module_info *swig_module = SWIG_GetModule(0);
2816 descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
2817 if (descriptor) {
2818 #ifdef SWIGPY_USE_CAPSULE
2819 obj = PyCapsule_New((void*) descriptor, NULL, NULL);
2820 #else
2821 obj = PyCObject_FromVoidPtr(descriptor, NULL);
2822 #endif
2823 PyDict_SetItem(cache, key, obj);
2824 Py_DECREF(obj);
2825 }
2826 }
2827 Py_DECREF(key);
2828 return descriptor;
2829 }
2830
2831 /*
2832 For backward compatibility only
2833 */
2834 #define SWIG_POINTER_EXCEPTION 0
2835 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
2836 #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
2837
2838 SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char * mesg,int infront)2839 SWIG_Python_AddErrMesg(const char* mesg, int infront)
2840 {
2841 if (PyErr_Occurred()) {
2842 PyObject *type = 0;
2843 PyObject *value = 0;
2844 PyObject *traceback = 0;
2845 PyErr_Fetch(&type, &value, &traceback);
2846 if (value) {
2847 char *tmp;
2848 PyObject *old_str = PyObject_Str(value);
2849 Py_XINCREF(type);
2850 PyErr_Clear();
2851 if (infront) {
2852 PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
2853 } else {
2854 PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
2855 }
2856 SWIG_Python_str_DelForPy3(tmp);
2857 Py_DECREF(old_str);
2858 }
2859 return 1;
2860 } else {
2861 return 0;
2862 }
2863 }
2864
2865 SWIGRUNTIME int
SWIG_Python_ArgFail(int argnum)2866 SWIG_Python_ArgFail(int argnum)
2867 {
2868 if (PyErr_Occurred()) {
2869 /* add information about failing argument */
2870 char mesg[256];
2871 PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
2872 return SWIG_Python_AddErrMesg(mesg, 1);
2873 } else {
2874 return 0;
2875 }
2876 }
2877
2878 SWIGRUNTIMEINLINE const char *
SwigPyObject_GetDesc(PyObject * self)2879 SwigPyObject_GetDesc(PyObject *self)
2880 {
2881 SwigPyObject *v = (SwigPyObject *)self;
2882 swig_type_info *ty = v ? v->ty : 0;
2883 return ty ? ty->str : "";
2884 }
2885
2886 SWIGRUNTIME void
SWIG_Python_TypeError(const char * type,PyObject * obj)2887 SWIG_Python_TypeError(const char *type, PyObject *obj)
2888 {
2889 if (type) {
2890 #if defined(SWIG_COBJECT_TYPES)
2891 if (obj && SwigPyObject_Check(obj)) {
2892 const char *otype = (const char *) SwigPyObject_GetDesc(obj);
2893 if (otype) {
2894 PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
2895 type, otype);
2896 return;
2897 }
2898 } else
2899 #endif
2900 {
2901 const char *otype = (obj ? obj->ob_type->tp_name : 0);
2902 if (otype) {
2903 PyObject *str = PyObject_Str(obj);
2904 const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
2905 if (cstr) {
2906 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
2907 type, otype, cstr);
2908 SWIG_Python_str_DelForPy3(cstr);
2909 } else {
2910 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
2911 type, otype);
2912 }
2913 Py_XDECREF(str);
2914 return;
2915 }
2916 }
2917 PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
2918 } else {
2919 PyErr_Format(PyExc_TypeError, "unexpected type is received");
2920 }
2921 }
2922
2923
2924 /* Convert a pointer value, signal an exception on a type mismatch */
2925 SWIGRUNTIME void *
SWIG_Python_MustGetPtr(PyObject * obj,swig_type_info * ty,int SWIGUNUSEDPARM (argnum),int flags)2926 SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
2927 void *result;
2928 if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
2929 PyErr_Clear();
2930 #if SWIG_POINTER_EXCEPTION
2931 if (flags) {
2932 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
2933 SWIG_Python_ArgFail(argnum);
2934 }
2935 #endif
2936 }
2937 return result;
2938 }
2939
2940 #ifdef SWIGPYTHON_BUILTIN
2941 SWIGRUNTIME int
SWIG_Python_NonDynamicSetAttr(PyObject * obj,PyObject * name,PyObject * value)2942 SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
2943 PyTypeObject *tp = obj->ob_type;
2944 PyObject *descr;
2945 PyObject *encoded_name;
2946 descrsetfunc f;
2947 int res = -1;
2948
2949 # ifdef Py_USING_UNICODE
2950 if (PyString_Check(name)) {
2951 name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
2952 if (!name)
2953 return -1;
2954 } else if (!PyUnicode_Check(name))
2955 # else
2956 if (!PyString_Check(name))
2957 # endif
2958 {
2959 PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
2960 return -1;
2961 } else {
2962 Py_INCREF(name);
2963 }
2964
2965 if (!tp->tp_dict) {
2966 if (PyType_Ready(tp) < 0)
2967 goto done;
2968 }
2969
2970 descr = _PyType_Lookup(tp, name);
2971 f = NULL;
2972 if (descr != NULL)
2973 f = descr->ob_type->tp_descr_set;
2974 if (!f) {
2975 if (PyString_Check(name)) {
2976 encoded_name = name;
2977 Py_INCREF(name);
2978 } else {
2979 encoded_name = PyUnicode_AsUTF8String(name);
2980 }
2981 PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
2982 Py_DECREF(encoded_name);
2983 } else {
2984 res = f(descr, obj, value);
2985 }
2986
2987 done:
2988 Py_DECREF(name);
2989 return res;
2990 }
2991 #endif
2992
2993
2994 #ifdef __cplusplus
2995 }
2996 #endif
2997
2998
2999
3000 #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
3001
3002 #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
3003
3004
3005
3006 #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0)
3007
3008
3009 /* -------- TYPES TABLE (BEGIN) -------- */
3010
3011 #define SWIGTYPE_p_CPLErrorHandler swig_types[0]
3012 #define SWIGTYPE_p_CPLVirtualMemShadow swig_types[1]
3013 #define SWIGTYPE_p_CPLXMLNode swig_types[2]
3014 #define SWIGTYPE_p_DirEntry swig_types[3]
3015 #define SWIGTYPE_p_GByte swig_types[4]
3016 #define SWIGTYPE_p_GDALAsyncReaderShadow swig_types[5]
3017 #define SWIGTYPE_p_GDALAttributeHS swig_types[6]
3018 #define SWIGTYPE_p_GDALBuildVRTOptions swig_types[7]
3019 #define SWIGTYPE_p_GDALColorEntry swig_types[8]
3020 #define SWIGTYPE_p_GDALColorTableShadow swig_types[9]
3021 #define SWIGTYPE_p_GDALDEMProcessingOptions swig_types[10]
3022 #define SWIGTYPE_p_GDALDatasetShadow swig_types[11]
3023 #define SWIGTYPE_p_GDALDimensionHS swig_types[12]
3024 #define SWIGTYPE_p_GDALDriverShadow swig_types[13]
3025 #define SWIGTYPE_p_GDALEDTComponentHS swig_types[14]
3026 #define SWIGTYPE_p_GDALExtendedDataTypeClass swig_types[15]
3027 #define SWIGTYPE_p_GDALExtendedDataTypeHS swig_types[16]
3028 #define SWIGTYPE_p_GDALGridOptions swig_types[17]
3029 #define SWIGTYPE_p_GDALGroupHS swig_types[18]
3030 #define SWIGTYPE_p_GDALInfoOptions swig_types[19]
3031 #define SWIGTYPE_p_GDALMDArrayHS swig_types[20]
3032 #define SWIGTYPE_p_GDALMajorObjectShadow swig_types[21]
3033 #define SWIGTYPE_p_GDALMultiDimInfoOptions swig_types[22]
3034 #define SWIGTYPE_p_GDALMultiDimTranslateOptions swig_types[23]
3035 #define SWIGTYPE_p_GDALNearblackOptions swig_types[24]
3036 #define SWIGTYPE_p_GDALProgressFunc swig_types[25]
3037 #define SWIGTYPE_p_GDALRasterAttributeTableShadow swig_types[26]
3038 #define SWIGTYPE_p_GDALRasterBandShadow swig_types[27]
3039 #define SWIGTYPE_p_GDALRasterizeOptions swig_types[28]
3040 #define SWIGTYPE_p_GDALTransformerInfoShadow swig_types[29]
3041 #define SWIGTYPE_p_GDALTranslateOptions swig_types[30]
3042 #define SWIGTYPE_p_GDALVectorTranslateOptions swig_types[31]
3043 #define SWIGTYPE_p_GDALViewshedMode swig_types[32]
3044 #define SWIGTYPE_p_GDALViewshedOutputType swig_types[33]
3045 #define SWIGTYPE_p_GDALWarpAppOptions swig_types[34]
3046 #define SWIGTYPE_p_GDAL_GCP swig_types[35]
3047 #define SWIGTYPE_p_GIntBig swig_types[36]
3048 #define SWIGTYPE_p_GUIntBig swig_types[37]
3049 #define SWIGTYPE_p_OGRFeatureShadow swig_types[38]
3050 #define SWIGTYPE_p_OGRFieldDomainShadow swig_types[39]
3051 #define SWIGTYPE_p_OGRGeometryShadow swig_types[40]
3052 #define SWIGTYPE_p_OGRLayerShadow swig_types[41]
3053 #define SWIGTYPE_p_OGRStyleTableShadow swig_types[42]
3054 #define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[43]
3055 #define SWIGTYPE_p_StatBuf swig_types[44]
3056 #define SWIGTYPE_p_Statistics swig_types[45]
3057 #define SWIGTYPE_p_VSIDIR swig_types[46]
3058 #define SWIGTYPE_p_VSILFILE swig_types[47]
3059 #define SWIGTYPE_p_char swig_types[48]
3060 #define SWIGTYPE_p_double swig_types[49]
3061 #define SWIGTYPE_p_f_double_p_q_const__char_p_void__int swig_types[50]
3062 #define SWIGTYPE_p_int swig_types[51]
3063 #define SWIGTYPE_p_p_GByte swig_types[52]
3064 #define SWIGTYPE_p_p_GDALDatasetShadow swig_types[53]
3065 #define SWIGTYPE_p_p_GDALDimensionHS swig_types[54]
3066 #define SWIGTYPE_p_p_GDALEDTComponentHS swig_types[55]
3067 #define SWIGTYPE_p_p_GDALRasterBandShadow swig_types[56]
3068 #define SWIGTYPE_p_p_GDAL_GCP swig_types[57]
3069 #define SWIGTYPE_p_p_GUIntBig swig_types[58]
3070 #define SWIGTYPE_p_p_OGRLayerShadow swig_types[59]
3071 #define SWIGTYPE_p_p_char swig_types[60]
3072 #define SWIGTYPE_p_p_double swig_types[61]
3073 #define SWIGTYPE_p_p_int swig_types[62]
3074 #define SWIGTYPE_p_p_p_GDALAttributeHS swig_types[63]
3075 #define SWIGTYPE_p_p_p_GDALDimensionHS swig_types[64]
3076 #define SWIGTYPE_p_p_p_GDALEDTComponentHS swig_types[65]
3077 #define SWIGTYPE_p_p_void swig_types[66]
3078 #define SWIGTYPE_p_size_t swig_types[67]
3079 #define SWIGTYPE_p_vsi_l_offset swig_types[68]
3080 static swig_type_info *swig_types[70];
3081 static swig_module_info swig_module = {swig_types, 69, 0, 0, 0, 0};
3082 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
3083 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
3084
3085 /* -------- TYPES TABLE (END) -------- */
3086
3087 #if (PY_VERSION_HEX <= 0x02000000)
3088 # if !defined(SWIG_PYTHON_CLASSIC)
3089 # error "This python version requires swig to be run with the '-classic' option"
3090 # endif
3091 #endif
3092
3093 /*-----------------------------------------------
3094 @(target):= _gdal.so
3095 ------------------------------------------------*/
3096 #if PY_VERSION_HEX >= 0x03000000
3097 # define SWIG_init PyInit__gdal
3098
3099 #else
3100 # define SWIG_init init_gdal
3101
3102 #endif
3103 #define SWIG_name "_gdal"
3104
3105 #define SWIGVERSION 0x030012
3106 #define SWIG_VERSION SWIGVERSION
3107
3108
3109 #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
3110 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
3111
3112
3113 #include <stdexcept>
3114
3115
3116 namespace swig {
3117 class SwigPtr_PyObject {
3118 protected:
3119 PyObject *_obj;
3120
3121 public:
SwigPtr_PyObject()3122 SwigPtr_PyObject() :_obj(0)
3123 {
3124 }
3125
SwigPtr_PyObject(const SwigPtr_PyObject & item)3126 SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
3127 {
3128 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3129 Py_XINCREF(_obj);
3130 SWIG_PYTHON_THREAD_END_BLOCK;
3131 }
3132
SwigPtr_PyObject(PyObject * obj,bool initial_ref=true)3133 SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
3134 {
3135 if (initial_ref) {
3136 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3137 Py_XINCREF(_obj);
3138 SWIG_PYTHON_THREAD_END_BLOCK;
3139 }
3140 }
3141
operator =(const SwigPtr_PyObject & item)3142 SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
3143 {
3144 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3145 Py_XINCREF(item._obj);
3146 Py_XDECREF(_obj);
3147 _obj = item._obj;
3148 SWIG_PYTHON_THREAD_END_BLOCK;
3149 return *this;
3150 }
3151
~SwigPtr_PyObject()3152 ~SwigPtr_PyObject()
3153 {
3154 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3155 Py_XDECREF(_obj);
3156 SWIG_PYTHON_THREAD_END_BLOCK;
3157 }
3158
operator PyObject*() const3159 operator PyObject *() const
3160 {
3161 return _obj;
3162 }
3163
operator ->() const3164 PyObject *operator->() const
3165 {
3166 return _obj;
3167 }
3168 };
3169 }
3170
3171
3172 namespace swig {
3173 struct SwigVar_PyObject : SwigPtr_PyObject {
SwigVar_PyObjectswig::SwigVar_PyObject3174 SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
3175
operator =swig::SwigVar_PyObject3176 SwigVar_PyObject & operator = (PyObject* obj)
3177 {
3178 Py_XDECREF(_obj);
3179 _obj = obj;
3180 return *this;
3181 }
3182 };
3183 }
3184
3185
3186 #include <iostream>
3187 #include <vector>
3188 using namespace std;
3189
3190 #define CPL_SUPRESS_CPLUSPLUS
3191 #include "cpl_port.h"
3192 #include "cpl_string.h"
3193 #include "cpl_multiproc.h"
3194 #include "cpl_http.h"
3195 #include "cpl_vsi_error.h"
3196
3197 #include "gdal.h"
3198 #include "gdal_alg.h"
3199 #include "gdalwarper.h"
3200 #include "ogr_srs_api.h"
3201
3202 typedef void GDALMajorObjectShadow;
3203 typedef void GDALDriverShadow;
3204 typedef void GDALDatasetShadow;
3205 typedef void GDALRasterBandShadow;
3206 typedef void GDALColorTableShadow;
3207 typedef void GDALRasterAttributeTableShadow;
3208 typedef void GDALTransformerInfoShadow;
3209 typedef void GDALAsyncReaderShadow;
3210
3211 typedef GDALExtendedDataTypeHS GDALExtendedDataTypeHS;
3212 typedef GDALEDTComponentHS GDALEDTComponentHS;
3213 typedef GDALGroupHS GDALGroupHS;
3214 typedef GDALMDArrayHS GDALMDArrayHS;
3215 typedef GDALAttributeHS GDALAttributeHS;
3216 typedef GDALDimensionHS GDALDimensionHS;
3217
3218
3219
3220 #ifdef DEBUG
3221 typedef struct OGRSpatialReferenceHS OSRSpatialReferenceShadow;
3222 typedef struct OGRLayerHS OGRLayerShadow;
3223 typedef struct OGRFeatureHS OGRFeatureShadow;
3224 typedef struct OGRGeometryHS OGRGeometryShadow;
3225 #else
3226 typedef void OSRSpatialReferenceShadow;
3227 typedef void OGRLayerShadow;
3228 typedef void OGRFeatureShadow;
3229 typedef void OGRGeometryShadow;
3230 #endif
3231
3232 typedef struct OGRStyleTableHS OGRStyleTableShadow;
3233 typedef struct OGRFieldDomainHS OGRFieldDomainShadow;
3234
3235
3236 /* use this to not return the int returned by GDAL */
3237 typedef int RETURN_NONE;
3238 /* return value that is used for VSI methods that return -1 on error (and set errno) */
3239 typedef int VSI_RETVAL;
3240
3241
getAlignment(GDALDataType ntype)3242 static int getAlignment(GDALDataType ntype)
3243 {
3244 switch(ntype)
3245 {
3246 case GDT_Unknown:
3247 break; // shouldn't happen
3248 case GDT_Byte:
3249 return 1;
3250 case GDT_Int16:
3251 case GDT_UInt16:
3252 return 2;
3253 case GDT_Int32:
3254 case GDT_UInt32:
3255 case GDT_Float32:
3256 return 4;
3257 case GDT_Float64:
3258 return 8;
3259 case GDT_CInt16:
3260 return 2;
3261 case GDT_CInt32:
3262 case GDT_CFloat32:
3263 return 4;
3264 case GDT_CFloat64:
3265 return 8;
3266 case GDT_TypeCount:
3267 break; // shouldn't happen
3268 }
3269 // shouldn't happen
3270 CPLAssert(false);
3271 return 1;
3272 }
3273
readraster_acquirebuffer(void ** buf,void * & inputOutputBuf,size_t buf_size,GDALDataType ntype,int bUseExceptions,char * & data,Py_buffer & view)3274 static bool readraster_acquirebuffer(void** buf,
3275 void*& inputOutputBuf,
3276 size_t buf_size,
3277 GDALDataType ntype,
3278 int bUseExceptions,
3279 char*& data,
3280 Py_buffer& view)
3281 {
3282 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3283
3284 if( inputOutputBuf == Py_None )
3285 inputOutputBuf = NULL;
3286
3287 if( inputOutputBuf )
3288 {
3289 if (PyObject_GetBuffer( (PyObject*)inputOutputBuf, &view,
3290 PyBUF_SIMPLE | PyBUF_WRITABLE) == 0)
3291 {
3292 if( static_cast<GUIntBig>(view.len) < buf_size )
3293 {
3294 PyBuffer_Release(&view);
3295 SWIG_PYTHON_THREAD_END_BLOCK;
3296 CPLError(CE_Failure, CPLE_AppDefined,
3297 "buf_obj length is " CPL_FRMT_GUIB " bytes. "
3298 "It should be at least " CPL_FRMT_GUIB,
3299 static_cast<GUIntBig>(view.len),
3300 static_cast<GUIntBig>(buf_size));
3301 return false;
3302 }
3303 data = (char*)view.buf;
3304 if( (reinterpret_cast<uintptr_t>(data) % getAlignment(ntype)) != 0 )
3305 {
3306 PyBuffer_Release(&view);
3307 SWIG_PYTHON_THREAD_END_BLOCK;
3308 CPLError(CE_Failure, CPLE_AppDefined,
3309 "buffer has not the appropriate alignment");
3310 return false;
3311 }
3312 }
3313 else
3314 {
3315 PyErr_Clear();
3316 SWIG_PYTHON_THREAD_END_BLOCK;
3317 CPLError(CE_Failure, CPLE_AppDefined,
3318 "buf_obj is not a simple writable buffer");
3319 return false;
3320 }
3321 }
3322 else
3323 {
3324 *buf = (void *)PyByteArray_FromStringAndSize( NULL, buf_size );
3325 if (*buf == NULL)
3326 {
3327 *buf = Py_None;
3328 if( !bUseExceptions )
3329 {
3330 PyErr_Clear();
3331 }
3332 SWIG_PYTHON_THREAD_END_BLOCK;
3333 CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate result buffer");
3334 return false;
3335 }
3336 data = PyByteArray_AsString( (PyObject *)*buf );
3337 }
3338 SWIG_PYTHON_THREAD_END_BLOCK;
3339 return true;
3340 }
3341
readraster_releasebuffer(CPLErr eErr,void ** buf,void * inputOutputBuf,Py_buffer & view)3342 static void readraster_releasebuffer(CPLErr eErr,
3343 void** buf,
3344 void* inputOutputBuf,
3345 Py_buffer& view)
3346 {
3347 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3348
3349 if( inputOutputBuf )
3350 PyBuffer_Release(&view);
3351
3352 if (eErr == CE_Failure)
3353 {
3354 if( inputOutputBuf == NULL )
3355 Py_DECREF((PyObject*)*buf);
3356 *buf = NULL;
3357 }
3358 else if( inputOutputBuf )
3359 {
3360 *buf = inputOutputBuf;
3361 Py_INCREF((PyObject*)*buf);
3362 }
3363
3364 SWIG_PYTHON_THREAD_END_BLOCK;
3365 }
3366
3367
3368
3369 #define MODULE_NAME "gdal"
3370
3371
3372 static int bUseExceptions=0;
3373 static CPLErrorHandler pfnPreviousHandler = CPLDefaultErrorHandler;
3374
3375 static void CPL_STDCALL
PythonBindingErrorHandler(CPLErr eclass,int code,const char * msg)3376 PythonBindingErrorHandler(CPLErr eclass, int code, const char *msg )
3377 {
3378 /*
3379 ** Generally we want to suppress error reporting if we have exceptions
3380 ** enabled as the error message will be in the exception thrown in
3381 ** Python.
3382 */
3383
3384 /* If the error class is CE_Fatal, we want to have a message issued
3385 because the CPL support code does an abort() before any exception
3386 can be generated */
3387 if (eclass == CE_Fatal ) {
3388 pfnPreviousHandler(eclass, code, msg );
3389 }
3390
3391 /*
3392 ** We do not want to interfere with non-failure messages since
3393 ** they won't be translated into exceptions.
3394 */
3395 else if (eclass != CE_Failure ) {
3396 pfnPreviousHandler(eclass, code, msg );
3397 }
3398 else {
3399 CPLSetThreadLocalConfigOption("__last_error_message", msg);
3400 CPLSetThreadLocalConfigOption("__last_error_code", CPLSPrintf("%d", code));
3401 }
3402 }
3403
3404
3405
3406 static
GetUseExceptions()3407 int GetUseExceptions() {
3408 CPLErrorReset();
3409 return bUseExceptions;
3410 }
3411
3412 static
UseExceptions()3413 void UseExceptions() {
3414 CPLErrorReset();
3415 if( !bUseExceptions )
3416 {
3417 bUseExceptions = 1;
3418 char* pszNewValue = CPLStrdup(CPLSPrintf("%s %s",
3419 MODULE_NAME,
3420 CPLGetConfigOption("__chain_python_error_handlers", "")));
3421 CPLSetConfigOption("__chain_python_error_handlers", pszNewValue);
3422 CPLFree(pszNewValue);
3423 // if the previous logger was custom, we need the user data available
3424 pfnPreviousHandler =
3425 CPLSetErrorHandlerEx( (CPLErrorHandler) PythonBindingErrorHandler, CPLGetErrorHandlerUserData() );
3426 }
3427 }
3428
3429 static
DontUseExceptions()3430 void DontUseExceptions() {
3431 CPLErrorReset();
3432 if( bUseExceptions )
3433 {
3434 const char* pszValue = CPLGetConfigOption("__chain_python_error_handlers", "");
3435 if( strncmp(pszValue, MODULE_NAME, strlen(MODULE_NAME)) != 0 ||
3436 pszValue[strlen(MODULE_NAME)] != ' ')
3437 {
3438 CPLError(CE_Failure, CPLE_NotSupported,
3439 "Cannot call %s.DontUseExceptions() at that point since the "
3440 "stack of error handlers is: %s", MODULE_NAME, pszValue);
3441 return;
3442 }
3443 char* pszNewValue = CPLStrdup(pszValue + strlen(MODULE_NAME) + 1);
3444 if( pszNewValue[0] == ' ' && pszNewValue[1] == '\0' )
3445 {
3446 CPLFree(pszNewValue);
3447 pszNewValue = NULL;
3448 }
3449 CPLSetConfigOption("__chain_python_error_handlers", pszNewValue);
3450 CPLFree(pszNewValue);
3451 bUseExceptions = 0;
3452 // if the previous logger was custom, we need the user data available. Preserve it.
3453 CPLSetErrorHandlerEx( pfnPreviousHandler, CPLGetErrorHandlerUserData());
3454 }
3455 }
3456
3457
3458 SWIGINTERNINLINE PyObject*
SWIG_From_int(int value)3459 SWIG_From_int (int value)
3460 {
3461 return PyInt_FromLong((long) value);
3462 }
3463
3464
3465 /* Completely unrelated: just to avoid Coverity warnings */
3466
3467 static int bReturnSame = 1;
3468
NeverCallMePlease()3469 void NeverCallMePlease() {
3470 bReturnSame = 0;
3471 }
3472
3473 /* Some SWIG code generates dead code, which Coverity warns about */
ReturnSame(T x)3474 template<class T> static T ReturnSame(T x)
3475 {
3476 if( bReturnSame )
3477 return x;
3478 return 0;
3479 }
3480
ClearErrorState()3481 static void ClearErrorState()
3482 {
3483 CPLSetThreadLocalConfigOption("__last_error_message", NULL);
3484 CPLSetThreadLocalConfigOption("__last_error_code", NULL);
3485 CPLErrorReset();
3486 }
3487
3488 static void StoreLastException() CPL_UNUSED;
3489
3490 // Note: this is also copy&pasted in gdal_array.i
StoreLastException()3491 static void StoreLastException()
3492 {
3493 const char* pszLastErrorMessage =
3494 CPLGetThreadLocalConfigOption("__last_error_message", NULL);
3495 const char* pszLastErrorCode =
3496 CPLGetThreadLocalConfigOption("__last_error_code", NULL);
3497 if( pszLastErrorMessage != NULL && pszLastErrorCode != NULL )
3498 {
3499 CPLErrorSetState( CE_Failure,
3500 static_cast<CPLErrorNum>(atoi(pszLastErrorCode)),
3501 pszLastErrorMessage);
3502 }
3503 }
3504
3505
3506
3507
3508 /* Return a PyObject* from a NULL terminated C String */
3509 static PyObject* GDALPythonObjectFromCStr(const char *pszStr) CPL_UNUSED;
GDALPythonObjectFromCStr(const char * pszStr)3510 static PyObject* GDALPythonObjectFromCStr(const char *pszStr)
3511 {
3512 const unsigned char* pszIter = (const unsigned char*) pszStr;
3513 while(*pszIter != 0)
3514 {
3515 if (*pszIter > 127)
3516 {
3517 PyObject* pyObj = PyUnicode_DecodeUTF8(pszStr, strlen(pszStr), "strict");
3518 if (pyObj != NULL && !PyErr_Occurred())
3519 return pyObj;
3520 PyErr_Clear();
3521 return PyBytes_FromString(pszStr);
3522 }
3523 pszIter ++;
3524 }
3525 return PyUnicode_FromString(pszStr);
3526 }
3527
3528 /* Return a NULL terminated c String from a PyObject */
3529 /* Result must be freed with GDALPythonFreeCStr */
3530 static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree) CPL_UNUSED;
GDALPythonObjectToCStr(PyObject * pyObject,int * pbToFree)3531 static char* GDALPythonObjectToCStr(PyObject* pyObject, int* pbToFree)
3532 {
3533 *pbToFree = 0;
3534 if (PyUnicode_Check(pyObject))
3535 {
3536 char *pszStr;
3537 char *pszNewStr;
3538 Py_ssize_t nLen;
3539 PyObject* pyUTF8Str = PyUnicode_AsUTF8String(pyObject);
3540 if( pyUTF8Str == NULL )
3541 return NULL;
3542 PyBytes_AsStringAndSize(pyUTF8Str, &pszStr, &nLen);
3543 pszNewStr = (char *) malloc(nLen+1);
3544 if( pszNewStr == NULL )
3545 {
3546 CPLError(CE_Failure, CPLE_OutOfMemory, "Failed to allocate %llu bytes",
3547 (unsigned long long)(nLen + 1));
3548 Py_XDECREF(pyUTF8Str);
3549 return NULL;
3550 }
3551 memcpy(pszNewStr, pszStr, nLen+1);
3552 Py_XDECREF(pyUTF8Str);
3553 *pbToFree = 1;
3554 return pszNewStr;
3555 }
3556 else if( PyBytes_Check(pyObject) )
3557 {
3558 char* ret = PyBytes_AsString(pyObject);
3559
3560 // Check if there are \0 bytes inside the string
3561 const Py_ssize_t size = PyBytes_Size(pyObject);
3562 for( Py_ssize_t i = 0; i < size; i++ )
3563 {
3564 if( ret[i] == 0 )
3565 {
3566 CPLError(CE_Failure, CPLE_AppDefined,
3567 "bytes object cast as string contains a zero-byte.");
3568 return NULL;
3569 }
3570 }
3571
3572 return ret;
3573 }
3574 else
3575 {
3576 CPLError(CE_Failure, CPLE_AppDefined,
3577 "Passed object is neither of type string nor bytes");
3578 return NULL;
3579 }
3580 }
3581
3582 static void GDALPythonFreeCStr(void* ptr, int bToFree) CPL_UNUSED;
GDALPythonFreeCStr(void * ptr,int bToFree)3583 static void GDALPythonFreeCStr(void* ptr, int bToFree)
3584 {
3585 if (bToFree)
3586 free(ptr);
3587 }
3588
3589
3590
wrapper_VSIFReadL(void ** buf,unsigned int nMembSize,unsigned int nMembCount,VSILFILE * fp)3591 unsigned int wrapper_VSIFReadL( void **buf, unsigned int nMembSize, unsigned int nMembCount, VSILFILE *fp)
3592 {
3593 size_t buf_size = static_cast<size_t>(nMembSize) * nMembCount;
3594 if( buf_size > 0xFFFFFFFFU )
3595 {
3596 CPLError(CE_Failure, CPLE_AppDefined, "Too big request");
3597 *buf = NULL;
3598 return 0;
3599 }
3600
3601 if (buf_size == 0)
3602 {
3603 *buf = NULL;
3604 return 0;
3605 }
3606
3607 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3608 *buf = (void *)PyByteArray_FromStringAndSize( NULL, buf_size );
3609 if (*buf == NULL)
3610 {
3611 *buf = Py_None;
3612 if( !bUseExceptions )
3613 {
3614 PyErr_Clear();
3615 }
3616 SWIG_PYTHON_THREAD_END_BLOCK;
3617 CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate result buffer");
3618 return 0;
3619 }
3620 PyObject* o = (PyObject*) *buf;
3621 char *data = PyByteArray_AsString(o);
3622 SWIG_PYTHON_THREAD_END_BLOCK;
3623 size_t nRet = (size_t)VSIFReadL( data, nMembSize, nMembCount, fp );
3624 if (nRet * (size_t)nMembSize < buf_size)
3625 {
3626 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3627 PyByteArray_Resize(o, nRet * nMembSize);
3628 SWIG_PYTHON_THREAD_END_BLOCK;
3629 *buf = o;
3630 }
3631 return static_cast<unsigned int>(nRet);
3632 }
3633
3634
3635 #include <limits.h>
3636 #if !defined(SWIG_NO_LLONG_MAX)
3637 # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
3638 # define LLONG_MAX __LONG_LONG_MAX__
3639 # define LLONG_MIN (-LLONG_MAX - 1LL)
3640 # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
3641 # endif
3642 #endif
3643
3644
3645 SWIGINTERN int
SWIG_AsVal_double(PyObject * obj,double * val)3646 SWIG_AsVal_double (PyObject *obj, double *val)
3647 {
3648 int res = SWIG_TypeError;
3649 if (PyFloat_Check(obj)) {
3650 if (val) *val = PyFloat_AsDouble(obj);
3651 return SWIG_OK;
3652 #if PY_VERSION_HEX < 0x03000000
3653 } else if (PyInt_Check(obj)) {
3654 if (val) *val = (double) PyInt_AsLong(obj);
3655 return SWIG_OK;
3656 #endif
3657 } else if (PyLong_Check(obj)) {
3658 double v = PyLong_AsDouble(obj);
3659 if (!PyErr_Occurred()) {
3660 if (val) *val = v;
3661 return SWIG_OK;
3662 } else {
3663 PyErr_Clear();
3664 }
3665 }
3666 #ifdef SWIG_PYTHON_CAST_MODE
3667 {
3668 int dispatch = 0;
3669 double d = PyFloat_AsDouble(obj);
3670 if (!PyErr_Occurred()) {
3671 if (val) *val = d;
3672 return SWIG_AddCast(SWIG_OK);
3673 } else {
3674 PyErr_Clear();
3675 }
3676 if (!dispatch) {
3677 long v = PyLong_AsLong(obj);
3678 if (!PyErr_Occurred()) {
3679 if (val) *val = v;
3680 return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
3681 } else {
3682 PyErr_Clear();
3683 }
3684 }
3685 }
3686 #endif
3687 return res;
3688 }
3689
3690
3691 #include <float.h>
3692
3693
3694 #include <math.h>
3695
3696
3697 SWIGINTERNINLINE int
SWIG_CanCastAsInteger(double * d,double min,double max)3698 SWIG_CanCastAsInteger(double *d, double min, double max) {
3699 double x = *d;
3700 if ((min <= x && x <= max)) {
3701 double fx = floor(x);
3702 double cx = ceil(x);
3703 double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
3704 if ((errno == EDOM) || (errno == ERANGE)) {
3705 errno = 0;
3706 } else {
3707 double summ, reps, diff;
3708 if (rd < x) {
3709 diff = x - rd;
3710 } else if (rd > x) {
3711 diff = rd - x;
3712 } else {
3713 return 1;
3714 }
3715 summ = rd + x;
3716 reps = diff/summ;
3717 if (reps < 8*DBL_EPSILON) {
3718 *d = rd;
3719 return 1;
3720 }
3721 }
3722 }
3723 return 0;
3724 }
3725
3726
3727 SWIGINTERN int
SWIG_AsVal_unsigned_SS_long(PyObject * obj,unsigned long * val)3728 SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
3729 {
3730 #if PY_VERSION_HEX < 0x03000000
3731 if (PyInt_Check(obj)) {
3732 long v = PyInt_AsLong(obj);
3733 if (v >= 0) {
3734 if (val) *val = v;
3735 return SWIG_OK;
3736 } else {
3737 return SWIG_OverflowError;
3738 }
3739 } else
3740 #endif
3741 if (PyLong_Check(obj)) {
3742 unsigned long v = PyLong_AsUnsignedLong(obj);
3743 if (!PyErr_Occurred()) {
3744 if (val) *val = v;
3745 return SWIG_OK;
3746 } else {
3747 PyErr_Clear();
3748 return SWIG_OverflowError;
3749 }
3750 }
3751 #ifdef SWIG_PYTHON_CAST_MODE
3752 {
3753 int dispatch = 0;
3754 unsigned long v = PyLong_AsUnsignedLong(obj);
3755 if (!PyErr_Occurred()) {
3756 if (val) *val = v;
3757 return SWIG_AddCast(SWIG_OK);
3758 } else {
3759 PyErr_Clear();
3760 }
3761 if (!dispatch) {
3762 double d;
3763 int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
3764 if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
3765 if (val) *val = (unsigned long)(d);
3766 return res;
3767 }
3768 }
3769 }
3770 #endif
3771 return SWIG_TypeError;
3772 }
3773
3774
3775 SWIGINTERN int
SWIG_AsVal_unsigned_SS_int(PyObject * obj,unsigned int * val)3776 SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
3777 {
3778 unsigned long v;
3779 int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
3780 if (SWIG_IsOK(res)) {
3781 if ((v > UINT_MAX)) {
3782 return SWIG_OverflowError;
3783 } else {
3784 if (val) *val = static_cast< unsigned int >(v);
3785 }
3786 }
3787 return res;
3788 }
3789
3790
3791 SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_int(unsigned int value)3792 SWIG_From_unsigned_SS_int (unsigned int value)
3793 {
3794 return PyInt_FromSize_t((size_t) value);
3795 }
3796
3797
wrapper_VSIGetMemFileBuffer(const char * utf8_path,GByte ** out,vsi_l_offset * length)3798 void wrapper_VSIGetMemFileBuffer(const char *utf8_path, GByte **out, vsi_l_offset *length)
3799 {
3800 *out = VSIGetMemFileBuffer(utf8_path, length, 0);
3801 }
3802
3803
3804 SWIGINTERN swig_type_info*
SWIG_pchar_descriptor(void)3805 SWIG_pchar_descriptor(void)
3806 {
3807 static int init = 0;
3808 static swig_type_info* info = 0;
3809 if (!init) {
3810 info = SWIG_TypeQuery("_p_char");
3811 init = 1;
3812 }
3813 return info;
3814 }
3815
3816
3817 SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject * obj,char ** cptr,size_t * psize,int * alloc)3818 SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
3819 {
3820 #if PY_VERSION_HEX>=0x03000000
3821 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3822 if (PyBytes_Check(obj))
3823 #else
3824 if (PyUnicode_Check(obj))
3825 #endif
3826 #else
3827 if (PyString_Check(obj))
3828 #endif
3829 {
3830 char *cstr; Py_ssize_t len;
3831 #if PY_VERSION_HEX>=0x03000000
3832 #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3833 if (!alloc && cptr) {
3834 /* We can't allow converting without allocation, since the internal
3835 representation of string in Python 3 is UCS-2/UCS-4 but we require
3836 a UTF-8 representation.
3837 TODO(bhy) More detailed explanation */
3838 return SWIG_RuntimeError;
3839 }
3840 obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
3841 if(alloc) *alloc = SWIG_NEWOBJ;
3842 #endif
3843 PyBytes_AsStringAndSize(obj, &cstr, &len);
3844 #else
3845 PyString_AsStringAndSize(obj, &cstr, &len);
3846 #endif
3847 if (cptr) {
3848 if (alloc) {
3849 /*
3850 In python the user should not be able to modify the inner
3851 string representation. To warranty that, if you define
3852 SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
3853 buffer is always returned.
3854
3855 The default behavior is just to return the pointer value,
3856 so, be careful.
3857 */
3858 #if defined(SWIG_PYTHON_SAFE_CSTRINGS)
3859 if (*alloc != SWIG_OLDOBJ)
3860 #else
3861 if (*alloc == SWIG_NEWOBJ)
3862 #endif
3863 {
3864 *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
3865 *alloc = SWIG_NEWOBJ;
3866 } else {
3867 *cptr = cstr;
3868 *alloc = SWIG_OLDOBJ;
3869 }
3870 } else {
3871 #if PY_VERSION_HEX>=0x03000000
3872 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3873 *cptr = PyBytes_AsString(obj);
3874 #else
3875 assert(0); /* Should never reach here with Unicode strings in Python 3 */
3876 #endif
3877 #else
3878 *cptr = SWIG_Python_str_AsChar(obj);
3879 #endif
3880 }
3881 }
3882 if (psize) *psize = len + 1;
3883 #if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3884 Py_XDECREF(obj);
3885 #endif
3886 return SWIG_OK;
3887 } else {
3888 #if defined(SWIG_PYTHON_2_UNICODE)
3889 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
3890 #error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
3891 #endif
3892 #if PY_VERSION_HEX<0x03000000
3893 if (PyUnicode_Check(obj)) {
3894 char *cstr; Py_ssize_t len;
3895 if (!alloc && cptr) {
3896 return SWIG_RuntimeError;
3897 }
3898 obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError;
3899 if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
3900 if (cptr) {
3901 if (alloc) *alloc = SWIG_NEWOBJ;
3902 *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
3903 }
3904 if (psize) *psize = len + 1;
3905
3906 Py_XDECREF(obj);
3907 return SWIG_OK;
3908 } else {
3909 Py_XDECREF(obj);
3910 }
3911 }
3912 #endif
3913 #endif
3914
3915 swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
3916 if (pchar_descriptor) {
3917 void* vptr = 0;
3918 if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
3919 if (cptr) *cptr = (char *) vptr;
3920 if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
3921 if (alloc) *alloc = SWIG_OLDOBJ;
3922 return SWIG_OK;
3923 }
3924 }
3925 }
3926 return SWIG_TypeError;
3927 }
3928
3929
3930
3931
3932
3933
3934 typedef struct {
3935 PyObject *psPyCallback;
3936 PyObject *psPyCallbackData;
3937 int nLastReported;
3938 } PyProgressData;
3939
3940 /************************************************************************/
3941 /* PyProgressProxy() */
3942 /************************************************************************/
3943
3944
3945 static int CPL_STDCALL
3946 PyProgressProxy( double dfComplete, const char *pszMessage, void *pData ) CPL_UNUSED;
3947
3948 static int CPL_STDCALL
PyProgressProxy(double dfComplete,const char * pszMessage,void * pData)3949 PyProgressProxy( double dfComplete, const char *pszMessage, void *pData )
3950
3951 {
3952 PyProgressData *psInfo = (PyProgressData *) pData;
3953 PyObject *psArgs, *psResult;
3954 int bContinue = TRUE;
3955
3956 if( psInfo->nLastReported == (int) (100.0 * dfComplete) )
3957 return TRUE;
3958
3959 if( psInfo->psPyCallback == NULL || psInfo->psPyCallback == Py_None )
3960 return TRUE;
3961
3962 psInfo->nLastReported = (int) (100.0 * dfComplete);
3963
3964 if( pszMessage == NULL )
3965 pszMessage = "";
3966
3967 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
3968
3969 if( psInfo->psPyCallbackData == NULL )
3970 psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage, Py_None );
3971 else
3972 psArgs = Py_BuildValue("(dsO)", dfComplete, pszMessage,
3973 psInfo->psPyCallbackData );
3974
3975 psResult = PyObject_CallObject( psInfo->psPyCallback, psArgs);
3976 Py_XDECREF(psArgs);
3977
3978 if( PyErr_Occurred() != NULL )
3979 {
3980 PyErr_Print();
3981 PyErr_Clear();
3982 SWIG_PYTHON_THREAD_END_BLOCK;
3983 return FALSE;
3984 }
3985
3986 if( psResult == NULL )
3987 {
3988 SWIG_PYTHON_THREAD_END_BLOCK;
3989 return TRUE;
3990 }
3991
3992 if( psResult == Py_None )
3993 {
3994 SWIG_PYTHON_THREAD_END_BLOCK;
3995 return TRUE;
3996 }
3997
3998 if( !PyArg_Parse( psResult, "i", &bContinue ) )
3999 {
4000 PyErr_Clear();
4001 CPLError(CE_Failure, CPLE_AppDefined, "bad progress return value");
4002 Py_XDECREF(psResult);
4003 SWIG_PYTHON_THREAD_END_BLOCK;
4004 return FALSE;
4005 }
4006
4007 Py_XDECREF(psResult);
4008 SWIG_PYTHON_THREAD_END_BLOCK;
4009
4010 return bContinue;
4011 }
4012
4013
4014 typedef char retStringAndCPLFree;
4015
4016
Debug(const char * msg_class,const char * message)4017 void Debug( const char *msg_class, const char *message ) {
4018 CPLDebug( msg_class, "%s", message );
4019 }
4020
4021
SetErrorHandler(CPLErrorHandler pfnErrorHandler=NULL,void * user_data=NULL)4022 CPLErr SetErrorHandler( CPLErrorHandler pfnErrorHandler = NULL, void* user_data = NULL )
4023 {
4024 if( pfnErrorHandler == NULL )
4025 {
4026 pfnErrorHandler = CPLDefaultErrorHandler;
4027 }
4028
4029 CPLSetErrorHandlerEx( pfnErrorHandler, user_data );
4030
4031 return CE_None;
4032 }
4033
4034
4035 SWIGINTERN int
SWIG_AsVal_long(PyObject * obj,long * val)4036 SWIG_AsVal_long (PyObject *obj, long* val)
4037 {
4038 #if PY_VERSION_HEX < 0x03000000
4039 if (PyInt_Check(obj)) {
4040 if (val) *val = PyInt_AsLong(obj);
4041 return SWIG_OK;
4042 } else
4043 #endif
4044 if (PyLong_Check(obj)) {
4045 long v = PyLong_AsLong(obj);
4046 if (!PyErr_Occurred()) {
4047 if (val) *val = v;
4048 return SWIG_OK;
4049 } else {
4050 PyErr_Clear();
4051 return SWIG_OverflowError;
4052 }
4053 }
4054 #ifdef SWIG_PYTHON_CAST_MODE
4055 {
4056 int dispatch = 0;
4057 long v = PyInt_AsLong(obj);
4058 if (!PyErr_Occurred()) {
4059 if (val) *val = v;
4060 return SWIG_AddCast(SWIG_OK);
4061 } else {
4062 PyErr_Clear();
4063 }
4064 if (!dispatch) {
4065 double d;
4066 int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
4067 if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
4068 if (val) *val = (long)(d);
4069 return res;
4070 }
4071 }
4072 }
4073 #endif
4074 return SWIG_TypeError;
4075 }
4076
4077
4078 SWIGINTERN int
SWIG_AsVal_int(PyObject * obj,int * val)4079 SWIG_AsVal_int (PyObject * obj, int *val)
4080 {
4081 long v;
4082 int res = SWIG_AsVal_long (obj, &v);
4083 if (SWIG_IsOK(res)) {
4084 if ((v < INT_MIN || v > INT_MAX)) {
4085 return SWIG_OverflowError;
4086 } else {
4087 if (val) *val = static_cast< int >(v);
4088 }
4089 }
4090 return res;
4091 }
4092
4093
4094 extern "C" int CPL_DLL GDALIsInGlobalDestructor();
4095
PyCPLErrorHandler(CPLErr eErrClass,int err_no,const char * pszErrorMsg)4096 void CPL_STDCALL PyCPLErrorHandler(CPLErr eErrClass, int err_no, const char* pszErrorMsg)
4097 {
4098 if( GDALIsInGlobalDestructor() )
4099 {
4100 // this is typically during Python interpreter shutdown, and ends up in a crash
4101 // because error handling tries to do thread initialization.
4102 return;
4103 }
4104
4105 void* user_data = CPLGetErrorHandlerUserData();
4106 PyObject *psArgs;
4107
4108 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
4109
4110 psArgs = Py_BuildValue("(iis)", eErrClass, err_no, pszErrorMsg );
4111 PyObject_CallObject( (PyObject*)user_data, psArgs);
4112 Py_XDECREF(psArgs);
4113
4114 SWIG_PYTHON_THREAD_END_BLOCK;
4115 }
4116
4117
PushErrorHandler(CPLErrorHandler pfnErrorHandler=NULL,void * user_data=NULL)4118 CPLErr PushErrorHandler( CPLErrorHandler pfnErrorHandler = NULL, void* user_data = NULL )
4119 {
4120 if( pfnErrorHandler == NULL )
4121 CPLPushErrorHandler(CPLQuietErrorHandler);
4122 else
4123 CPLPushErrorHandlerEx(pfnErrorHandler, user_data);
4124 return CE_None;
4125 }
4126
4127
PopErrorHandler()4128 void PopErrorHandler()
4129 {
4130 void* user_data = CPLGetErrorHandlerUserData();
4131 if( user_data != NULL )
4132 {
4133 Py_XDECREF((PyObject*)user_data);
4134 }
4135 CPLPopErrorHandler();
4136 }
4137
4138
Error(CPLErr msg_class=CE_Failure,int err_code=0,const char * msg="error")4139 void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) {
4140 CPLError( msg_class, err_code, "%s", msg );
4141 }
4142
4143
EscapeString(int len,char * bin_string,int scheme=CPLES_SQL)4144 retStringAndCPLFree* EscapeString(int len, char *bin_string , int scheme=CPLES_SQL) {
4145 return CPLEscapeString(bin_string, len, scheme);
4146 }
4147
4148
4149 SWIGINTERNINLINE PyObject *
SWIG_FromCharPtrAndSize(const char * carray,size_t size)4150 SWIG_FromCharPtrAndSize(const char* carray, size_t size)
4151 {
4152 if (carray) {
4153 if (size > INT_MAX) {
4154 swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
4155 return pchar_descriptor ?
4156 SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
4157 } else {
4158 #if PY_VERSION_HEX >= 0x03000000
4159 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
4160 return PyBytes_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
4161 #else
4162 #if PY_VERSION_HEX >= 0x03010000
4163 return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape");
4164 #else
4165 return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
4166 #endif
4167 #endif
4168 #else
4169 return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
4170 #endif
4171 }
4172 } else {
4173 return SWIG_Py_Void();
4174 }
4175 }
4176
4177
4178 SWIGINTERNINLINE PyObject *
SWIG_FromCharPtr(const char * cptr)4179 SWIG_FromCharPtr(const char *cptr)
4180 {
4181 return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
4182 }
4183
4184
wrapper_VSIReadDirEx(const char * utf8_path,int nMaxFiles=0)4185 char **wrapper_VSIReadDirEx( const char * utf8_path, int nMaxFiles = 0 )
4186 {
4187 return VSIReadDirEx(utf8_path, nMaxFiles);
4188 }
4189
4190
wrapper_VSIOpenDir(const char * utf8_path,int nRecurseDepth=-1,char ** options=NULL)4191 VSIDIR* wrapper_VSIOpenDir( const char * utf8_path,
4192 int nRecurseDepth = -1,
4193 char** options = NULL )
4194 {
4195 return VSIOpenDir(utf8_path, nRecurseDepth, options);
4196 }
4197
4198
4199 /************************************************************************/
4200 /* CSLFromPySequence() */
4201 /************************************************************************/
CSLFromPySequence(PyObject * pySeq,int * pbErr)4202 static char **CSLFromPySequence( PyObject *pySeq, int *pbErr )
4203
4204 {
4205 *pbErr = FALSE;
4206 /* Check if is a list (and reject strings, that are seen as sequence of characters) */
4207 if ( ! PySequence_Check(pySeq) || PyUnicode_Check(pySeq) ) {
4208 PyErr_SetString(PyExc_TypeError,"not a sequence");
4209 *pbErr = TRUE;
4210 return NULL;
4211 }
4212
4213 Py_ssize_t size = PySequence_Size(pySeq);
4214 if( size != (int)size ) {
4215 PyErr_SetString(PyExc_TypeError, "too big sequence");
4216 *pbErr = TRUE;
4217 return NULL;
4218 }
4219 char** papszRet = NULL;
4220 for (int i = 0; i < (int)size; i++) {
4221 PyObject* pyObj = PySequence_GetItem(pySeq,i);
4222 if (PyUnicode_Check(pyObj))
4223 {
4224 char *pszStr;
4225 Py_ssize_t nLen;
4226 PyObject* pyUTF8Str = PyUnicode_AsUTF8String(pyObj);
4227 if( !pyUTF8Str )
4228 {
4229 Py_DECREF(pyObj);
4230 PyErr_SetString(PyExc_TypeError,"invalid Unicode sequence");
4231 CSLDestroy(papszRet);
4232 *pbErr = TRUE;
4233 return NULL;
4234 }
4235 PyBytes_AsStringAndSize(pyUTF8Str, &pszStr, &nLen);
4236 papszRet = CSLAddString( papszRet, pszStr );
4237 Py_XDECREF(pyUTF8Str);
4238 }
4239 else if (PyBytes_Check(pyObj))
4240 papszRet = CSLAddString( papszRet, PyBytes_AsString(pyObj) );
4241 else
4242 {
4243 Py_DECREF(pyObj);
4244 PyErr_SetString(PyExc_TypeError,"sequence must contain strings");
4245 CSLDestroy(papszRet);
4246 *pbErr = TRUE;
4247 return NULL;
4248 }
4249 Py_DECREF(pyObj);
4250 }
4251 return papszRet;
4252 }
4253
4254
4255 typedef struct
4256 {
4257 char* name;
4258 int mode;
4259 GIntBig size;
4260 GIntBig mtime;
4261 bool modeKnown;
4262 bool sizeKnown;
4263 bool mtimeKnown;
4264 char** extra;
4265 } DirEntry;
4266
4267
4268 SWIGINTERNINLINE PyObject*
SWIG_From_bool(bool value)4269 SWIG_From_bool (bool value)
4270 {
4271 return PyBool_FromLong(value ? 1 : 0);
4272 }
4273
new_DirEntry(DirEntry const * entryIn)4274 SWIGINTERN DirEntry *new_DirEntry(DirEntry const *entryIn){
4275 DirEntry *self = (DirEntry*) CPLMalloc( sizeof( DirEntry ) );
4276 self->name = CPLStrdup(entryIn->name);
4277 self->mode = entryIn->mode;
4278 self->size = entryIn->size;
4279 self->mtime = entryIn->mtime;
4280 self->modeKnown = entryIn->modeKnown;
4281 self->sizeKnown = entryIn->sizeKnown;
4282 self->mtimeKnown = entryIn->mtimeKnown;
4283 self->extra = CSLDuplicate(entryIn->extra);
4284 return self;
4285 }
delete_DirEntry(DirEntry * self)4286 SWIGINTERN void delete_DirEntry(DirEntry *self){
4287 CPLFree(self->name);
4288 CSLDestroy(self->extra);
4289 CPLFree(self);
4290 }
DirEntry_IsDirectory(DirEntry * self)4291 SWIGINTERN bool DirEntry_IsDirectory(DirEntry *self){
4292 return (self->mode & S_IFDIR) != 0;
4293 }
4294
wrapper_VSIGetNextDirEntry(VSIDIR * dir)4295 DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
4296 {
4297 const VSIDIREntry* vsiEntry = VSIGetNextDirEntry(dir);
4298 if( vsiEntry == nullptr )
4299 {
4300 return nullptr;
4301 }
4302 DirEntry* entry = (DirEntry*) CPLMalloc( sizeof( DirEntry ) );
4303 entry->name = CPLStrdup(vsiEntry->pszName);
4304 entry->mode = vsiEntry->nMode;
4305 entry->size = vsiEntry->nSize;
4306 entry->mtime = vsiEntry->nMTime;
4307 entry->modeKnown = vsiEntry->bModeKnown == TRUE;
4308 entry->sizeKnown = vsiEntry->bSizeKnown == TRUE;
4309 entry->mtimeKnown = vsiEntry->bMTimeKnown == TRUE;
4310 entry->extra = CSLDuplicate(vsiEntry->papszExtra);
4311 return entry;
4312 }
4313
4314
wrapper_CPLGetConfigOption(const char * pszKey,const char * pszDefault=NULL)4315 const char *wrapper_CPLGetConfigOption( const char * pszKey, const char * pszDefault = NULL )
4316 {
4317 return CPLGetConfigOption( pszKey, pszDefault );
4318 }
4319
4320
wrapper_VSIFileFromMemBuffer(const char * utf8_path,GIntBig nBytes,const char * pabyData)4321 void wrapper_VSIFileFromMemBuffer( const char* utf8_path, GIntBig nBytes, const char *pabyData)
4322 {
4323 const size_t nSize = static_cast<size_t>(nBytes);
4324 void* pabyDataDup = VSIMalloc(nSize);
4325 if (pabyDataDup == NULL)
4326 return;
4327 memcpy(pabyDataDup, pabyData, nSize);
4328 VSIFCloseL(VSIFileFromMemBuffer(utf8_path, (GByte*) pabyDataDup, nSize, TRUE));
4329 }
4330
4331
wrapper_VSIUnlinkBatch(char ** files)4332 bool wrapper_VSIUnlinkBatch(char** files)
4333 {
4334 int* success = VSIUnlinkBatch(files);
4335 if( !success )
4336 return false;
4337 int bRet = true;
4338 for( int i = 0; files && files[i]; i++ )
4339 {
4340 if( !success[i] ) {
4341 bRet = false;
4342 break;
4343 }
4344 }
4345 VSIFree(success);
4346 return bRet;
4347 }
4348
4349
wrapper_HasThreadSupport()4350 int wrapper_HasThreadSupport()
4351 {
4352 return strcmp(CPLGetThreadingModel(), "stub") != 0;
4353 }
4354
4355
wrapper_VSISync(const char * pszSource,const char * pszTarget,char ** options=NULL,GDALProgressFunc callback=NULL,void * callback_data=NULL)4356 bool wrapper_VSISync(const char* pszSource,
4357 const char* pszTarget,
4358 char** options = NULL,
4359 GDALProgressFunc callback=NULL,
4360 void* callback_data=NULL)
4361 {
4362 return VSISync( pszSource, pszTarget, options, callback, callback_data, nullptr );
4363 }
4364
4365
wrapper_VSIGetSignedURL(const char * utf8_path,char ** options=NULL)4366 retStringAndCPLFree* wrapper_VSIGetSignedURL(const char * utf8_path, char** options = NULL )
4367 {
4368 return VSIGetSignedURL( utf8_path, options );
4369 }
4370
4371
4372 typedef struct
4373 {
4374 int mode;
4375 GIntBig size;
4376 GIntBig mtime;
4377 } StatBuf;
4378
new_StatBuf(StatBuf * psStatBuf)4379 SWIGINTERN StatBuf *new_StatBuf(StatBuf *psStatBuf){
4380 StatBuf *self = (StatBuf*) CPLMalloc( sizeof( StatBuf ) );
4381 self->mode = psStatBuf->mode;
4382 self->size = psStatBuf->size;
4383 self->mtime = psStatBuf->mtime;
4384 return self;
4385 }
delete_StatBuf(StatBuf * self)4386 SWIGINTERN void delete_StatBuf(StatBuf *self){
4387 CPLFree(self);
4388 }
StatBuf_IsDirectory(StatBuf * self)4389 SWIGINTERN int StatBuf_IsDirectory(StatBuf *self){
4390 return (self->mode & S_IFDIR) != 0;
4391 }
4392
wrapper_VSIStatL(const char * utf8_path,StatBuf * psStatBufOut,int nFlags=0)4393 int wrapper_VSIStatL( const char * utf8_path, StatBuf *psStatBufOut, int nFlags = 0 )
4394 {
4395 VSIStatBufL sStat;
4396 memset(&sStat, 0, sizeof(sStat));
4397 memset(psStatBufOut, 0, sizeof(StatBuf));
4398 int nRet = VSIStatExL(utf8_path, &sStat, nFlags);
4399 psStatBufOut->mode = sStat.st_mode;
4400 psStatBufOut->size = (GIntBig)sStat.st_size;
4401 psStatBufOut->mtime = (GIntBig)sStat.st_mtime;
4402 return nRet;
4403 }
4404
4405
wrapper_VSIFOpenL(const char * utf8_path,const char * pszMode)4406 VSILFILE *wrapper_VSIFOpenL( const char *utf8_path, const char *pszMode )
4407 {
4408 if (!pszMode) /* would lead to segfault */
4409 pszMode = "r";
4410 return VSIFOpenL( utf8_path, pszMode );
4411 }
4412
4413
wrapper_VSIFOpenExL(const char * utf8_path,const char * pszMode,int bSetError=FALSE,char ** options=NULL)4414 VSILFILE *wrapper_VSIFOpenExL( const char *utf8_path, const char *pszMode, int bSetError = FALSE, char** options = NULL )
4415 {
4416 if (!pszMode) /* would lead to segfault */
4417 pszMode = "r";
4418 return VSIFOpenEx2L( utf8_path, pszMode, bSetError, options );
4419 }
4420
4421
wrapper_VSIFWriteL(int nLen,char * pBuf,int size,int memb,VSILFILE * fp)4422 int wrapper_VSIFWriteL( int nLen, char *pBuf, int size, int memb, VSILFILE* fp)
4423 {
4424 if (nLen < static_cast<GIntBig>(size) * memb)
4425 {
4426 CPLError(CE_Failure, CPLE_AppDefined, "Inconsistent buffer size with 'size' and 'memb' values");
4427 return 0;
4428 }
4429 return static_cast<int>(VSIFWriteL(pBuf, size, memb, fp));
4430 }
4431
GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow * self)4432 SWIGINTERN char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){
4433 return GDALGetDescription( self );
4434 }
GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow * self,char const * pszNewDesc)4435 SWIGINTERN void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){
4436 GDALSetDescription( self, pszNewDesc );
4437 }
GDALMajorObjectShadow_GetMetadataDomainList(GDALMajorObjectShadow * self)4438 SWIGINTERN char **GDALMajorObjectShadow_GetMetadataDomainList(GDALMajorObjectShadow *self){
4439 return GDALGetMetadataDomainList( self );
4440 }
GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow * self,char const * pszDomain="")4441 SWIGINTERN char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){
4442 return GDALGetMetadata( self, pszDomain );
4443 }
GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow * self,char const * pszDomain="")4444 SWIGINTERN char **GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow *self,char const *pszDomain=""){
4445 return GDALGetMetadata( self, pszDomain );
4446 }
GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow * self,char ** papszMetadata,char const * pszDomain="")4447 SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){
4448 return GDALSetMetadata( self, papszMetadata, pszDomain );
4449 }
GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow * self,char * pszMetadataString,char const * pszDomain="")4450 SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){
4451 char *tmpList[2];
4452 tmpList[0] = pszMetadataString;
4453 tmpList[1] = 0;
4454 return GDALSetMetadata( self, tmpList, pszDomain );
4455 }
GDALMajorObjectShadow_GetMetadataItem(GDALMajorObjectShadow * self,char const * pszName,char const * pszDomain="")4456 SWIGINTERN char const *GDALMajorObjectShadow_GetMetadataItem(GDALMajorObjectShadow *self,char const *pszName,char const *pszDomain=""){
4457 return GDALGetMetadataItem( self, pszName, pszDomain);
4458 }
GDALMajorObjectShadow_SetMetadataItem(GDALMajorObjectShadow * self,char const * pszName,char const * pszValue,char const * pszDomain="")4459 SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadataItem(GDALMajorObjectShadow *self,char const *pszName,char const *pszValue,char const *pszDomain=""){
4460 return GDALSetMetadataItem( self, pszName, pszValue, pszDomain);
4461 }
GDALDriverShadow_Create(GDALDriverShadow * self,char const * utf8_path,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char ** options=0)4462 SWIGINTERN GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *utf8_path,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){
4463
4464 GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self,
4465 utf8_path,
4466 xsize,
4467 ysize,
4468 bands,
4469 eType,
4470 options );
4471 return ds;
4472 }
GDALDriverShadow_CreateMultiDimensional(GDALDriverShadow * self,char const * utf8_path,char ** root_group_options=0,char ** options=0)4473 SWIGINTERN GDALDatasetShadow *GDALDriverShadow_CreateMultiDimensional(GDALDriverShadow *self,char const *utf8_path,char **root_group_options=0,char **options=0){
4474
4475 GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreateMultiDimensional( self,
4476 utf8_path,
4477 root_group_options,
4478 options );
4479 return ds;
4480 }
GDALDriverShadow_CreateCopy(GDALDriverShadow * self,char const * utf8_path,GDALDatasetShadow * src,int strict=1,char ** options=0,GDALProgressFunc callback=NULL,void * callback_data=NULL)4481 SWIGINTERN GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *utf8_path,GDALDatasetShadow *src,int strict=1,char **options=0,GDALProgressFunc callback=NULL,void *callback_data=NULL){
4482
4483 GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy( self,
4484 utf8_path,
4485 src,
4486 strict,
4487 options,
4488 callback,
4489 callback_data );
4490 return ds;
4491 }
GDALDriverShadow_Delete(GDALDriverShadow * self,char const * utf8_path)4492 SWIGINTERN CPLErr GDALDriverShadow_Delete(GDALDriverShadow *self,char const *utf8_path){
4493 return GDALDeleteDataset( self, utf8_path );
4494 }
GDALDriverShadow_Rename(GDALDriverShadow * self,char const * newName,char const * oldName)4495 SWIGINTERN CPLErr GDALDriverShadow_Rename(GDALDriverShadow *self,char const *newName,char const *oldName){
4496 return GDALRenameDataset( self, newName, oldName );
4497 }
GDALDriverShadow_CopyFiles(GDALDriverShadow * self,char const * newName,char const * oldName)4498 SWIGINTERN CPLErr GDALDriverShadow_CopyFiles(GDALDriverShadow *self,char const *newName,char const *oldName){
4499 return GDALCopyDatasetFiles( self, newName, oldName );
4500 }
GDALDriverShadow_Register(GDALDriverShadow * self)4501 SWIGINTERN int GDALDriverShadow_Register(GDALDriverShadow *self){
4502 return GDALRegisterDriver( self );
4503 }
GDALDriverShadow_Deregister(GDALDriverShadow * self)4504 SWIGINTERN void GDALDriverShadow_Deregister(GDALDriverShadow *self){
4505 GDALDeregisterDriver( self );
4506 }
4507
GDALDriverShadow_ShortName_get(GDALDriverShadow * h)4508 char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) {
4509 return GDALGetDriverShortName( h );
4510 }
GDALDriverShadow_LongName_get(GDALDriverShadow * h)4511 char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) {
4512 return GDALGetDriverLongName( h );
4513 }
GDALDriverShadow_HelpTopic_get(GDALDriverShadow * h)4514 char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) {
4515 return GDALGetDriverHelpTopic( h );
4516 }
4517
4518
4519 SWIGINTERN int
SWIG_AsVal_short(PyObject * obj,short * val)4520 SWIG_AsVal_short (PyObject * obj, short *val)
4521 {
4522 long v;
4523 int res = SWIG_AsVal_long (obj, &v);
4524 if (SWIG_IsOK(res)) {
4525 if ((v < SHRT_MIN || v > SHRT_MAX)) {
4526 return SWIG_OverflowError;
4527 } else {
4528 if (val) *val = static_cast< short >(v);
4529 }
4530 }
4531 return res;
4532 }
4533
4534
4535 #define SWIG_From_long PyInt_FromLong
4536
4537
4538 SWIGINTERNINLINE PyObject *
SWIG_From_short(short value)4539 SWIG_From_short (short value)
4540 {
4541 return SWIG_From_long (value);
4542 }
4543
4544
4545 #define SWIG_From_double PyFloat_FromDouble
4546
new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const * info="",char const * id="")4547 SWIGINTERN GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){
4548
4549 GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) );
4550 self->dfGCPX = x;
4551 self->dfGCPY = y;
4552 self->dfGCPZ = z;
4553 self->dfGCPPixel = pixel;
4554 self->dfGCPLine = line;
4555 self->pszInfo = CPLStrdup( (info == 0) ? "" : info );
4556 self->pszId = CPLStrdup( (id==0)? "" : id );
4557 return self;
4558 }
delete_GDAL_GCP(GDAL_GCP * self)4559 SWIGINTERN void delete_GDAL_GCP(GDAL_GCP *self){
4560 if ( self->pszInfo )
4561 CPLFree( self->pszInfo );
4562 if ( self->pszId )
4563 CPLFree( self->pszId );
4564 CPLFree( self );
4565 }
4566
4567
GDAL_GCP_GCPX_get(GDAL_GCP * gcp)4568 double GDAL_GCP_GCPX_get( GDAL_GCP *gcp ) {
4569 return gcp->dfGCPX;
4570 }
GDAL_GCP_GCPX_set(GDAL_GCP * gcp,double dfGCPX)4571 void GDAL_GCP_GCPX_set( GDAL_GCP *gcp, double dfGCPX ) {
4572 gcp->dfGCPX = dfGCPX;
4573 }
GDAL_GCP_GCPY_get(GDAL_GCP * gcp)4574 double GDAL_GCP_GCPY_get( GDAL_GCP *gcp ) {
4575 return gcp->dfGCPY;
4576 }
GDAL_GCP_GCPY_set(GDAL_GCP * gcp,double dfGCPY)4577 void GDAL_GCP_GCPY_set( GDAL_GCP *gcp, double dfGCPY ) {
4578 gcp->dfGCPY = dfGCPY;
4579 }
GDAL_GCP_GCPZ_get(GDAL_GCP * gcp)4580 double GDAL_GCP_GCPZ_get( GDAL_GCP *gcp ) {
4581 return gcp->dfGCPZ;
4582 }
GDAL_GCP_GCPZ_set(GDAL_GCP * gcp,double dfGCPZ)4583 void GDAL_GCP_GCPZ_set( GDAL_GCP *gcp, double dfGCPZ ) {
4584 gcp->dfGCPZ = dfGCPZ;
4585 }
GDAL_GCP_GCPPixel_get(GDAL_GCP * gcp)4586 double GDAL_GCP_GCPPixel_get( GDAL_GCP *gcp ) {
4587 return gcp->dfGCPPixel;
4588 }
GDAL_GCP_GCPPixel_set(GDAL_GCP * gcp,double dfGCPPixel)4589 void GDAL_GCP_GCPPixel_set( GDAL_GCP *gcp, double dfGCPPixel ) {
4590 gcp->dfGCPPixel = dfGCPPixel;
4591 }
GDAL_GCP_GCPLine_get(GDAL_GCP * gcp)4592 double GDAL_GCP_GCPLine_get( GDAL_GCP *gcp ) {
4593 return gcp->dfGCPLine;
4594 }
GDAL_GCP_GCPLine_set(GDAL_GCP * gcp,double dfGCPLine)4595 void GDAL_GCP_GCPLine_set( GDAL_GCP *gcp, double dfGCPLine ) {
4596 gcp->dfGCPLine = dfGCPLine;
4597 }
GDAL_GCP_Info_get(GDAL_GCP * gcp)4598 const char * GDAL_GCP_Info_get( GDAL_GCP *gcp ) {
4599 return gcp->pszInfo;
4600 }
GDAL_GCP_Info_set(GDAL_GCP * gcp,const char * pszInfo)4601 void GDAL_GCP_Info_set( GDAL_GCP *gcp, const char * pszInfo ) {
4602 if ( gcp->pszInfo )
4603 CPLFree( gcp->pszInfo );
4604 gcp->pszInfo = CPLStrdup(pszInfo);
4605 }
GDAL_GCP_Id_get(GDAL_GCP * gcp)4606 const char * GDAL_GCP_Id_get( GDAL_GCP *gcp ) {
4607 return gcp->pszId;
4608 }
GDAL_GCP_Id_set(GDAL_GCP * gcp,const char * pszId)4609 void GDAL_GCP_Id_set( GDAL_GCP *gcp, const char * pszId ) {
4610 if ( gcp->pszId )
4611 CPLFree( gcp->pszId );
4612 gcp->pszId = CPLStrdup(pszId);
4613 }
4614
4615
4616 #define t_output_helper SWIG_Python_AppendOutput
4617
4618
4619 static PyObject *
CreateTupleFromDoubleArray(const double * first,size_t size)4620 CreateTupleFromDoubleArray( const double *first, size_t size ) {
4621 PyObject *out = PyTuple_New( size );
4622 for( unsigned int i=0; i<size; i++ ) {
4623 PyObject *val = PyFloat_FromDouble( *first );
4624 ++first;
4625 PyTuple_SetItem( out, i, val );
4626 }
4627 return out;
4628 }
4629
4630
4631 #include "gdal.h"
4632
4633 typedef struct
4634 {
4635 CPLVirtualMem *vmem;
4636 int bAuto;
4637 GDALDataType eBufType;
4638 int bIsBandSequential;
4639 int bReadOnly;
4640 int nBufXSize;
4641 int nBufYSize;
4642 int nBandCount;
4643 GDALTileOrganization eTileOrganization;
4644 int nTileXSize;
4645 int nTileYSize;
4646 int nPixelSpace; /* if bAuto == TRUE */
4647 GIntBig nLineSpace; /* if bAuto == TRUE */
4648 } CPLVirtualMemShadow;
4649
4650
delete_CPLVirtualMemShadow(CPLVirtualMemShadow * self)4651 SWIGINTERN void delete_CPLVirtualMemShadow(CPLVirtualMemShadow *self){
4652 CPLVirtualMemFree( self->vmem );
4653 free(self);
4654 }
CPLVirtualMemShadow_GetAddr(CPLVirtualMemShadow * self,void ** pptr,size_t * pnsize,GDALDataType * pdatatype,int * preadonly)4655 SWIGINTERN void CPLVirtualMemShadow_GetAddr(CPLVirtualMemShadow *self,void **pptr,size_t *pnsize,GDALDataType *pdatatype,int *preadonly){
4656 *pptr = CPLVirtualMemGetAddr( self->vmem );
4657 *pnsize = CPLVirtualMemGetSize( self->vmem );
4658 *pdatatype = self->eBufType;
4659 *preadonly = self->bReadOnly;
4660 }
4661
4662 #if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
4663 # define SWIG_LONG_LONG_AVAILABLE
4664 #endif
4665
4666
4667 #ifdef SWIG_LONG_LONG_AVAILABLE
4668 SWIGINTERN int
SWIG_AsVal_unsigned_SS_long_SS_long(PyObject * obj,unsigned long long * val)4669 SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val)
4670 {
4671 int res = SWIG_TypeError;
4672 if (PyLong_Check(obj)) {
4673 unsigned long long v = PyLong_AsUnsignedLongLong(obj);
4674 if (!PyErr_Occurred()) {
4675 if (val) *val = v;
4676 return SWIG_OK;
4677 } else {
4678 PyErr_Clear();
4679 res = SWIG_OverflowError;
4680 }
4681 } else {
4682 unsigned long v;
4683 res = SWIG_AsVal_unsigned_SS_long (obj,&v);
4684 if (SWIG_IsOK(res)) {
4685 if (val) *val = v;
4686 return res;
4687 }
4688 }
4689 #ifdef SWIG_PYTHON_CAST_MODE
4690 {
4691 const double mant_max = 1LL << DBL_MANT_DIG;
4692 double d;
4693 res = SWIG_AsVal_double (obj,&d);
4694 if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
4695 return SWIG_OverflowError;
4696 if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
4697 if (val) *val = (unsigned long long)(d);
4698 return SWIG_AddCast(res);
4699 }
4700 res = SWIG_TypeError;
4701 }
4702 #endif
4703 return res;
4704 }
4705 #endif
4706
4707
4708 SWIGINTERNINLINE int
SWIG_AsVal_size_t(PyObject * obj,size_t * val)4709 SWIG_AsVal_size_t (PyObject * obj, size_t *val)
4710 {
4711 int res = SWIG_TypeError;
4712 #ifdef SWIG_LONG_LONG_AVAILABLE
4713 if (sizeof(size_t) <= sizeof(unsigned long)) {
4714 #endif
4715 unsigned long v;
4716 res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
4717 if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
4718 #ifdef SWIG_LONG_LONG_AVAILABLE
4719 } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
4720 unsigned long long v;
4721 res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0);
4722 if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
4723 }
4724 #endif
4725 return res;
4726 }
4727
CPLVirtualMemShadow_Pin(CPLVirtualMemShadow * self,size_t start_offset=0,size_t nsize=0,int bWriteOp=0)4728 SWIGINTERN void CPLVirtualMemShadow_Pin(CPLVirtualMemShadow *self,size_t start_offset=0,size_t nsize=0,int bWriteOp=0){
4729 if( nsize == 0 || start_offset + nsize >= CPLVirtualMemGetSize( self->vmem ) )
4730 nsize = CPLVirtualMemGetSize( self->vmem ) - start_offset;
4731 char* start_addr = (char*)CPLVirtualMemGetAddr( self->vmem ) + start_offset;
4732 CPLVirtualMemPin(self->vmem, start_addr, nsize, bWriteOp);
4733 }
4734
4735 /* Returned size is in bytes or 0 if an error occurred. */
4736 static
ComputeDatasetRasterIOSize(int buf_xsize,int buf_ysize,int nPixelSize,int nBands,int * bandMap,int nBandMapArrayLength,GIntBig nPixelSpace,GIntBig nLineSpace,GIntBig nBandSpace,int bSpacingShouldBeMultipleOfPixelSize)4737 GIntBig ComputeDatasetRasterIOSize (int buf_xsize, int buf_ysize, int nPixelSize,
4738 int nBands, int* bandMap, int nBandMapArrayLength,
4739 GIntBig nPixelSpace, GIntBig nLineSpace, GIntBig nBandSpace,
4740 int bSpacingShouldBeMultipleOfPixelSize )
4741 {
4742 if (buf_xsize <= 0 || buf_ysize <= 0)
4743 {
4744 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal values for buffer size");
4745 return 0;
4746 }
4747
4748 if (nPixelSpace < 0 || nLineSpace < 0 || nBandSpace < 0)
4749 {
4750 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal values for space arguments");
4751 return 0;
4752 }
4753
4754 if (nPixelSize == 0)
4755 {
4756 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal value for data type");
4757 return 0;
4758 }
4759
4760 if( nPixelSpace == 0 )
4761 nPixelSpace = nPixelSize;
4762 else if ( bSpacingShouldBeMultipleOfPixelSize && (nPixelSpace % nPixelSize) != 0 )
4763 {
4764 CPLError(CE_Failure, CPLE_IllegalArg, "nPixelSpace should be a multiple of nPixelSize");
4765 return 0;
4766 }
4767
4768 if( nLineSpace == 0 )
4769 {
4770 nLineSpace = nPixelSpace * buf_xsize;
4771 }
4772 else if ( bSpacingShouldBeMultipleOfPixelSize && (nLineSpace % nPixelSize) != 0 )
4773 {
4774 CPLError(CE_Failure, CPLE_IllegalArg, "nLineSpace should be a multiple of nPixelSize");
4775 return 0;
4776 }
4777
4778 if( nBandSpace == 0 )
4779 {
4780 nBandSpace = nLineSpace * buf_ysize;
4781 }
4782 else if ( bSpacingShouldBeMultipleOfPixelSize && (nBandSpace % nPixelSize) != 0 )
4783 {
4784 CPLError(CE_Failure, CPLE_IllegalArg, "nLineSpace should be a multiple of nPixelSize");
4785 return 0;
4786 }
4787
4788 if (nBands <= 0 || (bandMap != NULL && nBands > nBandMapArrayLength))
4789 {
4790 CPLError(CE_Failure, CPLE_IllegalArg, "Invalid band count");
4791 return 0;
4792 }
4793
4794 GIntBig nRet = (GIntBig)(buf_ysize - 1) * nLineSpace + (GIntBig)(buf_xsize - 1) * nPixelSpace + (GIntBig)(nBands - 1) * nBandSpace + nPixelSize;
4795 #if SIZEOF_VOIDP == 4
4796 if (nRet > INT_MAX)
4797 {
4798 CPLError(CE_Failure, CPLE_IllegalArg, "Integer overflow");
4799 return 0;
4800 }
4801 #endif
4802
4803 return nRet;
4804 }
4805
4806
4807 typedef struct
4808 {
4809 GDALAsyncReaderH hAsyncReader;
4810 void *pyObject;
4811 } GDALAsyncReaderWrapper;
4812
4813 typedef void* GDALAsyncReaderWrapperH;
4814
AsyncReaderWrapperGetReader(GDALAsyncReaderWrapperH hWrapper)4815 static GDALAsyncReaderH AsyncReaderWrapperGetReader(GDALAsyncReaderWrapperH hWrapper)
4816 {
4817 GDALAsyncReaderWrapper* psWrapper = (GDALAsyncReaderWrapper*)hWrapper;
4818 if (psWrapper->hAsyncReader == NULL)
4819 {
4820 CPLError(CE_Failure, CPLE_AppDefined, "AsyncReader object is defunct");
4821 }
4822 return psWrapper->hAsyncReader;
4823 }
4824
4825 #if defined(SWIGPYTHON)
AsyncReaderWrapperGetPyObject(GDALAsyncReaderWrapperH hWrapper)4826 static void* AsyncReaderWrapperGetPyObject(GDALAsyncReaderWrapperH hWrapper)
4827 {
4828 GDALAsyncReaderWrapper* psWrapper = (GDALAsyncReaderWrapper*)hWrapper;
4829 return psWrapper->pyObject;
4830 }
4831 #endif
4832
DeleteAsyncReaderWrapper(GDALAsyncReaderWrapperH hWrapper)4833 static void DeleteAsyncReaderWrapper(GDALAsyncReaderWrapperH hWrapper)
4834 {
4835 GDALAsyncReaderWrapper* psWrapper = (GDALAsyncReaderWrapper*)hWrapper;
4836 if (psWrapper->hAsyncReader != NULL)
4837 {
4838 CPLError(CE_Failure, CPLE_AppDefined,
4839 "Native AsyncReader object will leak. EndAsyncReader() should have been called before");
4840 }
4841 CPLFree(psWrapper);
4842 }
4843
4844
4845
4846
CreateAsyncReaderWrapper(GDALAsyncReaderH hAsyncReader,void * pyObject)4847 static GDALAsyncReaderWrapper* CreateAsyncReaderWrapper(GDALAsyncReaderH hAsyncReader,
4848 void *pyObject)
4849 {
4850 GDALAsyncReaderWrapper* psWrapper = (GDALAsyncReaderWrapper* )CPLMalloc(sizeof(GDALAsyncReaderWrapper));
4851 psWrapper->hAsyncReader = hAsyncReader;
4852 psWrapper->pyObject = pyObject;
4853 Py_INCREF((PyObject*) psWrapper->pyObject);
4854 return psWrapper;
4855 }
4856
DisableAsyncReaderWrapper(GDALAsyncReaderWrapperH hWrapper)4857 static void DisableAsyncReaderWrapper(GDALAsyncReaderWrapperH hWrapper)
4858 {
4859 GDALAsyncReaderWrapper* psWrapper = (GDALAsyncReaderWrapper*)hWrapper;
4860 if (psWrapper->pyObject)
4861 {
4862 Py_XDECREF((PyObject*) psWrapper->pyObject);
4863 }
4864 psWrapper->pyObject = NULL;
4865 psWrapper->hAsyncReader = NULL;
4866 }
4867
delete_GDALAsyncReaderShadow(GDALAsyncReaderShadow * self)4868 SWIGINTERN void delete_GDALAsyncReaderShadow(GDALAsyncReaderShadow *self){
4869 DeleteAsyncReaderWrapper(self);
4870 }
GDALAsyncReaderShadow_GetNextUpdatedRegion(GDALAsyncReaderShadow * self,double timeout,int * xoff,int * yoff,int * buf_xsize,int * buf_ysize)4871 SWIGINTERN GDALAsyncStatusType GDALAsyncReaderShadow_GetNextUpdatedRegion(GDALAsyncReaderShadow *self,double timeout,int *xoff,int *yoff,int *buf_xsize,int *buf_ysize){
4872 GDALAsyncReaderH hReader = AsyncReaderWrapperGetReader(self);
4873 if (hReader == NULL)
4874 {
4875 *xoff = 0;
4876 *yoff = 0;
4877 *buf_xsize = 0;
4878 *buf_ysize = 0;
4879 return GARIO_ERROR;
4880 }
4881 return GDALARGetNextUpdatedRegion(hReader, timeout, xoff, yoff, buf_xsize, buf_ysize );
4882 }
GDALAsyncReaderShadow_GetBuffer(GDALAsyncReaderShadow * self,void ** ppRetPyObject)4883 SWIGINTERN void GDALAsyncReaderShadow_GetBuffer(GDALAsyncReaderShadow *self,void **ppRetPyObject){
4884 GDALAsyncReaderH hReader = AsyncReaderWrapperGetReader(self);
4885 if (hReader == NULL)
4886 {
4887 *ppRetPyObject = NULL;
4888 return;
4889 }
4890 *ppRetPyObject = AsyncReaderWrapperGetPyObject(self);
4891 Py_INCREF((PyObject*)*ppRetPyObject);
4892 }
GDALAsyncReaderShadow_LockBuffer(GDALAsyncReaderShadow * self,double timeout)4893 SWIGINTERN int GDALAsyncReaderShadow_LockBuffer(GDALAsyncReaderShadow *self,double timeout){
4894 GDALAsyncReaderH hReader = AsyncReaderWrapperGetReader(self);
4895 if (hReader == NULL)
4896 {
4897 return 0;
4898 }
4899 return GDALARLockBuffer(hReader,timeout);
4900 }
GDALAsyncReaderShadow_UnlockBuffer(GDALAsyncReaderShadow * self)4901 SWIGINTERN void GDALAsyncReaderShadow_UnlockBuffer(GDALAsyncReaderShadow *self){
4902 GDALAsyncReaderH hReader = AsyncReaderWrapperGetReader(self);
4903 if (hReader == NULL)
4904 {
4905 return;
4906 }
4907 GDALARUnlockBuffer(hReader);
4908 }
delete_GDALDatasetShadow(GDALDatasetShadow * self)4909 SWIGINTERN void delete_GDALDatasetShadow(GDALDatasetShadow *self){
4910 if ( GDALDereferenceDataset( self ) <= 0 ) {
4911 GDALClose(self);
4912 }
4913 }
GDALDatasetShadow_GetDriver(GDALDatasetShadow * self)4914 SWIGINTERN GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){
4915 return (GDALDriverShadow*) GDALGetDatasetDriver( self );
4916 }
GDALDatasetShadow_GetRasterBand(GDALDatasetShadow * self,int nBand)4917 SWIGINTERN GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){
4918 return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand );
4919 }
GDALDatasetShadow_GetRootGroup(GDALDatasetShadow * self)4920 SWIGINTERN GDALGroupHS *GDALDatasetShadow_GetRootGroup(GDALDatasetShadow *self){
4921 return GDALDatasetGetRootGroup(self);
4922 }
GDALDatasetShadow_GetProjection(GDALDatasetShadow * self)4923 SWIGINTERN char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){
4924 return GDALGetProjectionRef( self );
4925 }
GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow * self)4926 SWIGINTERN char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){
4927 return GDALGetProjectionRef( self );
4928 }
GDALDatasetShadow_GetSpatialRef(GDALDatasetShadow * self)4929 SWIGINTERN OSRSpatialReferenceShadow *GDALDatasetShadow_GetSpatialRef(GDALDatasetShadow *self){
4930 OGRSpatialReferenceH ref = GDALGetSpatialRef(self);
4931 if( ref )
4932 ref = OSRClone( ref );
4933 return (OSRSpatialReferenceShadow*) ref;
4934 }
GDALDatasetShadow_SetProjection(GDALDatasetShadow * self,char const * prj)4935 SWIGINTERN CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){
4936 return GDALSetProjection( self, prj );
4937 }
GDALDatasetShadow_SetSpatialRef(GDALDatasetShadow * self,OSRSpatialReferenceShadow * srs)4938 SWIGINTERN CPLErr GDALDatasetShadow_SetSpatialRef(GDALDatasetShadow *self,OSRSpatialReferenceShadow *srs){
4939 return GDALSetSpatialRef( self, (OGRSpatialReferenceH)srs );
4940 }
GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow * self,double argout[6],int * isvalid,int * can_return_null=0)4941 SWIGINTERN void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6],int *isvalid,int *can_return_null=0){
4942 if (can_return_null && *can_return_null)
4943 {
4944 *isvalid = (GDALGetGeoTransform( self, argout ) == CE_None );
4945 }
4946 else
4947 {
4948 *isvalid = TRUE;
4949 if ( GDALGetGeoTransform( self, argout ) != CE_None ) {
4950 argout[0] = 0.0;
4951 argout[1] = 1.0;
4952 argout[2] = 0.0;
4953 argout[3] = 0.0;
4954 argout[4] = 0.0;
4955 argout[5] = 1.0;
4956 }
4957 }
4958 }
GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow * self,double argin[6])4959 SWIGINTERN CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){
4960 return GDALSetGeoTransform( self, argin );
4961 }
4962
4963 static int*
CreateCIntListFromSequence(PyObject * pySeq,int * pnSize)4964 CreateCIntListFromSequence( PyObject* pySeq, int* pnSize ) {
4965 /* check if is List */
4966 if ( !PySequence_Check(pySeq) ) {
4967 PyErr_SetString(PyExc_TypeError, "not a sequence");
4968 *pnSize = -1;
4969 return NULL;
4970 }
4971 Py_ssize_t size = PySequence_Size(pySeq);
4972 if( size != (int)size ) {
4973 PyErr_SetString(PyExc_TypeError, "too big sequence");
4974 *pnSize = -1;
4975 return NULL;
4976 }
4977 *pnSize = (int)size;
4978 int* ret = (int*) malloc(*pnSize*sizeof(int));
4979 for( int i = 0; i<*pnSize; i++ ) {
4980 PyObject *o = PySequence_GetItem(pySeq,i);
4981 if ( !PyArg_Parse(o,"i",&ret[i]) ) {
4982 PyErr_SetString(PyExc_TypeError, "not an integer");
4983 Py_DECREF(o);
4984 free(ret);
4985 *pnSize = -1;
4986 return NULL;
4987 }
4988 Py_DECREF(o);
4989 }
4990 return ret;
4991 }
4992
GDALDatasetShadow_BuildOverviews(GDALDatasetShadow * self,char const * resampling="NEAREST",int overviewlist=0,int * pOverviews=0,GDALProgressFunc callback=NULL,void * callback_data=NULL)4993 SWIGINTERN int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0,GDALProgressFunc callback=NULL,void *callback_data=NULL){
4994
4995 return GDALBuildOverviews( self,
4996 resampling ? resampling : "NEAREST",
4997 overviewlist,
4998 pOverviews,
4999 0,
5000 0,
5001 callback,
5002 callback_data);
5003 }
GDALDatasetShadow_GetGCPCount(GDALDatasetShadow * self)5004 SWIGINTERN int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){
5005 return GDALGetGCPCount( self );
5006 }
GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow * self)5007 SWIGINTERN char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){
5008 return GDALGetGCPProjection( self );
5009 }
GDALDatasetShadow_GetGCPSpatialRef(GDALDatasetShadow * self)5010 SWIGINTERN OSRSpatialReferenceShadow *GDALDatasetShadow_GetGCPSpatialRef(GDALDatasetShadow *self){
5011 OGRSpatialReferenceH ref = GDALGetGCPSpatialRef(self);
5012 if( ref )
5013 ref = OSRClone( ref );
5014 return (OSRSpatialReferenceShadow*) ref;
5015 }
GDALDatasetShadow_GetGCPs(GDALDatasetShadow * self,int * nGCPs,GDAL_GCP const ** pGCPs)5016 SWIGINTERN void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){
5017 *nGCPs = GDALGetGCPCount( self );
5018 *pGCPs = GDALGetGCPs( self );
5019 }
GDALDatasetShadow_SetGCPs(GDALDatasetShadow * self,int nGCPs,GDAL_GCP const * pGCPs,char const * pszGCPProjection)5020 SWIGINTERN CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){
5021 return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection );
5022 }
GDALDatasetShadow_SetGCPs2(GDALDatasetShadow * self,int nGCPs,GDAL_GCP const * pGCPs,OSRSpatialReferenceShadow * hSRS)5023 SWIGINTERN CPLErr GDALDatasetShadow_SetGCPs2(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,OSRSpatialReferenceShadow *hSRS){
5024 return GDALSetGCPs2( self, nGCPs, pGCPs, (OGRSpatialReferenceH)hSRS );
5025 }
GDALDatasetShadow_FlushCache(GDALDatasetShadow * self)5026 SWIGINTERN void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){
5027 GDALFlushCache( self );
5028 }
GDALDatasetShadow_AddBand(GDALDatasetShadow * self,GDALDataType datatype=GDT_Byte,char ** options=0)5029 SWIGINTERN CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){
5030 return GDALAddBand( self, datatype, options );
5031 }
GDALDatasetShadow_CreateMaskBand(GDALDatasetShadow * self,int nFlags)5032 SWIGINTERN CPLErr GDALDatasetShadow_CreateMaskBand(GDALDatasetShadow *self,int nFlags){
5033 return GDALCreateDatasetMaskBand( self, nFlags );
5034 }
GDALDatasetShadow_GetFileList(GDALDatasetShadow * self)5035 SWIGINTERN char **GDALDatasetShadow_GetFileList(GDALDatasetShadow *self){
5036 return GDALGetFileList( self );
5037 }
GDALDatasetShadow_WriteRaster(GDALDatasetShadow * self,int xoff,int yoff,int xsize,int ysize,GIntBig buf_len,char * buf_string,int * buf_xsize=0,int * buf_ysize=0,GDALDataType * buf_type=0,int band_list=0,int * pband_list=0,GIntBig * buf_pixel_space=0,GIntBig * buf_line_space=0,GIntBig * buf_band_space=0)5038 SWIGINTERN CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,GIntBig buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0,GIntBig *buf_pixel_space=0,GIntBig *buf_line_space=0,GIntBig *buf_band_space=0){
5039 CPLErr eErr;
5040 int nxsize = (buf_xsize==0) ? xsize : *buf_xsize;
5041 int nysize = (buf_ysize==0) ? ysize : *buf_ysize;
5042 GDALDataType ntype;
5043 if ( buf_type != 0 ) {
5044 ntype = (GDALDataType) *buf_type;
5045 } else {
5046 int lastband = GDALGetRasterCount( self );
5047 if (lastband <= 0)
5048 return CE_Failure;
5049 ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) );
5050 }
5051
5052 GIntBig pixel_space = (buf_pixel_space == 0) ? 0 : *buf_pixel_space;
5053 GIntBig line_space = (buf_line_space == 0) ? 0 : *buf_line_space;
5054 GIntBig band_space = (buf_band_space == 0) ? 0 : *buf_band_space;
5055
5056 GIntBig min_buffer_size =
5057 ComputeDatasetRasterIOSize (nxsize, nysize, GDALGetDataTypeSize( ntype ) / 8,
5058 band_list ? band_list : GDALGetRasterCount(self), pband_list, band_list,
5059 pixel_space, line_space, band_space, FALSE);
5060 if (min_buffer_size == 0)
5061 return CE_Failure;
5062
5063 if ( buf_len < min_buffer_size )
5064 {
5065 CPLError(CE_Failure, CPLE_AppDefined, "Buffer too small");
5066 return CE_Failure;
5067 }
5068
5069 GDALRasterIOExtraArg* psExtraArg = NULL;
5070
5071 eErr = GDALDatasetRasterIOEx( self, GF_Write, xoff, yoff, xsize, ysize,
5072 (void*) buf_string, nxsize, nysize, ntype,
5073 band_list, pband_list, pixel_space, line_space, band_space, psExtraArg );
5074
5075 return eErr;
5076 }
GDALDatasetShadow_AdviseRead(GDALDatasetShadow * self,int xoff,int yoff,int xsize,int ysize,int * buf_xsize=0,int * buf_ysize=0,GDALDataType * buf_type=0,int band_list=0,int * pband_list=0,char ** options=NULL)5077 SWIGINTERN CPLErr GDALDatasetShadow_AdviseRead(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0,char **options=NULL){
5078 int nxsize = (buf_xsize==0) ? xsize : *buf_xsize;
5079 int nysize = (buf_ysize==0) ? ysize : *buf_ysize;
5080 GDALDataType ntype;
5081 if ( buf_type != 0 ) {
5082 ntype = (GDALDataType) *buf_type;
5083 } else {
5084 int lastband = GDALGetRasterCount( self );
5085 if (lastband <= 0)
5086 return CE_Failure;
5087 ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) );
5088 }
5089 return GDALDatasetAdviseRead(self, xoff, yoff, xsize, ysize,
5090 nxsize, nysize, ntype,
5091 band_list, pband_list, options);
5092 }
GDALDatasetShadow_BeginAsyncReader(GDALDatasetShadow * self,int xOff,int yOff,int xSize,int ySize,int buf_len,char * buf_string,void * pyObject,int buf_xsize,int buf_ysize,GDALDataType bufType=(GDALDataType)0,int band_list=0,int * pband_list=0,int nPixelSpace=0,int nLineSpace=0,int nBandSpace=0,char ** options=0)5093 SWIGINTERN GDALAsyncReaderShadow *GDALDatasetShadow_BeginAsyncReader(GDALDatasetShadow *self,int xOff,int yOff,int xSize,int ySize,int buf_len,char *buf_string,void *pyObject,int buf_xsize,int buf_ysize,GDALDataType bufType=(GDALDataType) 0,int band_list=0,int *pband_list=0,int nPixelSpace=0,int nLineSpace=0,int nBandSpace=0,char **options=0){
5094
5095 if ((options != NULL) && (buf_xsize ==0) && (buf_ysize == 0))
5096 {
5097 // calculate an appropriate buffer size
5098 const char* pszLevel = CSLFetchNameValue(options, "LEVEL");
5099 if (pszLevel)
5100 {
5101 // round up
5102 int nLevel = atoi(pszLevel);
5103 if( nLevel < 0 || nLevel > 30 )
5104 {
5105 CPLError(CE_Failure, CPLE_AppDefined, "Invalid LEVEL: %d", nLevel);
5106 }
5107 else
5108 {
5109 int nRes = 1 << nLevel;
5110 buf_xsize = static_cast<int>(ceil(xSize / (1.0 * nRes)));
5111 buf_ysize = static_cast<int>(ceil(ySize / (1.0 * nRes)));
5112 }
5113 }
5114 }
5115
5116 int nxsize = (buf_xsize == 0) ? xSize : buf_xsize;
5117 int nysize = (buf_ysize == 0) ? ySize : buf_ysize;
5118
5119 GDALDataType ntype;
5120 if (bufType != 0) {
5121 ntype = (GDALDataType) bufType;
5122 }
5123 else {
5124 ntype = GDT_Byte;
5125 }
5126
5127 int nBCount = (band_list) != 0 ? band_list : GDALGetRasterCount(self);
5128 int nMinSize = nxsize * nysize * nBCount * (GDALGetDataTypeSize(ntype) / 8);
5129 if (buf_string == NULL || buf_len < nMinSize)
5130 {
5131 CPLError(CE_Failure, CPLE_AppDefined, "Buffer is too small");
5132 return NULL;
5133 }
5134
5135 bool myBandList = false;
5136 int* pBandList;
5137
5138 if (band_list != 0){
5139 myBandList = false;
5140 pBandList = pband_list;
5141 }
5142 else
5143 {
5144 myBandList = true;
5145 pBandList = (int*)CPLMalloc(sizeof(int) * nBCount);
5146 for (int i = 0; i < nBCount; ++i) {
5147 pBandList[i] = i + 1;
5148 }
5149 }
5150
5151 GDALAsyncReaderH hAsyncReader =
5152 GDALBeginAsyncReader(self, xOff, yOff, xSize, ySize, (void*) buf_string, nxsize, nysize, ntype, nBCount, pBandList, nPixelSpace, nLineSpace,
5153 nBandSpace, options);
5154
5155 if ( myBandList ) {
5156 CPLFree( pBandList );
5157 }
5158
5159 if (hAsyncReader)
5160 {
5161 return (GDALAsyncReaderShadow*) CreateAsyncReaderWrapper(hAsyncReader, pyObject);
5162 }
5163 else
5164 {
5165 return NULL;
5166 }
5167
5168 }
GDALDatasetShadow_EndAsyncReader(GDALDatasetShadow * self,GDALAsyncReaderShadow * ario)5169 SWIGINTERN void GDALDatasetShadow_EndAsyncReader(GDALDatasetShadow *self,GDALAsyncReaderShadow *ario){
5170 if( ario == NULL ) return;
5171 GDALAsyncReaderH hReader = AsyncReaderWrapperGetReader(ario);
5172 if (hReader == NULL)
5173 {
5174 return;
5175 }
5176 GDALEndAsyncReader(self, hReader);
5177 DisableAsyncReaderWrapper(ario);
5178 }
GDALDatasetShadow_GetVirtualMem(GDALDatasetShadow * self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,int band_list,int * pband_list,int bIsBandSequential,size_t nCacheSize,size_t nPageSizeHint,char ** options=NULL)5179 SWIGINTERN CPLVirtualMemShadow *GDALDatasetShadow_GetVirtualMem(GDALDatasetShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,int band_list,int *pband_list,int bIsBandSequential,size_t nCacheSize,size_t nPageSizeHint,char **options=NULL){
5180 int nPixelSpace;
5181 int nBandSpace;
5182 if( bIsBandSequential != 0 && bIsBandSequential != 1 )
5183 return NULL;
5184 if( band_list == 0 )
5185 return NULL;
5186 if( bIsBandSequential || band_list == 1 )
5187 {
5188 nPixelSpace = 0;
5189 nBandSpace = 0;
5190 }
5191 else
5192 {
5193 nBandSpace = GDALGetDataTypeSize(eBufType) / 8;
5194 nPixelSpace = nBandSpace * band_list;
5195 }
5196 CPLVirtualMem* vmem = GDALDatasetGetVirtualMem( self,
5197 eRWFlag,
5198 nXOff, nYOff,
5199 nXSize, nYSize,
5200 nBufXSize, nBufYSize,
5201 eBufType,
5202 band_list, pband_list,
5203 nPixelSpace,
5204 0,
5205 nBandSpace,
5206 nCacheSize,
5207 nPageSizeHint,
5208 FALSE,
5209 options );
5210 if( vmem == NULL )
5211 return NULL;
5212 CPLVirtualMemShadow* vmemshadow = (CPLVirtualMemShadow*)calloc(1, sizeof(CPLVirtualMemShadow));
5213 vmemshadow->vmem = vmem;
5214 vmemshadow->eBufType = eBufType;
5215 vmemshadow->bIsBandSequential = bIsBandSequential;
5216 vmemshadow->bReadOnly = (eRWFlag == GF_Read);
5217 vmemshadow->nBufXSize = nBufXSize;
5218 vmemshadow->nBufYSize = nBufYSize;
5219 vmemshadow->nBandCount = band_list;
5220 return vmemshadow;
5221 }
GDALDatasetShadow_GetTiledVirtualMem(GDALDatasetShadow * self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,int band_list,int * pband_list,GDALTileOrganization eTileOrganization,size_t nCacheSize,char ** options=NULL)5222 SWIGINTERN CPLVirtualMemShadow *GDALDatasetShadow_GetTiledVirtualMem(GDALDatasetShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,int band_list,int *pband_list,GDALTileOrganization eTileOrganization,size_t nCacheSize,char **options=NULL){
5223 if( band_list == 0 )
5224 return NULL;
5225 CPLVirtualMem* vmem = GDALDatasetGetTiledVirtualMem( self,
5226 eRWFlag,
5227 nXOff, nYOff,
5228 nXSize, nYSize,
5229 nTileXSize, nTileYSize,
5230 eBufType,
5231 band_list, pband_list,
5232 eTileOrganization,
5233 nCacheSize,
5234 FALSE,
5235 options );
5236 if( vmem == NULL )
5237 return NULL;
5238 CPLVirtualMemShadow* vmemshadow = (CPLVirtualMemShadow*)calloc(1, sizeof(CPLVirtualMemShadow));
5239 vmemshadow->vmem = vmem;
5240 vmemshadow->eBufType = eBufType;
5241 vmemshadow->bIsBandSequential = -1;
5242 vmemshadow->bReadOnly = (eRWFlag == GF_Read);
5243 vmemshadow->nBufXSize = nXSize;
5244 vmemshadow->nBufYSize = nYSize;
5245 vmemshadow->eTileOrganization = eTileOrganization;
5246 vmemshadow->nTileXSize = nTileXSize;
5247 vmemshadow->nTileYSize = nTileYSize;
5248 vmemshadow->nBandCount = band_list;
5249 return vmemshadow;
5250 }
GDALDatasetShadow_CreateLayer(GDALDatasetShadow * self,char const * name,OSRSpatialReferenceShadow * srs=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char ** options=0)5251 SWIGINTERN OGRLayerShadow *GDALDatasetShadow_CreateLayer(GDALDatasetShadow *self,char const *name,OSRSpatialReferenceShadow *srs=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){
5252 OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetCreateLayer( self,
5253 name,
5254 srs,
5255 geom_type,
5256 options);
5257 return layer;
5258 }
GDALDatasetShadow_CopyLayer(GDALDatasetShadow * self,OGRLayerShadow * src_layer,char const * new_name,char ** options=0)5259 SWIGINTERN OGRLayerShadow *GDALDatasetShadow_CopyLayer(GDALDatasetShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){
5260 OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetCopyLayer( self,
5261 src_layer,
5262 new_name,
5263 options);
5264 return layer;
5265 }
GDALDatasetShadow_DeleteLayer(GDALDatasetShadow * self,int index)5266 SWIGINTERN OGRErr GDALDatasetShadow_DeleteLayer(GDALDatasetShadow *self,int index){
5267 return GDALDatasetDeleteLayer(self, index);
5268 }
5269
5270
5271 #include "ogr_core.h"
5272 static char const *
OGRErrMessages(int rc)5273 OGRErrMessages( int rc ) {
5274 switch( rc ) {
5275 case OGRERR_NONE:
5276 return "OGR Error: None";
5277 case OGRERR_NOT_ENOUGH_DATA:
5278 return "OGR Error: Not enough data to deserialize";
5279 case OGRERR_NOT_ENOUGH_MEMORY:
5280 return "OGR Error: Not enough memory";
5281 case OGRERR_UNSUPPORTED_GEOMETRY_TYPE:
5282 return "OGR Error: Unsupported geometry type";
5283 case OGRERR_UNSUPPORTED_OPERATION:
5284 return "OGR Error: Unsupported operation";
5285 case OGRERR_CORRUPT_DATA:
5286 return "OGR Error: Corrupt data";
5287 case OGRERR_FAILURE:
5288 return "OGR Error: General Error";
5289 case OGRERR_UNSUPPORTED_SRS:
5290 return "OGR Error: Unsupported SRS";
5291 case OGRERR_INVALID_HANDLE:
5292 return "OGR Error: Invalid handle";
5293 case OGRERR_NON_EXISTING_FEATURE:
5294 return "OGR Error: Non existing feature";
5295 default:
5296 return "OGR Error: Unknown";
5297 }
5298 }
5299
GDALDatasetShadow_GetLayerCount(GDALDatasetShadow * self)5300 SWIGINTERN int GDALDatasetShadow_GetLayerCount(GDALDatasetShadow *self){
5301 return GDALDatasetGetLayerCount(self);
5302 }
GDALDatasetShadow_GetLayerByIndex(GDALDatasetShadow * self,int index=0)5303 SWIGINTERN OGRLayerShadow *GDALDatasetShadow_GetLayerByIndex(GDALDatasetShadow *self,int index=0){
5304
5305 OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetGetLayer(self, index);
5306 return layer;
5307 }
GDALDatasetShadow_GetLayerByName(GDALDatasetShadow * self,char const * layer_name)5308 SWIGINTERN OGRLayerShadow *GDALDatasetShadow_GetLayerByName(GDALDatasetShadow *self,char const *layer_name){
5309 OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetGetLayerByName(self, layer_name);
5310 return layer;
5311 }
GDALDatasetShadow_ResetReading(GDALDatasetShadow * self)5312 SWIGINTERN void GDALDatasetShadow_ResetReading(GDALDatasetShadow *self){
5313 GDALDatasetResetReading( self );
5314 }
5315
5316 SWIGINTERN int
SWIG_AsVal_bool(PyObject * obj,bool * val)5317 SWIG_AsVal_bool (PyObject *obj, bool *val)
5318 {
5319 int r;
5320 if (!PyBool_Check(obj))
5321 return SWIG_ERROR;
5322 r = PyObject_IsTrue(obj);
5323 if (r == -1)
5324 return SWIG_ERROR;
5325 if (val) *val = r ? true : false;
5326 return SWIG_OK;
5327 }
5328
GDALDatasetShadow_GetNextFeature(GDALDatasetShadow * self,bool include_layer=true,bool include_pct=false,OGRLayerShadow ** ppoBelongingLayer=NULL,double * pdfProgressPct=NULL,GDALProgressFunc callback=NULL,void * callback_data=NULL)5329 SWIGINTERN OGRFeatureShadow *GDALDatasetShadow_GetNextFeature(GDALDatasetShadow *self,bool include_layer=true,bool include_pct=false,OGRLayerShadow **ppoBelongingLayer=NULL,double *pdfProgressPct=NULL,GDALProgressFunc callback=NULL,void *callback_data=NULL){
5330 return GDALDatasetGetNextFeature( self, ppoBelongingLayer, pdfProgressPct,
5331 callback, callback_data );
5332 }
GDALDatasetShadow_TestCapability(GDALDatasetShadow * self,char const * cap)5333 SWIGINTERN bool GDALDatasetShadow_TestCapability(GDALDatasetShadow *self,char const *cap){
5334 return (GDALDatasetTestCapability(self, cap) > 0);
5335 }
GDALDatasetShadow_ExecuteSQL(GDALDatasetShadow * self,char const * statement,OGRGeometryShadow * spatialFilter=NULL,char const * dialect="")5336 SWIGINTERN OGRLayerShadow *GDALDatasetShadow_ExecuteSQL(GDALDatasetShadow *self,char const *statement,OGRGeometryShadow *spatialFilter=NULL,char const *dialect=""){
5337 OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetExecuteSQL(self,
5338 statement,
5339 spatialFilter,
5340 dialect);
5341 return layer;
5342 }
GDALDatasetShadow_ReleaseResultSet(GDALDatasetShadow * self,OGRLayerShadow * layer)5343 SWIGINTERN void GDALDatasetShadow_ReleaseResultSet(GDALDatasetShadow *self,OGRLayerShadow *layer){
5344 GDALDatasetReleaseResultSet(self, layer);
5345 }
GDALDatasetShadow_GetStyleTable(GDALDatasetShadow * self)5346 SWIGINTERN OGRStyleTableShadow *GDALDatasetShadow_GetStyleTable(GDALDatasetShadow *self){
5347 return (OGRStyleTableShadow*) GDALDatasetGetStyleTable(self);
5348 }
GDALDatasetShadow_SetStyleTable(GDALDatasetShadow * self,OGRStyleTableShadow * table)5349 SWIGINTERN void GDALDatasetShadow_SetStyleTable(GDALDatasetShadow *self,OGRStyleTableShadow *table){
5350 if( table != NULL )
5351 GDALDatasetSetStyleTable(self, (OGRStyleTableH) table);
5352 }
GDALDatasetShadow_AbortSQL(GDALDatasetShadow * self)5353 SWIGINTERN OGRErr GDALDatasetShadow_AbortSQL(GDALDatasetShadow *self){
5354 return GDALDatasetAbortSQL(self);
5355 }
GDALDatasetShadow_StartTransaction(GDALDatasetShadow * self,int force=FALSE)5356 SWIGINTERN OGRErr GDALDatasetShadow_StartTransaction(GDALDatasetShadow *self,int force=FALSE){
5357 return GDALDatasetStartTransaction(self, force);
5358 }
GDALDatasetShadow_CommitTransaction(GDALDatasetShadow * self)5359 SWIGINTERN OGRErr GDALDatasetShadow_CommitTransaction(GDALDatasetShadow *self){
5360 return GDALDatasetCommitTransaction(self);
5361 }
GDALDatasetShadow_RollbackTransaction(GDALDatasetShadow * self)5362 SWIGINTERN OGRErr GDALDatasetShadow_RollbackTransaction(GDALDatasetShadow *self){
5363 return GDALDatasetRollbackTransaction(self);
5364 }
GDALDatasetShadow_ClearStatistics(GDALDatasetShadow * self)5365 SWIGINTERN void GDALDatasetShadow_ClearStatistics(GDALDatasetShadow *self){
5366 GDALDatasetClearStatistics(self);
5367 }
GDALDatasetShadow_GetFieldDomain(GDALDatasetShadow * self,char const * name)5368 SWIGINTERN OGRFieldDomainShadow *GDALDatasetShadow_GetFieldDomain(GDALDatasetShadow *self,char const *name){
5369 return (OGRFieldDomainShadow*) GDALDatasetGetFieldDomain(self, name);
5370 }
GDALDatasetShadow_AddFieldDomain(GDALDatasetShadow * self,OGRFieldDomainShadow * fieldDomain)5371 SWIGINTERN bool GDALDatasetShadow_AddFieldDomain(GDALDatasetShadow *self,OGRFieldDomainShadow *fieldDomain){
5372 return GDALDatasetAddFieldDomain(self, (OGRFieldDomainH)fieldDomain, NULL);
5373 }
GDALDatasetShadow_ReadRaster1(GDALDatasetShadow * self,double xoff,double yoff,double xsize,double ysize,void ** buf,int * buf_xsize=0,int * buf_ysize=0,GDALDataType * buf_type=0,int band_list=0,int * pband_list=0,GIntBig * buf_pixel_space=0,GIntBig * buf_line_space=0,GIntBig * buf_band_space=0,GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour,GDALProgressFunc callback=NULL,void * callback_data=NULL,void * inputOutputBuf=NULL)5374 SWIGINTERN CPLErr GDALDatasetShadow_ReadRaster1(GDALDatasetShadow *self,double xoff,double yoff,double xsize,double ysize,void **buf,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0,GIntBig *buf_pixel_space=0,GIntBig *buf_line_space=0,GIntBig *buf_band_space=0,GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour,GDALProgressFunc callback=NULL,void *callback_data=NULL,void *inputOutputBuf=NULL){
5375 *buf = NULL;
5376
5377 int nxsize = (buf_xsize==0) ? xsize : *buf_xsize;
5378 int nysize = (buf_ysize==0) ? ysize : *buf_ysize;
5379 GDALDataType ntype;
5380 if ( buf_type != 0 ) {
5381 ntype = *buf_type;
5382 } else {
5383 int lastband = GDALGetRasterCount( self ) - 1;
5384 if (lastband < 0)
5385 {
5386 return CE_Failure;
5387 }
5388 ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) );
5389 }
5390
5391 GIntBig pixel_space = (buf_pixel_space == 0) ? 0 : *buf_pixel_space;
5392 GIntBig line_space = (buf_line_space == 0) ? 0 : *buf_line_space;
5393 GIntBig band_space = (buf_band_space == 0) ? 0 : *buf_band_space;
5394
5395 int ntypesize = GDALGetDataTypeSize( ntype ) / 8;
5396 size_t buf_size = static_cast<size_t>(
5397 ComputeDatasetRasterIOSize (nxsize, nysize, ntypesize,
5398 band_list ? band_list :
5399 GDALGetRasterCount(self),
5400 pband_list, band_list,
5401 pixel_space, line_space, band_space,
5402 FALSE));
5403 if (buf_size == 0)
5404 {
5405 return CE_Failure;
5406 }
5407
5408 char *data;
5409 Py_buffer view;
5410
5411 if( !readraster_acquirebuffer(buf, inputOutputBuf, buf_size, ntype,
5412 bUseExceptions, data, view) )
5413 {
5414 return CE_Failure;
5415 }
5416
5417 if( inputOutputBuf == NULL )
5418 {
5419 /* Should we clear the buffer in case there are hole in it ? */
5420 if( line_space != 0 && pixel_space != 0 && line_space > pixel_space * nxsize )
5421 {
5422 memset(data, 0, buf_size);
5423 }
5424 else if( band_list > 1 && band_space != 0 )
5425 {
5426 if( line_space != 0 && band_space > line_space * nysize )
5427 memset(data, 0, buf_size);
5428 else if( pixel_space != 0 && band_space < pixel_space &&
5429 pixel_space != GDALGetRasterCount(self) * ntypesize )
5430 memset(data, 0, buf_size);
5431 }
5432 }
5433
5434 GDALRasterIOExtraArg sExtraArg;
5435 INIT_RASTERIO_EXTRA_ARG(sExtraArg);
5436 sExtraArg.eResampleAlg = resample_alg;
5437 sExtraArg.pfnProgress = callback;
5438 sExtraArg.pProgressData = callback_data;
5439
5440 int nXOff = (int)(xoff + 0.5);
5441 int nYOff = (int)(yoff + 0.5);
5442 int nXSize = (int)(xsize + 0.5);
5443 int nYSize = (int)(ysize + 0.5);
5444 if( fabs(xoff-nXOff) > 1e-8 || fabs(yoff-nYOff) > 1e-8 ||
5445 fabs(xsize-nXSize) > 1e-8 || fabs(ysize-nYSize) > 1e-8 )
5446 {
5447 sExtraArg.bFloatingPointWindowValidity = TRUE;
5448 sExtraArg.dfXOff = xoff;
5449 sExtraArg.dfYOff = yoff;
5450 sExtraArg.dfXSize = xsize;
5451 sExtraArg.dfYSize = ysize;
5452 }
5453
5454 CPLErr eErr = GDALDatasetRasterIOEx(self, GF_Read, nXOff, nYOff, nXSize, nYSize,
5455 data, nxsize, nysize, ntype,
5456 band_list, pband_list, pixel_space, line_space, band_space,
5457 &sExtraArg );
5458
5459 readraster_releasebuffer(eErr, buf, inputOutputBuf, view);
5460
5461 return eErr;
5462 }
5463
GDALDatasetShadow_RasterXSize_get(GDALDatasetShadow * h)5464 int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) {
5465 return GDALGetRasterXSize( h );
5466 }
GDALDatasetShadow_RasterYSize_get(GDALDatasetShadow * h)5467 int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) {
5468 return GDALGetRasterYSize( h );
5469 }
GDALDatasetShadow_RasterCount_get(GDALDatasetShadow * h)5470 int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) {
5471 return GDALGetRasterCount( h );
5472 }
5473
delete_GDALGroupHS(GDALGroupHS * self)5474 SWIGINTERN void delete_GDALGroupHS(GDALGroupHS *self){
5475 GDALGroupRelease(self);
5476 }
GDALGroupHS_GetName(GDALGroupHS * self)5477 SWIGINTERN char const *GDALGroupHS_GetName(GDALGroupHS *self){
5478 return GDALGroupGetName(self);
5479 }
GDALGroupHS_GetFullName(GDALGroupHS * self)5480 SWIGINTERN char const *GDALGroupHS_GetFullName(GDALGroupHS *self){
5481 return GDALGroupGetFullName(self);
5482 }
GDALGroupHS_GetMDArrayNames(GDALGroupHS * self,char ** options=0)5483 SWIGINTERN char **GDALGroupHS_GetMDArrayNames(GDALGroupHS *self,char **options=0){
5484 return GDALGroupGetMDArrayNames( self, options );
5485 }
GDALGroupHS_OpenMDArray(GDALGroupHS * self,char const * name,char ** options=0)5486 SWIGINTERN GDALMDArrayHS *GDALGroupHS_OpenMDArray(GDALGroupHS *self,char const *name,char **options=0){
5487 return GDALGroupOpenMDArray(self, name, options);
5488 }
GDALGroupHS_OpenMDArrayFromFullname(GDALGroupHS * self,char const * name,char ** options=0)5489 SWIGINTERN GDALMDArrayHS *GDALGroupHS_OpenMDArrayFromFullname(GDALGroupHS *self,char const *name,char **options=0){
5490 return GDALGroupOpenMDArrayFromFullname(self, name, options);
5491 }
GDALGroupHS_ResolveMDArray(GDALGroupHS * self,char const * name,char const * starting_point,char ** options=0)5492 SWIGINTERN GDALMDArrayHS *GDALGroupHS_ResolveMDArray(GDALGroupHS *self,char const *name,char const *starting_point,char **options=0){
5493 return GDALGroupResolveMDArray(self, name, starting_point, options);
5494 }
GDALGroupHS_GetGroupNames(GDALGroupHS * self,char ** options=0)5495 SWIGINTERN char **GDALGroupHS_GetGroupNames(GDALGroupHS *self,char **options=0){
5496 return GDALGroupGetGroupNames( self, options );
5497 }
GDALGroupHS_OpenGroup(GDALGroupHS * self,char const * name,char ** options=0)5498 SWIGINTERN GDALGroupHS *GDALGroupHS_OpenGroup(GDALGroupHS *self,char const *name,char **options=0){
5499 return GDALGroupOpenGroup(self, name, options);
5500 }
GDALGroupHS_OpenGroupFromFullname(GDALGroupHS * self,char const * name,char ** options=0)5501 SWIGINTERN GDALGroupHS *GDALGroupHS_OpenGroupFromFullname(GDALGroupHS *self,char const *name,char **options=0){
5502 return GDALGroupOpenGroupFromFullname(self, name, options);
5503 }
GDALGroupHS_GetDimensions(GDALGroupHS * self,GDALDimensionHS *** pdims,size_t * pnCount,char ** options=0)5504 SWIGINTERN void GDALGroupHS_GetDimensions(GDALGroupHS *self,GDALDimensionHS ***pdims,size_t *pnCount,char **options=0){
5505 *pdims = GDALGroupGetDimensions(self, pnCount, options);
5506 }
GDALGroupHS_GetAttribute(GDALGroupHS * self,char const * name)5507 SWIGINTERN GDALAttributeHS *GDALGroupHS_GetAttribute(GDALGroupHS *self,char const *name){
5508 return GDALGroupGetAttribute(self, name);
5509 }
GDALGroupHS_GetAttributes(GDALGroupHS * self,GDALAttributeHS *** pattrs,size_t * pnCount,char ** options=0)5510 SWIGINTERN void GDALGroupHS_GetAttributes(GDALGroupHS *self,GDALAttributeHS ***pattrs,size_t *pnCount,char **options=0){
5511 *pattrs = GDALGroupGetAttributes(self, pnCount, options);
5512 }
GDALGroupHS_GetStructuralInfo(GDALGroupHS * self)5513 SWIGINTERN char **GDALGroupHS_GetStructuralInfo(GDALGroupHS *self){
5514 return GDALGroupGetStructuralInfo( self );
5515 }
GDALGroupHS_CreateGroup(GDALGroupHS * self,char const * name,char ** options=0)5516 SWIGINTERN GDALGroupHS *GDALGroupHS_CreateGroup(GDALGroupHS *self,char const *name,char **options=0){
5517 return GDALGroupCreateGroup(self, name, options);
5518 }
GDALGroupHS_CreateDimension(GDALGroupHS * self,char const * name,char const * type,char const * direction,unsigned long long size,char ** options=0)5519 SWIGINTERN GDALDimensionHS *GDALGroupHS_CreateDimension(GDALGroupHS *self,char const *name,char const *type,char const *direction,unsigned long long size,char **options=0){
5520 return GDALGroupCreateDimension(self, name, type, direction, size, options);
5521 }
GDALGroupHS_CreateMDArray(GDALGroupHS * self,char const * name,int nDimensions,GDALDimensionHS ** dimensions,GDALExtendedDataTypeHS * data_type,char ** options=0)5522 SWIGINTERN GDALMDArrayHS *GDALGroupHS_CreateMDArray(GDALGroupHS *self,char const *name,int nDimensions,GDALDimensionHS **dimensions,GDALExtendedDataTypeHS *data_type,char **options=0){
5523 return GDALGroupCreateMDArray(self, name, nDimensions, dimensions,
5524 data_type, options);
5525 }
GDALGroupHS_CreateAttribute(GDALGroupHS * self,char const * name,int nDimensions,GUIntBig * dimensions,GDALExtendedDataTypeHS * data_type,char ** options=0)5526 SWIGINTERN GDALAttributeHS *GDALGroupHS_CreateAttribute(GDALGroupHS *self,char const *name,int nDimensions,GUIntBig *dimensions,GDALExtendedDataTypeHS *data_type,char **options=0){
5527 return GDALGroupCreateAttribute(self, name, nDimensions,
5528 (const GUInt64*)dimensions,
5529 data_type, options);
5530 }
5531
5532 typedef struct
5533 {
5534 double min;
5535 double max;
5536 double mean;
5537 double std_dev;
5538 GIntBig valid_count;
5539 } Statistics;
5540
delete_Statistics(Statistics * self)5541 SWIGINTERN void delete_Statistics(Statistics *self){
5542 CPLFree(self);
5543 }
5544
5545 #include <limits>
5546
CheckNumericDataType(GDALExtendedDataTypeHS * dt)5547 static bool CheckNumericDataType(GDALExtendedDataTypeHS* dt)
5548 {
5549 GDALExtendedDataTypeClass klass = GDALExtendedDataTypeGetClass(dt);
5550 if( klass == GEDTC_NUMERIC )
5551 return true;
5552 if( klass == GEDTC_STRING )
5553 return false;
5554 CPLAssert( klass == GEDTC_COMPOUND );
5555 size_t nCount = 0;
5556 GDALEDTComponentH* comps = GDALExtendedDataTypeGetComponents(dt, &nCount);
5557 bool ret = true;
5558 for( size_t i = 0; i < nCount; i++ )
5559 {
5560 GDALExtendedDataTypeH tmpType = GDALEDTComponentGetType(comps[i]);
5561 ret = CheckNumericDataType(tmpType);
5562 GDALExtendedDataTypeRelease(tmpType);
5563 if( !ret )
5564 break;
5565 }
5566 GDALExtendedDataTypeFreeComponents(comps, nCount);
5567 return ret;
5568 }
5569
MDArrayReadWriteCheckArguments(GDALMDArrayHS * array,bool bCheckOnlyDims,int nDims1,GUIntBig * array_start_idx,int nDims2,GUIntBig * count,int nDims3,GIntBig * array_step,int nDims4,GIntBig * buffer_stride,GDALExtendedDataTypeHS * buffer_datatype,size_t * pnBufferSize)5570 static CPLErr MDArrayReadWriteCheckArguments(GDALMDArrayHS* array,
5571 bool bCheckOnlyDims,
5572 int nDims1, GUIntBig* array_start_idx,
5573 int nDims2, GUIntBig* count,
5574 int nDims3, GIntBig* array_step,
5575 int nDims4, GIntBig* buffer_stride,
5576 GDALExtendedDataTypeHS* buffer_datatype,
5577 size_t* pnBufferSize)
5578 {
5579 const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(array);
5580 if( nDims1 != nExpectedDims )
5581 {
5582 CPLError(CE_Failure, CPLE_AppDefined,
5583 "Wrong number of values in array_start_idx");
5584 return CE_Failure;
5585 }
5586 if( nDims2 != nExpectedDims )
5587 {
5588 CPLError(CE_Failure, CPLE_AppDefined,
5589 "Wrong number of values in count");
5590 return CE_Failure;
5591 }
5592 if( nDims3 != nExpectedDims )
5593 {
5594 CPLError(CE_Failure, CPLE_AppDefined,
5595 "Wrong number of values in array_step");
5596 return CE_Failure;
5597 }
5598 if( nDims4!= nExpectedDims )
5599 {
5600 CPLError(CE_Failure, CPLE_AppDefined,
5601 "Wrong number of values in buffer_stride");
5602 return CE_Failure;
5603 }
5604 if( bCheckOnlyDims )
5605 return CE_None;
5606 if( !CheckNumericDataType(buffer_datatype) )
5607 {
5608 CPLError(CE_Failure, CPLE_NotSupported,
5609 "non-numeric buffer data type not supported in SWIG bindings");
5610 return CE_Failure;
5611 }
5612 GIntBig nBufferSize = 0;
5613 for( int i = 0; i < nExpectedDims; i++ )
5614 {
5615 if( count[i] == 0 )
5616 {
5617 CPLError(CE_Failure, CPLE_AppDefined,
5618 "count[%d] = 0 is invalid", i);
5619 return CE_Failure;
5620 }
5621 if( buffer_stride[i] < 0 )
5622 {
5623 CPLError(CE_Failure, CPLE_NotSupported,
5624 "Negative value in buffer_stride not supported in SWIG bindings");
5625 return CE_Failure;
5626 }
5627 if( count[i] > 1 && buffer_stride[i] != 0 )
5628 {
5629 if( (GUIntBig)buffer_stride[i] > std::numeric_limits<GIntBig>::max() / (count[i] - 1) )
5630 {
5631 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5632 return CE_Failure;
5633 }
5634 GIntBig nDelta = buffer_stride[i] * (count[i] - 1);
5635 if( nBufferSize > std::numeric_limits<GIntBig>::max() - nDelta )
5636 {
5637 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5638 return CE_Failure;
5639 }
5640 nBufferSize += nDelta;
5641 }
5642 }
5643 const size_t nDTSize = GDALExtendedDataTypeGetSize(buffer_datatype);
5644 if( nDTSize == 0 )
5645 {
5646 CPLError(CE_Failure, CPLE_AppDefined, "nDTSize == 0");
5647 return CE_Failure;
5648 }
5649 if( (GUIntBig)nBufferSize > (GUIntBig)std::numeric_limits<GIntBig>::max() / nDTSize )
5650 {
5651 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5652 return CE_Failure;
5653 }
5654 nBufferSize *= nDTSize;
5655 if( (GUIntBig)nBufferSize > (GUIntBig)std::numeric_limits<GIntBig>::max() - nDTSize )
5656 {
5657 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5658 return CE_Failure;
5659 }
5660 nBufferSize += nDTSize;
5661
5662 #if SIZEOF_VOIDP == 4
5663 if( nBufferSize > INT_MAX )
5664 {
5665 CPLError(CE_Failure, CPLE_IllegalArg, "Integer overflow");
5666 return CE_Failure;
5667 }
5668 #endif
5669 *pnBufferSize = (size_t)nBufferSize;
5670 return CE_None;
5671 }
5672
delete_GDALMDArrayHS(GDALMDArrayHS * self)5673 SWIGINTERN void delete_GDALMDArrayHS(GDALMDArrayHS *self){
5674 GDALMDArrayRelease(self);
5675 }
GDALMDArrayHS_GetName(GDALMDArrayHS * self)5676 SWIGINTERN char const *GDALMDArrayHS_GetName(GDALMDArrayHS *self){
5677 return GDALMDArrayGetName(self);
5678 }
GDALMDArrayHS_GetFullName(GDALMDArrayHS * self)5679 SWIGINTERN char const *GDALMDArrayHS_GetFullName(GDALMDArrayHS *self){
5680 return GDALMDArrayGetFullName(self);
5681 }
GDALMDArrayHS_GetTotalElementsCount(GDALMDArrayHS * self)5682 SWIGINTERN unsigned long long GDALMDArrayHS_GetTotalElementsCount(GDALMDArrayHS *self){
5683 return GDALMDArrayGetTotalElementsCount(self);
5684 }
5685
5686 #ifdef SWIG_LONG_LONG_AVAILABLE
5687 SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_long_SS_long(unsigned long long value)5688 SWIG_From_unsigned_SS_long_SS_long (unsigned long long value)
5689 {
5690 return (value > LONG_MAX) ?
5691 PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(static_cast< long >(value));
5692 }
5693 #endif
5694
GDALMDArrayHS_GetDimensionCount(GDALMDArrayHS * self)5695 SWIGINTERN size_t GDALMDArrayHS_GetDimensionCount(GDALMDArrayHS *self){
5696 return GDALMDArrayGetDimensionCount(self);
5697 }
5698
5699 SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_long(unsigned long value)5700 SWIG_From_unsigned_SS_long (unsigned long value)
5701 {
5702 return (value > LONG_MAX) ?
5703 PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value));
5704 }
5705
5706
5707 SWIGINTERNINLINE PyObject *
SWIG_From_size_t(size_t value)5708 SWIG_From_size_t (size_t value)
5709 {
5710 #ifdef SWIG_LONG_LONG_AVAILABLE
5711 if (sizeof(size_t) <= sizeof(unsigned long)) {
5712 #endif
5713 return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value));
5714 #ifdef SWIG_LONG_LONG_AVAILABLE
5715 } else {
5716 /* assume sizeof(size_t) <= sizeof(unsigned long long) */
5717 return SWIG_From_unsigned_SS_long_SS_long (static_cast< unsigned long long >(value));
5718 }
5719 #endif
5720 }
5721
GDALMDArrayHS_GetDimensions(GDALMDArrayHS * self,GDALDimensionHS *** pdims,size_t * pnCount)5722 SWIGINTERN void GDALMDArrayHS_GetDimensions(GDALMDArrayHS *self,GDALDimensionHS ***pdims,size_t *pnCount){
5723 *pdims = GDALMDArrayGetDimensions(self, pnCount);
5724 }
GDALMDArrayHS_GetBlockSize(GDALMDArrayHS * self,GUIntBig ** psizes,size_t * pnCount)5725 SWIGINTERN void GDALMDArrayHS_GetBlockSize(GDALMDArrayHS *self,GUIntBig **psizes,size_t *pnCount){
5726 *psizes = GDALMDArrayGetBlockSize(self, pnCount);
5727 }
GDALMDArrayHS_GetProcessingChunkSize(GDALMDArrayHS * self,size_t nMaxChunkMemory,GUIntBig ** psizes,size_t * pnCount)5728 SWIGINTERN void GDALMDArrayHS_GetProcessingChunkSize(GDALMDArrayHS *self,size_t nMaxChunkMemory,GUIntBig **psizes,size_t *pnCount){
5729 size_t* panTmp = GDALMDArrayGetProcessingChunkSize(self, pnCount, nMaxChunkMemory);
5730 *psizes = NULL;
5731 if( panTmp )
5732 {
5733 *psizes = (GUIntBig*) CPLMalloc(sizeof(GUIntBig) * (*pnCount));
5734 for( size_t i = 0; i < *pnCount; ++i )
5735 {
5736 (*psizes)[i] = panTmp[i];
5737 }
5738 CPLFree(panTmp);
5739 }
5740 }
GDALMDArrayHS_GetDataType(GDALMDArrayHS * self)5741 SWIGINTERN GDALExtendedDataTypeHS *GDALMDArrayHS_GetDataType(GDALMDArrayHS *self){
5742 return GDALMDArrayGetDataType(self);
5743 }
GDALMDArrayHS_GetStructuralInfo(GDALMDArrayHS * self)5744 SWIGINTERN char **GDALMDArrayHS_GetStructuralInfo(GDALMDArrayHS *self){
5745 return GDALMDArrayGetStructuralInfo( self );
5746 }
GDALMDArrayHS_Read(GDALMDArrayHS * self,int nDims1,GUIntBig * array_start_idx,int nDims2,GUIntBig * count,int nDims3,GIntBig * array_step,int nDims4,GIntBig * buffer_stride,GDALExtendedDataTypeHS * buffer_datatype,void ** buf)5747 SWIGINTERN CPLErr GDALMDArrayHS_Read(GDALMDArrayHS *self,int nDims1,GUIntBig *array_start_idx,int nDims2,GUIntBig *count,int nDims3,GIntBig *array_step,int nDims4,GIntBig *buffer_stride,GDALExtendedDataTypeHS *buffer_datatype,void **buf){
5748 *buf = NULL;
5749
5750 size_t buf_size = 0;
5751 if( MDArrayReadWriteCheckArguments(self, true,
5752 nDims1, array_start_idx,
5753 nDims2, count,
5754 nDims3, array_step,
5755 nDims4, buffer_stride,
5756 buffer_datatype,
5757 &buf_size) != CE_None )
5758 {
5759 return CE_Failure;
5760 }
5761
5762 const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(self);
5763 std::vector<size_t> count_internal(nExpectedDims + 1);
5764 std::vector<GPtrDiff_t> buffer_stride_internal(nExpectedDims + 1);
5765 size_t nProductCount = 1;
5766 for( int i = 0; i < nExpectedDims; i++ )
5767 {
5768 count_internal[i] = (size_t)count[i];
5769 if( count_internal[i] != count[i] )
5770 {
5771 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5772 return CE_Failure;
5773 }
5774 nProductCount *= count_internal[i];
5775 buffer_stride_internal[i] = (GPtrDiff_t)buffer_stride[i];
5776 if( buffer_stride_internal[i] != buffer_stride[i] )
5777 {
5778 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5779 return CE_Failure;
5780 }
5781 }
5782
5783 GDALExtendedDataTypeHS* selfType = GDALMDArrayGetDataType(self);
5784 bool isSelfString = GDALExtendedDataTypeGetClass(selfType) == GEDTC_STRING;
5785 GDALExtendedDataTypeRelease(selfType);
5786
5787 if( GDALExtendedDataTypeGetClass(buffer_datatype) == GEDTC_STRING &&
5788 isSelfString )
5789 {
5790 size_t nExpectedStride = 1;
5791 for( int i = nExpectedDims; i > 0; )
5792 {
5793 --i;
5794 if( (size_t)buffer_stride_internal[i] != nExpectedStride )
5795 {
5796 CPLError(CE_Failure, CPLE_AppDefined, "Unhandled stride");
5797 return CE_Failure;
5798 }
5799 nExpectedStride *= count_internal[i];
5800 }
5801 char** ppszBuffer = (char**)VSI_CALLOC_VERBOSE(nProductCount, sizeof(char*));
5802 if( !ppszBuffer )
5803 return CE_Failure;
5804 GByte* pabyBuffer = (GByte*)ppszBuffer;
5805 if( !(GDALMDArrayRead( self,
5806 array_start_idx,
5807 &count_internal[0],
5808 array_step,
5809 NULL,
5810 buffer_datatype,
5811 pabyBuffer,
5812 pabyBuffer,
5813 nProductCount * sizeof(char*) )) )
5814 {
5815 for( size_t i = 0; i < nProductCount; i++ )
5816 VSIFree(ppszBuffer[i]);
5817 VSIFree(pabyBuffer);
5818 return CE_Failure;
5819 }
5820
5821 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
5822 PyObject* obj = PyList_New( nProductCount );
5823 for( size_t i = 0; i < nProductCount; i++ )
5824 {
5825 if( !ppszBuffer[i] )
5826 {
5827 Py_INCREF(Py_None);
5828 PyList_SetItem(obj, i, Py_None);
5829 }
5830 else
5831 {
5832 PyList_SetItem(obj, i, GDALPythonObjectFromCStr( ppszBuffer[i] ) );
5833 }
5834 VSIFree(ppszBuffer[i]);
5835 }
5836 SWIG_PYTHON_THREAD_END_BLOCK;
5837 *buf = obj;
5838 VSIFree(pabyBuffer);
5839 return CE_None;
5840 }
5841
5842 if( MDArrayReadWriteCheckArguments(self, false,
5843 nDims1, array_start_idx,
5844 nDims2, count,
5845 nDims3, array_step,
5846 nDims4, buffer_stride,
5847 buffer_datatype,
5848 &buf_size) != CE_None )
5849 {
5850 return CE_Failure;
5851 }
5852 if( buf_size == 0 )
5853 {
5854 return CE_None;
5855 }
5856
5857
5858 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
5859 *buf = (void *)PyByteArray_FromStringAndSize( NULL, buf_size );
5860 if (*buf == NULL)
5861 {
5862 *buf = Py_None;
5863 if( !bUseExceptions )
5864 {
5865 PyErr_Clear();
5866 }
5867 SWIG_PYTHON_THREAD_END_BLOCK;
5868 CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate result buffer");
5869 return CE_Failure;
5870 }
5871 char *data = PyByteArray_AsString( (PyObject *)*buf );
5872 SWIG_PYTHON_THREAD_END_BLOCK;
5873
5874 memset(data, 0, buf_size);
5875
5876 CPLErr eErr = GDALMDArrayRead( self,
5877 array_start_idx,
5878 &count_internal[0],
5879 array_step,
5880 &buffer_stride_internal[0],
5881 buffer_datatype,
5882 data,
5883 data,
5884 buf_size ) ? CE_None : CE_Failure;
5885 if (eErr == CE_Failure)
5886 {
5887 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
5888 Py_DECREF((PyObject*)*buf);
5889 SWIG_PYTHON_THREAD_END_BLOCK;
5890 *buf = NULL;
5891 }
5892
5893 return eErr;
5894 }
GDALMDArrayHS_WriteStringArray(GDALMDArrayHS * self,int nDims1,GUIntBig * array_start_idx,int nDims2,GUIntBig * count,int nDims3,GIntBig * array_step,GDALExtendedDataTypeHS * buffer_datatype,char ** options)5895 SWIGINTERN CPLErr GDALMDArrayHS_WriteStringArray(GDALMDArrayHS *self,int nDims1,GUIntBig *array_start_idx,int nDims2,GUIntBig *count,int nDims3,GIntBig *array_step,GDALExtendedDataTypeHS *buffer_datatype,char **options){
5896
5897 const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(self);
5898 std::vector<size_t> count_internal(nExpectedDims);
5899 if( nExpectedDims != 1 )
5900 {
5901 CPLError(CE_Failure, CPLE_AppDefined,
5902 "Unsupported number of dimensions");
5903 return CE_Failure;
5904 }
5905 for( int i = 0; i < nExpectedDims; i++ )
5906 {
5907 count_internal[i] = (size_t)count[i];
5908 if( count_internal[i] != count[i] )
5909 {
5910 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5911 return CE_Failure;
5912 }
5913 }
5914 if( nDims1 != 1 )
5915 {
5916 CPLError(CE_Failure, CPLE_AppDefined,
5917 "Wrong number of values in array_start_idx");
5918 return CE_Failure;
5919 }
5920 if( nDims2 != 1 )
5921 {
5922 CPLError(CE_Failure, CPLE_AppDefined,
5923 "Wrong number of values in count");
5924 return CE_Failure;
5925 }
5926 if( nDims3 != 1 )
5927 {
5928 CPLError(CE_Failure, CPLE_AppDefined,
5929 "Wrong number of values in array_step");
5930 return CE_Failure;
5931 }
5932
5933 CPLErr eErr = GDALMDArrayWrite(self,
5934 array_start_idx,
5935 &count_internal[0],
5936 array_step,
5937 NULL,
5938 buffer_datatype,
5939 options,
5940 options,
5941 CSLCount(options) * sizeof(char*) ) ? CE_None : CE_Failure;
5942 return eErr;
5943 }
GDALMDArrayHS_Write(GDALMDArrayHS * self,int nDims1,GUIntBig * array_start_idx,int nDims2,GUIntBig * count,int nDims3,GIntBig * array_step,int nDims4,GIntBig * buffer_stride,GDALExtendedDataTypeHS * buffer_datatype,GIntBig buf_len,char * buf_string)5944 SWIGINTERN CPLErr GDALMDArrayHS_Write(GDALMDArrayHS *self,int nDims1,GUIntBig *array_start_idx,int nDims2,GUIntBig *count,int nDims3,GIntBig *array_step,int nDims4,GIntBig *buffer_stride,GDALExtendedDataTypeHS *buffer_datatype,GIntBig buf_len,char *buf_string){
5945
5946 size_t buf_size = 0;
5947 if( MDArrayReadWriteCheckArguments(self, false,
5948 nDims1, array_start_idx,
5949 nDims2, count,
5950 nDims3, array_step,
5951 nDims4, buffer_stride,
5952 buffer_datatype,
5953 &buf_size) != CE_None )
5954 {
5955 return CE_Failure;
5956 }
5957
5958 if ( (GUIntBig)buf_len < buf_size )
5959 {
5960 CPLError(CE_Failure, CPLE_AppDefined, "Buffer too small");
5961 return CE_Failure;
5962 }
5963
5964 const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(self);
5965 std::vector<size_t> count_internal(nExpectedDims+1);
5966 std::vector<GPtrDiff_t> buffer_stride_internal(nExpectedDims+1);
5967 for( int i = 0; i < nExpectedDims; i++ )
5968 {
5969 count_internal[i] = (size_t)count[i];
5970 if( count_internal[i] != count[i] )
5971 {
5972 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5973 return CE_Failure;
5974 }
5975 buffer_stride_internal[i] = (GPtrDiff_t)buffer_stride[i];
5976 if( buffer_stride_internal[i] != buffer_stride[i] )
5977 {
5978 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
5979 return CE_Failure;
5980 }
5981 }
5982
5983 CPLErr eErr = GDALMDArrayWrite( self,
5984 array_start_idx,
5985 &count_internal[0],
5986 array_step,
5987 &buffer_stride_internal[0],
5988 buffer_datatype,
5989 buf_string,
5990 buf_string,
5991 (size_t)buf_len ) ? CE_None : CE_Failure;
5992 return eErr;
5993 }
GDALMDArrayHS_AdviseRead(GDALMDArrayHS * self,int nDims1,GUIntBig * array_start_idx,int nDims2,GUIntBig * count)5994 SWIGINTERN CPLErr GDALMDArrayHS_AdviseRead(GDALMDArrayHS *self,int nDims1,GUIntBig *array_start_idx,int nDims2,GUIntBig *count){
5995
5996 const int nExpectedDims = (int)GDALMDArrayGetDimensionCount(self);
5997 if( nDims1 != nExpectedDims )
5998 {
5999 CPLError(CE_Failure, CPLE_AppDefined,
6000 "Wrong number of values in array_start_idx");
6001 return CE_Failure;
6002 }
6003 if( nDims2 != nExpectedDims )
6004 {
6005 CPLError(CE_Failure, CPLE_AppDefined,
6006 "Wrong number of values in count");
6007 return CE_Failure;
6008 }
6009
6010 std::vector<size_t> count_internal(nExpectedDims+1);
6011 for( int i = 0; i < nExpectedDims; i++ )
6012 {
6013 count_internal[i] = (size_t)count[i];
6014 if( count_internal[i] != count[i] )
6015 {
6016 CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow");
6017 return CE_Failure;
6018 }
6019 }
6020
6021 if( !(GDALMDArrayAdviseRead( self, array_start_idx, count_internal.data() )) )
6022 {
6023 return CE_Failure;
6024 }
6025 return CE_None;
6026 }
GDALMDArrayHS_GetAttribute(GDALMDArrayHS * self,char const * name)6027 SWIGINTERN GDALAttributeHS *GDALMDArrayHS_GetAttribute(GDALMDArrayHS *self,char const *name){
6028 return GDALMDArrayGetAttribute(self, name);
6029 }
GDALMDArrayHS_GetAttributes(GDALMDArrayHS * self,GDALAttributeHS *** pattrs,size_t * pnCount,char ** options=0)6030 SWIGINTERN void GDALMDArrayHS_GetAttributes(GDALMDArrayHS *self,GDALAttributeHS ***pattrs,size_t *pnCount,char **options=0){
6031 *pattrs = GDALMDArrayGetAttributes(self, pnCount, options);
6032 }
GDALMDArrayHS_CreateAttribute(GDALMDArrayHS * self,char const * name,int nDimensions,GUIntBig * dimensions,GDALExtendedDataTypeHS * data_type,char ** options=0)6033 SWIGINTERN GDALAttributeHS *GDALMDArrayHS_CreateAttribute(GDALMDArrayHS *self,char const *name,int nDimensions,GUIntBig *dimensions,GDALExtendedDataTypeHS *data_type,char **options=0){
6034 return GDALMDArrayCreateAttribute(self, name, nDimensions,
6035 (const GUInt64*)dimensions,
6036 data_type, options);
6037 }
GDALMDArrayHS_GetNoDataValueAsRaw(GDALMDArrayHS * self,void ** buf)6038 SWIGINTERN CPLErr GDALMDArrayHS_GetNoDataValueAsRaw(GDALMDArrayHS *self,void **buf){
6039 *buf = NULL;
6040 const void* pabyBuf = GDALMDArrayGetRawNoDataValue(self);
6041 if( pabyBuf == NULL )
6042 {
6043 return CE_Failure;
6044 }
6045 GDALExtendedDataTypeHS* selfType = GDALMDArrayGetDataType(self);
6046 const size_t buf_size = GDALExtendedDataTypeGetSize(selfType);
6047 GDALExtendedDataTypeRelease(selfType);
6048
6049 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
6050 *buf = (void *)PyByteArray_FromStringAndSize( NULL, buf_size );
6051 if (*buf == NULL)
6052 {
6053 *buf = Py_None;
6054 if( !bUseExceptions )
6055 {
6056 PyErr_Clear();
6057 }
6058 SWIG_PYTHON_THREAD_END_BLOCK;
6059 CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate result buffer");
6060 return CE_Failure;
6061 }
6062 char *data = PyByteArray_AsString( (PyObject *)*buf );
6063 SWIG_PYTHON_THREAD_END_BLOCK;
6064
6065 memcpy(data, pabyBuf, buf_size);
6066
6067 return CE_None;
6068 }
GDALMDArrayHS_GetNoDataValueAsDouble(GDALMDArrayHS * self,double * val,int * hasval)6069 SWIGINTERN void GDALMDArrayHS_GetNoDataValueAsDouble(GDALMDArrayHS *self,double *val,int *hasval){
6070 *val = GDALMDArrayGetNoDataValueAsDouble( self, hasval );
6071 }
GDALMDArrayHS_SetNoDataValueDouble(GDALMDArrayHS * self,double d)6072 SWIGINTERN CPLErr GDALMDArrayHS_SetNoDataValueDouble(GDALMDArrayHS *self,double d){
6073 return GDALMDArraySetNoDataValueAsDouble( self, d ) ? CE_None : CE_Failure;
6074 }
GDALMDArrayHS_SetNoDataValueRaw(GDALMDArrayHS * self,GIntBig nLen,char * pBuf)6075 SWIGINTERN CPLErr GDALMDArrayHS_SetNoDataValueRaw(GDALMDArrayHS *self,GIntBig nLen,char *pBuf){
6076 GDALExtendedDataTypeHS* selfType = GDALMDArrayGetDataType(self);
6077 const size_t selfTypeSize = GDALExtendedDataTypeGetSize(selfType);
6078 GDALExtendedDataTypeRelease(selfType);
6079
6080 if( static_cast<size_t>(nLen) != selfTypeSize )
6081 {
6082 CPLError(CE_Failure, CPLE_IllegalArg, "Argument of wrong size");
6083 return CE_Failure;
6084 }
6085 return GDALMDArraySetRawNoDataValue(self, pBuf) ? CE_None : CE_Failure;
6086 }
GDALMDArrayHS_DeleteNoDataValue(GDALMDArrayHS * self)6087 SWIGINTERN CPLErr GDALMDArrayHS_DeleteNoDataValue(GDALMDArrayHS *self){
6088 return GDALMDArraySetRawNoDataValue( self, NULL ) ? CE_None : CE_Failure;
6089 }
GDALMDArrayHS_GetOffset(GDALMDArrayHS * self,double * val,int * hasval)6090 SWIGINTERN void GDALMDArrayHS_GetOffset(GDALMDArrayHS *self,double *val,int *hasval){
6091 *val = GDALMDArrayGetOffset( self, hasval );
6092 }
GDALMDArrayHS_GetOffsetStorageType(GDALMDArrayHS * self)6093 SWIGINTERN GDALDataType GDALMDArrayHS_GetOffsetStorageType(GDALMDArrayHS *self){
6094 GDALDataType eDT = GDT_Unknown;
6095 int hasval = FALSE;
6096 GDALMDArrayGetOffsetEx( self, &hasval, &eDT );
6097 return hasval ? eDT : GDT_Unknown;
6098 }
GDALMDArrayHS_GetScale(GDALMDArrayHS * self,double * val,int * hasval)6099 SWIGINTERN void GDALMDArrayHS_GetScale(GDALMDArrayHS *self,double *val,int *hasval){
6100 *val = GDALMDArrayGetScale( self, hasval );
6101 }
GDALMDArrayHS_GetScaleStorageType(GDALMDArrayHS * self)6102 SWIGINTERN GDALDataType GDALMDArrayHS_GetScaleStorageType(GDALMDArrayHS *self){
6103 GDALDataType eDT = GDT_Unknown;
6104 int hasval = FALSE;
6105 GDALMDArrayGetScaleEx( self, &hasval, &eDT );
6106 return hasval ? eDT : GDT_Unknown;
6107 }
GDALMDArrayHS_SetOffset(GDALMDArrayHS * self,double val,GDALDataType storageType=GDT_Unknown)6108 SWIGINTERN CPLErr GDALMDArrayHS_SetOffset(GDALMDArrayHS *self,double val,GDALDataType storageType=GDT_Unknown){
6109 return GDALMDArraySetOffsetEx( self, val, storageType ) ? CE_None : CE_Failure;
6110 }
GDALMDArrayHS_SetScale(GDALMDArrayHS * self,double val,GDALDataType storageType=GDT_Unknown)6111 SWIGINTERN CPLErr GDALMDArrayHS_SetScale(GDALMDArrayHS *self,double val,GDALDataType storageType=GDT_Unknown){
6112 return GDALMDArraySetScaleEx( self, val, storageType ) ? CE_None : CE_Failure;
6113 }
GDALMDArrayHS_SetUnit(GDALMDArrayHS * self,char const * unit)6114 SWIGINTERN CPLErr GDALMDArrayHS_SetUnit(GDALMDArrayHS *self,char const *unit){
6115 return GDALMDArraySetUnit(self, unit) ? CE_None : CE_Failure;
6116 }
GDALMDArrayHS_GetUnit(GDALMDArrayHS * self)6117 SWIGINTERN char const *GDALMDArrayHS_GetUnit(GDALMDArrayHS *self){
6118 return GDALMDArrayGetUnit(self);
6119 }
GDALMDArrayHS_SetSpatialRef(GDALMDArrayHS * self,OSRSpatialReferenceShadow * srs)6120 SWIGINTERN OGRErr GDALMDArrayHS_SetSpatialRef(GDALMDArrayHS *self,OSRSpatialReferenceShadow *srs){
6121 return GDALMDArraySetSpatialRef( self, (OGRSpatialReferenceH)srs ) ? CE_None : CE_Failure;
6122 }
GDALMDArrayHS_GetSpatialRef(GDALMDArrayHS * self)6123 SWIGINTERN OSRSpatialReferenceShadow *GDALMDArrayHS_GetSpatialRef(GDALMDArrayHS *self){
6124 return GDALMDArrayGetSpatialRef(self);
6125 }
GDALMDArrayHS_GetView(GDALMDArrayHS * self,char const * viewExpr)6126 SWIGINTERN GDALMDArrayHS *GDALMDArrayHS_GetView(GDALMDArrayHS *self,char const *viewExpr){
6127 return GDALMDArrayGetView(self, viewExpr);
6128 }
GDALMDArrayHS_Transpose(GDALMDArrayHS * self,int nList,int * pList)6129 SWIGINTERN GDALMDArrayHS *GDALMDArrayHS_Transpose(GDALMDArrayHS *self,int nList,int *pList){
6130 return GDALMDArrayTranspose(self, nList, pList);
6131 }
GDALMDArrayHS_GetUnscaled(GDALMDArrayHS * self)6132 SWIGINTERN GDALMDArrayHS *GDALMDArrayHS_GetUnscaled(GDALMDArrayHS *self){
6133 return GDALMDArrayGetUnscaled(self);
6134 }
GDALMDArrayHS_GetMask(GDALMDArrayHS * self,char ** options=0)6135 SWIGINTERN GDALMDArrayHS *GDALMDArrayHS_GetMask(GDALMDArrayHS *self,char **options=0){
6136 return GDALMDArrayGetMask(self, options);
6137 }
GDALMDArrayHS_AsClassicDataset(GDALMDArrayHS * self,size_t iXDim,size_t iYDim)6138 SWIGINTERN GDALDatasetShadow *GDALMDArrayHS_AsClassicDataset(GDALMDArrayHS *self,size_t iXDim,size_t iYDim){
6139 return (GDALDatasetShadow*)GDALMDArrayAsClassicDataset(self, iXDim, iYDim);
6140 }
GDALMDArrayHS_GetStatistics(GDALMDArrayHS * self,GDALDatasetShadow * ds=NULL,bool approx_ok=FALSE,bool force=TRUE,GDALProgressFunc callback=NULL,void * callback_data=NULL)6141 SWIGINTERN Statistics *GDALMDArrayHS_GetStatistics(GDALMDArrayHS *self,GDALDatasetShadow *ds=NULL,bool approx_ok=FALSE,bool force=TRUE,GDALProgressFunc callback=NULL,void *callback_data=NULL){
6142 GUInt64 nValidCount = 0;
6143 Statistics* psStatisticsOut = (Statistics*)CPLMalloc(sizeof(Statistics));
6144 CPLErr eErr = GDALMDArrayGetStatistics(self, ds, approx_ok, force,
6145 &(psStatisticsOut->min),
6146 &(psStatisticsOut->max),
6147 &(psStatisticsOut->mean),
6148 &(psStatisticsOut->std_dev),
6149 &nValidCount,
6150 callback, callback_data);
6151 psStatisticsOut->valid_count = static_cast<GIntBig>(nValidCount);
6152 if( eErr == CE_None )
6153 return psStatisticsOut;
6154 CPLFree(psStatisticsOut);
6155 return NULL;
6156 }
GDALMDArrayHS_ComputeStatistics(GDALMDArrayHS * self,GDALDatasetShadow * ds=NULL,bool approx_ok=FALSE,GDALProgressFunc callback=NULL,void * callback_data=NULL)6157 SWIGINTERN Statistics *GDALMDArrayHS_ComputeStatistics(GDALMDArrayHS *self,GDALDatasetShadow *ds=NULL,bool approx_ok=FALSE,GDALProgressFunc callback=NULL,void *callback_data=NULL){
6158 GUInt64 nValidCount = 0;
6159 Statistics* psStatisticsOut = (Statistics*)CPLMalloc(sizeof(Statistics));
6160 int nSuccess = GDALMDArrayComputeStatistics(self, ds, approx_ok,
6161 &(psStatisticsOut->min),
6162 &(psStatisticsOut->max),
6163 &(psStatisticsOut->mean),
6164 &(psStatisticsOut->std_dev),
6165 &nValidCount,
6166 callback, callback_data);
6167 psStatisticsOut->valid_count = static_cast<GIntBig>(nValidCount);
6168 if( nSuccess )
6169 return psStatisticsOut;
6170 CPLFree(psStatisticsOut);
6171 return NULL;
6172 }
delete_GDALAttributeHS(GDALAttributeHS * self)6173 SWIGINTERN void delete_GDALAttributeHS(GDALAttributeHS *self){
6174 GDALAttributeRelease(self);
6175 }
GDALAttributeHS_GetName(GDALAttributeHS * self)6176 SWIGINTERN char const *GDALAttributeHS_GetName(GDALAttributeHS *self){
6177 return GDALAttributeGetName(self);
6178 }
GDALAttributeHS_GetFullName(GDALAttributeHS * self)6179 SWIGINTERN char const *GDALAttributeHS_GetFullName(GDALAttributeHS *self){
6180 return GDALAttributeGetFullName(self);
6181 }
GDALAttributeHS_GetTotalElementsCount(GDALAttributeHS * self)6182 SWIGINTERN unsigned long long GDALAttributeHS_GetTotalElementsCount(GDALAttributeHS *self){
6183 return GDALAttributeGetTotalElementsCount(self);
6184 }
GDALAttributeHS_GetDimensionCount(GDALAttributeHS * self)6185 SWIGINTERN size_t GDALAttributeHS_GetDimensionCount(GDALAttributeHS *self){
6186 return GDALAttributeGetDimensionCount(self);
6187 }
GDALAttributeHS_GetDimensionsSize(GDALAttributeHS * self,GUIntBig ** pdims,size_t * pnCount)6188 SWIGINTERN void GDALAttributeHS_GetDimensionsSize(GDALAttributeHS *self,GUIntBig **pdims,size_t *pnCount){
6189 *pdims = GDALAttributeGetDimensionsSize(self, pnCount);
6190 }
GDALAttributeHS_GetDataType(GDALAttributeHS * self)6191 SWIGINTERN GDALExtendedDataTypeHS *GDALAttributeHS_GetDataType(GDALAttributeHS *self){
6192 return GDALAttributeGetDataType(self);
6193 }
GDALAttributeHS_ReadAsRaw(GDALAttributeHS * self,void ** buf)6194 SWIGINTERN CPLErr GDALAttributeHS_ReadAsRaw(GDALAttributeHS *self,void **buf){
6195 *buf = NULL;
6196 GDALExtendedDataTypeHS* dt = GDALAttributeGetDataType(self);
6197 bool bIsNumeric = CheckNumericDataType(dt);
6198 GDALExtendedDataTypeRelease(dt);
6199 if( !bIsNumeric )
6200 {
6201 CPLError(CE_Failure, CPLE_NotSupported,
6202 "non-numeric buffer data type not supported in SWIG bindings");
6203 return CE_Failure;
6204 }
6205 size_t buf_size = 0;
6206 GByte* pabyBuf = GDALAttributeReadAsRaw(self, &buf_size);
6207 if( pabyBuf == NULL )
6208 {
6209 return CE_Failure;
6210 }
6211
6212 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
6213 *buf = (void *)PyBytes_FromStringAndSize( NULL, buf_size );
6214 if (*buf == NULL)
6215 {
6216 *buf = Py_None;
6217 if( !bUseExceptions )
6218 {
6219 PyErr_Clear();
6220 }
6221 SWIG_PYTHON_THREAD_END_BLOCK;
6222 CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate result buffer");
6223 GDALAttributeFreeRawResult(self, pabyBuf, buf_size);
6224 return CE_Failure;
6225 }
6226 char *data = PyBytes_AsString( (PyObject *)*buf );
6227 SWIG_PYTHON_THREAD_END_BLOCK;
6228
6229 memcpy(data, pabyBuf, buf_size);
6230 GDALAttributeFreeRawResult(self, pabyBuf, buf_size);
6231
6232 return CE_None;
6233 }
GDALAttributeHS_ReadAsString(GDALAttributeHS * self)6234 SWIGINTERN char const *GDALAttributeHS_ReadAsString(GDALAttributeHS *self){
6235 return GDALAttributeReadAsString(self);
6236 }
GDALAttributeHS_ReadAsInt(GDALAttributeHS * self)6237 SWIGINTERN int GDALAttributeHS_ReadAsInt(GDALAttributeHS *self){
6238 return GDALAttributeReadAsInt(self);
6239 }
GDALAttributeHS_ReadAsDouble(GDALAttributeHS * self)6240 SWIGINTERN double GDALAttributeHS_ReadAsDouble(GDALAttributeHS *self){
6241 return GDALAttributeReadAsDouble(self);
6242 }
GDALAttributeHS_ReadAsStringArray(GDALAttributeHS * self)6243 SWIGINTERN char **GDALAttributeHS_ReadAsStringArray(GDALAttributeHS *self){
6244 return GDALAttributeReadAsStringArray(self);
6245 }
GDALAttributeHS_ReadAsIntArray(GDALAttributeHS * self,int ** pvals,size_t * pnCount)6246 SWIGINTERN void GDALAttributeHS_ReadAsIntArray(GDALAttributeHS *self,int **pvals,size_t *pnCount){
6247 *pvals = GDALAttributeReadAsIntArray(self, pnCount);
6248 }
GDALAttributeHS_ReadAsDoubleArray(GDALAttributeHS * self,double ** pvals,size_t * pnCount)6249 SWIGINTERN void GDALAttributeHS_ReadAsDoubleArray(GDALAttributeHS *self,double **pvals,size_t *pnCount){
6250 *pvals = GDALAttributeReadAsDoubleArray(self, pnCount);
6251 }
GDALAttributeHS_WriteRaw(GDALAttributeHS * self,GIntBig nLen,char * pBuf)6252 SWIGINTERN CPLErr GDALAttributeHS_WriteRaw(GDALAttributeHS *self,GIntBig nLen,char *pBuf){
6253 GDALExtendedDataTypeHS* dt = GDALAttributeGetDataType(self);
6254 bool bIsNumeric = CheckNumericDataType(dt);
6255 GDALExtendedDataTypeRelease(dt);
6256 if( !bIsNumeric )
6257 {
6258 CPLError(CE_Failure, CPLE_NotSupported,
6259 "non-numeric buffer data type not supported in SWIG bindings");
6260 return CE_Failure;
6261 }
6262 return GDALAttributeWriteRaw(self, pBuf, nLen) ? CE_None : CE_Failure;
6263 }
GDALAttributeHS_WriteString(GDALAttributeHS * self,char const * val)6264 SWIGINTERN CPLErr GDALAttributeHS_WriteString(GDALAttributeHS *self,char const *val){
6265 return GDALAttributeWriteString(self, val) ? CE_None : CE_Failure;
6266 }
GDALAttributeHS_WriteStringArray(GDALAttributeHS * self,char ** vals)6267 SWIGINTERN CPLErr GDALAttributeHS_WriteStringArray(GDALAttributeHS *self,char **vals){
6268 return GDALAttributeWriteStringArray(self, vals) ? CE_None : CE_Failure;
6269 }
GDALAttributeHS_WriteInt(GDALAttributeHS * self,int val)6270 SWIGINTERN CPLErr GDALAttributeHS_WriteInt(GDALAttributeHS *self,int val){
6271 return GDALAttributeWriteInt(self, val) ? CE_None : CE_Failure;
6272 }
GDALAttributeHS_WriteDouble(GDALAttributeHS * self,double val)6273 SWIGINTERN CPLErr GDALAttributeHS_WriteDouble(GDALAttributeHS *self,double val){
6274 return GDALAttributeWriteDouble(self, val) ? CE_None : CE_Failure;
6275 }
GDALAttributeHS_WriteDoubleArray(GDALAttributeHS * self,int nList,double * pList)6276 SWIGINTERN CPLErr GDALAttributeHS_WriteDoubleArray(GDALAttributeHS *self,int nList,double *pList){
6277 return GDALAttributeWriteDoubleArray(self, pList, nList) ? CE_None : CE_Failure;
6278 }
delete_GDALDimensionHS(GDALDimensionHS * self)6279 SWIGINTERN void delete_GDALDimensionHS(GDALDimensionHS *self){
6280 GDALDimensionRelease(self);
6281 }
GDALDimensionHS_GetName(GDALDimensionHS * self)6282 SWIGINTERN char const *GDALDimensionHS_GetName(GDALDimensionHS *self){
6283 return GDALDimensionGetName(self);
6284 }
GDALDimensionHS_GetFullName(GDALDimensionHS * self)6285 SWIGINTERN char const *GDALDimensionHS_GetFullName(GDALDimensionHS *self){
6286 return GDALDimensionGetFullName(self);
6287 }
GDALDimensionHS_GetType(GDALDimensionHS * self)6288 SWIGINTERN char const *GDALDimensionHS_GetType(GDALDimensionHS *self){
6289 return GDALDimensionGetType(self);
6290 }
GDALDimensionHS_GetDirection(GDALDimensionHS * self)6291 SWIGINTERN char const *GDALDimensionHS_GetDirection(GDALDimensionHS *self){
6292 return GDALDimensionGetDirection(self);
6293 }
GDALDimensionHS_GetSize(GDALDimensionHS * self)6294 SWIGINTERN unsigned long long GDALDimensionHS_GetSize(GDALDimensionHS *self){
6295 return GDALDimensionGetSize(self);
6296 }
GDALDimensionHS_GetIndexingVariable(GDALDimensionHS * self)6297 SWIGINTERN GDALMDArrayHS *GDALDimensionHS_GetIndexingVariable(GDALDimensionHS *self){
6298 return GDALDimensionGetIndexingVariable(self);
6299 }
GDALDimensionHS_SetIndexingVariable(GDALDimensionHS * self,GDALMDArrayHS * array)6300 SWIGINTERN bool GDALDimensionHS_SetIndexingVariable(GDALDimensionHS *self,GDALMDArrayHS *array){
6301 return GDALDimensionSetIndexingVariable(self, array);
6302 }
delete_GDALExtendedDataTypeHS(GDALExtendedDataTypeHS * self)6303 SWIGINTERN void delete_GDALExtendedDataTypeHS(GDALExtendedDataTypeHS *self){
6304 GDALExtendedDataTypeRelease(self);
6305 }
GDALExtendedDataTypeHS_Create(GDALDataType dt)6306 SWIGINTERN GDALExtendedDataTypeHS *GDALExtendedDataTypeHS_Create(GDALDataType dt){
6307 return GDALExtendedDataTypeCreate(dt);
6308 }
GDALExtendedDataTypeHS_CreateString(size_t nMaxStringLength=0)6309 SWIGINTERN GDALExtendedDataTypeHS *GDALExtendedDataTypeHS_CreateString(size_t nMaxStringLength=0){
6310 return GDALExtendedDataTypeCreateString(nMaxStringLength);
6311 }
GDALExtendedDataTypeHS_CreateCompound(char const * name,size_t nTotalSize,int nComps,GDALEDTComponentHS ** comps)6312 SWIGINTERN GDALExtendedDataTypeHS *GDALExtendedDataTypeHS_CreateCompound(char const *name,size_t nTotalSize,int nComps,GDALEDTComponentHS **comps){
6313 return GDALExtendedDataTypeCreateCompound(name, nTotalSize, nComps, comps);
6314 }
GDALExtendedDataTypeHS_GetName(GDALExtendedDataTypeHS * self)6315 SWIGINTERN char const *GDALExtendedDataTypeHS_GetName(GDALExtendedDataTypeHS *self){
6316 return GDALExtendedDataTypeGetName(self);
6317 }
GDALExtendedDataTypeHS_GetClass(GDALExtendedDataTypeHS * self)6318 SWIGINTERN GDALExtendedDataTypeClass GDALExtendedDataTypeHS_GetClass(GDALExtendedDataTypeHS *self){
6319 return GDALExtendedDataTypeGetClass(self);
6320 }
GDALExtendedDataTypeHS_GetNumericDataType(GDALExtendedDataTypeHS * self)6321 SWIGINTERN GDALDataType GDALExtendedDataTypeHS_GetNumericDataType(GDALExtendedDataTypeHS *self){
6322 return GDALExtendedDataTypeGetNumericDataType(self);
6323 }
GDALExtendedDataTypeHS_GetSize(GDALExtendedDataTypeHS * self)6324 SWIGINTERN size_t GDALExtendedDataTypeHS_GetSize(GDALExtendedDataTypeHS *self){
6325 return GDALExtendedDataTypeGetSize(self);
6326 }
GDALExtendedDataTypeHS_GetMaxStringLength(GDALExtendedDataTypeHS * self)6327 SWIGINTERN size_t GDALExtendedDataTypeHS_GetMaxStringLength(GDALExtendedDataTypeHS *self){
6328 return GDALExtendedDataTypeGetMaxStringLength(self);
6329 }
GDALExtendedDataTypeHS_GetComponents(GDALExtendedDataTypeHS * self,GDALEDTComponentHS *** pcomps,size_t * pnCount)6330 SWIGINTERN void GDALExtendedDataTypeHS_GetComponents(GDALExtendedDataTypeHS *self,GDALEDTComponentHS ***pcomps,size_t *pnCount){
6331 *pcomps = GDALExtendedDataTypeGetComponents(self, pnCount);
6332 }
GDALExtendedDataTypeHS_CanConvertTo(GDALExtendedDataTypeHS * self,GDALExtendedDataTypeHS * other)6333 SWIGINTERN bool GDALExtendedDataTypeHS_CanConvertTo(GDALExtendedDataTypeHS *self,GDALExtendedDataTypeHS *other){
6334 return GDALExtendedDataTypeCanConvertTo(self, other);
6335 }
GDALExtendedDataTypeHS_Equals(GDALExtendedDataTypeHS * self,GDALExtendedDataTypeHS * other)6336 SWIGINTERN bool GDALExtendedDataTypeHS_Equals(GDALExtendedDataTypeHS *self,GDALExtendedDataTypeHS *other){
6337 return GDALExtendedDataTypeEquals(self, other);
6338 }
delete_GDALEDTComponentHS(GDALEDTComponentHS * self)6339 SWIGINTERN void delete_GDALEDTComponentHS(GDALEDTComponentHS *self){
6340 GDALEDTComponentRelease(self);
6341 }
GDALEDTComponentHS_Create(char const * name,size_t offset,GDALExtendedDataTypeHS * type)6342 SWIGINTERN GDALEDTComponentHS *GDALEDTComponentHS_Create(char const *name,size_t offset,GDALExtendedDataTypeHS *type){
6343 return GDALEDTComponentCreate(name, offset, type);
6344 }
GDALEDTComponentHS_GetName(GDALEDTComponentHS * self)6345 SWIGINTERN char const *GDALEDTComponentHS_GetName(GDALEDTComponentHS *self){
6346 return GDALEDTComponentGetName(self);
6347 }
GDALEDTComponentHS_GetOffset(GDALEDTComponentHS * self)6348 SWIGINTERN size_t GDALEDTComponentHS_GetOffset(GDALEDTComponentHS *self){
6349 return GDALEDTComponentGetOffset(self);
6350 }
GDALEDTComponentHS_GetType(GDALEDTComponentHS * self)6351 SWIGINTERN GDALExtendedDataTypeHS *GDALEDTComponentHS_GetType(GDALEDTComponentHS *self){
6352 return GDALEDTComponentGetType(self);
6353 }
6354
6355 /* Returned size is in bytes or 0 if an error occurred. */
6356 static
ComputeBandRasterIOSize(int buf_xsize,int buf_ysize,int nPixelSize,GIntBig nPixelSpace,GIntBig nLineSpace,int bSpacingShouldBeMultipleOfPixelSize)6357 GIntBig ComputeBandRasterIOSize (int buf_xsize, int buf_ysize, int nPixelSize,
6358 GIntBig nPixelSpace, GIntBig nLineSpace,
6359 int bSpacingShouldBeMultipleOfPixelSize )
6360 {
6361 if (buf_xsize <= 0 || buf_ysize <= 0)
6362 {
6363 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal values for buffer size");
6364 return 0;
6365 }
6366
6367 if (nPixelSpace < 0 || nLineSpace < 0)
6368 {
6369 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal values for space arguments");
6370 return 0;
6371 }
6372
6373 if (nPixelSize == 0)
6374 {
6375 CPLError(CE_Failure, CPLE_IllegalArg, "Illegal value for data type");
6376 return 0;
6377 }
6378
6379 if( nPixelSpace == 0 )
6380 nPixelSpace = nPixelSize;
6381 else if ( bSpacingShouldBeMultipleOfPixelSize && (nPixelSpace % nPixelSize) != 0 )
6382 {
6383 CPLError(CE_Failure, CPLE_IllegalArg, "nPixelSpace should be a multiple of nPixelSize");
6384 return 0;
6385 }
6386
6387 if( nLineSpace == 0 )
6388 {
6389 nLineSpace = nPixelSpace * buf_xsize;
6390 }
6391 else if ( bSpacingShouldBeMultipleOfPixelSize && (nLineSpace % nPixelSize) != 0 )
6392 {
6393 CPLError(CE_Failure, CPLE_IllegalArg, "nLineSpace should be a multiple of nPixelSize");
6394 return 0;
6395 }
6396
6397 GIntBig nRet = (GIntBig)(buf_ysize - 1) * nLineSpace + (GIntBig)(buf_xsize - 1) * nPixelSpace + nPixelSize;
6398 #if SIZEOF_VOIDP == 4
6399 if (nRet > INT_MAX)
6400 {
6401 CPLError(CE_Failure, CPLE_IllegalArg, "Integer overflow");
6402 return 0;
6403 }
6404 #endif
6405
6406 return nRet;
6407 }
6408
6409
6410 static
WriteRaster_internal(GDALRasterBandShadow * obj,int xoff,int yoff,int xsize,int ysize,int buf_xsize,int buf_ysize,GDALDataType buf_type,GIntBig buf_size,char * buffer,GIntBig pixel_space,GIntBig line_space,GDALRasterIOExtraArg * psExtraArg)6411 CPLErr WriteRaster_internal( GDALRasterBandShadow *obj,
6412 int xoff, int yoff, int xsize, int ysize,
6413 int buf_xsize, int buf_ysize,
6414 GDALDataType buf_type,
6415 GIntBig buf_size, char *buffer,
6416 GIntBig pixel_space, GIntBig line_space,
6417 GDALRasterIOExtraArg* psExtraArg )
6418 {
6419 GIntBig min_buffer_size = ComputeBandRasterIOSize (buf_xsize, buf_ysize, GDALGetDataTypeSize( buf_type ) / 8,
6420 pixel_space, line_space, FALSE );
6421 if ( min_buffer_size == 0 )
6422 return CE_Failure;
6423
6424 if ( buf_size < min_buffer_size ) {
6425 CPLError(CE_Failure, CPLE_AppDefined, "Buffer too small");
6426 return CE_Failure;
6427 }
6428
6429 return GDALRasterIOEx( obj, GF_Write, xoff, yoff, xsize, ysize,
6430 (void *) buffer, buf_xsize, buf_ysize, buf_type, pixel_space, line_space, psExtraArg );
6431 }
6432
GDALRasterBandShadow_GetDataset(GDALRasterBandShadow * self)6433 SWIGINTERN GDALDatasetShadow *GDALRasterBandShadow_GetDataset(GDALRasterBandShadow *self){
6434 return (GDALDatasetShadow*) GDALGetBandDataset(self);
6435 }
GDALRasterBandShadow_GetBand(GDALRasterBandShadow * self)6436 SWIGINTERN int GDALRasterBandShadow_GetBand(GDALRasterBandShadow *self){
6437 return GDALGetBandNumber(self);
6438 }
GDALRasterBandShadow_GetBlockSize(GDALRasterBandShadow * self,int * pnBlockXSize,int * pnBlockYSize)6439 SWIGINTERN void GDALRasterBandShadow_GetBlockSize(GDALRasterBandShadow *self,int *pnBlockXSize,int *pnBlockYSize){
6440 GDALGetBlockSize(self, pnBlockXSize, pnBlockYSize);
6441 }
GDALRasterBandShadow_GetActualBlockSize(GDALRasterBandShadow * self,int nXBlockOff,int nYBlockOff,int * pnxvalid,int * pnyvalid,int * pisvalid)6442 SWIGINTERN void GDALRasterBandShadow_GetActualBlockSize(GDALRasterBandShadow *self,int nXBlockOff,int nYBlockOff,int *pnxvalid,int *pnyvalid,int *pisvalid){
6443 *pisvalid = (GDALGetActualBlockSize(self, nXBlockOff, nYBlockOff, pnxvalid, pnyvalid) == CE_None);
6444 }
GDALRasterBandShadow_GetColorInterpretation(GDALRasterBandShadow * self)6445 SWIGINTERN GDALColorInterp GDALRasterBandShadow_GetColorInterpretation(GDALRasterBandShadow *self){
6446 return GDALGetRasterColorInterpretation(self);
6447 }
GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow * self)6448 SWIGINTERN GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){
6449 return GDALGetRasterColorInterpretation(self);
6450 }
GDALRasterBandShadow_SetColorInterpretation(GDALRasterBandShadow * self,GDALColorInterp val)6451 SWIGINTERN CPLErr GDALRasterBandShadow_SetColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){
6452 return GDALSetRasterColorInterpretation( self, val );
6453 }
GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow * self,GDALColorInterp val)6454 SWIGINTERN CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){
6455 return GDALSetRasterColorInterpretation( self, val );
6456 }
GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow * self,double * val,int * hasval)6457 SWIGINTERN void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){
6458 *val = GDALGetRasterNoDataValue( self, hasval );
6459 }
GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow * self,double d)6460 SWIGINTERN CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){
6461 return GDALSetRasterNoDataValue( self, d );
6462 }
GDALRasterBandShadow_DeleteNoDataValue(GDALRasterBandShadow * self)6463 SWIGINTERN CPLErr GDALRasterBandShadow_DeleteNoDataValue(GDALRasterBandShadow *self){
6464 return GDALDeleteRasterNoDataValue(self);
6465 }
GDALRasterBandShadow_GetUnitType(GDALRasterBandShadow * self)6466 SWIGINTERN char const *GDALRasterBandShadow_GetUnitType(GDALRasterBandShadow *self){
6467 return GDALGetRasterUnitType(self);
6468 }
GDALRasterBandShadow_SetUnitType(GDALRasterBandShadow * self,char const * val)6469 SWIGINTERN CPLErr GDALRasterBandShadow_SetUnitType(GDALRasterBandShadow *self,char const *val){
6470 return GDALSetRasterUnitType( self, val );
6471 }
GDALRasterBandShadow_GetRasterCategoryNames(GDALRasterBandShadow * self)6472 SWIGINTERN char **GDALRasterBandShadow_GetRasterCategoryNames(GDALRasterBandShadow *self){
6473 return GDALGetRasterCategoryNames(self);
6474 }
GDALRasterBandShadow_SetRasterCategoryNames(GDALRasterBandShadow * self,char ** names)6475 SWIGINTERN CPLErr GDALRasterBandShadow_SetRasterCategoryNames(GDALRasterBandShadow *self,char **names){
6476 return GDALSetRasterCategoryNames( self, names );
6477 }
GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow * self,double * val,int * hasval)6478 SWIGINTERN void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){
6479 *val = GDALGetRasterMinimum( self, hasval );
6480 }
GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow * self,double * val,int * hasval)6481 SWIGINTERN void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){
6482 *val = GDALGetRasterMaximum( self, hasval );
6483 }
GDALRasterBandShadow_GetOffset(GDALRasterBandShadow * self,double * val,int * hasval)6484 SWIGINTERN void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){
6485 *val = GDALGetRasterOffset( self, hasval );
6486 }
GDALRasterBandShadow_GetScale(GDALRasterBandShadow * self,double * val,int * hasval)6487 SWIGINTERN void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){
6488 *val = GDALGetRasterScale( self, hasval );
6489 }
GDALRasterBandShadow_SetOffset(GDALRasterBandShadow * self,double val)6490 SWIGINTERN CPLErr GDALRasterBandShadow_SetOffset(GDALRasterBandShadow *self,double val){
6491 return GDALSetRasterOffset( self, val );
6492 }
GDALRasterBandShadow_SetScale(GDALRasterBandShadow * self,double val)6493 SWIGINTERN CPLErr GDALRasterBandShadow_SetScale(GDALRasterBandShadow *self,double val){
6494 return GDALSetRasterScale( self, val );
6495 }
GDALRasterBandShadow_GetStatistics(GDALRasterBandShadow * self,int approx_ok,int force,double * min,double * max,double * mean,double * stddev)6496 SWIGINTERN CPLErr GDALRasterBandShadow_GetStatistics(GDALRasterBandShadow *self,int approx_ok,int force,double *min,double *max,double *mean,double *stddev){
6497 if (min) *min = 0;
6498 if (max) *max = 0;
6499 if (mean) *mean = 0;
6500 if (stddev) *stddev = -1; /* This is the only way to recognize from Python if GetRasterStatistics() has updated the values */
6501 return GDALGetRasterStatistics( self, approx_ok, force,
6502 min, max, mean, stddev );
6503 }
GDALRasterBandShadow_ComputeStatistics(GDALRasterBandShadow * self,bool approx_ok,double * min=NULL,double * max=NULL,double * mean=NULL,double * stddev=NULL,GDALProgressFunc callback=NULL,void * callback_data=NULL)6504 SWIGINTERN CPLErr GDALRasterBandShadow_ComputeStatistics(GDALRasterBandShadow *self,bool approx_ok,double *min=NULL,double *max=NULL,double *mean=NULL,double *stddev=NULL,GDALProgressFunc callback=NULL,void *callback_data=NULL){
6505 return GDALComputeRasterStatistics( self, approx_ok, min, max, mean, stddev, callback, callback_data );
6506 }
GDALRasterBandShadow_SetStatistics(GDALRasterBandShadow * self,double min,double max,double mean,double stddev)6507 SWIGINTERN CPLErr GDALRasterBandShadow_SetStatistics(GDALRasterBandShadow *self,double min,double max,double mean,double stddev){
6508 return GDALSetRasterStatistics( self, min, max, mean, stddev );
6509 }
GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow * self)6510 SWIGINTERN int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){
6511 return GDALGetOverviewCount(self);
6512 }
GDALRasterBandShadow_GetOverview(GDALRasterBandShadow * self,int i)6513 SWIGINTERN GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){
6514 return (GDALRasterBandShadow*) GDALGetOverview( self, i );
6515 }
GDALRasterBandShadow_Checksum(GDALRasterBandShadow * self,int xoff=0,int yoff=0,int * xsize=0,int * ysize=0)6516 SWIGINTERN int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){
6517 int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self );
6518 int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self );
6519 return GDALChecksumImage( self, xoff, yoff, nxsize, nysize );
6520 }
GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow * self,double argout[2],int approx_ok=0)6521 SWIGINTERN void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){
6522 GDALComputeRasterMinMax( self, approx_ok, argout );
6523 }
GDALRasterBandShadow_ComputeBandStats(GDALRasterBandShadow * self,double argout[2],int samplestep=1)6524 SWIGINTERN void GDALRasterBandShadow_ComputeBandStats(GDALRasterBandShadow *self,double argout[2],int samplestep=1){
6525 GDALComputeBandStats( self, samplestep, argout+0, argout+1,
6526 NULL, NULL );
6527 }
GDALRasterBandShadow_Fill(GDALRasterBandShadow * self,double real_fill,double imag_fill=0.0)6528 SWIGINTERN CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){
6529 return GDALFillRaster( self, real_fill, imag_fill );
6530 }
GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow * self,int xoff,int yoff,int xsize,int ysize,GIntBig buf_len,char * buf_string,int * buf_xsize=0,int * buf_ysize=0,GDALDataType * buf_type=0,GIntBig * buf_pixel_space=0,GIntBig * buf_line_space=0)6531 SWIGINTERN CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,GIntBig buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,GIntBig *buf_pixel_space=0,GIntBig *buf_line_space=0){
6532 int nxsize = (buf_xsize==0) ? xsize : *buf_xsize;
6533 int nysize = (buf_ysize==0) ? ysize : *buf_ysize;
6534 GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self)
6535 : *buf_type;
6536 GIntBig pixel_space = (buf_pixel_space == 0) ? 0 : *buf_pixel_space;
6537 GIntBig line_space = (buf_line_space == 0) ? 0 : *buf_line_space;
6538 GDALRasterIOExtraArg* psExtraArg = NULL;
6539 return WriteRaster_internal( self, xoff, yoff, xsize, ysize,
6540 nxsize, nysize, ntype, buf_len, buf_string, pixel_space, line_space, psExtraArg );
6541 }
GDALRasterBandShadow_FlushCache(GDALRasterBandShadow * self)6542 SWIGINTERN void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){
6543 GDALFlushRasterCache( self );
6544 }
GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow * self)6545 SWIGINTERN GDALColorTableShadow *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){
6546 return (GDALColorTableShadow*) GDALGetRasterColorTable( self );
6547 }
GDALRasterBandShadow_GetColorTable(GDALRasterBandShadow * self)6548 SWIGINTERN GDALColorTableShadow *GDALRasterBandShadow_GetColorTable(GDALRasterBandShadow *self){
6549 return (GDALColorTableShadow*) GDALGetRasterColorTable( self );
6550 }
GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow * self,GDALColorTableShadow * arg)6551 SWIGINTERN int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTableShadow *arg){
6552 return GDALSetRasterColorTable( self, arg );
6553 }
GDALRasterBandShadow_SetColorTable(GDALRasterBandShadow * self,GDALColorTableShadow * arg)6554 SWIGINTERN int GDALRasterBandShadow_SetColorTable(GDALRasterBandShadow *self,GDALColorTableShadow *arg){
6555 return GDALSetRasterColorTable( self, arg );
6556 }
GDALRasterBandShadow_GetDefaultRAT(GDALRasterBandShadow * self)6557 SWIGINTERN GDALRasterAttributeTableShadow *GDALRasterBandShadow_GetDefaultRAT(GDALRasterBandShadow *self){
6558 return (GDALRasterAttributeTableShadow*) GDALGetDefaultRAT(self);
6559 }
GDALRasterBandShadow_SetDefaultRAT(GDALRasterBandShadow * self,GDALRasterAttributeTableShadow * table)6560 SWIGINTERN int GDALRasterBandShadow_SetDefaultRAT(GDALRasterBandShadow *self,GDALRasterAttributeTableShadow *table){
6561 return GDALSetDefaultRAT(self, table);
6562 }
GDALRasterBandShadow_GetMaskBand(GDALRasterBandShadow * self)6563 SWIGINTERN GDALRasterBandShadow *GDALRasterBandShadow_GetMaskBand(GDALRasterBandShadow *self){
6564 return (GDALRasterBandShadow *) GDALGetMaskBand( self );
6565 }
GDALRasterBandShadow_GetMaskFlags(GDALRasterBandShadow * self)6566 SWIGINTERN int GDALRasterBandShadow_GetMaskFlags(GDALRasterBandShadow *self){
6567 return GDALGetMaskFlags( self );
6568 }
GDALRasterBandShadow_CreateMaskBand(GDALRasterBandShadow * self,int nFlags)6569 SWIGINTERN CPLErr GDALRasterBandShadow_CreateMaskBand(GDALRasterBandShadow *self,int nFlags){
6570 return GDALCreateMaskBand( self, nFlags );
6571 }
GDALRasterBandShadow_GetHistogram(GDALRasterBandShadow * self,double min=-0.5,double max=255.5,int buckets=256,GUIntBig * panHistogram=NULL,int include_out_of_range=0,int approx_ok=1,GDALProgressFunc callback=NULL,void * callback_data=NULL)6572 SWIGINTERN CPLErr GDALRasterBandShadow_GetHistogram(GDALRasterBandShadow *self,double min=-0.5,double max=255.5,int buckets=256,GUIntBig *panHistogram=NULL,int include_out_of_range=0,int approx_ok=1,GDALProgressFunc callback=NULL,void *callback_data=NULL){
6573 CPLErrorReset();
6574 CPLErr err = GDALGetRasterHistogramEx( self, min, max, buckets, panHistogram,
6575 include_out_of_range, approx_ok,
6576 callback, callback_data );
6577 return err;
6578 }
GDALRasterBandShadow_GetDefaultHistogram(GDALRasterBandShadow * self,double * min_ret=NULL,double * max_ret=NULL,int * buckets_ret=NULL,GUIntBig ** ppanHistogram=NULL,int force=1,GDALProgressFunc callback=NULL,void * callback_data=NULL)6579 SWIGINTERN CPLErr GDALRasterBandShadow_GetDefaultHistogram(GDALRasterBandShadow *self,double *min_ret=NULL,double *max_ret=NULL,int *buckets_ret=NULL,GUIntBig **ppanHistogram=NULL,int force=1,GDALProgressFunc callback=NULL,void *callback_data=NULL){
6580 return GDALGetDefaultHistogramEx( self, min_ret, max_ret, buckets_ret,
6581 ppanHistogram, force,
6582 callback, callback_data );
6583 }
GDALRasterBandShadow_SetDefaultHistogram(GDALRasterBandShadow * self,double min,double max,int buckets_in,GUIntBig * panHistogram_in)6584 SWIGINTERN CPLErr GDALRasterBandShadow_SetDefaultHistogram(GDALRasterBandShadow *self,double min,double max,int buckets_in,GUIntBig *panHistogram_in){
6585 return GDALSetDefaultHistogramEx( self, min, max,
6586 buckets_in, panHistogram_in );
6587 }
GDALRasterBandShadow_HasArbitraryOverviews(GDALRasterBandShadow * self)6588 SWIGINTERN bool GDALRasterBandShadow_HasArbitraryOverviews(GDALRasterBandShadow *self){
6589 return (GDALHasArbitraryOverviews( self ) != 0) ? true : false;
6590 }
GDALRasterBandShadow_GetCategoryNames(GDALRasterBandShadow * self)6591 SWIGINTERN char **GDALRasterBandShadow_GetCategoryNames(GDALRasterBandShadow *self){
6592 return GDALGetRasterCategoryNames( self );
6593 }
GDALRasterBandShadow_SetCategoryNames(GDALRasterBandShadow * self,char ** papszCategoryNames)6594 SWIGINTERN CPLErr GDALRasterBandShadow_SetCategoryNames(GDALRasterBandShadow *self,char **papszCategoryNames){
6595 return GDALSetRasterCategoryNames( self, papszCategoryNames );
6596 }
GDALRasterBandShadow_GetVirtualMem(GDALRasterBandShadow * self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,size_t nCacheSize,size_t nPageSizeHint,char ** options=NULL)6597 SWIGINTERN CPLVirtualMemShadow *GDALRasterBandShadow_GetVirtualMem(GDALRasterBandShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,size_t nCacheSize,size_t nPageSizeHint,char **options=NULL){
6598 CPLVirtualMem* vmem = GDALRasterBandGetVirtualMem( self,
6599 eRWFlag,
6600 nXOff, nYOff,
6601 nXSize, nYSize,
6602 nBufXSize, nBufYSize,
6603 eBufType,
6604 0,
6605 0,
6606 nCacheSize,
6607 nPageSizeHint,
6608 FALSE,
6609 options );
6610 if( vmem == NULL )
6611 return NULL;
6612 CPLVirtualMemShadow* vmemshadow = (CPLVirtualMemShadow*)calloc(1, sizeof(CPLVirtualMemShadow));
6613 vmemshadow->vmem = vmem;
6614 vmemshadow->eBufType = eBufType;
6615 vmemshadow->bIsBandSequential = TRUE;
6616 vmemshadow->bReadOnly = (eRWFlag == GF_Read);
6617 vmemshadow->nBufXSize = nBufXSize;
6618 vmemshadow->nBufYSize = nBufYSize;
6619 vmemshadow->nBandCount = 1;
6620 return vmemshadow;
6621 }
GDALRasterBandShadow_GetVirtualMemAuto(GDALRasterBandShadow * self,GDALRWFlag eRWFlag,char ** options=NULL)6622 SWIGINTERN CPLVirtualMemShadow *GDALRasterBandShadow_GetVirtualMemAuto(GDALRasterBandShadow *self,GDALRWFlag eRWFlag,char **options=NULL){
6623 int nPixelSpace;
6624 GIntBig nLineSpace;
6625 CPLVirtualMem* vmem = GDALGetVirtualMemAuto( self,
6626 eRWFlag,
6627 &nPixelSpace,
6628 &nLineSpace,
6629 options );
6630 if( vmem == NULL )
6631 return NULL;
6632 CPLVirtualMemShadow* vmemshadow = (CPLVirtualMemShadow*)calloc(1, sizeof(CPLVirtualMemShadow));
6633 vmemshadow->vmem = vmem;
6634 vmemshadow->eBufType = GDALGetRasterDataType( self );
6635 vmemshadow->bAuto = TRUE;
6636 vmemshadow->bReadOnly = (eRWFlag == GF_Read);
6637 vmemshadow->nBandCount = 1;
6638 vmemshadow->nPixelSpace = nPixelSpace;
6639 vmemshadow->nLineSpace = nLineSpace;
6640 vmemshadow->nBufXSize = GDALGetRasterBandXSize(self);
6641 vmemshadow->nBufYSize = GDALGetRasterBandYSize(self);
6642 return vmemshadow;
6643 }
GDALRasterBandShadow_GetTiledVirtualMem(GDALRasterBandShadow * self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,size_t nCacheSize,char ** options=NULL)6644 SWIGINTERN CPLVirtualMemShadow *GDALRasterBandShadow_GetTiledVirtualMem(GDALRasterBandShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,size_t nCacheSize,char **options=NULL){
6645 CPLVirtualMem* vmem = GDALRasterBandGetTiledVirtualMem( self,
6646 eRWFlag,
6647 nXOff, nYOff,
6648 nXSize, nYSize,
6649 nTileXSize, nTileYSize,
6650 eBufType,
6651 nCacheSize,
6652 FALSE,
6653 options );
6654 if( vmem == NULL )
6655 return NULL;
6656 CPLVirtualMemShadow* vmemshadow = (CPLVirtualMemShadow*)calloc(1, sizeof(CPLVirtualMemShadow));
6657 vmemshadow->vmem = vmem;
6658 vmemshadow->eBufType = eBufType;
6659 vmemshadow->bIsBandSequential = -1;
6660 vmemshadow->bReadOnly = (eRWFlag == GF_Read);
6661 vmemshadow->nBufXSize = nXSize;
6662 vmemshadow->nBufYSize = nYSize;
6663 vmemshadow->eTileOrganization = GTO_BSQ;
6664 vmemshadow->nTileXSize = nTileXSize;
6665 vmemshadow->nTileYSize = nTileYSize;
6666 vmemshadow->nBandCount = 1;
6667 return vmemshadow;
6668 }
GDALRasterBandShadow_GetDataCoverageStatus(GDALRasterBandShadow * self,int nXOff,int nYOff,int nXSize,int nYSize,int nMaskFlagStop=0,double * pdfDataPct=NULL)6669 SWIGINTERN int GDALRasterBandShadow_GetDataCoverageStatus(GDALRasterBandShadow *self,int nXOff,int nYOff,int nXSize,int nYSize,int nMaskFlagStop=0,double *pdfDataPct=NULL){
6670 return GDALGetDataCoverageStatus(self, nXOff, nYOff,
6671 nXSize, nYSize,
6672 nMaskFlagStop,
6673 pdfDataPct);
6674 }
GDALRasterBandShadow_AdviseRead(GDALRasterBandShadow * self,int xoff,int yoff,int xsize,int ysize,int * buf_xsize=0,int * buf_ysize=0,GDALDataType * buf_type=0,char ** options=NULL)6675 SWIGINTERN CPLErr GDALRasterBandShadow_AdviseRead(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,char **options=NULL){
6676 int nxsize = (buf_xsize==0) ? xsize : *buf_xsize;
6677 int nysize = (buf_ysize==0) ? ysize : *buf_ysize;
6678 GDALDataType ntype;
6679 if ( buf_type != 0 ) {
6680 ntype = (GDALDataType) *buf_type;
6681 } else {
6682 ntype = GDALGetRasterDataType( self );
6683 }
6684 return GDALRasterAdviseRead(self, xoff, yoff, xsize, ysize,
6685 nxsize, nysize, ntype, options);
6686 }
GDALRasterBandShadow_AsMDArray(GDALRasterBandShadow * self)6687