~ubuntu-branches/ubuntu/oneiric/python-scipy/oneiric-proposed

« back to all changes in this revision

Viewing changes to scipy/sparse/sparsetools/csgraph_wrap.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 21:26:25 UTC
  • mfrom: (9.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110406212625-3izdplobqe6fzeql
Tags: 0.9.0+dfsg1-1
* New upstream release (Closes: #614407, #579041, #569008)
* Convert to dh_python2 (Closes: #617028)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ----------------------------------------------------------------------------
 
2
 * This file was automatically generated by SWIG (http://www.swig.org).
 
3
 * Version 2.0.1+capsulehack
 
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
#define SWIGPYTHON
 
12
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
 
13
 
 
14
 
 
15
#ifdef __cplusplus
 
16
/* SwigValueWrapper is described in swig.swg */
 
17
template<typename T> class SwigValueWrapper {
 
18
  struct SwigMovePointer {
 
19
    T *ptr;
 
20
    SwigMovePointer(T *p) : ptr(p) { }
 
21
    ~SwigMovePointer() { delete ptr; }
 
22
    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
 
23
  } pointer;
 
24
  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
 
25
  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
 
26
public:
 
27
  SwigValueWrapper() : pointer(0) { }
 
28
  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
 
29
  operator T&() const { return *pointer.ptr; }
 
30
  T *operator&() { return pointer.ptr; }
 
31
};
 
32
 
 
33
template <typename T> T SwigValueInit() {
 
34
  return T();
 
35
}
 
36
#endif
 
37
 
 
38
/* -----------------------------------------------------------------------------
 
39
 *  This section contains generic SWIG labels for method/variable
 
40
 *  declarations/attributes, and other compiler dependent labels.
 
41
 * ----------------------------------------------------------------------------- */
 
42
 
 
43
/* template workaround for compilers that cannot correctly implement the C++ standard */
 
44
#ifndef SWIGTEMPLATEDISAMBIGUATOR
 
45
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
 
46
#  define SWIGTEMPLATEDISAMBIGUATOR template
 
47
# elif defined(__HP_aCC)
 
48
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
 
49
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
 
50
#  define SWIGTEMPLATEDISAMBIGUATOR template
 
51
# else
 
52
#  define SWIGTEMPLATEDISAMBIGUATOR
 
53
# endif
 
54
#endif
 
55
 
 
56
/* inline attribute */
 
57
#ifndef SWIGINLINE
 
58
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
 
59
#   define SWIGINLINE inline
 
60
# else
 
61
#   define SWIGINLINE
 
62
# endif
 
63
#endif
 
64
 
 
65
/* attribute recognised by some compilers to avoid 'unused' warnings */
 
66
#ifndef SWIGUNUSED
 
67
# if defined(__GNUC__)
 
68
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
 
69
#     define SWIGUNUSED __attribute__ ((__unused__)) 
 
70
#   else
 
71
#     define SWIGUNUSED
 
72
#   endif
 
73
# elif defined(__ICC)
 
74
#   define SWIGUNUSED __attribute__ ((__unused__)) 
 
75
# else
 
76
#   define SWIGUNUSED 
 
77
# endif
 
78
#endif
 
79
 
 
80
#ifndef SWIG_MSC_UNSUPPRESS_4505
 
81
# if defined(_MSC_VER)
 
82
#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
 
83
# endif 
 
84
#endif
 
85
 
 
86
#ifndef SWIGUNUSEDPARM
 
87
# ifdef __cplusplus
 
88
#   define SWIGUNUSEDPARM(p)
 
89
# else
 
90
#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
 
91
# endif
 
92
#endif
 
93
 
 
94
/* internal SWIG method */
 
95
#ifndef SWIGINTERN
 
96
# define SWIGINTERN static SWIGUNUSED
 
97
#endif
 
98
 
 
99
/* internal inline SWIG method */
 
100
#ifndef SWIGINTERNINLINE
 
101
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
 
102
#endif
 
103
 
 
104
/* exporting methods */
 
105
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
 
106
#  ifndef GCC_HASCLASSVISIBILITY
 
107
#    define GCC_HASCLASSVISIBILITY
 
108
#  endif
 
109
#endif
 
110
 
 
111
#ifndef SWIGEXPORT
 
112
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 
113
#   if defined(STATIC_LINKED)
 
114
#     define SWIGEXPORT
 
115
#   else
 
116
#     define SWIGEXPORT __declspec(dllexport)
 
117
#   endif
 
118
# else
 
119
#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
 
120
#     define SWIGEXPORT __attribute__ ((visibility("default")))
 
121
#   else
 
122
#     define SWIGEXPORT
 
123
#   endif
 
124
# endif
 
125
#endif
 
126
 
 
127
/* calling conventions for Windows */
 
128
#ifndef SWIGSTDCALL
 
129
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 
130
#   define SWIGSTDCALL __stdcall
 
131
# else
 
132
#   define SWIGSTDCALL
 
133
# endif 
 
134
#endif
 
135
 
 
136
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
 
137
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
 
138
# define _CRT_SECURE_NO_DEPRECATE
 
139
#endif
 
140
 
 
141
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
 
142
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
 
143
# define _SCL_SECURE_NO_DEPRECATE
 
144
#endif
 
145
 
 
146
 
 
147
 
 
148
/* Python.h has to appear first */
 
149
#include <Python.h>
 
150
 
 
151
/* -----------------------------------------------------------------------------
 
152
 * swigrun.swg
 
153
 *
 
154
 * This file contains generic C API SWIG runtime support for pointer
 
155
 * type checking.
 
156
 * ----------------------------------------------------------------------------- */
 
157
 
 
158
/* This should only be incremented when either the layout of swig_type_info changes,
 
159
   or for whatever reason, the runtime changes incompatibly */
 
160
#define SWIG_RUNTIME_VERSION "4"
 
161
 
 
162
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
 
163
#ifdef SWIG_TYPE_TABLE
 
164
# define SWIG_QUOTE_STRING(x) #x
 
165
# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
 
166
# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
 
167
#else
 
168
# define SWIG_TYPE_TABLE_NAME
 
169
#endif
 
170
 
 
171
/*
 
172
  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
 
173
  creating a static or dynamic library from the SWIG runtime code.
 
174
  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
 
175
  
 
176
  But only do this if strictly necessary, ie, if you have problems
 
177
  with your compiler or suchlike.
 
178
*/
 
179
 
 
180
#ifndef SWIGRUNTIME
 
181
# define SWIGRUNTIME SWIGINTERN
 
182
#endif
 
183
 
 
184
#ifndef SWIGRUNTIMEINLINE
 
185
# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
 
186
#endif
 
187
 
 
188
/*  Generic buffer size */
 
189
#ifndef SWIG_BUFFER_SIZE
 
190
# define SWIG_BUFFER_SIZE 1024
 
191
#endif
 
192
 
 
193
/* Flags for pointer conversions */
 
194
#define SWIG_POINTER_DISOWN        0x1
 
195
#define SWIG_CAST_NEW_MEMORY       0x2
 
196
 
 
197
/* Flags for new pointer objects */
 
198
#define SWIG_POINTER_OWN           0x1
 
199
 
 
200
 
 
201
/* 
 
202
   Flags/methods for returning states.
 
203
   
 
204
   The SWIG conversion methods, as ConvertPtr, return an integer 
 
205
   that tells if the conversion was successful or not. And if not,
 
206
   an error code can be returned (see swigerrors.swg for the codes).
 
207
   
 
208
   Use the following macros/flags to set or process the returning
 
209
   states.
 
210
   
 
211
   In old versions of SWIG, code such as the following was usually written:
 
212
 
 
213
     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
 
214
       // success code
 
215
     } else {
 
216
       //fail code
 
217
     }
 
218
 
 
219
   Now you can be more explicit:
 
220
 
 
221
    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
 
222
    if (SWIG_IsOK(res)) {
 
223
      // success code
 
224
    } else {
 
225
      // fail code
 
226
    }
 
227
 
 
228
   which is the same really, but now you can also do
 
229
 
 
230
    Type *ptr;
 
231
    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
 
232
    if (SWIG_IsOK(res)) {
 
233
      // success code
 
234
      if (SWIG_IsNewObj(res) {
 
235
        ...
 
236
        delete *ptr;
 
237
      } else {
 
238
        ...
 
239
      }
 
240
    } else {
 
241
      // fail code
 
242
    }
 
243
    
 
244
   I.e., now SWIG_ConvertPtr can return new objects and you can
 
245
   identify the case and take care of the deallocation. Of course that
 
246
   also requires SWIG_ConvertPtr to return new result values, such as
 
247
 
 
248
      int SWIG_ConvertPtr(obj, ptr,...) {         
 
249
        if (<obj is ok>) {                             
 
250
          if (<need new object>) {                     
 
251
            *ptr = <ptr to new allocated object>; 
 
252
            return SWIG_NEWOBJ;                
 
253
          } else {                                     
 
254
            *ptr = <ptr to old object>;        
 
255
            return SWIG_OLDOBJ;                
 
256
          }                                    
 
257
        } else {                                       
 
258
          return SWIG_BADOBJ;                  
 
259
        }                                              
 
260
      }
 
261
 
 
262
   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
 
263
   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
 
264
   SWIG errors code.
 
265
 
 
266
   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
 
267
   allows to return the 'cast rank', for example, if you have this
 
268
 
 
269
       int food(double)
 
270
       int fooi(int);
 
271
 
 
272
   and you call
 
273
 
 
274
      food(1)   // cast rank '1'  (1 -> 1.0)
 
275
      fooi(1)   // cast rank '0'
 
276
 
 
277
   just use the SWIG_AddCast()/SWIG_CheckState()
 
278
*/
 
279
 
 
280
#define SWIG_OK                    (0) 
 
281
#define SWIG_ERROR                 (-1)
 
282
#define SWIG_IsOK(r)               (r >= 0)
 
283
#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
 
284
 
 
285
/* The CastRankLimit says how many bits are used for the cast rank */
 
286
#define SWIG_CASTRANKLIMIT         (1 << 8)
 
287
/* The NewMask denotes the object was created (using new/malloc) */
 
288
#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
 
289
/* The TmpMask is for in/out typemaps that use temporal objects */
 
290
#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
 
291
/* Simple returning values */
 
292
#define SWIG_BADOBJ                (SWIG_ERROR)
 
293
#define SWIG_OLDOBJ                (SWIG_OK)
 
294
#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
 
295
#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
 
296
/* Check, add and del mask methods */
 
297
#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
 
298
#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
 
299
#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
 
300
#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
 
301
#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
 
302
#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
 
303
 
 
304
/* Cast-Rank Mode */
 
305
#if defined(SWIG_CASTRANK_MODE)
 
306
#  ifndef SWIG_TypeRank
 
307
#    define SWIG_TypeRank             unsigned long
 
308
#  endif
 
309
#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
 
310
#    define SWIG_MAXCASTRANK          (2)
 
311
#  endif
 
312
#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
 
313
#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
 
314
SWIGINTERNINLINE int SWIG_AddCast(int r) { 
 
315
  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
 
316
}
 
317
SWIGINTERNINLINE int SWIG_CheckState(int r) { 
 
318
  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
 
319
}
 
320
#else /* no cast-rank mode */
 
321
#  define SWIG_AddCast
 
322
#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
 
323
#endif
 
324
 
 
325
 
 
326
#include <string.h>
 
327
 
 
328
#ifdef __cplusplus
 
329
extern "C" {
 
330
#endif
 
331
 
 
332
typedef void *(*swig_converter_func)(void *, int *);
 
333
typedef struct swig_type_info *(*swig_dycast_func)(void **);
 
334
 
 
335
/* Structure to store information on one type */
 
336
typedef struct swig_type_info {
 
337
  const char             *name;                 /* mangled name of this type */
 
338
  const char             *str;                  /* human readable name of this type */
 
339
  swig_dycast_func        dcast;                /* dynamic cast function down a hierarchy */
 
340
  struct swig_cast_info  *cast;                 /* linked list of types that can cast into this type */
 
341
  void                   *clientdata;           /* language specific type data */
 
342
  int                    owndata;               /* flag if the structure owns the clientdata */
 
343
} swig_type_info;
 
344
 
 
345
/* Structure to store a type and conversion function used for casting */
 
346
typedef struct swig_cast_info {
 
347
  swig_type_info         *type;                 /* pointer to type that is equivalent to this type */
 
348
  swig_converter_func     converter;            /* function to cast the void pointers */
 
349
  struct swig_cast_info  *next;                 /* pointer to next cast in linked list */
 
350
  struct swig_cast_info  *prev;                 /* pointer to the previous cast */
 
351
} swig_cast_info;
 
352
 
 
353
/* Structure used to store module information
 
354
 * Each module generates one structure like this, and the runtime collects
 
355
 * all of these structures and stores them in a circularly linked list.*/
 
356
typedef struct swig_module_info {
 
357
  swig_type_info         **types;               /* Array of pointers to swig_type_info structures that are in this module */
 
358
  size_t                 size;                  /* Number of types in this module */
 
359
  struct swig_module_info *next;                /* Pointer to next element in circularly linked list */
 
360
  swig_type_info         **type_initial;        /* Array of initially generated type structures */
 
361
  swig_cast_info         **cast_initial;        /* Array of initially generated casting structures */
 
362
  void                    *clientdata;          /* Language specific module data */
 
363
} swig_module_info;
 
364
 
 
365
/* 
 
366
  Compare two type names skipping the space characters, therefore
 
367
  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
 
368
 
 
369
  Return 0 when the two name types are equivalent, as in
 
370
  strncmp, but skipping ' '.
 
371
*/
 
372
SWIGRUNTIME int
 
373
SWIG_TypeNameComp(const char *f1, const char *l1,
 
374
                  const char *f2, const char *l2) {
 
375
  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
 
376
    while ((*f1 == ' ') && (f1 != l1)) ++f1;
 
377
    while ((*f2 == ' ') && (f2 != l2)) ++f2;
 
378
    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
 
379
  }
 
380
  return (int)((l1 - f1) - (l2 - f2));
 
381
}
 
382
 
 
383
/*
 
384
  Check type equivalence in a name list like <name1>|<name2>|...
 
385
  Return 0 if not equal, 1 if equal
 
386
*/
 
387
SWIGRUNTIME int
 
388
SWIG_TypeEquiv(const char *nb, const char *tb) {
 
389
  int equiv = 0;
 
390
  const char* te = tb + strlen(tb);
 
391
  const char* ne = nb;
 
392
  while (!equiv && *ne) {
 
393
    for (nb = ne; *ne; ++ne) {
 
394
      if (*ne == '|') break;
 
395
    }
 
396
    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
 
397
    if (*ne) ++ne;
 
398
  }
 
399
  return equiv;
 
400
}
 
401
 
 
402
/*
 
403
  Check type equivalence in a name list like <name1>|<name2>|...
 
404
  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
 
405
*/
 
406
SWIGRUNTIME int
 
407
SWIG_TypeCompare(const char *nb, const char *tb) {
 
408
  int equiv = 0;
 
409
  const char* te = tb + strlen(tb);
 
410
  const char* ne = nb;
 
411
  while (!equiv && *ne) {
 
412
    for (nb = ne; *ne; ++ne) {
 
413
      if (*ne == '|') break;
 
414
    }
 
415
    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
 
416
    if (*ne) ++ne;
 
417
  }
 
418
  return equiv;
 
419
}
 
420
 
 
421
 
 
422
/*
 
423
  Check the typename
 
424
*/
 
425
SWIGRUNTIME swig_cast_info *
 
426
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
 
427
  if (ty) {
 
428
    swig_cast_info *iter = ty->cast;
 
429
    while (iter) {
 
430
      if (strcmp(iter->type->name, c) == 0) {
 
431
        if (iter == ty->cast)
 
432
          return iter;
 
433
        /* Move iter to the top of the linked list */
 
434
        iter->prev->next = iter->next;
 
435
        if (iter->next)
 
436
          iter->next->prev = iter->prev;
 
437
        iter->next = ty->cast;
 
438
        iter->prev = 0;
 
439
        if (ty->cast) ty->cast->prev = iter;
 
440
        ty->cast = iter;
 
441
        return iter;
 
442
      }
 
443
      iter = iter->next;
 
444
    }
 
445
  }
 
446
  return 0;
 
447
}
 
448
 
 
449
/* 
 
450
  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
 
451
*/
 
452
SWIGRUNTIME swig_cast_info *
 
453
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
 
454
  if (ty) {
 
455
    swig_cast_info *iter = ty->cast;
 
456
    while (iter) {
 
457
      if (iter->type == from) {
 
458
        if (iter == ty->cast)
 
459
          return iter;
 
460
        /* Move iter to the top of the linked list */
 
461
        iter->prev->next = iter->next;
 
462
        if (iter->next)
 
463
          iter->next->prev = iter->prev;
 
464
        iter->next = ty->cast;
 
465
        iter->prev = 0;
 
466
        if (ty->cast) ty->cast->prev = iter;
 
467
        ty->cast = iter;
 
468
        return iter;
 
469
      }
 
470
      iter = iter->next;
 
471
    }
 
472
  }
 
473
  return 0;
 
474
}
 
475
 
 
476
/*
 
477
  Cast a pointer up an inheritance hierarchy
 
478
*/
 
479
SWIGRUNTIMEINLINE void *
 
480
SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
 
481
  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
 
482
}
 
483
 
 
484
/* 
 
485
   Dynamic pointer casting. Down an inheritance hierarchy
 
486
*/
 
487
SWIGRUNTIME swig_type_info *
 
488
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
 
489
  swig_type_info *lastty = ty;
 
490
  if (!ty || !ty->dcast) return ty;
 
491
  while (ty && (ty->dcast)) {
 
492
    ty = (*ty->dcast)(ptr);
 
493
    if (ty) lastty = ty;
 
494
  }
 
495
  return lastty;
 
496
}
 
497
 
 
498
/*
 
499
  Return the name associated with this type
 
500
*/
 
501
SWIGRUNTIMEINLINE const char *
 
502
SWIG_TypeName(const swig_type_info *ty) {
 
503
  return ty->name;
 
504
}
 
505
 
 
506
/*
 
507
  Return the pretty name associated with this type,
 
508
  that is an unmangled type name in a form presentable to the user.
 
509
*/
 
510
SWIGRUNTIME const char *
 
511
SWIG_TypePrettyName(const swig_type_info *type) {
 
512
  /* The "str" field contains the equivalent pretty names of the
 
513
     type, separated by vertical-bar characters.  We choose
 
514
     to print the last name, as it is often (?) the most
 
515
     specific. */
 
516
  if (!type) return NULL;
 
517
  if (type->str != NULL) {
 
518
    const char *last_name = type->str;
 
519
    const char *s;
 
520
    for (s = type->str; *s; s++)
 
521
      if (*s == '|') last_name = s+1;
 
522
    return last_name;
 
523
  }
 
524
  else
 
525
    return type->name;
 
526
}
 
527
 
 
528
/* 
 
529
   Set the clientdata field for a type
 
530
*/
 
531
SWIGRUNTIME void
 
532
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
 
533
  swig_cast_info *cast = ti->cast;
 
534
  /* if (ti->clientdata == clientdata) return; */
 
535
  ti->clientdata = clientdata;
 
536
  
 
537
  while (cast) {
 
538
    if (!cast->converter) {
 
539
      swig_type_info *tc = cast->type;
 
540
      if (!tc->clientdata) {
 
541
        SWIG_TypeClientData(tc, clientdata);
 
542
      }
 
543
    }    
 
544
    cast = cast->next;
 
545
  }
 
