CYCLUS
pymodule.cc
Go to the documentation of this file.
1 /* Generated by Cython 0.26.1 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6  #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
8  #error Cython requires Python 2.6+ or Python 3.2+.
9 #else
10 #define CYTHON_ABI "0_26_1"
11 #include <stddef.h>
12 #ifndef offsetof
13  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
14 #endif
15 #if !defined(WIN32) && !defined(MS_WINDOWS)
16  #ifndef __stdcall
17  #define __stdcall
18  #endif
19  #ifndef __cdecl
20  #define __cdecl
21  #endif
22  #ifndef __fastcall
23  #define __fastcall
24  #endif
25 #endif
26 #ifndef DL_IMPORT
27  #define DL_IMPORT(t) t
28 #endif
29 #ifndef DL_EXPORT
30  #define DL_EXPORT(t) t
31 #endif
32 #define __PYX_COMMA ,
33 #ifndef HAVE_LONG_LONG
34  #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
35  #define HAVE_LONG_LONG
36  #endif
37 #endif
38 #ifndef PY_LONG_LONG
39  #define PY_LONG_LONG LONG_LONG
40 #endif
41 #ifndef Py_HUGE_VAL
42  #define Py_HUGE_VAL HUGE_VAL
43 #endif
44 #ifdef PYPY_VERSION
45  #define CYTHON_COMPILING_IN_PYPY 1
46  #define CYTHON_COMPILING_IN_PYSTON 0
47  #define CYTHON_COMPILING_IN_CPYTHON 0
48  #undef CYTHON_USE_TYPE_SLOTS
49  #define CYTHON_USE_TYPE_SLOTS 0
50  #undef CYTHON_USE_PYTYPE_LOOKUP
51  #define CYTHON_USE_PYTYPE_LOOKUP 0
52  #undef CYTHON_USE_ASYNC_SLOTS
53  #define CYTHON_USE_ASYNC_SLOTS 0
54  #undef CYTHON_USE_PYLIST_INTERNALS
55  #define CYTHON_USE_PYLIST_INTERNALS 0
56  #undef CYTHON_USE_UNICODE_INTERNALS
57  #define CYTHON_USE_UNICODE_INTERNALS 0
58  #undef CYTHON_USE_UNICODE_WRITER
59  #define CYTHON_USE_UNICODE_WRITER 0
60  #undef CYTHON_USE_PYLONG_INTERNALS
61  #define CYTHON_USE_PYLONG_INTERNALS 0
62  #undef CYTHON_AVOID_BORROWED_REFS
63  #define CYTHON_AVOID_BORROWED_REFS 1
64  #undef CYTHON_ASSUME_SAFE_MACROS
65  #define CYTHON_ASSUME_SAFE_MACROS 0
66  #undef CYTHON_UNPACK_METHODS
67  #define CYTHON_UNPACK_METHODS 0
68  #undef CYTHON_FAST_THREAD_STATE
69  #define CYTHON_FAST_THREAD_STATE 0
70  #undef CYTHON_FAST_PYCALL
71  #define CYTHON_FAST_PYCALL 0
72 #elif defined(PYSTON_VERSION)
73  #define CYTHON_COMPILING_IN_PYPY 0
74  #define CYTHON_COMPILING_IN_PYSTON 1
75  #define CYTHON_COMPILING_IN_CPYTHON 0
76  #ifndef CYTHON_USE_TYPE_SLOTS
77  #define CYTHON_USE_TYPE_SLOTS 1
78  #endif
79  #undef CYTHON_USE_PYTYPE_LOOKUP
80  #define CYTHON_USE_PYTYPE_LOOKUP 0
81  #undef CYTHON_USE_ASYNC_SLOTS
82  #define CYTHON_USE_ASYNC_SLOTS 0
83  #undef CYTHON_USE_PYLIST_INTERNALS
84  #define CYTHON_USE_PYLIST_INTERNALS 0
85  #ifndef CYTHON_USE_UNICODE_INTERNALS
86  #define CYTHON_USE_UNICODE_INTERNALS 1
87  #endif
88  #undef CYTHON_USE_UNICODE_WRITER
89  #define CYTHON_USE_UNICODE_WRITER 0
90  #undef CYTHON_USE_PYLONG_INTERNALS
91  #define CYTHON_USE_PYLONG_INTERNALS 0
92  #ifndef CYTHON_AVOID_BORROWED_REFS
93  #define CYTHON_AVOID_BORROWED_REFS 0
94  #endif
95  #ifndef CYTHON_ASSUME_SAFE_MACROS
96  #define CYTHON_ASSUME_SAFE_MACROS 1
97  #endif
98  #ifndef CYTHON_UNPACK_METHODS
99  #define CYTHON_UNPACK_METHODS 1
100  #endif
101  #undef CYTHON_FAST_THREAD_STATE
102  #define CYTHON_FAST_THREAD_STATE 0
103  #undef CYTHON_FAST_PYCALL
104  #define CYTHON_FAST_PYCALL 0
105 #else
106  #define CYTHON_COMPILING_IN_PYPY 0
107  #define CYTHON_COMPILING_IN_PYSTON 0
108  #define CYTHON_COMPILING_IN_CPYTHON 1
109  #ifndef CYTHON_USE_TYPE_SLOTS
110  #define CYTHON_USE_TYPE_SLOTS 1
111  #endif
112  #if PY_VERSION_HEX < 0x02070000
113  #undef CYTHON_USE_PYTYPE_LOOKUP
114  #define CYTHON_USE_PYTYPE_LOOKUP 0
115  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
116  #define CYTHON_USE_PYTYPE_LOOKUP 1
117  #endif
118  #if PY_MAJOR_VERSION < 3
119  #undef CYTHON_USE_ASYNC_SLOTS
120  #define CYTHON_USE_ASYNC_SLOTS 0
121  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
122  #define CYTHON_USE_ASYNC_SLOTS 1
123  #endif
124  #if PY_VERSION_HEX < 0x02070000
125  #undef CYTHON_USE_PYLONG_INTERNALS
126  #define CYTHON_USE_PYLONG_INTERNALS 0
127  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
128  #define CYTHON_USE_PYLONG_INTERNALS 1
129  #endif
130  #ifndef CYTHON_USE_PYLIST_INTERNALS
131  #define CYTHON_USE_PYLIST_INTERNALS 1
132  #endif
133  #ifndef CYTHON_USE_UNICODE_INTERNALS
134  #define CYTHON_USE_UNICODE_INTERNALS 1
135  #endif
136  #if PY_VERSION_HEX < 0x030300F0
137  #undef CYTHON_USE_UNICODE_WRITER
138  #define CYTHON_USE_UNICODE_WRITER 0
139  #elif !defined(CYTHON_USE_UNICODE_WRITER)
140  #define CYTHON_USE_UNICODE_WRITER 1
141  #endif
142  #ifndef CYTHON_AVOID_BORROWED_REFS
143  #define CYTHON_AVOID_BORROWED_REFS 0
144  #endif
145  #ifndef CYTHON_ASSUME_SAFE_MACROS
146  #define CYTHON_ASSUME_SAFE_MACROS 1
147  #endif
148  #ifndef CYTHON_UNPACK_METHODS
149  #define CYTHON_UNPACK_METHODS 1
150  #endif
151  #ifndef CYTHON_FAST_THREAD_STATE
152  #define CYTHON_FAST_THREAD_STATE 1
153  #endif
154  #ifndef CYTHON_FAST_PYCALL
155  #define CYTHON_FAST_PYCALL 1
156  #endif
157 #endif
158 #if !defined(CYTHON_FAST_PYCCALL)
159 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
160 #endif
161 #if CYTHON_USE_PYLONG_INTERNALS
162  #include "longintrepr.h"
163  #undef SHIFT
164  #undef BASE
165  #undef MASK
166 #endif
167 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
168  #define Py_OptimizeFlag 0
169 #endif
170 #define __PYX_BUILD_PY_SSIZE_T "n"
171 #define CYTHON_FORMAT_SSIZE_T "z"
172 #if PY_MAJOR_VERSION < 3
173  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
174  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
175  PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
176  #define __Pyx_DefaultClassType PyClass_Type
177 #else
178  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
179  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
180  PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
181  #define __Pyx_DefaultClassType PyType_Type
182 #endif
183 #ifndef Py_TPFLAGS_CHECKTYPES
184  #define Py_TPFLAGS_CHECKTYPES 0
185 #endif
186 #ifndef Py_TPFLAGS_HAVE_INDEX
187  #define Py_TPFLAGS_HAVE_INDEX 0
188 #endif
189 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
190  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
191 #endif
192 #ifndef Py_TPFLAGS_HAVE_FINALIZE
193  #define Py_TPFLAGS_HAVE_FINALIZE 0
194 #endif
195 #if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL)
196  #ifndef METH_FASTCALL
197  #define METH_FASTCALL 0x80
198  #endif
199  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs);
200  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args,
201  Py_ssize_t nargs, PyObject *kwnames);
202 #else
203  #define __Pyx_PyCFunctionFast _PyCFunctionFast
204  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
205 #endif
206 #if CYTHON_FAST_PYCCALL
207 #define __Pyx_PyFastCFunction_Check(func)\
208  ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
209 #else
210 #define __Pyx_PyFastCFunction_Check(func) 0
211 #endif
212 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
213  #define CYTHON_PEP393_ENABLED 1
214  #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
215  0 : _PyUnicode_Ready((PyObject *)(op)))
216  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
217  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
218  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
219  #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
220  #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
221  #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
222  #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
223  #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
224 #else
225  #define CYTHON_PEP393_ENABLED 0
226  #define PyUnicode_1BYTE_KIND 1
227  #define PyUnicode_2BYTE_KIND 2
228  #define PyUnicode_4BYTE_KIND 4
229  #define __Pyx_PyUnicode_READY(op) (0)
230  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
231  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
232  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
233  #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
234  #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
235  #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
236  #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
237  #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
238 #endif
239 #if CYTHON_COMPILING_IN_PYPY
240  #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
241  #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
242 #else
243  #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
244  #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
245  PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
246 #endif
247 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
248  #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
249 #endif
250 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
251  #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
252 #endif
253 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
254  #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
255 #endif
256 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
257  #define PyObject_Malloc(s) PyMem_Malloc(s)
258  #define PyObject_Free(p) PyMem_Free(p)
259  #define PyObject_Realloc(p) PyMem_Realloc(p)
260 #endif
261 #if CYTHON_COMPILING_IN_PYSTON
262  #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
263  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
264 #else
265  #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
266  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
267 #endif
268 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
269 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
270 #if PY_MAJOR_VERSION >= 3
271  #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
272 #else
273  #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
274 #endif
275 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
276  #define PyObject_ASCII(o) PyObject_Repr(o)
277 #endif
278 #if PY_MAJOR_VERSION >= 3
279  #define PyBaseString_Type PyUnicode_Type
280  #define PyStringObject PyUnicodeObject
281  #define PyString_Type PyUnicode_Type
282  #define PyString_Check PyUnicode_Check
283  #define PyString_CheckExact PyUnicode_CheckExact
284 #endif
285 #if PY_MAJOR_VERSION >= 3
286  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
287  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
288 #else
289  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
290  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
291 #endif
292 #ifndef PySet_CheckExact
293  #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
294 #endif
295 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
296 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
297 #if PY_MAJOR_VERSION >= 3
298  #define PyIntObject PyLongObject
299  #define PyInt_Type PyLong_Type
300  #define PyInt_Check(op) PyLong_Check(op)
301  #define PyInt_CheckExact(op) PyLong_CheckExact(op)
302  #define PyInt_FromString PyLong_FromString
303  #define PyInt_FromUnicode PyLong_FromUnicode
304  #define PyInt_FromLong PyLong_FromLong
305  #define PyInt_FromSize_t PyLong_FromSize_t
306  #define PyInt_FromSsize_t PyLong_FromSsize_t
307  #define PyInt_AsLong PyLong_AsLong
308  #define PyInt_AS_LONG PyLong_AS_LONG
309  #define PyInt_AsSsize_t PyLong_AsSsize_t
310  #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
311  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
312  #define PyNumber_Int PyNumber_Long
313 #endif
314 #if PY_MAJOR_VERSION >= 3
315  #define PyBoolObject PyLongObject
316 #endif
317 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
318  #ifndef PyUnicode_InternFromString
319  #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
320  #endif
321 #endif
322 #if PY_VERSION_HEX < 0x030200A4
323  typedef long Py_hash_t;
324  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
325  #define __Pyx_PyInt_AsHash_t PyInt_AsLong
326 #else
327  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
328  #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
329 #endif
330 #if PY_MAJOR_VERSION >= 3
331  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
332 #else
333  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
334 #endif
335 #ifndef __has_attribute
336  #define __has_attribute(x) 0
337 #endif
338 #ifndef __has_cpp_attribute
339  #define __has_cpp_attribute(x) 0
340 #endif
341 #if CYTHON_USE_ASYNC_SLOTS
342  #if PY_VERSION_HEX >= 0x030500B1
343  #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
344  #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
345  #else
346  typedef struct {
347  unaryfunc am_await;
348  unaryfunc am_aiter;
349  unaryfunc am_anext;
350  } __Pyx_PyAsyncMethodsStruct;
351  #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
352  #endif
353 #else
354  #define __Pyx_PyType_AsAsync(obj) NULL
355 #endif
356 #ifndef CYTHON_RESTRICT
357  #if defined(__GNUC__)
358  #define CYTHON_RESTRICT __restrict__
359  #elif defined(_MSC_VER) && _MSC_VER >= 1400
360  #define CYTHON_RESTRICT __restrict
361  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
362  #define CYTHON_RESTRICT restrict
363  #else
364  #define CYTHON_RESTRICT
365  #endif
366 #endif
367 #ifndef CYTHON_UNUSED
368 # if defined(__GNUC__)
369 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
370 # define CYTHON_UNUSED __attribute__ ((__unused__))
371 # else
372 # define CYTHON_UNUSED
373 # endif
374 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
375 # define CYTHON_UNUSED __attribute__ ((__unused__))
376 # else
377 # define CYTHON_UNUSED
378 # endif
379 #endif
380 #ifndef CYTHON_MAYBE_UNUSED_VAR
381 # if defined(__cplusplus)
382  template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
383 # else
384 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
385 # endif
386 #endif
387 #ifndef CYTHON_NCP_UNUSED
388 # if CYTHON_COMPILING_IN_CPYTHON
389 # define CYTHON_NCP_UNUSED
390 # else
391 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
392 # endif
393 #endif
394 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
395 #ifdef _MSC_VER
396  #ifndef _MSC_STDINT_H_
397  #if _MSC_VER < 1300
398  typedef unsigned char uint8_t;
399  typedef unsigned int uint32_t;
400  #else
401  typedef unsigned __int8 uint8_t;
402  typedef unsigned __int32 uint32_t;
403  #endif
404  #endif
405 #else
406  #include <stdint.h>
407 #endif
408 #ifndef CYTHON_FALLTHROUGH
409  #ifdef __cplusplus
410  #if __has_cpp_attribute(fallthrough)
411  #define CYTHON_FALLTHROUGH [[fallthrough]]
412  #elif __has_cpp_attribute(clang::fallthrough)
413  #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
414  #endif
415  #endif
416  #ifndef CYTHON_FALLTHROUGH
417  #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__))
418  #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
419  #else
420  #define CYTHON_FALLTHROUGH
421  #endif
422  #endif
423 #endif
424 
425 #ifndef __cplusplus
426  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
427 #endif
428 #ifndef CYTHON_INLINE
429  #if defined(__clang__)
430  #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
431  #else
432  #define CYTHON_INLINE inline
433  #endif
434 #endif
435 template<typename T>
436 void __Pyx_call_destructor(T& x) {
437  x.~T();
438 }
439 template<typename T>
440 class __Pyx_FakeReference {
441  public:
442  __Pyx_FakeReference() : ptr(NULL) { }
443  __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
444  T *operator->() { return ptr; }
445  T *operator&() { return ptr; }
446  operator T&() { return *ptr; }
447  template<typename U> bool operator ==(U other) { return *ptr == other; }
448  template<typename U> bool operator !=(U other) { return *ptr != other; }
449  private:
450  T *ptr;
451 };
452 
453 #if defined(WIN32) || defined(MS_WINDOWS)
454  #define _USE_MATH_DEFINES
455 #endif
456 #include <math.h>
457 #ifdef NAN
458 #define __PYX_NAN() ((float) NAN)
459 #else
460 static CYTHON_INLINE float __PYX_NAN() {
461  float value;
462  memset(&value, 0xFF, sizeof(value));
463  return value;
464 }
465 #endif
466 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
467 #define __Pyx_truncl trunc
468 #else
469 #define __Pyx_truncl truncl
470 #endif
471 
472 
473 #define __PYX_ERR(f_index, lineno, Ln_error) \
474 { \
475  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
476 }
477 
478 #if PY_MAJOR_VERSION >= 3
479  #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
480  #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
481 #else
482  #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
483  #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
484 #endif
485 
486 #ifndef __PYX_EXTERN_C
487  #ifdef __cplusplus
488  #define __PYX_EXTERN_C extern "C"
489  #else
490  #define __PYX_EXTERN_C extern
491  #endif
492 #endif
493 
494 #define __PYX_HAVE__pymodule
495 #define __PYX_HAVE_API__pymodule
496 #include <string.h>
497 #include <string>
498 #include "ios"
499 #include "new"
500 #include "stdexcept"
501 #include "typeinfo"
502 #include <typeinfo>
503 #include "cyclus.h"
504 #include "agent.h"
505 #include "region.h"
506 #include "institution.h"
507 #include "facility.h"
508 #include "toolkit/timeseries.h"
509 #include <stdio.h>
510 #ifdef _OPENMP
511 #include <omp.h>
512 #endif /* _OPENMP */
513 
514 #ifdef PYREX_WITHOUT_ASSERTIONS
515 #define CYTHON_WITHOUT_ASSERTIONS
516 #endif
517 
518 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
519  const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
520 
521 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
522 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
523 #define __PYX_DEFAULT_STRING_ENCODING ""
524 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
525 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
526 #define __Pyx_uchar_cast(c) ((unsigned char)c)
527 #define __Pyx_long_cast(x) ((long)x)
528 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
529  (sizeof(type) < sizeof(Py_ssize_t)) ||\
530  (sizeof(type) > sizeof(Py_ssize_t) &&\
531  likely(v < (type)PY_SSIZE_T_MAX ||\
532  v == (type)PY_SSIZE_T_MAX) &&\
533  (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
534  v == (type)PY_SSIZE_T_MIN))) ||\
535  (sizeof(type) == sizeof(Py_ssize_t) &&\
536  (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
537  v == (type)PY_SSIZE_T_MAX))) )
538 #if defined (__cplusplus) && __cplusplus >= 201103L
539  #include <cstdlib>
540  #define __Pyx_sst_abs(value) std::abs(value)
541 #elif SIZEOF_INT >= SIZEOF_SIZE_T
542  #define __Pyx_sst_abs(value) abs(value)
543 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
544  #define __Pyx_sst_abs(value) labs(value)
545 #elif defined (_MSC_VER) && defined (_M_X64)
546  #define __Pyx_sst_abs(value) _abs64(value)
547 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
548  #define __Pyx_sst_abs(value) llabs(value)
549 #elif defined (__GNUC__)
550  #define __Pyx_sst_abs(value) __builtin_llabs(value)
551 #else
552  #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
553 #endif
554 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
555 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
556 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
557 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
558 #define __Pyx_PyBytes_FromString PyBytes_FromString
559 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
560 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
561 #if PY_MAJOR_VERSION < 3
562  #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
563  #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
564 #else
565  #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
566  #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
567 #endif
568 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
569 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
570 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
571 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
572 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
573 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
574 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
575 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
576 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
577 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
578 #if PY_MAJOR_VERSION < 3
579 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
580 {
581  const Py_UNICODE *u_end = u;
582  while (*u_end++) ;
583  return (size_t)(u_end - u - 1);
584 }
585 #else
586 #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
587 #endif
588 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
589 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
590 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
591 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
592 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
593 #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
594 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
595 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
596 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
597 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
598 #if CYTHON_ASSUME_SAFE_MACROS
599 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
600 #else
601 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
602 #endif
603 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
604 #if PY_MAJOR_VERSION >= 3
605 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
606 #else
607 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
608 #endif
609 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
610 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
611 static int __Pyx_sys_getdefaultencoding_not_ascii;
612 static int __Pyx_init_sys_getdefaultencoding_params(void) {
613  PyObject* sys;
614  PyObject* default_encoding = NULL;
615  PyObject* ascii_chars_u = NULL;
616  PyObject* ascii_chars_b = NULL;
617  const char* default_encoding_c;
618  sys = PyImport_ImportModule("sys");
619  if (!sys) goto bad;
620  default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
621  Py_DECREF(sys);
622  if (!default_encoding) goto bad;
623  default_encoding_c = PyBytes_AsString(default_encoding);
624  if (!default_encoding_c) goto bad;
625  if (strcmp(default_encoding_c, "ascii") == 0) {
626  __Pyx_sys_getdefaultencoding_not_ascii = 0;
627  } else {
628  char ascii_chars[128];
629  int c;
630  for (c = 0; c < 128; c++) {
631  ascii_chars[c] = c;
632  }
633  __Pyx_sys_getdefaultencoding_not_ascii = 1;
634  ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
635  if (!ascii_chars_u) goto bad;
636  ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
637  if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
638  PyErr_Format(
639  PyExc_ValueError,
640  "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
641  default_encoding_c);
642  goto bad;
643  }
644  Py_DECREF(ascii_chars_u);
645  Py_DECREF(ascii_chars_b);
646  }
647  Py_DECREF(default_encoding);
648  return 0;
649 bad:
650  Py_XDECREF(default_encoding);
651  Py_XDECREF(ascii_chars_u);
652  Py_XDECREF(ascii_chars_b);
653  return -1;
654 }
655 #endif
656 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
657 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
658 #else
659 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
660 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
661 static char* __PYX_DEFAULT_STRING_ENCODING;
662 static int __Pyx_init_sys_getdefaultencoding_params(void) {
663  PyObject* sys;
664  PyObject* default_encoding = NULL;
665  char* default_encoding_c;
666  sys = PyImport_ImportModule("sys");
667  if (!sys) goto bad;
668  default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
669  Py_DECREF(sys);
670  if (!default_encoding) goto bad;
671  default_encoding_c = PyBytes_AsString(default_encoding);
672  if (!default_encoding_c) goto bad;
673  __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
674  if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
675  strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
676  Py_DECREF(default_encoding);
677  return 0;
678 bad:
679  Py_XDECREF(default_encoding);
680  return -1;
681 }
682 #endif
683 #endif
684 
685 
686 /* Test for GCC > 2.95 */
687 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
688  #define likely(x) __builtin_expect(!!(x), 1)
689  #define unlikely(x) __builtin_expect(!!(x), 0)
690 #else /* !__GNUC__ or GCC < 2.95 */
691  #define likely(x) (x)
692  #define unlikely(x) (x)
693 #endif /* __GNUC__ */
694 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
695 
696 static PyObject *__pyx_m;
697 static PyObject *__pyx_d;
698 static PyObject *__pyx_b;
699 static PyObject *__pyx_cython_runtime;
700 static PyObject *__pyx_empty_tuple;
701 static PyObject *__pyx_empty_bytes;
702 static PyObject *__pyx_empty_unicode;
703 static int __pyx_lineno;
704 static int __pyx_clineno = 0;
705 static const char * __pyx_cfilenm= __FILE__;
706 static const char *__pyx_filename;
707 
708 
709 static const char *__pyx_f[] = {
710  "pymodule.pyx",
711  "stringsource",
712  "type.pxd",
713 };
714 
715 /*--- Type declarations ---*/
716 
717 /* "pymodule.pxd":19
718  * cdef cppclass Agent
719  *
720  * ctypedef Agent* agent_ptr # <<<<<<<<<<<<<<
721  *
722  * cdef extern from "region.h" namespace "cyclus":
723  */
724 typedef cyclus::Agent *__pyx_t_8pymodule_agent_ptr;
725 
726 /* "pymodule.pxd":25
727  * cdef cppclass Region
728  *
729  * ctypedef Region* region_ptr # <<<<<<<<<<<<<<
730  *
731  * cdef extern from "institution.h" namespace "cyclus":
732  */
733 typedef cyclus::Region *__pyx_t_8pymodule_region_ptr;
734 
735 /* "pymodule.pxd":31
736  * cdef cppclass Institution
737  *
738  * ctypedef Institution* institution_ptr # <<<<<<<<<<<<<<
739  *
740  * cdef extern from "facility.h" namespace "cyclus":
741  */
742 typedef cyclus::Institution *__pyx_t_8pymodule_institution_ptr;
743 
744 /* "pymodule.pxd":37
745  * cdef cppclass Facility
746  *
747  * ctypedef Facility* facility_ptr # <<<<<<<<<<<<<<
748  *
749  * cdef extern from "toolkit/timeseries.h" namespace "cyclus::toolkit":
750  */
751 typedef cyclus::Facility *__pyx_t_8pymodule_facility_ptr;
752 
753 /* --- Runtime support code (head) --- */
754 /* Refnanny.proto */
755 #ifndef CYTHON_REFNANNY
756  #define CYTHON_REFNANNY 0
757 #endif
758 #if CYTHON_REFNANNY
759  typedef struct {
760  void (*INCREF)(void*, PyObject*, int);
761  void (*DECREF)(void*, PyObject*, int);
762  void (*GOTREF)(void*, PyObject*, int);
763  void (*GIVEREF)(void*, PyObject*, int);
764  void* (*SetupContext)(const char*, int, const char*);
765  void (*FinishContext)(void**);
766  } __Pyx_RefNannyAPIStruct;
767  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
768  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
769  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
770 #ifdef WITH_THREAD
771  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
772  if (acquire_gil) {\
773  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
774  __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
775  PyGILState_Release(__pyx_gilstate_save);\
776  } else {\
777  __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
778  }
779 #else
780  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
781  __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
782 #endif
783  #define __Pyx_RefNannyFinishContext()\
784  __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
785  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
786  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
787  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
788  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
789  #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
790  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
791  #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
792  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
793 #else
794  #define __Pyx_RefNannyDeclarations
795  #define __Pyx_RefNannySetupContext(name, acquire_gil)
796  #define __Pyx_RefNannyFinishContext()
797  #define __Pyx_INCREF(r) Py_INCREF(r)
798  #define __Pyx_DECREF(r) Py_DECREF(r)
799  #define __Pyx_GOTREF(r)
800  #define __Pyx_GIVEREF(r)
801  #define __Pyx_XINCREF(r) Py_XINCREF(r)
802  #define __Pyx_XDECREF(r) Py_XDECREF(r)
803  #define __Pyx_XGOTREF(r)
804  #define __Pyx_XGIVEREF(r)
805 #endif
806 #define __Pyx_XDECREF_SET(r, v) do {\
807  PyObject *tmp = (PyObject *) r;\
808  r = v; __Pyx_XDECREF(tmp);\
809  } while (0)
810 #define __Pyx_DECREF_SET(r, v) do {\
811  PyObject *tmp = (PyObject *) r;\
812  r = v; __Pyx_DECREF(tmp);\
813  } while (0)
814 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
815 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
816 
817 /* PyObjectGetAttrStr.proto */
818 #if CYTHON_USE_TYPE_SLOTS
819 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
820  PyTypeObject* tp = Py_TYPE(obj);
821  if (likely(tp->tp_getattro))
822  return tp->tp_getattro(obj, attr_name);
823 #if PY_MAJOR_VERSION < 3
824  if (likely(tp->tp_getattr))
825  return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
826 #endif
827  return PyObject_GetAttr(obj, attr_name);
828 }
829 #else
830 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
831 #endif
832 
833 /* GetBuiltinName.proto */
834 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
835 
836 /* PyCFunctionFastCall.proto */
837 #if CYTHON_FAST_PYCCALL
838 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
839 #else
840 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
841 #endif
842 
843 /* PyFunctionFastCall.proto */
844 #if CYTHON_FAST_PYCALL
845 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
846  __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
847 #if 1 || PY_VERSION_HEX < 0x030600B1
848 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
849 #else
850 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
851 #endif
852 #endif
853 
854 /* PyObjectCall.proto */
855 #if CYTHON_COMPILING_IN_CPYTHON
856 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
857 #else
858 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
859 #endif
860 
861 /* PyObjectCallMethO.proto */
862 #if CYTHON_COMPILING_IN_CPYTHON
863 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
864 #endif
865 
866 /* PyObjectCallOneArg.proto */
867 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
868 
869 /* PyObjectCallNoArg.proto */
870 #if CYTHON_COMPILING_IN_CPYTHON
871 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
872 #else
873 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
874 #endif
875 
876 /* PyThreadStateGet.proto */
877 #if CYTHON_FAST_THREAD_STATE
878 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
879 #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
880 #else
881 #define __Pyx_PyThreadState_declare
882 #define __Pyx_PyThreadState_assign
883 #endif
884 
885 /* PyErrFetchRestore.proto */
886 #if CYTHON_FAST_THREAD_STATE
887 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
888 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
889 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
890 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
891 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
892 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
893 #else
894 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
895 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
896 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
897 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
898 #endif
899 
900 /* WriteUnraisableException.proto */
901 static void __Pyx_WriteUnraisable(const char *name, int clineno,
902  int lineno, const char *filename,
903  int full_traceback, int nogil);
904 
905 /* GetModuleGlobalName.proto */
906 static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
907 
908 /* SaveResetException.proto */
909 #if CYTHON_FAST_THREAD_STATE
910 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
911 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
912 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
913 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
914 #else
915 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
916 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
917 #endif
918 
919 /* PyErrExceptionMatches.proto */
920 #if CYTHON_FAST_THREAD_STATE
921 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
922 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
923 #else
924 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
925 #endif
926 
927 /* GetException.proto */
928 #if CYTHON_FAST_THREAD_STATE
929 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
930 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
931 #else
932 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
933 #endif
934 
935 /* RaiseTooManyValuesToUnpack.proto */
936 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
937 
938 /* RaiseNeedMoreValuesToUnpack.proto */
939 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
940 
941 /* IterFinish.proto */
942 static CYTHON_INLINE int __Pyx_IterFinish(void);
943 
944 /* UnpackItemEndCheck.proto */
945 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
946 
947 /* IncludeStringH.proto */
948 #include <string.h>
949 
950 /* BytesEquals.proto */
951 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
952 
953 /* UnicodeEquals.proto */
954 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
955 
956 /* Import.proto */
957 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
958 
959 /* ImportFrom.proto */
960 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
961 
962 /* CLineInTraceback.proto */
963 static int __Pyx_CLineForTraceback(int c_line);
964 
965 /* CodeObjectCache.proto */
966 typedef struct {
967  PyCodeObject* code_object;
968  int code_line;
969 } __Pyx_CodeObjectCacheEntry;
970 struct __Pyx_CodeObjectCache {
971  int count;
972  int max_count;
973  __Pyx_CodeObjectCacheEntry* entries;
974 };
975 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
976 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
977 static PyCodeObject *__pyx_find_code_object(int code_line);
978 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
979 
980 /* AddTraceback.proto */
981 static void __Pyx_AddTraceback(const char *funcname, int c_line,
982  int py_line, const char *filename);
983 
984 /* CppExceptionConversion.proto */
985 #ifndef __Pyx_CppExn2PyErr
986 #include <new>
987 #include <typeinfo>
988 #include <stdexcept>
989 #include <ios>
990 static void __Pyx_CppExn2PyErr() {
991  try {
992  if (PyErr_Occurred())
993  ; // let the latest Python exn pass through and ignore the current one
994  else
995  throw;
996  } catch (const std::bad_alloc& exn) {
997  PyErr_SetString(PyExc_MemoryError, exn.what());
998  } catch (const std::bad_cast& exn) {
999  PyErr_SetString(PyExc_TypeError, exn.what());
1000  } catch (const std::bad_typeid& exn) {
1001  PyErr_SetString(PyExc_TypeError, exn.what());
1002  } catch (const std::domain_error& exn) {
1003  PyErr_SetString(PyExc_ValueError, exn.what());
1004  } catch (const std::invalid_argument& exn) {
1005  PyErr_SetString(PyExc_ValueError, exn.what());
1006  } catch (const std::ios_base::failure& exn) {
1007  PyErr_SetString(PyExc_IOError, exn.what());
1008  } catch (const std::out_of_range& exn) {
1009  PyErr_SetString(PyExc_IndexError, exn.what());
1010  } catch (const std::overflow_error& exn) {
1011  PyErr_SetString(PyExc_OverflowError, exn.what());
1012  } catch (const std::range_error& exn) {
1013  PyErr_SetString(PyExc_ArithmeticError, exn.what());
1014  } catch (const std::underflow_error& exn) {
1015  PyErr_SetString(PyExc_ArithmeticError, exn.what());
1016  } catch (const std::exception& exn) {
1017  PyErr_SetString(PyExc_RuntimeError, exn.what());
1018  }
1019  catch (...)
1020  {
1021  PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
1022  }
1023 }
1024 #endif
1025 
1026 /* CIntToPy.proto */
1027 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1028 
1029 /* CIntToPy.proto */
1030 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1031 
1032 /* CIntFromPy.proto */
1033 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1034 
1035 /* CIntFromPy.proto */
1036 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1037 
1038 /* CheckBinaryVersion.proto */
1039 static int __Pyx_check_binary_version(void);
1040 
1041 /* FunctionExport.proto */
1042 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
1043 
1044 /* PyIdentifierFromString.proto */
1045 #if !defined(__Pyx_PyIdentifier_FromString)
1046 #if PY_MAJOR_VERSION < 3
1047  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
1048 #else
1049  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
1050 #endif
1051 #endif
1052 
1053 /* ModuleImport.proto */
1054 static PyObject *__Pyx_ImportModule(const char *name);
1055 
1056 /* TypeImport.proto */
1057 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
1058 
1059 /* InitStrings.proto */
1060 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1061 
1062 
1063 /* Module declarations from 'libc.string' */
1064 
1065 /* Module declarations from 'libcpp.string' */
1066 
1067 /* Module declarations from 'libcpp' */
1068 
1069 /* Module declarations from 'libcpp.typeinfo' */
1070 
1071 /* Module declarations from 'cpython.pycapsule' */
1072 
1073 /* Module declarations from 'libcpp.cast' */
1074 
1075 /* Module declarations from 'libc.stdio' */
1076 
1077 /* Module declarations from '__builtin__' */
1078 
1079 /* Module declarations from 'cpython.type' */
1080 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1081 
1082 /* Module declarations from 'cpython' */
1083 
1084 /* Module declarations from 'cpython.object' */
1085 
1086 /* Module declarations from 'cpython.exc' */
1087 
1088 /* Module declarations from 'pymodule' */
1089 static std::string __pyx_f_8pymodule_str_py_to_cpp(PyObject *); /*proto*/
1090 static PyObject *__pyx_f_8pymodule_std_string_to_py(std::string); /*proto*/
1094 __PYX_EXTERN_C void CyclusClearPyAgentRefs(void); /*proto*/
1095 __PYX_EXTERN_C void CyclusPyDelAgent(int); /*proto*/
1097 static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/
1098 static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/
1099 static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/
1100 static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/
1101 static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/
1102 #define __Pyx_MODULE_NAME "pymodule"
1103 int __pyx_module_is_main_pymodule = 0;
1104 
1105 /* Implementation of 'pymodule' */
1106 static PyObject *__pyx_builtin_ImportError;
1107 static const char __pyx_k_[] = "*";
1108 static const char __pyx_k_py[] = "<py>";
1109 static const char __pyx_k_ts[] = "ts";
1110 static const char __pyx_k_Inst[] = "Inst";
1111 static const char __pyx_k_file[] = "__file__";
1112 static const char __pyx_k_main[] = "__main__";
1113 static const char __pyx_k_test[] = "__test__";
1114 static const char __pyx_k_Region[] = "Region";
1115 static const char __pyx_k_cyclib[] = "cyclib";
1116 static const char __pyx_k_decode[] = "decode";
1117 static const char __pyx_k_encode[] = "encode";
1118 static const char __pyx_k_import[] = "__import__";
1119 static const char __pyx_k_Facility[] = "Facility";
1120 static const char __pyx_k_del_agent[] = "_del_agent";
1121 static const char __pyx_k_importlib[] = "importlib";
1122 static const char __pyx_k_cyclus_lib[] = "cyclus.lib";
1123 static const char __pyx_k_ImportError[] = "ImportError";
1124 static const char __pyx_k_import_module[] = "import_module";
1125 static const char __pyx_k_make_py_agent[] = "make_py_agent";
1126 static const char __pyx_k_call_listeners[] = "call_listeners";
1127 static const char __pyx_k_init_from_agent[] = "init_from_agent";
1128 static const char __pyx_k_clear_agent_refs[] = "_clear_agent_refs";
1129 static const char __pyx_k_capsule_any_to_py[] = "capsule_any_to_py";
1130 static const char __pyx_k_cyclus_typesystem[] = "cyclus.typesystem";
1131 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1132 static const char __pyx_k_capsule_agent_to_py[] = "capsule_agent_to_py";
1133 static const char __pyx_k_Cyclus_Python_module_loading_too[] = "Cyclus Python module loading tools.";
1134 static PyObject *__pyx_n_s_;
1135 static PyObject *__pyx_n_u_Facility;
1136 static PyObject *__pyx_n_s_ImportError;
1137 static PyObject *__pyx_n_u_Inst;
1138 static PyObject *__pyx_n_u_Region;
1139 static PyObject *__pyx_n_s_call_listeners;
1140 static PyObject *__pyx_n_s_capsule_agent_to_py;
1141 static PyObject *__pyx_n_s_capsule_any_to_py;
1142 static PyObject *__pyx_n_s_clear_agent_refs;
1143 static PyObject *__pyx_n_s_cline_in_traceback;
1144 static PyObject *__pyx_n_s_cyclib;
1145 static PyObject *__pyx_n_s_cyclus_lib;
1146 static PyObject *__pyx_n_s_cyclus_typesystem;
1147 static PyObject *__pyx_n_s_decode;
1148 static PyObject *__pyx_n_s_del_agent;
1149 static PyObject *__pyx_n_s_encode;
1150 static PyObject *__pyx_n_s_file;
1151 static PyObject *__pyx_n_s_import;
1152 static PyObject *__pyx_n_s_import_module;
1153 static PyObject *__pyx_n_s_importlib;
1154 static PyObject *__pyx_n_s_init_from_agent;
1155 static PyObject *__pyx_n_s_main;
1156 static PyObject *__pyx_n_s_make_py_agent;
1157 static PyObject *__pyx_kp_u_py;
1158 static PyObject *__pyx_n_s_test;
1159 static PyObject *__pyx_n_s_ts;
1160 
1161 /* "pymodule.pyx":13
1162  * import cyclus.typesystem as ts
1163  *
1164  * cdef object std_string_to_py(std_string x): # <<<<<<<<<<<<<<
1165  * pyx = x
1166  * pyx = pyx.decode()
1167  */
1168 
1169 static PyObject *__pyx_f_8pymodule_std_string_to_py(std::string __pyx_v_x) {
1170  PyObject *__pyx_v_pyx = NULL;
1171  PyObject *__pyx_r = NULL;
1172  __Pyx_RefNannyDeclarations
1173  PyObject *__pyx_t_1 = NULL;
1174  PyObject *__pyx_t_2 = NULL;
1175  PyObject *__pyx_t_3 = NULL;
1176  __Pyx_RefNannySetupContext("std_string_to_py", 0);
1177 
1178  /* "pymodule.pyx":14
1179  *
1180  * cdef object std_string_to_py(std_string x):
1181  * pyx = x # <<<<<<<<<<<<<<
1182  * pyx = pyx.decode()
1183  * return pyx
1184  */
1185  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
1186  __Pyx_GOTREF(__pyx_t_1);
1187  __pyx_v_pyx = __pyx_t_1;
1188  __pyx_t_1 = 0;
1189 
1190  /* "pymodule.pyx":15
1191  * cdef object std_string_to_py(std_string x):
1192  * pyx = x
1193  * pyx = pyx.decode() # <<<<<<<<<<<<<<
1194  * return pyx
1195  *
1196  */
1197  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pyx, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
1198  __Pyx_GOTREF(__pyx_t_2);
1199  __pyx_t_3 = NULL;
1200  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1201  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1202  if (likely(__pyx_t_3)) {
1203  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1204  __Pyx_INCREF(__pyx_t_3);
1205  __Pyx_INCREF(function);
1206  __Pyx_DECREF_SET(__pyx_t_2, function);
1207  }
1208  }
1209  if (__pyx_t_3) {
1210  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
1211  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1212  } else {
1213  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
1214  }
1215  __Pyx_GOTREF(__pyx_t_1);
1216  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1217  __Pyx_DECREF_SET(__pyx_v_pyx, __pyx_t_1);
1218  __pyx_t_1 = 0;
1219 
1220  /* "pymodule.pyx":16
1221  * pyx = x
1222  * pyx = pyx.decode()
1223  * return pyx # <<<<<<<<<<<<<<
1224  *
1225  *
1226  */
1227  __Pyx_XDECREF(__pyx_r);
1228  __Pyx_INCREF(__pyx_v_pyx);
1229  __pyx_r = __pyx_v_pyx;
1230  goto __pyx_L0;
1231 
1232  /* "pymodule.pyx":13
1233  * import cyclus.typesystem as ts
1234  *
1235  * cdef object std_string_to_py(std_string x): # <<<<<<<<<<<<<<
1236  * pyx = x
1237  * pyx = pyx.decode()
1238  */
1239 
1240  /* function exit code */
1241  __pyx_L1_error:;
1242  __Pyx_XDECREF(__pyx_t_1);
1243  __Pyx_XDECREF(__pyx_t_2);
1244  __Pyx_XDECREF(__pyx_t_3);
1245  __Pyx_AddTraceback("pymodule.std_string_to_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
1246  __pyx_r = 0;
1247  __pyx_L0:;
1248  __Pyx_XDECREF(__pyx_v_pyx);
1249  __Pyx_XGIVEREF(__pyx_r);
1250  __Pyx_RefNannyFinishContext();
1251  return __pyx_r;
1252 }
1253 
1254 /* "pymodule.pyx":19
1255  *
1256  *
1257  * cdef std_string str_py_to_cpp(object x): # <<<<<<<<<<<<<<
1258  * cdef std_string s
1259  * x = x.encode()
1260  */
1261 
1262 static std::string __pyx_f_8pymodule_str_py_to_cpp(PyObject *__pyx_v_x) {
1263  std::string __pyx_v_s;
1264  std::string __pyx_r;
1265  __Pyx_RefNannyDeclarations
1266  PyObject *__pyx_t_1 = NULL;
1267  PyObject *__pyx_t_2 = NULL;
1268  PyObject *__pyx_t_3 = NULL;
1269  char const *__pyx_t_4;
1270  std::string __pyx_t_5;
1271  __Pyx_RefNannySetupContext("str_py_to_cpp", 0);
1272  __Pyx_INCREF(__pyx_v_x);
1273 
1274  /* "pymodule.pyx":21
1275  * cdef std_string str_py_to_cpp(object x):
1276  * cdef std_string s
1277  * x = x.encode() # <<<<<<<<<<<<<<
1278  * s = std_string(<const char*> x)
1279  * return s
1280  */
1281  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
1282  __Pyx_GOTREF(__pyx_t_2);
1283  __pyx_t_3 = NULL;
1284  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1285  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1286  if (likely(__pyx_t_3)) {
1287  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1288  __Pyx_INCREF(__pyx_t_3);
1289  __Pyx_INCREF(function);
1290  __Pyx_DECREF_SET(__pyx_t_2, function);
1291  }
1292  }
1293  if (__pyx_t_3) {
1294  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
1295  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1296  } else {
1297  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
1298  }
1299  __Pyx_GOTREF(__pyx_t_1);
1300  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1301  __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_1);
1302  __pyx_t_1 = 0;
1303 
1304  /* "pymodule.pyx":22
1305  * cdef std_string s
1306  * x = x.encode()
1307  * s = std_string(<const char*> x) # <<<<<<<<<<<<<<
1308  * return s
1309  *
1310  */
1311  __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_v_x); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L1_error)
1312  try {
1313  __pyx_t_5 = std::string(((char const *)__pyx_t_4));
1314  } catch(...) {
1315  __Pyx_CppExn2PyErr();
1316  __PYX_ERR(0, 22, __pyx_L1_error)
1317  }
1318  __pyx_v_s = __pyx_t_5;
1319 
1320  /* "pymodule.pyx":23
1321  * x = x.encode()
1322  * s = std_string(<const char*> x)
1323  * return s # <<<<<<<<<<<<<<
1324  *
1325  *
1326  */
1327  __pyx_r = __pyx_v_s;
1328  goto __pyx_L0;
1329 
1330  /* "pymodule.pyx":19
1331  *
1332  *
1333  * cdef std_string str_py_to_cpp(object x): # <<<<<<<<<<<<<<
1334  * cdef std_string s
1335  * x = x.encode()
1336  */
1337 
1338  /* function exit code */
1339  __pyx_L1_error:;
1340  __Pyx_XDECREF(__pyx_t_1);
1341  __Pyx_XDECREF(__pyx_t_2);
1342  __Pyx_XDECREF(__pyx_t_3);
1343  __Pyx_WriteUnraisable("pymodule.str_py_to_cpp", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
1344  __Pyx_pretend_to_initialize(&__pyx_r);
1345  __pyx_L0:;
1346  __Pyx_XDECREF(__pyx_v_x);
1347  __Pyx_RefNannyFinishContext();
1348  return __pyx_r;
1349 }
1350 
1351 /* "pymodule.pyx":26
1352  *
1353  *
1354  * cdef public std_string py_find_module "CyclusPyFindModule" (std_string cpp_lib) except +: # <<<<<<<<<<<<<<
1355  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1356  * lib = std_string_to_py(cpp_lib)
1357  */
1358 
1359 std::string CyclusPyFindModule(std::string __pyx_v_cpp_lib) {
1360  PyObject *__pyx_v_lib = NULL;
1361  PyObject *__pyx_v_mod = NULL;
1362  std::string __pyx_v_rtn;
1363  std::string __pyx_r;
1364  __Pyx_RefNannyDeclarations
1365  PyObject *__pyx_t_1 = NULL;
1366  PyObject *__pyx_t_2 = NULL;
1367  PyObject *__pyx_t_3 = NULL;
1368  PyObject *__pyx_t_4 = NULL;
1369  PyObject *__pyx_t_5 = NULL;
1370  PyObject *__pyx_t_6 = NULL;
1371  PyObject *__pyx_t_7 = NULL;
1372  int __pyx_t_8;
1373  std::string __pyx_t_9;
1374  __Pyx_RefNannySetupContext("py_find_module", 0);
1375 
1376  /* "pymodule.pyx":28
1377  * cdef public std_string py_find_module "CyclusPyFindModule" (std_string cpp_lib) except +:
1378  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1379  * lib = std_string_to_py(cpp_lib) # <<<<<<<<<<<<<<
1380  * try:
1381  * mod = import_module(lib)
1382  */
1383  __pyx_t_1 = __pyx_f_8pymodule_std_string_to_py(__pyx_v_cpp_lib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
1384  __Pyx_GOTREF(__pyx_t_1);
1385  __pyx_v_lib = __pyx_t_1;
1386  __pyx_t_1 = 0;
1387 
1388  /* "pymodule.pyx":29
1389  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1390  * lib = std_string_to_py(cpp_lib)
1391  * try: # <<<<<<<<<<<<<<
1392  * mod = import_module(lib)
1393  * except ImportError:
1394  */
1395  {
1396  __Pyx_PyThreadState_declare
1397  __Pyx_PyThreadState_assign
1398  __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
1399  __Pyx_XGOTREF(__pyx_t_2);
1400  __Pyx_XGOTREF(__pyx_t_3);
1401  __Pyx_XGOTREF(__pyx_t_4);
1402  /*try:*/ {
1403 
1404  /* "pymodule.pyx":30
1405  * lib = std_string_to_py(cpp_lib)
1406  * try:
1407  * mod = import_module(lib) # <<<<<<<<<<<<<<
1408  * except ImportError:
1409  * return std_string(b"")
1410  */
1411  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_module); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L3_error)
1412  __Pyx_GOTREF(__pyx_t_5);
1413  __pyx_t_6 = NULL;
1414  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
1415  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
1416  if (likely(__pyx_t_6)) {
1417  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
1418  __Pyx_INCREF(__pyx_t_6);
1419  __Pyx_INCREF(function);
1420  __Pyx_DECREF_SET(__pyx_t_5, function);
1421  }
1422  }
1423  if (!__pyx_t_6) {
1424  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_lib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L3_error)
1425  __Pyx_GOTREF(__pyx_t_1);
1426  } else {
1427  #if CYTHON_FAST_PYCALL
1428  if (PyFunction_Check(__pyx_t_5)) {
1429  PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_lib};
1430  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L3_error)
1431  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1432  __Pyx_GOTREF(__pyx_t_1);
1433  } else
1434  #endif
1435  #if CYTHON_FAST_PYCCALL
1436  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
1437  PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_lib};
1438  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L3_error)
1439  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1440  __Pyx_GOTREF(__pyx_t_1);
1441  } else
1442  #endif
1443  {
1444  __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L3_error)
1445  __Pyx_GOTREF(__pyx_t_7);
1446  __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
1447  __Pyx_INCREF(__pyx_v_lib);
1448  __Pyx_GIVEREF(__pyx_v_lib);
1449  PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_lib);
1450  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L3_error)
1451  __Pyx_GOTREF(__pyx_t_1);
1452  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1453  }
1454  }
1455  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1456  __pyx_v_mod = __pyx_t_1;
1457  __pyx_t_1 = 0;
1458 
1459  /* "pymodule.pyx":29
1460  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1461  * lib = std_string_to_py(cpp_lib)
1462  * try: # <<<<<<<<<<<<<<
1463  * mod = import_module(lib)
1464  * except ImportError:
1465  */
1466  }
1467  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1468  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1469  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1470  goto __pyx_L8_try_end;
1471  __pyx_L3_error:;
1472  __Pyx_PyThreadState_assign
1473  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1474  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
1475  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1476  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
1477 
1478  /* "pymodule.pyx":31
1479  * try:
1480  * mod = import_module(lib)
1481  * except ImportError: # <<<<<<<<<<<<<<
1482  * return std_string(b"")
1483  * PyErr_CheckSignals()
1484  */
1485  __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
1486  if (__pyx_t_8) {
1487  __Pyx_AddTraceback("pymodule.py_find_module", __pyx_clineno, __pyx_lineno, __pyx_filename);
1488  if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 31, __pyx_L5_except_error)
1489  __Pyx_GOTREF(__pyx_t_1);
1490  __Pyx_GOTREF(__pyx_t_5);
1491  __Pyx_GOTREF(__pyx_t_7);
1492 
1493  /* "pymodule.pyx":32
1494  * mod = import_module(lib)
1495  * except ImportError:
1496  * return std_string(b"") # <<<<<<<<<<<<<<
1497  * PyErr_CheckSignals()
1498  * cdef std_string rtn = str_py_to_cpp("<py>" + mod.__file__)
1499  */
1500  try {
1501  __pyx_t_9 = std::string(((char *)""));
1502  } catch(...) {
1503  __Pyx_CppExn2PyErr();
1504  __PYX_ERR(0, 32, __pyx_L5_except_error)
1505  }
1506  __pyx_r = __pyx_t_9;
1507  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1508  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1509  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1510  goto __pyx_L6_except_return;
1511  }
1512  goto __pyx_L5_except_error;
1513  __pyx_L5_except_error:;
1514 
1515  /* "pymodule.pyx":29
1516  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1517  * lib = std_string_to_py(cpp_lib)
1518  * try: # <<<<<<<<<<<<<<
1519  * mod = import_module(lib)
1520  * except ImportError:
1521  */
1522  __Pyx_PyThreadState_assign
1523  __Pyx_XGIVEREF(__pyx_t_2);
1524  __Pyx_XGIVEREF(__pyx_t_3);
1525  __Pyx_XGIVEREF(__pyx_t_4);
1526  __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
1527  goto __pyx_L1_error;
1528  __pyx_L6_except_return:;
1529  __Pyx_PyThreadState_assign
1530  __Pyx_XGIVEREF(__pyx_t_2);
1531  __Pyx_XGIVEREF(__pyx_t_3);
1532  __Pyx_XGIVEREF(__pyx_t_4);
1533  __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
1534  goto __pyx_L0;
1535  __pyx_L8_try_end:;
1536  }
1537 
1538  /* "pymodule.pyx":33
1539  * except ImportError:
1540  * return std_string(b"")
1541  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
1542  * cdef std_string rtn = str_py_to_cpp("<py>" + mod.__file__)
1543  * return rtn
1544  */
1545  __pyx_t_8 = PyErr_CheckSignals(); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 33, __pyx_L1_error)
1546 
1547  /* "pymodule.pyx":34
1548  * return std_string(b"")
1549  * PyErr_CheckSignals()
1550  * cdef std_string rtn = str_py_to_cpp("<py>" + mod.__file__) # <<<<<<<<<<<<<<
1551  * return rtn
1552  *
1553  */
1554  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_mod, __pyx_n_s_file); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 34, __pyx_L1_error)
1555  __Pyx_GOTREF(__pyx_t_7);
1556  __pyx_t_5 = PyNumber_Add(__pyx_kp_u_py, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 34, __pyx_L1_error)
1557  __Pyx_GOTREF(__pyx_t_5);
1558  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1559  __pyx_v_rtn = __pyx_f_8pymodule_str_py_to_cpp(__pyx_t_5);
1560  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1561 
1562  /* "pymodule.pyx":35
1563  * PyErr_CheckSignals()
1564  * cdef std_string rtn = str_py_to_cpp("<py>" + mod.__file__)
1565  * return rtn # <<<<<<<<<<<<<<
1566  *
1567  *
1568  */
1569  __pyx_r = __pyx_v_rtn;
1570  goto __pyx_L0;
1571 
1572  /* "pymodule.pyx":26
1573  *
1574  *
1575  * cdef public std_string py_find_module "CyclusPyFindModule" (std_string cpp_lib) except +: # <<<<<<<<<<<<<<
1576  * """Finds a Python module and returns a string of the form '<py>:modulepath'"""
1577  * lib = std_string_to_py(cpp_lib)
1578  */
1579 
1580  /* function exit code */
1581  __pyx_L1_error:;
1582  __Pyx_XDECREF(__pyx_t_1);
1583  __Pyx_XDECREF(__pyx_t_5);
1584  __Pyx_XDECREF(__pyx_t_6);
1585  __Pyx_XDECREF(__pyx_t_7);
1586  __Pyx_AddTraceback("pymodule.py_find_module", __pyx_clineno, __pyx_lineno, __pyx_filename);
1587  __Pyx_pretend_to_initialize(&__pyx_r);
1588  __pyx_L0:;
1589  __Pyx_XDECREF(__pyx_v_lib);
1590  __Pyx_XDECREF(__pyx_v_mod);
1591  __Pyx_RefNannyFinishContext();
1592  return __pyx_r;
1593 }
1594 
1595 /* "pymodule.pyx":38
1596  *
1597  *
1598  * cdef public Agent* make_py_agent "CyclusMakePyAgent" (std_string cpp_lib, # <<<<<<<<<<<<<<
1599  * std_string cpp_agent,
1600  * void* cpp_ctx) except +:
1601  */
1602 
1603 cyclus::Agent *CyclusMakePyAgent(std::string __pyx_v_cpp_lib, std::string __pyx_v_cpp_agent, void *__pyx_v_cpp_ctx) {
1604  PyObject *__pyx_v_libname = NULL;
1605  PyObject *__pyx_v_agentname = NULL;
1606  PyObject *__pyx_v_ctx = NULL;
1607  PyObject *__pyx_v_a = NULL;
1608  PyObject *__pyx_v_kind = NULL;
1609  void *__pyx_v_avoid;
1610  cyclus::Agent *__pyx_v_rtn;
1611  cyclus::Agent *__pyx_r;
1612  __Pyx_RefNannyDeclarations
1613  PyObject *__pyx_t_1 = NULL;
1614  PyObject *__pyx_t_2 = NULL;
1615  PyObject *__pyx_t_3 = NULL;
1616  int __pyx_t_4;
1617  PyObject *__pyx_t_5 = NULL;
1618  PyObject *(*__pyx_t_6)(PyObject *);
1619  void *__pyx_t_7;
1620  int __pyx_t_8;
1621  __pyx_t_8pymodule_agent_ptr __pyx_t_9;
1622  __Pyx_RefNannySetupContext("make_py_agent", 0);
1623 
1624  /* "pymodule.pyx":42
1625  * void* cpp_ctx) except +:
1626  * """Makes a new Python agent instance."""
1627  * libname = std_string_to_py(cpp_lib) # <<<<<<<<<<<<<<
1628  * agentname = std_string_to_py(cpp_agent)
1629  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
1630  */
1631  __pyx_t_1 = __pyx_f_8pymodule_std_string_to_py(__pyx_v_cpp_lib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
1632  __Pyx_GOTREF(__pyx_t_1);
1633  __pyx_v_libname = __pyx_t_1;
1634  __pyx_t_1 = 0;
1635 
1636  /* "pymodule.pyx":43
1637  * """Makes a new Python agent instance."""
1638  * libname = std_string_to_py(cpp_lib)
1639  * agentname = std_string_to_py(cpp_agent) # <<<<<<<<<<<<<<
1640  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
1641  * a, kind = cyclib.make_py_agent(libname, agentname, ctx)
1642  */
1643  __pyx_t_1 = __pyx_f_8pymodule_std_string_to_py(__pyx_v_cpp_agent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
1644  __Pyx_GOTREF(__pyx_t_1);
1645  __pyx_v_agentname = __pyx_t_1;
1646  __pyx_t_1 = 0;
1647 
1648  /* "pymodule.pyx":44
1649  * libname = std_string_to_py(cpp_lib)
1650  * agentname = std_string_to_py(cpp_agent)
1651  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL) # <<<<<<<<<<<<<<
1652  * a, kind = cyclib.make_py_agent(libname, agentname, ctx)
1653  * cdef void* avoid = PyCapsule_GetPointer(a, <char*> b"agent")
1654  */
1655  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_ctx, ((char *)((char *)"ctx")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
1656  __Pyx_GOTREF(__pyx_t_1);
1657  __pyx_v_ctx = __pyx_t_1;
1658  __pyx_t_1 = 0;
1659 
1660  /* "pymodule.pyx":45
1661  * agentname = std_string_to_py(cpp_agent)
1662  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
1663  * a, kind = cyclib.make_py_agent(libname, agentname, ctx) # <<<<<<<<<<<<<<
1664  * cdef void* avoid = PyCapsule_GetPointer(a, <char*> b"agent")
1665  * cdef Agent* rtn
1666  */
1667  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
1668  __Pyx_GOTREF(__pyx_t_2);
1669  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_make_py_agent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
1670  __Pyx_GOTREF(__pyx_t_3);
1671  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1672  __pyx_t_2 = NULL;
1673  __pyx_t_4 = 0;
1674  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1675  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
1676  if (likely(__pyx_t_2)) {
1677  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1678  __Pyx_INCREF(__pyx_t_2);
1679  __Pyx_INCREF(function);
1680  __Pyx_DECREF_SET(__pyx_t_3, function);
1681  __pyx_t_4 = 1;
1682  }
1683  }
1684  #if CYTHON_FAST_PYCALL
1685  if (PyFunction_Check(__pyx_t_3)) {
1686  PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_libname, __pyx_v_agentname, __pyx_v_ctx};
1687  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
1688  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1689  __Pyx_GOTREF(__pyx_t_1);
1690  } else
1691  #endif
1692  #if CYTHON_FAST_PYCCALL
1693  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
1694  PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_libname, __pyx_v_agentname, __pyx_v_ctx};
1695  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
1696  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1697  __Pyx_GOTREF(__pyx_t_1);
1698  } else
1699  #endif
1700  {
1701  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L1_error)
1702  __Pyx_GOTREF(__pyx_t_5);
1703  if (__pyx_t_2) {
1704  __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
1705  }
1706  __Pyx_INCREF(__pyx_v_libname);
1707  __Pyx_GIVEREF(__pyx_v_libname);
1708  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_libname);
1709  __Pyx_INCREF(__pyx_v_agentname);
1710  __Pyx_GIVEREF(__pyx_v_agentname);
1711  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_agentname);
1712  __Pyx_INCREF(__pyx_v_ctx);
1713  __Pyx_GIVEREF(__pyx_v_ctx);
1714  PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ctx);
1715  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
1716  __Pyx_GOTREF(__pyx_t_1);
1717  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1718  }
1719  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1720  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
1721  PyObject* sequence = __pyx_t_1;
1722  #if !CYTHON_COMPILING_IN_PYPY
1723  Py_ssize_t size = Py_SIZE(sequence);
1724  #else
1725  Py_ssize_t size = PySequence_Size(sequence);
1726  #endif
1727  if (unlikely(size != 2)) {
1728  if (size > 2) __Pyx_RaiseTooManyValuesError(2);
1729  else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1730  __PYX_ERR(0, 45, __pyx_L1_error)
1731  }
1732  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1733  if (likely(PyTuple_CheckExact(sequence))) {
1734  __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
1735  __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
1736  } else {
1737  __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
1738  __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
1739  }
1740  __Pyx_INCREF(__pyx_t_3);
1741  __Pyx_INCREF(__pyx_t_5);
1742  #else
1743  __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
1744  __Pyx_GOTREF(__pyx_t_3);
1745  __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L1_error)
1746  __Pyx_GOTREF(__pyx_t_5);
1747  #endif
1748  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1749  } else {
1750  Py_ssize_t index = -1;
1751  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
1752  __Pyx_GOTREF(__pyx_t_2);
1753  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1754  __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext;
1755  index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
1756  __Pyx_GOTREF(__pyx_t_3);
1757  index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
1758  __Pyx_GOTREF(__pyx_t_5);
1759  if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_2), 2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
1760  __pyx_t_6 = NULL;
1761  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1762  goto __pyx_L4_unpacking_done;
1763  __pyx_L3_unpacking_failed:;
1764  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1765  __pyx_t_6 = NULL;
1766  if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1767  __PYX_ERR(0, 45, __pyx_L1_error)
1768  __pyx_L4_unpacking_done:;
1769  }
1770  __pyx_v_a = __pyx_t_3;
1771  __pyx_t_3 = 0;
1772  __pyx_v_kind = __pyx_t_5;
1773  __pyx_t_5 = 0;
1774 
1775  /* "pymodule.pyx":46
1776  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
1777  * a, kind = cyclib.make_py_agent(libname, agentname, ctx)
1778  * cdef void* avoid = PyCapsule_GetPointer(a, <char*> b"agent") # <<<<<<<<<<<<<<
1779  * cdef Agent* rtn
1780  * if kind == "Region":
1781  */
1782  __pyx_t_7 = PyCapsule_GetPointer(__pyx_v_a, ((char *)((char *)"agent"))); if (unlikely(__pyx_t_7 == NULL && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
1783  __pyx_v_avoid = __pyx_t_7;
1784 
1785  /* "pymodule.pyx":48
1786  * cdef void* avoid = PyCapsule_GetPointer(a, <char*> b"agent")
1787  * cdef Agent* rtn
1788  * if kind == "Region": # <<<<<<<<<<<<<<
1789  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid))
1790  * elif kind == "Inst":
1791  */
1792  __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_n_u_Region, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 48, __pyx_L1_error)
1793  if (__pyx_t_8) {
1794 
1795  /* "pymodule.pyx":49
1796  * cdef Agent* rtn
1797  * if kind == "Region":
1798  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid)) # <<<<<<<<<<<<<<
1799  * elif kind == "Inst":
1800  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1801  */
1802  try {
1803  __pyx_t_9 = dynamic_cast<__pyx_t_8pymodule_agent_ptr>(reinterpret_cast<__pyx_t_8pymodule_region_ptr>(__pyx_v_avoid));
1804  } catch(...) {
1805  __Pyx_CppExn2PyErr();
1806  __PYX_ERR(0, 49, __pyx_L1_error)
1807  }
1808  __pyx_v_rtn = __pyx_t_9;
1809 
1810  /* "pymodule.pyx":48
1811  * cdef void* avoid = PyCapsule_GetPointer(a, <char*> b"agent")
1812  * cdef Agent* rtn
1813  * if kind == "Region": # <<<<<<<<<<<<<<
1814  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid))
1815  * elif kind == "Inst":
1816  */
1817  goto __pyx_L5;
1818  }
1819 
1820  /* "pymodule.pyx":50
1821  * if kind == "Region":
1822  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid))
1823  * elif kind == "Inst": # <<<<<<<<<<<<<<
1824  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1825  * elif kind == "Facility":
1826  */
1827  __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_n_u_Inst, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
1828  if (__pyx_t_8) {
1829 
1830  /* "pymodule.pyx":51
1831  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid))
1832  * elif kind == "Inst":
1833  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid)) # <<<<<<<<<<<<<<
1834  * elif kind == "Facility":
1835  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[facility_ptr](avoid))
1836  */
1837  try {
1838  __pyx_t_9 = dynamic_cast<__pyx_t_8pymodule_agent_ptr>(reinterpret_cast<__pyx_t_8pymodule_institution_ptr>(__pyx_v_avoid));
1839  } catch(...) {
1840  __Pyx_CppExn2PyErr();
1841  __PYX_ERR(0, 51, __pyx_L1_error)
1842  }
1843  __pyx_v_rtn = __pyx_t_9;
1844 
1845  /* "pymodule.pyx":50
1846  * if kind == "Region":
1847  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[region_ptr](avoid))
1848  * elif kind == "Inst": # <<<<<<<<<<<<<<
1849  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1850  * elif kind == "Facility":
1851  */
1852  goto __pyx_L5;
1853  }
1854 
1855  /* "pymodule.pyx":52
1856  * elif kind == "Inst":
1857  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1858  * elif kind == "Facility": # <<<<<<<<<<<<<<
1859  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[facility_ptr](avoid))
1860  * else:
1861  */
1862  __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_n_u_Facility, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 52, __pyx_L1_error)
1863  if (__pyx_t_8) {
1864 
1865  /* "pymodule.pyx":53
1866  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1867  * elif kind == "Facility":
1868  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[facility_ptr](avoid)) # <<<<<<<<<<<<<<
1869  * else:
1870  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[agent_ptr](avoid))
1871  */
1872  try {
1873  __pyx_t_9 = dynamic_cast<__pyx_t_8pymodule_agent_ptr>(reinterpret_cast<__pyx_t_8pymodule_facility_ptr>(__pyx_v_avoid));
1874  } catch(...) {
1875  __Pyx_CppExn2PyErr();
1876  __PYX_ERR(0, 53, __pyx_L1_error)
1877  }
1878  __pyx_v_rtn = __pyx_t_9;
1879 
1880  /* "pymodule.pyx":52
1881  * elif kind == "Inst":
1882  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[institution_ptr](avoid))
1883  * elif kind == "Facility": # <<<<<<<<<<<<<<
1884  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[facility_ptr](avoid))
1885  * else:
1886  */
1887  goto __pyx_L5;
1888  }
1889 
1890  /* "pymodule.pyx":55
1891  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[facility_ptr](avoid))
1892  * else:
1893  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[agent_ptr](avoid)) # <<<<<<<<<<<<<<
1894  * PyErr_CheckSignals()
1895  * return rtn
1896  */
1897  /*else*/ {
1898  try {
1899  __pyx_t_9 = dynamic_cast<__pyx_t_8pymodule_agent_ptr>(reinterpret_cast<__pyx_t_8pymodule_agent_ptr>(__pyx_v_avoid));
1900  } catch(...) {
1901  __Pyx_CppExn2PyErr();
1902  __PYX_ERR(0, 55, __pyx_L1_error)
1903  }
1904  __pyx_v_rtn = __pyx_t_9;
1905  }
1906  __pyx_L5:;
1907 
1908  /* "pymodule.pyx":56
1909  * else:
1910  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[agent_ptr](avoid))
1911  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
1912  * return rtn
1913  *
1914  */
1915  __pyx_t_4 = PyErr_CheckSignals(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 56, __pyx_L1_error)
1916 
1917  /* "pymodule.pyx":57
1918  * rtn = dynamic_cast[agent_ptr](reinterpret_cast[agent_ptr](avoid))
1919  * PyErr_CheckSignals()
1920  * return rtn # <<<<<<<<<<<<<<
1921  *
1922  *
1923  */
1924  __pyx_r = __pyx_v_rtn;
1925  goto __pyx_L0;
1926 
1927  /* "pymodule.pyx":38
1928  *
1929  *
1930  * cdef public Agent* make_py_agent "CyclusMakePyAgent" (std_string cpp_lib, # <<<<<<<<<<<<<<
1931  * std_string cpp_agent,
1932  * void* cpp_ctx) except +:
1933  */
1934 
1935  /* function exit code */
1936  __pyx_L1_error:;
1937  __Pyx_XDECREF(__pyx_t_1);
1938  __Pyx_XDECREF(__pyx_t_2);
1939  __Pyx_XDECREF(__pyx_t_3);
1940  __Pyx_XDECREF(__pyx_t_5);
1941  __Pyx_AddTraceback("pymodule.make_py_agent", __pyx_clineno, __pyx_lineno, __pyx_filename);
1942  __pyx_r = 0;
1943  __pyx_L0:;
1944  __Pyx_XDECREF(__pyx_v_libname);
1945  __Pyx_XDECREF(__pyx_v_agentname);
1946  __Pyx_XDECREF(__pyx_v_ctx);
1947  __Pyx_XDECREF(__pyx_v_a);
1948  __Pyx_XDECREF(__pyx_v_kind);
1949  __Pyx_RefNannyFinishContext();
1950  return __pyx_r;
1951 }
1952 
1953 /* "pymodule.pyx":60
1954  *
1955  *
1956  * cdef public void init_from_py_agent "CyclusInitFromPyAgent" (Agent* cpp_src, # <<<<<<<<<<<<<<
1957  * Agent* cpp_dst,
1958  * void* cpp_ctx) except +:
1959  */
1960 
1961 void CyclusInitFromPyAgent(cyclus::Agent *__pyx_v_cpp_src, cyclus::Agent *__pyx_v_cpp_dst, void *__pyx_v_cpp_ctx) {
1962  PyObject *__pyx_v_ctx = NULL;
1963  PyObject *__pyx_v_src = NULL;
1964  PyObject *__pyx_v_dst = NULL;
1965  PyObject *__pyx_v_py_src = NULL;
1966  PyObject *__pyx_v_py_dst = NULL;
1967  __Pyx_RefNannyDeclarations
1968  PyObject *__pyx_t_1 = NULL;
1969  PyObject *__pyx_t_2 = NULL;
1970  PyObject *__pyx_t_3 = NULL;
1971  int __pyx_t_4;
1972  PyObject *__pyx_t_5 = NULL;
1973  __Pyx_RefNannySetupContext("init_from_py_agent", 0);
1974 
1975  /* "pymodule.pyx":66
1976  * normally need to call this. Useful for cloning prototypes.
1977  * """
1978  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL) # <<<<<<<<<<<<<<
1979  * src = PyCapsule_New(cpp_src, <char*> b"agent", NULL)
1980  * dst = PyCapsule_New(cpp_dst, <char*> b"agent", NULL)
1981  */
1982  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_ctx, ((char *)((char *)"ctx")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
1983  __Pyx_GOTREF(__pyx_t_1);
1984  __pyx_v_ctx = __pyx_t_1;
1985  __pyx_t_1 = 0;
1986 
1987  /* "pymodule.pyx":67
1988  * """
1989  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
1990  * src = PyCapsule_New(cpp_src, <char*> b"agent", NULL) # <<<<<<<<<<<<<<
1991  * dst = PyCapsule_New(cpp_dst, <char*> b"agent", NULL)
1992  * py_src = cyclib.capsule_agent_to_py(src, ctx)
1993  */
1994  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_src, ((char *)((char *)"agent")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
1995  __Pyx_GOTREF(__pyx_t_1);
1996  __pyx_v_src = __pyx_t_1;
1997  __pyx_t_1 = 0;
1998 
1999  /* "pymodule.pyx":68
2000  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
2001  * src = PyCapsule_New(cpp_src, <char*> b"agent", NULL)
2002  * dst = PyCapsule_New(cpp_dst, <char*> b"agent", NULL) # <<<<<<<<<<<<<<
2003  * py_src = cyclib.capsule_agent_to_py(src, ctx)
2004  * py_dst = cyclib.capsule_agent_to_py(dst, ctx)
2005  */
2006  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_dst, ((char *)((char *)"agent")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2007  __Pyx_GOTREF(__pyx_t_1);
2008  __pyx_v_dst = __pyx_t_1;
2009  __pyx_t_1 = 0;
2010 
2011  /* "pymodule.pyx":69
2012  * src = PyCapsule_New(cpp_src, <char*> b"agent", NULL)
2013  * dst = PyCapsule_New(cpp_dst, <char*> b"agent", NULL)
2014  * py_src = cyclib.capsule_agent_to_py(src, ctx) # <<<<<<<<<<<<<<
2015  * py_dst = cyclib.capsule_agent_to_py(dst, ctx)
2016  * py_dst.init_from_agent(py_src)
2017  */
2018  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
2019  __Pyx_GOTREF(__pyx_t_2);
2020  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_capsule_agent_to_py); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
2021  __Pyx_GOTREF(__pyx_t_3);
2022  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2023  __pyx_t_2 = NULL;
2024  __pyx_t_4 = 0;
2025  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2026  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2027  if (likely(__pyx_t_2)) {
2028  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2029  __Pyx_INCREF(__pyx_t_2);
2030  __Pyx_INCREF(function);
2031  __Pyx_DECREF_SET(__pyx_t_3, function);
2032  __pyx_t_4 = 1;
2033  }
2034  }
2035  #if CYTHON_FAST_PYCALL
2036  if (PyFunction_Check(__pyx_t_3)) {
2037  PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_src, __pyx_v_ctx};
2038  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
2039  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2040  __Pyx_GOTREF(__pyx_t_1);
2041  } else
2042  #endif
2043  #if CYTHON_FAST_PYCCALL
2044  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2045  PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_src, __pyx_v_ctx};
2046  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
2047  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2048  __Pyx_GOTREF(__pyx_t_1);
2049  } else
2050  #endif
2051  {
2052  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 69, __pyx_L1_error)
2053  __Pyx_GOTREF(__pyx_t_5);
2054  if (__pyx_t_2) {
2055  __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
2056  }
2057  __Pyx_INCREF(__pyx_v_src);
2058  __Pyx_GIVEREF(__pyx_v_src);
2059  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_src);
2060  __Pyx_INCREF(__pyx_v_ctx);
2061  __Pyx_GIVEREF(__pyx_v_ctx);
2062  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_ctx);
2063  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
2064  __Pyx_GOTREF(__pyx_t_1);
2065  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2066  }
2067  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2068  __pyx_v_py_src = __pyx_t_1;
2069  __pyx_t_1 = 0;
2070 
2071  /* "pymodule.pyx":70
2072  * dst = PyCapsule_New(cpp_dst, <char*> b"agent", NULL)
2073  * py_src = cyclib.capsule_agent_to_py(src, ctx)
2074  * py_dst = cyclib.capsule_agent_to_py(dst, ctx) # <<<<<<<<<<<<<<
2075  * py_dst.init_from_agent(py_src)
2076  * PyErr_CheckSignals()
2077  */
2078  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
2079  __Pyx_GOTREF(__pyx_t_3);
2080  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_capsule_agent_to_py); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 70, __pyx_L1_error)
2081  __Pyx_GOTREF(__pyx_t_5);
2082  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2083  __pyx_t_3 = NULL;
2084  __pyx_t_4 = 0;
2085  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2086  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
2087  if (likely(__pyx_t_3)) {
2088  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2089  __Pyx_INCREF(__pyx_t_3);
2090  __Pyx_INCREF(function);
2091  __Pyx_DECREF_SET(__pyx_t_5, function);
2092  __pyx_t_4 = 1;
2093  }
2094  }
2095  #if CYTHON_FAST_PYCALL
2096  if (PyFunction_Check(__pyx_t_5)) {
2097  PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_dst, __pyx_v_ctx};
2098  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
2099  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2100  __Pyx_GOTREF(__pyx_t_1);
2101  } else
2102  #endif
2103  #if CYTHON_FAST_PYCCALL
2104  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
2105  PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_dst, __pyx_v_ctx};
2106  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
2107  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2108  __Pyx_GOTREF(__pyx_t_1);
2109  } else
2110  #endif
2111  {
2112  __pyx_t_2 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
2113  __Pyx_GOTREF(__pyx_t_2);
2114  if (__pyx_t_3) {
2115  __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
2116  }
2117  __Pyx_INCREF(__pyx_v_dst);
2118  __Pyx_GIVEREF(__pyx_v_dst);
2119  PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_4, __pyx_v_dst);
2120  __Pyx_INCREF(__pyx_v_ctx);
2121  __Pyx_GIVEREF(__pyx_v_ctx);
2122  PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_4, __pyx_v_ctx);
2123  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
2124  __Pyx_GOTREF(__pyx_t_1);
2125  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2126  }
2127  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2128  __pyx_v_py_dst = __pyx_t_1;
2129  __pyx_t_1 = 0;
2130 
2131  /* "pymodule.pyx":71
2132  * py_src = cyclib.capsule_agent_to_py(src, ctx)
2133  * py_dst = cyclib.capsule_agent_to_py(dst, ctx)
2134  * py_dst.init_from_agent(py_src) # <<<<<<<<<<<<<<
2135  * PyErr_CheckSignals()
2136  *
2137  */
2138  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_py_dst, __pyx_n_s_init_from_agent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error)
2139  __Pyx_GOTREF(__pyx_t_5);
2140  __pyx_t_2 = NULL;
2141  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
2142  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
2143  if (likely(__pyx_t_2)) {
2144  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2145  __Pyx_INCREF(__pyx_t_2);
2146  __Pyx_INCREF(function);
2147  __Pyx_DECREF_SET(__pyx_t_5, function);
2148  }
2149  }
2150  if (!__pyx_t_2) {
2151  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_py_src); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
2152  __Pyx_GOTREF(__pyx_t_1);
2153  } else {
2154  #if CYTHON_FAST_PYCALL
2155  if (PyFunction_Check(__pyx_t_5)) {
2156  PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_py_src};
2157  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
2158  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2159  __Pyx_GOTREF(__pyx_t_1);
2160  } else
2161  #endif
2162  #if CYTHON_FAST_PYCCALL
2163  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
2164  PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_py_src};
2165  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
2166  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2167  __Pyx_GOTREF(__pyx_t_1);
2168  } else
2169  #endif
2170  {
2171  __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
2172  __Pyx_GOTREF(__pyx_t_3);
2173  __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
2174  __Pyx_INCREF(__pyx_v_py_src);
2175  __Pyx_GIVEREF(__pyx_v_py_src);
2176  PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_py_src);
2177  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
2178  __Pyx_GOTREF(__pyx_t_1);
2179  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2180  }
2181  }
2182  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2183  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2184 
2185  /* "pymodule.pyx":72
2186  * py_dst = cyclib.capsule_agent_to_py(dst, ctx)
2187  * py_dst.init_from_agent(py_src)
2188  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
2189  *
2190  *
2191  */
2192  __pyx_t_4 = PyErr_CheckSignals(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 72, __pyx_L1_error)
2193 
2194  /* "pymodule.pyx":60
2195  *
2196  *
2197  * cdef public void init_from_py_agent "CyclusInitFromPyAgent" (Agent* cpp_src, # <<<<<<<<<<<<<<
2198  * Agent* cpp_dst,
2199  * void* cpp_ctx) except +:
2200  */
2201 
2202  /* function exit code */
2203  goto __pyx_L0;
2204  __pyx_L1_error:;
2205  __Pyx_XDECREF(__pyx_t_1);
2206  __Pyx_XDECREF(__pyx_t_2);
2207  __Pyx_XDECREF(__pyx_t_3);
2208  __Pyx_XDECREF(__pyx_t_5);
2209  __Pyx_AddTraceback("pymodule.init_from_py_agent", __pyx_clineno, __pyx_lineno, __pyx_filename);
2210  __pyx_L0:;
2211  __Pyx_XDECREF(__pyx_v_ctx);
2212  __Pyx_XDECREF(__pyx_v_src);
2213  __Pyx_XDECREF(__pyx_v_dst);
2214  __Pyx_XDECREF(__pyx_v_py_src);
2215  __Pyx_XDECREF(__pyx_v_py_dst);
2216  __Pyx_RefNannyFinishContext();
2217 }
2218 
2219 /* "pymodule.pyx":75
2220  *
2221  *
2222  * cdef public void clear_pyagent_refs "CyclusClearPyAgentRefs" () except +: # <<<<<<<<<<<<<<
2223  * """Clears the cache of agent referencess"""
2224  * cyclib._clear_agent_refs()
2225  */
2226 
2227 void CyclusClearPyAgentRefs(void) {
2228  __Pyx_RefNannyDeclarations
2229  PyObject *__pyx_t_1 = NULL;
2230  PyObject *__pyx_t_2 = NULL;
2231  PyObject *__pyx_t_3 = NULL;
2232  int __pyx_t_4;
2233  __Pyx_RefNannySetupContext("clear_pyagent_refs", 0);
2234 
2235  /* "pymodule.pyx":77
2236  * cdef public void clear_pyagent_refs "CyclusClearPyAgentRefs" () except +:
2237  * """Clears the cache of agent referencess"""
2238  * cyclib._clear_agent_refs() # <<<<<<<<<<<<<<
2239  * PyErr_CheckSignals()
2240  *
2241  */
2242  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
2243  __Pyx_GOTREF(__pyx_t_2);
2244  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_clear_agent_refs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
2245  __Pyx_GOTREF(__pyx_t_3);
2246  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2247  __pyx_t_2 = NULL;
2248  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2249  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2250  if (likely(__pyx_t_2)) {
2251  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2252  __Pyx_INCREF(__pyx_t_2);
2253  __Pyx_INCREF(function);
2254  __Pyx_DECREF_SET(__pyx_t_3, function);
2255  }
2256  }
2257  if (__pyx_t_2) {
2258  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
2259  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2260  } else {
2261  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
2262  }
2263  __Pyx_GOTREF(__pyx_t_1);
2264  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2265  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2266 
2267  /* "pymodule.pyx":78
2268  * """Clears the cache of agent referencess"""
2269  * cyclib._clear_agent_refs()
2270  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
2271  *
2272  *
2273  */
2274  __pyx_t_4 = PyErr_CheckSignals(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
2275 
2276  /* "pymodule.pyx":75
2277  *
2278  *
2279  * cdef public void clear_pyagent_refs "CyclusClearPyAgentRefs" () except +: # <<<<<<<<<<<<<<
2280  * """Clears the cache of agent referencess"""
2281  * cyclib._clear_agent_refs()
2282  */
2283 
2284  /* function exit code */
2285  goto __pyx_L0;
2286  __pyx_L1_error:;
2287  __Pyx_XDECREF(__pyx_t_1);
2288  __Pyx_XDECREF(__pyx_t_2);
2289  __Pyx_XDECREF(__pyx_t_3);
2290  __Pyx_AddTraceback("pymodule.clear_pyagent_refs", __pyx_clineno, __pyx_lineno, __pyx_filename);
2291  __pyx_L0:;
2292  __Pyx_RefNannyFinishContext();
2293 }
2294 
2295 /* "pymodule.pyx":81
2296  *
2297  *
2298  * cdef public void py_del_agent "CyclusPyDelAgent" (int i) except +: # <<<<<<<<<<<<<<
2299  * """Clears the cache of a single agent ref"""
2300  * cyclib._del_agent(i)
2301  */
2302 
2303 void CyclusPyDelAgent(int __pyx_v_i) {
2304  __Pyx_RefNannyDeclarations
2305  PyObject *__pyx_t_1 = NULL;
2306  PyObject *__pyx_t_2 = NULL;
2307  PyObject *__pyx_t_3 = NULL;
2308  PyObject *__pyx_t_4 = NULL;
2309  PyObject *__pyx_t_5 = NULL;
2310  int __pyx_t_6;
2311  __Pyx_RefNannySetupContext("py_del_agent", 0);
2312 
2313  /* "pymodule.pyx":83
2314  * cdef public void py_del_agent "CyclusPyDelAgent" (int i) except +:
2315  * """Clears the cache of a single agent ref"""
2316  * cyclib._del_agent(i) # <<<<<<<<<<<<<<
2317  * PyErr_CheckSignals()
2318  *
2319  */
2320  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
2321  __Pyx_GOTREF(__pyx_t_2);
2322  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_del_agent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
2323  __Pyx_GOTREF(__pyx_t_3);
2324  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2325  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
2326  __Pyx_GOTREF(__pyx_t_2);
2327  __pyx_t_4 = NULL;
2328  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2329  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2330  if (likely(__pyx_t_4)) {
2331  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2332  __Pyx_INCREF(__pyx_t_4);
2333  __Pyx_INCREF(function);
2334  __Pyx_DECREF_SET(__pyx_t_3, function);
2335  }
2336  }
2337  if (!__pyx_t_4) {
2338  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2339  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2340  __Pyx_GOTREF(__pyx_t_1);
2341  } else {
2342  #if CYTHON_FAST_PYCALL
2343  if (PyFunction_Check(__pyx_t_3)) {
2344  PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
2345  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2346  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2347  __Pyx_GOTREF(__pyx_t_1);
2348  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2349  } else
2350  #endif
2351  #if CYTHON_FAST_PYCCALL
2352  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2353  PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
2354  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2355  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2356  __Pyx_GOTREF(__pyx_t_1);
2357  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2358  } else
2359  #endif
2360  {
2361  __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error)
2362  __Pyx_GOTREF(__pyx_t_5);
2363  __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
2364  __Pyx_GIVEREF(__pyx_t_2);
2365  PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
2366  __pyx_t_2 = 0;
2367  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2368  __Pyx_GOTREF(__pyx_t_1);
2369  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2370  }
2371  }
2372  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2373  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2374 
2375  /* "pymodule.pyx":84
2376  * """Clears the cache of a single agent ref"""
2377  * cyclib._del_agent(i)
2378  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
2379  *
2380  *
2381  */
2382  __pyx_t_6 = PyErr_CheckSignals(); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 84, __pyx_L1_error)
2383 
2384  /* "pymodule.pyx":81
2385  *
2386  *
2387  * cdef public void py_del_agent "CyclusPyDelAgent" (int i) except +: # <<<<<<<<<<<<<<
2388  * """Clears the cache of a single agent ref"""
2389  * cyclib._del_agent(i)
2390  */
2391 
2392  /* function exit code */
2393  goto __pyx_L0;
2394  __pyx_L1_error:;
2395  __Pyx_XDECREF(__pyx_t_1);
2396  __Pyx_XDECREF(__pyx_t_2);
2397  __Pyx_XDECREF(__pyx_t_3);
2398  __Pyx_XDECREF(__pyx_t_4);
2399  __Pyx_XDECREF(__pyx_t_5);
2400  __Pyx_AddTraceback("pymodule.py_del_agent", __pyx_clineno, __pyx_lineno, __pyx_filename);
2401  __pyx_L0:;
2402  __Pyx_RefNannyFinishContext();
2403 }
2404 
2405 /* "pymodule.pyx":87
2406  *
2407  *
2408  * cdef public void py_call_listeners "CyclusPyCallListeners" (std_string cpp_tsname, # <<<<<<<<<<<<<<
2409  * Agent* cpp_agent, void* cpp_ctx, int time, hold_any cpp_value) except +:
2410  * """Calls the python time series listeners
2411  */
2412 
2413 void CyclusPyCallListeners(std::string __pyx_v_cpp_tsname, cyclus::Agent *__pyx_v_cpp_agent, void *__pyx_v_cpp_ctx, int __pyx_v_time, boost::spirit::hold_any __pyx_v_cpp_value) {
2414  PyObject *__pyx_v_ctx = NULL;
2415  PyObject *__pyx_v_agent = NULL;
2416  PyObject *__pyx_v_value = NULL;
2417  PyObject *__pyx_v_py_tsname = NULL;
2418  PyObject *__pyx_v_py_agent = NULL;
2419  PyObject *__pyx_v_py_value = NULL;
2420  __Pyx_RefNannyDeclarations
2421  PyObject *__pyx_t_1 = NULL;
2422  PyObject *__pyx_t_2 = NULL;
2423  PyObject *__pyx_t_3 = NULL;
2424  int __pyx_t_4;
2425  PyObject *__pyx_t_5 = NULL;
2426  PyObject *__pyx_t_6 = NULL;
2427  __Pyx_RefNannySetupContext("py_call_listeners", 0);
2428 
2429  /* "pymodule.pyx":91
2430  * """Calls the python time series listeners
2431  * """
2432  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL) # <<<<<<<<<<<<<<
2433  * agent = PyCapsule_New(cpp_agent, <char*> b"agent", NULL)
2434  * value = PyCapsule_New(&cpp_value, <char*> b"value", NULL)
2435  */
2436  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_ctx, ((char *)((char *)"ctx")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
2437  __Pyx_GOTREF(__pyx_t_1);
2438  __pyx_v_ctx = __pyx_t_1;
2439  __pyx_t_1 = 0;
2440 
2441  /* "pymodule.pyx":92
2442  * """
2443  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
2444  * agent = PyCapsule_New(cpp_agent, <char*> b"agent", NULL) # <<<<<<<<<<<<<<
2445  * value = PyCapsule_New(&cpp_value, <char*> b"value", NULL)
2446  * py_tsname = std_string_to_py(cpp_tsname)
2447  */
2448  __pyx_t_1 = PyCapsule_New(__pyx_v_cpp_agent, ((char *)((char *)"agent")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
2449  __Pyx_GOTREF(__pyx_t_1);
2450  __pyx_v_agent = __pyx_t_1;
2451  __pyx_t_1 = 0;
2452 
2453  /* "pymodule.pyx":93
2454  * ctx = PyCapsule_New(cpp_ctx, <char*> b"ctx", NULL)
2455  * agent = PyCapsule_New(cpp_agent, <char*> b"agent", NULL)
2456  * value = PyCapsule_New(&cpp_value, <char*> b"value", NULL) # <<<<<<<<<<<<<<
2457  * py_tsname = std_string_to_py(cpp_tsname)
2458  * py_agent = cyclib.capsule_agent_to_py(agent, ctx)
2459  */
2460  __pyx_t_1 = PyCapsule_New((&__pyx_v_cpp_value), ((char *)((char *)"value")), NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
2461  __Pyx_GOTREF(__pyx_t_1);
2462  __pyx_v_value = __pyx_t_1;
2463  __pyx_t_1 = 0;
2464 
2465  /* "pymodule.pyx":94
2466  * agent = PyCapsule_New(cpp_agent, <char*> b"agent", NULL)
2467  * value = PyCapsule_New(&cpp_value, <char*> b"value", NULL)
2468  * py_tsname = std_string_to_py(cpp_tsname) # <<<<<<<<<<<<<<
2469  * py_agent = cyclib.capsule_agent_to_py(agent, ctx)
2470  * py_value = ts.capsule_any_to_py(value)
2471  */
2472  __pyx_t_1 = __pyx_f_8pymodule_std_string_to_py(__pyx_v_cpp_tsname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
2473  __Pyx_GOTREF(__pyx_t_1);
2474  __pyx_v_py_tsname = __pyx_t_1;
2475  __pyx_t_1 = 0;
2476 
2477  /* "pymodule.pyx":95
2478  * value = PyCapsule_New(&cpp_value, <char*> b"value", NULL)
2479  * py_tsname = std_string_to_py(cpp_tsname)
2480  * py_agent = cyclib.capsule_agent_to_py(agent, ctx) # <<<<<<<<<<<<<<
2481  * py_value = ts.capsule_any_to_py(value)
2482  * cyclib.call_listeners(py_tsname, py_agent, time, py_value)
2483  */
2484  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
2485  __Pyx_GOTREF(__pyx_t_2);
2486  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_capsule_agent_to_py); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
2487  __Pyx_GOTREF(__pyx_t_3);
2488  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2489  __pyx_t_2 = NULL;
2490  __pyx_t_4 = 0;
2491  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2492  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2493  if (likely(__pyx_t_2)) {
2494  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2495  __Pyx_INCREF(__pyx_t_2);
2496  __Pyx_INCREF(function);
2497  __Pyx_DECREF_SET(__pyx_t_3, function);
2498  __pyx_t_4 = 1;
2499  }
2500  }
2501  #if CYTHON_FAST_PYCALL
2502  if (PyFunction_Check(__pyx_t_3)) {
2503  PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_agent, __pyx_v_ctx};
2504  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
2505  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2506  __Pyx_GOTREF(__pyx_t_1);
2507  } else
2508  #endif
2509  #if CYTHON_FAST_PYCCALL
2510  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2511  PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_agent, __pyx_v_ctx};
2512  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
2513  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2514  __Pyx_GOTREF(__pyx_t_1);
2515  } else
2516  #endif
2517  {
2518  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error)
2519  __Pyx_GOTREF(__pyx_t_5);
2520  if (__pyx_t_2) {
2521  __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
2522  }
2523  __Pyx_INCREF(__pyx_v_agent);
2524  __Pyx_GIVEREF(__pyx_v_agent);
2525  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_agent);
2526  __Pyx_INCREF(__pyx_v_ctx);
2527  __Pyx_GIVEREF(__pyx_v_ctx);
2528  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_ctx);
2529  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
2530  __Pyx_GOTREF(__pyx_t_1);
2531  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2532  }
2533  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2534  __pyx_v_py_agent = __pyx_t_1;
2535  __pyx_t_1 = 0;
2536 
2537  /* "pymodule.pyx":96
2538  * py_tsname = std_string_to_py(cpp_tsname)
2539  * py_agent = cyclib.capsule_agent_to_py(agent, ctx)
2540  * py_value = ts.capsule_any_to_py(value) # <<<<<<<<<<<<<<
2541  * cyclib.call_listeners(py_tsname, py_agent, time, py_value)
2542  * PyErr_CheckSignals()
2543  */
2544  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
2545  __Pyx_GOTREF(__pyx_t_3);
2546  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_capsule_any_to_py); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error)
2547  __Pyx_GOTREF(__pyx_t_5);
2548  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2549  __pyx_t_3 = NULL;
2550  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2551  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
2552  if (likely(__pyx_t_3)) {
2553  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2554  __Pyx_INCREF(__pyx_t_3);
2555  __Pyx_INCREF(function);
2556  __Pyx_DECREF_SET(__pyx_t_5, function);
2557  }
2558  }
2559  if (!__pyx_t_3) {
2560  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2561  __Pyx_GOTREF(__pyx_t_1);
2562  } else {
2563  #if CYTHON_FAST_PYCALL
2564  if (PyFunction_Check(__pyx_t_5)) {
2565  PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_value};
2566  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2567  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2568  __Pyx_GOTREF(__pyx_t_1);
2569  } else
2570  #endif
2571  #if CYTHON_FAST_PYCCALL
2572  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
2573  PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_value};
2574  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2575  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2576  __Pyx_GOTREF(__pyx_t_1);
2577  } else
2578  #endif
2579  {
2580  __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
2581  __Pyx_GOTREF(__pyx_t_2);
2582  __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
2583  __Pyx_INCREF(__pyx_v_value);
2584  __Pyx_GIVEREF(__pyx_v_value);
2585  PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_value);
2586  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2587  __Pyx_GOTREF(__pyx_t_1);
2588  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2589  }
2590  }
2591  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2592  __pyx_v_py_value = __pyx_t_1;
2593  __pyx_t_1 = 0;
2594 
2595  /* "pymodule.pyx":97
2596  * py_agent = cyclib.capsule_agent_to_py(agent, ctx)
2597  * py_value = ts.capsule_any_to_py(value)
2598  * cyclib.call_listeners(py_tsname, py_agent, time, py_value) # <<<<<<<<<<<<<<
2599  * PyErr_CheckSignals()
2600  */
2601  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cyclib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error)
2602  __Pyx_GOTREF(__pyx_t_5);
2603  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_call_listeners); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
2604  __Pyx_GOTREF(__pyx_t_2);
2605  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2606  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error)
2607  __Pyx_GOTREF(__pyx_t_5);
2608  __pyx_t_3 = NULL;
2609  __pyx_t_4 = 0;
2610  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
2611  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2612  if (likely(__pyx_t_3)) {
2613  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2614  __Pyx_INCREF(__pyx_t_3);
2615  __Pyx_INCREF(function);
2616  __Pyx_DECREF_SET(__pyx_t_2, function);
2617  __pyx_t_4 = 1;
2618  }
2619  }
2620  #if CYTHON_FAST_PYCALL
2621  if (PyFunction_Check(__pyx_t_2)) {
2622  PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_py_tsname, __pyx_v_py_agent, __pyx_t_5, __pyx_v_py_value};
2623  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
2624  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2625  __Pyx_GOTREF(__pyx_t_1);
2626  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2627  } else
2628  #endif
2629  #if CYTHON_FAST_PYCCALL
2630  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
2631  PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_py_tsname, __pyx_v_py_agent, __pyx_t_5, __pyx_v_py_value};
2632  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
2633  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2634  __Pyx_GOTREF(__pyx_t_1);
2635  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2636  } else
2637  #endif
2638  {
2639  __pyx_t_6 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 97, __pyx_L1_error)
2640  __Pyx_GOTREF(__pyx_t_6);
2641  if (__pyx_t_3) {
2642  __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
2643  }
2644  __Pyx_INCREF(__pyx_v_py_tsname);
2645  __Pyx_GIVEREF(__pyx_v_py_tsname);
2646  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_py_tsname);
2647  __Pyx_INCREF(__pyx_v_py_agent);
2648  __Pyx_GIVEREF(__pyx_v_py_agent);
2649  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_v_py_agent);
2650  __Pyx_GIVEREF(__pyx_t_5);
2651  PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_4, __pyx_t_5);
2652  __Pyx_INCREF(__pyx_v_py_value);
2653  __Pyx_GIVEREF(__pyx_v_py_value);
2654  PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_4, __pyx_v_py_value);
2655  __pyx_t_5 = 0;
2656  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
2657  __Pyx_GOTREF(__pyx_t_1);
2658  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2659  }
2660  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2661  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2662 
2663  /* "pymodule.pyx":98
2664  * py_value = ts.capsule_any_to_py(value)
2665  * cyclib.call_listeners(py_tsname, py_agent, time, py_value)
2666  * PyErr_CheckSignals() # <<<<<<<<<<<<<<
2667  */
2668  __pyx_t_4 = PyErr_CheckSignals(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 98, __pyx_L1_error)
2669 
2670  /* "pymodule.pyx":87
2671  *
2672  *
2673  * cdef public void py_call_listeners "CyclusPyCallListeners" (std_string cpp_tsname, # <<<<<<<<<<<<<<
2674  * Agent* cpp_agent, void* cpp_ctx, int time, hold_any cpp_value) except +:
2675  * """Calls the python time series listeners
2676  */
2677 
2678  /* function exit code */
2679  goto __pyx_L0;
2680  __pyx_L1_error:;
2681  __Pyx_XDECREF(__pyx_t_1);
2682  __Pyx_XDECREF(__pyx_t_2);
2683  __Pyx_XDECREF(__pyx_t_3);
2684  __Pyx_XDECREF(__pyx_t_5);
2685  __Pyx_XDECREF(__pyx_t_6);
2686  __Pyx_AddTraceback("pymodule.py_call_listeners", __pyx_clineno, __pyx_lineno, __pyx_filename);
2687  __pyx_L0:;
2688  __Pyx_XDECREF(__pyx_v_ctx);
2689  __Pyx_XDECREF(__pyx_v_agent);
2690  __Pyx_XDECREF(__pyx_v_value);
2691  __Pyx_XDECREF(__pyx_v_py_tsname);
2692  __Pyx_XDECREF(__pyx_v_py_agent);
2693  __Pyx_XDECREF(__pyx_v_py_value);
2694  __Pyx_RefNannyFinishContext();
2695 }
2696 
2697 /* "string.to_py":31
2698  *
2699  * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
2700  * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2701  * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
2702  * cdef extern from *:
2703  */
2704 
2705 static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) {
2706  PyObject *__pyx_r = NULL;
2707  __Pyx_RefNannyDeclarations
2708  PyObject *__pyx_t_1 = NULL;
2709  __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0);
2710 
2711  /* "string.to_py":32
2712  * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
2713  * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):
2714  * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<<
2715  * cdef extern from *:
2716  * cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t)
2717  */
2718  __Pyx_XDECREF(__pyx_r);
2719  __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error)
2720  __Pyx_GOTREF(__pyx_t_1);
2721  __pyx_r = __pyx_t_1;
2722  __pyx_t_1 = 0;
2723  goto __pyx_L0;
2724 
2725  /* "string.to_py":31
2726  *
2727  * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
2728  * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2729  * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
2730  * cdef extern from *:
2731  */
2732 
2733  /* function exit code */
2734  __pyx_L1_error:;
2735  __Pyx_XDECREF(__pyx_t_1);
2736  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
2737  __pyx_r = 0;
2738  __pyx_L0:;
2739  __Pyx_XGIVEREF(__pyx_r);
2740  __Pyx_RefNannyFinishContext();
2741  return __pyx_r;
2742 }
2743 
2744 /* "string.to_py":37
2745  *
2746  * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
2747  * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2748  * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
2749  * cdef extern from *:
2750  */
2751 
2752 static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) {
2753  PyObject *__pyx_r = NULL;
2754  __Pyx_RefNannyDeclarations
2755  PyObject *__pyx_t_1 = NULL;
2756  __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0);
2757 
2758  /* "string.to_py":38
2759  * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
2760  * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):
2761  * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<<
2762  * cdef extern from *:
2763  * cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t)
2764  */
2765  __Pyx_XDECREF(__pyx_r);
2766  __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 38, __pyx_L1_error)
2767  __Pyx_GOTREF(__pyx_t_1);
2768  __pyx_r = __pyx_t_1;
2769  __pyx_t_1 = 0;
2770  goto __pyx_L0;
2771 
2772  /* "string.to_py":37
2773  *
2774  * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
2775  * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2776  * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
2777  * cdef extern from *:
2778  */
2779 
2780  /* function exit code */
2781  __pyx_L1_error:;
2782  __Pyx_XDECREF(__pyx_t_1);
2783  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
2784  __pyx_r = 0;
2785  __pyx_L0:;
2786  __Pyx_XGIVEREF(__pyx_r);
2787  __Pyx_RefNannyFinishContext();
2788  return __pyx_r;
2789 }
2790 
2791 /* "string.to_py":43
2792  *
2793  * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
2794  * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2795  * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
2796  * cdef extern from *:
2797  */
2798 
2799 static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) {
2800  PyObject *__pyx_r = NULL;
2801  __Pyx_RefNannyDeclarations
2802  PyObject *__pyx_t_1 = NULL;
2803  __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0);
2804 
2805  /* "string.to_py":44
2806  * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
2807  * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):
2808  * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<<
2809  * cdef extern from *:
2810  * cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t)
2811  */
2812  __Pyx_XDECREF(__pyx_r);
2813  __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error)
2814  __Pyx_GOTREF(__pyx_t_1);
2815  __pyx_r = __pyx_t_1;
2816  __pyx_t_1 = 0;
2817  goto __pyx_L0;
2818 
2819  /* "string.to_py":43
2820  *
2821  * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
2822  * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2823  * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
2824  * cdef extern from *:
2825  */
2826 
2827  /* function exit code */
2828  __pyx_L1_error:;
2829  __Pyx_XDECREF(__pyx_t_1);
2830  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
2831  __pyx_r = 0;
2832  __pyx_L0:;
2833  __Pyx_XGIVEREF(__pyx_r);
2834  __Pyx_RefNannyFinishContext();
2835  return __pyx_r;
2836 }
2837 
2838 /* "string.to_py":49
2839  *
2840  * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
2841  * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2842  * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
2843  * cdef extern from *:
2844  */
2845 
2846 static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) {
2847  PyObject *__pyx_r = NULL;
2848  __Pyx_RefNannyDeclarations
2849  PyObject *__pyx_t_1 = NULL;
2850  __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0);
2851 
2852  /* "string.to_py":50
2853  * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
2854  * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):
2855  * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<<
2856  * cdef extern from *:
2857  * cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t)
2858  */
2859  __Pyx_XDECREF(__pyx_r);
2860  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error)
2861  __Pyx_GOTREF(__pyx_t_1);
2862  __pyx_r = __pyx_t_1;
2863  __pyx_t_1 = 0;
2864  goto __pyx_L0;
2865 
2866  /* "string.to_py":49
2867  *
2868  * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
2869  * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2870  * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
2871  * cdef extern from *:
2872  */
2873 
2874  /* function exit code */
2875  __pyx_L1_error:;
2876  __Pyx_XDECREF(__pyx_t_1);
2877  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
2878  __pyx_r = 0;
2879  __pyx_L0:;
2880  __Pyx_XGIVEREF(__pyx_r);
2881  __Pyx_RefNannyFinishContext();
2882  return __pyx_r;
2883 }
2884 
2885 /* "string.to_py":55
2886  *
2887  * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
2888  * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2889  * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
2890  *
2891  */
2892 
2893 static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) {
2894  PyObject *__pyx_r = NULL;
2895  __Pyx_RefNannyDeclarations
2896  PyObject *__pyx_t_1 = NULL;
2897  __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0);
2898 
2899  /* "string.to_py":56
2900  * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
2901  * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):
2902  * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<<
2903  *
2904  */
2905  __Pyx_XDECREF(__pyx_r);
2906  __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error)
2907  __Pyx_GOTREF(__pyx_t_1);
2908  __pyx_r = __pyx_t_1;
2909  __pyx_t_1 = 0;
2910  goto __pyx_L0;
2911 
2912  /* "string.to_py":55
2913  *
2914  * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
2915  * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
2916  * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
2917  *
2918  */
2919 
2920  /* function exit code */
2921  __pyx_L1_error:;
2922  __Pyx_XDECREF(__pyx_t_1);
2923  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
2924  __pyx_r = 0;
2925  __pyx_L0:;
2926  __Pyx_XGIVEREF(__pyx_r);
2927  __Pyx_RefNannyFinishContext();
2928  return __pyx_r;
2929 }
2930 
2931 static PyMethodDef __pyx_methods[] = {
2932  {0, 0, 0, 0}
2933 };
2934 
2935 #if PY_MAJOR_VERSION >= 3
2936 static struct PyModuleDef __pyx_moduledef = {
2937  #if PY_VERSION_HEX < 0x03020000
2938  { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
2939  #else
2940  PyModuleDef_HEAD_INIT,
2941  #endif
2942  "pymodule",
2943  __pyx_k_Cyclus_Python_module_loading_too, /* m_doc */
2944  -1, /* m_size */
2945  __pyx_methods /* m_methods */,
2946  NULL, /* m_reload */
2947  NULL, /* m_traverse */
2948  NULL, /* m_clear */
2949  NULL /* m_free */
2950 };
2951 #endif
2952 
2953 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2954  {&__pyx_n_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 1},
2955  {&__pyx_n_u_Facility, __pyx_k_Facility, sizeof(__pyx_k_Facility), 0, 1, 0, 1},
2956  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
2957  {&__pyx_n_u_Inst, __pyx_k_Inst, sizeof(__pyx_k_Inst), 0, 1, 0, 1},
2958  {&__pyx_n_u_Region, __pyx_k_Region, sizeof(__pyx_k_Region), 0, 1, 0, 1},
2959  {&__pyx_n_s_call_listeners, __pyx_k_call_listeners, sizeof(__pyx_k_call_listeners), 0, 0, 1, 1},
2960  {&__pyx_n_s_capsule_agent_to_py, __pyx_k_capsule_agent_to_py, sizeof(__pyx_k_capsule_agent_to_py), 0, 0, 1, 1},
2961  {&__pyx_n_s_capsule_any_to_py, __pyx_k_capsule_any_to_py, sizeof(__pyx_k_capsule_any_to_py), 0, 0, 1, 1},
2962  {&__pyx_n_s_clear_agent_refs, __pyx_k_clear_agent_refs, sizeof(__pyx_k_clear_agent_refs), 0, 0, 1, 1},
2963  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2964  {&__pyx_n_s_cyclib, __pyx_k_cyclib, sizeof(__pyx_k_cyclib), 0, 0, 1, 1},
2965  {&__pyx_n_s_cyclus_lib, __pyx_k_cyclus_lib, sizeof(__pyx_k_cyclus_lib), 0, 0, 1, 1},
2966  {&__pyx_n_s_cyclus_typesystem, __pyx_k_cyclus_typesystem, sizeof(__pyx_k_cyclus_typesystem), 0, 0, 1, 1},
2967  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
2968  {&__pyx_n_s_del_agent, __pyx_k_del_agent, sizeof(__pyx_k_del_agent), 0, 0, 1, 1},
2969  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
2970  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
2971  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2972  {&__pyx_n_s_import_module, __pyx_k_import_module, sizeof(__pyx_k_import_module), 0, 0, 1, 1},
2973  {&__pyx_n_s_importlib, __pyx_k_importlib, sizeof(__pyx_k_importlib), 0, 0, 1, 1},
2974  {&__pyx_n_s_init_from_agent, __pyx_k_init_from_agent, sizeof(__pyx_k_init_from_agent), 0, 0, 1, 1},
2975  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2976  {&__pyx_n_s_make_py_agent, __pyx_k_make_py_agent, sizeof(__pyx_k_make_py_agent), 0, 0, 1, 1},
2977  {&__pyx_kp_u_py, __pyx_k_py, sizeof(__pyx_k_py), 0, 1, 0, 0},
2978  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2979  {&__pyx_n_s_ts, __pyx_k_ts, sizeof(__pyx_k_ts), 0, 0, 1, 1},
2980  {0, 0, 0, 0, 0, 0, 0}
2981 };
2982 static int __Pyx_InitCachedBuiltins(void) {
2983  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 31, __pyx_L1_error)
2984  return 0;
2985  __pyx_L1_error:;
2986  return -1;
2987 }
2988 
2989 static int __Pyx_InitCachedConstants(void) {
2990  __Pyx_RefNannyDeclarations
2991  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2992  __Pyx_RefNannyFinishContext();
2993  return 0;
2994 }
2995 
2996 static int __Pyx_InitGlobals(void) {
2997  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2998  return 0;
2999  __pyx_L1_error:;
3000  return -1;
3001 }
3002 
3003 #if PY_MAJOR_VERSION < 3
3004 PyMODINIT_FUNC initpymodule(void); /*proto*/
3005 PyMODINIT_FUNC initpymodule(void)
3006 #else
3007 PyMODINIT_FUNC PyInit_pymodule(void); /*proto*/
3008 PyMODINIT_FUNC PyInit_pymodule(void)
3009 #endif
3010 {
3011  PyObject *__pyx_t_1 = NULL;
3012  PyObject *__pyx_t_2 = NULL;
3013  __Pyx_RefNannyDeclarations
3014  #if CYTHON_REFNANNY
3015  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3016  if (!__Pyx_RefNanny) {
3017  PyErr_Clear();
3018  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3019  if (!__Pyx_RefNanny)
3020  Py_FatalError("failed to import 'refnanny' module");
3021  }
3022  #endif
3023  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_pymodule(void)", 0);
3024  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3025  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
3026  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
3027  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
3028  #ifdef __Pyx_CyFunction_USED
3029  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3030  #endif
3031  #ifdef __Pyx_FusedFunction_USED
3032  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3033  #endif
3034  #ifdef __Pyx_Coroutine_USED
3035  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3036  #endif
3037  #ifdef __Pyx_Generator_USED
3038  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3039  #endif
3040  #ifdef __Pyx_StopAsyncIteration_USED
3041  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3042  #endif
3043  /*--- Library function declarations ---*/
3044  /*--- Threads initialization code ---*/
3045  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3046  #ifdef WITH_THREAD /* Python build with threading support? */
3047  PyEval_InitThreads();
3048  #endif
3049  #endif
3050  /*--- Module creation code ---*/
3051  #if PY_MAJOR_VERSION < 3
3052  __pyx_m = Py_InitModule4("pymodule", __pyx_methods, __pyx_k_Cyclus_Python_module_loading_too, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3053  #else
3054  __pyx_m = PyModule_Create(&__pyx_moduledef);
3055  #endif
3056  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3057  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3058  Py_INCREF(__pyx_d);
3059  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3060  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3061  #if CYTHON_COMPILING_IN_PYPY
3062  Py_INCREF(__pyx_b);
3063  #endif
3064  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3065  /*--- Initialize various global constants etc. ---*/
3066  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3067  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3068  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3069  #endif
3070  if (__pyx_module_is_main_pymodule) {
3071  if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3072  }
3073  #if PY_MAJOR_VERSION >= 3
3074  {
3075  PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3076  if (!PyDict_GetItemString(modules, "pymodule")) {
3077  if (unlikely(PyDict_SetItemString(modules, "pymodule", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3078  }
3079  }
3080  #endif
3081  /*--- Builtin init code ---*/
3082  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3083  /*--- Constants init code ---*/
3084  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3085  /*--- Global init code ---*/
3086  /*--- Variable export code ---*/
3087  /*--- Function export code ---*/
3088  if (__Pyx_ExportFunction("str_py_to_cpp", (void (*)(void))__pyx_f_8pymodule_str_py_to_cpp, "std::string (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3089  if (__Pyx_ExportFunction("std_string_to_py", (void (*)(void))__pyx_f_8pymodule_std_string_to_py, "PyObject *(std::string)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3090  if (__Pyx_ExportFunction("py_find_module", (void (*)(void))CyclusPyFindModule, "std::string (std::string)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3091  if (__Pyx_ExportFunction("make_py_agent", (void (*)(void))CyclusMakePyAgent, "cyclus::Agent *(std::string, std::string, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3092  if (__Pyx_ExportFunction("init_from_py_agent", (void (*)(void))CyclusInitFromPyAgent, "void (cyclus::Agent *, cyclus::Agent *, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3093  if (__Pyx_ExportFunction("clear_pyagent_refs", (void (*)(void))CyclusClearPyAgentRefs, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3094  if (__Pyx_ExportFunction("py_del_agent", (void (*)(void))CyclusPyDelAgent, "void (int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3095  if (__Pyx_ExportFunction("py_call_listeners", (void (*)(void))CyclusPyCallListeners, "void (std::string, cyclus::Agent *, void *, int, boost::spirit::hold_any)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3096  /*--- Type init code ---*/
3097  /*--- Type import code ---*/
3098  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
3099  #if CYTHON_COMPILING_IN_PYPY
3100  sizeof(PyTypeObject),
3101  #else
3102  sizeof(PyHeapTypeObject),
3103  #endif
3104  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error)
3105  /*--- Variable import code ---*/
3106  /*--- Function import code ---*/
3107  /*--- Execution code ---*/
3108  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3109  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3110  #endif
3111 
3112  /* "pymodule.pyx":8
3113  * from cpython.pycapsule cimport PyCapsule_New, PyCapsule_GetPointer
3114  *
3115  * from importlib import import_module # <<<<<<<<<<<<<<
3116  *
3117  * import cyclus.lib as cyclib
3118  */
3119  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
3120  __Pyx_GOTREF(__pyx_t_1);
3121  __Pyx_INCREF(__pyx_n_s_import_module);
3122  __Pyx_GIVEREF(__pyx_n_s_import_module);
3123  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_import_module);
3124  __pyx_t_2 = __Pyx_Import(__pyx_n_s_importlib, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
3125  __Pyx_GOTREF(__pyx_t_2);
3126  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3127  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_module); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
3128  __Pyx_GOTREF(__pyx_t_1);
3129  if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_module, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
3130  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3131  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3132 
3133  /* "pymodule.pyx":10
3134  * from importlib import import_module
3135  *
3136  * import cyclus.lib as cyclib # <<<<<<<<<<<<<<
3137  * import cyclus.typesystem as ts
3138  *
3139  */
3140  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
3141  __Pyx_GOTREF(__pyx_t_2);
3142  __Pyx_INCREF(__pyx_n_s_);
3143  __Pyx_GIVEREF(__pyx_n_s_);
3144  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_);
3145  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cyclus_lib, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
3146  __Pyx_GOTREF(__pyx_t_1);
3147  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3148  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cyclib, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
3149  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3150 
3151  /* "pymodule.pyx":11
3152  *
3153  * import cyclus.lib as cyclib
3154  * import cyclus.typesystem as ts # <<<<<<<<<<<<<<
3155  *
3156  * cdef object std_string_to_py(std_string x):
3157  */
3158  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
3159  __Pyx_GOTREF(__pyx_t_1);
3160  __Pyx_INCREF(__pyx_n_s_);
3161  __Pyx_GIVEREF(__pyx_n_s_);
3162  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_);
3163  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cyclus_typesystem, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
3164  __Pyx_GOTREF(__pyx_t_2);
3165  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3166  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ts, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
3167  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3168 
3169  /* "pymodule.pyx":1
3170  * """Cyclus Python module loading tools.""" # <<<<<<<<<<<<<<
3171  * from __future__ import print_function, unicode_literals
3172  * from libcpp.cast cimport reinterpret_cast, dynamic_cast
3173  */
3174  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
3175  __Pyx_GOTREF(__pyx_t_2);
3176  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3177  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3178 
3179  /* "string.to_py":55
3180  *
3181  * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
3182  * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<<
3183  * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
3184  *
3185  */
3186 
3187  /*--- Wrapped vars code ---*/
3188 
3189  goto __pyx_L0;
3190  __pyx_L1_error:;
3191  __Pyx_XDECREF(__pyx_t_1);
3192  __Pyx_XDECREF(__pyx_t_2);
3193  if (__pyx_m) {
3194  if (__pyx_d) {
3195  __Pyx_AddTraceback("init pymodule", 0, __pyx_lineno, __pyx_filename);
3196  }
3197  Py_DECREF(__pyx_m); __pyx_m = 0;
3198  } else if (!PyErr_Occurred()) {
3199  PyErr_SetString(PyExc_ImportError, "init pymodule");
3200  }
3201  __pyx_L0:;
3202  __Pyx_RefNannyFinishContext();
3203  #if PY_MAJOR_VERSION < 3
3204  return;
3205  #else
3206  return __pyx_m;
3207  #endif
3208 }
3209 
3210 /* --- Runtime support code --- */
3211 /* Refnanny */
3212 #if CYTHON_REFNANNY
3213 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3214  PyObject *m = NULL, *p = NULL;
3215  void *r = NULL;
3216  m = PyImport_ImportModule((char *)modname);
3217  if (!m) goto end;
3218  p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
3219  if (!p) goto end;
3220  r = PyLong_AsVoidPtr(p);
3221 end:
3222  Py_XDECREF(p);
3223  Py_XDECREF(m);
3224  return (__Pyx_RefNannyAPIStruct *)r;
3225 }
3226 #endif
3227 
3228 /* GetBuiltinName */
3229 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3230  PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3231  if (unlikely(!result)) {
3232  PyErr_Format(PyExc_NameError,
3233 #if PY_MAJOR_VERSION >= 3
3234  "name '%U' is not defined", name);
3235 #else
3236  "name '%.200s' is not defined", PyString_AS_STRING(name));
3237 #endif
3238  }
3239  return result;
3240 }
3241 
3242 /* PyCFunctionFastCall */
3243 #if CYTHON_FAST_PYCCALL
3244 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
3245  PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
3246  PyCFunction meth = PyCFunction_GET_FUNCTION(func);
3247  PyObject *self = PyCFunction_GET_SELF(func);
3248  int flags = PyCFunction_GET_FLAGS(func);
3249  assert(PyCFunction_Check(func));
3250  assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
3251  assert(nargs >= 0);
3252  assert(nargs == 0 || args != NULL);
3253  /* _PyCFunction_FastCallDict() must not be called with an exception set,
3254  because it may clear it (directly or indirectly) and so the
3255  caller loses its exception */
3256  assert(!PyErr_Occurred());
3257  if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
3258  return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
3259  } else {
3260  return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
3261  }
3262 }
3263 #endif
3264 
3265 /* PyFunctionFastCall */
3266 #if CYTHON_FAST_PYCALL
3267 #include "frameobject.h"
3268 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
3269  PyObject *globals) {
3270  PyFrameObject *f;
3271  PyThreadState *tstate = PyThreadState_GET();
3272  PyObject **fastlocals;
3273  Py_ssize_t i;
3274  PyObject *result;
3275  assert(globals != NULL);
3276  /* XXX Perhaps we should create a specialized
3277  PyFrame_New() that doesn't take locals, but does
3278  take builtins without sanity checking them.
3279  */
3280  assert(tstate != NULL);
3281  f = PyFrame_New(tstate, co, globals, NULL);
3282  if (f == NULL) {
3283  return NULL;
3284  }
3285  fastlocals = f->f_localsplus;
3286  for (i = 0; i < na; i++) {
3287  Py_INCREF(*args);
3288  fastlocals[i] = *args++;
3289  }
3290  result = PyEval_EvalFrameEx(f,0);
3291  ++tstate->recursion_depth;
3292  Py_DECREF(f);
3293  --tstate->recursion_depth;
3294  return result;
3295 }
3296 #if 1 || PY_VERSION_HEX < 0x030600B1
3297 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
3298  PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
3299  PyObject *globals = PyFunction_GET_GLOBALS(func);
3300  PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
3301  PyObject *closure;
3302 #if PY_MAJOR_VERSION >= 3
3303  PyObject *kwdefs;
3304 #endif
3305  PyObject *kwtuple, **k;
3306  PyObject **d;
3307  Py_ssize_t nd;
3308  Py_ssize_t nk;
3309  PyObject *result;
3310  assert(kwargs == NULL || PyDict_Check(kwargs));
3311  nk = kwargs ? PyDict_Size(kwargs) : 0;
3312  if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
3313  return NULL;
3314  }
3315  if (
3316 #if PY_MAJOR_VERSION >= 3
3317  co->co_kwonlyargcount == 0 &&
3318 #endif
3319  likely(kwargs == NULL || nk == 0) &&
3320  co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
3321  if (argdefs == NULL && co->co_argcount == nargs) {
3322  result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
3323  goto done;
3324  }
3325  else if (nargs == 0 && argdefs != NULL
3326  && co->co_argcount == Py_SIZE(argdefs)) {
3327  /* function called with no arguments, but all parameters have
3328  a default value: use default values as arguments .*/
3329  args = &PyTuple_GET_ITEM(argdefs, 0);
3330  result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
3331  goto done;
3332  }
3333  }
3334  if (kwargs != NULL) {
3335  Py_ssize_t pos, i;
3336  kwtuple = PyTuple_New(2 * nk);
3337  if (kwtuple == NULL) {
3338  result = NULL;
3339  goto done;
3340  }
3341  k = &PyTuple_GET_ITEM(kwtuple, 0);
3342  pos = i = 0;
3343  while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
3344  Py_INCREF(k[i]);
3345  Py_INCREF(k[i+1]);
3346  i += 2;
3347  }
3348  nk = i / 2;
3349  }
3350  else {
3351  kwtuple = NULL;
3352  k = NULL;
3353  }
3354  closure = PyFunction_GET_CLOSURE(func);
3355 #if PY_MAJOR_VERSION >= 3
3356  kwdefs = PyFunction_GET_KW_DEFAULTS(func);
3357 #endif
3358  if (argdefs != NULL) {
3359  d = &PyTuple_GET_ITEM(argdefs, 0);
3360  nd = Py_SIZE(argdefs);
3361  }
3362  else {
3363  d = NULL;
3364  nd = 0;
3365  }
3366 #if PY_MAJOR_VERSION >= 3
3367  result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
3368  args, nargs,
3369  k, (int)nk,
3370  d, (int)nd, kwdefs, closure);
3371 #else
3372  result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
3373  args, nargs,
3374  k, (int)nk,
3375  d, (int)nd, closure);
3376 #endif
3377  Py_XDECREF(kwtuple);
3378 done:
3379  Py_LeaveRecursiveCall();
3380  return result;
3381 }
3382 #endif
3383 #endif
3384 
3385 /* PyObjectCall */
3386 #if CYTHON_COMPILING_IN_CPYTHON
3387 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3388  PyObject *result;
3389  ternaryfunc call = func->ob_type->tp_call;
3390  if (unlikely(!call))
3391  return PyObject_Call(func, arg, kw);
3392  if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3393  return NULL;
3394  result = (*call)(func, arg, kw);
3395  Py_LeaveRecursiveCall();
3396  if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3397  PyErr_SetString(
3398  PyExc_SystemError,
3399  "NULL result without error in PyObject_Call");
3400  }
3401  return result;
3402 }
3403 #endif
3404 
3405 /* PyObjectCallMethO */
3406 #if CYTHON_COMPILING_IN_CPYTHON
3407 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
3408  PyObject *self, *result;
3409  PyCFunction cfunc;
3410  cfunc = PyCFunction_GET_FUNCTION(func);
3411  self = PyCFunction_GET_SELF(func);
3412  if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3413  return NULL;
3414  result = cfunc(self, arg);
3415  Py_LeaveRecursiveCall();
3416  if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3417  PyErr_SetString(
3418  PyExc_SystemError,
3419  "NULL result without error in PyObject_Call");
3420  }
3421  return result;
3422 }
3423 #endif
3424 
3425 /* PyObjectCallOneArg */
3426 #if CYTHON_COMPILING_IN_CPYTHON
3427 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3428  PyObject *result;
3429  PyObject *args = PyTuple_New(1);
3430  if (unlikely(!args)) return NULL;
3431  Py_INCREF(arg);
3432  PyTuple_SET_ITEM(args, 0, arg);
3433  result = __Pyx_PyObject_Call(func, args, NULL);
3434  Py_DECREF(args);
3435  return result;
3436 }
3437 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3438 #if CYTHON_FAST_PYCALL
3439  if (PyFunction_Check(func)) {
3440  return __Pyx_PyFunction_FastCall(func, &arg, 1);
3441  }
3442 #endif
3443  if (likely(PyCFunction_Check(func))) {
3444  if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
3445  return __Pyx_PyObject_CallMethO(func, arg);
3446 #if CYTHON_FAST_PYCCALL
3447  } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
3448  return __Pyx_PyCFunction_FastCall(func, &arg, 1);
3449 #endif
3450  }
3451  }
3452  return __Pyx__PyObject_CallOneArg(func, arg);
3453 }
3454 #else
3455 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3456  PyObject *result;
3457  PyObject *args = PyTuple_Pack(1, arg);
3458  if (unlikely(!args)) return NULL;
3459  result = __Pyx_PyObject_Call(func, args, NULL);
3460  Py_DECREF(args);
3461  return result;
3462 }
3463 #endif
3464 
3465 /* PyObjectCallNoArg */
3466 #if CYTHON_COMPILING_IN_CPYTHON
3467 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
3468 #if CYTHON_FAST_PYCALL
3469  if (PyFunction_Check(func)) {
3470  return __Pyx_PyFunction_FastCall(func, NULL, 0);
3471  }
3472 #endif
3473 #ifdef __Pyx_CyFunction_USED
3474  if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
3475 #else
3476  if (likely(PyCFunction_Check(func))) {
3477 #endif
3478  if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
3479  return __Pyx_PyObject_CallMethO(func, NULL);
3480  }
3481  }
3482  return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
3483 }
3484 #endif
3485 
3486 /* PyErrFetchRestore */
3487  #if CYTHON_FAST_THREAD_STATE
3488 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3489  PyObject *tmp_type, *tmp_value, *tmp_tb;
3490  tmp_type = tstate->curexc_type;
3491  tmp_value = tstate->curexc_value;
3492  tmp_tb = tstate->curexc_traceback;
3493  tstate->curexc_type = type;
3494  tstate->curexc_value = value;
3495  tstate->curexc_traceback = tb;
3496  Py_XDECREF(tmp_type);
3497  Py_XDECREF(tmp_value);
3498  Py_XDECREF(tmp_tb);
3499 }
3500 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3501  *type = tstate->curexc_type;
3502  *value = tstate->curexc_value;
3503  *tb = tstate->curexc_traceback;
3504  tstate->curexc_type = 0;
3505  tstate->curexc_value = 0;
3506  tstate->curexc_traceback = 0;
3507 }
3508 #endif
3509 
3510 /* WriteUnraisableException */
3511  static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
3512  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
3513  int full_traceback, CYTHON_UNUSED int nogil) {
3514  PyObject *old_exc, *old_val, *old_tb;
3515  PyObject *ctx;
3516  __Pyx_PyThreadState_declare
3517 #ifdef WITH_THREAD
3518  PyGILState_STATE state;
3519  if (nogil)
3520  state = PyGILState_Ensure();
3521 #ifdef _MSC_VER
3522  else state = (PyGILState_STATE)-1;
3523 #endif
3524 #endif
3525  __Pyx_PyThreadState_assign
3526  __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
3527  if (full_traceback) {
3528  Py_XINCREF(old_exc);
3529  Py_XINCREF(old_val);
3530  Py_XINCREF(old_tb);
3531  __Pyx_ErrRestore(old_exc, old_val, old_tb);
3532  PyErr_PrintEx(1);
3533  }
3534  #if PY_MAJOR_VERSION < 3
3535  ctx = PyString_FromString(name);
3536  #else
3537  ctx = PyUnicode_FromString(name);
3538  #endif
3539  __Pyx_ErrRestore(old_exc, old_val, old_tb);
3540  if (!ctx) {
3541  PyErr_WriteUnraisable(Py_None);
3542  } else {
3543  PyErr_WriteUnraisable(ctx);
3544  Py_DECREF(ctx);
3545  }
3546 #ifdef WITH_THREAD
3547  if (nogil)
3548  PyGILState_Release(state);
3549 #endif
3550 }
3551 
3552 /* GetModuleGlobalName */
3553  static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
3554  PyObject *result;
3555 #if !CYTHON_AVOID_BORROWED_REFS
3556  result = PyDict_GetItem(__pyx_d, name);
3557  if (likely(result)) {
3558  Py_INCREF(result);
3559  } else {
3560 #else
3561  result = PyObject_GetItem(__pyx_d, name);
3562  if (!result) {
3563  PyErr_Clear();
3564 #endif
3565  result = __Pyx_GetBuiltinName(name);
3566  }
3567  return result;
3568 }
3569 
3570 /* SaveResetException */
3571  #if CYTHON_FAST_THREAD_STATE
3572 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3573  *type = tstate->exc_type;
3574  *value = tstate->exc_value;
3575  *tb = tstate->exc_traceback;
3576  Py_XINCREF(*type);
3577  Py_XINCREF(*value);
3578  Py_XINCREF(*tb);
3579 }
3580 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3581  PyObject *tmp_type, *tmp_value, *tmp_tb;
3582  tmp_type = tstate->exc_type;
3583  tmp_value = tstate->exc_value;
3584  tmp_tb = tstate->exc_traceback;
3585  tstate->exc_type = type;
3586  tstate->exc_value = value;
3587  tstate->exc_traceback = tb;
3588  Py_XDECREF(tmp_type);
3589  Py_XDECREF(tmp_value);
3590  Py_XDECREF(tmp_tb);
3591 }
3592 #endif
3593 
3594 /* PyErrExceptionMatches */
3595  #if CYTHON_FAST_THREAD_STATE
3596 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3597  PyObject *exc_type = tstate->curexc_type;
3598  if (exc_type == err) return 1;
3599  if (unlikely(!exc_type)) return 0;
3600  return PyErr_GivenExceptionMatches(exc_type, err);
3601 }
3602 #endif
3603 
3604 /* GetException */
3605  #if CYTHON_FAST_THREAD_STATE
3606 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3607 #else
3608 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
3609 #endif
3610  PyObject *local_type, *local_value, *local_tb;
3611 #if CYTHON_FAST_THREAD_STATE
3612  PyObject *tmp_type, *tmp_value, *tmp_tb;
3613  local_type = tstate->curexc_type;
3614  local_value = tstate->curexc_value;
3615  local_tb = tstate->curexc_traceback;
3616  tstate->curexc_type = 0;
3617  tstate->curexc_value = 0;
3618  tstate->curexc_traceback = 0;
3619 #else
3620  PyErr_Fetch(&local_type, &local_value, &local_tb);
3621 #endif
3622  PyErr_NormalizeException(&local_type, &local_value, &local_tb);
3623 #if CYTHON_FAST_THREAD_STATE
3624  if (unlikely(tstate->curexc_type))
3625 #else
3626  if (unlikely(PyErr_Occurred()))
3627 #endif
3628  goto bad;
3629  #if PY_MAJOR_VERSION >= 3
3630  if (local_tb) {
3631  if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
3632  goto bad;
3633  }
3634  #endif
3635  Py_XINCREF(local_tb);
3636  Py_XINCREF(local_type);
3637  Py_XINCREF(local_value);
3638  *type = local_type;
3639  *value = local_value;
3640  *tb = local_tb;
3641 #if CYTHON_FAST_THREAD_STATE
3642  tmp_type = tstate->exc_type;
3643  tmp_value = tstate->exc_value;
3644  tmp_tb = tstate->exc_traceback;
3645  tstate->exc_type = local_type;
3646  tstate->exc_value = local_value;
3647  tstate->exc_traceback = local_tb;
3648  Py_XDECREF(tmp_type);
3649  Py_XDECREF(tmp_value);
3650  Py_XDECREF(tmp_tb);
3651 #else
3652  PyErr_SetExcInfo(local_type, local_value, local_tb);
3653 #endif
3654  return 0;
3655 bad:
3656  *type = 0;
3657  *value = 0;
3658  *tb = 0;
3659  Py_XDECREF(local_type);
3660  Py_XDECREF(local_value);
3661  Py_XDECREF(local_tb);
3662  return -1;
3663 }
3664 
3665 /* RaiseTooManyValuesToUnpack */
3666  static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
3667  PyErr_Format(PyExc_ValueError,
3668  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
3669 }
3670 
3671 /* RaiseNeedMoreValuesToUnpack */
3672  static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
3673  PyErr_Format(PyExc_ValueError,
3674  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
3675  index, (index == 1) ? "" : "s");
3676 }
3677 
3678 /* IterFinish */
3679  static CYTHON_INLINE int __Pyx_IterFinish(void) {
3680 #if CYTHON_FAST_THREAD_STATE
3681  PyThreadState *tstate = PyThreadState_GET();
3682  PyObject* exc_type = tstate->curexc_type;
3683  if (unlikely(exc_type)) {
3684  if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
3685  PyObject *exc_value, *exc_tb;
3686  exc_value = tstate->curexc_value;
3687  exc_tb = tstate->curexc_traceback;
3688  tstate->curexc_type = 0;
3689  tstate->curexc_value = 0;
3690  tstate->curexc_traceback = 0;
3691  Py_DECREF(exc_type);
3692  Py_XDECREF(exc_value);
3693  Py_XDECREF(exc_tb);
3694  return 0;
3695  } else {
3696  return -1;
3697  }
3698  }
3699  return 0;
3700 #else
3701  if (unlikely(PyErr_Occurred())) {
3702  if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
3703  PyErr_Clear();
3704  return 0;
3705  } else {
3706  return -1;
3707  }
3708  }
3709  return 0;
3710 #endif
3711 }
3712 
3713 /* UnpackItemEndCheck */
3714  static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
3715  if (unlikely(retval)) {
3716  Py_DECREF(retval);
3717  __Pyx_RaiseTooManyValuesError(expected);
3718  return -1;
3719  } else {
3720  return __Pyx_IterFinish();
3721  }
3722  return 0;
3723 }
3724 
3725 /* BytesEquals */
3726  static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
3727 #if CYTHON_COMPILING_IN_PYPY
3728  return PyObject_RichCompareBool(s1, s2, equals);
3729 #else
3730  if (s1 == s2) {
3731  return (equals == Py_EQ);
3732  } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
3733  const char *ps1, *ps2;
3734  Py_ssize_t length = PyBytes_GET_SIZE(s1);
3735  if (length != PyBytes_GET_SIZE(s2))
3736  return (equals == Py_NE);
3737  ps1 = PyBytes_AS_STRING(s1);
3738  ps2 = PyBytes_AS_STRING(s2);
3739  if (ps1[0] != ps2[0]) {
3740  return (equals == Py_NE);
3741  } else if (length == 1) {
3742  return (equals == Py_EQ);
3743  } else {
3744  int result;
3745 #if CYTHON_USE_UNICODE_INTERNALS
3746  Py_hash_t hash1, hash2;
3747  hash1 = ((PyBytesObject*)s1)->ob_shash;
3748  hash2 = ((PyBytesObject*)s2)->ob_shash;
3749  if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
3750  return (equals == Py_NE);
3751  }
3752 #endif
3753  result = memcmp(ps1, ps2, (size_t)length);
3754  return (equals == Py_EQ) ? (result == 0) : (result != 0);
3755  }
3756  } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
3757  return (equals == Py_NE);
3758  } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
3759  return (equals == Py_NE);
3760  } else {
3761  int result;
3762  PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
3763  if (!py_result)
3764  return -1;
3765  result = __Pyx_PyObject_IsTrue(py_result);
3766  Py_DECREF(py_result);
3767  return result;
3768  }
3769 #endif
3770 }
3771 
3772 /* UnicodeEquals */
3773  static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
3774 #if CYTHON_COMPILING_IN_PYPY
3775  return PyObject_RichCompareBool(s1, s2, equals);
3776 #else
3777 #if PY_MAJOR_VERSION < 3
3778  PyObject* owned_ref = NULL;
3779 #endif
3780  int s1_is_unicode, s2_is_unicode;
3781  if (s1 == s2) {
3782  goto return_eq;
3783  }
3784  s1_is_unicode = PyUnicode_CheckExact(s1);
3785  s2_is_unicode = PyUnicode_CheckExact(s2);
3786 #if PY_MAJOR_VERSION < 3
3787  if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
3788  owned_ref = PyUnicode_FromObject(s2);
3789  if (unlikely(!owned_ref))
3790  return -1;
3791  s2 = owned_ref;
3792  s2_is_unicode = 1;
3793  } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
3794  owned_ref = PyUnicode_FromObject(s1);
3795  if (unlikely(!owned_ref))
3796  return -1;
3797  s1 = owned_ref;
3798  s1_is_unicode = 1;
3799  } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
3800  return __Pyx_PyBytes_Equals(s1, s2, equals);
3801  }
3802 #endif
3803  if (s1_is_unicode & s2_is_unicode) {
3804  Py_ssize_t length;
3805  int kind;
3806  void *data1, *data2;
3807  if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
3808  return -1;
3809  length = __Pyx_PyUnicode_GET_LENGTH(s1);
3810  if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
3811  goto return_ne;
3812  }
3813 #if CYTHON_USE_UNICODE_INTERNALS
3814  {
3815  Py_hash_t hash1, hash2;
3816  #if CYTHON_PEP393_ENABLED
3817  hash1 = ((PyASCIIObject*)s1)->hash;
3818  hash2 = ((PyASCIIObject*)s2)->hash;
3819  #else
3820  hash1 = ((PyUnicodeObject*)s1)->hash;
3821  hash2 = ((PyUnicodeObject*)s2)->hash;
3822  #endif
3823  if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
3824  goto return_ne;
3825  }
3826  }
3827 #endif
3828  kind = __Pyx_PyUnicode_KIND(s1);
3829  if (kind != __Pyx_PyUnicode_KIND(s2)) {
3830  goto return_ne;
3831  }
3832  data1 = __Pyx_PyUnicode_DATA(s1);
3833  data2 = __Pyx_PyUnicode_DATA(s2);
3834  if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
3835  goto return_ne;
3836  } else if (length == 1) {
3837  goto return_eq;
3838  } else {
3839  int result = memcmp(data1, data2, (size_t)(length * kind));
3840  #if PY_MAJOR_VERSION < 3
3841  Py_XDECREF(owned_ref);
3842  #endif
3843  return (equals == Py_EQ) ? (result == 0) : (result != 0);
3844  }
3845  } else if ((s1 == Py_None) & s2_is_unicode) {
3846  goto return_ne;
3847  } else if ((s2 == Py_None) & s1_is_unicode) {
3848  goto return_ne;
3849  } else {
3850  int result;
3851  PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
3852  if (!py_result)
3853  return -1;
3854  result = __Pyx_PyObject_IsTrue(py_result);
3855  Py_DECREF(py_result);
3856  return result;
3857  }
3858 return_eq:
3859  #if PY_MAJOR_VERSION < 3
3860  Py_XDECREF(owned_ref);
3861  #endif
3862  return (equals == Py_EQ);
3863 return_ne:
3864  #if PY_MAJOR_VERSION < 3
3865  Py_XDECREF(owned_ref);
3866  #endif
3867  return (equals == Py_NE);
3868 #endif
3869 }
3870 
3871 /* Import */
3872  static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
3873  PyObject *empty_list = 0;
3874  PyObject *module = 0;
3875  PyObject *global_dict = 0;
3876  PyObject *empty_dict = 0;
3877  PyObject *list;
3878  #if PY_VERSION_HEX < 0x03030000
3879  PyObject *py_import;
3880  py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
3881  if (!py_import)
3882  goto bad;
3883  #endif
3884  if (from_list)
3885  list = from_list;
3886  else {
3887  empty_list = PyList_New(0);
3888  if (!empty_list)
3889  goto bad;
3890  list = empty_list;
3891  }
3892  global_dict = PyModule_GetDict(__pyx_m);
3893  if (!global_dict)
3894  goto bad;
3895  empty_dict = PyDict_New();
3896  if (!empty_dict)
3897  goto bad;
3898  {
3899  #if PY_MAJOR_VERSION >= 3
3900  if (level == -1) {
3901  if (strchr(__Pyx_MODULE_NAME, '.')) {
3902  #if PY_VERSION_HEX < 0x03030000
3903  PyObject *py_level = PyInt_FromLong(1);
3904  if (!py_level)
3905  goto bad;
3906  module = PyObject_CallFunctionObjArgs(py_import,
3907  name, global_dict, empty_dict, list, py_level, NULL);
3908  Py_DECREF(py_level);
3909  #else
3910  module = PyImport_ImportModuleLevelObject(
3911  name, global_dict, empty_dict, list, 1);
3912  #endif
3913  if (!module) {
3914  if (!PyErr_ExceptionMatches(PyExc_ImportError))
3915  goto bad;
3916  PyErr_Clear();
3917  }
3918  }
3919  level = 0;
3920  }
3921  #endif
3922  if (!module) {
3923  #if PY_VERSION_HEX < 0x03030000
3924  PyObject *py_level = PyInt_FromLong(level);
3925  if (!py_level)
3926  goto bad;
3927  module = PyObject_CallFunctionObjArgs(py_import,
3928  name, global_dict, empty_dict, list, py_level, NULL);
3929  Py_DECREF(py_level);
3930  #else
3931  module = PyImport_ImportModuleLevelObject(
3932  name, global_dict, empty_dict, list, level);
3933  #endif
3934  }
3935  }
3936 bad:
3937  #if PY_VERSION_HEX < 0x03030000
3938  Py_XDECREF(py_import);
3939  #endif
3940  Py_XDECREF(empty_list);
3941  Py_XDECREF(empty_dict);
3942  return module;
3943 }
3944 
3945 /* ImportFrom */
3946  static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
3947  PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
3948  if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
3949  PyErr_Format(PyExc_ImportError,
3950  #if PY_MAJOR_VERSION < 3
3951  "cannot import name %.230s", PyString_AS_STRING(name));
3952  #else
3953  "cannot import name %S", name);
3954  #endif
3955  }
3956  return value;
3957 }
3958 
3959 /* CLineInTraceback */
3960  static int __Pyx_CLineForTraceback(int c_line) {
3961 #ifdef CYTHON_CLINE_IN_TRACEBACK
3962  return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0;
3963 #else
3964  PyObject *use_cline;
3965 #if CYTHON_COMPILING_IN_CPYTHON
3966  PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
3967  if (likely(cython_runtime_dict)) {
3968  use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
3969  } else
3970 #endif
3971  {
3972  PyObject *ptype, *pvalue, *ptraceback;
3973  PyObject *use_cline_obj;
3974  PyErr_Fetch(&ptype, &pvalue, &ptraceback);
3975  use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
3976  if (use_cline_obj) {
3977  use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
3978  Py_DECREF(use_cline_obj);
3979  } else {
3980  use_cline = NULL;
3981  }
3982  PyErr_Restore(ptype, pvalue, ptraceback);
3983  }
3984  if (!use_cline) {
3985  c_line = 0;
3986  PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
3987  }
3988  else if (PyObject_Not(use_cline) != 0) {
3989  c_line = 0;
3990  }
3991  return c_line;
3992 #endif
3993 }
3994 
3995 /* CodeObjectCache */
3996  static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3997  int start = 0, mid = 0, end = count - 1;
3998  if (end >= 0 && code_line > entries[end].code_line) {
3999  return count;
4000  }
4001  while (start < end) {
4002  mid = start + (end - start) / 2;
4003  if (code_line < entries[mid].code_line) {
4004  end = mid;
4005  } else if (code_line > entries[mid].code_line) {
4006  start = mid + 1;
4007  } else {
4008  return mid;
4009  }
4010  }
4011  if (code_line <= entries[mid].code_line) {
4012  return mid;
4013  } else {
4014  return mid + 1;
4015  }
4016 }
4017 static PyCodeObject *__pyx_find_code_object(int code_line) {
4018  PyCodeObject* code_object;
4019  int pos;
4020  if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
4021  return NULL;
4022  }
4023  pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4024  if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
4025  return NULL;
4026  }
4027  code_object = __pyx_code_cache.entries[pos].code_object;
4028  Py_INCREF(code_object);
4029  return code_object;
4030 }
4031 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
4032  int pos, i;
4033  __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
4034  if (unlikely(!code_line)) {
4035  return;
4036  }
4037  if (unlikely(!entries)) {
4038  entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
4039  if (likely(entries)) {
4040  __pyx_code_cache.entries = entries;
4041  __pyx_code_cache.max_count = 64;
4042  __pyx_code_cache.count = 1;
4043  entries[0].code_line = code_line;
4044  entries[0].code_object = code_object;
4045  Py_INCREF(code_object);
4046  }
4047  return;
4048  }
4049  pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4050  if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
4051  PyCodeObject* tmp = entries[pos].code_object;
4052  entries[pos].code_object = code_object;
4053  Py_DECREF(tmp);
4054  return;
4055  }
4056  if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
4057  int new_max = __pyx_code_cache.max_count + 64;
4058  entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
4059  __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
4060  if (unlikely(!entries)) {
4061  return;
4062  }
4063  __pyx_code_cache.entries = entries;
4064  __pyx_code_cache.max_count = new_max;
4065  }
4066  for (i=__pyx_code_cache.count; i>pos; i--) {
4067  entries[i] = entries[i-1];
4068  }
4069  entries[pos].code_line = code_line;
4070  entries[pos].code_object = code_object;
4071  __pyx_code_cache.count++;
4072  Py_INCREF(code_object);
4073 }
4074 
4075 /* AddTraceback */
4076  #include "compile.h"
4077 #include "frameobject.h"
4078 #include "traceback.h"
4079 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
4080  const char *funcname, int c_line,
4081  int py_line, const char *filename) {
4082  PyCodeObject *py_code = 0;
4083  PyObject *py_srcfile = 0;
4084  PyObject *py_funcname = 0;
4085  #if PY_MAJOR_VERSION < 3
4086  py_srcfile = PyString_FromString(filename);
4087  #else
4088  py_srcfile = PyUnicode_FromString(filename);
4089  #endif
4090  if (!py_srcfile) goto bad;
4091  if (c_line) {
4092  #if PY_MAJOR_VERSION < 3
4093  py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4094  #else
4095  py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4096  #endif
4097  }
4098  else {
4099  #if PY_MAJOR_VERSION < 3
4100  py_funcname = PyString_FromString(funcname);
4101  #else
4102  py_funcname = PyUnicode_FromString(funcname);
4103  #endif
4104  }
4105  if (!py_funcname) goto bad;
4106  py_code = __Pyx_PyCode_New(
4107  0,
4108  0,
4109  0,
4110  0,
4111  0,
4112  __pyx_empty_bytes, /*PyObject *code,*/
4113  __pyx_empty_tuple, /*PyObject *consts,*/
4114  __pyx_empty_tuple, /*PyObject *names,*/
4115  __pyx_empty_tuple, /*PyObject *varnames,*/
4116  __pyx_empty_tuple, /*PyObject *freevars,*/
4117  __pyx_empty_tuple, /*PyObject *cellvars,*/
4118  py_srcfile, /*PyObject *filename,*/
4119  py_funcname, /*PyObject *name,*/
4120  py_line,
4121  __pyx_empty_bytes /*PyObject *lnotab*/
4122  );
4123  Py_DECREF(py_srcfile);
4124  Py_DECREF(py_funcname);
4125  return py_code;
4126 bad:
4127  Py_XDECREF(py_srcfile);
4128  Py_XDECREF(py_funcname);
4129  return NULL;
4130 }
4131 static void __Pyx_AddTraceback(const char *funcname, int c_line,
4132  int py_line, const char *filename) {
4133  PyCodeObject *py_code = 0;
4134  PyFrameObject *py_frame = 0;
4135  if (c_line) {
4136  c_line = __Pyx_CLineForTraceback(c_line);
4137  }
4138  py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
4139  if (!py_code) {
4140  py_code = __Pyx_CreateCodeObjectForTraceback(
4141  funcname, c_line, py_line, filename);
4142  if (!py_code) goto bad;
4143  __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
4144  }
4145  py_frame = PyFrame_New(
4146  PyThreadState_GET(), /*PyThreadState *tstate,*/
4147  py_code, /*PyCodeObject *code,*/
4148  __pyx_d, /*PyObject *globals,*/
4149  0 /*PyObject *locals*/
4150  );
4151  if (!py_frame) goto bad;
4152  __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
4153  PyTraceBack_Here(py_frame);
4154 bad:
4155  Py_XDECREF(py_code);
4156  Py_XDECREF(py_frame);
4157 }
4158 
4159 /* CIntToPy */
4160  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
4161  const int neg_one = (int) -1, const_zero = (int) 0;
4162  const int is_unsigned = neg_one > const_zero;
4163  if (is_unsigned) {
4164  if (sizeof(int) < sizeof(long)) {
4165  return PyInt_FromLong((long) value);
4166  } else if (sizeof(int) <= sizeof(unsigned long)) {
4167  return PyLong_FromUnsignedLong((unsigned long) value);
4168 #ifdef HAVE_LONG_LONG
4169  } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
4170  return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4171 #endif
4172  }
4173  } else {
4174  if (sizeof(int) <= sizeof(long)) {
4175  return PyInt_FromLong((long) value);
4176 #ifdef HAVE_LONG_LONG
4177  } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
4178  return PyLong_FromLongLong((PY_LONG_LONG) value);
4179 #endif
4180  }
4181  }
4182  {
4183  int one = 1; int little = (int)*(unsigned char *)&one;
4184  unsigned char *bytes = (unsigned char *)&value;
4185  return _PyLong_FromByteArray(bytes, sizeof(int),
4186  little, !is_unsigned);
4187  }
4188 }
4189 
4190 /* CIntToPy */
4191  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
4192  const long neg_one = (long) -1, const_zero = (long) 0;
4193  const int is_unsigned = neg_one > const_zero;
4194  if (is_unsigned) {
4195  if (sizeof(long) < sizeof(long)) {
4196  return PyInt_FromLong((long) value);
4197  } else if (sizeof(long) <= sizeof(unsigned long)) {
4198  return PyLong_FromUnsignedLong((unsigned long) value);
4199 #ifdef HAVE_LONG_LONG
4200  } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4201  return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4202 #endif
4203  }
4204  } else {
4205  if (sizeof(long) <= sizeof(long)) {
4206  return PyInt_FromLong((long) value);
4207 #ifdef HAVE_LONG_LONG
4208  } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4209  return PyLong_FromLongLong((PY_LONG_LONG) value);
4210 #endif
4211  }
4212  }
4213  {
4214  int one = 1; int little = (int)*(unsigned char *)&one;
4215  unsigned char *bytes = (unsigned char *)&value;
4216  return _PyLong_FromByteArray(bytes, sizeof(long),
4217  little, !is_unsigned);
4218  }
4219 }
4220 
4221 /* CIntFromPyVerify */
4222  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
4223  __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
4224 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
4225  __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
4226 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
4227  {\
4228  func_type value = func_value;\
4229  if (sizeof(target_type) < sizeof(func_type)) {\
4230  if (unlikely(value != (func_type) (target_type) value)) {\
4231  func_type zero = 0;\
4232  if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
4233  return (target_type) -1;\
4234  if (is_unsigned && unlikely(value < zero))\
4235  goto raise_neg_overflow;\
4236  else\
4237  goto raise_overflow;\
4238  }\
4239  }\
4240  return (target_type) value;\
4241  }
4242 
4243 /* CIntFromPy */
4244  static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
4245  const long neg_one = (long) -1, const_zero = (long) 0;
4246  const int is_unsigned = neg_one > const_zero;
4247 #if PY_MAJOR_VERSION < 3
4248  if (likely(PyInt_Check(x))) {
4249  if (sizeof(long) < sizeof(long)) {
4250  __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
4251  } else {
4252  long val = PyInt_AS_LONG(x);
4253  if (is_unsigned && unlikely(val < 0)) {
4254  goto raise_neg_overflow;
4255  }
4256  return (long) val;
4257  }
4258  } else
4259 #endif
4260  if (likely(PyLong_Check(x))) {
4261  if (is_unsigned) {
4262 #if CYTHON_USE_PYLONG_INTERNALS
4263  const digit* digits = ((PyLongObject*)x)->ob_digit;
4264  switch (Py_SIZE(x)) {
4265  case 0: return (long) 0;
4266  case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
4267  case 2:
4268  if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4269  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4270  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4271  } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
4272  return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4273  }
4274  }
4275  break;
4276  case 3:
4277  if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4278  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4279  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4280  } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
4281  return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4282  }
4283  }
4284  break;
4285  case 4:
4286  if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4287  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4288  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4289  } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
4290  return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4291  }
4292  }
4293  break;
4294  }
4295 #endif
4296 #if CYTHON_COMPILING_IN_CPYTHON
4297  if (unlikely(Py_SIZE(x) < 0)) {
4298  goto raise_neg_overflow;
4299  }
4300 #else
4301  {
4302  int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4303  if (unlikely(result < 0))
4304  return (long) -1;
4305  if (unlikely(result == 1))
4306  goto raise_neg_overflow;
4307  }
4308 #endif
4309  if (sizeof(long) <= sizeof(unsigned long)) {
4310  __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
4311 #ifdef HAVE_LONG_LONG
4312  } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4313  __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4314 #endif
4315  }
4316  } else {
4317 #if CYTHON_USE_PYLONG_INTERNALS
4318  const digit* digits = ((PyLongObject*)x)->ob_digit;
4319  switch (Py_SIZE(x)) {
4320  case 0: return (long) 0;
4321  case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
4322  case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
4323  case -2:
4324  if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
4325  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4326  __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4327  } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4328  return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4329  }
4330  }
4331  break;
4332  case 2:
4333  if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4334  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4335  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4336  } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4337  return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4338  }
4339  }
4340  break;
4341  case -3:
4342  if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4343  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4344  __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4345  } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4346  return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4347  }
4348  }
4349  break;
4350  case 3:
4351  if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4352  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4353  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4354  } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4355  return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4356  }
4357  }
4358  break;
4359  case -4:
4360  if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4361  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4362  __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4363  } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4364  return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4365  }
4366  }
4367  break;
4368  case 4:
4369  if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4370  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4371  __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4372  } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4373  return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4374  }
4375  }
4376  break;
4377  }
4378 #endif
4379  if (sizeof(long) <= sizeof(long)) {
4380  __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
4381 #ifdef HAVE_LONG_LONG
4382  } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4383  __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
4384 #endif
4385  }
4386  }
4387  {
4388 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4389  PyErr_SetString(PyExc_RuntimeError,
4390  "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4391 #else
4392  long val;
4393  PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4394  #if PY_MAJOR_VERSION < 3
4395  if (likely(v) && !PyLong_Check(v)) {
4396  PyObject *tmp = v;
4397  v = PyNumber_Long(tmp);
4398  Py_DECREF(tmp);
4399  }
4400  #endif
4401  if (likely(v)) {
4402  int one = 1; int is_little = (int)*(unsigned char *)&one;
4403  unsigned char *bytes = (unsigned char *)&val;
4404  int ret = _PyLong_AsByteArray((PyLongObject *)v,
4405  bytes, sizeof(val),
4406  is_little, !is_unsigned);
4407  Py_DECREF(v);
4408  if (likely(!ret))
4409  return val;
4410  }
4411 #endif
4412  return (long) -1;
4413  }
4414  } else {
4415  long val;
4416  PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4417  if (!tmp) return (long) -1;
4418  val = __Pyx_PyInt_As_long(tmp);
4419  Py_DECREF(tmp);
4420  return val;
4421  }
4422 raise_overflow:
4423  PyErr_SetString(PyExc_OverflowError,
4424  "value too large to convert to long");
4425  return (long) -1;
4426 raise_neg_overflow:
4427  PyErr_SetString(PyExc_OverflowError,
4428  "can't convert negative value to long");
4429  return (long) -1;
4430 }
4431 
4432 /* CIntFromPy */
4433  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
4434  const int neg_one = (int) -1, const_zero = (int) 0;
4435  const int is_unsigned = neg_one > const_zero;
4436 #if PY_MAJOR_VERSION < 3
4437  if (likely(PyInt_Check(x))) {
4438  if (sizeof(int) < sizeof(long)) {
4439  __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
4440  } else {
4441  long val = PyInt_AS_LONG(x);
4442  if (is_unsigned && unlikely(val < 0)) {
4443  goto raise_neg_overflow;
4444  }
4445  return (int) val;
4446  }
4447  } else
4448 #endif
4449  if (likely(PyLong_Check(x))) {
4450  if (is_unsigned) {
4451 #if CYTHON_USE_PYLONG_INTERNALS
4452  const digit* digits = ((PyLongObject*)x)->ob_digit;
4453  switch (Py_SIZE(x)) {
4454  case 0: return (int) 0;
4455  case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
4456  case 2:
4457  if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4458  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4459  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4460  } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
4461  return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4462  }
4463  }
4464  break;
4465  case 3:
4466  if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4467  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4468  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4469  } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
4470  return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4471  }
4472  }
4473  break;
4474  case 4:
4475  if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4476  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4477  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4478  } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
4479  return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4480  }
4481  }
4482  break;
4483  }
4484 #endif
4485 #if CYTHON_COMPILING_IN_CPYTHON
4486  if (unlikely(Py_SIZE(x) < 0)) {
4487  goto raise_neg_overflow;
4488  }
4489 #else
4490  {
4491  int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4492  if (unlikely(result < 0))
4493  return (int) -1;
4494  if (unlikely(result == 1))
4495  goto raise_neg_overflow;
4496  }
4497 #endif
4498  if (sizeof(int) <= sizeof(unsigned long)) {
4499  __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
4500 #ifdef HAVE_LONG_LONG
4501  } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
4502  __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4503 #endif
4504  }
4505  } else {
4506 #if CYTHON_USE_PYLONG_INTERNALS
4507  const digit* digits = ((PyLongObject*)x)->ob_digit;
4508  switch (Py_SIZE(x)) {
4509  case 0: return (int) 0;
4510  case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
4511  case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
4512  case -2:
4513  if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
4514  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4515  __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4516  } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4517  return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4518  }
4519  }
4520  break;
4521  case 2:
4522  if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4523  if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4524  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4525  } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4526  return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4527  }
4528  }
4529  break;
4530  case -3:
4531  if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4532  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4533  __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4534  } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4535  return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4536  }
4537  }
4538  break;
4539  case 3:
4540  if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4541  if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4542  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4543  } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4544  return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4545  }
4546  }
4547  break;
4548  case -4:
4549  if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4550  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4551  __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4552  } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4553  return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4554  }
4555  }
4556  break;
4557  case 4:
4558  if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4559  if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4560  __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4561  } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4562  return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4563  }
4564  }
4565  break;
4566  }
4567 #endif
4568  if (sizeof(int) <= sizeof(long)) {
4569  __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
4570 #ifdef HAVE_LONG_LONG
4571  } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
4572  __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
4573 #endif
4574  }
4575  }
4576  {
4577 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4578  PyErr_SetString(PyExc_RuntimeError,
4579  "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4580 #else
4581  int val;
4582  PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4583  #if PY_MAJOR_VERSION < 3
4584  if (likely(v) && !PyLong_Check(v)) {
4585  PyObject *tmp = v;
4586  v = PyNumber_Long(tmp);
4587  Py_DECREF(tmp);
4588  }
4589  #endif
4590  if (likely(v)) {
4591  int one = 1; int is_little = (int)*(unsigned char *)&one;
4592  unsigned char *bytes = (unsigned char *)&val;
4593  int ret = _PyLong_AsByteArray((PyLongObject *)v,
4594  bytes, sizeof(val),
4595  is_little, !is_unsigned);
4596  Py_DECREF(v);
4597  if (likely(!ret))
4598  return val;
4599  }
4600 #endif
4601  return (int) -1;
4602  }
4603  } else {
4604  int val;
4605  PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4606  if (!tmp) return (int) -1;
4607  val = __Pyx_PyInt_As_int(tmp);
4608  Py_DECREF(tmp);
4609  return val;
4610  }
4611 raise_overflow:
4612  PyErr_SetString(PyExc_OverflowError,
4613  "value too large to convert to int");
4614  return (int) -1;
4615 raise_neg_overflow:
4616  PyErr_SetString(PyExc_OverflowError,
4617  "can't convert negative value to int");
4618  return (int) -1;
4619 }
4620 
4621 /* CheckBinaryVersion */
4622  static int __Pyx_check_binary_version(void) {
4623  char ctversion[4], rtversion[4];
4624  PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
4625  PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
4626  if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
4627  char message[200];
4628  PyOS_snprintf(message, sizeof(message),
4629  "compiletime version %s of module '%.100s' "
4630  "does not match runtime version %s",
4631  ctversion, __Pyx_MODULE_NAME, rtversion);
4632  return PyErr_WarnEx(NULL, message, 1);
4633  }
4634  return 0;
4635 }
4636 
4637 /* FunctionExport */
4638  static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
4639  PyObject *d = 0;
4640  PyObject *cobj = 0;
4641  union {
4642  void (*fp)(void);
4643  void *p;
4644  } tmp;
4645  d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
4646  if (!d) {
4647  PyErr_Clear();
4648  d = PyDict_New();
4649  if (!d)
4650  goto bad;
4651  Py_INCREF(d);
4652  if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
4653  goto bad;
4654  }
4655  tmp.fp = f;
4656 #if PY_VERSION_HEX >= 0x02070000
4657  cobj = PyCapsule_New(tmp.p, sig, 0);
4658 #else
4659  cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
4660 #endif
4661  if (!cobj)
4662  goto bad;
4663  if (PyDict_SetItemString(d, name, cobj) < 0)
4664  goto bad;
4665  Py_DECREF(cobj);
4666  Py_DECREF(d);
4667  return 0;
4668 bad:
4669  Py_XDECREF(cobj);
4670  Py_XDECREF(d);
4671  return -1;
4672 }
4673 
4674 /* ModuleImport */
4675  #ifndef __PYX_HAVE_RT_ImportModule
4676 #define __PYX_HAVE_RT_ImportModule
4677 static PyObject *__Pyx_ImportModule(const char *name) {
4678  PyObject *py_name = 0;
4679  PyObject *py_module = 0;
4680  py_name = __Pyx_PyIdentifier_FromString(name);
4681  if (!py_name)
4682  goto bad;
4683  py_module = PyImport_Import(py_name);
4684  Py_DECREF(py_name);
4685  return py_module;
4686 bad:
4687  Py_XDECREF(py_name);
4688  return 0;
4689 }
4690 #endif
4691 
4692 /* TypeImport */
4693  #ifndef __PYX_HAVE_RT_ImportType
4694 #define __PYX_HAVE_RT_ImportType
4695 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
4696  size_t size, int strict)
4697 {
4698  PyObject *py_module = 0;
4699  PyObject *result = 0;
4700  PyObject *py_name = 0;
4701  char warning[200];
4702  Py_ssize_t basicsize;
4703 #ifdef Py_LIMITED_API
4704  PyObject *py_basicsize;
4705 #endif
4706  py_module = __Pyx_ImportModule(module_name);
4707  if (!py_module)
4708  goto bad;
4709  py_name = __Pyx_PyIdentifier_FromString(class_name);
4710  if (!py_name)
4711  goto bad;
4712  result = PyObject_GetAttr(py_module, py_name);
4713  Py_DECREF(py_name);
4714  py_name = 0;
4715  Py_DECREF(py_module);
4716  py_module = 0;
4717  if (!result)
4718  goto bad;
4719  if (!PyType_Check(result)) {
4720  PyErr_Format(PyExc_TypeError,
4721  "%.200s.%.200s is not a type object",
4722  module_name, class_name);
4723  goto bad;
4724  }
4725 #ifndef Py_LIMITED_API
4726  basicsize = ((PyTypeObject *)result)->tp_basicsize;
4727 #else
4728  py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
4729  if (!py_basicsize)
4730  goto bad;
4731  basicsize = PyLong_AsSsize_t(py_basicsize);
4732  Py_DECREF(py_basicsize);
4733  py_basicsize = 0;
4734  if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
4735  goto bad;
4736 #endif
4737  if (!strict && (size_t)basicsize > size) {
4738  PyOS_snprintf(warning, sizeof(warning),
4739  "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
4740  module_name, class_name, basicsize, size);
4741  if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
4742  }
4743  else if ((size_t)basicsize != size) {
4744  PyErr_Format(PyExc_ValueError,
4745  "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
4746  module_name, class_name, basicsize, size);
4747  goto bad;
4748  }
4749  return (PyTypeObject *)result;
4750 bad:
4751  Py_XDECREF(py_module);
4752  Py_XDECREF(result);
4753  return NULL;
4754 }
4755 #endif
4756 
4757 /* InitStrings */
4758  static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
4759  while (t->p) {
4760  #if PY_MAJOR_VERSION < 3
4761  if (t->is_unicode) {
4762  *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
4763  } else if (t->intern) {
4764  *t->p = PyString_InternFromString(t->s);
4765  } else {
4766  *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
4767  }
4768  #else
4769  if (t->is_unicode | t->is_str) {
4770  if (t->intern) {
4771  *t->p = PyUnicode_InternFromString(t->s);
4772  } else if (t->encoding) {
4773  *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
4774  } else {
4775  *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
4776  }
4777  } else {
4778  *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
4779  }
4780  #endif
4781  if (!*t->p)
4782  return -1;
4783  if (PyObject_Hash(*t->p) == -1)
4784  PyErr_Clear();
4785  ++t;
4786  }
4787  return 0;
4788 }
4789 
4790 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
4791  return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
4792 }
4793 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
4794  Py_ssize_t ignore;
4795  return __Pyx_PyObject_AsStringAndSize(o, &ignore);
4796 }
4797 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4798 #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
4799  if (
4800 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4801  __Pyx_sys_getdefaultencoding_not_ascii &&
4802 #endif
4803  PyUnicode_Check(o)) {
4804 #if PY_VERSION_HEX < 0x03030000
4805  char* defenc_c;
4806  PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
4807  if (!defenc) return NULL;
4808  defenc_c = PyBytes_AS_STRING(defenc);
4809 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4810  {
4811  char* end = defenc_c + PyBytes_GET_SIZE(defenc);
4812  char* c;
4813  for (c = defenc_c; c < end; c++) {
4814  if ((unsigned char) (*c) >= 128) {
4815  PyUnicode_AsASCIIString(o);
4816  return NULL;
4817  }
4818  }
4819  }
4820 #endif
4821  *length = PyBytes_GET_SIZE(defenc);
4822  return defenc_c;
4823 #else
4824  if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
4825 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4826  if (PyUnicode_IS_ASCII(o)) {
4827  *length = PyUnicode_GET_LENGTH(o);
4828  return PyUnicode_AsUTF8(o);
4829  } else {
4830  PyUnicode_AsASCIIString(o);
4831  return NULL;
4832  }
4833 #else
4834  return PyUnicode_AsUTF8AndSize(o, length);
4835 #endif
4836 #endif
4837  } else
4838 #endif
4839 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
4840  if (PyByteArray_Check(o)) {
4841  *length = PyByteArray_GET_SIZE(o);
4842  return PyByteArray_AS_STRING(o);
4843  } else
4844 #endif
4845  {
4846  char* result;
4847  int r = PyBytes_AsStringAndSize(o, &result, length);
4848  if (unlikely(r < 0)) {
4849  return NULL;
4850  } else {
4851  return result;
4852  }
4853  }
4854 }
4855 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
4856  int is_true = x == Py_True;
4857  if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
4858  else return PyObject_IsTrue(x);
4859 }
4860 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
4861 #if CYTHON_USE_TYPE_SLOTS
4862  PyNumberMethods *m;
4863 #endif
4864  const char *name = NULL;
4865  PyObject *res = NULL;
4866 #if PY_MAJOR_VERSION < 3
4867  if (PyInt_Check(x) || PyLong_Check(x))
4868 #else
4869  if (PyLong_Check(x))
4870 #endif
4871  return __Pyx_NewRef(x);
4872 #if CYTHON_USE_TYPE_SLOTS
4873  m = Py_TYPE(x)->tp_as_number;
4874  #if PY_MAJOR_VERSION < 3
4875  if (m && m->nb_int) {
4876  name = "int";
4877  res = PyNumber_Int(x);
4878  }
4879  else if (m && m->nb_long) {
4880  name = "long";
4881  res = PyNumber_Long(x);
4882  }
4883  #else
4884  if (m && m->nb_int) {
4885  name = "int";
4886  res = PyNumber_Long(x);
4887  }
4888  #endif
4889 #else
4890  res = PyNumber_Int(x);
4891 #endif
4892  if (res) {
4893 #if PY_MAJOR_VERSION < 3
4894  if (!PyInt_Check(res) && !PyLong_Check(res)) {
4895 #else
4896  if (!PyLong_Check(res)) {
4897 #endif
4898  PyErr_Format(PyExc_TypeError,
4899  "__%.4s__ returned non-%.4s (type %.200s)",
4900  name, name, Py_TYPE(res)->tp_name);
4901  Py_DECREF(res);
4902  return NULL;
4903  }
4904  }
4905  else if (!PyErr_Occurred()) {
4906  PyErr_SetString(PyExc_TypeError,
4907  "an integer is required");
4908  }
4909  return res;
4910 }
4911 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
4912  Py_ssize_t ival;
4913  PyObject *x;
4914 #if PY_MAJOR_VERSION < 3
4915  if (likely(PyInt_CheckExact(b))) {
4916  if (sizeof(Py_ssize_t) >= sizeof(long))
4917  return PyInt_AS_LONG(b);
4918  else
4919  return PyInt_AsSsize_t(x);
4920  }
4921 #endif
4922  if (likely(PyLong_CheckExact(b))) {
4923  #if CYTHON_USE_PYLONG_INTERNALS
4924  const digit* digits = ((PyLongObject*)b)->ob_digit;
4925  const Py_ssize_t size = Py_SIZE(b);
4926  if (likely(__Pyx_sst_abs(size) <= 1)) {
4927  ival = likely(size) ? digits[0] : 0;
4928  if (size == -1) ival = -ival;
4929  return ival;
4930  } else {
4931  switch (size) {
4932  case 2:
4933  if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4934  return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4935  }
4936  break;
4937  case -2:
4938  if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4939  return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4940  }
4941  break;
4942  case 3:
4943  if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4944  return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4945  }
4946  break;
4947  case -3:
4948  if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4949  return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4950  }
4951  break;
4952  case 4:
4953  if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4954  return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4955  }
4956  break;
4957  case -4:
4958  if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4959  return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4960  }
4961  break;
4962  }
4963  }
4964  #endif
4965  return PyLong_AsSsize_t(b);
4966  }
4967  x = PyNumber_Index(b);
4968  if (!x) return -1;
4969  ival = PyInt_AsSsize_t(x);
4970  Py_DECREF(x);
4971  return ival;
4972 }
4973 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
4974  return PyInt_FromSize_t(ival);
4975 }
4976 
4977 
4978 #endif /* Py_PYTHON_H */
PyMODINIT_FUNC initpymodule(void)
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
Definition: pyne.cc:11180
The Region class is the abstract class/interface used by all region agents.
Definition: region.h:60
std::string name(int nuc)
Definition: pyne.cc:2940
__PYX_EXTERN_C void CyclusPyDelAgent(int)
The Facility class is the abstract class/interface used by all facility agents.
Definition: facility.h:68
def memset(dest, src, size)
zz_group fp
fission product Z number group
Definition: pyne.cc:2663
__PYX_EXTERN_C void CyclusInitFromPyAgent(cyclus::Agent *, cyclus::Agent *, void *)
__PYX_EXTERN_C void CyclusPyCallListeners(std::string, cyclus::Agent *, void *, int, boost::spirit::hold_any)
__PYX_EXTERN_C cyclus::Agent * CyclusMakePyAgent(std::string, std::string, void *)
static std::string digits
string of digit characters
Definition: pyne.h:124
bool operator==(const CapacityConstraint< T > &lhs, const CapacityConstraint< T > &rhs)
CapacityConstraint-CapacityConstraint equality operator.
#define __PYX_EXTERN_C
Definition: eventhooks.cc.h:13
The abstract base class used by all types of agents that live and interact in a simulation.
Definition: agent.h:51
void warning(std::string s)
Prints a warning message.
Definition: pyne.cc:413
__PYX_EXTERN_C void CyclusClearPyAgentRefs(void)
__PYX_EXTERN_C std::string CyclusPyFindModule(std::string)
enable_if< has_const_iterator< T >::value, typename T::const_iterator >::type end(const T &c)
The Institution class is the abstract class/interface used by all institution agents.
Definition: institution.h:29