├── particles.pxd ├── setup.py ├── recipe.sh ├── particles.pyx └── particles.c /particles.pxd: -------------------------------------------------------------------------------- 1 | cdef class particle: 2 | cdef int ent 3 | cdef float vx 4 | cdef float vy 5 | cdef float lifespan 6 | cdef float maxlifespan 7 | cdef float drag 8 | cdef float gx 9 | cdef float gy 10 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from os import environ, remove 2 | from os.path import dirname, join, isfile 3 | from distutils.core import setup 4 | from distutils.extension import Extension 5 | try: 6 | from Cython.Build import cythonize 7 | from Cython.Distutils import build_ext 8 | have_cython = True 9 | except ImportError: 10 | have_cython = False 11 | 12 | 13 | if have_cython: 14 | particles_files = [ 15 | 'particles.pyx' 16 | ] 17 | cmdclass = {'build_ext': build_ext} 18 | else: 19 | particles_files = ['particles.c'] 20 | cmdclass = {} 21 | 22 | ext = Extension('particles', 23 | particles_files) 24 | 25 | setup( 26 | name='particles', 27 | cmdclass=cmdclass, 28 | ext_modules=[ext]) 29 | -------------------------------------------------------------------------------- /recipe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION_kivent_simple_particles=1.0.0 4 | URL_kivent_simple_particles=https://github.com/chozabu/kivent_simple_particles/archive/master.zip 5 | MD5_kivent_simple_particles= 6 | DEPS_kivent_simple_particles=(python cymunk kivy kivent_core) 7 | BUILD_kivent_simple_particles=$BUILD_PATH/kivent_simple_particles/master/ 8 | RECIPE_kivent_simple_particles=$RECIPES_PATH/kivent_simple_particles 9 | 10 | function prebuild_kivent_simple_particles() { 11 | true 12 | } 13 | 14 | function build_kivent_simple_particles() { 15 | cd $BUILD_kivent_simple_particles 16 | echo `pwd` 17 | echo `ls` 18 | push_arm 19 | 20 | export LDSHARED="$LIBLINK" 21 | export PYTHONPATH=$BUILD_kivy/:$PYTHONPATH 22 | export PYTHONPATH=$BUILD_cymunk/cymunk/python:$PYTHONPATH 23 | export PYTHONPATH=$BUILD_kivent_core/:$PYTHONPATH 24 | try find . -iname 'particles' -exec $CYTHON {} \; 25 | try $BUILD_PATH/python-install/bin/python.host setup.py build_ext -v 26 | try find build/lib.* -name "*.o" -exec $STRIP {} \; 27 | 28 | export PYTHONPATH=$BUILD_hostpython/Lib/site-packages 29 | try $BUILD_hostpython/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages 30 | 31 | unset LDSHARED 32 | pop_arm 33 | } 34 | 35 | function postbuild_kivent_simple_particles() { 36 | true 37 | } 38 | -------------------------------------------------------------------------------- /particles.pyx: -------------------------------------------------------------------------------- 1 | __author__ = 'chozabu' 2 | 3 | gameref = None 4 | 5 | enable_particles = 1 6 | 7 | from random import random 8 | 9 | particles = [] 10 | 11 | cdef class particle: 12 | def __init__(self, ent, vel,lifespan, drag, gravity): 13 | self.ent=ent 14 | self.vx=vel[0] 15 | self.vy=vel[1] 16 | self.lifespan=lifespan 17 | self.maxlifespan=lifespan 18 | self.drag = drag 19 | self.gx=gravity[0] 20 | self.gy=gravity[1] 21 | def entity_id(self): 22 | return self.ent 23 | def updateme(self, list ents, float dt): 24 | cdef float ls = self.lifespan 25 | cdef float mls = self.maxlifespan 26 | ent = ents[self.ent] 27 | self.vx = self.vx*self.drag+self.gx 28 | self.vy = self.vy*self.drag+self.gy 29 | ent.position.x+=self.vx 30 | ent.position.y+=self.vy 31 | ent.color.a=ls/mls 32 | ent.scale.s=ls/(mls*.5) 33 | self.lifespan-=dt 34 | return self.lifespan 35 | 36 | def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): 37 | if enable_particles==0:return 38 | pid = create_visual(pos, color=color, radius=radius*.5) 39 | #ent = gameref.gameworld.entities[pid] 40 | newp = particle(pid,vel,lifespan=lifespan, drag=drag, gravity=gravity) 41 | particles.append(newp) 42 | 43 | def update(float dt): 44 | global particles 45 | ents = gameref.gameworld.entities 46 | remlist=[] 47 | for p in particles: 48 | ls = p.updateme(ents, dt) 49 | #print ls 50 | if ls<0: 51 | remlist.append(p) 52 | gameref.gameworld.remove_entity(p.entity_id()) 53 | for r in remlist: 54 | particles.remove(r) 55 | 56 | 57 | 58 | cdef create_visual(pos, color,float radius=64): 59 | 60 | create_component_dict = { 61 | 'renderer': {'texture': 'particle', 62 | 'size': (radius,radius)}, 63 | 'position': pos, 'rotate': 0, 'color': color, 64 | #'lerp_system': {}, 65 | 'scale':1.} 66 | component_order = ['position', 'rotate', 'color', 67 | 'renderer','scale'] 68 | eid = gameref.gameworld.init_entity(create_component_dict, 69 | component_order) 70 | return eid -------------------------------------------------------------------------------- /particles.c: -------------------------------------------------------------------------------- 1 | /* Generated by Cython 0.21.1 */ 2 | 3 | #define PY_SSIZE_T_CLEAN 4 | #ifndef CYTHON_USE_PYLONG_INTERNALS 5 | #ifdef PYLONG_BITS_IN_DIGIT 6 | #define CYTHON_USE_PYLONG_INTERNALS 0 7 | #else 8 | #include "pyconfig.h" 9 | #ifdef PYLONG_BITS_IN_DIGIT 10 | #define CYTHON_USE_PYLONG_INTERNALS 1 11 | #else 12 | #define CYTHON_USE_PYLONG_INTERNALS 0 13 | #endif 14 | #endif 15 | #endif 16 | #include "Python.h" 17 | #ifndef Py_PYTHON_H 18 | #error Python headers needed to compile C extensions, please install development version of Python. 19 | #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) 20 | #error Cython requires Python 2.6+ or Python 3.2+. 21 | #else 22 | #define CYTHON_ABI "0_21_1" 23 | #include 24 | #ifndef offsetof 25 | #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) 26 | #endif 27 | #if !defined(WIN32) && !defined(MS_WINDOWS) 28 | #ifndef __stdcall 29 | #define __stdcall 30 | #endif 31 | #ifndef __cdecl 32 | #define __cdecl 33 | #endif 34 | #ifndef __fastcall 35 | #define __fastcall 36 | #endif 37 | #endif 38 | #ifndef DL_IMPORT 39 | #define DL_IMPORT(t) t 40 | #endif 41 | #ifndef DL_EXPORT 42 | #define DL_EXPORT(t) t 43 | #endif 44 | #ifndef PY_LONG_LONG 45 | #define PY_LONG_LONG LONG_LONG 46 | #endif 47 | #ifndef Py_HUGE_VAL 48 | #define Py_HUGE_VAL HUGE_VAL 49 | #endif 50 | #ifdef PYPY_VERSION 51 | #define CYTHON_COMPILING_IN_PYPY 1 52 | #define CYTHON_COMPILING_IN_CPYTHON 0 53 | #else 54 | #define CYTHON_COMPILING_IN_PYPY 0 55 | #define CYTHON_COMPILING_IN_CPYTHON 1 56 | #endif 57 | #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 58 | #define Py_OptimizeFlag 0 59 | #endif 60 | #define __PYX_BUILD_PY_SSIZE_T "n" 61 | #define CYTHON_FORMAT_SSIZE_T "z" 62 | #if PY_MAJOR_VERSION < 3 63 | #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" 64 | #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ 65 | PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) 66 | #define __Pyx_DefaultClassType PyClass_Type 67 | #else 68 | #define __Pyx_BUILTIN_MODULE_NAME "builtins" 69 | #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ 70 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) 71 | #define __Pyx_DefaultClassType PyType_Type 72 | #endif 73 | #if PY_MAJOR_VERSION >= 3 74 | #define Py_TPFLAGS_CHECKTYPES 0 75 | #define Py_TPFLAGS_HAVE_INDEX 0 76 | #define Py_TPFLAGS_HAVE_NEWBUFFER 0 77 | #endif 78 | #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) 79 | #define Py_TPFLAGS_HAVE_FINALIZE 0 80 | #endif 81 | #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) 82 | #define CYTHON_PEP393_ENABLED 1 83 | #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ 84 | 0 : _PyUnicode_Ready((PyObject *)(op))) 85 | #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) 86 | #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) 87 | #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) 88 | #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) 89 | #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) 90 | #else 91 | #define CYTHON_PEP393_ENABLED 0 92 | #define __Pyx_PyUnicode_READY(op) (0) 93 | #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) 94 | #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) 95 | #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) 96 | #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) 97 | #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) 98 | #endif 99 | #if CYTHON_COMPILING_IN_PYPY 100 | #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) 101 | #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) 102 | #define __Pyx_PyFrozenSet_Size(s) PyObject_Size(s) 103 | #else 104 | #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) 105 | #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ 106 | PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) 107 | #define __Pyx_PyFrozenSet_Size(s) PySet_Size(s) 108 | #endif 109 | #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) 110 | #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) 111 | #if PY_MAJOR_VERSION >= 3 112 | #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) 113 | #else 114 | #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) 115 | #endif 116 | #if PY_MAJOR_VERSION >= 3 117 | #define PyBaseString_Type PyUnicode_Type 118 | #define PyStringObject PyUnicodeObject 119 | #define PyString_Type PyUnicode_Type 120 | #define PyString_Check PyUnicode_Check 121 | #define PyString_CheckExact PyUnicode_CheckExact 122 | #endif 123 | #if PY_MAJOR_VERSION >= 3 124 | #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) 125 | #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) 126 | #else 127 | #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) 128 | #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) 129 | #endif 130 | #ifndef PySet_CheckExact 131 | #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) 132 | #endif 133 | #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) 134 | #if PY_MAJOR_VERSION >= 3 135 | #define PyIntObject PyLongObject 136 | #define PyInt_Type PyLong_Type 137 | #define PyInt_Check(op) PyLong_Check(op) 138 | #define PyInt_CheckExact(op) PyLong_CheckExact(op) 139 | #define PyInt_FromString PyLong_FromString 140 | #define PyInt_FromUnicode PyLong_FromUnicode 141 | #define PyInt_FromLong PyLong_FromLong 142 | #define PyInt_FromSize_t PyLong_FromSize_t 143 | #define PyInt_FromSsize_t PyLong_FromSsize_t 144 | #define PyInt_AsLong PyLong_AsLong 145 | #define PyInt_AS_LONG PyLong_AS_LONG 146 | #define PyInt_AsSsize_t PyLong_AsSsize_t 147 | #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask 148 | #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask 149 | #define PyNumber_Int PyNumber_Long 150 | #endif 151 | #if PY_MAJOR_VERSION >= 3 152 | #define PyBoolObject PyLongObject 153 | #endif 154 | #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY 155 | #ifndef PyUnicode_InternFromString 156 | #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) 157 | #endif 158 | #endif 159 | #if PY_VERSION_HEX < 0x030200A4 160 | typedef long Py_hash_t; 161 | #define __Pyx_PyInt_FromHash_t PyInt_FromLong 162 | #define __Pyx_PyInt_AsHash_t PyInt_AsLong 163 | #else 164 | #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t 165 | #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t 166 | #endif 167 | #if PY_MAJOR_VERSION >= 3 168 | #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) 169 | #else 170 | #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) 171 | #endif 172 | #ifndef CYTHON_INLINE 173 | #if defined(__GNUC__) 174 | #define CYTHON_INLINE __inline__ 175 | #elif defined(_MSC_VER) 176 | #define CYTHON_INLINE __inline 177 | #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 178 | #define CYTHON_INLINE inline 179 | #else 180 | #define CYTHON_INLINE 181 | #endif 182 | #endif 183 | #ifndef CYTHON_RESTRICT 184 | #if defined(__GNUC__) 185 | #define CYTHON_RESTRICT __restrict__ 186 | #elif defined(_MSC_VER) && _MSC_VER >= 1400 187 | #define CYTHON_RESTRICT __restrict 188 | #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 189 | #define CYTHON_RESTRICT restrict 190 | #else 191 | #define CYTHON_RESTRICT 192 | #endif 193 | #endif 194 | #ifdef NAN 195 | #define __PYX_NAN() ((float) NAN) 196 | #else 197 | static CYTHON_INLINE float __PYX_NAN() { 198 | /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and 199 | a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is 200 | a quiet NaN. */ 201 | float value; 202 | memset(&value, 0xFF, sizeof(value)); 203 | return value; 204 | } 205 | #endif 206 | #ifdef __cplusplus 207 | template 208 | void __Pyx_call_destructor(T* x) { 209 | x->~T(); 210 | } 211 | #endif 212 | 213 | 214 | #if PY_MAJOR_VERSION >= 3 215 | #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) 216 | #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) 217 | #else 218 | #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) 219 | #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) 220 | #endif 221 | 222 | #ifndef __PYX_EXTERN_C 223 | #ifdef __cplusplus 224 | #define __PYX_EXTERN_C extern "C" 225 | #else 226 | #define __PYX_EXTERN_C extern 227 | #endif 228 | #endif 229 | 230 | #if defined(WIN32) || defined(MS_WINDOWS) 231 | #define _USE_MATH_DEFINES 232 | #endif 233 | #include 234 | #define __PYX_HAVE__particles 235 | #define __PYX_HAVE_API__particles 236 | #ifdef _OPENMP 237 | #include 238 | #endif /* _OPENMP */ 239 | 240 | #ifdef PYREX_WITHOUT_ASSERTIONS 241 | #define CYTHON_WITHOUT_ASSERTIONS 242 | #endif 243 | 244 | #ifndef CYTHON_UNUSED 245 | # if defined(__GNUC__) 246 | # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 247 | # define CYTHON_UNUSED __attribute__ ((__unused__)) 248 | # else 249 | # define CYTHON_UNUSED 250 | # endif 251 | # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) 252 | # define CYTHON_UNUSED __attribute__ ((__unused__)) 253 | # else 254 | # define CYTHON_UNUSED 255 | # endif 256 | #endif 257 | typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; 258 | const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; 259 | 260 | #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 261 | #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 262 | #define __PYX_DEFAULT_STRING_ENCODING "" 263 | #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString 264 | #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize 265 | #define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ 266 | (sizeof(type) < sizeof(Py_ssize_t)) || \ 267 | (sizeof(type) > sizeof(Py_ssize_t) && \ 268 | likely(v < (type)PY_SSIZE_T_MAX || \ 269 | v == (type)PY_SSIZE_T_MAX) && \ 270 | (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ 271 | v == (type)PY_SSIZE_T_MIN))) || \ 272 | (sizeof(type) == sizeof(Py_ssize_t) && \ 273 | (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ 274 | v == (type)PY_SSIZE_T_MAX))) ) 275 | static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); 276 | static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); 277 | #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) 278 | #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) 279 | #define __Pyx_PyBytes_FromString PyBytes_FromString 280 | #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize 281 | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); 282 | #if PY_MAJOR_VERSION < 3 283 | #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString 284 | #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize 285 | #else 286 | #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString 287 | #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize 288 | #endif 289 | #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) 290 | #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) 291 | #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((const char*)s) 292 | #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((const char*)s) 293 | #define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((const char*)s) 294 | #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((const char*)s) 295 | #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s) 296 | #if PY_MAJOR_VERSION < 3 297 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) 298 | { 299 | const Py_UNICODE *u_end = u; 300 | while (*u_end++) ; 301 | return (size_t)(u_end - u - 1); 302 | } 303 | #else 304 | #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen 305 | #endif 306 | #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) 307 | #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode 308 | #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode 309 | #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) 310 | #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) 311 | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); 312 | static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); 313 | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); 314 | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); 315 | #if CYTHON_COMPILING_IN_CPYTHON 316 | #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) 317 | #else 318 | #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) 319 | #endif 320 | #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) 321 | #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 322 | static int __Pyx_sys_getdefaultencoding_not_ascii; 323 | static int __Pyx_init_sys_getdefaultencoding_params(void) { 324 | PyObject* sys; 325 | PyObject* default_encoding = NULL; 326 | PyObject* ascii_chars_u = NULL; 327 | PyObject* ascii_chars_b = NULL; 328 | const char* default_encoding_c; 329 | sys = PyImport_ImportModule("sys"); 330 | if (!sys) goto bad; 331 | default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); 332 | Py_DECREF(sys); 333 | if (!default_encoding) goto bad; 334 | default_encoding_c = PyBytes_AsString(default_encoding); 335 | if (!default_encoding_c) goto bad; 336 | if (strcmp(default_encoding_c, "ascii") == 0) { 337 | __Pyx_sys_getdefaultencoding_not_ascii = 0; 338 | } else { 339 | char ascii_chars[128]; 340 | int c; 341 | for (c = 0; c < 128; c++) { 342 | ascii_chars[c] = c; 343 | } 344 | __Pyx_sys_getdefaultencoding_not_ascii = 1; 345 | ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); 346 | if (!ascii_chars_u) goto bad; 347 | ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); 348 | if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { 349 | PyErr_Format( 350 | PyExc_ValueError, 351 | "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", 352 | default_encoding_c); 353 | goto bad; 354 | } 355 | Py_DECREF(ascii_chars_u); 356 | Py_DECREF(ascii_chars_b); 357 | } 358 | Py_DECREF(default_encoding); 359 | return 0; 360 | bad: 361 | Py_XDECREF(default_encoding); 362 | Py_XDECREF(ascii_chars_u); 363 | Py_XDECREF(ascii_chars_b); 364 | return -1; 365 | } 366 | #endif 367 | #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 368 | #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) 369 | #else 370 | #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) 371 | #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 372 | static char* __PYX_DEFAULT_STRING_ENCODING; 373 | static int __Pyx_init_sys_getdefaultencoding_params(void) { 374 | PyObject* sys; 375 | PyObject* default_encoding = NULL; 376 | char* default_encoding_c; 377 | sys = PyImport_ImportModule("sys"); 378 | if (!sys) goto bad; 379 | default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); 380 | Py_DECREF(sys); 381 | if (!default_encoding) goto bad; 382 | default_encoding_c = PyBytes_AsString(default_encoding); 383 | if (!default_encoding_c) goto bad; 384 | __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); 385 | if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; 386 | strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); 387 | Py_DECREF(default_encoding); 388 | return 0; 389 | bad: 390 | Py_XDECREF(default_encoding); 391 | return -1; 392 | } 393 | #endif 394 | #endif 395 | 396 | 397 | /* Test for GCC > 2.95 */ 398 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) 399 | #define likely(x) __builtin_expect(!!(x), 1) 400 | #define unlikely(x) __builtin_expect(!!(x), 0) 401 | #else /* !__GNUC__ or GCC < 2.95 */ 402 | #define likely(x) (x) 403 | #define unlikely(x) (x) 404 | #endif /* __GNUC__ */ 405 | 406 | static PyObject *__pyx_m; 407 | static PyObject *__pyx_d; 408 | static PyObject *__pyx_b; 409 | static PyObject *__pyx_empty_tuple; 410 | static PyObject *__pyx_empty_bytes; 411 | static int __pyx_lineno; 412 | static int __pyx_clineno = 0; 413 | static const char * __pyx_cfilenm= __FILE__; 414 | static const char *__pyx_filename; 415 | 416 | 417 | static const char *__pyx_f[] = { 418 | "particles.pyx", 419 | }; 420 | 421 | /*--- Type declarations ---*/ 422 | struct __pyx_obj_9particles_particle; 423 | struct __pyx_opt_args_9particles_create_visual; 424 | 425 | /* "particles.pyx":58 426 | * 427 | * 428 | * cdef create_visual(pos, color,float radius=64): # <<<<<<<<<<<<<< 429 | * 430 | * create_component_dict = { 431 | */ 432 | struct __pyx_opt_args_9particles_create_visual { 433 | int __pyx_n; 434 | float radius; 435 | }; 436 | 437 | /* "particles.pxd":1 438 | * cdef class particle: # <<<<<<<<<<<<<< 439 | * cdef int ent 440 | * cdef float vx 441 | */ 442 | struct __pyx_obj_9particles_particle { 443 | PyObject_HEAD 444 | int ent; 445 | float vx; 446 | float vy; 447 | float lifespan; 448 | float maxlifespan; 449 | float drag; 450 | float gx; 451 | float gy; 452 | }; 453 | 454 | #ifndef CYTHON_REFNANNY 455 | #define CYTHON_REFNANNY 0 456 | #endif 457 | #if CYTHON_REFNANNY 458 | typedef struct { 459 | void (*INCREF)(void*, PyObject*, int); 460 | void (*DECREF)(void*, PyObject*, int); 461 | void (*GOTREF)(void*, PyObject*, int); 462 | void (*GIVEREF)(void*, PyObject*, int); 463 | void* (*SetupContext)(const char*, int, const char*); 464 | void (*FinishContext)(void**); 465 | } __Pyx_RefNannyAPIStruct; 466 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; 467 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); 468 | #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; 469 | #ifdef WITH_THREAD 470 | #define __Pyx_RefNannySetupContext(name, acquire_gil) \ 471 | if (acquire_gil) { \ 472 | PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ 473 | __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ 474 | PyGILState_Release(__pyx_gilstate_save); \ 475 | } else { \ 476 | __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ 477 | } 478 | #else 479 | #define __Pyx_RefNannySetupContext(name, acquire_gil) \ 480 | __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) 481 | #endif 482 | #define __Pyx_RefNannyFinishContext() \ 483 | __Pyx_RefNanny->FinishContext(&__pyx_refnanny) 484 | #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 485 | #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 486 | #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 487 | #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 488 | #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) 489 | #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) 490 | #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) 491 | #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) 492 | #else 493 | #define __Pyx_RefNannyDeclarations 494 | #define __Pyx_RefNannySetupContext(name, acquire_gil) 495 | #define __Pyx_RefNannyFinishContext() 496 | #define __Pyx_INCREF(r) Py_INCREF(r) 497 | #define __Pyx_DECREF(r) Py_DECREF(r) 498 | #define __Pyx_GOTREF(r) 499 | #define __Pyx_GIVEREF(r) 500 | #define __Pyx_XINCREF(r) Py_XINCREF(r) 501 | #define __Pyx_XDECREF(r) Py_XDECREF(r) 502 | #define __Pyx_XGOTREF(r) 503 | #define __Pyx_XGIVEREF(r) 504 | #endif 505 | #define __Pyx_XDECREF_SET(r, v) do { \ 506 | PyObject *tmp = (PyObject *) r; \ 507 | r = v; __Pyx_XDECREF(tmp); \ 508 | } while (0) 509 | #define __Pyx_DECREF_SET(r, v) do { \ 510 | PyObject *tmp = (PyObject *) r; \ 511 | r = v; __Pyx_DECREF(tmp); \ 512 | } while (0) 513 | #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) 514 | #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) 515 | 516 | static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, 517 | Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); 518 | 519 | static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); 520 | 521 | static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ 522 | PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ 523 | const char* function_name); 524 | 525 | #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ 526 | (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ 527 | __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \ 528 | (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \ 529 | __Pyx_GetItemInt_Generic(o, to_py_func(i)))) 530 | #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ 531 | (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ 532 | __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ 533 | (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) 534 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, 535 | int wraparound, int boundscheck); 536 | #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ 537 | (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ 538 | __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ 539 | (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) 540 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, 541 | int wraparound, int boundscheck); 542 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); 543 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, 544 | int is_list, int wraparound, int boundscheck); 545 | 546 | static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, 547 | const char *name, int exact); 548 | 549 | #if CYTHON_COMPILING_IN_CPYTHON 550 | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { 551 | PyTypeObject* tp = Py_TYPE(obj); 552 | if (likely(tp->tp_getattro)) 553 | return tp->tp_getattro(obj, attr_name); 554 | #if PY_MAJOR_VERSION < 3 555 | if (likely(tp->tp_getattr)) 556 | return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); 557 | #endif 558 | return PyObject_GetAttr(obj, attr_name); 559 | } 560 | #else 561 | #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) 562 | #endif 563 | 564 | #if CYTHON_COMPILING_IN_CPYTHON 565 | #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) 566 | static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { 567 | PyTypeObject* tp = Py_TYPE(obj); 568 | if (likely(tp->tp_setattro)) 569 | return tp->tp_setattro(obj, attr_name, value); 570 | #if PY_MAJOR_VERSION < 3 571 | if (likely(tp->tp_setattr)) 572 | return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); 573 | #endif 574 | return PyObject_SetAttr(obj, attr_name, value); 575 | } 576 | #else 577 | #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) 578 | #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) 579 | #endif 580 | 581 | #ifndef __PYX_FORCE_INIT_THREADS 582 | #define __PYX_FORCE_INIT_THREADS 0 583 | #endif 584 | 585 | static PyObject *__Pyx_GetBuiltinName(PyObject *name); 586 | 587 | static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); 588 | 589 | #if CYTHON_COMPILING_IN_CPYTHON 590 | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); 591 | #else 592 | #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) 593 | #endif 594 | 595 | #if CYTHON_COMPILING_IN_CPYTHON 596 | static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { 597 | PyListObject* L = (PyListObject*) list; 598 | Py_ssize_t len = Py_SIZE(list); 599 | if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { 600 | Py_INCREF(x); 601 | PyList_SET_ITEM(list, len, x); 602 | Py_SIZE(list) = len+1; 603 | return 0; 604 | } 605 | return PyList_Append(list, x); 606 | } 607 | #else 608 | #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) 609 | #endif 610 | 611 | #if CYTHON_COMPILING_IN_CPYTHON 612 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); 613 | #endif 614 | 615 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); 616 | 617 | static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); 618 | 619 | static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); 620 | 621 | #if CYTHON_COMPILING_IN_CPYTHON 622 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); 623 | #else 624 | #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) 625 | #endif 626 | 627 | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); 628 | 629 | typedef struct { 630 | int code_line; 631 | PyCodeObject* code_object; 632 | } __Pyx_CodeObjectCacheEntry; 633 | struct __Pyx_CodeObjectCache { 634 | int count; 635 | int max_count; 636 | __Pyx_CodeObjectCacheEntry* entries; 637 | }; 638 | static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; 639 | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); 640 | static PyCodeObject *__pyx_find_code_object(int code_line); 641 | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); 642 | 643 | static void __Pyx_AddTraceback(const char *funcname, int c_line, 644 | int py_line, const char *filename); 645 | 646 | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); 647 | 648 | static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); 649 | 650 | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); 651 | 652 | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); 653 | 654 | static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); 655 | 656 | static int __Pyx_check_binary_version(void); 657 | 658 | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); 659 | 660 | 661 | /* Module declarations from 'particles' */ 662 | static PyTypeObject *__pyx_ptype_9particles_particle = 0; 663 | static PyObject *__pyx_f_9particles_create_visual(PyObject *, PyObject *, struct __pyx_opt_args_9particles_create_visual *__pyx_optional_args); /*proto*/ 664 | #define __Pyx_MODULE_NAME "particles" 665 | int __pyx_module_is_main_particles = 0; 666 | 667 | /* Implementation of 'particles' */ 668 | static int __pyx_pf_9particles_8particle___init__(struct __pyx_obj_9particles_particle *__pyx_v_self, PyObject *__pyx_v_ent, PyObject *__pyx_v_vel, PyObject *__pyx_v_lifespan, PyObject *__pyx_v_drag, PyObject *__pyx_v_gravity); /* proto */ 669 | static PyObject *__pyx_pf_9particles_8particle_2entity_id(struct __pyx_obj_9particles_particle *__pyx_v_self); /* proto */ 670 | static PyObject *__pyx_pf_9particles_8particle_4updateme(struct __pyx_obj_9particles_particle *__pyx_v_self, PyObject *__pyx_v_ents, float __pyx_v_dt); /* proto */ 671 | static PyObject *__pyx_pf_9particles_spawn_particles_at(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pos, PyObject *__pyx_v_vel, PyObject *__pyx_v_color, float __pyx_v_lifespan, float __pyx_v_drag, PyObject *__pyx_v_gravity, float __pyx_v_radius); /* proto */ 672 | static PyObject *__pyx_pf_9particles_2update(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_dt); /* proto */ 673 | static PyObject *__pyx_tp_new_9particles_particle(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ 674 | static char __pyx_k_a[] = "a"; 675 | static char __pyx_k_p[] = "p"; 676 | static char __pyx_k_r[] = "r"; 677 | static char __pyx_k_s[] = "s"; 678 | static char __pyx_k_x[] = "x"; 679 | static char __pyx_k_y[] = "y"; 680 | static char __pyx_k_dt[] = "dt"; 681 | static char __pyx_k_ls[] = "ls"; 682 | static char __pyx_k_ent[] = "ent"; 683 | static char __pyx_k_pid[] = "pid"; 684 | static char __pyx_k_pos[] = "pos"; 685 | static char __pyx_k_vel[] = "vel"; 686 | static char __pyx_k_drag[] = "drag"; 687 | static char __pyx_k_ents[] = "ents"; 688 | static char __pyx_k_main[] = "__main__"; 689 | static char __pyx_k_newp[] = "newp"; 690 | static char __pyx_k_size[] = "size"; 691 | static char __pyx_k_test[] = "__test__"; 692 | static char __pyx_k_color[] = "color"; 693 | static char __pyx_k_scale[] = "scale"; 694 | static char __pyx_k_append[] = "append"; 695 | static char __pyx_k_author[] = "__author__"; 696 | static char __pyx_k_import[] = "__import__"; 697 | static char __pyx_k_radius[] = "radius"; 698 | static char __pyx_k_random[] = "random"; 699 | static char __pyx_k_remove[] = "remove"; 700 | static char __pyx_k_rotate[] = "rotate"; 701 | static char __pyx_k_update[] = "update"; 702 | static char __pyx_k_chozabu[] = "chozabu"; 703 | static char __pyx_k_gameref[] = "gameref"; 704 | static char __pyx_k_gravity[] = "gravity"; 705 | static char __pyx_k_remlist[] = "remlist"; 706 | static char __pyx_k_texture[] = "texture"; 707 | static char __pyx_k_entities[] = "entities"; 708 | static char __pyx_k_lifespan[] = "lifespan"; 709 | static char __pyx_k_particle[] = "particle"; 710 | static char __pyx_k_position[] = "position"; 711 | static char __pyx_k_renderer[] = "renderer"; 712 | static char __pyx_k_updateme[] = "updateme"; 713 | static char __pyx_k_entity_id[] = "entity_id"; 714 | static char __pyx_k_gameworld[] = "gameworld"; 715 | static char __pyx_k_particles[] = "particles"; 716 | static char __pyx_k_init_entity[] = "init_entity"; 717 | static char __pyx_k_remove_entity[] = "remove_entity"; 718 | static char __pyx_k_enable_particles[] = "enable_particles"; 719 | static char __pyx_k_spawn_particles_at[] = "spawn_particles_at"; 720 | static char __pyx_k_home_chozabu_git_kivent_simple[] = "/home/chozabu/git/kivent_simple_particles/particles.pyx"; 721 | static PyObject *__pyx_n_s_a; 722 | static PyObject *__pyx_n_s_append; 723 | static PyObject *__pyx_n_s_author; 724 | static PyObject *__pyx_n_s_chozabu; 725 | static PyObject *__pyx_n_s_color; 726 | static PyObject *__pyx_n_s_drag; 727 | static PyObject *__pyx_n_s_dt; 728 | static PyObject *__pyx_n_s_enable_particles; 729 | static PyObject *__pyx_n_s_ent; 730 | static PyObject *__pyx_n_s_entities; 731 | static PyObject *__pyx_n_s_entity_id; 732 | static PyObject *__pyx_n_s_ents; 733 | static PyObject *__pyx_n_s_gameref; 734 | static PyObject *__pyx_n_s_gameworld; 735 | static PyObject *__pyx_n_s_gravity; 736 | static PyObject *__pyx_kp_s_home_chozabu_git_kivent_simple; 737 | static PyObject *__pyx_n_s_import; 738 | static PyObject *__pyx_n_s_init_entity; 739 | static PyObject *__pyx_n_s_lifespan; 740 | static PyObject *__pyx_n_s_ls; 741 | static PyObject *__pyx_n_s_main; 742 | static PyObject *__pyx_n_s_newp; 743 | static PyObject *__pyx_n_s_p; 744 | static PyObject *__pyx_n_s_particle; 745 | static PyObject *__pyx_n_s_particles; 746 | static PyObject *__pyx_n_s_pid; 747 | static PyObject *__pyx_n_s_pos; 748 | static PyObject *__pyx_n_s_position; 749 | static PyObject *__pyx_n_s_r; 750 | static PyObject *__pyx_n_s_radius; 751 | static PyObject *__pyx_n_s_random; 752 | static PyObject *__pyx_n_s_remlist; 753 | static PyObject *__pyx_n_s_remove; 754 | static PyObject *__pyx_n_s_remove_entity; 755 | static PyObject *__pyx_n_s_renderer; 756 | static PyObject *__pyx_n_s_rotate; 757 | static PyObject *__pyx_n_s_s; 758 | static PyObject *__pyx_n_s_scale; 759 | static PyObject *__pyx_n_s_size; 760 | static PyObject *__pyx_n_s_spawn_particles_at; 761 | static PyObject *__pyx_n_s_test; 762 | static PyObject *__pyx_n_s_texture; 763 | static PyObject *__pyx_n_s_update; 764 | static PyObject *__pyx_n_s_updateme; 765 | static PyObject *__pyx_n_s_vel; 766 | static PyObject *__pyx_n_s_x; 767 | static PyObject *__pyx_n_s_y; 768 | static PyObject *__pyx_float_1_; 769 | static PyObject *__pyx_int_0; 770 | static PyObject *__pyx_int_1; 771 | static PyObject *__pyx_tuple_; 772 | static PyObject *__pyx_tuple__2; 773 | static PyObject *__pyx_tuple__3; 774 | static PyObject *__pyx_tuple__4; 775 | static PyObject *__pyx_tuple__6; 776 | static PyObject *__pyx_codeobj__5; 777 | static PyObject *__pyx_codeobj__7; 778 | 779 | /* "particles.pyx":12 780 | * 781 | * cdef class particle: 782 | * def __init__(self, ent, vel,lifespan, drag, gravity): # <<<<<<<<<<<<<< 783 | * self.ent=ent 784 | * self.vx=vel[0] 785 | */ 786 | 787 | /* Python wrapper */ 788 | static int __pyx_pw_9particles_8particle_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 789 | static int __pyx_pw_9particles_8particle_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 790 | PyObject *__pyx_v_ent = 0; 791 | PyObject *__pyx_v_vel = 0; 792 | PyObject *__pyx_v_lifespan = 0; 793 | PyObject *__pyx_v_drag = 0; 794 | PyObject *__pyx_v_gravity = 0; 795 | int __pyx_lineno = 0; 796 | const char *__pyx_filename = NULL; 797 | int __pyx_clineno = 0; 798 | int __pyx_r; 799 | __Pyx_RefNannyDeclarations 800 | __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); 801 | { 802 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ent,&__pyx_n_s_vel,&__pyx_n_s_lifespan,&__pyx_n_s_drag,&__pyx_n_s_gravity,0}; 803 | PyObject* values[5] = {0,0,0,0,0}; 804 | if (unlikely(__pyx_kwds)) { 805 | Py_ssize_t kw_args; 806 | const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); 807 | switch (pos_args) { 808 | case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); 809 | case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 810 | case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 811 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 812 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 813 | case 0: break; 814 | default: goto __pyx_L5_argtuple_error; 815 | } 816 | kw_args = PyDict_Size(__pyx_kwds); 817 | switch (pos_args) { 818 | case 0: 819 | if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ent)) != 0)) kw_args--; 820 | else goto __pyx_L5_argtuple_error; 821 | case 1: 822 | if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vel)) != 0)) kw_args--; 823 | else { 824 | __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 825 | } 826 | case 2: 827 | if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_lifespan)) != 0)) kw_args--; 828 | else { 829 | __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 830 | } 831 | case 3: 832 | if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_drag)) != 0)) kw_args--; 833 | else { 834 | __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 835 | } 836 | case 4: 837 | if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_gravity)) != 0)) kw_args--; 838 | else { 839 | __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 840 | } 841 | } 842 | if (unlikely(kw_args > 0)) { 843 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 844 | } 845 | } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { 846 | goto __pyx_L5_argtuple_error; 847 | } else { 848 | values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 849 | values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 850 | values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 851 | values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 852 | values[4] = PyTuple_GET_ITEM(__pyx_args, 4); 853 | } 854 | __pyx_v_ent = values[0]; 855 | __pyx_v_vel = values[1]; 856 | __pyx_v_lifespan = values[2]; 857 | __pyx_v_drag = values[3]; 858 | __pyx_v_gravity = values[4]; 859 | } 860 | goto __pyx_L4_argument_unpacking_done; 861 | __pyx_L5_argtuple_error:; 862 | __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 863 | __pyx_L3_error:; 864 | __Pyx_AddTraceback("particles.particle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); 865 | __Pyx_RefNannyFinishContext(); 866 | return -1; 867 | __pyx_L4_argument_unpacking_done:; 868 | __pyx_r = __pyx_pf_9particles_8particle___init__(((struct __pyx_obj_9particles_particle *)__pyx_v_self), __pyx_v_ent, __pyx_v_vel, __pyx_v_lifespan, __pyx_v_drag, __pyx_v_gravity); 869 | 870 | /* function exit code */ 871 | __Pyx_RefNannyFinishContext(); 872 | return __pyx_r; 873 | } 874 | 875 | static int __pyx_pf_9particles_8particle___init__(struct __pyx_obj_9particles_particle *__pyx_v_self, PyObject *__pyx_v_ent, PyObject *__pyx_v_vel, PyObject *__pyx_v_lifespan, PyObject *__pyx_v_drag, PyObject *__pyx_v_gravity) { 876 | int __pyx_r; 877 | __Pyx_RefNannyDeclarations 878 | int __pyx_t_1; 879 | PyObject *__pyx_t_2 = NULL; 880 | float __pyx_t_3; 881 | int __pyx_lineno = 0; 882 | const char *__pyx_filename = NULL; 883 | int __pyx_clineno = 0; 884 | __Pyx_RefNannySetupContext("__init__", 0); 885 | 886 | /* "particles.pyx":13 887 | * cdef class particle: 888 | * def __init__(self, ent, vel,lifespan, drag, gravity): 889 | * self.ent=ent # <<<<<<<<<<<<<< 890 | * self.vx=vel[0] 891 | * self.vy=vel[1] 892 | */ 893 | __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_ent); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 894 | __pyx_v_self->ent = __pyx_t_1; 895 | 896 | /* "particles.pyx":14 897 | * def __init__(self, ent, vel,lifespan, drag, gravity): 898 | * self.ent=ent 899 | * self.vx=vel[0] # <<<<<<<<<<<<<< 900 | * self.vy=vel[1] 901 | * self.lifespan=lifespan 902 | */ 903 | __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_vel, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 904 | __Pyx_GOTREF(__pyx_t_2); 905 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 906 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 907 | __pyx_v_self->vx = __pyx_t_3; 908 | 909 | /* "particles.pyx":15 910 | * self.ent=ent 911 | * self.vx=vel[0] 912 | * self.vy=vel[1] # <<<<<<<<<<<<<< 913 | * self.lifespan=lifespan 914 | * self.maxlifespan=lifespan 915 | */ 916 | __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_vel, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 917 | __Pyx_GOTREF(__pyx_t_2); 918 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 919 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 920 | __pyx_v_self->vy = __pyx_t_3; 921 | 922 | /* "particles.pyx":16 923 | * self.vx=vel[0] 924 | * self.vy=vel[1] 925 | * self.lifespan=lifespan # <<<<<<<<<<<<<< 926 | * self.maxlifespan=lifespan 927 | * self.drag = drag 928 | */ 929 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_lifespan); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 930 | __pyx_v_self->lifespan = __pyx_t_3; 931 | 932 | /* "particles.pyx":17 933 | * self.vy=vel[1] 934 | * self.lifespan=lifespan 935 | * self.maxlifespan=lifespan # <<<<<<<<<<<<<< 936 | * self.drag = drag 937 | * self.gx=gravity[0] 938 | */ 939 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_lifespan); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 940 | __pyx_v_self->maxlifespan = __pyx_t_3; 941 | 942 | /* "particles.pyx":18 943 | * self.lifespan=lifespan 944 | * self.maxlifespan=lifespan 945 | * self.drag = drag # <<<<<<<<<<<<<< 946 | * self.gx=gravity[0] 947 | * self.gy=gravity[1] 948 | */ 949 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_drag); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 950 | __pyx_v_self->drag = __pyx_t_3; 951 | 952 | /* "particles.pyx":19 953 | * self.maxlifespan=lifespan 954 | * self.drag = drag 955 | * self.gx=gravity[0] # <<<<<<<<<<<<<< 956 | * self.gy=gravity[1] 957 | * def entity_id(self): 958 | */ 959 | __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_gravity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 960 | __Pyx_GOTREF(__pyx_t_2); 961 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 962 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 963 | __pyx_v_self->gx = __pyx_t_3; 964 | 965 | /* "particles.pyx":20 966 | * self.drag = drag 967 | * self.gx=gravity[0] 968 | * self.gy=gravity[1] # <<<<<<<<<<<<<< 969 | * def entity_id(self): 970 | * return self.ent 971 | */ 972 | __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_gravity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 973 | __Pyx_GOTREF(__pyx_t_2); 974 | __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 975 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 976 | __pyx_v_self->gy = __pyx_t_3; 977 | 978 | /* "particles.pyx":12 979 | * 980 | * cdef class particle: 981 | * def __init__(self, ent, vel,lifespan, drag, gravity): # <<<<<<<<<<<<<< 982 | * self.ent=ent 983 | * self.vx=vel[0] 984 | */ 985 | 986 | /* function exit code */ 987 | __pyx_r = 0; 988 | goto __pyx_L0; 989 | __pyx_L1_error:; 990 | __Pyx_XDECREF(__pyx_t_2); 991 | __Pyx_AddTraceback("particles.particle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); 992 | __pyx_r = -1; 993 | __pyx_L0:; 994 | __Pyx_RefNannyFinishContext(); 995 | return __pyx_r; 996 | } 997 | 998 | /* "particles.pyx":21 999 | * self.gx=gravity[0] 1000 | * self.gy=gravity[1] 1001 | * def entity_id(self): # <<<<<<<<<<<<<< 1002 | * return self.ent 1003 | * def updateme(self, list ents, float dt): 1004 | */ 1005 | 1006 | /* Python wrapper */ 1007 | static PyObject *__pyx_pw_9particles_8particle_3entity_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 1008 | static PyObject *__pyx_pw_9particles_8particle_3entity_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { 1009 | PyObject *__pyx_r = 0; 1010 | __Pyx_RefNannyDeclarations 1011 | __Pyx_RefNannySetupContext("entity_id (wrapper)", 0); 1012 | __pyx_r = __pyx_pf_9particles_8particle_2entity_id(((struct __pyx_obj_9particles_particle *)__pyx_v_self)); 1013 | 1014 | /* function exit code */ 1015 | __Pyx_RefNannyFinishContext(); 1016 | return __pyx_r; 1017 | } 1018 | 1019 | static PyObject *__pyx_pf_9particles_8particle_2entity_id(struct __pyx_obj_9particles_particle *__pyx_v_self) { 1020 | PyObject *__pyx_r = NULL; 1021 | __Pyx_RefNannyDeclarations 1022 | PyObject *__pyx_t_1 = NULL; 1023 | int __pyx_lineno = 0; 1024 | const char *__pyx_filename = NULL; 1025 | int __pyx_clineno = 0; 1026 | __Pyx_RefNannySetupContext("entity_id", 0); 1027 | 1028 | /* "particles.pyx":22 1029 | * self.gy=gravity[1] 1030 | * def entity_id(self): 1031 | * return self.ent # <<<<<<<<<<<<<< 1032 | * def updateme(self, list ents, float dt): 1033 | * cdef float ls = self.lifespan 1034 | */ 1035 | __Pyx_XDECREF(__pyx_r); 1036 | __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->ent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1037 | __Pyx_GOTREF(__pyx_t_1); 1038 | __pyx_r = __pyx_t_1; 1039 | __pyx_t_1 = 0; 1040 | goto __pyx_L0; 1041 | 1042 | /* "particles.pyx":21 1043 | * self.gx=gravity[0] 1044 | * self.gy=gravity[1] 1045 | * def entity_id(self): # <<<<<<<<<<<<<< 1046 | * return self.ent 1047 | * def updateme(self, list ents, float dt): 1048 | */ 1049 | 1050 | /* function exit code */ 1051 | __pyx_L1_error:; 1052 | __Pyx_XDECREF(__pyx_t_1); 1053 | __Pyx_AddTraceback("particles.particle.entity_id", __pyx_clineno, __pyx_lineno, __pyx_filename); 1054 | __pyx_r = NULL; 1055 | __pyx_L0:; 1056 | __Pyx_XGIVEREF(__pyx_r); 1057 | __Pyx_RefNannyFinishContext(); 1058 | return __pyx_r; 1059 | } 1060 | 1061 | /* "particles.pyx":23 1062 | * def entity_id(self): 1063 | * return self.ent 1064 | * def updateme(self, list ents, float dt): # <<<<<<<<<<<<<< 1065 | * cdef float ls = self.lifespan 1066 | * cdef float mls = self.maxlifespan 1067 | */ 1068 | 1069 | /* Python wrapper */ 1070 | static PyObject *__pyx_pw_9particles_8particle_5updateme(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1071 | static PyObject *__pyx_pw_9particles_8particle_5updateme(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1072 | PyObject *__pyx_v_ents = 0; 1073 | float __pyx_v_dt; 1074 | int __pyx_lineno = 0; 1075 | const char *__pyx_filename = NULL; 1076 | int __pyx_clineno = 0; 1077 | PyObject *__pyx_r = 0; 1078 | __Pyx_RefNannyDeclarations 1079 | __Pyx_RefNannySetupContext("updateme (wrapper)", 0); 1080 | { 1081 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ents,&__pyx_n_s_dt,0}; 1082 | PyObject* values[2] = {0,0}; 1083 | if (unlikely(__pyx_kwds)) { 1084 | Py_ssize_t kw_args; 1085 | const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); 1086 | switch (pos_args) { 1087 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1088 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1089 | case 0: break; 1090 | default: goto __pyx_L5_argtuple_error; 1091 | } 1092 | kw_args = PyDict_Size(__pyx_kwds); 1093 | switch (pos_args) { 1094 | case 0: 1095 | if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ents)) != 0)) kw_args--; 1096 | else goto __pyx_L5_argtuple_error; 1097 | case 1: 1098 | if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--; 1099 | else { 1100 | __Pyx_RaiseArgtupleInvalid("updateme", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1101 | } 1102 | } 1103 | if (unlikely(kw_args > 0)) { 1104 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "updateme") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1105 | } 1106 | } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { 1107 | goto __pyx_L5_argtuple_error; 1108 | } else { 1109 | values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1110 | values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1111 | } 1112 | __pyx_v_ents = ((PyObject*)values[0]); 1113 | __pyx_v_dt = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_dt == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1114 | } 1115 | goto __pyx_L4_argument_unpacking_done; 1116 | __pyx_L5_argtuple_error:; 1117 | __Pyx_RaiseArgtupleInvalid("updateme", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1118 | __pyx_L3_error:; 1119 | __Pyx_AddTraceback("particles.particle.updateme", __pyx_clineno, __pyx_lineno, __pyx_filename); 1120 | __Pyx_RefNannyFinishContext(); 1121 | return NULL; 1122 | __pyx_L4_argument_unpacking_done:; 1123 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ents), (&PyList_Type), 1, "ents", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1124 | __pyx_r = __pyx_pf_9particles_8particle_4updateme(((struct __pyx_obj_9particles_particle *)__pyx_v_self), __pyx_v_ents, __pyx_v_dt); 1125 | 1126 | /* function exit code */ 1127 | goto __pyx_L0; 1128 | __pyx_L1_error:; 1129 | __pyx_r = NULL; 1130 | __pyx_L0:; 1131 | __Pyx_RefNannyFinishContext(); 1132 | return __pyx_r; 1133 | } 1134 | 1135 | static PyObject *__pyx_pf_9particles_8particle_4updateme(struct __pyx_obj_9particles_particle *__pyx_v_self, PyObject *__pyx_v_ents, float __pyx_v_dt) { 1136 | float __pyx_v_ls; 1137 | float __pyx_v_mls; 1138 | PyObject *__pyx_v_ent = NULL; 1139 | PyObject *__pyx_r = NULL; 1140 | __Pyx_RefNannyDeclarations 1141 | float __pyx_t_1; 1142 | PyObject *__pyx_t_2 = NULL; 1143 | PyObject *__pyx_t_3 = NULL; 1144 | PyObject *__pyx_t_4 = NULL; 1145 | PyObject *__pyx_t_5 = NULL; 1146 | double __pyx_t_6; 1147 | int __pyx_lineno = 0; 1148 | const char *__pyx_filename = NULL; 1149 | int __pyx_clineno = 0; 1150 | __Pyx_RefNannySetupContext("updateme", 0); 1151 | 1152 | /* "particles.pyx":24 1153 | * return self.ent 1154 | * def updateme(self, list ents, float dt): 1155 | * cdef float ls = self.lifespan # <<<<<<<<<<<<<< 1156 | * cdef float mls = self.maxlifespan 1157 | * ent = ents[self.ent] 1158 | */ 1159 | __pyx_t_1 = __pyx_v_self->lifespan; 1160 | __pyx_v_ls = __pyx_t_1; 1161 | 1162 | /* "particles.pyx":25 1163 | * def updateme(self, list ents, float dt): 1164 | * cdef float ls = self.lifespan 1165 | * cdef float mls = self.maxlifespan # <<<<<<<<<<<<<< 1166 | * ent = ents[self.ent] 1167 | * self.vx = self.vx*self.drag+self.gx 1168 | */ 1169 | __pyx_t_1 = __pyx_v_self->maxlifespan; 1170 | __pyx_v_mls = __pyx_t_1; 1171 | 1172 | /* "particles.pyx":26 1173 | * cdef float ls = self.lifespan 1174 | * cdef float mls = self.maxlifespan 1175 | * ent = ents[self.ent] # <<<<<<<<<<<<<< 1176 | * self.vx = self.vx*self.drag+self.gx 1177 | * self.vy = self.vy*self.drag+self.gy 1178 | */ 1179 | if (unlikely(__pyx_v_ents == Py_None)) { 1180 | PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); 1181 | {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1182 | } 1183 | __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_ents, __pyx_v_self->ent, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 1184 | __Pyx_GOTREF(__pyx_t_2); 1185 | __pyx_v_ent = __pyx_t_2; 1186 | __pyx_t_2 = 0; 1187 | 1188 | /* "particles.pyx":27 1189 | * cdef float mls = self.maxlifespan 1190 | * ent = ents[self.ent] 1191 | * self.vx = self.vx*self.drag+self.gx # <<<<<<<<<<<<<< 1192 | * self.vy = self.vy*self.drag+self.gy 1193 | * ent.position.x+=self.vx 1194 | */ 1195 | __pyx_v_self->vx = ((__pyx_v_self->vx * __pyx_v_self->drag) + __pyx_v_self->gx); 1196 | 1197 | /* "particles.pyx":28 1198 | * ent = ents[self.ent] 1199 | * self.vx = self.vx*self.drag+self.gx 1200 | * self.vy = self.vy*self.drag+self.gy # <<<<<<<<<<<<<< 1201 | * ent.position.x+=self.vx 1202 | * ent.position.y+=self.vy 1203 | */ 1204 | __pyx_v_self->vy = ((__pyx_v_self->vy * __pyx_v_self->drag) + __pyx_v_self->gy); 1205 | 1206 | /* "particles.pyx":29 1207 | * self.vx = self.vx*self.drag+self.gx 1208 | * self.vy = self.vy*self.drag+self.gy 1209 | * ent.position.x+=self.vx # <<<<<<<<<<<<<< 1210 | * ent.position.y+=self.vy 1211 | * ent.color.a=ls/mls 1212 | */ 1213 | __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ent, __pyx_n_s_position); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1214 | __Pyx_GOTREF(__pyx_t_2); 1215 | __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1216 | __Pyx_GOTREF(__pyx_t_3); 1217 | __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->vx); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1218 | __Pyx_GOTREF(__pyx_t_4); 1219 | __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1220 | __Pyx_GOTREF(__pyx_t_5); 1221 | __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 1222 | __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; 1223 | if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_x, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1224 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1225 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1226 | 1227 | /* "particles.pyx":30 1228 | * self.vy = self.vy*self.drag+self.gy 1229 | * ent.position.x+=self.vx 1230 | * ent.position.y+=self.vy # <<<<<<<<<<<<<< 1231 | * ent.color.a=ls/mls 1232 | * ent.scale.s=ls/(mls*.5) 1233 | */ 1234 | __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ent, __pyx_n_s_position); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1235 | __Pyx_GOTREF(__pyx_t_2); 1236 | __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_y); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1237 | __Pyx_GOTREF(__pyx_t_5); 1238 | __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->vy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1239 | __Pyx_GOTREF(__pyx_t_4); 1240 | __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1241 | __Pyx_GOTREF(__pyx_t_3); 1242 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1243 | __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; 1244 | if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_y, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1245 | __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 1246 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1247 | 1248 | /* "particles.pyx":31 1249 | * ent.position.x+=self.vx 1250 | * ent.position.y+=self.vy 1251 | * ent.color.a=ls/mls # <<<<<<<<<<<<<< 1252 | * ent.scale.s=ls/(mls*.5) 1253 | * self.lifespan-=dt 1254 | */ 1255 | if (unlikely(__pyx_v_mls == 0)) { 1256 | #ifdef WITH_THREAD 1257 | PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); 1258 | #endif 1259 | PyErr_SetString(PyExc_ZeroDivisionError, "float division"); 1260 | #ifdef WITH_THREAD 1261 | PyGILState_Release(__pyx_gilstate_save); 1262 | #endif 1263 | {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1264 | } 1265 | __pyx_t_2 = PyFloat_FromDouble((__pyx_v_ls / __pyx_v_mls)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1266 | __Pyx_GOTREF(__pyx_t_2); 1267 | __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ent, __pyx_n_s_color); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1268 | __Pyx_GOTREF(__pyx_t_3); 1269 | if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_a, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1270 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1271 | __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 1272 | 1273 | /* "particles.pyx":32 1274 | * ent.position.y+=self.vy 1275 | * ent.color.a=ls/mls 1276 | * ent.scale.s=ls/(mls*.5) # <<<<<<<<<<<<<< 1277 | * self.lifespan-=dt 1278 | * return self.lifespan 1279 | */ 1280 | __pyx_t_6 = (__pyx_v_mls * .5); 1281 | if (unlikely(__pyx_t_6 == 0)) { 1282 | #ifdef WITH_THREAD 1283 | PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); 1284 | #endif 1285 | PyErr_SetString(PyExc_ZeroDivisionError, "float division"); 1286 | #ifdef WITH_THREAD 1287 | PyGILState_Release(__pyx_gilstate_save); 1288 | #endif 1289 | {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1290 | } 1291 | __pyx_t_3 = PyFloat_FromDouble((__pyx_v_ls / __pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1292 | __Pyx_GOTREF(__pyx_t_3); 1293 | __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ent, __pyx_n_s_scale); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1294 | __Pyx_GOTREF(__pyx_t_2); 1295 | if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_s, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1296 | __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 1297 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1298 | 1299 | /* "particles.pyx":33 1300 | * ent.color.a=ls/mls 1301 | * ent.scale.s=ls/(mls*.5) 1302 | * self.lifespan-=dt # <<<<<<<<<<<<<< 1303 | * return self.lifespan 1304 | * 1305 | */ 1306 | __pyx_v_self->lifespan = (__pyx_v_self->lifespan - __pyx_v_dt); 1307 | 1308 | /* "particles.pyx":34 1309 | * ent.scale.s=ls/(mls*.5) 1310 | * self.lifespan-=dt 1311 | * return self.lifespan # <<<<<<<<<<<<<< 1312 | * 1313 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): 1314 | */ 1315 | __Pyx_XDECREF(__pyx_r); 1316 | __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->lifespan); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1317 | __Pyx_GOTREF(__pyx_t_2); 1318 | __pyx_r = __pyx_t_2; 1319 | __pyx_t_2 = 0; 1320 | goto __pyx_L0; 1321 | 1322 | /* "particles.pyx":23 1323 | * def entity_id(self): 1324 | * return self.ent 1325 | * def updateme(self, list ents, float dt): # <<<<<<<<<<<<<< 1326 | * cdef float ls = self.lifespan 1327 | * cdef float mls = self.maxlifespan 1328 | */ 1329 | 1330 | /* function exit code */ 1331 | __pyx_L1_error:; 1332 | __Pyx_XDECREF(__pyx_t_2); 1333 | __Pyx_XDECREF(__pyx_t_3); 1334 | __Pyx_XDECREF(__pyx_t_4); 1335 | __Pyx_XDECREF(__pyx_t_5); 1336 | __Pyx_AddTraceback("particles.particle.updateme", __pyx_clineno, __pyx_lineno, __pyx_filename); 1337 | __pyx_r = NULL; 1338 | __pyx_L0:; 1339 | __Pyx_XDECREF(__pyx_v_ent); 1340 | __Pyx_XGIVEREF(__pyx_r); 1341 | __Pyx_RefNannyFinishContext(); 1342 | return __pyx_r; 1343 | } 1344 | 1345 | /* "particles.pyx":36 1346 | * return self.lifespan 1347 | * 1348 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): # <<<<<<<<<<<<<< 1349 | * if enable_particles==0:return 1350 | * pid = create_visual(pos, color=color, radius=radius*.5) 1351 | */ 1352 | 1353 | /* Python wrapper */ 1354 | static PyObject *__pyx_pw_9particles_1spawn_particles_at(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1355 | static PyMethodDef __pyx_mdef_9particles_1spawn_particles_at = {"spawn_particles_at", (PyCFunction)__pyx_pw_9particles_1spawn_particles_at, METH_VARARGS|METH_KEYWORDS, 0}; 1356 | static PyObject *__pyx_pw_9particles_1spawn_particles_at(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1357 | PyObject *__pyx_v_pos = 0; 1358 | PyObject *__pyx_v_vel = 0; 1359 | PyObject *__pyx_v_color = 0; 1360 | float __pyx_v_lifespan; 1361 | float __pyx_v_drag; 1362 | PyObject *__pyx_v_gravity = 0; 1363 | float __pyx_v_radius; 1364 | int __pyx_lineno = 0; 1365 | const char *__pyx_filename = NULL; 1366 | int __pyx_clineno = 0; 1367 | PyObject *__pyx_r = 0; 1368 | __Pyx_RefNannyDeclarations 1369 | __Pyx_RefNannySetupContext("spawn_particles_at (wrapper)", 0); 1370 | { 1371 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pos,&__pyx_n_s_vel,&__pyx_n_s_color,&__pyx_n_s_lifespan,&__pyx_n_s_drag,&__pyx_n_s_gravity,&__pyx_n_s_radius,0}; 1372 | PyObject* values[7] = {0,0,0,0,0,0,0}; 1373 | values[1] = ((PyObject *)__pyx_tuple_); 1374 | values[2] = ((PyObject *)__pyx_tuple__2); 1375 | values[5] = ((PyObject *)__pyx_tuple__3); 1376 | if (unlikely(__pyx_kwds)) { 1377 | Py_ssize_t kw_args; 1378 | const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); 1379 | switch (pos_args) { 1380 | case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); 1381 | case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); 1382 | case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); 1383 | case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 1384 | case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 1385 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1386 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1387 | case 0: break; 1388 | default: goto __pyx_L5_argtuple_error; 1389 | } 1390 | kw_args = PyDict_Size(__pyx_kwds); 1391 | switch (pos_args) { 1392 | case 0: 1393 | if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--; 1394 | else goto __pyx_L5_argtuple_error; 1395 | case 1: 1396 | if (kw_args > 0) { 1397 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vel); 1398 | if (value) { values[1] = value; kw_args--; } 1399 | } 1400 | case 2: 1401 | if (kw_args > 0) { 1402 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_color); 1403 | if (value) { values[2] = value; kw_args--; } 1404 | } 1405 | case 3: 1406 | if (kw_args > 0) { 1407 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_lifespan); 1408 | if (value) { values[3] = value; kw_args--; } 1409 | } 1410 | case 4: 1411 | if (kw_args > 0) { 1412 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_drag); 1413 | if (value) { values[4] = value; kw_args--; } 1414 | } 1415 | case 5: 1416 | if (kw_args > 0) { 1417 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_gravity); 1418 | if (value) { values[5] = value; kw_args--; } 1419 | } 1420 | case 6: 1421 | if (kw_args > 0) { 1422 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_radius); 1423 | if (value) { values[6] = value; kw_args--; } 1424 | } 1425 | } 1426 | if (unlikely(kw_args > 0)) { 1427 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spawn_particles_at") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1428 | } 1429 | } else { 1430 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1431 | case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); 1432 | case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); 1433 | case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); 1434 | case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 1435 | case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 1436 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1437 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1438 | break; 1439 | default: goto __pyx_L5_argtuple_error; 1440 | } 1441 | } 1442 | __pyx_v_pos = values[0]; 1443 | __pyx_v_vel = values[1]; 1444 | __pyx_v_color = values[2]; 1445 | if (values[3]) { 1446 | __pyx_v_lifespan = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_lifespan == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1447 | } else { 1448 | __pyx_v_lifespan = ((float)1.); 1449 | } 1450 | if (values[4]) { 1451 | __pyx_v_drag = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_drag == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1452 | } else { 1453 | __pyx_v_drag = ((float).95); 1454 | } 1455 | __pyx_v_gravity = values[5]; 1456 | if (values[6]) { 1457 | __pyx_v_radius = __pyx_PyFloat_AsFloat(values[6]); if (unlikely((__pyx_v_radius == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1458 | } else { 1459 | __pyx_v_radius = ((float)64.0); 1460 | } 1461 | } 1462 | goto __pyx_L4_argument_unpacking_done; 1463 | __pyx_L5_argtuple_error:; 1464 | __Pyx_RaiseArgtupleInvalid("spawn_particles_at", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1465 | __pyx_L3_error:; 1466 | __Pyx_AddTraceback("particles.spawn_particles_at", __pyx_clineno, __pyx_lineno, __pyx_filename); 1467 | __Pyx_RefNannyFinishContext(); 1468 | return NULL; 1469 | __pyx_L4_argument_unpacking_done:; 1470 | __pyx_r = __pyx_pf_9particles_spawn_particles_at(__pyx_self, __pyx_v_pos, __pyx_v_vel, __pyx_v_color, __pyx_v_lifespan, __pyx_v_drag, __pyx_v_gravity, __pyx_v_radius); 1471 | 1472 | /* function exit code */ 1473 | __Pyx_RefNannyFinishContext(); 1474 | return __pyx_r; 1475 | } 1476 | 1477 | static PyObject *__pyx_pf_9particles_spawn_particles_at(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pos, PyObject *__pyx_v_vel, PyObject *__pyx_v_color, float __pyx_v_lifespan, float __pyx_v_drag, PyObject *__pyx_v_gravity, float __pyx_v_radius) { 1478 | PyObject *__pyx_v_pid = NULL; 1479 | struct __pyx_obj_9particles_particle *__pyx_v_newp = NULL; 1480 | PyObject *__pyx_r = NULL; 1481 | __Pyx_RefNannyDeclarations 1482 | PyObject *__pyx_t_1 = NULL; 1483 | PyObject *__pyx_t_2 = NULL; 1484 | int __pyx_t_3; 1485 | struct __pyx_opt_args_9particles_create_visual __pyx_t_4; 1486 | PyObject *__pyx_t_5 = NULL; 1487 | int __pyx_t_6; 1488 | int __pyx_lineno = 0; 1489 | const char *__pyx_filename = NULL; 1490 | int __pyx_clineno = 0; 1491 | __Pyx_RefNannySetupContext("spawn_particles_at", 0); 1492 | 1493 | /* "particles.pyx":37 1494 | * 1495 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): 1496 | * if enable_particles==0:return # <<<<<<<<<<<<<< 1497 | * pid = create_visual(pos, color=color, radius=radius*.5) 1498 | * #ent = gameref.gameworld.entities[pid] 1499 | */ 1500 | __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_enable_particles); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1501 | __Pyx_GOTREF(__pyx_t_1); 1502 | __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1503 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1504 | __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1505 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1506 | if (__pyx_t_3) { 1507 | __Pyx_XDECREF(__pyx_r); 1508 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1509 | goto __pyx_L0; 1510 | } 1511 | 1512 | /* "particles.pyx":38 1513 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): 1514 | * if enable_particles==0:return 1515 | * pid = create_visual(pos, color=color, radius=radius*.5) # <<<<<<<<<<<<<< 1516 | * #ent = gameref.gameworld.entities[pid] 1517 | * newp = particle(pid,vel,lifespan=lifespan, drag=drag, gravity=gravity) 1518 | */ 1519 | __pyx_t_4.__pyx_n = 1; 1520 | __pyx_t_4.radius = (__pyx_v_radius * .5); 1521 | __pyx_t_2 = __pyx_f_9particles_create_visual(__pyx_v_pos, __pyx_v_color, &__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1522 | __Pyx_GOTREF(__pyx_t_2); 1523 | __pyx_v_pid = __pyx_t_2; 1524 | __pyx_t_2 = 0; 1525 | 1526 | /* "particles.pyx":40 1527 | * pid = create_visual(pos, color=color, radius=radius*.5) 1528 | * #ent = gameref.gameworld.entities[pid] 1529 | * newp = particle(pid,vel,lifespan=lifespan, drag=drag, gravity=gravity) # <<<<<<<<<<<<<< 1530 | * particles.append(newp) 1531 | * 1532 | */ 1533 | __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1534 | __Pyx_GOTREF(__pyx_t_2); 1535 | __Pyx_INCREF(__pyx_v_pid); 1536 | PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pid); 1537 | __Pyx_GIVEREF(__pyx_v_pid); 1538 | __Pyx_INCREF(__pyx_v_vel); 1539 | PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_vel); 1540 | __Pyx_GIVEREF(__pyx_v_vel); 1541 | __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1542 | __Pyx_GOTREF(__pyx_t_1); 1543 | __pyx_t_5 = PyFloat_FromDouble(__pyx_v_lifespan); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1544 | __Pyx_GOTREF(__pyx_t_5); 1545 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_lifespan, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1546 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1547 | __pyx_t_5 = PyFloat_FromDouble(__pyx_v_drag); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1548 | __Pyx_GOTREF(__pyx_t_5); 1549 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_drag, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1550 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1551 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_gravity, __pyx_v_gravity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1552 | __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9particles_particle)), __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1553 | __Pyx_GOTREF(__pyx_t_5); 1554 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1555 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1556 | __pyx_v_newp = ((struct __pyx_obj_9particles_particle *)__pyx_t_5); 1557 | __pyx_t_5 = 0; 1558 | 1559 | /* "particles.pyx":41 1560 | * #ent = gameref.gameworld.entities[pid] 1561 | * newp = particle(pid,vel,lifespan=lifespan, drag=drag, gravity=gravity) 1562 | * particles.append(newp) # <<<<<<<<<<<<<< 1563 | * 1564 | * def update(float dt): 1565 | */ 1566 | __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_particles); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1567 | __Pyx_GOTREF(__pyx_t_5); 1568 | __pyx_t_6 = __Pyx_PyObject_Append(__pyx_t_5, ((PyObject *)__pyx_v_newp)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1569 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1570 | 1571 | /* "particles.pyx":36 1572 | * return self.lifespan 1573 | * 1574 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): # <<<<<<<<<<<<<< 1575 | * if enable_particles==0:return 1576 | * pid = create_visual(pos, color=color, radius=radius*.5) 1577 | */ 1578 | 1579 | /* function exit code */ 1580 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1581 | goto __pyx_L0; 1582 | __pyx_L1_error:; 1583 | __Pyx_XDECREF(__pyx_t_1); 1584 | __Pyx_XDECREF(__pyx_t_2); 1585 | __Pyx_XDECREF(__pyx_t_5); 1586 | __Pyx_AddTraceback("particles.spawn_particles_at", __pyx_clineno, __pyx_lineno, __pyx_filename); 1587 | __pyx_r = NULL; 1588 | __pyx_L0:; 1589 | __Pyx_XDECREF(__pyx_v_pid); 1590 | __Pyx_XDECREF((PyObject *)__pyx_v_newp); 1591 | __Pyx_XGIVEREF(__pyx_r); 1592 | __Pyx_RefNannyFinishContext(); 1593 | return __pyx_r; 1594 | } 1595 | 1596 | /* "particles.pyx":43 1597 | * particles.append(newp) 1598 | * 1599 | * def update(float dt): # <<<<<<<<<<<<<< 1600 | * global particles 1601 | * ents = gameref.gameworld.entities 1602 | */ 1603 | 1604 | /* Python wrapper */ 1605 | static PyObject *__pyx_pw_9particles_3update(PyObject *__pyx_self, PyObject *__pyx_arg_dt); /*proto*/ 1606 | static PyMethodDef __pyx_mdef_9particles_3update = {"update", (PyCFunction)__pyx_pw_9particles_3update, METH_O, 0}; 1607 | static PyObject *__pyx_pw_9particles_3update(PyObject *__pyx_self, PyObject *__pyx_arg_dt) { 1608 | float __pyx_v_dt; 1609 | int __pyx_lineno = 0; 1610 | const char *__pyx_filename = NULL; 1611 | int __pyx_clineno = 0; 1612 | PyObject *__pyx_r = 0; 1613 | __Pyx_RefNannyDeclarations 1614 | __Pyx_RefNannySetupContext("update (wrapper)", 0); 1615 | assert(__pyx_arg_dt); { 1616 | __pyx_v_dt = __pyx_PyFloat_AsFloat(__pyx_arg_dt); if (unlikely((__pyx_v_dt == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1617 | } 1618 | goto __pyx_L4_argument_unpacking_done; 1619 | __pyx_L3_error:; 1620 | __Pyx_AddTraceback("particles.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 1621 | __Pyx_RefNannyFinishContext(); 1622 | return NULL; 1623 | __pyx_L4_argument_unpacking_done:; 1624 | __pyx_r = __pyx_pf_9particles_2update(__pyx_self, ((float)__pyx_v_dt)); 1625 | 1626 | /* function exit code */ 1627 | __Pyx_RefNannyFinishContext(); 1628 | return __pyx_r; 1629 | } 1630 | 1631 | static PyObject *__pyx_pf_9particles_2update(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_dt) { 1632 | PyObject *__pyx_v_ents = NULL; 1633 | PyObject *__pyx_v_remlist = NULL; 1634 | PyObject *__pyx_v_p = NULL; 1635 | PyObject *__pyx_v_ls = NULL; 1636 | PyObject *__pyx_v_r = NULL; 1637 | PyObject *__pyx_r = NULL; 1638 | __Pyx_RefNannyDeclarations 1639 | PyObject *__pyx_t_1 = NULL; 1640 | PyObject *__pyx_t_2 = NULL; 1641 | Py_ssize_t __pyx_t_3; 1642 | PyObject *(*__pyx_t_4)(PyObject *); 1643 | PyObject *__pyx_t_5 = NULL; 1644 | PyObject *__pyx_t_6 = NULL; 1645 | PyObject *__pyx_t_7 = NULL; 1646 | Py_ssize_t __pyx_t_8; 1647 | PyObject *__pyx_t_9 = NULL; 1648 | int __pyx_t_10; 1649 | int __pyx_t_11; 1650 | int __pyx_lineno = 0; 1651 | const char *__pyx_filename = NULL; 1652 | int __pyx_clineno = 0; 1653 | __Pyx_RefNannySetupContext("update", 0); 1654 | 1655 | /* "particles.pyx":45 1656 | * def update(float dt): 1657 | * global particles 1658 | * ents = gameref.gameworld.entities # <<<<<<<<<<<<<< 1659 | * remlist=[] 1660 | * for p in particles: 1661 | */ 1662 | __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_gameref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1663 | __Pyx_GOTREF(__pyx_t_1); 1664 | __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_gameworld); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1665 | __Pyx_GOTREF(__pyx_t_2); 1666 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1667 | __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_entities); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1668 | __Pyx_GOTREF(__pyx_t_1); 1669 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1670 | __pyx_v_ents = __pyx_t_1; 1671 | __pyx_t_1 = 0; 1672 | 1673 | /* "particles.pyx":46 1674 | * global particles 1675 | * ents = gameref.gameworld.entities 1676 | * remlist=[] # <<<<<<<<<<<<<< 1677 | * for p in particles: 1678 | * ls = p.updateme(ents, dt) 1679 | */ 1680 | __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1681 | __Pyx_GOTREF(__pyx_t_1); 1682 | __pyx_v_remlist = ((PyObject*)__pyx_t_1); 1683 | __pyx_t_1 = 0; 1684 | 1685 | /* "particles.pyx":47 1686 | * ents = gameref.gameworld.entities 1687 | * remlist=[] 1688 | * for p in particles: # <<<<<<<<<<<<<< 1689 | * ls = p.updateme(ents, dt) 1690 | * #print ls 1691 | */ 1692 | __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_particles); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1693 | __Pyx_GOTREF(__pyx_t_1); 1694 | if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { 1695 | __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; 1696 | __pyx_t_4 = NULL; 1697 | } else { 1698 | __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1699 | __Pyx_GOTREF(__pyx_t_2); 1700 | __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1701 | } 1702 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1703 | for (;;) { 1704 | if (likely(!__pyx_t_4)) { 1705 | if (likely(PyList_CheckExact(__pyx_t_2))) { 1706 | if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; 1707 | #if CYTHON_COMPILING_IN_CPYTHON 1708 | __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1709 | #else 1710 | __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1711 | #endif 1712 | } else { 1713 | if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; 1714 | #if CYTHON_COMPILING_IN_CPYTHON 1715 | __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1716 | #else 1717 | __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1718 | #endif 1719 | } 1720 | } else { 1721 | __pyx_t_1 = __pyx_t_4(__pyx_t_2); 1722 | if (unlikely(!__pyx_t_1)) { 1723 | PyObject* exc_type = PyErr_Occurred(); 1724 | if (exc_type) { 1725 | if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); 1726 | else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1727 | } 1728 | break; 1729 | } 1730 | __Pyx_GOTREF(__pyx_t_1); 1731 | } 1732 | __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_1); 1733 | __pyx_t_1 = 0; 1734 | 1735 | /* "particles.pyx":48 1736 | * remlist=[] 1737 | * for p in particles: 1738 | * ls = p.updateme(ents, dt) # <<<<<<<<<<<<<< 1739 | * #print ls 1740 | * if ls<0: 1741 | */ 1742 | __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_updateme); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1743 | __Pyx_GOTREF(__pyx_t_5); 1744 | __pyx_t_6 = PyFloat_FromDouble(__pyx_v_dt); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1745 | __Pyx_GOTREF(__pyx_t_6); 1746 | __pyx_t_7 = NULL; 1747 | __pyx_t_8 = 0; 1748 | if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { 1749 | __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); 1750 | if (likely(__pyx_t_7)) { 1751 | PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); 1752 | __Pyx_INCREF(__pyx_t_7); 1753 | __Pyx_INCREF(function); 1754 | __Pyx_DECREF_SET(__pyx_t_5, function); 1755 | __pyx_t_8 = 1; 1756 | } 1757 | } 1758 | __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1759 | __Pyx_GOTREF(__pyx_t_9); 1760 | if (__pyx_t_7) { 1761 | PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL; 1762 | } 1763 | __Pyx_INCREF(__pyx_v_ents); 1764 | PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_ents); 1765 | __Pyx_GIVEREF(__pyx_v_ents); 1766 | PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6); 1767 | __Pyx_GIVEREF(__pyx_t_6); 1768 | __pyx_t_6 = 0; 1769 | __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1770 | __Pyx_GOTREF(__pyx_t_1); 1771 | __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; 1772 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1773 | __Pyx_XDECREF_SET(__pyx_v_ls, __pyx_t_1); 1774 | __pyx_t_1 = 0; 1775 | 1776 | /* "particles.pyx":50 1777 | * ls = p.updateme(ents, dt) 1778 | * #print ls 1779 | * if ls<0: # <<<<<<<<<<<<<< 1780 | * remlist.append(p) 1781 | * gameref.gameworld.remove_entity(p.entity_id()) 1782 | */ 1783 | __pyx_t_1 = PyObject_RichCompare(__pyx_v_ls, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1784 | __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1785 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1786 | if (__pyx_t_10) { 1787 | 1788 | /* "particles.pyx":51 1789 | * #print ls 1790 | * if ls<0: 1791 | * remlist.append(p) # <<<<<<<<<<<<<< 1792 | * gameref.gameworld.remove_entity(p.entity_id()) 1793 | * for r in remlist: 1794 | */ 1795 | __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_remlist, __pyx_v_p); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1796 | 1797 | /* "particles.pyx":52 1798 | * if ls<0: 1799 | * remlist.append(p) 1800 | * gameref.gameworld.remove_entity(p.entity_id()) # <<<<<<<<<<<<<< 1801 | * for r in remlist: 1802 | * particles.remove(r) 1803 | */ 1804 | __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_gameref); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1805 | __Pyx_GOTREF(__pyx_t_5); 1806 | __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_gameworld); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1807 | __Pyx_GOTREF(__pyx_t_9); 1808 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1809 | __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_remove_entity); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1810 | __Pyx_GOTREF(__pyx_t_5); 1811 | __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; 1812 | __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_entity_id); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1813 | __Pyx_GOTREF(__pyx_t_6); 1814 | __pyx_t_7 = NULL; 1815 | if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { 1816 | __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); 1817 | if (likely(__pyx_t_7)) { 1818 | PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); 1819 | __Pyx_INCREF(__pyx_t_7); 1820 | __Pyx_INCREF(function); 1821 | __Pyx_DECREF_SET(__pyx_t_6, function); 1822 | } 1823 | } 1824 | if (__pyx_t_7) { 1825 | __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1826 | __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; 1827 | } else { 1828 | __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1829 | } 1830 | __Pyx_GOTREF(__pyx_t_9); 1831 | __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; 1832 | __pyx_t_6 = NULL; 1833 | if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { 1834 | __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); 1835 | if (likely(__pyx_t_6)) { 1836 | PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); 1837 | __Pyx_INCREF(__pyx_t_6); 1838 | __Pyx_INCREF(function); 1839 | __Pyx_DECREF_SET(__pyx_t_5, function); 1840 | } 1841 | } 1842 | if (!__pyx_t_6) { 1843 | __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1844 | __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; 1845 | __Pyx_GOTREF(__pyx_t_1); 1846 | } else { 1847 | __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1848 | __Pyx_GOTREF(__pyx_t_7); 1849 | PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL; 1850 | PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_9); 1851 | __Pyx_GIVEREF(__pyx_t_9); 1852 | __pyx_t_9 = 0; 1853 | __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1854 | __Pyx_GOTREF(__pyx_t_1); 1855 | __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; 1856 | } 1857 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1858 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1859 | goto __pyx_L5; 1860 | } 1861 | __pyx_L5:; 1862 | 1863 | /* "particles.pyx":47 1864 | * ents = gameref.gameworld.entities 1865 | * remlist=[] 1866 | * for p in particles: # <<<<<<<<<<<<<< 1867 | * ls = p.updateme(ents, dt) 1868 | * #print ls 1869 | */ 1870 | } 1871 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1872 | 1873 | /* "particles.pyx":53 1874 | * remlist.append(p) 1875 | * gameref.gameworld.remove_entity(p.entity_id()) 1876 | * for r in remlist: # <<<<<<<<<<<<<< 1877 | * particles.remove(r) 1878 | * 1879 | */ 1880 | __pyx_t_2 = __pyx_v_remlist; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; 1881 | for (;;) { 1882 | if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; 1883 | #if CYTHON_COMPILING_IN_CPYTHON 1884 | __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1885 | #else 1886 | __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1887 | #endif 1888 | __Pyx_XDECREF_SET(__pyx_v_r, __pyx_t_1); 1889 | __pyx_t_1 = 0; 1890 | 1891 | /* "particles.pyx":54 1892 | * gameref.gameworld.remove_entity(p.entity_id()) 1893 | * for r in remlist: 1894 | * particles.remove(r) # <<<<<<<<<<<<<< 1895 | * 1896 | * 1897 | */ 1898 | __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_particles); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1899 | __Pyx_GOTREF(__pyx_t_5); 1900 | __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_remove); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1901 | __Pyx_GOTREF(__pyx_t_7); 1902 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 1903 | __pyx_t_5 = NULL; 1904 | if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { 1905 | __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); 1906 | if (likely(__pyx_t_5)) { 1907 | PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); 1908 | __Pyx_INCREF(__pyx_t_5); 1909 | __Pyx_INCREF(function); 1910 | __Pyx_DECREF_SET(__pyx_t_7, function); 1911 | } 1912 | } 1913 | if (!__pyx_t_5) { 1914 | __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1915 | __Pyx_GOTREF(__pyx_t_1); 1916 | } else { 1917 | __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1918 | __Pyx_GOTREF(__pyx_t_9); 1919 | PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; 1920 | __Pyx_INCREF(__pyx_v_r); 1921 | PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_r); 1922 | __Pyx_GIVEREF(__pyx_v_r); 1923 | __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1924 | __Pyx_GOTREF(__pyx_t_1); 1925 | __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; 1926 | } 1927 | __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; 1928 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1929 | 1930 | /* "particles.pyx":53 1931 | * remlist.append(p) 1932 | * gameref.gameworld.remove_entity(p.entity_id()) 1933 | * for r in remlist: # <<<<<<<<<<<<<< 1934 | * particles.remove(r) 1935 | * 1936 | */ 1937 | } 1938 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1939 | 1940 | /* "particles.pyx":43 1941 | * particles.append(newp) 1942 | * 1943 | * def update(float dt): # <<<<<<<<<<<<<< 1944 | * global particles 1945 | * ents = gameref.gameworld.entities 1946 | */ 1947 | 1948 | /* function exit code */ 1949 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1950 | goto __pyx_L0; 1951 | __pyx_L1_error:; 1952 | __Pyx_XDECREF(__pyx_t_1); 1953 | __Pyx_XDECREF(__pyx_t_2); 1954 | __Pyx_XDECREF(__pyx_t_5); 1955 | __Pyx_XDECREF(__pyx_t_6); 1956 | __Pyx_XDECREF(__pyx_t_7); 1957 | __Pyx_XDECREF(__pyx_t_9); 1958 | __Pyx_AddTraceback("particles.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 1959 | __pyx_r = NULL; 1960 | __pyx_L0:; 1961 | __Pyx_XDECREF(__pyx_v_ents); 1962 | __Pyx_XDECREF(__pyx_v_remlist); 1963 | __Pyx_XDECREF(__pyx_v_p); 1964 | __Pyx_XDECREF(__pyx_v_ls); 1965 | __Pyx_XDECREF(__pyx_v_r); 1966 | __Pyx_XGIVEREF(__pyx_r); 1967 | __Pyx_RefNannyFinishContext(); 1968 | return __pyx_r; 1969 | } 1970 | 1971 | /* "particles.pyx":58 1972 | * 1973 | * 1974 | * cdef create_visual(pos, color,float radius=64): # <<<<<<<<<<<<<< 1975 | * 1976 | * create_component_dict = { 1977 | */ 1978 | 1979 | static PyObject *__pyx_f_9particles_create_visual(PyObject *__pyx_v_pos, PyObject *__pyx_v_color, struct __pyx_opt_args_9particles_create_visual *__pyx_optional_args) { 1980 | float __pyx_v_radius = ((float)64.0); 1981 | PyObject *__pyx_v_create_component_dict = NULL; 1982 | PyObject *__pyx_v_component_order = NULL; 1983 | PyObject *__pyx_v_eid = NULL; 1984 | PyObject *__pyx_r = NULL; 1985 | __Pyx_RefNannyDeclarations 1986 | PyObject *__pyx_t_1 = NULL; 1987 | PyObject *__pyx_t_2 = NULL; 1988 | PyObject *__pyx_t_3 = NULL; 1989 | PyObject *__pyx_t_4 = NULL; 1990 | PyObject *__pyx_t_5 = NULL; 1991 | Py_ssize_t __pyx_t_6; 1992 | int __pyx_lineno = 0; 1993 | const char *__pyx_filename = NULL; 1994 | int __pyx_clineno = 0; 1995 | __Pyx_RefNannySetupContext("create_visual", 0); 1996 | if (__pyx_optional_args) { 1997 | if (__pyx_optional_args->__pyx_n > 0) { 1998 | __pyx_v_radius = __pyx_optional_args->radius; 1999 | } 2000 | } 2001 | 2002 | /* "particles.pyx":60 2003 | * cdef create_visual(pos, color,float radius=64): 2004 | * 2005 | * create_component_dict = { # <<<<<<<<<<<<<< 2006 | * 'renderer': {'texture': 'particle', 2007 | * 'size': (radius,radius)}, 2008 | */ 2009 | __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2010 | __Pyx_GOTREF(__pyx_t_1); 2011 | 2012 | /* "particles.pyx":61 2013 | * 2014 | * create_component_dict = { 2015 | * 'renderer': {'texture': 'particle', # <<<<<<<<<<<<<< 2016 | * 'size': (radius,radius)}, 2017 | * 'position': pos, 'rotate': 0, 'color': color, 2018 | */ 2019 | __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2020 | __Pyx_GOTREF(__pyx_t_2); 2021 | if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_texture, __pyx_n_s_particle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2022 | 2023 | /* "particles.pyx":62 2024 | * create_component_dict = { 2025 | * 'renderer': {'texture': 'particle', 2026 | * 'size': (radius,radius)}, # <<<<<<<<<<<<<< 2027 | * 'position': pos, 'rotate': 0, 'color': color, 2028 | * #'lerp_system': {}, 2029 | */ 2030 | __pyx_t_3 = PyFloat_FromDouble(__pyx_v_radius); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2031 | __Pyx_GOTREF(__pyx_t_3); 2032 | __pyx_t_4 = PyFloat_FromDouble(__pyx_v_radius); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2033 | __Pyx_GOTREF(__pyx_t_4); 2034 | __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2035 | __Pyx_GOTREF(__pyx_t_5); 2036 | PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); 2037 | __Pyx_GIVEREF(__pyx_t_3); 2038 | PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); 2039 | __Pyx_GIVEREF(__pyx_t_4); 2040 | __pyx_t_3 = 0; 2041 | __pyx_t_4 = 0; 2042 | if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2043 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 2044 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_renderer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2045 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2046 | 2047 | /* "particles.pyx":63 2048 | * 'renderer': {'texture': 'particle', 2049 | * 'size': (radius,radius)}, 2050 | * 'position': pos, 'rotate': 0, 'color': color, # <<<<<<<<<<<<<< 2051 | * #'lerp_system': {}, 2052 | * 'scale':1.} 2053 | */ 2054 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_position, __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2055 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rotate, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2056 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_color, __pyx_v_color) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2057 | if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_scale, __pyx_float_1_) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2058 | __pyx_v_create_component_dict = ((PyObject*)__pyx_t_1); 2059 | __pyx_t_1 = 0; 2060 | 2061 | /* "particles.pyx":66 2062 | * #'lerp_system': {}, 2063 | * 'scale':1.} 2064 | * component_order = ['position', 'rotate', 'color', # <<<<<<<<<<<<<< 2065 | * 'renderer','scale'] 2066 | * eid = gameref.gameworld.init_entity(create_component_dict, 2067 | */ 2068 | __pyx_t_1 = PyList_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2069 | __Pyx_GOTREF(__pyx_t_1); 2070 | __Pyx_INCREF(__pyx_n_s_position); 2071 | PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_position); 2072 | __Pyx_GIVEREF(__pyx_n_s_position); 2073 | __Pyx_INCREF(__pyx_n_s_rotate); 2074 | PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_rotate); 2075 | __Pyx_GIVEREF(__pyx_n_s_rotate); 2076 | __Pyx_INCREF(__pyx_n_s_color); 2077 | PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_color); 2078 | __Pyx_GIVEREF(__pyx_n_s_color); 2079 | __Pyx_INCREF(__pyx_n_s_renderer); 2080 | PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_renderer); 2081 | __Pyx_GIVEREF(__pyx_n_s_renderer); 2082 | __Pyx_INCREF(__pyx_n_s_scale); 2083 | PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_scale); 2084 | __Pyx_GIVEREF(__pyx_n_s_scale); 2085 | __pyx_v_component_order = ((PyObject*)__pyx_t_1); 2086 | __pyx_t_1 = 0; 2087 | 2088 | /* "particles.pyx":68 2089 | * component_order = ['position', 'rotate', 'color', 2090 | * 'renderer','scale'] 2091 | * eid = gameref.gameworld.init_entity(create_component_dict, # <<<<<<<<<<<<<< 2092 | * component_order) 2093 | * return eid 2094 | */ 2095 | __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gameref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2096 | __Pyx_GOTREF(__pyx_t_2); 2097 | __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_gameworld); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2098 | __Pyx_GOTREF(__pyx_t_5); 2099 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2100 | __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_init_entity); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2101 | __Pyx_GOTREF(__pyx_t_2); 2102 | __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; 2103 | 2104 | /* "particles.pyx":69 2105 | * 'renderer','scale'] 2106 | * eid = gameref.gameworld.init_entity(create_component_dict, 2107 | * component_order) # <<<<<<<<<<<<<< 2108 | * return eid 2109 | */ 2110 | __pyx_t_5 = NULL; 2111 | __pyx_t_6 = 0; 2112 | if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { 2113 | __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); 2114 | if (likely(__pyx_t_5)) { 2115 | PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); 2116 | __Pyx_INCREF(__pyx_t_5); 2117 | __Pyx_INCREF(function); 2118 | __Pyx_DECREF_SET(__pyx_t_2, function); 2119 | __pyx_t_6 = 1; 2120 | } 2121 | } 2122 | __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2123 | __Pyx_GOTREF(__pyx_t_4); 2124 | if (__pyx_t_5) { 2125 | PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; 2126 | } 2127 | __Pyx_INCREF(__pyx_v_create_component_dict); 2128 | PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_create_component_dict); 2129 | __Pyx_GIVEREF(__pyx_v_create_component_dict); 2130 | __Pyx_INCREF(__pyx_v_component_order); 2131 | PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_component_order); 2132 | __Pyx_GIVEREF(__pyx_v_component_order); 2133 | __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2134 | __Pyx_GOTREF(__pyx_t_1); 2135 | __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; 2136 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2137 | __pyx_v_eid = __pyx_t_1; 2138 | __pyx_t_1 = 0; 2139 | 2140 | /* "particles.pyx":70 2141 | * eid = gameref.gameworld.init_entity(create_component_dict, 2142 | * component_order) 2143 | * return eid # <<<<<<<<<<<<<< 2144 | */ 2145 | __Pyx_XDECREF(__pyx_r); 2146 | __Pyx_INCREF(__pyx_v_eid); 2147 | __pyx_r = __pyx_v_eid; 2148 | goto __pyx_L0; 2149 | 2150 | /* "particles.pyx":58 2151 | * 2152 | * 2153 | * cdef create_visual(pos, color,float radius=64): # <<<<<<<<<<<<<< 2154 | * 2155 | * create_component_dict = { 2156 | */ 2157 | 2158 | /* function exit code */ 2159 | __pyx_L1_error:; 2160 | __Pyx_XDECREF(__pyx_t_1); 2161 | __Pyx_XDECREF(__pyx_t_2); 2162 | __Pyx_XDECREF(__pyx_t_3); 2163 | __Pyx_XDECREF(__pyx_t_4); 2164 | __Pyx_XDECREF(__pyx_t_5); 2165 | __Pyx_AddTraceback("particles.create_visual", __pyx_clineno, __pyx_lineno, __pyx_filename); 2166 | __pyx_r = 0; 2167 | __pyx_L0:; 2168 | __Pyx_XDECREF(__pyx_v_create_component_dict); 2169 | __Pyx_XDECREF(__pyx_v_component_order); 2170 | __Pyx_XDECREF(__pyx_v_eid); 2171 | __Pyx_XGIVEREF(__pyx_r); 2172 | __Pyx_RefNannyFinishContext(); 2173 | return __pyx_r; 2174 | } 2175 | 2176 | static PyObject *__pyx_tp_new_9particles_particle(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { 2177 | PyObject *o; 2178 | if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { 2179 | o = (*t->tp_alloc)(t, 0); 2180 | } else { 2181 | o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); 2182 | } 2183 | if (unlikely(!o)) return 0; 2184 | return o; 2185 | } 2186 | 2187 | static void __pyx_tp_dealloc_9particles_particle(PyObject *o) { 2188 | #if PY_VERSION_HEX >= 0x030400a1 2189 | if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { 2190 | if (PyObject_CallFinalizerFromDealloc(o)) return; 2191 | } 2192 | #endif 2193 | (*Py_TYPE(o)->tp_free)(o); 2194 | } 2195 | 2196 | static PyMethodDef __pyx_methods_9particles_particle[] = { 2197 | {"entity_id", (PyCFunction)__pyx_pw_9particles_8particle_3entity_id, METH_NOARGS, 0}, 2198 | {"updateme", (PyCFunction)__pyx_pw_9particles_8particle_5updateme, METH_VARARGS|METH_KEYWORDS, 0}, 2199 | {0, 0, 0, 0} 2200 | }; 2201 | 2202 | static PyTypeObject __pyx_type_9particles_particle = { 2203 | PyVarObject_HEAD_INIT(0, 0) 2204 | "particles.particle", /*tp_name*/ 2205 | sizeof(struct __pyx_obj_9particles_particle), /*tp_basicsize*/ 2206 | 0, /*tp_itemsize*/ 2207 | __pyx_tp_dealloc_9particles_particle, /*tp_dealloc*/ 2208 | 0, /*tp_print*/ 2209 | 0, /*tp_getattr*/ 2210 | 0, /*tp_setattr*/ 2211 | #if PY_MAJOR_VERSION < 3 2212 | 0, /*tp_compare*/ 2213 | #else 2214 | 0, /*reserved*/ 2215 | #endif 2216 | 0, /*tp_repr*/ 2217 | 0, /*tp_as_number*/ 2218 | 0, /*tp_as_sequence*/ 2219 | 0, /*tp_as_mapping*/ 2220 | 0, /*tp_hash*/ 2221 | 0, /*tp_call*/ 2222 | 0, /*tp_str*/ 2223 | 0, /*tp_getattro*/ 2224 | 0, /*tp_setattro*/ 2225 | 0, /*tp_as_buffer*/ 2226 | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 2227 | 0, /*tp_doc*/ 2228 | 0, /*tp_traverse*/ 2229 | 0, /*tp_clear*/ 2230 | 0, /*tp_richcompare*/ 2231 | 0, /*tp_weaklistoffset*/ 2232 | 0, /*tp_iter*/ 2233 | 0, /*tp_iternext*/ 2234 | __pyx_methods_9particles_particle, /*tp_methods*/ 2235 | 0, /*tp_members*/ 2236 | 0, /*tp_getset*/ 2237 | 0, /*tp_base*/ 2238 | 0, /*tp_dict*/ 2239 | 0, /*tp_descr_get*/ 2240 | 0, /*tp_descr_set*/ 2241 | 0, /*tp_dictoffset*/ 2242 | __pyx_pw_9particles_8particle_1__init__, /*tp_init*/ 2243 | 0, /*tp_alloc*/ 2244 | __pyx_tp_new_9particles_particle, /*tp_new*/ 2245 | 0, /*tp_free*/ 2246 | 0, /*tp_is_gc*/ 2247 | 0, /*tp_bases*/ 2248 | 0, /*tp_mro*/ 2249 | 0, /*tp_cache*/ 2250 | 0, /*tp_subclasses*/ 2251 | 0, /*tp_weaklist*/ 2252 | 0, /*tp_del*/ 2253 | 0, /*tp_version_tag*/ 2254 | #if PY_VERSION_HEX >= 0x030400a1 2255 | 0, /*tp_finalize*/ 2256 | #endif 2257 | }; 2258 | 2259 | static PyMethodDef __pyx_methods[] = { 2260 | {0, 0, 0, 0} 2261 | }; 2262 | 2263 | #if PY_MAJOR_VERSION >= 3 2264 | static struct PyModuleDef __pyx_moduledef = { 2265 | #if PY_VERSION_HEX < 0x03020000 2266 | { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, 2267 | #else 2268 | PyModuleDef_HEAD_INIT, 2269 | #endif 2270 | "particles", 2271 | 0, /* m_doc */ 2272 | -1, /* m_size */ 2273 | __pyx_methods /* m_methods */, 2274 | NULL, /* m_reload */ 2275 | NULL, /* m_traverse */ 2276 | NULL, /* m_clear */ 2277 | NULL /* m_free */ 2278 | }; 2279 | #endif 2280 | 2281 | static __Pyx_StringTabEntry __pyx_string_tab[] = { 2282 | {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, 2283 | {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, 2284 | {&__pyx_n_s_author, __pyx_k_author, sizeof(__pyx_k_author), 0, 0, 1, 1}, 2285 | {&__pyx_n_s_chozabu, __pyx_k_chozabu, sizeof(__pyx_k_chozabu), 0, 0, 1, 1}, 2286 | {&__pyx_n_s_color, __pyx_k_color, sizeof(__pyx_k_color), 0, 0, 1, 1}, 2287 | {&__pyx_n_s_drag, __pyx_k_drag, sizeof(__pyx_k_drag), 0, 0, 1, 1}, 2288 | {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, 2289 | {&__pyx_n_s_enable_particles, __pyx_k_enable_particles, sizeof(__pyx_k_enable_particles), 0, 0, 1, 1}, 2290 | {&__pyx_n_s_ent, __pyx_k_ent, sizeof(__pyx_k_ent), 0, 0, 1, 1}, 2291 | {&__pyx_n_s_entities, __pyx_k_entities, sizeof(__pyx_k_entities), 0, 0, 1, 1}, 2292 | {&__pyx_n_s_entity_id, __pyx_k_entity_id, sizeof(__pyx_k_entity_id), 0, 0, 1, 1}, 2293 | {&__pyx_n_s_ents, __pyx_k_ents, sizeof(__pyx_k_ents), 0, 0, 1, 1}, 2294 | {&__pyx_n_s_gameref, __pyx_k_gameref, sizeof(__pyx_k_gameref), 0, 0, 1, 1}, 2295 | {&__pyx_n_s_gameworld, __pyx_k_gameworld, sizeof(__pyx_k_gameworld), 0, 0, 1, 1}, 2296 | {&__pyx_n_s_gravity, __pyx_k_gravity, sizeof(__pyx_k_gravity), 0, 0, 1, 1}, 2297 | {&__pyx_kp_s_home_chozabu_git_kivent_simple, __pyx_k_home_chozabu_git_kivent_simple, sizeof(__pyx_k_home_chozabu_git_kivent_simple), 0, 0, 1, 0}, 2298 | {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, 2299 | {&__pyx_n_s_init_entity, __pyx_k_init_entity, sizeof(__pyx_k_init_entity), 0, 0, 1, 1}, 2300 | {&__pyx_n_s_lifespan, __pyx_k_lifespan, sizeof(__pyx_k_lifespan), 0, 0, 1, 1}, 2301 | {&__pyx_n_s_ls, __pyx_k_ls, sizeof(__pyx_k_ls), 0, 0, 1, 1}, 2302 | {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, 2303 | {&__pyx_n_s_newp, __pyx_k_newp, sizeof(__pyx_k_newp), 0, 0, 1, 1}, 2304 | {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1}, 2305 | {&__pyx_n_s_particle, __pyx_k_particle, sizeof(__pyx_k_particle), 0, 0, 1, 1}, 2306 | {&__pyx_n_s_particles, __pyx_k_particles, sizeof(__pyx_k_particles), 0, 0, 1, 1}, 2307 | {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1}, 2308 | {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1}, 2309 | {&__pyx_n_s_position, __pyx_k_position, sizeof(__pyx_k_position), 0, 0, 1, 1}, 2310 | {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1}, 2311 | {&__pyx_n_s_radius, __pyx_k_radius, sizeof(__pyx_k_radius), 0, 0, 1, 1}, 2312 | {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1}, 2313 | {&__pyx_n_s_remlist, __pyx_k_remlist, sizeof(__pyx_k_remlist), 0, 0, 1, 1}, 2314 | {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1}, 2315 | {&__pyx_n_s_remove_entity, __pyx_k_remove_entity, sizeof(__pyx_k_remove_entity), 0, 0, 1, 1}, 2316 | {&__pyx_n_s_renderer, __pyx_k_renderer, sizeof(__pyx_k_renderer), 0, 0, 1, 1}, 2317 | {&__pyx_n_s_rotate, __pyx_k_rotate, sizeof(__pyx_k_rotate), 0, 0, 1, 1}, 2318 | {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, 2319 | {&__pyx_n_s_scale, __pyx_k_scale, sizeof(__pyx_k_scale), 0, 0, 1, 1}, 2320 | {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, 2321 | {&__pyx_n_s_spawn_particles_at, __pyx_k_spawn_particles_at, sizeof(__pyx_k_spawn_particles_at), 0, 0, 1, 1}, 2322 | {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, 2323 | {&__pyx_n_s_texture, __pyx_k_texture, sizeof(__pyx_k_texture), 0, 0, 1, 1}, 2324 | {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, 2325 | {&__pyx_n_s_updateme, __pyx_k_updateme, sizeof(__pyx_k_updateme), 0, 0, 1, 1}, 2326 | {&__pyx_n_s_vel, __pyx_k_vel, sizeof(__pyx_k_vel), 0, 0, 1, 1}, 2327 | {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, 2328 | {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, 2329 | {0, 0, 0, 0, 0, 0, 0} 2330 | }; 2331 | static int __Pyx_InitCachedBuiltins(void) { 2332 | return 0; 2333 | } 2334 | 2335 | static int __Pyx_InitCachedConstants(void) { 2336 | __Pyx_RefNannyDeclarations 2337 | __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); 2338 | 2339 | /* "particles.pyx":36 2340 | * return self.lifespan 2341 | * 2342 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): # <<<<<<<<<<<<<< 2343 | * if enable_particles==0:return 2344 | * pid = create_visual(pos, color=color, radius=radius*.5) 2345 | */ 2346 | __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2347 | __Pyx_GOTREF(__pyx_tuple_); 2348 | __Pyx_GIVEREF(__pyx_tuple_); 2349 | __pyx_tuple__2 = PyTuple_Pack(4, __pyx_int_1, __pyx_int_1, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2350 | __Pyx_GOTREF(__pyx_tuple__2); 2351 | __Pyx_GIVEREF(__pyx_tuple__2); 2352 | __pyx_tuple__3 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2353 | __Pyx_GOTREF(__pyx_tuple__3); 2354 | __Pyx_GIVEREF(__pyx_tuple__3); 2355 | __pyx_tuple__4 = PyTuple_Pack(9, __pyx_n_s_pos, __pyx_n_s_vel, __pyx_n_s_color, __pyx_n_s_lifespan, __pyx_n_s_drag, __pyx_n_s_gravity, __pyx_n_s_radius, __pyx_n_s_pid, __pyx_n_s_newp); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2356 | __Pyx_GOTREF(__pyx_tuple__4); 2357 | __Pyx_GIVEREF(__pyx_tuple__4); 2358 | __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(7, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_chozabu_git_kivent_simple, __pyx_n_s_spawn_particles_at, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2359 | 2360 | /* "particles.pyx":43 2361 | * particles.append(newp) 2362 | * 2363 | * def update(float dt): # <<<<<<<<<<<<<< 2364 | * global particles 2365 | * ents = gameref.gameworld.entities 2366 | */ 2367 | __pyx_tuple__6 = PyTuple_Pack(7, __pyx_n_s_dt, __pyx_n_s_dt, __pyx_n_s_ents, __pyx_n_s_remlist, __pyx_n_s_p, __pyx_n_s_ls, __pyx_n_s_r); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2368 | __Pyx_GOTREF(__pyx_tuple__6); 2369 | __Pyx_GIVEREF(__pyx_tuple__6); 2370 | __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_chozabu_git_kivent_simple, __pyx_n_s_update, 43, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2371 | __Pyx_RefNannyFinishContext(); 2372 | return 0; 2373 | __pyx_L1_error:; 2374 | __Pyx_RefNannyFinishContext(); 2375 | return -1; 2376 | } 2377 | 2378 | static int __Pyx_InitGlobals(void) { 2379 | if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2380 | __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2381 | __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2382 | __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2383 | return 0; 2384 | __pyx_L1_error:; 2385 | return -1; 2386 | } 2387 | 2388 | #if PY_MAJOR_VERSION < 3 2389 | PyMODINIT_FUNC initparticles(void); /*proto*/ 2390 | PyMODINIT_FUNC initparticles(void) 2391 | #else 2392 | PyMODINIT_FUNC PyInit_particles(void); /*proto*/ 2393 | PyMODINIT_FUNC PyInit_particles(void) 2394 | #endif 2395 | { 2396 | PyObject *__pyx_t_1 = NULL; 2397 | PyObject *__pyx_t_2 = NULL; 2398 | int __pyx_lineno = 0; 2399 | const char *__pyx_filename = NULL; 2400 | int __pyx_clineno = 0; 2401 | __Pyx_RefNannyDeclarations 2402 | #if CYTHON_REFNANNY 2403 | __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); 2404 | if (!__Pyx_RefNanny) { 2405 | PyErr_Clear(); 2406 | __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); 2407 | if (!__Pyx_RefNanny) 2408 | Py_FatalError("failed to import 'refnanny' module"); 2409 | } 2410 | #endif 2411 | __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_particles(void)", 0); 2412 | if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2413 | __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2414 | __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2415 | #ifdef __Pyx_CyFunction_USED 2416 | if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2417 | #endif 2418 | #ifdef __Pyx_FusedFunction_USED 2419 | if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2420 | #endif 2421 | #ifdef __Pyx_Generator_USED 2422 | if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2423 | #endif 2424 | /*--- Library function declarations ---*/ 2425 | /*--- Threads initialization code ---*/ 2426 | #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS 2427 | #ifdef WITH_THREAD /* Python build with threading support? */ 2428 | PyEval_InitThreads(); 2429 | #endif 2430 | #endif 2431 | /*--- Module creation code ---*/ 2432 | #if PY_MAJOR_VERSION < 3 2433 | __pyx_m = Py_InitModule4("particles", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); 2434 | #else 2435 | __pyx_m = PyModule_Create(&__pyx_moduledef); 2436 | #endif 2437 | if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2438 | __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2439 | Py_INCREF(__pyx_d); 2440 | __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2441 | #if CYTHON_COMPILING_IN_PYPY 2442 | Py_INCREF(__pyx_b); 2443 | #endif 2444 | if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2445 | /*--- Initialize various global constants etc. ---*/ 2446 | if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2447 | #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) 2448 | if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2449 | #endif 2450 | if (__pyx_module_is_main_particles) { 2451 | if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2452 | } 2453 | #if PY_MAJOR_VERSION >= 3 2454 | { 2455 | PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2456 | if (!PyDict_GetItemString(modules, "particles")) { 2457 | if (unlikely(PyDict_SetItemString(modules, "particles", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2458 | } 2459 | } 2460 | #endif 2461 | /*--- Builtin init code ---*/ 2462 | if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2463 | /*--- Constants init code ---*/ 2464 | if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2465 | /*--- Global init code ---*/ 2466 | /*--- Variable export code ---*/ 2467 | /*--- Function export code ---*/ 2468 | /*--- Type init code ---*/ 2469 | if (PyType_Ready(&__pyx_type_9particles_particle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2470 | __pyx_type_9particles_particle.tp_print = 0; 2471 | if (PyObject_SetAttrString(__pyx_m, "particle", (PyObject *)&__pyx_type_9particles_particle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2472 | __pyx_ptype_9particles_particle = &__pyx_type_9particles_particle; 2473 | /*--- Type import code ---*/ 2474 | /*--- Variable import code ---*/ 2475 | /*--- Function import code ---*/ 2476 | /*--- Execution code ---*/ 2477 | 2478 | /* "particles.pyx":1 2479 | * __author__ = 'chozabu' # <<<<<<<<<<<<<< 2480 | * 2481 | * gameref = None 2482 | */ 2483 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_author, __pyx_n_s_chozabu) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2484 | 2485 | /* "particles.pyx":3 2486 | * __author__ = 'chozabu' 2487 | * 2488 | * gameref = None # <<<<<<<<<<<<<< 2489 | * 2490 | * enable_particles = 1 2491 | */ 2492 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_gameref, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2493 | 2494 | /* "particles.pyx":5 2495 | * gameref = None 2496 | * 2497 | * enable_particles = 1 # <<<<<<<<<<<<<< 2498 | * 2499 | * from random import random 2500 | */ 2501 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_enable_particles, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2502 | 2503 | /* "particles.pyx":7 2504 | * enable_particles = 1 2505 | * 2506 | * from random import random # <<<<<<<<<<<<<< 2507 | * 2508 | * particles = [] 2509 | */ 2510 | __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2511 | __Pyx_GOTREF(__pyx_t_1); 2512 | __Pyx_INCREF(__pyx_n_s_random); 2513 | PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_random); 2514 | __Pyx_GIVEREF(__pyx_n_s_random); 2515 | __pyx_t_2 = __Pyx_Import(__pyx_n_s_random, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2516 | __Pyx_GOTREF(__pyx_t_2); 2517 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 2518 | __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2519 | __Pyx_GOTREF(__pyx_t_1); 2520 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2521 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 2522 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2523 | 2524 | /* "particles.pyx":9 2525 | * from random import random 2526 | * 2527 | * particles = [] # <<<<<<<<<<<<<< 2528 | * 2529 | * cdef class particle: 2530 | */ 2531 | __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2532 | __Pyx_GOTREF(__pyx_t_2); 2533 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_particles, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2534 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2535 | 2536 | /* "particles.pyx":36 2537 | * return self.lifespan 2538 | * 2539 | * def spawn_particles_at(pos, vel=(0,0), color=(1,1,1,1), float lifespan=1., float drag=.95, gravity=(0,0), float radius=64): # <<<<<<<<<<<<<< 2540 | * if enable_particles==0:return 2541 | * pid = create_visual(pos, color=color, radius=radius*.5) 2542 | */ 2543 | __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_9particles_1spawn_particles_at, NULL, __pyx_n_s_particles); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2544 | __Pyx_GOTREF(__pyx_t_2); 2545 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_spawn_particles_at, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2546 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2547 | 2548 | /* "particles.pyx":43 2549 | * particles.append(newp) 2550 | * 2551 | * def update(float dt): # <<<<<<<<<<<<<< 2552 | * global particles 2553 | * ents = gameref.gameworld.entities 2554 | */ 2555 | __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_9particles_3update, NULL, __pyx_n_s_particles); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2556 | __Pyx_GOTREF(__pyx_t_2); 2557 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_update, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2558 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2559 | 2560 | /* "particles.pyx":1 2561 | * __author__ = 'chozabu' # <<<<<<<<<<<<<< 2562 | * 2563 | * gameref = None 2564 | */ 2565 | __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2566 | __Pyx_GOTREF(__pyx_t_2); 2567 | if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2568 | __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 2569 | 2570 | /*--- Wrapped vars code ---*/ 2571 | 2572 | goto __pyx_L0; 2573 | __pyx_L1_error:; 2574 | __Pyx_XDECREF(__pyx_t_1); 2575 | __Pyx_XDECREF(__pyx_t_2); 2576 | if (__pyx_m) { 2577 | if (__pyx_d) { 2578 | __Pyx_AddTraceback("init particles", __pyx_clineno, __pyx_lineno, __pyx_filename); 2579 | } 2580 | Py_DECREF(__pyx_m); __pyx_m = 0; 2581 | } else if (!PyErr_Occurred()) { 2582 | PyErr_SetString(PyExc_ImportError, "init particles"); 2583 | } 2584 | __pyx_L0:; 2585 | __Pyx_RefNannyFinishContext(); 2586 | #if PY_MAJOR_VERSION < 3 2587 | return; 2588 | #else 2589 | return __pyx_m; 2590 | #endif 2591 | } 2592 | 2593 | /* Runtime support code */ 2594 | #if CYTHON_REFNANNY 2595 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { 2596 | PyObject *m = NULL, *p = NULL; 2597 | void *r = NULL; 2598 | m = PyImport_ImportModule((char *)modname); 2599 | if (!m) goto end; 2600 | p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); 2601 | if (!p) goto end; 2602 | r = PyLong_AsVoidPtr(p); 2603 | end: 2604 | Py_XDECREF(p); 2605 | Py_XDECREF(m); 2606 | return (__Pyx_RefNannyAPIStruct *)r; 2607 | } 2608 | #endif 2609 | 2610 | static void __Pyx_RaiseArgtupleInvalid( 2611 | const char* func_name, 2612 | int exact, 2613 | Py_ssize_t num_min, 2614 | Py_ssize_t num_max, 2615 | Py_ssize_t num_found) 2616 | { 2617 | Py_ssize_t num_expected; 2618 | const char *more_or_less; 2619 | if (num_found < num_min) { 2620 | num_expected = num_min; 2621 | more_or_less = "at least"; 2622 | } else { 2623 | num_expected = num_max; 2624 | more_or_less = "at most"; 2625 | } 2626 | if (exact) { 2627 | more_or_less = "exactly"; 2628 | } 2629 | PyErr_Format(PyExc_TypeError, 2630 | "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", 2631 | func_name, more_or_less, num_expected, 2632 | (num_expected == 1) ? "" : "s", num_found); 2633 | } 2634 | 2635 | static void __Pyx_RaiseDoubleKeywordsError( 2636 | const char* func_name, 2637 | PyObject* kw_name) 2638 | { 2639 | PyErr_Format(PyExc_TypeError, 2640 | #if PY_MAJOR_VERSION >= 3 2641 | "%s() got multiple values for keyword argument '%U'", func_name, kw_name); 2642 | #else 2643 | "%s() got multiple values for keyword argument '%s'", func_name, 2644 | PyString_AsString(kw_name)); 2645 | #endif 2646 | } 2647 | 2648 | static int __Pyx_ParseOptionalKeywords( 2649 | PyObject *kwds, 2650 | PyObject **argnames[], 2651 | PyObject *kwds2, 2652 | PyObject *values[], 2653 | Py_ssize_t num_pos_args, 2654 | const char* function_name) 2655 | { 2656 | PyObject *key = 0, *value = 0; 2657 | Py_ssize_t pos = 0; 2658 | PyObject*** name; 2659 | PyObject*** first_kw_arg = argnames + num_pos_args; 2660 | while (PyDict_Next(kwds, &pos, &key, &value)) { 2661 | name = first_kw_arg; 2662 | while (*name && (**name != key)) name++; 2663 | if (*name) { 2664 | values[name-argnames] = value; 2665 | continue; 2666 | } 2667 | name = first_kw_arg; 2668 | #if PY_MAJOR_VERSION < 3 2669 | if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { 2670 | while (*name) { 2671 | if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) 2672 | && _PyString_Eq(**name, key)) { 2673 | values[name-argnames] = value; 2674 | break; 2675 | } 2676 | name++; 2677 | } 2678 | if (*name) continue; 2679 | else { 2680 | PyObject*** argname = argnames; 2681 | while (argname != first_kw_arg) { 2682 | if ((**argname == key) || ( 2683 | (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) 2684 | && _PyString_Eq(**argname, key))) { 2685 | goto arg_passed_twice; 2686 | } 2687 | argname++; 2688 | } 2689 | } 2690 | } else 2691 | #endif 2692 | if (likely(PyUnicode_Check(key))) { 2693 | while (*name) { 2694 | int cmp = (**name == key) ? 0 : 2695 | #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 2696 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : 2697 | #endif 2698 | PyUnicode_Compare(**name, key); 2699 | if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; 2700 | if (cmp == 0) { 2701 | values[name-argnames] = value; 2702 | break; 2703 | } 2704 | name++; 2705 | } 2706 | if (*name) continue; 2707 | else { 2708 | PyObject*** argname = argnames; 2709 | while (argname != first_kw_arg) { 2710 | int cmp = (**argname == key) ? 0 : 2711 | #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 2712 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : 2713 | #endif 2714 | PyUnicode_Compare(**argname, key); 2715 | if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; 2716 | if (cmp == 0) goto arg_passed_twice; 2717 | argname++; 2718 | } 2719 | } 2720 | } else 2721 | goto invalid_keyword_type; 2722 | if (kwds2) { 2723 | if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; 2724 | } else { 2725 | goto invalid_keyword; 2726 | } 2727 | } 2728 | return 0; 2729 | arg_passed_twice: 2730 | __Pyx_RaiseDoubleKeywordsError(function_name, key); 2731 | goto bad; 2732 | invalid_keyword_type: 2733 | PyErr_Format(PyExc_TypeError, 2734 | "%.200s() keywords must be strings", function_name); 2735 | goto bad; 2736 | invalid_keyword: 2737 | PyErr_Format(PyExc_TypeError, 2738 | #if PY_MAJOR_VERSION < 3 2739 | "%.200s() got an unexpected keyword argument '%.200s'", 2740 | function_name, PyString_AsString(key)); 2741 | #else 2742 | "%s() got an unexpected keyword argument '%U'", 2743 | function_name, key); 2744 | #endif 2745 | bad: 2746 | return -1; 2747 | } 2748 | 2749 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { 2750 | PyObject *r; 2751 | if (!j) return NULL; 2752 | r = PyObject_GetItem(o, j); 2753 | Py_DECREF(j); 2754 | return r; 2755 | } 2756 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, 2757 | int wraparound, int boundscheck) { 2758 | #if CYTHON_COMPILING_IN_CPYTHON 2759 | if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); 2760 | if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { 2761 | PyObject *r = PyList_GET_ITEM(o, i); 2762 | Py_INCREF(r); 2763 | return r; 2764 | } 2765 | return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 2766 | #else 2767 | return PySequence_GetItem(o, i); 2768 | #endif 2769 | } 2770 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, 2771 | int wraparound, int boundscheck) { 2772 | #if CYTHON_COMPILING_IN_CPYTHON 2773 | if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); 2774 | if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { 2775 | PyObject *r = PyTuple_GET_ITEM(o, i); 2776 | Py_INCREF(r); 2777 | return r; 2778 | } 2779 | return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 2780 | #else 2781 | return PySequence_GetItem(o, i); 2782 | #endif 2783 | } 2784 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, 2785 | int is_list, int wraparound, int boundscheck) { 2786 | #if CYTHON_COMPILING_IN_CPYTHON 2787 | if (is_list || PyList_CheckExact(o)) { 2788 | Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); 2789 | if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { 2790 | PyObject *r = PyList_GET_ITEM(o, n); 2791 | Py_INCREF(r); 2792 | return r; 2793 | } 2794 | } 2795 | else if (PyTuple_CheckExact(o)) { 2796 | Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); 2797 | if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { 2798 | PyObject *r = PyTuple_GET_ITEM(o, n); 2799 | Py_INCREF(r); 2800 | return r; 2801 | } 2802 | } else { 2803 | PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; 2804 | if (likely(m && m->sq_item)) { 2805 | if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { 2806 | Py_ssize_t l = m->sq_length(o); 2807 | if (likely(l >= 0)) { 2808 | i += l; 2809 | } else { 2810 | if (PyErr_ExceptionMatches(PyExc_OverflowError)) 2811 | PyErr_Clear(); 2812 | else 2813 | return NULL; 2814 | } 2815 | } 2816 | return m->sq_item(o, i); 2817 | } 2818 | } 2819 | #else 2820 | if (is_list || PySequence_Check(o)) { 2821 | return PySequence_GetItem(o, i); 2822 | } 2823 | #endif 2824 | return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 2825 | } 2826 | 2827 | static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { 2828 | PyErr_Format(PyExc_TypeError, 2829 | "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", 2830 | name, type->tp_name, Py_TYPE(obj)->tp_name); 2831 | } 2832 | static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, 2833 | const char *name, int exact) 2834 | { 2835 | if (unlikely(!type)) { 2836 | PyErr_SetString(PyExc_SystemError, "Missing type object"); 2837 | return 0; 2838 | } 2839 | if (none_allowed && obj == Py_None) return 1; 2840 | else if (exact) { 2841 | if (likely(Py_TYPE(obj) == type)) return 1; 2842 | #if PY_MAJOR_VERSION == 2 2843 | else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; 2844 | #endif 2845 | } 2846 | else { 2847 | if (likely(PyObject_TypeCheck(obj, type))) return 1; 2848 | } 2849 | __Pyx_RaiseArgumentTypeInvalid(name, obj, type); 2850 | return 0; 2851 | } 2852 | 2853 | static PyObject *__Pyx_GetBuiltinName(PyObject *name) { 2854 | PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); 2855 | if (unlikely(!result)) { 2856 | PyErr_Format(PyExc_NameError, 2857 | #if PY_MAJOR_VERSION >= 3 2858 | "name '%U' is not defined", name); 2859 | #else 2860 | "name '%.200s' is not defined", PyString_AS_STRING(name)); 2861 | #endif 2862 | } 2863 | return result; 2864 | } 2865 | 2866 | static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { 2867 | PyObject *result; 2868 | #if CYTHON_COMPILING_IN_CPYTHON 2869 | result = PyDict_GetItem(__pyx_d, name); 2870 | if (likely(result)) { 2871 | Py_INCREF(result); 2872 | } else { 2873 | #else 2874 | result = PyObject_GetItem(__pyx_d, name); 2875 | if (!result) { 2876 | PyErr_Clear(); 2877 | #endif 2878 | result = __Pyx_GetBuiltinName(name); 2879 | } 2880 | return result; 2881 | } 2882 | 2883 | #if CYTHON_COMPILING_IN_CPYTHON 2884 | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { 2885 | PyObject *result; 2886 | ternaryfunc call = func->ob_type->tp_call; 2887 | if (unlikely(!call)) 2888 | return PyObject_Call(func, arg, kw); 2889 | if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) 2890 | return NULL; 2891 | result = (*call)(func, arg, kw); 2892 | Py_LeaveRecursiveCall(); 2893 | if (unlikely(!result) && unlikely(!PyErr_Occurred())) { 2894 | PyErr_SetString( 2895 | PyExc_SystemError, 2896 | "NULL result without error in PyObject_Call"); 2897 | } 2898 | return result; 2899 | } 2900 | #endif 2901 | 2902 | #if CYTHON_COMPILING_IN_CPYTHON 2903 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { 2904 | PyObject *self, *result; 2905 | PyCFunction cfunc; 2906 | cfunc = PyCFunction_GET_FUNCTION(func); 2907 | self = PyCFunction_GET_SELF(func); 2908 | if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) 2909 | return NULL; 2910 | result = cfunc(self, arg); 2911 | Py_LeaveRecursiveCall(); 2912 | if (unlikely(!result) && unlikely(!PyErr_Occurred())) { 2913 | PyErr_SetString( 2914 | PyExc_SystemError, 2915 | "NULL result without error in PyObject_Call"); 2916 | } 2917 | return result; 2918 | } 2919 | #endif 2920 | 2921 | #if CYTHON_COMPILING_IN_CPYTHON 2922 | static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { 2923 | PyObject *result; 2924 | PyObject *args = PyTuple_New(1); 2925 | if (unlikely(!args)) return NULL; 2926 | Py_INCREF(arg); 2927 | PyTuple_SET_ITEM(args, 0, arg); 2928 | result = __Pyx_PyObject_Call(func, args, NULL); 2929 | Py_DECREF(args); 2930 | return result; 2931 | } 2932 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { 2933 | #ifdef __Pyx_CyFunction_USED 2934 | if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { 2935 | #else 2936 | if (likely(PyCFunction_Check(func))) { 2937 | #endif 2938 | if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { 2939 | return __Pyx_PyObject_CallMethO(func, arg); 2940 | } 2941 | } 2942 | return __Pyx__PyObject_CallOneArg(func, arg); 2943 | } 2944 | #else 2945 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { 2946 | PyObject* args = PyTuple_Pack(1, arg); 2947 | return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL; 2948 | } 2949 | #endif 2950 | 2951 | static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { 2952 | PyObject *method, *result = NULL; 2953 | method = __Pyx_PyObject_GetAttrStr(obj, method_name); 2954 | if (unlikely(!method)) goto bad; 2955 | #if CYTHON_COMPILING_IN_CPYTHON 2956 | if (likely(PyMethod_Check(method))) { 2957 | PyObject *self = PyMethod_GET_SELF(method); 2958 | if (likely(self)) { 2959 | PyObject *args; 2960 | PyObject *function = PyMethod_GET_FUNCTION(method); 2961 | args = PyTuple_New(2); 2962 | if (unlikely(!args)) goto bad; 2963 | Py_INCREF(self); 2964 | PyTuple_SET_ITEM(args, 0, self); 2965 | Py_INCREF(arg); 2966 | PyTuple_SET_ITEM(args, 1, arg); 2967 | Py_INCREF(function); 2968 | Py_DECREF(method); method = NULL; 2969 | result = __Pyx_PyObject_Call(function, args, NULL); 2970 | Py_DECREF(args); 2971 | Py_DECREF(function); 2972 | return result; 2973 | } 2974 | } 2975 | #endif 2976 | result = __Pyx_PyObject_CallOneArg(method, arg); 2977 | bad: 2978 | Py_XDECREF(method); 2979 | return result; 2980 | } 2981 | 2982 | static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { 2983 | if (likely(PyList_CheckExact(L))) { 2984 | if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; 2985 | } else { 2986 | PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); 2987 | if (unlikely(!retval)) 2988 | return -1; 2989 | Py_DECREF(retval); 2990 | } 2991 | return 0; 2992 | } 2993 | 2994 | #if CYTHON_COMPILING_IN_CPYTHON 2995 | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { 2996 | #ifdef __Pyx_CyFunction_USED 2997 | if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { 2998 | #else 2999 | if (likely(PyCFunction_Check(func))) { 3000 | #endif 3001 | if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { 3002 | return __Pyx_PyObject_CallMethO(func, NULL); 3003 | } 3004 | } 3005 | return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); 3006 | } 3007 | #endif 3008 | 3009 | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { 3010 | PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); 3011 | if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { 3012 | PyErr_Format(PyExc_ImportError, 3013 | #if PY_MAJOR_VERSION < 3 3014 | "cannot import name %.230s", PyString_AS_STRING(name)); 3015 | #else 3016 | "cannot import name %S", name); 3017 | #endif 3018 | } 3019 | return value; 3020 | } 3021 | 3022 | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { 3023 | int start = 0, mid = 0, end = count - 1; 3024 | if (end >= 0 && code_line > entries[end].code_line) { 3025 | return count; 3026 | } 3027 | while (start < end) { 3028 | mid = (start + end) / 2; 3029 | if (code_line < entries[mid].code_line) { 3030 | end = mid; 3031 | } else if (code_line > entries[mid].code_line) { 3032 | start = mid + 1; 3033 | } else { 3034 | return mid; 3035 | } 3036 | } 3037 | if (code_line <= entries[mid].code_line) { 3038 | return mid; 3039 | } else { 3040 | return mid + 1; 3041 | } 3042 | } 3043 | static PyCodeObject *__pyx_find_code_object(int code_line) { 3044 | PyCodeObject* code_object; 3045 | int pos; 3046 | if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { 3047 | return NULL; 3048 | } 3049 | pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); 3050 | if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { 3051 | return NULL; 3052 | } 3053 | code_object = __pyx_code_cache.entries[pos].code_object; 3054 | Py_INCREF(code_object); 3055 | return code_object; 3056 | } 3057 | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { 3058 | int pos, i; 3059 | __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; 3060 | if (unlikely(!code_line)) { 3061 | return; 3062 | } 3063 | if (unlikely(!entries)) { 3064 | entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); 3065 | if (likely(entries)) { 3066 | __pyx_code_cache.entries = entries; 3067 | __pyx_code_cache.max_count = 64; 3068 | __pyx_code_cache.count = 1; 3069 | entries[0].code_line = code_line; 3070 | entries[0].code_object = code_object; 3071 | Py_INCREF(code_object); 3072 | } 3073 | return; 3074 | } 3075 | pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); 3076 | if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { 3077 | PyCodeObject* tmp = entries[pos].code_object; 3078 | entries[pos].code_object = code_object; 3079 | Py_DECREF(tmp); 3080 | return; 3081 | } 3082 | if (__pyx_code_cache.count == __pyx_code_cache.max_count) { 3083 | int new_max = __pyx_code_cache.max_count + 64; 3084 | entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( 3085 | __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); 3086 | if (unlikely(!entries)) { 3087 | return; 3088 | } 3089 | __pyx_code_cache.entries = entries; 3090 | __pyx_code_cache.max_count = new_max; 3091 | } 3092 | for (i=__pyx_code_cache.count; i>pos; i--) { 3093 | entries[i] = entries[i-1]; 3094 | } 3095 | entries[pos].code_line = code_line; 3096 | entries[pos].code_object = code_object; 3097 | __pyx_code_cache.count++; 3098 | Py_INCREF(code_object); 3099 | } 3100 | 3101 | #include "compile.h" 3102 | #include "frameobject.h" 3103 | #include "traceback.h" 3104 | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( 3105 | const char *funcname, int c_line, 3106 | int py_line, const char *filename) { 3107 | PyCodeObject *py_code = 0; 3108 | PyObject *py_srcfile = 0; 3109 | PyObject *py_funcname = 0; 3110 | #if PY_MAJOR_VERSION < 3 3111 | py_srcfile = PyString_FromString(filename); 3112 | #else 3113 | py_srcfile = PyUnicode_FromString(filename); 3114 | #endif 3115 | if (!py_srcfile) goto bad; 3116 | if (c_line) { 3117 | #if PY_MAJOR_VERSION < 3 3118 | py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); 3119 | #else 3120 | py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); 3121 | #endif 3122 | } 3123 | else { 3124 | #if PY_MAJOR_VERSION < 3 3125 | py_funcname = PyString_FromString(funcname); 3126 | #else 3127 | py_funcname = PyUnicode_FromString(funcname); 3128 | #endif 3129 | } 3130 | if (!py_funcname) goto bad; 3131 | py_code = __Pyx_PyCode_New( 3132 | 0, 3133 | 0, 3134 | 0, 3135 | 0, 3136 | 0, 3137 | __pyx_empty_bytes, /*PyObject *code,*/ 3138 | __pyx_empty_tuple, /*PyObject *consts,*/ 3139 | __pyx_empty_tuple, /*PyObject *names,*/ 3140 | __pyx_empty_tuple, /*PyObject *varnames,*/ 3141 | __pyx_empty_tuple, /*PyObject *freevars,*/ 3142 | __pyx_empty_tuple, /*PyObject *cellvars,*/ 3143 | py_srcfile, /*PyObject *filename,*/ 3144 | py_funcname, /*PyObject *name,*/ 3145 | py_line, 3146 | __pyx_empty_bytes /*PyObject *lnotab*/ 3147 | ); 3148 | Py_DECREF(py_srcfile); 3149 | Py_DECREF(py_funcname); 3150 | return py_code; 3151 | bad: 3152 | Py_XDECREF(py_srcfile); 3153 | Py_XDECREF(py_funcname); 3154 | return NULL; 3155 | } 3156 | static void __Pyx_AddTraceback(const char *funcname, int c_line, 3157 | int py_line, const char *filename) { 3158 | PyCodeObject *py_code = 0; 3159 | PyFrameObject *py_frame = 0; 3160 | py_code = __pyx_find_code_object(c_line ? c_line : py_line); 3161 | if (!py_code) { 3162 | py_code = __Pyx_CreateCodeObjectForTraceback( 3163 | funcname, c_line, py_line, filename); 3164 | if (!py_code) goto bad; 3165 | __pyx_insert_code_object(c_line ? c_line : py_line, py_code); 3166 | } 3167 | py_frame = PyFrame_New( 3168 | PyThreadState_GET(), /*PyThreadState *tstate,*/ 3169 | py_code, /*PyCodeObject *code,*/ 3170 | __pyx_d, /*PyObject *globals,*/ 3171 | 0 /*PyObject *locals*/ 3172 | ); 3173 | if (!py_frame) goto bad; 3174 | py_frame->f_lineno = py_line; 3175 | PyTraceBack_Here(py_frame); 3176 | bad: 3177 | Py_XDECREF(py_code); 3178 | Py_XDECREF(py_frame); 3179 | } 3180 | 3181 | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { 3182 | PyObject *empty_list = 0; 3183 | PyObject *module = 0; 3184 | PyObject *global_dict = 0; 3185 | PyObject *empty_dict = 0; 3186 | PyObject *list; 3187 | #if PY_VERSION_HEX < 0x03030000 3188 | PyObject *py_import; 3189 | py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); 3190 | if (!py_import) 3191 | goto bad; 3192 | #endif 3193 | if (from_list) 3194 | list = from_list; 3195 | else { 3196 | empty_list = PyList_New(0); 3197 | if (!empty_list) 3198 | goto bad; 3199 | list = empty_list; 3200 | } 3201 | global_dict = PyModule_GetDict(__pyx_m); 3202 | if (!global_dict) 3203 | goto bad; 3204 | empty_dict = PyDict_New(); 3205 | if (!empty_dict) 3206 | goto bad; 3207 | { 3208 | #if PY_MAJOR_VERSION >= 3 3209 | if (level == -1) { 3210 | if (strchr(__Pyx_MODULE_NAME, '.')) { 3211 | #if PY_VERSION_HEX < 0x03030000 3212 | PyObject *py_level = PyInt_FromLong(1); 3213 | if (!py_level) 3214 | goto bad; 3215 | module = PyObject_CallFunctionObjArgs(py_import, 3216 | name, global_dict, empty_dict, list, py_level, NULL); 3217 | Py_DECREF(py_level); 3218 | #else 3219 | module = PyImport_ImportModuleLevelObject( 3220 | name, global_dict, empty_dict, list, 1); 3221 | #endif 3222 | if (!module) { 3223 | if (!PyErr_ExceptionMatches(PyExc_ImportError)) 3224 | goto bad; 3225 | PyErr_Clear(); 3226 | } 3227 | } 3228 | level = 0; 3229 | } 3230 | #endif 3231 | if (!module) { 3232 | #if PY_VERSION_HEX < 0x03030000 3233 | PyObject *py_level = PyInt_FromLong(level); 3234 | if (!py_level) 3235 | goto bad; 3236 | module = PyObject_CallFunctionObjArgs(py_import, 3237 | name, global_dict, empty_dict, list, py_level, NULL); 3238 | Py_DECREF(py_level); 3239 | #else 3240 | module = PyImport_ImportModuleLevelObject( 3241 | name, global_dict, empty_dict, list, level); 3242 | #endif 3243 | } 3244 | } 3245 | bad: 3246 | #if PY_VERSION_HEX < 0x03030000 3247 | Py_XDECREF(py_import); 3248 | #endif 3249 | Py_XDECREF(empty_list); 3250 | Py_XDECREF(empty_dict); 3251 | return module; 3252 | } 3253 | 3254 | #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value) \ 3255 | { \ 3256 | func_type value = func_value; \ 3257 | if (sizeof(target_type) < sizeof(func_type)) { \ 3258 | if (unlikely(value != (func_type) (target_type) value)) { \ 3259 | func_type zero = 0; \ 3260 | if (is_unsigned && unlikely(value < zero)) \ 3261 | goto raise_neg_overflow; \ 3262 | else \ 3263 | goto raise_overflow; \ 3264 | } \ 3265 | } \ 3266 | return (target_type) value; \ 3267 | } 3268 | 3269 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3270 | #if CYTHON_USE_PYLONG_INTERNALS 3271 | #include "longintrepr.h" 3272 | #endif 3273 | #endif 3274 | 3275 | static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { 3276 | const int neg_one = (int) -1, const_zero = 0; 3277 | const int is_unsigned = neg_one > const_zero; 3278 | #if PY_MAJOR_VERSION < 3 3279 | if (likely(PyInt_Check(x))) { 3280 | if (sizeof(int) < sizeof(long)) { 3281 | __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) 3282 | } else { 3283 | long val = PyInt_AS_LONG(x); 3284 | if (is_unsigned && unlikely(val < 0)) { 3285 | goto raise_neg_overflow; 3286 | } 3287 | return (int) val; 3288 | } 3289 | } else 3290 | #endif 3291 | if (likely(PyLong_Check(x))) { 3292 | if (is_unsigned) { 3293 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3294 | #if CYTHON_USE_PYLONG_INTERNALS 3295 | switch (Py_SIZE(x)) { 3296 | case 0: return 0; 3297 | case 1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]); 3298 | } 3299 | #endif 3300 | #endif 3301 | if (unlikely(Py_SIZE(x) < 0)) { 3302 | goto raise_neg_overflow; 3303 | } 3304 | if (sizeof(int) <= sizeof(unsigned long)) { 3305 | __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x)) 3306 | } else if (sizeof(int) <= sizeof(unsigned long long)) { 3307 | __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x)) 3308 | } 3309 | } else { 3310 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3311 | #if CYTHON_USE_PYLONG_INTERNALS 3312 | switch (Py_SIZE(x)) { 3313 | case 0: return 0; 3314 | case 1: __PYX_VERIFY_RETURN_INT(int, digit, +(((PyLongObject*)x)->ob_digit[0])); 3315 | case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]); 3316 | } 3317 | #endif 3318 | #endif 3319 | if (sizeof(int) <= sizeof(long)) { 3320 | __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x)) 3321 | } else if (sizeof(int) <= sizeof(long long)) { 3322 | __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x)) 3323 | } 3324 | } 3325 | { 3326 | #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) 3327 | PyErr_SetString(PyExc_RuntimeError, 3328 | "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); 3329 | #else 3330 | int val; 3331 | PyObject *v = __Pyx_PyNumber_Int(x); 3332 | #if PY_MAJOR_VERSION < 3 3333 | if (likely(v) && !PyLong_Check(v)) { 3334 | PyObject *tmp = v; 3335 | v = PyNumber_Long(tmp); 3336 | Py_DECREF(tmp); 3337 | } 3338 | #endif 3339 | if (likely(v)) { 3340 | int one = 1; int is_little = (int)*(unsigned char *)&one; 3341 | unsigned char *bytes = (unsigned char *)&val; 3342 | int ret = _PyLong_AsByteArray((PyLongObject *)v, 3343 | bytes, sizeof(val), 3344 | is_little, !is_unsigned); 3345 | Py_DECREF(v); 3346 | if (likely(!ret)) 3347 | return val; 3348 | } 3349 | #endif 3350 | return (int) -1; 3351 | } 3352 | } else { 3353 | int val; 3354 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3355 | if (!tmp) return (int) -1; 3356 | val = __Pyx_PyInt_As_int(tmp); 3357 | Py_DECREF(tmp); 3358 | return val; 3359 | } 3360 | raise_overflow: 3361 | PyErr_SetString(PyExc_OverflowError, 3362 | "value too large to convert to int"); 3363 | return (int) -1; 3364 | raise_neg_overflow: 3365 | PyErr_SetString(PyExc_OverflowError, 3366 | "can't convert negative value to int"); 3367 | return (int) -1; 3368 | } 3369 | 3370 | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { 3371 | const long neg_one = (long) -1, const_zero = 0; 3372 | const int is_unsigned = neg_one > const_zero; 3373 | if (is_unsigned) { 3374 | if (sizeof(long) < sizeof(long)) { 3375 | return PyInt_FromLong((long) value); 3376 | } else if (sizeof(long) <= sizeof(unsigned long)) { 3377 | return PyLong_FromUnsignedLong((unsigned long) value); 3378 | } else if (sizeof(long) <= sizeof(unsigned long long)) { 3379 | return PyLong_FromUnsignedLongLong((unsigned long long) value); 3380 | } 3381 | } else { 3382 | if (sizeof(long) <= sizeof(long)) { 3383 | return PyInt_FromLong((long) value); 3384 | } else if (sizeof(long) <= sizeof(long long)) { 3385 | return PyLong_FromLongLong((long long) value); 3386 | } 3387 | } 3388 | { 3389 | int one = 1; int little = (int)*(unsigned char *)&one; 3390 | unsigned char *bytes = (unsigned char *)&value; 3391 | return _PyLong_FromByteArray(bytes, sizeof(long), 3392 | little, !is_unsigned); 3393 | } 3394 | } 3395 | 3396 | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { 3397 | const int neg_one = (int) -1, const_zero = 0; 3398 | const int is_unsigned = neg_one > const_zero; 3399 | if (is_unsigned) { 3400 | if (sizeof(int) < sizeof(long)) { 3401 | return PyInt_FromLong((long) value); 3402 | } else if (sizeof(int) <= sizeof(unsigned long)) { 3403 | return PyLong_FromUnsignedLong((unsigned long) value); 3404 | } else if (sizeof(int) <= sizeof(unsigned long long)) { 3405 | return PyLong_FromUnsignedLongLong((unsigned long long) value); 3406 | } 3407 | } else { 3408 | if (sizeof(int) <= sizeof(long)) { 3409 | return PyInt_FromLong((long) value); 3410 | } else if (sizeof(int) <= sizeof(long long)) { 3411 | return PyLong_FromLongLong((long long) value); 3412 | } 3413 | } 3414 | { 3415 | int one = 1; int little = (int)*(unsigned char *)&one; 3416 | unsigned char *bytes = (unsigned char *)&value; 3417 | return _PyLong_FromByteArray(bytes, sizeof(int), 3418 | little, !is_unsigned); 3419 | } 3420 | } 3421 | 3422 | static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { 3423 | const long neg_one = (long) -1, const_zero = 0; 3424 | const int is_unsigned = neg_one > const_zero; 3425 | #if PY_MAJOR_VERSION < 3 3426 | if (likely(PyInt_Check(x))) { 3427 | if (sizeof(long) < sizeof(long)) { 3428 | __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) 3429 | } else { 3430 | long val = PyInt_AS_LONG(x); 3431 | if (is_unsigned && unlikely(val < 0)) { 3432 | goto raise_neg_overflow; 3433 | } 3434 | return (long) val; 3435 | } 3436 | } else 3437 | #endif 3438 | if (likely(PyLong_Check(x))) { 3439 | if (is_unsigned) { 3440 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3441 | #if CYTHON_USE_PYLONG_INTERNALS 3442 | switch (Py_SIZE(x)) { 3443 | case 0: return 0; 3444 | case 1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]); 3445 | } 3446 | #endif 3447 | #endif 3448 | if (unlikely(Py_SIZE(x) < 0)) { 3449 | goto raise_neg_overflow; 3450 | } 3451 | if (sizeof(long) <= sizeof(unsigned long)) { 3452 | __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x)) 3453 | } else if (sizeof(long) <= sizeof(unsigned long long)) { 3454 | __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x)) 3455 | } 3456 | } else { 3457 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3458 | #if CYTHON_USE_PYLONG_INTERNALS 3459 | switch (Py_SIZE(x)) { 3460 | case 0: return 0; 3461 | case 1: __PYX_VERIFY_RETURN_INT(long, digit, +(((PyLongObject*)x)->ob_digit[0])); 3462 | case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]); 3463 | } 3464 | #endif 3465 | #endif 3466 | if (sizeof(long) <= sizeof(long)) { 3467 | __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x)) 3468 | } else if (sizeof(long) <= sizeof(long long)) { 3469 | __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x)) 3470 | } 3471 | } 3472 | { 3473 | #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) 3474 | PyErr_SetString(PyExc_RuntimeError, 3475 | "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); 3476 | #else 3477 | long val; 3478 | PyObject *v = __Pyx_PyNumber_Int(x); 3479 | #if PY_MAJOR_VERSION < 3 3480 | if (likely(v) && !PyLong_Check(v)) { 3481 | PyObject *tmp = v; 3482 | v = PyNumber_Long(tmp); 3483 | Py_DECREF(tmp); 3484 | } 3485 | #endif 3486 | if (likely(v)) { 3487 | int one = 1; int is_little = (int)*(unsigned char *)&one; 3488 | unsigned char *bytes = (unsigned char *)&val; 3489 | int ret = _PyLong_AsByteArray((PyLongObject *)v, 3490 | bytes, sizeof(val), 3491 | is_little, !is_unsigned); 3492 | Py_DECREF(v); 3493 | if (likely(!ret)) 3494 | return val; 3495 | } 3496 | #endif 3497 | return (long) -1; 3498 | } 3499 | } else { 3500 | long val; 3501 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3502 | if (!tmp) return (long) -1; 3503 | val = __Pyx_PyInt_As_long(tmp); 3504 | Py_DECREF(tmp); 3505 | return val; 3506 | } 3507 | raise_overflow: 3508 | PyErr_SetString(PyExc_OverflowError, 3509 | "value too large to convert to long"); 3510 | return (long) -1; 3511 | raise_neg_overflow: 3512 | PyErr_SetString(PyExc_OverflowError, 3513 | "can't convert negative value to long"); 3514 | return (long) -1; 3515 | } 3516 | 3517 | static int __Pyx_check_binary_version(void) { 3518 | char ctversion[4], rtversion[4]; 3519 | PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); 3520 | PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); 3521 | if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { 3522 | char message[200]; 3523 | PyOS_snprintf(message, sizeof(message), 3524 | "compiletime version %s of module '%.100s' " 3525 | "does not match runtime version %s", 3526 | ctversion, __Pyx_MODULE_NAME, rtversion); 3527 | return PyErr_WarnEx(NULL, message, 1); 3528 | } 3529 | return 0; 3530 | } 3531 | 3532 | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 3533 | while (t->p) { 3534 | #if PY_MAJOR_VERSION < 3 3535 | if (t->is_unicode) { 3536 | *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); 3537 | } else if (t->intern) { 3538 | *t->p = PyString_InternFromString(t->s); 3539 | } else { 3540 | *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 3541 | } 3542 | #else 3543 | if (t->is_unicode | t->is_str) { 3544 | if (t->intern) { 3545 | *t->p = PyUnicode_InternFromString(t->s); 3546 | } else if (t->encoding) { 3547 | *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); 3548 | } else { 3549 | *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); 3550 | } 3551 | } else { 3552 | *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); 3553 | } 3554 | #endif 3555 | if (!*t->p) 3556 | return -1; 3557 | ++t; 3558 | } 3559 | return 0; 3560 | } 3561 | 3562 | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { 3563 | return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); 3564 | } 3565 | static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { 3566 | Py_ssize_t ignore; 3567 | return __Pyx_PyObject_AsStringAndSize(o, &ignore); 3568 | } 3569 | static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { 3570 | #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 3571 | if ( 3572 | #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 3573 | __Pyx_sys_getdefaultencoding_not_ascii && 3574 | #endif 3575 | PyUnicode_Check(o)) { 3576 | #if PY_VERSION_HEX < 0x03030000 3577 | char* defenc_c; 3578 | PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); 3579 | if (!defenc) return NULL; 3580 | defenc_c = PyBytes_AS_STRING(defenc); 3581 | #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 3582 | { 3583 | char* end = defenc_c + PyBytes_GET_SIZE(defenc); 3584 | char* c; 3585 | for (c = defenc_c; c < end; c++) { 3586 | if ((unsigned char) (*c) >= 128) { 3587 | PyUnicode_AsASCIIString(o); 3588 | return NULL; 3589 | } 3590 | } 3591 | } 3592 | #endif 3593 | *length = PyBytes_GET_SIZE(defenc); 3594 | return defenc_c; 3595 | #else 3596 | if (__Pyx_PyUnicode_READY(o) == -1) return NULL; 3597 | #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 3598 | if (PyUnicode_IS_ASCII(o)) { 3599 | *length = PyUnicode_GET_LENGTH(o); 3600 | return PyUnicode_AsUTF8(o); 3601 | } else { 3602 | PyUnicode_AsASCIIString(o); 3603 | return NULL; 3604 | } 3605 | #else 3606 | return PyUnicode_AsUTF8AndSize(o, length); 3607 | #endif 3608 | #endif 3609 | } else 3610 | #endif 3611 | #if !CYTHON_COMPILING_IN_PYPY 3612 | if (PyByteArray_Check(o)) { 3613 | *length = PyByteArray_GET_SIZE(o); 3614 | return PyByteArray_AS_STRING(o); 3615 | } else 3616 | #endif 3617 | { 3618 | char* result; 3619 | int r = PyBytes_AsStringAndSize(o, &result, length); 3620 | if (unlikely(r < 0)) { 3621 | return NULL; 3622 | } else { 3623 | return result; 3624 | } 3625 | } 3626 | } 3627 | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { 3628 | int is_true = x == Py_True; 3629 | if (is_true | (x == Py_False) | (x == Py_None)) return is_true; 3630 | else return PyObject_IsTrue(x); 3631 | } 3632 | static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { 3633 | PyNumberMethods *m; 3634 | const char *name = NULL; 3635 | PyObject *res = NULL; 3636 | #if PY_MAJOR_VERSION < 3 3637 | if (PyInt_Check(x) || PyLong_Check(x)) 3638 | #else 3639 | if (PyLong_Check(x)) 3640 | #endif 3641 | return Py_INCREF(x), x; 3642 | m = Py_TYPE(x)->tp_as_number; 3643 | #if PY_MAJOR_VERSION < 3 3644 | if (m && m->nb_int) { 3645 | name = "int"; 3646 | res = PyNumber_Int(x); 3647 | } 3648 | else if (m && m->nb_long) { 3649 | name = "long"; 3650 | res = PyNumber_Long(x); 3651 | } 3652 | #else 3653 | if (m && m->nb_int) { 3654 | name = "int"; 3655 | res = PyNumber_Long(x); 3656 | } 3657 | #endif 3658 | if (res) { 3659 | #if PY_MAJOR_VERSION < 3 3660 | if (!PyInt_Check(res) && !PyLong_Check(res)) { 3661 | #else 3662 | if (!PyLong_Check(res)) { 3663 | #endif 3664 | PyErr_Format(PyExc_TypeError, 3665 | "__%.4s__ returned non-%.4s (type %.200s)", 3666 | name, name, Py_TYPE(res)->tp_name); 3667 | Py_DECREF(res); 3668 | return NULL; 3669 | } 3670 | } 3671 | else if (!PyErr_Occurred()) { 3672 | PyErr_SetString(PyExc_TypeError, 3673 | "an integer is required"); 3674 | } 3675 | return res; 3676 | } 3677 | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { 3678 | Py_ssize_t ival; 3679 | PyObject *x; 3680 | #if PY_MAJOR_VERSION < 3 3681 | if (likely(PyInt_CheckExact(b))) 3682 | return PyInt_AS_LONG(b); 3683 | #endif 3684 | if (likely(PyLong_CheckExact(b))) { 3685 | #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 3686 | #if CYTHON_USE_PYLONG_INTERNALS 3687 | switch (Py_SIZE(b)) { 3688 | case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; 3689 | case 0: return 0; 3690 | case 1: return ((PyLongObject*)b)->ob_digit[0]; 3691 | } 3692 | #endif 3693 | #endif 3694 | return PyLong_AsSsize_t(b); 3695 | } 3696 | x = PyNumber_Index(b); 3697 | if (!x) return -1; 3698 | ival = PyInt_AsSsize_t(x); 3699 | Py_DECREF(x); 3700 | return ival; 3701 | } 3702 | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { 3703 | return PyInt_FromSize_t(ival); 3704 | } 3705 | 3706 | 3707 | #endif /* Py_PYTHON_H */ 3708 | --------------------------------------------------------------------------------