546
}
 
547
SWIGRUNTIME void
 
548
SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
 
549
  SWIG_TypeClientData(ti, clientdata);
 
550
  ti->owndata = 1;
 
551
}
 
552
  
 
553
/*
 
554
  Search for a swig_type_info structure only by mangled name
 
555
  Search is a O(log #types)
 
556
  
 
557
  We start searching at module start, and finish searching when start == end.  
 
558
  Note: if start == end at the beginning of the function, we go all the way around
 
559
  the circular list.
 
560
*/
 
561
SWIGRUNTIME swig_type_info *
 
562
SWIG_MangledTypeQueryModule(swig_module_info *start, 
 
563
                            swig_module_info *end, 
 
564
                            const char *name) {
 
565
  swig_module_info *iter = start;
 
566
  do {
 
567
    if (iter->size) {
 
568
      register size_t l = 0;
 
569
      register size_t r = iter->size - 1;
 
570
      do {
 
571
        /* since l+r >= 0, we can (>> 1) instead (/ 2) */
 
572
        register size_t i = (l + r) >> 1; 
 
573
        const char *iname = iter->types[i]->name;
 
574
        if (iname) {
 
575
          register int compare = strcmp(name, iname);
 
576
          if (compare == 0) {       
 
577
            return iter->types[i];
 
578
          } else if (compare < 0) {
 
579
            if (i) {
 
580
              r = i - 1;
 
581
            } else {
 
582
              break;
 
583
            }
 
584
          } else if (compare > 0) {
 
585
            l = i + 1;
 
586
          }
 
587
        } else {
 
588
          break; /* should never happen */
 
589
        }
 
590
      } while (l <= r);
 
591
    }
 
592
    iter = iter->next;
 
593
  } while (iter != end);
 
594
  return 0;
 
595
}
 
596
 
 
597
/*
 
598
  Search for a swig_type_info structure for either a mangled name or a human readable name.
 
599
  It first searches the mangled names of the types, which is a O(log #types)
 
600
  If a type is not found it then searches the human readable names, which is O(#types).
 
601
  
 
602
  We start searching at module start, and finish searching when start == end.  
 
603
  Note: if start == end at the beginning of the function, we go all the way around
 
604
  the circular list.
 
605
*/
 
606
SWIGRUNTIME swig_type_info *
 
607
SWIG_TypeQueryModule(swig_module_info *start, 
 
608
                     swig_module_info *end, 
 
609
                     const char *name) {
 
610
  /* STEP 1: Search the name field using binary search */
 
611
  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
 
612
  if (ret) {
 
613
    return ret;
 
614
  } else {
 
615
    /* STEP 2: If the type hasn't been found, do a complete search
 
616
       of the str field (the human readable name) */
 
617
    swig_module_info *iter = start;
 
618
    do {
 
619
      register size_t i = 0;
 
620
      for (; i < iter->size; ++i) {
 
621
        if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
 
622
          return iter->types[i];
 
623
      }
 
624
      iter = iter->next;
 
625
    } while (iter != end);
 
626
  }
 
627
  
 
628
  /* neither found a match */
 
629
  return 0;
 
630
}
 
631
 
 
632
/* 
 
633
   Pack binary data into a string
 
634
*/
 
635
SWIGRUNTIME char *
 
636
SWIG_PackData(char *c, void *ptr, size_t sz) {
 
637
  static const char hex[17] = "0123456789abcdef";
 
638
  register const unsigned char *u = (unsigned char *) ptr;
 
639
  register const unsigned char *eu =  u + sz;
 
640
  for (; u != eu; ++u) {
 
641
    register unsigned char uu = *u;
 
642
    *(c++) = hex[(uu & 0xf0) >> 4];
 
643
    *(c++) = hex[uu & 0xf];
 
644
  }
 
645
  return c;
 
646
}
 
647
 
 
648
/* 
 
649
   Unpack binary data from a string
 
650
*/
 
651
SWIGRUNTIME const char *
 
652
SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
 
653
  register unsigned char *u = (unsigned char *) ptr;
 
654
  register const unsigned char *eu = u + sz;
 
655
  for (; u != eu; ++u) {
 
656
    register char d = *(c++);
 
657
    register unsigned char uu;
 
658
    if ((d >= '0') && (d <= '9'))
 
659
      uu = ((d - '0') << 4);
 
660
    else if ((d >= 'a') && (d <= 'f'))
 
661
      uu = ((d - ('a'-10)) << 4);
 
662
    else 
 
663
      return (char *) 0;
 
664
    d = *(c++);
 
665
    if ((d >= '0') && (d <= '9'))
 
666
      uu |= (d - '0');
 
667
    else if ((d >= 'a') && (d <= 'f'))
 
668
      uu |= (d - ('a'-10));
 
669
    else 
 
670
      return (char *) 0;
 
671
    *u = uu;
 
672
  }
 
673
  return c;
 
674
}
 
675
 
 
676
/* 
 
677
   Pack 'void *' into a string buffer.
 
678
*/
 
679
SWIGRUNTIME char *
 
680
SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
 
681
  char *r = buff;
 
682
  if ((2*sizeof(void *) + 2) > bsz) return 0;
 
683
  *(r++) = '_';
 
684
  r = SWIG_PackData(r,&ptr,sizeof(void *));
 
685
  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
 
686
  strcpy(r,name);
 
687
  return buff;
 
688
}
 
689
 
 
690
SWIGRUNTIME const char *
 
691
SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
 
692
  if (*c != '_') {
 
693
    if (strcmp(c,"NULL") == 0) {
 
694
      *ptr = (void *) 0;
 
695
      return name;
 
696
    } else {
 
697
      return 0;
 
698
    }
 
699
  }
 
700
  return SWIG_UnpackData(++c,ptr,sizeof(void *));
 
701
}
 
702
 
 
703
SWIGRUNTIME char *
 
704
SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
 
705
  char *r = buff;
 
706
  size_t lname = (name ? strlen(name) : 0);
 
707
  if ((2*sz + 2 + lname) > bsz) return 0;
 
708
  *(r++) = '_';
 
709
  r = SWIG_PackData(r,ptr,sz);
 
710
  if (lname) {
 
711
    strncpy(r,name,lname+1);
 
712
  } else {
 
713
    *r = 0;
 
714
  }
 
715
  return buff;
 
716
}
 
717
 
 
718
SWIGRUNTIME const char *
 
719
SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
 
720
  if (*c != '_') {
 
721
    if (strcmp(c,"NULL") == 0) {
 
722
      memset(ptr,0,sz);
 
723
      return name;
 
724
    } else {
 
725
      return 0;
 
726
    }
 
727
  }
 
728
  return SWIG_UnpackData(++c,ptr,sz);
 
729
}
 
730
 
 
731
#ifdef __cplusplus
 
732
}
 
733
#endif
 
734
 
 
735
/*  Errors in SWIG */
 
736
#define  SWIG_UnknownError         -1 
 
737
#define  SWIG_IOError              -2 
 
738
#define  SWIG_RuntimeError         -3 
 
739
#define  SWIG_IndexError           -4 
 
740
#define  SWIG_TypeError            -5 
 
741
#define  SWIG_DivisionByZero       -6 
 
742
#define  SWIG_OverflowError        -7 
 
743
#define  SWIG_SyntaxError          -8 
 
744
#define  SWIG_ValueError           -9 
 
745
#define  SWIG_SystemError          -10
 
746
#define  SWIG_AttributeError       -11
 
747
#define  SWIG_MemoryError          -12 
 
748
#define  SWIG_NullReferenceError   -13
 
749
 
 
750
 
 
751
 
 
752
/* Compatibility macros for Python 3 */
 
753
#if PY_VERSION_HEX >= 0x03000000
 
754
 
 
755
#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
 
756
#define PyInt_Check(x) PyLong_Check(x)
 
757
#define PyInt_AsLong(x) PyLong_AsLong(x)
 
758
#define PyInt_FromLong(x) PyLong_FromLong(x)
 
759
#define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)
 
760
 
 
761
#endif
 
762
 
 
763
#ifndef Py_TYPE
 
764
#  define Py_TYPE(op) ((op)->ob_type)
 
765
#endif
 
766
 
 
767
/* SWIG APIs for compatibility of both Python 2 & 3 */
 
768
 
 
769
#if PY_VERSION_HEX >= 0x03000000
 
770
#  define SWIG_Python_str_FromFormat PyUnicode_FromFormat
 
771
#else
 
772
#  define SWIG_Python_str_FromFormat PyString_FromFormat
 
773
#endif
 
774
 
 
775
 
 
776
/* Warning: This function will allocate a new string in Python 3,
 
777
 * so please call SWIG_Python_str_DelForPy3(x) to free the space.
 
778
 */
 
779
SWIGINTERN char*
 
780
SWIG_Python_str_AsChar(PyObject *str)
 
781
{
 
782
#if PY_VERSION_HEX >= 0x03000000
 
783
  char *cstr;
 
784
  char *newstr;
 
785
  Py_ssize_t len;
 
786
  str = PyUnicode_AsUTF8String(str);
 
787
  PyBytes_AsStringAndSize(str, &cstr, &len);
 
788
  newstr = (char *) malloc(len+1);
 
789
  memcpy(newstr, cstr, len+1);
 
790
  Py_XDECREF(str);
 
791
  return newstr;
 
792
#else
 
793
  return PyString_AsString(str);
 
794
#endif
 
795
}
 
796
 
 
797
#if PY_VERSION_HEX >= 0x03000000
 
798
#  define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
 
799
#else
 
800
#  define SWIG_Python_str_DelForPy3(x) 
 
801
#endif
 
802
 
 
803
 
 
804
SWIGINTERN PyObject*
 
805
SWIG_Python_str_FromChar(const char *c)
 
806
{
 
807
#if PY_VERSION_HEX >= 0x03000000
 
808
  return PyUnicode_FromString(c); 
 
809
#else
 
810
  return PyString_FromString(c);
 
811
#endif
 
812
}
 
813
 
 
814
/* Add PyOS_snprintf for old Pythons */
 
815
#if PY_VERSION_HEX < 0x02020000
 
816
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
 
817
#  define PyOS_snprintf _snprintf
 
818
# else
 
819
#  define PyOS_snprintf snprintf
 
820
# endif
 
821
#endif
 
822
 
 
823
/* A crude PyString_FromFormat implementation for old Pythons */
 
824
#if PY_VERSION_HEX < 0x02020000
 
825
 
 
826
#ifndef SWIG_PYBUFFER_SIZE
 
827
# define SWIG_PYBUFFER_SIZE 1024
 
828
#endif
 
829
 
 
830
static PyObject *
 
831
PyString_FromFormat(const char *fmt, ...) {
 
832
  va_list ap;
 
833
  char buf[SWIG_PYBUFFER_SIZE * 2];
 
834
  int res;
 
835
  va_start(ap, fmt);
 
836
  res = vsnprintf(buf, sizeof(buf), fmt, ap);
 
837
  va_end(ap);
 
838
  return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
 
839
}
 
840
#endif
 
841
 
 
842
/* Add PyObject_Del for old Pythons */
 
843
#if PY_VERSION_HEX < 0x01060000
 
844
# define PyObject_Del(op) PyMem_DEL((op))
 
845
#endif
 
846
#ifndef PyObject_DEL
 
847
# define PyObject_DEL PyObject_Del
 
848
#endif
 
849
 
 
850
/* A crude PyExc_StopIteration exception for old Pythons */
 
851
#if PY_VERSION_HEX < 0x02020000
 
852
# ifndef PyExc_StopIteration
 
853
#  define PyExc_StopIteration PyExc_RuntimeError
 
854
# endif
 
855
# ifndef PyObject_GenericGetAttr
 
856
#  define PyObject_GenericGetAttr 0
 
857
# endif
 
858
#endif
 
859
 
 
860
/* Py_NotImplemented is defined in 2.1 and up. */
 
861
#if PY_VERSION_HEX < 0x02010000
 
862
# ifndef Py_NotImplemented
 
863
#  define Py_NotImplemented PyExc_RuntimeError
 
864
# endif
 
865
#endif
 
866
 
 
867
/* A crude PyString_AsStringAndSize implementation for old Pythons */
 
868
#if PY_VERSION_HEX < 0x02010000
 
869
# ifndef PyString_AsStringAndSize
 
870
#  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
 
871
# endif
 
872
#endif
 
873
 
 
874
/* PySequence_Size for old Pythons */
 
875
#if PY_VERSION_HEX < 0x02000000
 
876
# ifndef PySequence_Size
 
877
#  define PySequence_Size PySequence_Length
 
878
# endif
 
879
#endif
 
880
 
 
881
/* PyBool_FromLong for old Pythons */
 
882
#if PY_VERSION_HEX < 0x02030000
 
883
static
 
884
PyObject *PyBool_FromLong(long ok)
 
885
{
 
886
  PyObject *result = ok ? Py_True : Py_False;
 
887
  Py_INCREF(result);
 
888
  return result;
 
889
}
 
890
#endif
 
891
 
 
892
/* Py_ssize_t for old Pythons */
 
893
/* This code is as recommended by: */
 
894
/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
 
895
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
 
896
typedef int Py_ssize_t;
 
897
# define PY_SSIZE_T_MAX INT_MAX
 
898
# define PY_SSIZE_T_MIN INT_MIN
 
899
#endif
 
900
 
 
901
/* -----------------------------------------------------------------------------
 
902
 * error manipulation
 
903
 * ----------------------------------------------------------------------------- */
 
904
 
 
905
SWIGRUNTIME PyObject*
 
906
SWIG_Python_ErrorType(int code) {
 
907
  PyObject* type = 0;
 
908
  switch(code) {
 
909
  case SWIG_MemoryError:
 
910
    type = PyExc_MemoryError;
 
911
    break;
 
912
  case SWIG_IOError:
 
913
    type = PyExc_IOError;
 
914
    break;
 
915
  case SWIG_RuntimeError:
 
916
    type = PyExc_RuntimeError;
 
917
    break;
 
918
  case SWIG_IndexError:
 
919
    type = PyExc_IndexError;
 
920
    break;
 
921
  case SWIG_TypeError:
 
922
    type = PyExc_TypeError;
 
923
    break;
 
924
  case SWIG_DivisionByZero:
 
925
    type = PyExc_ZeroDivisionError;
 
926
    break;
 
927
  case SWIG_OverflowError:
 
928
    type = PyExc_OverflowError;
 
929
    break;
 
930
  case SWIG_SyntaxError:
 
931
    type = PyExc_SyntaxError;
 
932
    break;
 
933
  case SWIG_ValueError:
 
934
    type = PyExc_ValueError;
 
935
    break;
 
936
  case SWIG_SystemError:
 
937
    type = PyExc_SystemError;
 
938
    break;
 
939
  case SWIG_AttributeError:
 
940
    type = PyExc_AttributeError;
 
941
    break;
 
942
  default:
 
943
    type = PyExc_RuntimeError;
 
944
  }
 
945
  return type;
 
946
}
 
947
 
 
948
 
 
949
SWIGRUNTIME void
 
950
SWIG_Python_AddErrorMsg(const char* mesg)
 
951
{
 
952
  PyObject *type = 0;
 
953
  PyObject *value = 0;
 
954
  PyObject *traceback = 0;
 
955
 
 
956
  if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
 
957
  if (value) {
 
958
    char *tmp;
 
959
    PyObject *old_str = PyObject_Str(value);
 
960
    PyErr_Clear();
 
961
    Py_XINCREF(type);
 
962
 
 
963
    PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
 
964
    SWIG_Python_str_DelForPy3(tmp);
 
965
    Py_DECREF(old_str);
 
966
    Py_DECREF(value);
 
967
  } else {
 
968
    PyErr_SetString(PyExc_RuntimeError, mesg);
 
969
  }
 
970
}
 
971
 
 
972
#if defined(SWIG_PYTHON_NO_THREADS)
 
973
#  if defined(SWIG_PYTHON_THREADS)
 
974
#    undef SWIG_PYTHON_THREADS
 
975
#  endif
 
976
#endif
 
977
#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
 
978
#  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
 
979
#    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
 
980
#      define SWIG_PYTHON_USE_GIL
 
981
#    endif
 
982
#  endif
 
983
#  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
 
984
#    ifndef SWIG_PYTHON_INITIALIZE_THREADS
 
985
#     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() 
 
986
#    endif
 
987
#    ifdef __cplusplus /* C++ code */
 
988
       class SWIG_Python_Thread_Block {
 
989
         bool status;
 
990
         PyGILState_STATE state;
 
991
       public:
 
992
         void end() { if (status) { PyGILState_Release(state); status = false;} }
 
993
         SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
 
994
         ~SWIG_Python_Thread_Block() { end(); }
 
995
       };
 
996
       class SWIG_Python_Thread_Allow {
 
997
         bool status;
 
998
         PyThreadState *save;
 
999
       public:
 
1000
         void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
 
1001
         SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
 
1002
         ~SWIG_Python_Thread_Allow() { end(); }
 
1003
       };
 
1004
#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block
 
1005
#      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()
 
1006
#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow
 
1007
#      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()
 
1008
#    else /* C code */
 
1009
#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
 
1010
#      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)
 
1011
#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()
 
1012
#      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)
 
1013
#    endif
 
1014
#  else /* Old thread way, not implemented, user must provide it */
 
1015
#    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
 
1016
#      define SWIG_PYTHON_INITIALIZE_THREADS
 
1017
#    endif
 
1018
#    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
 
1019
#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK
 
1020
#    endif
 
1021
#    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
 
1022
#      define SWIG_PYTHON_THREAD_END_BLOCK
 
1023
#    endif
 
1024
#    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
 
1025
#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW
 
1026
#    endif
 
1027
#    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
 
1028
#      define SWIG_PYTHON_THREAD_END_ALLOW
 
1029
#    endif
 
1030
#  endif
 
1031
#else /* No thread support */
 
1032
#  define SWIG_PYTHON_INITIALIZE_THREADS
 
1033
#  define SWIG_PYTHON_THREAD_BEGIN_BLOCK
 
1034
#  define SWIG_PYTHON_THREAD_END_BLOCK
 
1035
#  define SWIG_PYTHON_THREAD_BEGIN_ALLOW
 
1036
#  define SWIG_PYTHON_THREAD_END_ALLOW
 
1037
#endif
 
1038
 
 
1039
/* -----------------------------------------------------------------------------
 
1040
 * Python API portion that goes into the runtime
 
1041
 * ----------------------------------------------------------------------------- */
 
1042
 
 
1043
#ifdef __cplusplus
 
1044
extern "C" {
 
1045
#if 0
 
1046
} /* cc-mode */
 
1047
#endif
 
1048
#endif
 
1049
 
 
1050
/* -----------------------------------------------------------------------------
 
1051
 * Constant declarations
 
1052
 * ----------------------------------------------------------------------------- */
 
1053
 
 
1054
/* Constant Types */
 
1055
#define SWIG_PY_POINTER 4
 
1056
#define SWIG_PY_BINARY  5
 
1057
 
 
1058
/* Constant information structure */
 
1059
typedef struct swig_const_info {
 
1060
  int type;
 
1061
  char *name;
 
1062
  long lvalue;
 
1063
  double dvalue;
 
1064
  void   *pvalue;
 
1065
  swig_type_info **ptype;
 
1066
} swig_const_info;
 
1067
 
 
1068
 
 
1069
/* -----------------------------------------------------------------------------
 
1070
 * Wrapper of PyInstanceMethod_New() used in Python 3
 
1071
 * It is exported to the generated module, used for -fastproxy
 
1072
 * ----------------------------------------------------------------------------- */
 
1073
SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func)
 
1074
{
 
1075
#if PY_VERSION_HEX >= 0x03000000
 
1076
  return PyInstanceMethod_New(func);
 
1077
#else
 
1078
  return NULL;
 
1079
#endif
 
1080
}
 
1081
 
 
1082
#ifdef __cplusplus
 
1083
#if 0
 
1084
{ /* cc-mode */
 
1085
#endif
 
1086
}
 
1087
#endif
 
1088
 
 
1089
 
 
1090
/* -----------------------------------------------------------------------------
 
1091
 * pyrun.swg
 
1092
 *
 
1093
 * This file contains the runtime support for Python modules
 
1094
 * and includes code for managing global variables and pointer
 
1095
 * type checking.
 
1096
 *
 
1097
 * ----------------------------------------------------------------------------- */
 
1098
 
 
1099
/* Common SWIG API */
 
1100
 
 
1101
/* for raw pointers */
 
1102
#define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
 
1103
#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
 
1104
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
 
1105
#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(ptr, type, flags)
 
1106
#define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
 
1107
#define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
 
1108
#define swig_owntype                                    int
 
1109
 
 
1110
/* for raw packed data */
 
1111
#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
 
1112
#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
 
1113
 
 
1114
/* for class or struct pointers */
 
1115
#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
 
1116
#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
 
1117
 
 
1118
/* for C or C++ function pointers */
 
1119
#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
 
1120
#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(ptr, type, 0)
 
1121
 
 
1122
/* for C++ member pointers, ie, member methods */
 
1123
#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
 
1124
#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
 
1125
 
 
1126
 
 
1127
/* Runtime API */
 
1128
 
 
1129
#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
 
1130
#define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
 
1131
#define SWIG_NewClientData(obj)                         SwigPyClientData_New(obj)
 
1132
 
 
1133
#define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
 
1134
#define SWIG_SetErrorMsg                                SWIG_Python_SetErrorMsg                            
 
1135
#define SWIG_ErrorType(code)                            SWIG_Python_ErrorType(code)                        
 
1136
#define SWIG_Error(code, msg)                           SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
 
1137
#define SWIG_fail                                       goto fail                               
 
1138
 
 
1139
/*
 
1140
 * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
 
1141
 * CObjects API.
 
1142
 */
 
1143
#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
 
1144
     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
 
1145
#define USE_CAPSULES
 
1146
#define TYPE_POINTER_NAME \
 
1147
    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
 
1148
#endif
 
1149
 
 
1150
/* Runtime API implementation */
 
1151
 
 
1152
/* Error manipulation */
 
1153
 
 
1154
SWIGINTERN void 
 
1155
SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
 
1156
  SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
 
1157
  PyErr_SetObject(errtype, obj);
 
1158
  Py_DECREF(obj);
 
1159
  SWIG_PYTHON_THREAD_END_BLOCK;
 
1160
}
 
1161
 
 
1162
SWIGINTERN void 
 
1163
SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
 
1164
  SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 
1165
  PyErr_SetString(errtype, (char *) msg);
 
1166
  SWIG_PYTHON_THREAD_END_BLOCK;
 
1167
}
 
1168
 
 
1169
#define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
 
1170
 
 
1171
/* Set a constant value */
 
1172
 
 
1173
SWIGINTERN void
 
1174
SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
 
1175
  PyDict_SetItemString(d, (char*) name, obj);
 
1176
  Py_DECREF(obj);                            
 
1177
}
 
1178
 
 
1179
/* Append a value to the result obj */
 
1180
 
 
1181
SWIGINTERN PyObject*
 
1182
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
 
1183
#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
 
1184
  if (!result) {
 
1185
    result = obj;
 
1186
  } else if (result == Py_None) {
 
1187
    Py_DECREF(result);
 
1188
    result = obj;
 
1189
  } else {
 
1190
    if (!PyList_Check(result)) {
 
1191
      PyObject *o2 = result;
 
1192
      result = PyList_New(1);
 
1193
      PyList_SetItem(result, 0, o2);
 
1194
    }
 
1195
    PyList_Append(result,obj);
 
1196
    Py_DECREF(obj);
 
1197
  }
 
1198
  return result;
 
1199
#else
 
1200
  PyObject*   o2;
 
1201
  PyObject*   o3;
 
1202
  if (!result) {
 
1203
    result = obj;
 
1204
  } else if (result == Py_None) {
 
1205
    Py_DECREF(result);
 
1206
    result = obj;
 
1207
  } else {
 
1208
    if (!PyTuple_Check(result)) {
 
1209
      o2 = result;
 
1210
      result = PyTuple_New(1);
 
1211
      PyTuple_SET_ITEM(result, 0, o2);
 
1212
    }
 
1213
    o3 = PyTuple_New(1);
 
1214
    PyTuple_SET_ITEM(o3, 0, obj);
 
1215
    o2 = result;
 
1216
    result = PySequence_Concat(o2, o3);
 
1217
    Py_DECREF(o2);
 
1218
    Py_DECREF(o3);
 
1219
  }
 
1220
  return result;
 
1221
#endif
 
1222
}
 
1223
 
 
1224
/* Unpack the argument tuple */
 
1225
 
 
1226
SWIGINTERN int
 
1227
SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
 
1228
{
 
1229
  if (!args) {
 
1230
    if (!min && !max) {
 
1231
      return 1;
 
1232
    } else {
 
1233
      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 
 
1234
                   name, (min == max ? "" : "at least "), (int)min);
 
1235
      return 0;
 
1236
    }
 
1237
  }  
 
1238
  if (!PyTuple_Check(args)) {
 
1239
    PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
 
1240
    return 0;
 
1241
  } else {
 
1242
    register Py_ssize_t l = PyTuple_GET_SIZE(args);
 
1243
    if (l < min) {
 
1244
      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
 
1245
                   name, (min == max ? "" : "at least "), (int)min, (int)l);
 
1246
      return 0;
 
1247
    } else if (l > max) {
 
1248
      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
 
1249
                   name, (min == max ? "" : "at most "), (int)max, (int)l);
 
1250
      return 0;
 
1251
    } else {
 
1252
      register int i;
 
1253
      for (i = 0; i < l; ++i) {
 
1254
        objs[i] = PyTuple_GET_ITEM(args, i);
 
1255
      }
 
1256
      for (; l < max; ++l) {
 
1257
        objs[l] = 0;
 
1258
      }
 
1259
      return i + 1;
 
1260
    }    
 
1261
  }
 
1262
}
 
1263
 
 
1264
/* A functor is a function object with one single object argument */
 
1265
#if PY_VERSION_HEX >= 0x02020000
 
1266
#define SWIG_Python_CallFunctor(functor, obj)           PyObject_CallFunctionObjArgs(functor, obj, NULL);
 
1267
#else
 
1268
#define SWIG_Python_CallFunctor(functor, obj)           PyObject_CallFunction(functor, "O", obj);
 
1269
#endif
 
1270
 
 
1271
/*
 
1272
  Helper for static pointer initialization for both C and C++ code, for example
 
1273
  static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
 
1274
*/
 
1275
#ifdef __cplusplus
 
1276
#define SWIG_STATIC_POINTER(var)  var
 
1277
#else
 
1278
#define SWIG_STATIC_POINTER(var)  var = 0; if (!var) var
 
1279
#endif
 
1280
 
 
1281
/* -----------------------------------------------------------------------------
 
1282
 * Pointer declarations
 
1283
 * ----------------------------------------------------------------------------- */
 
1284
 
 
1285
/* Flags for new pointer objects */
 
1286
#define SWIG_POINTER_NOSHADOW       (SWIG_POINTER_OWN      << 1)
 
1287
#define SWIG_POINTER_NEW            (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
 
1288
 
 
1289
#define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)
 
1290
 
 
1291
#ifdef __cplusplus
 
1292
extern "C" {
 
1293
#if 0
 
1294
} /* cc-mode */
 
1295
#endif
 
1296
#endif
 
1297
 
 
1298
/*  How to access Py_None */
 
1299
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 
1300
#  ifndef SWIG_PYTHON_NO_BUILD_NONE
 
1301
#    ifndef SWIG_PYTHON_BUILD_NONE
 
1302
#      define SWIG_PYTHON_BUILD_NONE
 
1303
#    endif
 
1304
#  endif
 
1305
#endif
 
1306
 
 
1307
#ifdef SWIG_PYTHON_BUILD_NONE
 
1308
#  ifdef Py_None
 
1309
#   undef Py_None
 
1310
#   define Py_None SWIG_Py_None()
 
1311
#  endif
 
1312
SWIGRUNTIMEINLINE PyObject * 
 
1313
_SWIG_Py_None(void)
 
1314
{
 
1315
  PyObject *none = Py_BuildValue((char*)"");
 
1316
  Py_DECREF(none);
 
1317
  return none;
 
1318
}
 
1319
SWIGRUNTIME PyObject * 
 
1320
SWIG_Py_None(void)
 
1321
{
 
1322
  static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
 
1323
  return none;
 
1324
}
 
1325
#endif
 
1326
 
 
1327
/* The python void return value */
 
1328
 
 
1329
SWIGRUNTIMEINLINE PyObject * 
 
1330
SWIG_Py_Void(void)
 
1331
{
 
1332
  PyObject *none = Py_None;
 
1333
  Py_INCREF(none);
 
1334
  return none;
 
1335
}
 
1336
 
 
1337
/* SwigPyClientData */
 
1338
 
 
1339
typedef struct {
 
1340
  PyObject *klass;
 
1341
  PyObject *newraw;
 
1342
  PyObject *newargs;
 
1343
  PyObject *destroy;
 
1344
  int delargs;
 
1345
  int implicitconv;
 
1346
} SwigPyClientData;
 
1347
 
 
1348
SWIGRUNTIMEINLINE int 
 
1349
SWIG_Python_CheckImplicit(swig_type_info *ty)
 
1350
{
 
1351
  SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
 
1352
  return data ? data->implicitconv : 0;
 
1353
}
 
1354
 
 
1355
SWIGRUNTIMEINLINE PyObject *
 
1356
SWIG_Python_ExceptionType(swig_type_info *desc) {
 
1357
  SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
 
1358
  PyObject *klass = data ? data->klass : 0;
 
1359
  return (klass ? klass : PyExc_RuntimeError);
 
1360
}
 
1361
 
 
1362
 
 
1363
SWIGRUNTIME SwigPyClientData * 
 
1364
SwigPyClientData_New(PyObject* obj)
 
1365
{
 
1366
  if (!obj) {
 
1367
    return 0;
 
1368
  } else {
 
1369
    SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
 
1370
    /* the klass element */
 
1371
    data->klass = obj;
 
1372
    Py_INCREF(data->klass);
 
1373
    /* the newraw method and newargs arguments used to create a new raw instance */
 
1374
    if (PyClass_Check(obj)) {
 
1375
      data->newraw = 0;
 
1376
      data->newargs = obj;
 
1377
      Py_INCREF(obj);
 
1378
    } else {
 
1379
#if (PY_VERSION_HEX < 0x02020000)
 
1380
      data->newraw = 0;
 
1381
#else
 
1382
      data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
 
1383
#endif
 
1384
      if (data->newraw) {
 
1385
        Py_INCREF(data->newraw);
 
1386
        data->newargs = PyTuple_New(1);
 
1387
        PyTuple_SetItem(data->newargs, 0, obj);
 
1388
      } else {
 
1389
        data->newargs = obj;
 
1390
      }
 
1391
      Py_INCREF(data->newargs);
 
1392
    }
 
1393
    /* the destroy method, aka as the C++ delete method */
 
1394
    data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
 
1395
    if (PyErr_Occurred()) {
 
1396
      PyErr_Clear();
 
1397
      data->destroy = 0;
 
1398
    }
 
1399
    if (data->destroy) {
 
1400
      int flags;
 
1401
      Py_INCREF(data->destroy);
 
1402
      flags = PyCFunction_GET_FLAGS(data->destroy);
 
1403
#ifdef METH_O
 
1404
      data->delargs = !(flags & (METH_O));
 
1405
#else
 
1406
      data->delargs = 0;
 
1407
#endif
 
1408
    } else {
 
1409
      data->delargs = 0;
 
1410
    }
 
1411
    data->implicitconv = 0;
 
1412
    return data;
 
1413
  }
 
1414
}
 
1415
 
 
1416
SWIGRUNTIME void 
 
1417
SwigPyClientData_Del(SwigPyClientData* data)
 
1418
{
 
1419
  Py_XDECREF(data->newraw);
 
1420
  Py_XDECREF(data->newargs);
 
1421
  Py_XDECREF(data->destroy);
 
1422
}
 
1423
 
 
1424
/* =============== SwigPyObject =====================*/
 
1425
 
 
1426
typedef struct {
 
1427
  PyObject_HEAD
 
1428
  void *ptr;
 
1429
  swig_type_info *ty;
 
1430
  int own;
 
1431
  PyObject *next;
 
1432
} SwigPyObject;
 
1433
 
 
1434
SWIGRUNTIME PyObject *
 
1435
SwigPyObject_long(SwigPyObject *v)
 
1436
{
 
1437
  return PyLong_FromVoidPtr(v->ptr);
 
1438
}
 
1439
 
 
1440
SWIGRUNTIME PyObject *
 
1441
SwigPyObject_format(const char* fmt, SwigPyObject *v)
 
1442
{
 
1443
  PyObject *res = NULL;
 
1444
  PyObject *args = PyTuple_New(1);
 
1445
  if (args) {
 
1446
    if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
 
1447
      PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
 
1448
      if (ofmt) {
 
1449
#if PY_VERSION_HEX >= 0x03000000
 
1450
        res = PyUnicode_Format(ofmt,args);
 
1451
#else
 
1452
        res = PyString_Format(ofmt,args);
 
1453
#endif
 
1454
        Py_DECREF(ofmt);
 
1455
      }
 
1456
      Py_DECREF(args);
 
1457
    }
 
1458
  }
 
1459
  return res;
 
1460
}
 
1461
 
 
1462
SWIGRUNTIME PyObject *
 
1463
SwigPyObject_oct(SwigPyObject *v)
 
1464
{
 
1465
  return SwigPyObject_format("%o",v);
 
1466
}
 
1467
 
 
1468
SWIGRUNTIME PyObject *
 
1469
SwigPyObject_hex(SwigPyObject *v)
 
1470
{
 
1471
  return SwigPyObject_format("%x",v);
 
1472
}
 
1473
 
 
1474
SWIGRUNTIME PyObject *
 
1475
#ifdef METH_NOARGS
 
1476
SwigPyObject_repr(SwigPyObject *v)
 
1477
#else
 
1478
SwigPyObject_repr(SwigPyObject *v, PyObject *args)
 
1479
#endif
 
1480
{
 
1481
  const char *name = SWIG_TypePrettyName(v->ty);
 
1482
  PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, v);
 
1483
  if (v->next) {
 
1484
#ifdef METH_NOARGS
 
1485
    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
 
1486
#else
 
1487
    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
 
1488
#endif
 
1489
#if PY_VERSION_HEX >= 0x03000000
 
1490
    PyObject *joined = PyUnicode_Concat(repr, nrep);
 
1491
    Py_DecRef(repr);
 
1492
    Py_DecRef(nrep);
 
1493
    repr = joined;
 
1494
#else
 
1495
    PyString_ConcatAndDel(&repr,nrep);
 
1496
#endif
 
1497
  }
 
1498
  return repr;  
 
1499
}
 
1500
 
 
1501
SWIGRUNTIME int
 
1502
SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
 
1503
{
 
1504
  char *str;
 
1505
#ifdef METH_NOARGS
 
1506
  PyObject *repr = SwigPyObject_repr(v);
 
1507
#else
 
1508
  PyObject *repr = SwigPyObject_repr(v, NULL);
 
1509
#endif
 
1510
  if (repr) {
 
1511
    str = SWIG_Python_str_AsChar(repr); 
 
1512
    fputs(str, fp);
 
1513
    SWIG_Python_str_DelForPy3(str);
 
1514
    Py_DECREF(repr);
 
1515
    return 0; 
 
1516
  } else {
 
1517
    return 1; 
 
1518
  }
 
1519
}
 
1520
 
 
1521
SWIGRUNTIME PyObject *
 
1522
SwigPyObject_str(SwigPyObject *v)
 
1523
{
 
1524
  char result[SWIG_BUFFER_SIZE];
 
1525
  return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
 
1526
    SWIG_Python_str_FromChar(result) : 0;
 
1527
}
 
1528
 
 
1529
SWIGRUNTIME int
 
1530
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
 
1531
{
 
1532
  void *i = v->ptr;
 
1533
  void *j = w->ptr;
 
1534
  return (i < j) ? -1 : ((i > j) ? 1 : 0);
 
1535
}
 
1536
 
 
1537
/* Added for Python 3.x, would it also be useful for Python 2.x? */
 
1538
SWIGRUNTIME PyObject*
 
1539
SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
 
1540
{
 
1541
  PyObject* res;
 
1542
  if( op != Py_EQ && op != Py_NE ) {
 
1543
    Py_INCREF(Py_NotImplemented);
 
1544
    return Py_NotImplemented;
 
1545
  }
 
1546
  if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) )
 
1547
    res = Py_True;
 
1548
  else
 
1549
    res = Py_False;
 
1550
  Py_INCREF(res);
 
1551
  return res;  
 
1552
}
 
1553
 
 
1554
 
 
1555
SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
 
1556
 
 
1557
SWIGRUNTIME PyTypeObject*
 
1558
SwigPyObject_type(void) {
 
1559
  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
 
1560
  return type;
 
1561
}
 
1562
 
 
1563
SWIGRUNTIMEINLINE int
 
1564
SwigPyObject_Check(PyObject *op) {
 
1565
  return (Py_TYPE(op) == SwigPyObject_type())
 
1566
    || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
 
1567
}
 
1568
 
 
1569
SWIGRUNTIME PyObject *
 
1570
SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
 
1571
 
 
1572
SWIGRUNTIME void
 
1573
SwigPyObject_dealloc(PyObject *v)
 
1574
{
 
1575
  SwigPyObject *sobj = (SwigPyObject *) v;
 
1576
  PyObject *next = sobj->next;
 
1577
  if (sobj->own == SWIG_POINTER_OWN) {
 
1578
    swig_type_info *ty = sobj->ty;
 
1579
    SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
 
1580
    PyObject *destroy = data ? data->destroy : 0;
 
1581
    if (destroy) {
 
1582
      /* destroy is always a VARARGS method */
 
1583
      PyObject *res;
 
1584
      if (data->delargs) {
 
1585
        /* we need to create a temporary object to carry the destroy operation */
 
1586
        PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
 
1587
        res = SWIG_Python_CallFunctor(destroy, tmp);
 
1588
        Py_DECREF(tmp);
 
1589
      } else {
 
1590
        PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
 
1591
        PyObject *mself = PyCFunction_GET_SELF(destroy);
 
1592
        res = ((*meth)(mself, v));
 
1593
      }
 
1594
      Py_XDECREF(res);
 
1595
    } 
 
1596
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
 
1597
    else {
 
1598
      const char *name = SWIG_TypePrettyName(ty);
 
1599
      printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
 
1600
    }
 
1601
#endif
 
1602
  } 
 
1603
  Py_XDECREF(next);
 
1604
  PyObject_DEL(v);
 
1605
}
 
1606
 
 
1607
SWIGRUNTIME PyObject* 
 
1608
SwigPyObject_append(PyObject* v, PyObject* next)
 
1609
{
 
1610
  SwigPyObject *sobj = (SwigPyObject *) v;
 
1611
#ifndef METH_O
 
1612
  PyObject *tmp = 0;
 
1613
  if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
 
1614
  next = tmp;
 
1615
#endif
 
1616
  if (!SwigPyObject_Check(next)) {
 
1617
    return NULL;
 
1618
  }
 
1619
  sobj->next = next;
 
1620
  Py_INCREF(next);
 
1621
  return SWIG_Py_Void();
 
1622
}
 
1623
 
 
1624
SWIGRUNTIME PyObject* 
 
1625
#ifdef METH_NOARGS
 
1626
SwigPyObject_next(PyObject* v)
 
1627
#else
 
1628
SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 
1629
#endif
 
1630
{
 
1631
  SwigPyObject *sobj = (SwigPyObject *) v;
 
1632
  if (sobj->next) {    
 
1633
    Py_INCREF(sobj->next);
 
1634
    return sobj->next;
 
1635
  } else {
 
1636
    return SWIG_Py_Void();
 
1637
  }
 
1638
}
 
1639
 
 
1640
SWIGINTERN PyObject*
 
1641
#ifdef METH_NOARGS
 
1642
SwigPyObject_disown(PyObject *v)
 
1643
#else
 
1644
SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 
1645
#endif
 
1646
{
 
1647
  SwigPyObject *sobj = (SwigPyObject *)v;
 
1648
  sobj->own = 0;
 
1649
  return SWIG_Py_Void();
 
1650
}
 
1651
 
 
1652
SWIGINTERN PyObject*
 
1653
#ifdef METH_NOARGS
 
1654
SwigPyObject_acquire(PyObject *v)
 
1655
#else
 
1656
SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 
1657
#endif
 
1658
{
 
1659
  SwigPyObject *sobj = (SwigPyObject *)v;
 
1660
  sobj->own = SWIG_POINTER_OWN;
 
1661
  return SWIG_Py_Void();
 
1662
}
 
1663
 
 
1664
SWIGINTERN PyObject*
 
1665
SwigPyObject_own(PyObject *v, PyObject *args)
 
1666
{
 
1667
  PyObject *val = 0;
 
1668
#if (PY_VERSION_HEX < 0x02020000)
 
1669
  if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
 
1670
#else
 
1671
  if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
 
1672
#endif
 
1673
    {
 
1674
      return NULL;
 
1675
    } 
 
1676
  else
 
1677
    {
 
1678
      SwigPyObject *sobj = (SwigPyObject *)v;
 
1679
      PyObject *obj = PyBool_FromLong(sobj->own);
 
1680
      if (val) {
 
1681
#ifdef METH_NOARGS
 
1682
        if (PyObject_IsTrue(val)) {
 
1683
          SwigPyObject_acquire(v);
 
1684
        } else {
 
1685
          SwigPyObject_disown(v);
 
1686
        }
 
1687
#else
 
1688
        if (PyObject_IsTrue(val)) {
 
1689
          SwigPyObject_acquire(v,args);
 
1690
        } else {
 
1691
          SwigPyObject_disown(v,args);
 
1692
        }
 
1693
#endif
 
1694
      } 
 
1695
      return obj;
 
1696
    }
 
1697
}
 
1698
 
 
1699
#ifdef METH_O
 
1700
static PyMethodDef
 
1701
swigobject_methods[] = {
 
1702
  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
 
1703
  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS,  (char *)"aquires ownership of the pointer"},
 
1704
  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
 
1705
  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_O,       (char *)"appends another 'this' object"},
 
1706
  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
 
1707
  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
 
1708
  {0, 0, 0, 0}  
 
1709
};
 
1710
#else
 
1711
static PyMethodDef
 
1712
swigobject_methods[] = {
 
1713
  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
 
1714
  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
 
1715
  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
 
1716
  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
 
1717
  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
 
1718
  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
 
1719
  {0, 0, 0, 0}  
 
1720
};
 
1721
#endif
 
1722
 
 
1723
#if PY_VERSION_HEX < 0x02020000
 
1724
SWIGINTERN PyObject *
 
1725
SwigPyObject_getattr(SwigPyObject *sobj,char *name)
 
1726
{
 
1727
  return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
 
1728
}
 
1729
#endif
 
1730
 
 
1731
SWIGRUNTIME PyTypeObject*
 
1732
_PySwigObject_type(void) {
 
1733
  static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
 
1734
  
 
1735
  static PyNumberMethods SwigPyObject_as_number = {
 
1736
    (binaryfunc)0, /*nb_add*/
 
1737
    (binaryfunc)0, /*nb_subtract*/
 
1738
    (binaryfunc)0, /*nb_multiply*/
 
1739
    /* nb_divide removed in Python 3 */
 
1740
#if PY_VERSION_HEX < 0x03000000
 
1741
    (binaryfunc)0, /*nb_divide*/
 
1742
#endif
 
1743
    (binaryfunc)0, /*nb_remainder*/
 
1744
    (binaryfunc)0, /*nb_divmod*/
 
1745
    (ternaryfunc)0,/*nb_power*/
 
1746
    (unaryfunc)0,  /*nb_negative*/
 
1747
    (unaryfunc)0,  /*nb_positive*/
 
1748
    (unaryfunc)0,  /*nb_absolute*/
 
1749
    (inquiry)0,    /*nb_nonzero*/
 
1750
    0,             /*nb_invert*/
 
1751
    0,             /*nb_lshift*/
 
1752
    0,             /*nb_rshift*/
 
1753
    0,             /*nb_and*/
 
1754
    0,             /*nb_xor*/
 
1755
    0,             /*nb_or*/
 
1756
#if PY_VERSION_HEX < 0x03000000
 
1757
    0,   /*nb_coerce*/
 
1758
#endif
 
1759
    (unaryfunc)SwigPyObject_long, /*nb_int*/
 
1760
#if PY_VERSION_HEX < 0x03000000
 
1761
    (unaryfunc)SwigPyObject_long, /*nb_long*/
 
1762
#else
 
1763
    0, /*nb_reserved*/
 
1764
#endif
 
1765
    (unaryfunc)0,                 /*nb_float*/
 
1766
#if PY_VERSION_HEX < 0x03000000
 
1767
    (unaryfunc)SwigPyObject_oct,  /*nb_oct*/
 
1768
    (unaryfunc)SwigPyObject_hex,  /*nb_hex*/
 
1769
#endif
 
1770
#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
 
1771
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
 
1772
#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
 
1773
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
 
1774
#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
 
1775
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
 
1776
#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
 
1777
    0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
 
1778
#endif
 
1779
  };
 
1780
 
 
1781
  static PyTypeObject swigpyobject_type;  
 
1782
  static int type_init = 0;
 
1783
  if (!type_init) {
 
1784
    const PyTypeObject tmp
 
1785
      = {
 
1786
        /* PyObject header changed in Python 3 */
 
1787
#if PY_VERSION_HEX >= 0x03000000
 
1788
        PyVarObject_HEAD_INIT(&PyType_Type, 0)
 
1789
#else    
 
1790
        PyObject_HEAD_INIT(NULL)
 
1791
        0,                                  /* ob_size */
 
1792
#endif
 
1793
        (char *)"SwigPyObject",             /* tp_name */
 
1794
        sizeof(SwigPyObject),               /* tp_basicsize */
 
1795
        0,                                  /* tp_itemsize */
 
1796
        (destructor)SwigPyObject_dealloc,   /* tp_dealloc */
 
1797
        (printfunc)SwigPyObject_print,      /* tp_print */
 
1798
#if PY_VERSION_HEX < 0x02020000
 
1799
        (getattrfunc)SwigPyObject_getattr,  /* tp_getattr */ 
 
1800
#else
 
1801
        (getattrfunc)0,                     /* tp_getattr */ 
 
1802
#endif
 
1803
        (setattrfunc)0,                     /* tp_setattr */ 
 
1804
#if PY_VERSION_HEX >= 0x03000000
 
1805
    0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
 
1806
#else
 
1807
        (cmpfunc)SwigPyObject_compare,      /* tp_compare */
 
1808
#endif
 
1809
        (reprfunc)SwigPyObject_repr,        /* tp_repr */    
 
1810
        &SwigPyObject_as_number,            /* tp_as_number */
 
1811
        0,                                  /* tp_as_sequence */
 
1812
        0,                                  /* tp_as_mapping */
 
1813
        (hashfunc)0,                        /* tp_hash */
 
1814
        (ternaryfunc)0,                     /* tp_call */
 
1815
        (reprfunc)SwigPyObject_str,         /* tp_str */
 
1816
        PyObject_GenericGetAttr,            /* tp_getattro */
 
1817
        0,                                  /* tp_setattro */
 
1818
        0,                                  /* tp_as_buffer */
 
1819
        Py_TPFLAGS_DEFAULT,                 /* tp_flags */
 
1820
        swigobject_doc,                     /* tp_doc */        
 
1821
        0,                                  /* tp_traverse */
 
1822
        0,                                  /* tp_clear */
 
1823
        (richcmpfunc)SwigPyObject_richcompare,           /* tp_richcompare */
 
1824
        0,                                  /* tp_weaklistoffset */
 
1825
#if PY_VERSION_HEX >= 0x02020000
 
1826
        0,                                  /* tp_iter */
 
1827
        0,                                  /* tp_iternext */
 
1828
        swigobject_methods,                 /* tp_methods */ 
 
1829
        0,                                  /* tp_members */
 
1830
        0,                                  /* tp_getset */             
 
1831
        0,                                  /* tp_base */               
 
1832
        0,                                  /* tp_dict */               
 
1833
        0,                                  /* tp_descr_get */          
 
1834
        0,                                  /* tp_descr_set */          
 
1835
        0,                                  /* tp_dictoffset */         
 
1836
        0,                                  /* tp_init */               
 
1837
        0,                                  /* tp_alloc */              
 
1838
        0,                                  /* tp_new */                
 
1839
        0,                                  /* tp_free */          
 
1840
        0,                                  /* tp_is_gc */  
 
1841
        0,                                  /* tp_bases */   
 
1842
        0,                                  /* tp_mro */
 
1843
        0,                                  /* tp_cache */   
 
1844
        0,                                  /* tp_subclasses */
 
1845
        0,                                  /* tp_weaklist */
 
1846
#endif
 
1847
#if PY_VERSION_HEX >= 0x02030000
 
1848
        0,                                  /* tp_del */
 
1849
#endif
 
1850
#ifdef COUNT_ALLOCS
 
1851
        0,0,0,0                             /* tp_alloc -> tp_next */
 
1852
#endif
 
1853
      };
 
1854
    swigpyobject_type = tmp;
 
1855
    /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
 
1856
#if PY_VERSION_HEX < 0x03000000
 
1857
    swigpyobject_type.ob_type = &PyType_Type;
 
1858
#endif
 
1859
    type_init = 1;
 
1860
  }
 
1861
  return &swigpyobject_type;
 
1862
}
 
1863
 
 
1864
SWIGRUNTIME PyObject *
 
1865
SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
 
1866
{
 
1867
  SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
 
1868
  if (sobj) {
 
1869
    sobj->ptr  = ptr;
 
1870
    sobj->ty   = ty;
 
1871
    sobj->own  = own;
 
1872
    sobj->next = 0;
 
1873
  }
 
1874
  return (PyObject *)sobj;
 
1875
}
 
1876
 
 
1877
/* -----------------------------------------------------------------------------
 
1878
 * Implements a simple Swig Packed type, and use it instead of string
 
1879
 * ----------------------------------------------------------------------------- */
 
1880
 
 
1881
typedef struct {
 
1882
  PyObject_HEAD
 
1883
  void *pack;
 
1884
  swig_type_info *ty;
 
1885
  size_t size;
 
1886
} SwigPyPacked;
 
1887
 
 
1888
SWIGRUNTIME int
 
1889
SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
 
1890
{
 
1891
  char result[SWIG_BUFFER_SIZE];
 
1892
  fputs("<Swig Packed ", fp); 
 
1893
  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
 
1894
    fputs("at ", fp); 
 
1895
    fputs(result, fp); 
 
1896
  }
 
1897
  fputs(v->ty->name,fp); 
 
1898
  fputs(">", fp);
 
1899
  return 0; 
 
1900
}
 
1901
  
 
1902
SWIGRUNTIME PyObject *
 
1903
SwigPyPacked_repr(SwigPyPacked *v)
 
1904
{
 
1905
  char result[SWIG_BUFFER_SIZE];
 
1906
  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
 
1907
    return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
 
1908
  } else {
 
1909
    return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
 
1910
  }  
 
1911
}
 
1912
 
 
1913
SWIGRUNTIME PyObject *
 
1914
SwigPyPacked_str(SwigPyPacked *v)
 
1915
{
 
1916
  char result[SWIG_BUFFER_SIZE];
 
1917
  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
 
1918
    return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
 
1919
  } else {
 
1920
    return SWIG_Python_str_FromChar(v->ty->name);
 
1921
  }  
 
1922
}
 
1923
 
 
1924
SWIGRUNTIME int
 
1925
SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
 
1926
{
 
1927
  size_t i = v->size;
 
1928
  size_t j = w->size;
 
1929
  int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
 
1930
  return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
 
1931
}
 
1932
 
 
1933
SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
 
1934
 
 
1935
SWIGRUNTIME PyTypeObject*
 
1936
SwigPyPacked_type(void) {
 
1937
  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
 
1938
  return type;
 
1939
}
 
1940
 
 
1941
SWIGRUNTIMEINLINE int
 
1942
SwigPyPacked_Check(PyObject *op) {
 
1943
  return ((op)->ob_type == _PySwigPacked_type()) 
 
1944
    || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
 
1945
}
 
1946
 
 
1947
SWIGRUNTIME void
 
1948
SwigPyPacked_dealloc(PyObject *v)
 
1949
{
 
1950
  if (SwigPyPacked_Check(v)) {
 
1951
    SwigPyPacked *sobj = (SwigPyPacked *) v;
 
1952
    free(sobj->pack);
 
1953
  }
 
1954
  PyObject_DEL(v);
 
1955
}
 
1956
 
 
1957
SWIGRUNTIME PyTypeObject*
 
1958
_PySwigPacked_type(void) {
 
1959
  static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
 
1960
  static PyTypeObject swigpypacked_type;
 
1961
  static int type_init = 0;  
 
1962
  if (!type_init) {
 
1963
    const PyTypeObject tmp
 
1964
      = {
 
1965
    /* PyObject header changed in Python 3 */
 
1966
#if PY_VERSION_HEX>=0x03000000
 
1967
    PyVarObject_HEAD_INIT(&PyType_Type, 0)
 
1968
#else
 
1969
        PyObject_HEAD_INIT(NULL)
 
1970
    0,                              /* ob_size */       
 
1971
#endif
 
1972
        (char *)"SwigPyPacked",             /* tp_name */       
 
1973
        sizeof(SwigPyPacked),               /* tp_basicsize */  
 
1974
        0,                                  /* tp_itemsize */   
 
1975
        (destructor)SwigPyPacked_dealloc,   /* tp_dealloc */    
 
1976
        (printfunc)SwigPyPacked_print,      /* tp_print */      
 
1977
        (getattrfunc)0,                     /* tp_getattr */    
 
1978
        (setattrfunc)0,                     /* tp_setattr */    
 
1979
#if PY_VERSION_HEX>=0x03000000
 
1980
    0, /* tp_reserved in 3.0.1 */
 
1981
#else
 
1982
    (cmpfunc)SwigPyPacked_compare,          /* tp_compare */
 
1983
#endif
 
1984
        (reprfunc)SwigPyPacked_repr,        /* tp_repr */
 
1985
        0,                                  /* tp_as_number */
 
1986
        0,                                  /* tp_as_sequence */
 
1987
        0,                                  /* tp_as_mapping */
 
1988
        (hashfunc)0,                        /* tp_hash */
 
1989
        (ternaryfunc)0,                     /* tp_call */
 
1990
        (reprfunc)SwigPyPacked_str,         /* tp_str */
 
1991
        PyObject_GenericGetAttr,            /* tp_getattro */
 
1992
        0,                                  /* tp_setattro */
 
1993
        0,                                  /* tp_as_buffer */
 
1994
        Py_TPFLAGS_DEFAULT,                 /* tp_flags */
 
1995
        swigpacked_doc,                     /* tp_doc */
 
1996
        0,                                  /* tp_traverse */
 
1997
        0,                                  /* tp_clear */
 
1998
        0,                                  /* tp_richcompare */
 
1999
        0,                                  /* tp_weaklistoffset */
 
2000
#if PY_VERSION_HEX >= 0x02020000
 
2001
        0,                                  /* tp_iter */
 
2002
        0,                                  /* tp_iternext */
 
2003
        0,                                  /* tp_methods */ 
 
2004
        0,                                  /* tp_members */
 
2005
        0,                                  /* tp_getset */             
 
2006
        0,                                  /* tp_base */               
 
2007
        0,                                  /* tp_dict */               
 
2008
        0,                                  /* tp_descr_get */          
 
2009
        0,                                  /* tp_descr_set */          
 
2010
        0,                                  /* tp_dictoffset */         
 
2011
        0,                                  /* tp_init */               
 
2012
        0,                                  /* tp_alloc */              
 
2013
        0,                                  /* tp_new */                
 
2014
        0,                                  /* tp_free */          
 
2015
        0,                                  /* tp_is_gc */  
 
2016
        0,                                  /* tp_bases */   
 
2017
        0,                                  /* tp_mro */
 
2018
        0,                                  /* tp_cache */   
 
2019
        0,                                  /* tp_subclasses */
 
2020
        0,                                  /* tp_weaklist */
 
2021
#endif
 
2022
#if PY_VERSION_HEX >= 0x02030000
 
2023
        0,                                  /* tp_del */
 
2024
#endif
 
2025
#ifdef COUNT_ALLOCS
 
2026
        0,0,0,0                             /* tp_alloc -> tp_next */
 
2027
#endif
 
2028
      };
 
2029
    swigpypacked_type = tmp;
 
2030
    /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */
 
2031
#if PY_VERSION_HEX < 0x03000000
 
2032
    swigpypacked_type.ob_type = &PyType_Type;
 
2033
#endif
 
2034
    type_init = 1;
 
2035
  }
 
2036
  return &swigpypacked_type;
 
2037
}
 
2038
 
 
2039
SWIGRUNTIME PyObject *
 
2040
SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
 
2041
{
 
2042
  SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
 
2043
  if (sobj) {
 
2044
    void *pack = malloc(size);
 
2045
    if (pack) {
 
2046
      memcpy(pack, ptr, size);
 
2047
      sobj->pack = pack;
 
2048
      sobj->ty   = ty;
 
2049
      sobj->size = size;
 
2050
    } else {
 
2051
      PyObject_DEL((PyObject *) sobj);
 
2052
      sobj = 0;
 
2053
    }
 
2054
  }
 
2055
  return (PyObject *) sobj;
 
2056
}
 
2057
 
 
2058
SWIGRUNTIME swig_type_info *
 
2059
SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
 
2060
{
 
2061
  if (SwigPyPacked_Check(obj)) {
 
2062
    SwigPyPacked *sobj = (SwigPyPacked *)obj;
 
2063
    if (sobj->size != size) return 0;
 
2064
    memcpy(ptr, sobj->pack, size);
 
2065
    return sobj->ty;
 
2066
  } else {
 
2067
    return 0;
 
2068
  }
 
2069
}
 
2070
 
 
2071
/* -----------------------------------------------------------------------------
 
2072
 * pointers/data manipulation
 
2073
 * ----------------------------------------------------------------------------- */
 
2074
 
 
2075
SWIGRUNTIMEINLINE PyObject *
 
2076
_SWIG_This(void)
 
2077
{
 
2078
    return SWIG_Python_str_FromChar("this");
 
2079
}
 
2080
 
 
2081
static PyObject *swig_this = NULL;
 
2082
 
 
2083
SWIGRUNTIME PyObject *
 
2084
SWIG_This(void)
 
2085
{
 
2086
  if (swig_this == NULL)
 
2087
    swig_this = _SWIG_This();
 
2088
  return swig_this;
 
2089
}
 
2090
 
 
2091
/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
 
2092
 
 
2093
/* TODO: I don't know how to implement the fast getset in Python 3 right now */
 
2094
#if PY_VERSION_HEX>=0x03000000
 
2095
#define SWIG_PYTHON_SLOW_GETSET_THIS 
 
2096
#endif
 
2097
 
 
2098
SWIGRUNTIME SwigPyObject *
 
2099
SWIG_Python_GetSwigThis(PyObject *pyobj) 
 
2100
{
 
2101
  if (SwigPyObject_Check(pyobj)) {
 
2102
    return (SwigPyObject *) pyobj;
 
2103
  } else {
 
2104
    PyObject *obj = 0;
 
2105
#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
 
2106
    if (PyInstance_Check(pyobj)) {
 
2107
      obj = _PyInstance_Lookup(pyobj, SWIG_This());      
 
2108
    } else {
 
2109
      PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
 
2110
      if (dictptr != NULL) {
 
2111
        PyObject *dict = *dictptr;
 
2112
        obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
 
2113
      } else {
 
2114
#ifdef PyWeakref_CheckProxy
 
2115
        if (PyWeakref_CheckProxy(pyobj)) {
 
2116
          PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
 
2117
          return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
 
2118
        }
 
2119
#endif
 
2120
        obj = PyObject_GetAttr(pyobj,SWIG_This());
 
2121
        if (obj) {
 
2122
          Py_DECREF(obj);
 
2123
        } else {
 
2124
          if (PyErr_Occurred()) PyErr_Clear();
 
2125
          return 0;
 
2126
        }
 
2127
      }
 
2128
    }
 
2129
#else
 
2130
    obj = PyObject_GetAttr(pyobj,SWIG_This());
 
2131
    if (obj) {
 
2132
      Py_DECREF(obj);
 
2133
    } else {
 
2134
      if (PyErr_Occurred()) PyErr_Clear();
 
2135
      return 0;
 
2136
    }
 
2137
#endif
 
2138
    if (obj && !SwigPyObject_Check(obj)) {
 
2139
      /* a PyObject is called 'this', try to get the 'real this'
 
2140
         SwigPyObject from it */ 
 
2141
      return SWIG_Python_GetSwigThis(obj);
 
2142
    }
 
2143
    return (SwigPyObject *)obj;
 
2144
  }
 
2145
}
 
2146
 
 
2147
/* Acquire a pointer value */
 
2148
 
 
2149
SWIGRUNTIME int
 
2150
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
 
2151
  if (own == SWIG_POINTER_OWN) {
 
2152
    SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
 
2153
    if (sobj) {
 
2154
      int oldown = sobj->own;
 
2155
      sobj->own = own;
 
2156
      return oldown;
 
2157
    }
 
2158
  }
 
2159
  return 0;
 
2160
}
 
2161
 
 
2162
/* Convert a pointer value */
 
2163
 
 
2164
SWIGRUNTIME int
 
2165
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
 
2166
  if (!obj) return SWIG_ERROR;
 
2167
  if (obj == Py_None) {
 
2168
    if (ptr) *ptr = 0;
 
2169
    return SWIG_OK;
 
2170
  } else {
 
2171
    SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
 
2172
    if (own)
 
2173
      *own = 0;
 
2174
    while (sobj) {
 
2175
      void *vptr = sobj->ptr;
 
2176
      if (ty) {
 
2177
        swig_type_info *to = sobj->ty;
 
2178
        if (to == ty) {
 
2179
          /* no type cast needed */
 
2180
          if (ptr) *ptr = vptr;
 
2181
          break;
 
2182
        } else {
 
2183
          swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
 
2184
          if (!tc) {
 
2185
            sobj = (SwigPyObject *)sobj->next;
 
2186
          } else {
 
2187
            if (ptr) {
 
2188
              int newmemory = 0;
 
2189
              *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
 
2190
              if (newmemory == SWIG_CAST_NEW_MEMORY) {
 
2191
                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
 
2192
                if (own)
 
2193
                  *own = *own | SWIG_CAST_NEW_MEMORY;
 
2194
              }
 
2195
            }
 
2196
            break;
 
2197
          }
 
2198
        }
 
2199
      } else {
 
2200
        if (ptr) *ptr = vptr;
 
2201
        break;
 
2202
      }
 
2203
    }
 
2204
    if (sobj) {
 
2205
      if (own)
 
2206
        *own = *own | sobj->own;
 
2207
      if (flags & SWIG_POINTER_DISOWN) {
 
2208
        sobj->own = 0;
 
2209
      }
 
2210
      return SWIG_OK;
 
2211
    } else {
 
2212
      int res = SWIG_ERROR;
 
2213
      if (flags & SWIG_POINTER_IMPLICIT_CONV) {
 
2214
        SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
 
2215
        if (data && !data->implicitconv) {
 
2216
          PyObject *klass = data->klass;
 
2217
          if (klass) {
 
2218
            PyObject *impconv;
 
2219
            data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
 
2220
            impconv = SWIG_Python_CallFunctor(klass, obj);
 
2221
            data->implicitconv = 0;
 
2222
            if (PyErr_Occurred()) {
 
2223
              PyErr_Clear();
 
2224
              impconv = 0;
 
2225
            }
 
2226
            if (impconv) {
 
2227
              SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
 
2228
              if (iobj) {
 
2229
                void *vptr;
 
2230
                res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
 
2231
                if (SWIG_IsOK(res)) {
 
2232
                  if (ptr) {
 
2233
                    *ptr = vptr;
 
2234
                    /* transfer the ownership to 'ptr' */
 
2235
                    iobj->own = 0;
 
2236
                    res = SWIG_AddCast(res);
 
2237
                    res = SWIG_AddNewMask(res);
 
2238
                  } else {
 
2239
                    res = SWIG_AddCast(res);                
 
2240
                  }
 
2241
                }
 
2242
              }
 
2243
              Py_DECREF(impconv);
 
2244
            }
 
2245
          }
 
2246
        }
 
2247
      }
 
2248
      return res;
 
2249
    }
 
2250
  }
 
2251
}
 
2252
 
 
2253
/* Convert a function ptr value */
 
2254
 
 
2255
SWIGRUNTIME int
 
2256
SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
 
2257
  if (!PyCFunction_Check(obj)) {
 
2258
    return SWIG_ConvertPtr(obj, ptr, ty, 0);
 
2259
  } else {
 
2260
    void *vptr = 0;
 
2261
    
 
2262
    /* here we get the method pointer for callbacks */
 
2263
    const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
 
2264
    const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
 
2265
    if (desc)
 
2266
      desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
 
2267
    if (!desc) 
 
2268
      return SWIG_ERROR;
 
2269
    if (ty) {
 
2270
      swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
 
2271
      if (tc) {
 
2272
        int newmemory = 0;
 
2273
        *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
 
2274
        assert(!newmemory); /* newmemory handling not yet implemented */
 
2275
      } else {
 
2276
        return SWIG_ERROR;
 
2277
      }
 
2278
    } else {
 
2279
      *ptr = vptr;
 
2280
    }
 
2281
    return SWIG_OK;
 
2282
  }
 
2283
}
 
2284
 
 
2285
/* Convert a packed value value */
 
2286
 
 
2287
SWIGRUNTIME int
 
2288
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
 
2289
  swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
 
2290
  if (!to) return SWIG_ERROR;
 
2291
  if (ty) {
 
2292
    if (to != ty) {
 
2293
      /* check type cast? */
 
2294
      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
 
2295
      if (!tc) return SWIG_ERROR;
 
2296
    }
 
2297
  }
 
2298
  return SWIG_OK;
 
2299
}  
 
2300
 
 
2301
/* -----------------------------------------------------------------------------
 
2302
 * Create a new pointer object
 
2303
 * ----------------------------------------------------------------------------- */
 
2304
 
 
2305
/*
 
2306
  Create a new instance object, without calling __init__, and set the
 
2307
  'this' attribute.
 
2308
*/
 
2309
 
 
2310
SWIGRUNTIME PyObject* 
 
2311
SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
 
2312
{
 
2313
#if (PY_VERSION_HEX >= 0x02020000)
 
2314
  PyObject *inst = 0;
 
2315
  PyObject *newraw = data->newraw;
 
2316
  if (newraw) {
 
2317
    inst = PyObject_Call(newraw, data->newargs, NULL);
 
2318
    if (inst) {
 
2319
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
 
2320
      PyObject **dictptr = _PyObject_GetDictPtr(inst);
 
2321
      if (dictptr != NULL) {
 
2322
        PyObject *dict = *dictptr;
 
2323
        if (dict == NULL) {
 
2324
          dict = PyDict_New();
 
2325
          *dictptr = dict;
 
2326
          PyDict_SetItem(dict, SWIG_This(), swig_this);
 
2327
        }
 
2328
      }
 
2329
#else
 
2330
      PyObject *key = SWIG_This();
 
2331
      PyObject_SetAttr(inst, key, swig_this);
 
2332
#endif
 
2333
    }
 
2334
  } else {
 
2335
#if PY_VERSION_HEX >= 0x03000000
 
2336
    inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
 
2337
    PyObject_SetAttr(inst, SWIG_This(), swig_this);
 
2338
    Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
 
2339
#else
 
2340
    PyObject *dict = PyDict_New();
 
2341
    PyDict_SetItem(dict, SWIG_This(), swig_this);
 
2342
    inst = PyInstance_NewRaw(data->newargs, dict);
 
2343
    Py_DECREF(dict);
 
2344
#endif
 
2345
  }
 
2346
  return inst;
 
2347
#else
 
2348
#if (PY_VERSION_HEX >= 0x02010000)
 
2349
  PyObject *inst;
 
2350
  PyObject *dict = PyDict_New();
 
2351
  PyDict_SetItem(dict, SWIG_This(), swig_this);
 
2352
  inst = PyInstance_NewRaw(data->newargs, dict);
 
2353
  Py_DECREF(dict);
 
2354
  return (PyObject *) inst;
 
2355
#else
 
2356
  PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
 
2357
  if (inst == NULL) {
 
2358
    return NULL;
 
2359
  }
 
2360
  inst->in_class = (PyClassObject *)data->newargs;
 
2361
  Py_INCREF(inst->in_class);
 
2362
  inst->in_dict = PyDict_New();
 
2363
  if (inst->in_dict == NULL) {
 
2364
    Py_DECREF(inst);
 
2365
    return NULL;
 
2366
  }
 
2367
#ifdef Py_TPFLAGS_HAVE_WEAKREFS
 
2368
  inst->in_weakreflist = NULL;
 
2369
#endif
 
2370
#ifdef Py_TPFLAGS_GC
 
2371
  PyObject_GC_Init(inst);
 
2372
#endif
 
2373
  PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
 
2374
  return (PyObject *) inst;
 
2375
#endif
 
2376
#endif
 
2377
}
 
2378
 
 
2379
SWIGRUNTIME void
 
2380
SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
 
2381
{
 
2382
 PyObject *dict;
 
2383
#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
 
2384
 PyObject **dictptr = _PyObject_GetDictPtr(inst);
 
2385
 if (dictptr != NULL) {
 
2386
   dict = *dictptr;
 
2387
   if (dict == NULL) {
 
2388
     dict = PyDict_New();
 
2389
     *dictptr = dict;
 
2390
   }
 
2391
   PyDict_SetItem(dict, SWIG_This(), swig_this);
 
2392
   return;
 
2393
 }
 
2394
#endif
 
2395
 dict = PyObject_GetAttrString(inst, (char*)"__dict__");
 
2396
 PyDict_SetItem(dict, SWIG_This(), swig_this);
 
2397
 Py_DECREF(dict);
 
2398
 
2399
 
 
2400
 
 
2401
SWIGINTERN PyObject *
 
2402
SWIG_Python_InitShadowInstance(PyObject *args) {
 
2403
  PyObject *obj[2];
 
2404
  if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
 
2405
    return NULL;
 
2406
  } else {
 
2407
    SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
 
2408
    if (sthis) {
 
2409
      SwigPyObject_append((PyObject*) sthis, obj[1]);
 
2410
    } else {
 
2411
      SWIG_Python_SetSwigThis(obj[0], obj[1]);
 
2412
    }
 
2413
    return SWIG_Py_Void();
 
2414
  }
 
2415
}
 
2416
 
 
2417
/* Create a new pointer object */
 
2418
 
 
2419
SWIGRUNTIME PyObject *
 
2420
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
 
2421
  if (!ptr) {
 
2422
    return SWIG_Py_Void();
 
2423
  } else {
 
2424
    int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
 
2425
    PyObject *robj = SwigPyObject_New(ptr, type, own);
 
2426
    SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
 
2427
    if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
 
2428
      PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
 
2429
      if (inst) {
 
2430
        Py_DECREF(robj);
 
2431
        robj = inst;
 
2432
      }
 
2433
    }
 
2434
    return robj;
 
2435
  }
 
2436
}
 
2437
 
 
2438
/* Create a new packed object */
 
2439
 
 
2440
SWIGRUNTIMEINLINE PyObject *
 
2441
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
 
2442
  return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
 
2443
}
 
2444
 
 
2445
/* -----------------------------------------------------------------------------*
 
2446
 *  Get type list 
 
2447
 * -----------------------------------------------------------------------------*/
 
2448
 
 
2449
#ifdef SWIG_LINK_RUNTIME
 
2450
void *SWIG_ReturnGlobalTypeList(void *);
 
2451
#endif
 
2452
 
 
2453
SWIGRUNTIME swig_module_info *
 
2454
SWIG_Python_GetModule(void) {
 
2455
  static void *type_pointer = (void *)0;
 
2456
  /* first check if module already created */
 
2457
  if (!type_pointer) {
 
2458
#ifdef SWIG_LINK_RUNTIME
 
2459
    type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 
2460
#else
 
2461
#ifdef USE_CAPSULES
 
2462
    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
 
2463
#else
 
2464
    type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 
2465
                                    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
 
2466
#endif
 
2467
    if (PyErr_Occurred()) {
 
2468
      PyErr_Clear();
 
2469
      type_pointer = (void *)0;
 
2470
    }
 
2471
#endif
 
2472
  }
 
2473
  return (swig_module_info *) type_pointer;
 
2474
}
 
2475
 
 
2476
#if PY_MAJOR_VERSION < 2
 
2477
/* PyModule_AddObject function was introduced in Python 2.0.  The following function
 
2478
   is copied out of Python/modsupport.c in python version 2.3.4 */
 
2479
SWIGINTERN int
 
2480
PyModule_AddObject(PyObject *m, char *name, PyObject *o)
 
2481
{
 
2482
  PyObject *dict;
 
2483
  if (!PyModule_Check(m)) {
 
2484
    PyErr_SetString(PyExc_TypeError,
 
2485
                    "PyModule_AddObject() needs module as first arg");
 
2486
    return SWIG_ERROR;
 
2487
  }
 
2488
  if (!o) {
 
2489
    PyErr_SetString(PyExc_TypeError,
 
2490
                    "PyModule_AddObject() needs non-NULL value");
 
2491
    return SWIG_ERROR;
 
2492
  }
 
2493
  
 
2494
  dict = PyModule_GetDict(m);
 
2495
  if (dict == NULL) {
 
2496
    /* Internal error -- modules must have a dict! */
 
2497
    PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
 
2498
                 PyModule_GetName(m));
 
2499
    return SWIG_ERROR;
 
2500
  }
 
2501
  if (PyDict_SetItemString(dict, name, o))
 
2502
    return SWIG_ERROR;
 
2503
  Py_DECREF(o);
 
2504
  return SWIG_OK;
 
2505
}
 
2506
#endif
 
2507
 
 
2508
SWIGRUNTIME void
 
2509
SWIG_Python_DestroyModule(void *vptr)
 
2510
{
 
2511
  size_t i;
 
2512
#ifdef USE_CAPSULES
 
2513
  swig_module_info *swig_module =
 
2514
    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
 
2515
#else
 
2516
  swig_module_info *swig_module = (swig_module_info *) vptr;
 
2517
#endif
 
2518
  swig_type_info **types = swig_module->types;
 
2519
  for (i =0; i < swig_module->size; ++i) {
 
2520
    swig_type_info *ty = types[i];
 
2521
    if (ty->owndata) {
 
2522
      SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
 
2523
      if (data) SwigPyClientData_Del(data);
 
2524
    }
 
2525
  }
 
2526
  Py_DECREF(SWIG_This());
 
2527
  swig_this = NULL;
 
2528
}
 
2529
 
 
2530
SWIGRUNTIME void
 
2531
SWIG_Python_SetModule(swig_module_info *swig_module) {
 
2532
  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
 
2533
 
 
2534
#if PY_VERSION_HEX >= 0x03000000
 
2535
 /* Add a dummy module object into sys.modules */
 
2536
  PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
 
2537
#else
 
2538
  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 
2539
                                   swig_empty_runtime_method_table);
 
2540
#endif
 
2541
#ifdef USE_CAPSULES
 
2542
  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
 
2543
                                    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
 
2544
#else
 
2545
  PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
 
2546
#endif
 
2547
  if (pointer && module) {
 
2548
#ifdef USE_CAPSULES
 
2549
    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
 
2550
#else
 
2551
    PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
 
2552
#endif
 
2553
  } else {
 
2554
    Py_XDECREF(pointer);
 
2555
  }
 
2556
}
 
2557
 
 
2558
/* The python cached type query */
 
2559
SWIGRUNTIME PyObject *
 
2560
SWIG_Python_TypeCache(void) {
 
2561
  static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
 
2562
  return cache;
 
2563
}
 
2564
 
 
2565
SWIGRUNTIME swig_type_info *
 
2566
SWIG_Python_TypeQuery(const char *type)
 
2567
{
 
2568
  PyObject *cache = SWIG_Python_TypeCache();
 
2569
  PyObject *key = SWIG_Python_str_FromChar(type); 
 
2570
  PyObject *obj = PyDict_GetItem(cache, key);
 
2571
  swig_type_info *descriptor;
 
2572
  if (obj) {
 
2573
#ifdef USE_CAPSULES
 
2574
    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
 
2575
#else
 
2576
    descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
 
2577
#endif
 
2578
  } else {
 
2579
    swig_module_info *swig_module = SWIG_Python_GetModule();
 
2580
    descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
 
2581
    if (descriptor) {
 
2582
#ifdef USE_CAPSULES
 
2583
      obj = PyCapsule_New(descriptor, type, NULL);
 
2584
#else
 
2585
      obj = PyCObject_FromVoidPtr(descriptor, NULL);
 
2586
#endif
 
2587
      PyDict_SetItem(cache, key, obj);
 
2588
      Py_DECREF(obj);
 
2589
    }
 
2590
  }
 
2591
  Py_DECREF(key);
 
2592
  return descriptor;
 
2593
}
 
2594
 
 
2595
/* 
 
2596
   For backward compatibility only
 
2597
*/
 
2598
#define SWIG_POINTER_EXCEPTION  0
 
2599
#define SWIG_arg_fail(arg)      SWIG_Python_ArgFail(arg)
 
2600
#define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)
 
2601
 
 
2602
SWIGRUNTIME int
 
2603
SWIG_Python_AddErrMesg(const char* mesg, int infront)
 
2604
{  
 
2605
  if (PyErr_Occurred()) {
 
2606
    PyObject *type = 0;
 
2607
    PyObject *value = 0;
 
2608
    PyObject *traceback = 0;
 
2609
    PyErr_Fetch(&type, &value, &traceback);
 
2610
    if (value) {
 
2611
      char *tmp;
 
2612
      PyObject *old_str = PyObject_Str(value);
 
2613
      Py_XINCREF(type);
 
2614
      PyErr_Clear();
 
2615
      if (infront) {
 
2616
        PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
 
2617
      } else {
 
2618
        PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
 
2619
      }
 
2620
      SWIG_Python_str_DelForPy3(tmp);
 
2621
      Py_DECREF(old_str);
 
2622
    }
 
2623
    return 1;
 
2624
  } else {
 
2625
    return 0;
 
2626
  }
 
2627
}
 
2628
  
 
2629
SWIGRUNTIME int
 
2630
SWIG_Python_ArgFail(int argnum)
 
2631
{
 
2632
  if (PyErr_Occurred()) {
 
2633
    /* add information about failing argument */
 
2634
    char mesg[256];
 
2635
    PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
 
2636
    return SWIG_Python_AddErrMesg(mesg, 1);
 
2637
  } else {
 
2638
    return 0;
 
2639
  }
 
2640
}
 
2641
 
 
2642
SWIGRUNTIMEINLINE const char *
 
2643
SwigPyObject_GetDesc(PyObject *self)
 
2644
{
 
2645
  SwigPyObject *v = (SwigPyObject *)self;
 
2646
  swig_type_info *ty = v ? v->ty : 0;
 
2647
  return ty ? ty->str : (char*)"";
 
2648
}
 
2649
 
 
2650
SWIGRUNTIME void
 
2651
SWIG_Python_TypeError(const char *type, PyObject *obj)
 
2652
{
 
2653
  if (type) {
 
2654
#if defined(SWIG_COBJECT_TYPES)
 
2655
    if (obj && SwigPyObject_Check(obj)) {
 
2656
      const char *otype = (const char *) SwigPyObject_GetDesc(obj);
 
2657
      if (otype) {
 
2658
        PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
 
2659
                     type, otype);
 
2660
        return;
 
2661
      }
 
2662
    } else 
 
2663
#endif      
 
2664
    {
 
2665
      const char *otype = (obj ? obj->ob_type->tp_name : 0); 
 
2666
      if (otype) {
 
2667
        PyObject *str = PyObject_Str(obj);
 
2668
        const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
 
2669
        if (cstr) {
 
2670
          PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
 
2671
                       type, otype, cstr);
 
2672
          SWIG_Python_str_DelForPy3(cstr);
 
2673
        } else {
 
2674
          PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
 
2675
                       type, otype);
 
2676
        }
 
2677
        Py_XDECREF(str);
 
2678
        return;
 
2679
      }
 
2680
    }   
 
2681
    PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
 
2682
  } else {
 
2683
    PyErr_Format(PyExc_TypeError, "unexpected type is received");
 
2684
  }
 
2685
}
 
2686
 
 
2687
 
 
2688
/* Convert a pointer value, signal an exception on a type mismatch */
 
2689
SWIGRUNTIME void *
 
2690
SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
 
2691
  void *result;
 
2692
  if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
 
2693
    PyErr_Clear();
 
2694
#if SWIG_POINTER_EXCEPTION
 
2695
    if (flags) {
 
2696
      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
 
2697
      SWIG_Python_ArgFail(argnum);
 
2698
    }
 
2699
#endif
 
2700
  }
 
2701
  return result;
 
2702
}
 
2703
 
 
2704
 
 
2705
#ifdef __cplusplus
 
2706
#if 0
 
2707
{ /* cc-mode */
 
2708
#endif
 
2709
}
 
2710
#endif
 
2711
 
 
2712
 
 
2713
 
 
2714
#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
 
2715
 
 
2716
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
 
2717
 
 
2718
 
 
2719
 
 
2720
/* -------- TYPES TABLE (BEGIN) -------- */
 
2721
 
 
2722
#define SWIGTYPE_p_char swig_types[0]
 
2723
static swig_type_info *swig_types[2];
 
2724
static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0};
 
2725
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 
2726
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
2727
 
 
2728
/* -------- TYPES TABLE (END) -------- */
 
2729
 
 
2730
#if (PY_VERSION_HEX <= 0x02000000)
 
2731
# if !defined(SWIG_PYTHON_CLASSIC)
 
2732
#  error "This python version requires swig to be run with the '-classic' option"
 
2733
# endif
 
2734
#endif
 
2735
 
 
2736
/*-----------------------------------------------
 
2737
              @(target):= _csgraph.so
 
2738
  ------------------------------------------------*/
 
2739
#if PY_VERSION_HEX >= 0x03000000
 
2740
#  define SWIG_init    PyInit__csgraph
 
2741
 
 
2742
#else
 
2743
#  define SWIG_init    init_csgraph
 
2744
 
 
2745
#endif
 
2746
#define SWIG_name    "_csgraph"
 
2747
 
 
2748
#define SWIGVERSION 0x020001 
 
2749
#define SWIG_VERSION SWIGVERSION
 
2750
 
 
2751
 
 
2752
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) 
 
2753
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) 
 
2754
 
 
2755
 
 
2756
#include <stdexcept>
 
2757
 
 
2758
 
 
2759
namespace swig {
 
2760
  class SwigPtr_PyObject {
 
2761
  protected:
 
2762
    PyObject *_obj;
 
2763
 
 
2764
  public:
 
2765
    SwigPtr_PyObject() :_obj(0)
 
2766
    {
 
2767
    }
 
2768
 
 
2769
    SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
 
2770
    {
 
2771
      Py_XINCREF(_obj);      
 
2772
    }
 
2773
    
 
2774
    SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
 
2775
    {
 
2776
      if (initial_ref) {
 
2777
        Py_XINCREF(_obj);
 
2778
      }
 
2779
    }
 
2780
    
 
2781
    SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) 
 
2782
    {
 
2783
      Py_XINCREF(item._obj);
 
2784
      Py_XDECREF(_obj);
 
2785
      _obj = item._obj;
 
2786
      return *this;      
 
2787
    }
 
2788
    
 
2789
    ~SwigPtr_PyObject() 
 
2790
    {
 
2791
      Py_XDECREF(_obj);
 
2792
    }
 
2793
    
 
2794
    operator PyObject *() const
 
2795
    {
 
2796
      return _obj;
 
2797
    }
 
2798
 
 
2799
    PyObject *operator->() const
 
2800
    {
 
2801
      return _obj;
 
2802
    }
 
2803
  };
 
2804
}
 
2805
 
 
2806
 
 
2807
namespace swig {
 
2808
  struct SwigVar_PyObject : SwigPtr_PyObject {
 
2809
    SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
 
2810
    
 
2811
    SwigVar_PyObject & operator = (PyObject* obj)
 
2812
    {
 
2813
      Py_XDECREF(_obj);
 
2814
      _obj = obj;
 
2815
      return *this;      
 
2816
    }
 
2817
  };
 
2818
}
 
2819
 
 
2820
 
 
2821
#include "py3k.h"
 
2822
#define SWIG_FILE_WITH_INIT
 
2823
#include "Python.h"
 
2824
#include "numpy/arrayobject.h"
 
2825
#include "complex_ops.h"
 
2826
/*#include "sparsetools.h"*/
 
2827
 
 
2828
 
 
2829
#ifndef SWIG_FILE_WITH_INIT
 
2830
#  define NO_IMPORT_ARRAY
 
2831
#endif
 
2832
#include "stdio.h"
 
2833
#include <numpy/arrayobject.h>
 
2834
#include "complex_ops.h"
 
2835
 
 
2836
 
 
2837
/* The following code originally appeared in
 
2838
 * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
 
2839
 * translated from C++ to C by John Hunter.  Bill Spotz has modified
 
2840
 * it slightly to fix some minor bugs, upgrade to numpy (all
 
2841
 * versions), add some comments and some functionality.
 
2842
 */
 
2843
 
 
2844
/* Macros to extract array attributes.
 
2845
 */
 
2846
#define is_array(a)            ((a) && PyArray_Check((PyArrayObject *)a))
 
2847
#define array_type(a)          (int)(PyArray_TYPE(a))
 
2848
#define array_numdims(a)       (((PyArrayObject *)a)->nd)
 
2849
#define array_dimensions(a)    (((PyArrayObject *)a)->dimensions)
 
2850
#define array_size(a,i)        (((PyArrayObject *)a)->dimensions[i])
 
2851
#define array_data(a)          (((PyArrayObject *)a)->data)
 
2852
#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
 
2853
#define array_is_native(a)     (PyArray_ISNOTSWAPPED(a))
 
2854
 
 
2855
/* Support older NumPy data type names
 
2856
*/
 
2857
#if NDARRAY_VERSION < 0x01000000
 
2858
#define NPY_BOOL        PyArray_BOOL
 
2859
#define NPY_BYTE        PyArray_BYTE
 
2860
#define NPY_UBYTE       PyArray_UBYTE
 
2861
#define NPY_SHORT       PyArray_SHORT
 
2862
#define NPY_USHORT      PyArray_USHORT
 
2863
#define NPY_INT         PyArray_INT
 
2864
#define NPY_UINT        PyArray_UINT
 
2865
#define NPY_LONG        PyArray_LONG
 
2866
#define NPY_ULONG       PyArray_ULONG
 
2867
#define NPY_LONGLONG    PyArray_LONGLONG
 
2868
#define NPY_ULONGLONG   PyArray_ULONGLONG
 
2869
#define NPY_FLOAT       PyArray_FLOAT
 
2870
#define NPY_DOUBLE      PyArray_DOUBLE
 
2871
#define NPY_LONGDOUBLE  PyArray_LONGDOUBLE
 
2872
#define NPY_CFLOAT      PyArray_CFLOAT
 
2873
#define NPY_CDOUBLE     PyArray_CDOUBLE
 
2874
#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE
 
2875
#define NPY_OBJECT      PyArray_OBJECT
 
2876
#define NPY_STRING      PyArray_STRING
 
2877
#define NPY_UNICODE     PyArray_UNICODE
 
2878
#define NPY_VOID        PyArray_VOID
 
2879
#define NPY_NTYPES      PyArray_NTYPES
 
2880
#define NPY_NOTYPE      PyArray_NOTYPE
 
2881
#define NPY_CHAR        PyArray_CHAR
 
2882
#define NPY_USERDEF     PyArray_USERDEF
 
2883
#define npy_intp        intp
 
2884
#endif
 
2885
 
 
2886
/* Given a PyObject, return a string describing its type.
 
2887
 */
 
2888
const char* pytype_string(PyObject* py_obj) {
 
2889
  if (py_obj == NULL          ) return "C NULL value";
 
2890
  if (py_obj == Py_None       ) return "Python None" ;
 
2891
  if (PyCallable_Check(py_obj)) return "callable"    ;
 
2892
  if (PyString_Check(  py_obj)) return "string"      ;
 
2893
  if (PyInt_Check(     py_obj)) return "int"         ;
 
2894
  if (PyFloat_Check(   py_obj)) return "float"       ;
 
2895
  if (PyDict_Check(    py_obj)) return "dict"        ;
 
2896
  if (PyList_Check(    py_obj)) return "list"        ;
 
2897
  if (PyTuple_Check(   py_obj)) return "tuple"       ;
 
2898
  if (PyFile_Check(    py_obj)) return "file"        ;
 
2899
  if (PyModule_Check(  py_obj)) return "module"      ;
 
2900
  if (PyInstance_Check(py_obj)) return "instance"    ;
 
2901
 
 
2902
  return "unkown type";
 
2903
}
 
2904
 
 
2905
/* Given a NumPy typecode, return a string describing the type.
 
2906
 */
 
2907
const char* typecode_string(int typecode) {
 
2908
  static const char* type_names[25] = {"bool", "byte", "unsigned byte",
 
2909
                                 "short", "unsigned short", "int",
 
2910
                                 "unsigned int", "long", "unsigned long",
 
2911
                                 "long long", "unsigned long long",
 
2912
                                 "float", "double", "long double",
 
2913
                                 "complex float", "complex double",
 
2914
                                 "complex long double", "object",
 
2915
                                 "string", "unicode", "void", "ntypes",
 
2916
                                 "notype", "char", "unknown"};
 
2917
  return typecode < 24 ? type_names[typecode] : type_names[24];
 
2918
}
 
2919
 
 
2920
/* Make sure input has correct numpy type.  Allow character and byte
 
2921
 * to match.  Also allow int and long to match.  This is deprecated.
 
2922
 * You should use PyArray_EquivTypenums() instead.
 
2923
 */
 
2924
int type_match(int actual_type, int desired_type) {
 
2925
  return PyArray_EquivTypenums(actual_type, desired_type);
 
2926
}
 
2927
 
 
2928
/* Given a PyObject pointer, cast it to a PyArrayObject pointer if
 
2929
 * legal.  If not, set the python error string appropriately and
 
2930
 * return NULL.
 
2931
 */
 
2932
PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) {
 
2933
  PyArrayObject* ary = NULL;
 
2934
  if (is_array(input) && (typecode == NPY_NOTYPE ||
 
2935
                          PyArray_EquivTypenums(array_type(input), typecode))) {
 
2936
    ary = (PyArrayObject*) input;
 
2937
  }
 
2938
  else if is_array(input) {
 
2939
    const char* desired_type = typecode_string(typecode);
 
2940
    const char* actual_type  = typecode_string(array_type(input));
 
2941
    PyErr_Format(PyExc_TypeError, 
 
2942
                 "Array of type '%s' required.  Array of type '%s' given", 
 
2943
                 desired_type, actual_type);
 
2944
    ary = NULL;
 
2945
  }
 
2946
  else {
 
2947
    const char * desired_type = typecode_string(typecode);
 
2948
    const char * actual_type  = pytype_string(input);
 
2949
    PyErr_Format(PyExc_TypeError, 
 
2950
                 "Array of type '%s' required.  A '%s' was given", 
 
2951
                 desired_type, actual_type);
 
2952
    ary = NULL;
 
2953
  }
 
2954
  return ary;
 
2955
}
 
2956
 
 
2957
/* Convert the given PyObject to a NumPy array with the given
 
2958
 * typecode.  On success, return a valid PyArrayObject* with the
 
2959
 * correct type.  On failure, the python error string will be set and
 
2960
 * the routine returns NULL.
 
2961
 */
 
2962
PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
 
2963
                                             int* is_new_object) {
 
2964
  PyArrayObject* ary = NULL;
 
2965
  PyObject* py_obj;
 
2966
  if (is_array(input) && (typecode == NPY_NOTYPE ||
 
2967
                          PyArray_EquivTypenums(array_type(input),typecode))) {
 
2968
    ary = (PyArrayObject*) input;
 
2969
    *is_new_object = 0;
 
2970
  }
 
2971
  else {
 
2972
    py_obj = PyArray_FromObject(input, typecode, 0, 0);
 
2973
    /* If NULL, PyArray_FromObject will have set python error value.*/
 
2974
    ary = (PyArrayObject*) py_obj;
 
2975
    *is_new_object = 1;
 
2976
  }
 
2977
  return ary;
 
2978
}
 
2979
 
 
2980
/* Given a PyArrayObject, check to see if it is contiguous.  If so,
 
2981
 * return the input pointer and flag it as not a new object.  If it is
 
2982
 * not contiguous, create a new PyArrayObject using the original data,
 
2983
 * flag it as a new object and return the pointer.
 
2984
 */
 
2985
PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
 
2986
                               int min_dims, int max_dims) {
 
2987
  PyArrayObject* result;
 
2988
  if (array_is_contiguous(ary)) {
 
2989
    result = ary;
 
2990
    *is_new_object = 0;
 
2991
  }
 
2992
  else {
 
2993
    result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, 
 
2994
                                                           array_type(ary), 
 
2995
                                                           min_dims,
 
2996
                                                           max_dims);
 
2997
    *is_new_object = 1;
 
2998
  }
 
2999
  return result;
 
3000
}
 
3001
 
 
3002
/* Convert a given PyObject to a contiguous PyArrayObject of the
 
3003
 * specified type.  If the input object is not a contiguous
 
3004
 * PyArrayObject, a new one will be created and the new object flag
 
3005
 * will be set.
 
3006
 */
 
3007
PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
 
3008
                                                        int typecode,
 
3009
                                                        int* is_new_object) {
 
3010
  int is_new1 = 0;
 
3011
  int is_new2 = 0;
 
3012
  PyArrayObject* ary2;
 
3013
  PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, &is_new1);
 
3014
  if (ary1) {
 
3015
    ary2 = make_contiguous(ary1, &is_new2, 0, 0);
 
3016
    if ( is_new1 && is_new2) {
 
3017
      Py_DECREF(ary1);
 
3018
    }
 
3019
    ary1 = ary2;    
 
3020
  }
 
3021
  *is_new_object = is_new1 || is_new2;
 
3022
  return ary1;
 
3023
}
 
3024
 
 
3025
/* Test whether a python object is contiguous.  If array is
 
3026
 * contiguous, return 1.  Otherwise, set the python error string and
 
3027
 * return 0.
 
3028
 */
 
3029
int require_contiguous(PyArrayObject* ary) {
 
3030
  int contiguous = 1;
 
3031
  if (!array_is_contiguous(ary)) {
 
3032
    PyErr_SetString(PyExc_TypeError,
 
3033
                    "Array must be contiguous.  A non-contiguous array was given");
 
3034
    contiguous = 0;
 
3035
  }
 
3036
  return contiguous;
 
3037
}
 
3038
 
 
3039
/* Require that a numpy array is not byte-swapped.  If the array is
 
3040
 * not byte-swapped, return 1.  Otherwise, set the python error string
 
3041
 * and return 0.
 
3042
 */
 
3043
int require_native(PyArrayObject* ary) {
 
3044
  int native = 1;
 
3045
  if (!array_is_native(ary)) {
 
3046
    PyErr_SetString(PyExc_TypeError,
 
3047
                    "Array must have native byteorder.  A byte-swapped array was given");
 
3048
    native = 0;
 
3049
  }
 
3050
  return native;
 
3051
}
 
3052
 
 
3053
/* Require the given PyArrayObject to have a specified number of
 
3054
 * dimensions.  If the array has the specified number of dimensions,
 
3055
 * return 1.  Otherwise, set the python error string and return 0.
 
3056
 */
 
3057
int require_dimensions(PyArrayObject* ary, int exact_dimensions) {
 
3058
  int success = 1;
 
3059
  if (array_numdims(ary) != exact_dimensions) {
 
3060
    PyErr_Format(PyExc_TypeError, 
 
3061
                 "Array must have %d dimensions.  Given array has %d dimensions", 
 
3062
                 exact_dimensions, array_numdims(ary));
 
3063
    success = 0;
 
3064
  }
 
3065
  return success;
 
3066
}
 
3067
 
 
3068
/* Require the given PyArrayObject to have one of a list of specified
 
3069
 * number of dimensions.  If the array has one of the specified number
 
3070
 * of dimensions, return 1.  Otherwise, set the python error string
 
3071
 * and return 0.
 
3072
 */
 
3073
int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n) {
 
3074
  int success = 0;
 
3075
  int i;
 
3076
  char dims_str[255] = "";
 
3077
  char s[255];
 
3078
  for (i = 0; i < n && !success; i++) {
 
3079
    if (array_numdims(ary) == exact_dimensions[i]) {
 
3080
      success = 1;
 
3081
    }
 
3082
  }
 
3083
  if (!success) {
 
3084
    for (i = 0; i < n-1; i++) {
 
3085
      sprintf(s, "%d, ", exact_dimensions[i]);                
 
3086
      strcat(dims_str,s);
 
3087
    }
 
3088
    sprintf(s, " or %d", exact_dimensions[n-1]);            
 
3089
    strcat(dims_str,s);
 
3090
    PyErr_Format(PyExc_TypeError, 
 
3091
                 "Array must be have %s dimensions.  Given array has %d dimensions",
 
3092
                 dims_str, array_numdims(ary));
 
3093
  }
 
3094
  return success;
 
3095
}    
 
3096
 
 
3097
/* Require the given PyArrayObject to have a specified shape.  If the
 
3098
 * array has the specified shape, return 1.  Otherwise, set the python
 
3099
 * error string and return 0.
 
3100
 */
 
3101
int require_size(PyArrayObject* ary, npy_intp* size, int n) {
 
3102
  int i;
 
3103
  int success = 1;
 
3104
  int len;
 
3105
  char desired_dims[255] = "[";
 
3106
  char s[255];
 
3107
  char actual_dims[255] = "[";
 
3108
  for(i=0; i < n;i++) {
 
3109
    if (size[i] != -1 &&  size[i] != array_size(ary,i)) {
 
3110
      success = 0;    
 
3111
    }
 
3112
  }
 
3113
  if (!success) {
 
3114
    for (i = 0; i < n; i++) {
 
3115
      if (size[i] == -1) {
 
3116
        sprintf(s, "*,");                
 
3117
      }
 
3118
      else
 
3119
      {
 
3120
        sprintf(s,"%" NPY_INTP_FMT ",", size[i]);                
 
3121
      }    
 
3122
      strcat(desired_dims,s);
 
3123
    }
 
3124
    len = strlen(desired_dims);
 
3125
    desired_dims[len-1] = ']';
 
3126
    for (i = 0; i < n; i++) {
 
3127
      sprintf(s,"%" NPY_INTP_FMT ",", array_size(ary,i));                            
 
3128
      strcat(actual_dims,s);
 
3129
    }
 
3130
    len = strlen(actual_dims);
 
3131
    actual_dims[len-1] = ']';
 
3132
    PyErr_Format(PyExc_TypeError, 
 
3133
                 "Array must be have shape of %s.  Given array has shape of %s",
 
3134
                 desired_dims, actual_dims);
 
3135
  }
 
3136
  return success;
 
3137
}
 
3138
/* End John Hunter translation (with modifications by Bill Spotz) */
 
3139
 
 
3140
 
 
3141
 
 
3142
 
 
3143
 
 
3144
/*!
 
3145
  Appends @a what to @a where. On input, @a where need not to be a tuple, but on
 
3146
  return it always is.
 
3147
 
 
3148
  @par Revision history:
 
3149
  - 17.02.2005, c
 
3150
*/
 
3151
PyObject *helper_appendToTuple( PyObject *where, PyObject *what ) {
 
3152
  PyObject *o2, *o3;
 
3153
 
 
3154
  if ((!where) || (where == Py_None)) {
 
3155
    where = what;
 
3156
  } else {
 
3157
    if (!PyTuple_Check( where )) {
 
3158
      o2 = where;
 
3159
      where = PyTuple_New( 1 );
 
3160
      PyTuple_SetItem( where, 0, o2 );
 
3161
    }
 
3162
    o3 = PyTuple_New( 1 );
 
3163
    PyTuple_SetItem( o3, 0, what );
 
3164
    o2 = where;
 
3165
    where = PySequence_Concat( o2, o3 );
 
3166
    Py_DECREF( o2 );
 
3167
    Py_DECREF( o3 );
 
3168
  }
 
3169
  return where;
 
3170
}
 
3171
 
 
3172
 
 
3173
 
 
3174
 
 
3175
 
 
3176
 
 
3177
#include "csgraph.h"
 
3178
 
 
3179
 
 
3180
#include <limits.h>
 
3181
#if !defined(SWIG_NO_LLONG_MAX)
 
3182
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
 
3183
#   define LLONG_MAX __LONG_LONG_MAX__
 
3184
#   define LLONG_MIN (-LLONG_MAX - 1LL)
 
3185
#   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
 
3186
# endif
 
3187
#endif
 
3188
 
 
3189
 
 
3190
SWIGINTERN int
 
3191
SWIG_AsVal_double (PyObject *obj, double *val)
 
3192
{
 
3193
  int res = SWIG_TypeError;
 
3194
  if (PyFloat_Check(obj)) {
 
3195
    if (val) *val = PyFloat_AsDouble(obj);
 
3196
    return SWIG_OK;
 
3197
  } else if (PyInt_Check(obj)) {
 
3198
    if (val) *val = PyInt_AsLong(obj);
 
3199
    return SWIG_OK;
 
3200
  } else if (PyLong_Check(obj)) {
 
3201
    double v = PyLong_AsDouble(obj);
 
3202
    if (!PyErr_Occurred()) {
 
3203
      if (val) *val = v;
 
3204
      return SWIG_OK;
 
3205
    } else {
 
3206
      PyErr_Clear();
 
3207
    }
 
3208
  }
 
3209
#ifdef SWIG_PYTHON_CAST_MODE
 
3210
  {
 
3211
    int dispatch = 0;
 
3212
    double d = PyFloat_AsDouble(obj);
 
3213
    if (!PyErr_Occurred()) {
 
3214
      if (val) *val = d;
 
3215
      return SWIG_AddCast(SWIG_OK);
 
3216
    } else {
 
3217
      PyErr_Clear();
 
3218
    }
 
3219
    if (!dispatch) {
 
3220
      long v = PyLong_AsLong(obj);
 
3221
      if (!PyErr_Occurred()) {
 
3222
        if (val) *val = v;
 
3223
        return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
 
3224
      } else {
 
3225
        PyErr_Clear();
 
3226
      }
 
3227
    }
 
3228
  }
 
3229
#endif
 
3230
  return res;
 
3231
}
 
3232
 
 
3233
 
 
3234
#include <float.h>
 
3235
 
 
3236
 
 
3237
#include <math.h>
 
3238
 
 
3239
 
 
3240
SWIGINTERNINLINE int
 
3241
SWIG_CanCastAsInteger(double *d, double min, double max) {
 
3242
  double x = *d;
 
3243
  if ((min <= x && x <= max)) {
 
3244
   double fx = floor(x);
 
3245
   double cx = ceil(x);
 
3246
   double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
 
3247
   if ((errno == EDOM) || (errno == ERANGE)) {
 
3248
     errno = 0;
 
3249
   } else {
 
3250
     double summ, reps, diff;
 
3251
     if (rd < x) {
 
3252
       diff = x - rd;
 
3253
     } else if (rd > x) {
 
3254
       diff = rd - x;
 
3255
     } else {
 
3256
       return 1;
 
3257
     }
 
3258
     summ = rd + x;
 
3259
     reps = diff/summ;
 
3260
     if (reps < 8*DBL_EPSILON) {
 
3261
       *d = rd;
 
3262
       return 1;
 
3263
     }
 
3264
   }
 
3265
  }
 
3266
  return 0;
 
3267
}
 
3268
 
 
3269
 
 
3270
SWIGINTERN int
 
3271
SWIG_AsVal_long (PyObject *obj, long* val)
 
3272
{
 
3273
  if (PyInt_Check(obj)) {
 
3274
    if (val) *val = PyInt_AsLong(obj);
 
3275
    return SWIG_OK;
 
3276
  } else if (PyLong_Check(obj)) {
 
3277
    long v = PyLong_AsLong(obj);
 
3278
    if (!PyErr_Occurred()) {
 
3279
      if (val) *val = v;
 
3280
      return SWIG_OK;
 
3281
    } else {
 
3282
      PyErr_Clear();
 
3283
    }
 
3284
  }
 
3285
#ifdef SWIG_PYTHON_CAST_MODE
 
3286
  {
 
3287
    int dispatch = 0;
 
3288
    long v = PyInt_AsLong(obj);
 
3289
    if (!PyErr_Occurred()) {
 
3290
      if (val) *val = v;
 
3291
      return SWIG_AddCast(SWIG_OK);
 
3292
    } else {
 
3293
      PyErr_Clear();
 
3294
    }
 
3295
    if (!dispatch) {
 
3296
      double d;
 
3297
      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
 
3298
      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
 
3299
        if (val) *val = (long)(d);
 
3300
        return res;
 
3301
      }
 
3302
    }
 
3303
  }
 
3304
#endif
 
3305
  return SWIG_TypeError;
 
3306
}
 
3307
 
 
3308
 
 
3309
SWIGINTERN int
 
3310
SWIG_AsVal_int (PyObject * obj, int *val)
 
3311
{
 
3312
  long v;
 
3313
  int res = SWIG_AsVal_long (obj, &v);
 
3314
  if (SWIG_IsOK(res)) {
 
3315
    if ((v < INT_MIN || v > INT_MAX)) {
 
3316
      return SWIG_OverflowError;
 
3317
    } else {
 
3318
      if (val) *val = static_cast< int >(v);
 
3319
    }
 
3320
  }  
 
3321
  return res;
 
3322
}
 
3323
 
 
3324
 
 
3325
  #define SWIG_From_long   PyInt_FromLong 
 
3326
 
 
3327
 
 
3328
SWIGINTERNINLINE PyObject *
 
3329
SWIG_From_int  (int value)
 
3330
{    
 
3331
  return SWIG_From_long  (value);
 
3332
}
 
3333
 
 
3334
 
 
3335
#include "csgraph.h"
 
3336
 
 
3337
#ifdef __cplusplus
 
3338
extern "C" {
 
3339
#endif
 
3340
SWIGINTERN PyObject *_wrap_cs_graph_components(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
 
3341
  PyObject *resultobj = 0;
 
3342
  int arg1 ;
 
3343
  int *arg2 ;
 
3344
  int *arg3 ;
 
3345
  int *arg4 ;
 
3346
  int val1 ;
 
3347
  int ecode1 = 0 ;
 
3348
  PyArrayObject *array2 = NULL ;
 
3349
  int is_new_object2 ;
 
3350
  PyArrayObject *array3 = NULL ;
 
3351
  int is_new_object3 ;
 
3352
  PyArrayObject *temp4 = NULL ;
 
3353
  PyObject * obj0 = 0 ;
 
3354
  PyObject * obj1 = 0 ;
 
3355
  PyObject * obj2 = 0 ;
 
3356
  PyObject * obj3 = 0 ;
 
3357
  int result;
 
3358
  
 
3359
  if (!PyArg_ParseTuple(args,(char *)"OOOO:cs_graph_components",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
 
3360
  ecode1 = SWIG_AsVal_int(obj0, &val1);
 
3361
  if (!SWIG_IsOK(ecode1)) {
 
3362
    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cs_graph_components" "', argument " "1"" of type '" "int""'");
 
3363
  } 
 
3364
  arg1 = static_cast< int >(val1);
 
3365
  {
 
3366
    npy_intp size[1] = {
 
3367
      -1
 
3368
    };
 
3369
    array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2);
 
3370
    if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)
 
3371
      || !require_contiguous(array2)   || !require_native(array2)) SWIG_fail;
 
3372
    
 
3373
    arg2 = (int*) array2->data;
 
3374
  }
 
3375
  {
 
3376
    npy_intp size[1] = {
 
3377
      -1
 
3378
    };
 
3379
    array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3);
 
3380
    if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)
 
3381
      || !require_contiguous(array3)   || !require_native(array3)) SWIG_fail;
 
3382
    
 
3383
    arg3 = (int*) array3->data;
 
3384
  }
 
3385
  {
 
3386
    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
 
3387
    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
 
3388
    arg4 = (int*) array_data(temp4);
 
3389
  }
 
3390
  result = (int)cs_graph_components< int >(arg1,(int const (*))arg2,(int const (*))arg3,arg4);
 
3391
  resultobj = SWIG_From_int(static_cast< int >(result));
 
3392
  {
 
3393
    if (is_new_object2 && array2) {
 
3394
      Py_DECREF(array2); 
 
3395
    }
 
3396
  }
 
3397
  {
 
3398
    if (is_new_object3 && array3) {
 
3399
      Py_DECREF(array3); 
 
3400
    }
 
3401
  }
 
3402
  return resultobj;
 
3403
fail:
 
3404
  {
 
3405
    if (is_new_object2 && array2) {
 
3406
      Py_DECREF(array2); 
 
3407
    }
 
3408
  }
 
3409
  {
 
3410
    if (is_new_object3 && array3) {
 
3411
      Py_DECREF(array3); 
 
3412
    }
 
3413
  }
 
3414
  return NULL;
 
3415
}
 
3416
 
 
3417
 
 
3418
static PyMethodDef SwigMethods[] = {
 
3419
         { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
 
3420
         { (char *)"cs_graph_components", _wrap_cs_graph_components, METH_VARARGS, (char *)"cs_graph_components(int n_nod, int Ap, int Aj, int flag) -> int"},
 
3421
         { NULL, NULL, 0, NULL }
 
3422
};
 
3423
 
 
3424
 
 
3425
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
3426
 
 
3427
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
 
3428
 
 
3429
static swig_type_info *swig_type_initial[] = {
 
3430
  &_swigt__p_char,
 
3431
};
 
3432
 
 
3433
static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
 
3434
 
 
3435
static swig_cast_info *swig_cast_initial[] = {
 
3436
  _swigc__p_char,
 
3437
};
 
3438
 
 
3439
 
 
3440
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
 
3441
 
 
3442
static swig_const_info swig_const_table[] = {
 
3443
{0, 0, 0, 0.0, 0, 0}};
 
3444
 
 
3445
#ifdef __cplusplus
 
3446
}
 
3447
#endif
 
3448
/* -----------------------------------------------------------------------------
 
3449
 * Type initialization:
 
3450
 * This problem is tough by the requirement that no dynamic 
 
3451
 * memory is used. Also, since swig_type_info structures store pointers to 
 
3452
 * swig_cast_info structures and swig_cast_info structures store pointers back
 
3453
 * to swig_type_info structures, we need some lookup code at initialization. 
 
3454
 * The idea is that swig generates all the structures that are needed. 
 
3455
 * The runtime then collects these partially filled structures. 
 
3456
 * The SWIG_InitializeModule function takes these initial arrays out of 
 
3457
 * swig_module, and does all the lookup, filling in the swig_module.types
 
3458
 * array with the correct data and linking the correct swig_cast_info
 
3459
 * structures together.
 
3460
 *
 
3461
 * The generated swig_type_info structures are assigned staticly to an initial 
 
3462
 * array. We just loop through that array, and handle each type individually.
 
3463
 * First we lookup if this type has been already loaded, and if so, use the
 
3464
 * loaded structure instead of the generated one. Then we have to fill in the
 
3465
 * cast linked list. The cast data is initially stored in something like a
 
3466
 * two-dimensional array. Each row corresponds to a type (there are the same
 
3467
 * number of rows as there are in the swig_type_initial array). Each entry in
 
3468
 * a column is one of the swig_cast_info structures for that type.
 
3469
 * The cast_initial array is actually an array of arrays, because each row has
 
3470
 * a variable number of columns. So to actually build the cast linked list,
 
3471
 * we find the array of casts associated with the type, and loop through it 
 
3472
 * adding the casts to the list. The one last trick we need to do is making
 
3473
 * sure the type pointer in the swig_cast_info struct is correct.
 
3474
 *
 
3475
 * First off, we lookup the cast->type name to see if it is already loaded. 
 
3476
 * There are three cases to handle:
 
3477
 *  1) If the cast->type has already been loaded AND the type we are adding
 
3478
 *     casting info to has not been loaded (it is in this module), THEN we
 
3479
 *     replace the cast->type pointer with the type pointer that has already
 
3480
 *     been loaded.
 
3481
 *  2) If BOTH types (the one we are adding casting info to, and the 
 
3482
 *     cast->type) are loaded, THEN the cast info has already been loaded by
 
3483
 *     the previous module so we just ignore it.
 
3484
 *  3) Finally, if cast->type has not already been loaded, then we add that
 
3485
 *     swig_cast_info to the linked list (because the cast->type) pointer will
 
3486
 *     be correct.
 
3487
 * ----------------------------------------------------------------------------- */
 
3488
 
 
3489
#ifdef __cplusplus
 
3490
extern "C" {
 
3491
#if 0
 
3492
} /* c-mode */
 
3493
#endif
 
3494
#endif
 
3495
 
 
3496
#if 0
 
3497
#define SWIGRUNTIME_DEBUG
 
3498
#endif
 
3499
 
 
3500
 
 
3501
SWIGRUNTIME void
 
3502
SWIG_InitializeModule(void *clientdata) {
 
3503
  size_t i;
 
3504
  swig_module_info *module_head, *iter;
 
3505
  int found, init;
 
3506
  
 
3507
  clientdata = clientdata;
 
3508
  
 
3509
  /* check to see if the circular list has been setup, if not, set it up */
 
3510
  if (swig_module.next==0) {
 
3511
    /* Initialize the swig_module */
 
3512
    swig_module.type_initial = swig_type_initial;
 
3513
    swig_module.cast_initial = swig_cast_initial;
 
3514
    swig_module.next = &swig_module;
 
3515
    init = 1;
 
3516
  } else {
 
3517
    init = 0;
 
3518
  }
 
3519
  
 
3520
  /* Try and load any already created modules */
 
3521
  module_head = SWIG_GetModule(clientdata);
 
3522
  if (!module_head) {
 
3523
    /* This is the first module loaded for this interpreter */
 
3524
    /* so set the swig module into the interpreter */
 
3525
    SWIG_SetModule(clientdata, &swig_module);
 
3526
    module_head = &swig_module;
 
3527
  } else {
 
3528
    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
 
3529
    found=0;
 
3530
    iter=module_head;
 
3531
    do {
 
3532
      if (iter==&swig_module) {
 
3533
        found=1;
 
3534
        break;
 
3535
      }
 
3536
      iter=iter->next;
 
3537
    } while (iter!= module_head);
 
3538
    
 
3539
    /* if the is found in the list, then all is done and we may leave */
 
3540
    if (found) return;
 
3541
    /* otherwise we must add out module into the list */
 
3542
    swig_module.next = module_head->next;
 
3543
    module_head->next = &swig_module;
 
3544
  }
 
3545
  
 
3546
  /* When multiple interpeters are used, a module could have already been initialized in
 
3547
       a different interpreter, but not yet have a pointer in this interpreter.
 
3548
       In this case, we do not want to continue adding types... everything should be
 
3549
       set up already */
 
3550
  if (init == 0) return;
 
3551
  
 
3552
  /* Now work on filling in swig_module.types */
 
3553
#ifdef SWIGRUNTIME_DEBUG
 
3554
  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
 
3555
#endif
 
3556
  for (i = 0; i < swig_module.size; ++i) {
 
3557
    swig_type_info *type = 0;
 
3558
    swig_type_info *ret;
 
3559
    swig_cast_info *cast;
 
3560
    
 
3561
#ifdef SWIGRUNTIME_DEBUG
 
3562
    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
 
3563
#endif
 
3564
    
 
3565
    /* if there is another module already loaded */
 
3566
    if (swig_module.next != &swig_module) {
 
3567
      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
 
3568
    }
 
3569
    if (type) {
 
3570
      /* Overwrite clientdata field */
 
3571
#ifdef SWIGRUNTIME_DEBUG
 
3572
      printf("SWIG_InitializeModule: found type %s\n", type->name);
 
3573
#endif
 
3574
      if (swig_module.type_initial[i]->clientdata) {
 
3575
        type->clientdata = swig_module.type_initial[i]->clientdata;
 
3576
#ifdef SWIGRUNTIME_DEBUG
 
3577
        printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
 
3578
#endif
 
3579
      }
 
3580
    } else {
 
3581
      type = swig_module.type_initial[i];
 
3582
    }
 
3583
    
 
3584
    /* Insert casting types */
 
3585
    cast = swig_module.cast_initial[i];
 
3586
    while (cast->type) {
 
3587
      /* Don't need to add information already in the list */
 
3588
      ret = 0;
 
3589
#ifdef SWIGRUNTIME_DEBUG
 
3590
      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
 
3591
#endif
 
3592
      if (swig_module.next != &swig_module) {
 
3593
        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
 
3594
#ifdef SWIGRUNTIME_DEBUG
 
3595
        if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
 
3596
#endif
 
3597
      }
 
3598
      if (ret) {
 
3599
        if (type == swig_module.type_initial[i]) {
 
3600
#ifdef SWIGRUNTIME_DEBUG
 
3601
          printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
 
3602
#endif
 
3603
          cast->type = ret;
 
3604
          ret = 0;
 
3605
        } else {
 
3606
          /* Check for casting already in the list */
 
3607
          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
 
3608
#ifdef SWIGRUNTIME_DEBUG
 
3609
          if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
 
3610
#endif
 
3611
          if (!ocast) ret = 0;
 
3612
        }
 
3613
      }
 
3614
      
 
3615
      if (!ret) {
 
3616
#ifdef SWIGRUNTIME_DEBUG
 
3617
        printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
 
3618
#endif
 
3619
        if (type->cast) {
 
3620
          type->cast->prev = cast;
 
3621
          cast->next = type->cast;
 
3622
        }
 
3623
        type->cast = cast;
 
3624
      }
 
3625
      cast++;
 
3626
    }
 
3627
    /* Set entry in modules->types array equal to the type */
 
3628
    swig_module.types[i] = type;
 
3629
  }
 
3630
  swig_module.types[i] = 0;
 
3631
  
 
3632
#ifdef SWIGRUNTIME_DEBUG
 
3633
  printf("**** SWIG_InitializeModule: Cast List ******\n");
 
3634
  for (i = 0; i < swig_module.size; ++i) {
 
3635
    int j = 0;
 
3636
    swig_cast_info *cast = swig_module.cast_initial[i];
 
3637
    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
 
3638
    while (cast->type) {
 
3639
      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
 
3640
      cast++;
 
3641
      ++j;
 
3642
    }
 
3643
    printf("---- Total casts: %d\n",j);
 
3644
  }
 
3645
  printf("**** SWIG_InitializeModule: Cast List ******\n");
 
3646
#endif
 
3647
}
 
3648
 
 
3649
/* This function will propagate the clientdata field of type to
 
3650
* any new swig_type_info structures that have been added into the list
 
3651
* of equivalent types.  It is like calling
 
3652
* SWIG_TypeClientData(type, clientdata) a second time.
 
3653
*/
 
3654
SWIGRUNTIME void
 
3655
SWIG_PropagateClientData(void) {
 
3656
  size_t i;
 
3657
  swig_cast_info *equiv;
 
3658
  static int init_run = 0;
 
3659
  
 
3660
  if (init_run) return;
 
3661
  init_run = 1;
 
3662
  
 
3663
  for (i = 0; i < swig_module.size; i++) {
 
3664
    if (swig_module.types[i]->clientdata) {
 
3665
      equiv = swig_module.types[i]->cast;
 
3666
      while (equiv) {
 
3667
        if (!equiv->converter) {
 
3668
          if (equiv->type && !equiv->type->clientdata)
 
3669
          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
 
3670
        }
 
3671
        equiv = equiv->next;
 
3672
      }
 
3673
    }
 
3674
  }
 
3675
}
 
3676
 
 
3677
#ifdef __cplusplus
 
3678
#if 0
 
3679
{
 
3680
  /* c-mode */
 
3681
#endif
 
3682
}
 
3683
#endif
 
3684
 
 
3685
 
 
3686
 
 
3687
#ifdef __cplusplus
 
3688
extern "C" {
 
3689
#endif
 
3690
  
 
3691
  /* Python-specific SWIG API */
 
3692
#define SWIG_newvarlink()                             SWIG_Python_newvarlink()
 
3693
#define SWIG_addvarlink(p, name, get_attr, set_attr)  SWIG_Python_addvarlink(p, name, get_attr, set_attr)
 
3694
#define SWIG_InstallConstants(d, constants)           SWIG_Python_InstallConstants(d, constants)
 
3695
  
 
3696
  /* -----------------------------------------------------------------------------
 
3697
   * global variable support code.
 
3698
   * ----------------------------------------------------------------------------- */
 
3699
  
 
3700
  typedef struct swig_globalvar {
 
3701
    char       *name;                  /* Name of global variable */
 
3702
    PyObject *(*get_attr)(void);       /* Return the current value */
 
3703
    int       (*set_attr)(PyObject *); /* Set the value */
 
3704
    struct swig_globalvar *next;
 
3705
  } swig_globalvar;
 
3706
  
 
3707
  typedef struct swig_varlinkobject {
 
3708
    PyObject_HEAD
 
3709
    swig_globalvar *vars;
 
3710
  } swig_varlinkobject;
 
3711
  
 
3712
  SWIGINTERN PyObject *
 
3713
  swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
 
3714
#if PY_VERSION_HEX >= 0x03000000
 
3715
    return PyUnicode_InternFromString("<Swig global variables>");
 
3716
#else
 
3717
    return PyString_FromString("<Swig global variables>");
 
3718
#endif
 
3719
  }
 
3720
  
 
3721
  SWIGINTERN PyObject *
 
3722
  swig_varlink_str(swig_varlinkobject *v) {
 
3723
#if PY_VERSION_HEX >= 0x03000000
 
3724
    PyObject *str = PyUnicode_InternFromString("(");
 
3725
    PyObject *tail;
 
3726
    PyObject *joined;
 
3727
    swig_globalvar *var;
 
3728
    for (var = v->vars; var; var=var->next) {
 
3729
      tail = PyUnicode_FromString(var->name);
 
3730
      joined = PyUnicode_Concat(str, tail);
 
3731
      Py_DecRef(str);
 
3732
      Py_DecRef(tail);
 
3733
      str = joined;
 
3734
      if (var->next) {
 
3735
        tail = PyUnicode_InternFromString(", ");
 
3736
        joined = PyUnicode_Concat(str, tail);
 
3737
        Py_DecRef(str);
 
3738
        Py_DecRef(tail);
 
3739
        str = joined;
 
3740
      }
 
3741
    }
 
3742
    tail = PyUnicode_InternFromString(")");
 
3743
    joined = PyUnicode_Concat(str, tail);
 
3744
    Py_DecRef(str);
 
3745
    Py_DecRef(tail);
 
3746
    str = joined;
 
3747
#else
 
3748
    PyObject *str = PyString_FromString("(");
 
3749
    swig_globalvar *var;
 
3750
    for (var = v->vars; var; var=var->next) {
 
3751
      PyString_ConcatAndDel(&str,PyString_FromString(var->name));
 
3752
      if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
 
3753
    }
 
3754
    PyString_ConcatAndDel(&str,PyString_FromString(")"));
 
3755
#endif
 
3756
    return str;
 
3757
  }
 
3758
  
 
3759
  SWIGINTERN int
 
3760
  swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
 
3761
    char *tmp;
 
3762
    PyObject *str = swig_varlink_str(v);
 
3763
    fprintf(fp,"Swig global variables ");
 
3764
    fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
 
3765
    SWIG_Python_str_DelForPy3(tmp);
 
3766
    Py_DECREF(str);
 
3767
    return 0;
 
3768
  }
 
3769
  
 
3770
  SWIGINTERN void
 
3771
  swig_varlink_dealloc(swig_varlinkobject *v) {
 
3772
    swig_globalvar *var = v->vars;
 
3773
    while (var) {
 
3774
      swig_globalvar *n = var->next;
 
3775
      free(var->name);
 
3776
      free(var);
 
3777
      var = n;
 
3778
    }
 
3779
  }
 
3780
  
 
3781
  SWIGINTERN PyObject *
 
3782
  swig_varlink_getattr(swig_varlinkobject *v, char *n) {
 
3783
    PyObject *res = NULL;
 
3784
    swig_globalvar *var = v->vars;
 
3785
    while (var) {
 
3786
      if (strcmp(var->name,n) == 0) {
 
3787
        res = (*var->get_attr)();
 
3788
        break;
 
3789
      }
 
3790
      var = var->next;
 
3791
    }
 
3792
    if (res == NULL && !PyErr_Occurred()) {
 
3793
      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
 
3794
    }
 
3795
    return res;
 
3796
  }
 
3797
  
 
3798
  SWIGINTERN int
 
3799
  swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
 
3800
    int res = 1;
 
3801
    swig_globalvar *var = v->vars;
 
3802
    while (var) {
 
3803
      if (strcmp(var->name,n) == 0) {
 
3804
        res = (*var->set_attr)(p);
 
3805
        break;
 
3806
      }
 
3807
      var = var->next;
 
3808
    }
 
3809
    if (res == 1 && !PyErr_Occurred()) {
 
3810
      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
 
3811
    }
 
3812
    return res;
 
3813
  }
 
3814
  
 
3815
  SWIGINTERN PyTypeObject*
 
3816
  swig_varlink_type(void) {
 
3817
    static char varlink__doc__[] = "Swig var link object";
 
3818
    static PyTypeObject varlink_type;
 
3819
    static int type_init = 0;  
 
3820
    if (!type_init) {
 
3821
      const PyTypeObject tmp
 
3822
      = {
 
3823
        /* PyObject header changed in Python 3 */
 
3824
#if PY_VERSION_HEX >= 0x03000000
 
3825
        PyVarObject_HEAD_INIT(&PyType_Type, 0)
 
3826
#else
 
3827
        PyObject_HEAD_INIT(NULL)
 
3828
        0,                                  /* Number of items in variable part (ob_size) */
 
3829
#endif
 
3830
        (char *)"swigvarlink",              /* Type name (tp_name) */
 
3831
        sizeof(swig_varlinkobject),         /* Basic size (tp_basicsize) */
 
3832
        0,                                  /* Itemsize (tp_itemsize) */
 
3833
        (destructor) swig_varlink_dealloc,  /* Deallocator (tp_dealloc) */ 
 
3834
        (printfunc) swig_varlink_print,     /* Print (tp_print) */
 
3835
        (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
 
3836
        (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
 
3837
        0,                                  /* tp_compare */
 
3838
        (reprfunc) swig_varlink_repr,       /* tp_repr */
 
3839
        0,                                  /* tp_as_number */
 
3840
        0,                                  /* tp_as_sequence */
 
3841
        0,                                  /* tp_as_mapping */
 
3842
        0,                                  /* tp_hash */
 
3843
        0,                                  /* tp_call */
 
3844
        (reprfunc) swig_varlink_str,        /* tp_str */
 
3845
        0,                                  /* tp_getattro */
 
3846
        0,                                  /* tp_setattro */
 
3847
        0,                                  /* tp_as_buffer */
 
3848
        0,                                  /* tp_flags */
 
3849
        varlink__doc__,                     /* tp_doc */
 
3850
        0,                                  /* tp_traverse */
 
3851
        0,                                  /* tp_clear */
 
3852
        0,                                  /* tp_richcompare */
 
3853
        0,                                  /* tp_weaklistoffset */
 
3854
#if PY_VERSION_HEX >= 0x02020000
 
3855
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
 
3856
#endif
 
3857
#if PY_VERSION_HEX >= 0x02030000
 
3858
        0,                                  /* tp_del */
 
3859
#endif
 
3860
#ifdef COUNT_ALLOCS
 
3861
        0,0,0,0                             /* tp_alloc -> tp_next */
 
3862
#endif
 
3863
      };
 
3864
      varlink_type = tmp;
 
3865
      /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
 
3866
#if PY_VERSION_HEX < 0x03000000
 
3867
      varlink_type.ob_type = &PyType_Type;
 
3868
#endif
 
3869
      type_init = 1;
 
3870
    }
 
3871
    return &varlink_type;
 
3872
  }
 
3873
  
 
3874
  /* Create a variable linking object for use later */
 
3875
  SWIGINTERN PyObject *
 
3876
  SWIG_Python_newvarlink(void) {
 
3877
    swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
 
3878
    if (result) {
 
3879
      result->vars = 0;
 
3880
    }
 
3881
    return ((PyObject*) result);
 
3882
  }
 
3883
  
 
3884
  SWIGINTERN void 
 
3885
  SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
 
3886
    swig_varlinkobject *v = (swig_varlinkobject *) p;
 
3887
    swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
 
3888
    if (gv) {
 
3889
      size_t size = strlen(name)+1;
 
3890
      gv->name = (char *)malloc(size);
 
3891
      if (gv->name) {
 
3892
        strncpy(gv->name,name,size);
 
3893
        gv->get_attr = get_attr;
 
3894
        gv->set_attr = set_attr;
 
3895
        gv->next = v->vars;
 
3896
      }
 
3897
    }
 
3898
    v->vars = gv;
 
3899
  }
 
3900
  
 
3901
  SWIGINTERN PyObject *
 
3902
  SWIG_globals(void) {
 
3903
    static PyObject *_SWIG_globals = 0; 
 
3904
    if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();  
 
3905
    return _SWIG_globals;
 
3906
  }
 
3907
  
 
3908
  /* -----------------------------------------------------------------------------
 
3909
   * constants/methods manipulation
 
3910
   * ----------------------------------------------------------------------------- */
 
3911
  
 
3912
  /* Install Constants */
 
3913
  SWIGINTERN void
 
3914
  SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
 
3915
    PyObject *obj = 0;
 
3916
    size_t i;
 
3917
    for (i = 0; constants[i].type; ++i) {
 
3918
      switch(constants[i].type) {
 
3919
      case SWIG_PY_POINTER:
 
3920
        obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
 
3921
        break;
 
3922
      case SWIG_PY_BINARY:
 
3923
        obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
 
3924
        break;
 
3925
      default:
 
3926
        obj = 0;
 
3927
        break;
 
3928
      }
 
3929
      if (obj) {
 
3930
        PyDict_SetItemString(d, constants[i].name, obj);
 
3931
        Py_DECREF(obj);
 
3932
      }
 
3933
    }
 
3934
  }
 
3935
  
 
3936
  /* -----------------------------------------------------------------------------*/
 
3937
  /* Fix SwigMethods to carry the callback ptrs when needed */
 
3938
  /* -----------------------------------------------------------------------------*/
 
3939
  
 
3940
  SWIGINTERN void
 
3941
  SWIG_Python_FixMethods(PyMethodDef *methods,
 
3942
    swig_const_info *const_table,
 
3943
    swig_type_info **types,
 
3944
    swig_type_info **types_initial) {
 
3945
    size_t i;
 
3946
    for (i = 0; methods[i].ml_name; ++i) {
 
3947
      const char *c = methods[i].ml_doc;
 
3948
      if (c && (c = strstr(c, "swig_ptr: "))) {
 
3949
        int j;
 
3950
        swig_const_info *ci = 0;
 
3951
        const char *name = c + 10;
 
3952
        for (j = 0; const_table[j].type; ++j) {
 
3953
          if (strncmp(const_table[j].name, name, 
 
3954
              strlen(const_table[j].name)) == 0) {
 
3955
            ci = &(const_table[j]);
 
3956
            break;
 
3957
          }
 
3958
        }
 
3959
        if (ci) {
 
3960
          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
 
3961
          if (ptr) {
 
3962
            size_t shift = (ci->ptype) - types;
 
3963
            swig_type_info *ty = types_initial[shift];
 
3964
            size_t ldoc = (c - methods[i].ml_doc);
 
3965
            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
 
3966
            char *ndoc = (char*)malloc(ldoc + lptr + 10);
 
3967
            if (ndoc) {
 
3968
              char *buff = ndoc;
 
3969
              strncpy(buff, methods[i].ml_doc, ldoc);
 
3970
              buff += ldoc;
 
3971
              strncpy(buff, "swig_ptr: ", 10);
 
3972
              buff += 10;
 
3973
              SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
 
3974
              methods[i].ml_doc = ndoc;
 
3975
            }
 
3976
          }
 
3977
        }
 
3978
      }
 
3979
    }
 
3980
  } 
 
3981
  
 
3982
#ifdef __cplusplus
 
3983
}
 
3984
#endif
 
3985
 
 
3986
/* -----------------------------------------------------------------------------*
 
3987
 *  Partial Init method
 
3988
 * -----------------------------------------------------------------------------*/
 
3989
 
 
3990
#ifdef __cplusplus
 
3991
extern "C"
 
3992
#endif
 
3993
 
 
3994
SWIGEXPORT 
 
3995
#if PY_VERSION_HEX >= 0x03000000
 
3996
PyObject*
 
3997
#else
 
3998
void
 
3999
#endif
 
4000
SWIG_init(void) {
 
4001
  PyObject *m, *d;  
 
4002
#if PY_VERSION_HEX >= 0x03000000
 
4003
  static struct PyModuleDef SWIG_module = {
 
4004
    PyModuleDef_HEAD_INIT,
 
4005
    (char *) SWIG_name,
 
4006
    NULL,
 
4007
    -1,
 
4008
    SwigMethods,
 
4009
    NULL,
 
4010
    NULL,
 
4011
    NULL,
 
4012
    NULL
 
4013
  };
 
4014
#endif
 
4015
  
 
4016
  /* Fix SwigMethods to carry the callback ptrs when needed */
 
4017
  SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
 
4018
  
 
4019
#if PY_VERSION_HEX >= 0x03000000
 
4020
  m = PyModule_Create(&SWIG_module);
 
4021
#else
 
4022
  m = Py_InitModule((char *) SWIG_name, SwigMethods);
 
4023
#endif
 
4024
  d = PyModule_GetDict(m);
 
4025
  
 
4026
  SWIG_InitializeModule(0);
 
4027
  SWIG_InstallConstants(d,swig_const_table);
 
4028
  
 
4029
  
 
4030
  
 
4031
  import_array();
 
4032
  
 
4033
#if PY_VERSION_HEX >= 0x03000000
 
4034
  return m;
 
4035
#else
 
4036
  return;
 
4037
#endif
 
4038
}
 
4039