1 /* Generated by Cython 0.29.20 */
2
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6 #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8 #error Cython requires Python 2.6+ or Python 3.3+.
9 #else
10 #define CYTHON_ABI "0_29_20"
11 #define CYTHON_HEX_VERSION 0x001D14F0
12 #define CYTHON_FUTURE_DIVISION 0
13 #include <stddef.h>
14 #ifndef offsetof
15 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18 #ifndef __stdcall
19 #define __stdcall
20 #endif
21 #ifndef __cdecl
22 #define __cdecl
23 #endif
24 #ifndef __fastcall
25 #define __fastcall
26 #endif
27 #endif
28 #ifndef DL_IMPORT
29 #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32 #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36 #if PY_VERSION_HEX >= 0x02070000
37 #define HAVE_LONG_LONG
38 #endif
39 #endif
40 #ifndef PY_LONG_LONG
41 #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44 #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
47 #define CYTHON_COMPILING_IN_PYPY 1
48 #define CYTHON_COMPILING_IN_PYSTON 0
49 #define CYTHON_COMPILING_IN_CPYTHON 0
50 #undef CYTHON_USE_TYPE_SLOTS
51 #define CYTHON_USE_TYPE_SLOTS 0
52 #undef CYTHON_USE_PYTYPE_LOOKUP
53 #define CYTHON_USE_PYTYPE_LOOKUP 0
54 #if PY_VERSION_HEX < 0x03050000
55 #undef CYTHON_USE_ASYNC_SLOTS
56 #define CYTHON_USE_ASYNC_SLOTS 0
57 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58 #define CYTHON_USE_ASYNC_SLOTS 1
59 #endif
60 #undef CYTHON_USE_PYLIST_INTERNALS
61 #define CYTHON_USE_PYLIST_INTERNALS 0
62 #undef CYTHON_USE_UNICODE_INTERNALS
63 #define CYTHON_USE_UNICODE_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_WRITER
65 #define CYTHON_USE_UNICODE_WRITER 0
66 #undef CYTHON_USE_PYLONG_INTERNALS
67 #define CYTHON_USE_PYLONG_INTERNALS 0
68 #undef CYTHON_AVOID_BORROWED_REFS
69 #define CYTHON_AVOID_BORROWED_REFS 1
70 #undef CYTHON_ASSUME_SAFE_MACROS
71 #define CYTHON_ASSUME_SAFE_MACROS 0
72 #undef CYTHON_UNPACK_METHODS
73 #define CYTHON_UNPACK_METHODS 0
74 #undef CYTHON_FAST_THREAD_STATE
75 #define CYTHON_FAST_THREAD_STATE 0
76 #undef CYTHON_FAST_PYCALL
77 #define CYTHON_FAST_PYCALL 0
78 #undef CYTHON_PEP489_MULTI_PHASE_INIT
79 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80 #undef CYTHON_USE_TP_FINALIZE
81 #define CYTHON_USE_TP_FINALIZE 0
82 #undef CYTHON_USE_DICT_VERSIONS
83 #define CYTHON_USE_DICT_VERSIONS 0
84 #undef CYTHON_USE_EXC_INFO_STACK
85 #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87 #define CYTHON_COMPILING_IN_PYPY 0
88 #define CYTHON_COMPILING_IN_PYSTON 1
89 #define CYTHON_COMPILING_IN_CPYTHON 0
90 #ifndef CYTHON_USE_TYPE_SLOTS
91 #define CYTHON_USE_TYPE_SLOTS 1
92 #endif
93 #undef CYTHON_USE_PYTYPE_LOOKUP
94 #define CYTHON_USE_PYTYPE_LOOKUP 0
95 #undef CYTHON_USE_ASYNC_SLOTS
96 #define CYTHON_USE_ASYNC_SLOTS 0
97 #undef CYTHON_USE_PYLIST_INTERNALS
98 #define CYTHON_USE_PYLIST_INTERNALS 0
99 #ifndef CYTHON_USE_UNICODE_INTERNALS
100 #define CYTHON_USE_UNICODE_INTERNALS 1
101 #endif
102 #undef CYTHON_USE_UNICODE_WRITER
103 #define CYTHON_USE_UNICODE_WRITER 0
104 #undef CYTHON_USE_PYLONG_INTERNALS
105 #define CYTHON_USE_PYLONG_INTERNALS 0
106 #ifndef CYTHON_AVOID_BORROWED_REFS
107 #define CYTHON_AVOID_BORROWED_REFS 0
108 #endif
109 #ifndef CYTHON_ASSUME_SAFE_MACROS
110 #define CYTHON_ASSUME_SAFE_MACROS 1
111 #endif
112 #ifndef CYTHON_UNPACK_METHODS
113 #define CYTHON_UNPACK_METHODS 1
114 #endif
115 #undef CYTHON_FAST_THREAD_STATE
116 #define CYTHON_FAST_THREAD_STATE 0
117 #undef CYTHON_FAST_PYCALL
118 #define CYTHON_FAST_PYCALL 0
119 #undef CYTHON_PEP489_MULTI_PHASE_INIT
120 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121 #undef CYTHON_USE_TP_FINALIZE
122 #define CYTHON_USE_TP_FINALIZE 0
123 #undef CYTHON_USE_DICT_VERSIONS
124 #define CYTHON_USE_DICT_VERSIONS 0
125 #undef CYTHON_USE_EXC_INFO_STACK
126 #define CYTHON_USE_EXC_INFO_STACK 0
127 #else
128 #define CYTHON_COMPILING_IN_PYPY 0
129 #define CYTHON_COMPILING_IN_PYSTON 0
130 #define CYTHON_COMPILING_IN_CPYTHON 1
131 #ifndef CYTHON_USE_TYPE_SLOTS
132 #define CYTHON_USE_TYPE_SLOTS 1
133 #endif
134 #if PY_VERSION_HEX < 0x02070000
135 #undef CYTHON_USE_PYTYPE_LOOKUP
136 #define CYTHON_USE_PYTYPE_LOOKUP 0
137 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138 #define CYTHON_USE_PYTYPE_LOOKUP 1
139 #endif
140 #if PY_MAJOR_VERSION < 3
141 #undef CYTHON_USE_ASYNC_SLOTS
142 #define CYTHON_USE_ASYNC_SLOTS 0
143 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144 #define CYTHON_USE_ASYNC_SLOTS 1
145 #endif
146 #if PY_VERSION_HEX < 0x02070000
147 #undef CYTHON_USE_PYLONG_INTERNALS
148 #define CYTHON_USE_PYLONG_INTERNALS 0
149 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150 #define CYTHON_USE_PYLONG_INTERNALS 1
151 #endif
152 #ifndef CYTHON_USE_PYLIST_INTERNALS
153 #define CYTHON_USE_PYLIST_INTERNALS 1
154 #endif
155 #ifndef CYTHON_USE_UNICODE_INTERNALS
156 #define CYTHON_USE_UNICODE_INTERNALS 1
157 #endif
158 #if PY_VERSION_HEX < 0x030300F0
159 #undef CYTHON_USE_UNICODE_WRITER
160 #define CYTHON_USE_UNICODE_WRITER 0
161 #elif !defined(CYTHON_USE_UNICODE_WRITER)
162 #define CYTHON_USE_UNICODE_WRITER 1
163 #endif
164 #ifndef CYTHON_AVOID_BORROWED_REFS
165 #define CYTHON_AVOID_BORROWED_REFS 0
166 #endif
167 #ifndef CYTHON_ASSUME_SAFE_MACROS
168 #define CYTHON_ASSUME_SAFE_MACROS 1
169 #endif
170 #ifndef CYTHON_UNPACK_METHODS
171 #define CYTHON_UNPACK_METHODS 1
172 #endif
173 #ifndef CYTHON_FAST_THREAD_STATE
174 #define CYTHON_FAST_THREAD_STATE 1
175 #endif
176 #ifndef CYTHON_FAST_PYCALL
177 #define CYTHON_FAST_PYCALL 1
178 #endif
179 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181 #endif
182 #ifndef CYTHON_USE_TP_FINALIZE
183 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184 #endif
185 #ifndef CYTHON_USE_DICT_VERSIONS
186 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187 #endif
188 #ifndef CYTHON_USE_EXC_INFO_STACK
189 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190 #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196 #include "longintrepr.h"
197 #undef SHIFT
198 #undef BASE
199 #undef MASK
200 #ifdef SIZEOF_VOID_P
201 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202 #endif
203 #endif
204 #ifndef __has_attribute
205 #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208 #define __has_cpp_attribute(x) 0
209 #endif
210 #ifndef CYTHON_RESTRICT
211 #if defined(__GNUC__)
212 #define CYTHON_RESTRICT __restrict__
213 #elif defined(_MSC_VER) && _MSC_VER >= 1400
214 #define CYTHON_RESTRICT __restrict
215 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216 #define CYTHON_RESTRICT restrict
217 #else
218 #define CYTHON_RESTRICT
219 #endif
220 #endif
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 # define CYTHON_UNUSED __attribute__ ((__unused__))
225 # else
226 # define CYTHON_UNUSED
227 # endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 # define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 # define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 # else
238 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 # endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 # define CYTHON_NCP_UNUSED
244 # else
245 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250 #ifndef _MSC_STDINT_H_
251 #if _MSC_VER < 1300
252 typedef unsigned char uint8_t;
253 typedef unsigned int uint32_t;
254 #else
255 typedef unsigned __int8 uint8_t;
256 typedef unsigned __int32 uint32_t;
257 #endif
258 #endif
259 #else
260 #include <stdint.h>
261 #endif
262 #ifndef CYTHON_FALLTHROUGH
263 #if defined(__cplusplus) && __cplusplus >= 201103L
264 #if __has_cpp_attribute(fallthrough)
265 #define CYTHON_FALLTHROUGH [[fallthrough]]
266 #elif __has_cpp_attribute(clang::fallthrough)
267 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268 #elif __has_cpp_attribute(gnu::fallthrough)
269 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
270 #endif
271 #endif
272 #ifndef CYTHON_FALLTHROUGH
273 #if __has_attribute(fallthrough)
274 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275 #else
276 #define CYTHON_FALLTHROUGH
277 #endif
278 #endif
279 #if defined(__clang__ ) && defined(__apple_build_version__)
280 #if __apple_build_version__ < 7000000
281 #undef CYTHON_FALLTHROUGH
282 #define CYTHON_FALLTHROUGH
283 #endif
284 #endif
285 #endif
286
287 #ifndef CYTHON_INLINE
288 #if defined(__clang__)
289 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290 #elif defined(__GNUC__)
291 #define CYTHON_INLINE __inline__
292 #elif defined(_MSC_VER)
293 #define CYTHON_INLINE __inline
294 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295 #define CYTHON_INLINE inline
296 #else
297 #define CYTHON_INLINE
298 #endif
299 #endif
300
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302 #define Py_OptimizeFlag 0
303 #endif
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310 #define __Pyx_DefaultClassType PyClass_Type
311 #else
312 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
316 #else
317 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
319 #endif
320 #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323 #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326 #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332 #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335 #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338 #ifndef METH_FASTCALL
339 #define METH_FASTCALL 0x80
340 #endif
341 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
342 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
343 Py_ssize_t nargs, PyObject *kwnames);
344 #else
345 #define __Pyx_PyCFunctionFast _PyCFunctionFast
346 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355 #define PyObject_Malloc(s) PyMem_Malloc(s)
356 #define PyObject_Free(p) PyMem_Free(p)
357 #define PyObject_Realloc(p) PyMem_Realloc(p)
358 #endif
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
361 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
362 #define PyMem_RawFree(p) PyMem_Free(p)
363 #endif
364 #if CYTHON_COMPILING_IN_PYSTON
365 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
366 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
367 #else
368 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
369 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
370 #endif
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372 #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376 #define __Pyx_PyThreadState_Current PyThreadState_GET()
377 #else
378 #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385 *key = PyThread_create_key();
386 return 0;
387 }
PyThread_tss_alloc(void)388 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
389 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
390 *key = Py_tss_NEEDS_INIT;
391 return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394 PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397 return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400 PyThread_delete_key(*key);
401 *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404 return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407 return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
414 #endif
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
417 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
418 #else
419 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
420 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
426 #endif
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428 #define CYTHON_PEP393_ENABLED 1
429 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
430 0 : _PyUnicode_Ready((PyObject *)(op)))
431 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
432 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
434 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
435 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
436 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
437 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
438 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
439 #else
440 #define CYTHON_PEP393_ENABLED 0
441 #define PyUnicode_1BYTE_KIND 1
442 #define PyUnicode_2BYTE_KIND 2
443 #define PyUnicode_4BYTE_KIND 4
444 #define __Pyx_PyUnicode_READY(op) (0)
445 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
446 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
447 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
448 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
449 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
450 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
451 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
452 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
453 #endif
454 #if CYTHON_COMPILING_IN_PYPY
455 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
456 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
457 #else
458 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
459 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
460 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
461 #endif
462 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
463 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
464 #endif
465 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
466 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
469 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
470 #endif
471 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
472 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
473 #if PY_MAJOR_VERSION >= 3
474 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
475 #else
476 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
477 #endif
478 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
479 #define PyObject_ASCII(o) PyObject_Repr(o)
480 #endif
481 #if PY_MAJOR_VERSION >= 3
482 #define PyBaseString_Type PyUnicode_Type
483 #define PyStringObject PyUnicodeObject
484 #define PyString_Type PyUnicode_Type
485 #define PyString_Check PyUnicode_Check
486 #define PyString_CheckExact PyUnicode_CheckExact
487 #ifndef PyObject_Unicode
488 #define PyObject_Unicode PyObject_Str
489 #endif
490 #endif
491 #if PY_MAJOR_VERSION >= 3
492 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
493 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
494 #else
495 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
496 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
497 #endif
498 #ifndef PySet_CheckExact
499 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
500 #endif
501 #if PY_VERSION_HEX >= 0x030900A4
502 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
503 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
504 #else
505 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
506 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
507 #endif
508 #if CYTHON_ASSUME_SAFE_MACROS
509 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
510 #else
511 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
512 #endif
513 #if PY_MAJOR_VERSION >= 3
514 #define PyIntObject PyLongObject
515 #define PyInt_Type PyLong_Type
516 #define PyInt_Check(op) PyLong_Check(op)
517 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
518 #define PyInt_FromString PyLong_FromString
519 #define PyInt_FromUnicode PyLong_FromUnicode
520 #define PyInt_FromLong PyLong_FromLong
521 #define PyInt_FromSize_t PyLong_FromSize_t
522 #define PyInt_FromSsize_t PyLong_FromSsize_t
523 #define PyInt_AsLong PyLong_AsLong
524 #define PyInt_AS_LONG PyLong_AS_LONG
525 #define PyInt_AsSsize_t PyLong_AsSsize_t
526 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
527 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
528 #define PyNumber_Int PyNumber_Long
529 #endif
530 #if PY_MAJOR_VERSION >= 3
531 #define PyBoolObject PyLongObject
532 #endif
533 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
534 #ifndef PyUnicode_InternFromString
535 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
536 #endif
537 #endif
538 #if PY_VERSION_HEX < 0x030200A4
539 typedef long Py_hash_t;
540 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
541 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
542 #else
543 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
544 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
545 #endif
546 #if PY_MAJOR_VERSION >= 3
547 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
548 #else
549 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
550 #endif
551 #if CYTHON_USE_ASYNC_SLOTS
552 #if PY_VERSION_HEX >= 0x030500B1
553 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
554 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
555 #else
556 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
557 #endif
558 #else
559 #define __Pyx_PyType_AsAsync(obj) NULL
560 #endif
561 #ifndef __Pyx_PyAsyncMethodsStruct
562 typedef struct {
563 unaryfunc am_await;
564 unaryfunc am_aiter;
565 unaryfunc am_anext;
566 } __Pyx_PyAsyncMethodsStruct;
567 #endif
568
569 #if defined(WIN32) || defined(MS_WINDOWS)
570 #define _USE_MATH_DEFINES
571 #endif
572 #include <math.h>
573 #ifdef NAN
574 #define __PYX_NAN() ((float) NAN)
575 #else
__PYX_NAN()576 static CYTHON_INLINE float __PYX_NAN() {
577 float value;
578 memset(&value, 0xFF, sizeof(value));
579 return value;
580 }
581 #endif
582 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
583 #define __Pyx_truncl trunc
584 #else
585 #define __Pyx_truncl truncl
586 #endif
587
588 #define __PYX_MARK_ERR_POS(f_index, lineno) \
589 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
590 #define __PYX_ERR(f_index, lineno, Ln_error) \
591 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
592
593 #ifndef __PYX_EXTERN_C
594 #ifdef __cplusplus
595 #define __PYX_EXTERN_C extern "C"
596 #else
597 #define __PYX_EXTERN_C extern
598 #endif
599 #endif
600
601 #define __PYX_HAVE__pygame_sdl2__surface
602 #define __PYX_HAVE_API__pygame_sdl2__surface
603 /* Early includes */
604 #include <stdint.h>
605 #include <string.h>
606 #include <stdio.h>
607 #include <stddef.h>
608 #include "SDL.h"
609 #include "src/surface.h"
610 #ifdef _OPENMP
611 #include <omp.h>
612 #endif /* _OPENMP */
613
614 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
615 #define CYTHON_WITHOUT_ASSERTIONS
616 #endif
617
618 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
619 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
620
621 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
622 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
623 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
624 #define __PYX_DEFAULT_STRING_ENCODING ""
625 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
626 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
627 #define __Pyx_uchar_cast(c) ((unsigned char)c)
628 #define __Pyx_long_cast(x) ((long)x)
629 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
630 (sizeof(type) < sizeof(Py_ssize_t)) ||\
631 (sizeof(type) > sizeof(Py_ssize_t) &&\
632 likely(v < (type)PY_SSIZE_T_MAX ||\
633 v == (type)PY_SSIZE_T_MAX) &&\
634 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
635 v == (type)PY_SSIZE_T_MIN))) ||\
636 (sizeof(type) == sizeof(Py_ssize_t) &&\
637 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
638 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)639 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
640 return (size_t) i < (size_t) limit;
641 }
642 #if defined (__cplusplus) && __cplusplus >= 201103L
643 #include <cstdlib>
644 #define __Pyx_sst_abs(value) std::abs(value)
645 #elif SIZEOF_INT >= SIZEOF_SIZE_T
646 #define __Pyx_sst_abs(value) abs(value)
647 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
648 #define __Pyx_sst_abs(value) labs(value)
649 #elif defined (_MSC_VER)
650 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
651 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
652 #define __Pyx_sst_abs(value) llabs(value)
653 #elif defined (__GNUC__)
654 #define __Pyx_sst_abs(value) __builtin_llabs(value)
655 #else
656 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
657 #endif
658 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
659 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
660 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
661 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
662 #define __Pyx_PyBytes_FromString PyBytes_FromString
663 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
664 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
665 #if PY_MAJOR_VERSION < 3
666 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
667 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
668 #else
669 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
670 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
671 #endif
672 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
673 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
674 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
675 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
679 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
680 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
681 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
684 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
685 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
686 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
687 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)688 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
689 const Py_UNICODE *u_end = u;
690 while (*u_end++) ;
691 return (size_t)(u_end - u - 1);
692 }
693 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
694 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
695 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
696 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
697 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
698 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
699 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
700 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
701 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
702 #define __Pyx_PySequence_Tuple(obj)\
703 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
704 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
705 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
706 #if CYTHON_ASSUME_SAFE_MACROS
707 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
708 #else
709 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
710 #endif
711 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
712 #if PY_MAJOR_VERSION >= 3
713 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
714 #else
715 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
716 #endif
717 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
718 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
719 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)720 static int __Pyx_init_sys_getdefaultencoding_params(void) {
721 PyObject* sys;
722 PyObject* default_encoding = NULL;
723 PyObject* ascii_chars_u = NULL;
724 PyObject* ascii_chars_b = NULL;
725 const char* default_encoding_c;
726 sys = PyImport_ImportModule("sys");
727 if (!sys) goto bad;
728 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
729 Py_DECREF(sys);
730 if (!default_encoding) goto bad;
731 default_encoding_c = PyBytes_AsString(default_encoding);
732 if (!default_encoding_c) goto bad;
733 if (strcmp(default_encoding_c, "ascii") == 0) {
734 __Pyx_sys_getdefaultencoding_not_ascii = 0;
735 } else {
736 char ascii_chars[128];
737 int c;
738 for (c = 0; c < 128; c++) {
739 ascii_chars[c] = c;
740 }
741 __Pyx_sys_getdefaultencoding_not_ascii = 1;
742 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
743 if (!ascii_chars_u) goto bad;
744 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
745 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
746 PyErr_Format(
747 PyExc_ValueError,
748 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
749 default_encoding_c);
750 goto bad;
751 }
752 Py_DECREF(ascii_chars_u);
753 Py_DECREF(ascii_chars_b);
754 }
755 Py_DECREF(default_encoding);
756 return 0;
757 bad:
758 Py_XDECREF(default_encoding);
759 Py_XDECREF(ascii_chars_u);
760 Py_XDECREF(ascii_chars_b);
761 return -1;
762 }
763 #endif
764 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
765 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
766 #else
767 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
768 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
769 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)770 static int __Pyx_init_sys_getdefaultencoding_params(void) {
771 PyObject* sys;
772 PyObject* default_encoding = NULL;
773 char* default_encoding_c;
774 sys = PyImport_ImportModule("sys");
775 if (!sys) goto bad;
776 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
777 Py_DECREF(sys);
778 if (!default_encoding) goto bad;
779 default_encoding_c = PyBytes_AsString(default_encoding);
780 if (!default_encoding_c) goto bad;
781 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
782 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
783 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
784 Py_DECREF(default_encoding);
785 return 0;
786 bad:
787 Py_XDECREF(default_encoding);
788 return -1;
789 }
790 #endif
791 #endif
792
793
794 /* Test for GCC > 2.95 */
795 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
796 #define likely(x) __builtin_expect(!!(x), 1)
797 #define unlikely(x) __builtin_expect(!!(x), 0)
798 #else /* !__GNUC__ or GCC < 2.95 */
799 #define likely(x) (x)
800 #define unlikely(x) (x)
801 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)802 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
803
804 static PyObject *__pyx_m = NULL;
805 static PyObject *__pyx_d;
806 static PyObject *__pyx_b;
807 static PyObject *__pyx_cython_runtime = NULL;
808 static PyObject *__pyx_empty_tuple;
809 static PyObject *__pyx_empty_bytes;
810 static PyObject *__pyx_empty_unicode;
811 static int __pyx_lineno;
812 static int __pyx_clineno = 0;
813 static const char * __pyx_cfilenm= __FILE__;
814 static const char *__pyx_filename;
815
816
817 static const char *__pyx_f[] = {
818 "src/pygame_sdl2/surface.pyx",
819 "stringsource",
820 "src/pygame_sdl2/color.pxd",
821 "src/pygame_sdl2/rect.pxd",
822 };
823 /* NoFastGil.proto */
824 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
825 #define __Pyx_PyGILState_Release PyGILState_Release
826 #define __Pyx_FastGIL_Remember()
827 #define __Pyx_FastGIL_Forget()
828 #define __Pyx_FastGilFuncInit()
829
830 /* ForceInitThreads.proto */
831 #ifndef __PYX_FORCE_INIT_THREADS
832 #define __PYX_FORCE_INIT_THREADS 0
833 #endif
834
835
836 /*--- Type declarations ---*/
837 struct __pyx_obj_11pygame_sdl2_5color_Color;
838 struct __pyx_obj_11pygame_sdl2_4rect_Rect;
839 struct __pyx_obj_11pygame_sdl2_7surface_Surface;
840 struct __pyx_opt_args_11pygame_sdl2_4rect_to_sdl_rect;
841
842 /* "pygame_sdl2/rect.pxd":31
843 *
844 *
845 * cdef int to_sdl_rect(rectlike, SDL_Rect *rect, argname=*) except -1 # <<<<<<<<<<<<<<
846 */
847 struct __pyx_opt_args_11pygame_sdl2_4rect_to_sdl_rect {
848 int __pyx_n;
849 PyObject *argname;
850 };
851
852 /* "pygame_sdl2/color.pxd":26
853 * cdef to_sdl_color(color, SDL_Color *out)
854 *
855 * cdef class Color: # <<<<<<<<<<<<<<
856 * # Allow weak references.
857 * cdef object __weakref__
858 */
859 struct __pyx_obj_11pygame_sdl2_5color_Color {
860 PyObject_HEAD
861 struct __pyx_vtabstruct_11pygame_sdl2_5color_Color *__pyx_vtab;
862 PyObject *__weakref__;
863 Uint8 r;
864 Uint8 g;
865 Uint8 b;
866 Uint8 a;
867 uint8_t length;
868 };
869
870
871 /* "pygame_sdl2/rect.pxd":21
872 * from sdl2 cimport *
873 *
874 * cdef class Rect: # <<<<<<<<<<<<<<
875 * # Allow weak references.
876 * cdef object __weakref__
877 */
878 struct __pyx_obj_11pygame_sdl2_4rect_Rect {
879 PyObject_HEAD
880 PyObject *__weakref__;
881 int x;
882 int y;
883 int w;
884 int h;
885 };
886
887
888 /* "pygame_sdl2/surface.pxd":23
889 * from sdl2 cimport SDL_Surface
890 *
891 * cdef class Surface: # <<<<<<<<<<<<<<
892 * # Allow weak references.
893 * cdef object __weakref__
894 */
895 struct __pyx_obj_11pygame_sdl2_7surface_Surface {
896 PyObject_HEAD
897 struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *__pyx_vtab;
898 PyObject *__weakref__;
899 SDL_Surface *surface;
900 int owns_surface;
901 int window_surface;
902 PyObject *locklist;
903 struct __pyx_obj_11pygame_sdl2_7surface_Surface *parent;
904 struct __pyx_obj_11pygame_sdl2_7surface_Surface *root;
905 int offset_x;
906 int offset_y;
907 PyObject *get_window_flags;
908 int has_alpha;
909 };
910
911
912
913 /* "pygame_sdl2/color.pxd":26
914 * cdef to_sdl_color(color, SDL_Color *out)
915 *
916 * cdef class Color: # <<<<<<<<<<<<<<
917 * # Allow weak references.
918 * cdef object __weakref__
919 */
920
921 struct __pyx_vtabstruct_11pygame_sdl2_5color_Color {
922 PyObject *(*from_rgba)(struct __pyx_obj_11pygame_sdl2_5color_Color *, Uint8, Uint8, Uint8, Uint8);
923 PyObject *(*from_name)(struct __pyx_obj_11pygame_sdl2_5color_Color *, PyObject *);
924 PyObject *(*from_hex)(struct __pyx_obj_11pygame_sdl2_5color_Color *, PyObject *);
925 };
926 static struct __pyx_vtabstruct_11pygame_sdl2_5color_Color *__pyx_vtabptr_11pygame_sdl2_5color_Color;
927
928
929 /* "pygame_sdl2/surface.pyx":53
930 * total_size = 0
931 *
932 * cdef class Surface: # <<<<<<<<<<<<<<
933 *
934 * def __cinit__(self):
935 */
936
937 struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface {
938 void (*take_surface)(struct __pyx_obj_11pygame_sdl2_7surface_Surface *, SDL_Surface *);
939 };
940 static struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *__pyx_vtabptr_11pygame_sdl2_7surface_Surface;
941
942 /* --- Runtime support code (head) --- */
943 /* Refnanny.proto */
944 #ifndef CYTHON_REFNANNY
945 #define CYTHON_REFNANNY 0
946 #endif
947 #if CYTHON_REFNANNY
948 typedef struct {
949 void (*INCREF)(void*, PyObject*, int);
950 void (*DECREF)(void*, PyObject*, int);
951 void (*GOTREF)(void*, PyObject*, int);
952 void (*GIVEREF)(void*, PyObject*, int);
953 void* (*SetupContext)(const char*, int, const char*);
954 void (*FinishContext)(void**);
955 } __Pyx_RefNannyAPIStruct;
956 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
957 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
958 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
959 #ifdef WITH_THREAD
960 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
961 if (acquire_gil) {\
962 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
963 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
964 PyGILState_Release(__pyx_gilstate_save);\
965 } else {\
966 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
967 }
968 #else
969 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
970 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
971 #endif
972 #define __Pyx_RefNannyFinishContext()\
973 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
974 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
975 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
976 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
977 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
978 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
979 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
980 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
981 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
982 #else
983 #define __Pyx_RefNannyDeclarations
984 #define __Pyx_RefNannySetupContext(name, acquire_gil)
985 #define __Pyx_RefNannyFinishContext()
986 #define __Pyx_INCREF(r) Py_INCREF(r)
987 #define __Pyx_DECREF(r) Py_DECREF(r)
988 #define __Pyx_GOTREF(r)
989 #define __Pyx_GIVEREF(r)
990 #define __Pyx_XINCREF(r) Py_XINCREF(r)
991 #define __Pyx_XDECREF(r) Py_XDECREF(r)
992 #define __Pyx_XGOTREF(r)
993 #define __Pyx_XGIVEREF(r)
994 #endif
995 #define __Pyx_XDECREF_SET(r, v) do {\
996 PyObject *tmp = (PyObject *) r;\
997 r = v; __Pyx_XDECREF(tmp);\
998 } while (0)
999 #define __Pyx_DECREF_SET(r, v) do {\
1000 PyObject *tmp = (PyObject *) r;\
1001 r = v; __Pyx_DECREF(tmp);\
1002 } while (0)
1003 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1004 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1005
1006 /* PyObjectGetAttrStr.proto */
1007 #if CYTHON_USE_TYPE_SLOTS
1008 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1009 #else
1010 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1011 #endif
1012
1013 /* GetBuiltinName.proto */
1014 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1015
1016 /* RaiseArgTupleInvalid.proto */
1017 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1018 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1019
1020 /* KeywordStringCheck.proto */
1021 static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
1022
1023 /* PyDictVersioning.proto */
1024 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1025 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1026 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1027 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1028 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1029 (cache_var) = (value);
1030 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1031 static PY_UINT64_T __pyx_dict_version = 0;\
1032 static PyObject *__pyx_dict_cached_value = NULL;\
1033 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1034 (VAR) = __pyx_dict_cached_value;\
1035 } else {\
1036 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1037 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1038 }\
1039 }
1040 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1041 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1042 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1043 #else
1044 #define __PYX_GET_DICT_VERSION(dict) (0)
1045 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1046 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1047 #endif
1048
1049 /* GetModuleGlobalName.proto */
1050 #if CYTHON_USE_DICT_VERSIONS
1051 #define __Pyx_GetModuleGlobalName(var, name) {\
1052 static PY_UINT64_T __pyx_dict_version = 0;\
1053 static PyObject *__pyx_dict_cached_value = NULL;\
1054 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1055 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1056 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1057 }
1058 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1059 PY_UINT64_T __pyx_dict_version;\
1060 PyObject *__pyx_dict_cached_value;\
1061 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1062 }
1063 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1064 #else
1065 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1066 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1067 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1068 #endif
1069
1070 /* PyCFunctionFastCall.proto */
1071 #if CYTHON_FAST_PYCCALL
1072 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1073 #else
1074 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1075 #endif
1076
1077 /* PyFunctionFastCall.proto */
1078 #if CYTHON_FAST_PYCALL
1079 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1080 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1081 #if 1 || PY_VERSION_HEX < 0x030600B1
1082 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1083 #else
1084 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1085 #endif
1086 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1087 (sizeof(char [1 - 2*!(cond)]) - 1)
1088 #ifndef Py_MEMBER_SIZE
1089 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1090 #endif
1091 static size_t __pyx_pyframe_localsplus_offset = 0;
1092 #include "frameobject.h"
1093 #define __Pxy_PyFrame_Initialize_Offsets()\
1094 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1095 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1096 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1097 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1098 #endif
1099
1100 /* PyObjectCall.proto */
1101 #if CYTHON_COMPILING_IN_CPYTHON
1102 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1103 #else
1104 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1105 #endif
1106
1107 /* PyObjectCall2Args.proto */
1108 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1109
1110 /* PyObjectCallMethO.proto */
1111 #if CYTHON_COMPILING_IN_CPYTHON
1112 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1113 #endif
1114
1115 /* PyObjectCallOneArg.proto */
1116 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1117
1118 /* PyThreadStateGet.proto */
1119 #if CYTHON_FAST_THREAD_STATE
1120 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1121 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1122 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1123 #else
1124 #define __Pyx_PyThreadState_declare
1125 #define __Pyx_PyThreadState_assign
1126 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1127 #endif
1128
1129 /* PyErrFetchRestore.proto */
1130 #if CYTHON_FAST_THREAD_STATE
1131 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1132 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1133 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1134 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1135 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1136 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1137 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1138 #if CYTHON_COMPILING_IN_CPYTHON
1139 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1140 #else
1141 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1142 #endif
1143 #else
1144 #define __Pyx_PyErr_Clear() PyErr_Clear()
1145 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1146 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1147 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1148 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1149 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1150 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1151 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1152 #endif
1153
1154 /* WriteUnraisableException.proto */
1155 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1156 int lineno, const char *filename,
1157 int full_traceback, int nogil);
1158
1159 /* RaiseDoubleKeywords.proto */
1160 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1161
1162 /* ParseKeywords.proto */
1163 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1164 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1165 const char* function_name);
1166
1167 /* RaiseTooManyValuesToUnpack.proto */
1168 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1169
1170 /* RaiseNeedMoreValuesToUnpack.proto */
1171 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1172
1173 /* IterFinish.proto */
1174 static CYTHON_INLINE int __Pyx_IterFinish(void);
1175
1176 /* UnpackItemEndCheck.proto */
1177 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1178
1179 /* ExtTypeTest.proto */
1180 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1181
1182 /* PyObjectCallNoArg.proto */
1183 #if CYTHON_COMPILING_IN_CPYTHON
1184 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1185 #else
1186 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1187 #endif
1188
1189 /* RaiseException.proto */
1190 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1191
1192 /* ArgTypeTest.proto */
1193 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1194 ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1195 __Pyx__ArgTypeTest(obj, type, name, exact))
1196 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1197
1198 /* GetItemInt.proto */
1199 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1200 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1201 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1202 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1203 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1204 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1205 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1206 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1207 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1208 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1209 int wraparound, int boundscheck);
1210 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1211 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1212 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1213 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1214 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1215 int wraparound, int boundscheck);
1216 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1217 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1218 int is_list, int wraparound, int boundscheck);
1219
1220 /* ListAppend.proto */
1221 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1222 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1223 PyListObject* L = (PyListObject*) list;
1224 Py_ssize_t len = Py_SIZE(list);
1225 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1226 Py_INCREF(x);
1227 PyList_SET_ITEM(list, len, x);
1228 __Pyx_SET_SIZE(list, len + 1);
1229 return 0;
1230 }
1231 return PyList_Append(list, x);
1232 }
1233 #else
1234 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1235 #endif
1236
1237 /* PyObjectGetMethod.proto */
1238 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1239
1240 /* PyObjectCallMethod1.proto */
1241 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
1242
1243 /* append.proto */
1244 static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);
1245
1246 /* py_dict_items.proto */
1247 static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
1248
1249 /* UnpackUnboundCMethod.proto */
1250 typedef struct {
1251 PyObject *type;
1252 PyObject **method_name;
1253 PyCFunction func;
1254 PyObject *method;
1255 int flag;
1256 } __Pyx_CachedCFunction;
1257
1258 /* CallUnboundCMethod0.proto */
1259 static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
1260 #if CYTHON_COMPILING_IN_CPYTHON
1261 #define __Pyx_CallUnboundCMethod0(cfunc, self)\
1262 (likely((cfunc)->func) ?\
1263 (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\
1264 (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
1265 (PY_VERSION_HEX >= 0x030700A0 ?\
1266 (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
1267 (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
1268 (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
1269 (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
1270 (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
1271 ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\
1272 __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
1273 __Pyx__CallUnboundCMethod0(cfunc, self))
1274 #else
1275 #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
1276 #endif
1277
1278 /* PyObject_GenericGetAttrNoDict.proto */
1279 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1280 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1281 #else
1282 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1283 #endif
1284
1285 /* PyObject_GenericGetAttr.proto */
1286 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1287 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1288 #else
1289 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1290 #endif
1291
1292 /* SetVTable.proto */
1293 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1294
1295 /* PyErrExceptionMatches.proto */
1296 #if CYTHON_FAST_THREAD_STATE
1297 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1298 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1299 #else
1300 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1301 #endif
1302
1303 /* PyObjectGetAttrStrNoError.proto */
1304 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1305
1306 /* SetupReduce.proto */
1307 static int __Pyx_setup_reduce(PyObject* type_obj);
1308
1309 /* TypeImport.proto */
1310 #ifndef __PYX_HAVE_RT_ImportType_proto
1311 #define __PYX_HAVE_RT_ImportType_proto
1312 enum __Pyx_ImportType_CheckSize {
1313 __Pyx_ImportType_CheckSize_Error = 0,
1314 __Pyx_ImportType_CheckSize_Warn = 1,
1315 __Pyx_ImportType_CheckSize_Ignore = 2
1316 };
1317 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1318 #endif
1319
1320 /* GetVTable.proto */
1321 static void* __Pyx_GetVtable(PyObject *dict);
1322
1323 /* Import.proto */
1324 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1325
1326 /* ImportFrom.proto */
1327 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1328
1329 /* CLineInTraceback.proto */
1330 #ifdef CYTHON_CLINE_IN_TRACEBACK
1331 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1332 #else
1333 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1334 #endif
1335
1336 /* CodeObjectCache.proto */
1337 typedef struct {
1338 PyCodeObject* code_object;
1339 int code_line;
1340 } __Pyx_CodeObjectCacheEntry;
1341 struct __Pyx_CodeObjectCache {
1342 int count;
1343 int max_count;
1344 __Pyx_CodeObjectCacheEntry* entries;
1345 };
1346 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1347 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1348 static PyCodeObject *__pyx_find_code_object(int code_line);
1349 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1350
1351 /* AddTraceback.proto */
1352 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1353 int py_line, const char *filename);
1354
1355 /* CIntToPy.proto */
1356 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1357
1358 /* CIntToPy.proto */
1359 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);
1360
1361 /* CIntToPy.proto */
1362 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);
1363
1364 /* CIntToPy.proto */
1365 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1366
1367 /* CIntToPy.proto */
1368 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);
1369
1370 /* CIntFromPy.proto */
1371 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1372
1373 /* CIntFromPy.proto */
1374 static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);
1375
1376 /* CIntFromPy.proto */
1377 static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *);
1378
1379 /* CIntFromPy.proto */
1380 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1381
1382 /* FastTypeChecks.proto */
1383 #if CYTHON_COMPILING_IN_CPYTHON
1384 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1385 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1386 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1387 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1388 #else
1389 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1390 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1391 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1392 #endif
1393 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1394
1395 /* CheckBinaryVersion.proto */
1396 static int __Pyx_check_binary_version(void);
1397
1398 /* FunctionExport.proto */
1399 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
1400
1401 /* FunctionImport.proto */
1402 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
1403
1404 /* InitStrings.proto */
1405 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1406
1407 static void __pyx_f_11pygame_sdl2_7surface_7Surface_take_surface(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, SDL_Surface *__pyx_v_surface); /* proto*/
1408
1409 /* Module declarations from 'libc.stdint' */
1410
1411 /* Module declarations from 'libc.string' */
1412
1413 /* Module declarations from 'libc.stdio' */
1414
1415 /* Module declarations from 'libc.stddef' */
1416
1417 /* Module declarations from 'sdl2' */
1418
1419 /* Module declarations from 'pygame_sdl2.color' */
1420 static PyTypeObject *__pyx_ptype_11pygame_sdl2_5color_Color = 0;
1421 static Uint32 (*__pyx_f_11pygame_sdl2_5color_map_color)(SDL_Surface *, PyObject *); /*proto*/
1422 static PyObject *(*__pyx_f_11pygame_sdl2_5color_get_color)(Uint32, SDL_Surface *); /*proto*/
1423
1424 /* Module declarations from 'pygame_sdl2.rect' */
1425 static PyTypeObject *__pyx_ptype_11pygame_sdl2_4rect_Rect = 0;
1426 static int (*__pyx_f_11pygame_sdl2_4rect_to_sdl_rect)(PyObject *, SDL_Rect *, struct __pyx_opt_args_11pygame_sdl2_4rect_to_sdl_rect *__pyx_optional_args); /*proto*/
1427
1428 /* Module declarations from 'pygame_sdl2.surface' */
1429 static PyTypeObject *__pyx_ptype_11pygame_sdl2_7surface_Surface = 0;
1430 static void __pyx_f_11pygame_sdl2_7surface_move_pixels(Uint8 *, Uint8 *, int, int, int, int); /*proto*/
1431 static SDL_Surface *__pyx_f_11pygame_sdl2_7surface_PySurface_AsSurface(PyObject *); /*proto*/
1432 static PyObject *__pyx_f_11pygame_sdl2_7surface_PySurface_New(SDL_Surface *); /*proto*/
1433 #define __Pyx_MODULE_NAME "pygame_sdl2.surface"
1434 extern int __pyx_module_is_main_pygame_sdl2__surface;
1435 int __pyx_module_is_main_pygame_sdl2__surface = 0;
1436
1437 /* Implementation of 'pygame_sdl2.surface' */
1438 static PyObject *__pyx_builtin_IndexError;
1439 static PyObject *__pyx_builtin_ValueError;
1440 static PyObject *__pyx_builtin_TypeError;
1441 static const char __pyx_k_2[] = "2";
1442 static const char __pyx_k_dx[] = "dx";
1443 static const char __pyx_k_dy[] = "dy";
1444 static const char __pyx_k_pos[] = "pos";
1445 static const char __pyx_k_Rect[] = "Rect";
1446 static const char __pyx_k_area[] = "area";
1447 static const char __pyx_k_clip[] = "clip";
1448 static const char __pyx_k_dest[] = "dest";
1449 static const char __pyx_k_kind[] = "kind";
1450 static const char __pyx_k_lock[] = "lock";
1451 static const char __pyx_k_main[] = "__main__";
1452 static const char __pyx_k_name[] = "__name__";
1453 static const char __pyx_k_rect[] = "rect";
1454 static const char __pyx_k_size[] = "size";
1455 static const char __pyx_k_test[] = "__test__";
1456 static const char __pyx_k_warn[] = "warn";
1457 static const char __pyx_k_color[] = "color";
1458 static const char __pyx_k_depth[] = "depth";
1459 static const char __pyx_k_error[] = "error";
1460 static const char __pyx_k_flags[] = "flags";
1461 static const char __pyx_k_items[] = "items";
1462 static const char __pyx_k_masks[] = "masks";
1463 static const char __pyx_k_value[] = "value";
1464 static const char __pyx_k_append[] = "append";
1465 static const char __pyx_k_format[] = "format";
1466 static const char __pyx_k_import[] = "__import__";
1467 static const char __pyx_k_reduce[] = "__reduce__";
1468 static const char __pyx_k_remove[] = "remove";
1469 static const char __pyx_k_source[] = "source";
1470 static const char __pyx_k_unlock[] = "unlock";
1471 static const char __pyx_k_Surface[] = "Surface";
1472 static const char __pyx_k_convert[] = "convert";
1473 static const char __pyx_k_display[] = "display";
1474 static const char __pyx_k_surface[] = "surface";
1475 static const char __pyx_k_SRCALPHA[] = "SRCALPHA";
1476 static const char __pyx_k_get_rect[] = "get_rect";
1477 static const char __pyx_k_get_size[] = "get_size";
1478 static const char __pyx_k_getstate[] = "__getstate__";
1479 static const char __pyx_k_setstate[] = "__setstate__";
1480 static const char __pyx_k_warnings[] = "warnings";
1481 static const char __pyx_k_TypeError[] = "TypeError";
1482 static const char __pyx_k_get_alpha[] = "get_alpha";
1483 static const char __pyx_k_min_alpha[] = "min_alpha";
1484 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1485 static const char __pyx_k_set_alpha[] = "set_alpha";
1486 static const char __pyx_k_IndexError[] = "IndexError";
1487 static const char __pyx_k_ValueError[] = "ValueError";
1488 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
1489 static const char __pyx_k_subsurface[] = "subsurface";
1490 static const char __pyx_k_total_size[] = "total_size";
1491 static const char __pyx_k_Surface_x_x[] = "<Surface({}x{}x{})>";
1492 static const char __pyx_k_get_surface[] = "get_surface";
1493 static const char __pyx_k_pygame_sdl2[] = "pygame_sdl2";
1494 static const char __pyx_k_convert_alpha[] = "convert_alpha";
1495 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1496 static const char __pyx_k_special_flags[] = "special_flags";
1497 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1498 static const char __pyx_k_pygame_sdl2_rect[] = "pygame_sdl2.rect";
1499 static const char __pyx_k_pygame_sdl2_error[] = "pygame_sdl2.error";
1500 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1501 static const char __pyx_k_pygame_sdl2_locals[] = "pygame_sdl2.locals";
1502 static const char __pyx_k_Position_outside_surface[] = "Position outside surface.";
1503 static const char __pyx_k_A_null_pointer_was_passed_in[] = "A null pointer was passed in.";
1504 static const char __pyx_k_Memory_leak_via_Surface_in_pygam[] = "Memory leak via Surface in pygame_sdl2.";
1505 static const char __pyx_k_Surface_get_view_is_not_supporte[] = "Surface.get_view is not supported.";
1506 static const char __pyx_k_Surface_has_unsupported_bytesize[] = "Surface has unsupported bytesize.";
1507 static const char __pyx_k_Surface_set_masks_is_not_support[] = "Surface.set_masks is not supported.";
1508 static const char __pyx_k_Surface_set_shifts_is_not_suppor[] = "Surface.set_shifts is not supported.";
1509 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
1510 static const char __pyx_k_subsurface_rectangle_outside_sur[] = "subsurface rectangle outside surface area.";
1511 static const char __pyx_k_subsurface_size_must_be_non_nega[] = "subsurface size must be non-negative.";
1512 static PyObject *__pyx_kp_s_2;
1513 static PyObject *__pyx_kp_s_A_null_pointer_was_passed_in;
1514 static PyObject *__pyx_n_s_IndexError;
1515 static PyObject *__pyx_kp_s_Memory_leak_via_Surface_in_pygam;
1516 static PyObject *__pyx_kp_s_Position_outside_surface;
1517 static PyObject *__pyx_n_s_Rect;
1518 static PyObject *__pyx_n_s_SRCALPHA;
1519 static PyObject *__pyx_n_s_Surface;
1520 static PyObject *__pyx_kp_s_Surface_get_view_is_not_supporte;
1521 static PyObject *__pyx_kp_s_Surface_has_unsupported_bytesize;
1522 static PyObject *__pyx_kp_s_Surface_set_masks_is_not_support;
1523 static PyObject *__pyx_kp_s_Surface_set_shifts_is_not_suppor;
1524 static PyObject *__pyx_kp_s_Surface_x_x;
1525 static PyObject *__pyx_n_s_TypeError;
1526 static PyObject *__pyx_n_s_ValueError;
1527 static PyObject *__pyx_n_s_append;
1528 static PyObject *__pyx_n_s_area;
1529 static PyObject *__pyx_n_s_cline_in_traceback;
1530 static PyObject *__pyx_n_s_clip;
1531 static PyObject *__pyx_n_s_color;
1532 static PyObject *__pyx_n_s_convert;
1533 static PyObject *__pyx_n_s_convert_alpha;
1534 static PyObject *__pyx_n_s_depth;
1535 static PyObject *__pyx_n_s_dest;
1536 static PyObject *__pyx_n_s_display;
1537 static PyObject *__pyx_n_s_dx;
1538 static PyObject *__pyx_n_s_dy;
1539 static PyObject *__pyx_n_s_error;
1540 static PyObject *__pyx_n_s_flags;
1541 static PyObject *__pyx_n_s_format;
1542 static PyObject *__pyx_n_s_get_alpha;
1543 static PyObject *__pyx_n_s_get_rect;
1544 static PyObject *__pyx_n_s_get_size;
1545 static PyObject *__pyx_n_s_get_surface;
1546 static PyObject *__pyx_n_s_getstate;
1547 static PyObject *__pyx_n_s_import;
1548 static PyObject *__pyx_n_s_items;
1549 static PyObject *__pyx_n_s_kind;
1550 static PyObject *__pyx_n_s_lock;
1551 static PyObject *__pyx_n_s_main;
1552 static PyObject *__pyx_n_s_masks;
1553 static PyObject *__pyx_n_s_min_alpha;
1554 static PyObject *__pyx_n_s_name;
1555 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
1556 static PyObject *__pyx_n_s_pos;
1557 static PyObject *__pyx_n_s_pygame_sdl2;
1558 static PyObject *__pyx_n_s_pygame_sdl2_error;
1559 static PyObject *__pyx_n_s_pygame_sdl2_locals;
1560 static PyObject *__pyx_n_s_pygame_sdl2_rect;
1561 static PyObject *__pyx_n_s_pyx_vtable;
1562 static PyObject *__pyx_n_s_rect;
1563 static PyObject *__pyx_n_s_reduce;
1564 static PyObject *__pyx_n_s_reduce_cython;
1565 static PyObject *__pyx_n_s_reduce_ex;
1566 static PyObject *__pyx_n_s_remove;
1567 static PyObject *__pyx_n_s_set_alpha;
1568 static PyObject *__pyx_n_s_setstate;
1569 static PyObject *__pyx_n_s_setstate_cython;
1570 static PyObject *__pyx_n_s_size;
1571 static PyObject *__pyx_n_s_source;
1572 static PyObject *__pyx_n_s_special_flags;
1573 static PyObject *__pyx_n_s_subsurface;
1574 static PyObject *__pyx_kp_s_subsurface_rectangle_outside_sur;
1575 static PyObject *__pyx_kp_s_subsurface_size_must_be_non_nega;
1576 static PyObject *__pyx_n_s_surface;
1577 static PyObject *__pyx_n_s_test;
1578 static PyObject *__pyx_n_s_total_size;
1579 static PyObject *__pyx_n_s_unlock;
1580 static PyObject *__pyx_n_s_value;
1581 static PyObject *__pyx_n_s_warn;
1582 static PyObject *__pyx_n_s_warnings;
1583 static int __pyx_pf_11pygame_sdl2_7surface_7Surface___cinit__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1584 static void __pyx_pf_11pygame_sdl2_7surface_7Surface_2__dealloc__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1585 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_4__sizeof__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1586 static int __pyx_pf_11pygame_sdl2_7surface_7Surface_6__init__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_flags, PyObject *__pyx_v_depth, PyObject *__pyx_v_masks); /* proto */
1587 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_8__repr__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1588 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_10blit(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_source, PyObject *__pyx_v_dest, PyObject *__pyx_v_area, int __pyx_v_special_flags); /* proto */
1589 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_12convert(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_surface); /* proto */
1590 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_14convert_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_surface); /* proto */
1591 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_16copy(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1592 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_18fill(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color, PyObject *__pyx_v_rect, CYTHON_UNUSED PyObject *__pyx_v_special_flags); /* proto */
1593 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_20scroll(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, int __pyx_v_dx, int __pyx_v_dy); /* proto */
1594 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_22set_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color, CYTHON_UNUSED PyObject *__pyx_v_flags); /* proto */
1595 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_24get_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1596 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_26set_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_flags); /* proto */
1597 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_28get_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1598 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_30lock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_lock); /* proto */
1599 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_32unlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_lock); /* proto */
1600 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_34mustlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1601 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_36get_locked(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1602 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_38get_locks(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1603 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_40get_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos); /* proto */
1604 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_42set_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos, PyObject *__pyx_v_color); /* proto */
1605 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_44get_at_mapped(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos); /* proto */
1606 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_46map_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color); /* proto */
1607 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_48unmap_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pixel); /* proto */
1608 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_50set_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_rect); /* proto */
1609 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_52get_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1610 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_54subsurface(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
1611 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_56get_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1612 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_58get_abs_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1613 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_60get_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1614 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_62get_abs_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1615 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_64get_size(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1616 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_66get_width(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1617 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_68get_height(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1618 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_70get_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_kwargs); /* proto */
1619 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_72get_bitsize(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1620 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_74get_bytesize(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1621 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_76get_flags(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1622 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_78get_pitch(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1623 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_80get_masks(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1624 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_82set_masks(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_masks); /* proto */
1625 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_84get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1626 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_86set_shifts(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_shifts); /* proto */
1627 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_88get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1628 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_90get_losses(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1629 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_92get_bounding_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_min_alpha); /* proto */
1630 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_94get_view(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_kind); /* proto */
1631 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_96get_buffer(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1632 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_15_pixels_address___get__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1633 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_98__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self); /* proto */
1634 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_100__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1635 static PyObject *__pyx_tp_new_11pygame_sdl2_7surface_Surface(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1636 static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
1637 static PyObject *__pyx_int_0;
1638 static PyObject *__pyx_int_1;
1639 static PyObject *__pyx_int_32;
1640 static PyObject *__pyx_int_255;
1641 static PyObject *__pyx_int_16843009;
1642 static PyObject *__pyx_int_4294967295;
1643 static PyObject *__pyx_tuple_;
1644 static PyObject *__pyx_tuple__2;
1645 static PyObject *__pyx_tuple__3;
1646 static PyObject *__pyx_tuple__4;
1647 static PyObject *__pyx_tuple__5;
1648 /* Late includes */
1649
1650 /* "pygame_sdl2/surface.pyx":37
1651 * SDL_Surface * dst, SDL_Rect * dstrect, int the_args);
1652 *
1653 * cdef void move_pixels(Uint8 *src, Uint8 *dst, int h, int span, int srcpitch, int dstpitch) nogil: # <<<<<<<<<<<<<<
1654 * if src < dst:
1655 * src += (h - 1) * srcpitch;
1656 */
1657
__pyx_f_11pygame_sdl2_7surface_move_pixels(Uint8 * __pyx_v_src,Uint8 * __pyx_v_dst,int __pyx_v_h,int __pyx_v_span,int __pyx_v_srcpitch,int __pyx_v_dstpitch)1658 static void __pyx_f_11pygame_sdl2_7surface_move_pixels(Uint8 *__pyx_v_src, Uint8 *__pyx_v_dst, int __pyx_v_h, int __pyx_v_span, int __pyx_v_srcpitch, int __pyx_v_dstpitch) {
1659 int __pyx_t_1;
1660
1661 /* "pygame_sdl2/surface.pyx":38
1662 *
1663 * cdef void move_pixels(Uint8 *src, Uint8 *dst, int h, int span, int srcpitch, int dstpitch) nogil:
1664 * if src < dst: # <<<<<<<<<<<<<<
1665 * src += (h - 1) * srcpitch;
1666 * dst += (h - 1) * dstpitch;
1667 */
1668 __pyx_t_1 = ((__pyx_v_src < __pyx_v_dst) != 0);
1669 if (__pyx_t_1) {
1670
1671 /* "pygame_sdl2/surface.pyx":39
1672 * cdef void move_pixels(Uint8 *src, Uint8 *dst, int h, int span, int srcpitch, int dstpitch) nogil:
1673 * if src < dst:
1674 * src += (h - 1) * srcpitch; # <<<<<<<<<<<<<<
1675 * dst += (h - 1) * dstpitch;
1676 * srcpitch = -srcpitch;
1677 */
1678 __pyx_v_src = (__pyx_v_src + ((__pyx_v_h - 1) * __pyx_v_srcpitch));
1679
1680 /* "pygame_sdl2/surface.pyx":40
1681 * if src < dst:
1682 * src += (h - 1) * srcpitch;
1683 * dst += (h - 1) * dstpitch; # <<<<<<<<<<<<<<
1684 * srcpitch = -srcpitch;
1685 * dstpitch = -dstpitch;
1686 */
1687 __pyx_v_dst = (__pyx_v_dst + ((__pyx_v_h - 1) * __pyx_v_dstpitch));
1688
1689 /* "pygame_sdl2/surface.pyx":41
1690 * src += (h - 1) * srcpitch;
1691 * dst += (h - 1) * dstpitch;
1692 * srcpitch = -srcpitch; # <<<<<<<<<<<<<<
1693 * dstpitch = -dstpitch;
1694 *
1695 */
1696 __pyx_v_srcpitch = (-__pyx_v_srcpitch);
1697
1698 /* "pygame_sdl2/surface.pyx":42
1699 * dst += (h - 1) * dstpitch;
1700 * srcpitch = -srcpitch;
1701 * dstpitch = -dstpitch; # <<<<<<<<<<<<<<
1702 *
1703 * while h:
1704 */
1705 __pyx_v_dstpitch = (-__pyx_v_dstpitch);
1706
1707 /* "pygame_sdl2/surface.pyx":38
1708 *
1709 * cdef void move_pixels(Uint8 *src, Uint8 *dst, int h, int span, int srcpitch, int dstpitch) nogil:
1710 * if src < dst: # <<<<<<<<<<<<<<
1711 * src += (h - 1) * srcpitch;
1712 * dst += (h - 1) * dstpitch;
1713 */
1714 }
1715
1716 /* "pygame_sdl2/surface.pyx":44
1717 * dstpitch = -dstpitch;
1718 *
1719 * while h: # <<<<<<<<<<<<<<
1720 * h -= 1
1721 * memmove(dst, src, span);
1722 */
1723 while (1) {
1724 __pyx_t_1 = (__pyx_v_h != 0);
1725 if (!__pyx_t_1) break;
1726
1727 /* "pygame_sdl2/surface.pyx":45
1728 *
1729 * while h:
1730 * h -= 1 # <<<<<<<<<<<<<<
1731 * memmove(dst, src, span);
1732 * src += srcpitch;
1733 */
1734 __pyx_v_h = (__pyx_v_h - 1);
1735
1736 /* "pygame_sdl2/surface.pyx":46
1737 * while h:
1738 * h -= 1
1739 * memmove(dst, src, span); # <<<<<<<<<<<<<<
1740 * src += srcpitch;
1741 * dst += dstpitch;
1742 */
1743 (void)(memmove(__pyx_v_dst, __pyx_v_src, __pyx_v_span));
1744
1745 /* "pygame_sdl2/surface.pyx":47
1746 * h -= 1
1747 * memmove(dst, src, span);
1748 * src += srcpitch; # <<<<<<<<<<<<<<
1749 * dst += dstpitch;
1750 *
1751 */
1752 __pyx_v_src = (__pyx_v_src + __pyx_v_srcpitch);
1753
1754 /* "pygame_sdl2/surface.pyx":48
1755 * memmove(dst, src, span);
1756 * src += srcpitch;
1757 * dst += dstpitch; # <<<<<<<<<<<<<<
1758 *
1759 * # The total size of all allocated surfaces
1760 */
1761 __pyx_v_dst = (__pyx_v_dst + __pyx_v_dstpitch);
1762 }
1763
1764 /* "pygame_sdl2/surface.pyx":37
1765 * SDL_Surface * dst, SDL_Rect * dstrect, int the_args);
1766 *
1767 * cdef void move_pixels(Uint8 *src, Uint8 *dst, int h, int span, int srcpitch, int dstpitch) nogil: # <<<<<<<<<<<<<<
1768 * if src < dst:
1769 * src += (h - 1) * srcpitch;
1770 */
1771
1772 /* function exit code */
1773 }
1774
1775 /* "pygame_sdl2/surface.pyx":55
1776 * cdef class Surface:
1777 *
1778 * def __cinit__(self): # <<<<<<<<<<<<<<
1779 * self.surface = NULL
1780 * self.owns_surface = False
1781 */
1782
1783 /* Python wrapper */
1784 static int __pyx_pw_11pygame_sdl2_7surface_7Surface_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_1__cinit__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1785 static int __pyx_pw_11pygame_sdl2_7surface_7Surface_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1786 int __pyx_r;
1787 __Pyx_RefNannyDeclarations
1788 __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
1789 if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
1790 __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
1791 if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
1792 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface___cinit__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
1793
1794 /* function exit code */
1795 __Pyx_RefNannyFinishContext();
1796 return __pyx_r;
1797 }
1798
__pyx_pf_11pygame_sdl2_7surface_7Surface___cinit__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)1799 static int __pyx_pf_11pygame_sdl2_7surface_7Surface___cinit__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
1800 int __pyx_r;
1801 __Pyx_RefNannyDeclarations
1802 __Pyx_RefNannySetupContext("__cinit__", 0);
1803
1804 /* "pygame_sdl2/surface.pyx":56
1805 *
1806 * def __cinit__(self):
1807 * self.surface = NULL # <<<<<<<<<<<<<<
1808 * self.owns_surface = False
1809 * self.window_surface = False
1810 */
1811 __pyx_v_self->surface = NULL;
1812
1813 /* "pygame_sdl2/surface.pyx":57
1814 * def __cinit__(self):
1815 * self.surface = NULL
1816 * self.owns_surface = False # <<<<<<<<<<<<<<
1817 * self.window_surface = False
1818 * self.has_alpha = False
1819 */
1820 __pyx_v_self->owns_surface = 0;
1821
1822 /* "pygame_sdl2/surface.pyx":58
1823 * self.surface = NULL
1824 * self.owns_surface = False
1825 * self.window_surface = False # <<<<<<<<<<<<<<
1826 * self.has_alpha = False
1827 *
1828 */
1829 __pyx_v_self->window_surface = 0;
1830
1831 /* "pygame_sdl2/surface.pyx":59
1832 * self.owns_surface = False
1833 * self.window_surface = False
1834 * self.has_alpha = False # <<<<<<<<<<<<<<
1835 *
1836 * def __dealloc__(self):
1837 */
1838 __pyx_v_self->has_alpha = 0;
1839
1840 /* "pygame_sdl2/surface.pyx":55
1841 * cdef class Surface:
1842 *
1843 * def __cinit__(self): # <<<<<<<<<<<<<<
1844 * self.surface = NULL
1845 * self.owns_surface = False
1846 */
1847
1848 /* function exit code */
1849 __pyx_r = 0;
1850 __Pyx_RefNannyFinishContext();
1851 return __pyx_r;
1852 }
1853
1854 /* "pygame_sdl2/surface.pyx":61
1855 * self.has_alpha = False
1856 *
1857 * def __dealloc__(self): # <<<<<<<<<<<<<<
1858 * global total_size
1859 *
1860 */
1861
1862 /* Python wrapper */
1863 static void __pyx_pw_11pygame_sdl2_7surface_7Surface_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_3__dealloc__(PyObject * __pyx_v_self)1864 static void __pyx_pw_11pygame_sdl2_7surface_7Surface_3__dealloc__(PyObject *__pyx_v_self) {
1865 __Pyx_RefNannyDeclarations
1866 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1867 __pyx_pf_11pygame_sdl2_7surface_7Surface_2__dealloc__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
1868
1869 /* function exit code */
1870 __Pyx_RefNannyFinishContext();
1871 }
1872
__pyx_pf_11pygame_sdl2_7surface_7Surface_2__dealloc__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)1873 static void __pyx_pf_11pygame_sdl2_7surface_7Surface_2__dealloc__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
1874 __Pyx_RefNannyDeclarations
1875 int __pyx_t_1;
1876 int __pyx_t_2;
1877 PyObject *__pyx_t_3 = NULL;
1878 PyObject *__pyx_t_4 = NULL;
1879 PyObject *__pyx_t_5 = NULL;
1880 int __pyx_lineno = 0;
1881 const char *__pyx_filename = NULL;
1882 int __pyx_clineno = 0;
1883 __Pyx_RefNannySetupContext("__dealloc__", 0);
1884
1885 /* "pygame_sdl2/surface.pyx":64
1886 * global total_size
1887 *
1888 * if self.surface and self.owns_surface: # <<<<<<<<<<<<<<
1889 * if total_size:
1890 * total_size -= self.surface.pitch * self.surface.h
1891 */
1892 __pyx_t_2 = (__pyx_v_self->surface != 0);
1893 if (__pyx_t_2) {
1894 } else {
1895 __pyx_t_1 = __pyx_t_2;
1896 goto __pyx_L4_bool_binop_done;
1897 }
1898 __pyx_t_2 = (__pyx_v_self->owns_surface != 0);
1899 __pyx_t_1 = __pyx_t_2;
1900 __pyx_L4_bool_binop_done:;
1901 if (__pyx_t_1) {
1902
1903 /* "pygame_sdl2/surface.pyx":65
1904 *
1905 * if self.surface and self.owns_surface:
1906 * if total_size: # <<<<<<<<<<<<<<
1907 * total_size -= self.surface.pitch * self.surface.h
1908 *
1909 */
1910 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_total_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
1911 __Pyx_GOTREF(__pyx_t_3);
1912 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 65, __pyx_L1_error)
1913 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1914 if (__pyx_t_1) {
1915
1916 /* "pygame_sdl2/surface.pyx":66
1917 * if self.surface and self.owns_surface:
1918 * if total_size:
1919 * total_size -= self.surface.pitch * self.surface.h # <<<<<<<<<<<<<<
1920 *
1921 * SDL_FreeSurface(self.surface)
1922 */
1923 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_total_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
1924 __Pyx_GOTREF(__pyx_t_3);
1925 __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_self->surface->pitch * __pyx_v_self->surface->h)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
1926 __Pyx_GOTREF(__pyx_t_4);
1927 __pyx_t_5 = PyNumber_InPlaceSubtract(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
1928 __Pyx_GOTREF(__pyx_t_5);
1929 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1930 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1931 if (PyDict_SetItem(__pyx_d, __pyx_n_s_total_size, __pyx_t_5) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
1932 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1933
1934 /* "pygame_sdl2/surface.pyx":65
1935 *
1936 * if self.surface and self.owns_surface:
1937 * if total_size: # <<<<<<<<<<<<<<
1938 * total_size -= self.surface.pitch * self.surface.h
1939 *
1940 */
1941 }
1942
1943 /* "pygame_sdl2/surface.pyx":68
1944 * total_size -= self.surface.pitch * self.surface.h
1945 *
1946 * SDL_FreeSurface(self.surface) # <<<<<<<<<<<<<<
1947 * return
1948 * elif self.window_surface:
1949 */
1950 SDL_FreeSurface(__pyx_v_self->surface);
1951
1952 /* "pygame_sdl2/surface.pyx":69
1953 *
1954 * SDL_FreeSurface(self.surface)
1955 * return # <<<<<<<<<<<<<<
1956 * elif self.window_surface:
1957 * return
1958 */
1959 goto __pyx_L0;
1960
1961 /* "pygame_sdl2/surface.pyx":64
1962 * global total_size
1963 *
1964 * if self.surface and self.owns_surface: # <<<<<<<<<<<<<<
1965 * if total_size:
1966 * total_size -= self.surface.pitch * self.surface.h
1967 */
1968 }
1969
1970 /* "pygame_sdl2/surface.pyx":70
1971 * SDL_FreeSurface(self.surface)
1972 * return
1973 * elif self.window_surface: # <<<<<<<<<<<<<<
1974 * return
1975 * elif self.parent:
1976 */
1977 __pyx_t_1 = (__pyx_v_self->window_surface != 0);
1978 if (__pyx_t_1) {
1979
1980 /* "pygame_sdl2/surface.pyx":71
1981 * return
1982 * elif self.window_surface:
1983 * return # <<<<<<<<<<<<<<
1984 * elif self.parent:
1985 * SDL_FreeSurface(self.surface)
1986 */
1987 goto __pyx_L0;
1988
1989 /* "pygame_sdl2/surface.pyx":70
1990 * SDL_FreeSurface(self.surface)
1991 * return
1992 * elif self.window_surface: # <<<<<<<<<<<<<<
1993 * return
1994 * elif self.parent:
1995 */
1996 }
1997
1998 /* "pygame_sdl2/surface.pyx":72
1999 * elif self.window_surface:
2000 * return
2001 * elif self.parent: # <<<<<<<<<<<<<<
2002 * SDL_FreeSurface(self.surface)
2003 * return
2004 */
2005 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
2006 if (__pyx_t_1) {
2007
2008 /* "pygame_sdl2/surface.pyx":73
2009 * return
2010 * elif self.parent:
2011 * SDL_FreeSurface(self.surface) # <<<<<<<<<<<<<<
2012 * return
2013 *
2014 */
2015 SDL_FreeSurface(__pyx_v_self->surface);
2016
2017 /* "pygame_sdl2/surface.pyx":74
2018 * elif self.parent:
2019 * SDL_FreeSurface(self.surface)
2020 * return # <<<<<<<<<<<<<<
2021 *
2022 * warnings.warn("Memory leak via Surface in pygame_sdl2.")
2023 */
2024 goto __pyx_L0;
2025
2026 /* "pygame_sdl2/surface.pyx":72
2027 * elif self.window_surface:
2028 * return
2029 * elif self.parent: # <<<<<<<<<<<<<<
2030 * SDL_FreeSurface(self.surface)
2031 * return
2032 */
2033 }
2034
2035 /* "pygame_sdl2/surface.pyx":76
2036 * return
2037 *
2038 * warnings.warn("Memory leak via Surface in pygame_sdl2.") # <<<<<<<<<<<<<<
2039 *
2040 * def __sizeof__(self):
2041 */
2042 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L1_error)
2043 __Pyx_GOTREF(__pyx_t_4);
2044 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
2045 __Pyx_GOTREF(__pyx_t_3);
2046 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2047 __pyx_t_4 = NULL;
2048 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2049 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2050 if (likely(__pyx_t_4)) {
2051 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2052 __Pyx_INCREF(__pyx_t_4);
2053 __Pyx_INCREF(function);
2054 __Pyx_DECREF_SET(__pyx_t_3, function);
2055 }
2056 }
2057 __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_s_Memory_leak_via_Surface_in_pygam) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Memory_leak_via_Surface_in_pygam);
2058 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2059 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 76, __pyx_L1_error)
2060 __Pyx_GOTREF(__pyx_t_5);
2061 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2062 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2063
2064 /* "pygame_sdl2/surface.pyx":61
2065 * self.has_alpha = False
2066 *
2067 * def __dealloc__(self): # <<<<<<<<<<<<<<
2068 * global total_size
2069 *
2070 */
2071
2072 /* function exit code */
2073 goto __pyx_L0;
2074 __pyx_L1_error:;
2075 __Pyx_XDECREF(__pyx_t_3);
2076 __Pyx_XDECREF(__pyx_t_4);
2077 __Pyx_XDECREF(__pyx_t_5);
2078 __Pyx_WriteUnraisable("pygame_sdl2.surface.Surface.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
2079 __pyx_L0:;
2080 __Pyx_RefNannyFinishContext();
2081 }
2082
2083 /* "pygame_sdl2/surface.pyx":78
2084 * warnings.warn("Memory leak via Surface in pygame_sdl2.")
2085 *
2086 * def __sizeof__(self): # <<<<<<<<<<<<<<
2087 * if self.surface and self.owns_surface:
2088 * return self.surface.pitch * self.surface.h
2089 */
2090
2091 /* Python wrapper */
2092 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_5__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_5__sizeof__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)2093 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_5__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2094 PyObject *__pyx_r = 0;
2095 __Pyx_RefNannyDeclarations
2096 __Pyx_RefNannySetupContext("__sizeof__ (wrapper)", 0);
2097 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_4__sizeof__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
2098
2099 /* function exit code */
2100 __Pyx_RefNannyFinishContext();
2101 return __pyx_r;
2102 }
2103
__pyx_pf_11pygame_sdl2_7surface_7Surface_4__sizeof__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)2104 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_4__sizeof__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
2105 PyObject *__pyx_r = NULL;
2106 __Pyx_RefNannyDeclarations
2107 int __pyx_t_1;
2108 int __pyx_t_2;
2109 PyObject *__pyx_t_3 = NULL;
2110 int __pyx_lineno = 0;
2111 const char *__pyx_filename = NULL;
2112 int __pyx_clineno = 0;
2113 __Pyx_RefNannySetupContext("__sizeof__", 0);
2114
2115 /* "pygame_sdl2/surface.pyx":79
2116 *
2117 * def __sizeof__(self):
2118 * if self.surface and self.owns_surface: # <<<<<<<<<<<<<<
2119 * return self.surface.pitch * self.surface.h
2120 * else:
2121 */
2122 __pyx_t_2 = (__pyx_v_self->surface != 0);
2123 if (__pyx_t_2) {
2124 } else {
2125 __pyx_t_1 = __pyx_t_2;
2126 goto __pyx_L4_bool_binop_done;
2127 }
2128 __pyx_t_2 = (__pyx_v_self->owns_surface != 0);
2129 __pyx_t_1 = __pyx_t_2;
2130 __pyx_L4_bool_binop_done:;
2131 if (__pyx_t_1) {
2132
2133 /* "pygame_sdl2/surface.pyx":80
2134 * def __sizeof__(self):
2135 * if self.surface and self.owns_surface:
2136 * return self.surface.pitch * self.surface.h # <<<<<<<<<<<<<<
2137 * else:
2138 * return 0
2139 */
2140 __Pyx_XDECREF(__pyx_r);
2141 __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->surface->pitch * __pyx_v_self->surface->h)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
2142 __Pyx_GOTREF(__pyx_t_3);
2143 __pyx_r = __pyx_t_3;
2144 __pyx_t_3 = 0;
2145 goto __pyx_L0;
2146
2147 /* "pygame_sdl2/surface.pyx":79
2148 *
2149 * def __sizeof__(self):
2150 * if self.surface and self.owns_surface: # <<<<<<<<<<<<<<
2151 * return self.surface.pitch * self.surface.h
2152 * else:
2153 */
2154 }
2155
2156 /* "pygame_sdl2/surface.pyx":82
2157 * return self.surface.pitch * self.surface.h
2158 * else:
2159 * return 0 # <<<<<<<<<<<<<<
2160 *
2161 * def __init__(self, size, flags=0, depth=32, masks=None):
2162 */
2163 /*else*/ {
2164 __Pyx_XDECREF(__pyx_r);
2165 __Pyx_INCREF(__pyx_int_0);
2166 __pyx_r = __pyx_int_0;
2167 goto __pyx_L0;
2168 }
2169
2170 /* "pygame_sdl2/surface.pyx":78
2171 * warnings.warn("Memory leak via Surface in pygame_sdl2.")
2172 *
2173 * def __sizeof__(self): # <<<<<<<<<<<<<<
2174 * if self.surface and self.owns_surface:
2175 * return self.surface.pitch * self.surface.h
2176 */
2177
2178 /* function exit code */
2179 __pyx_L1_error:;
2180 __Pyx_XDECREF(__pyx_t_3);
2181 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__sizeof__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2182 __pyx_r = NULL;
2183 __pyx_L0:;
2184 __Pyx_XGIVEREF(__pyx_r);
2185 __Pyx_RefNannyFinishContext();
2186 return __pyx_r;
2187 }
2188
2189 /* "pygame_sdl2/surface.pyx":84
2190 * return 0
2191 *
2192 * def __init__(self, size, flags=0, depth=32, masks=None): # <<<<<<<<<<<<<<
2193 *
2194 * self.locklist = None
2195 */
2196
2197 /* Python wrapper */
2198 static int __pyx_pw_11pygame_sdl2_7surface_7Surface_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_7__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2199 static int __pyx_pw_11pygame_sdl2_7surface_7Surface_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2200 PyObject *__pyx_v_size = 0;
2201 PyObject *__pyx_v_flags = 0;
2202 PyObject *__pyx_v_depth = 0;
2203 PyObject *__pyx_v_masks = 0;
2204 int __pyx_lineno = 0;
2205 const char *__pyx_filename = NULL;
2206 int __pyx_clineno = 0;
2207 int __pyx_r;
2208 __Pyx_RefNannyDeclarations
2209 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
2210 {
2211 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_size,&__pyx_n_s_flags,&__pyx_n_s_depth,&__pyx_n_s_masks,0};
2212 PyObject* values[4] = {0,0,0,0};
2213 values[1] = ((PyObject *)__pyx_int_0);
2214 values[2] = ((PyObject *)__pyx_int_32);
2215 values[3] = ((PyObject *)Py_None);
2216 if (unlikely(__pyx_kwds)) {
2217 Py_ssize_t kw_args;
2218 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2219 switch (pos_args) {
2220 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2221 CYTHON_FALLTHROUGH;
2222 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2223 CYTHON_FALLTHROUGH;
2224 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2225 CYTHON_FALLTHROUGH;
2226 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2227 CYTHON_FALLTHROUGH;
2228 case 0: break;
2229 default: goto __pyx_L5_argtuple_error;
2230 }
2231 kw_args = PyDict_Size(__pyx_kwds);
2232 switch (pos_args) {
2233 case 0:
2234 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--;
2235 else goto __pyx_L5_argtuple_error;
2236 CYTHON_FALLTHROUGH;
2237 case 1:
2238 if (kw_args > 0) {
2239 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
2240 if (value) { values[1] = value; kw_args--; }
2241 }
2242 CYTHON_FALLTHROUGH;
2243 case 2:
2244 if (kw_args > 0) {
2245 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_depth);
2246 if (value) { values[2] = value; kw_args--; }
2247 }
2248 CYTHON_FALLTHROUGH;
2249 case 3:
2250 if (kw_args > 0) {
2251 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_masks);
2252 if (value) { values[3] = value; kw_args--; }
2253 }
2254 }
2255 if (unlikely(kw_args > 0)) {
2256 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 84, __pyx_L3_error)
2257 }
2258 } else {
2259 switch (PyTuple_GET_SIZE(__pyx_args)) {
2260 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2261 CYTHON_FALLTHROUGH;
2262 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2263 CYTHON_FALLTHROUGH;
2264 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2265 CYTHON_FALLTHROUGH;
2266 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2267 break;
2268 default: goto __pyx_L5_argtuple_error;
2269 }
2270 }
2271 __pyx_v_size = values[0];
2272 __pyx_v_flags = values[1];
2273 __pyx_v_depth = values[2];
2274 __pyx_v_masks = values[3];
2275 }
2276 goto __pyx_L4_argument_unpacking_done;
2277 __pyx_L5_argtuple_error:;
2278 __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 84, __pyx_L3_error)
2279 __pyx_L3_error:;
2280 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2281 __Pyx_RefNannyFinishContext();
2282 return -1;
2283 __pyx_L4_argument_unpacking_done:;
2284 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_6__init__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_size, __pyx_v_flags, __pyx_v_depth, __pyx_v_masks);
2285
2286 /* function exit code */
2287 __Pyx_RefNannyFinishContext();
2288 return __pyx_r;
2289 }
2290
__pyx_pf_11pygame_sdl2_7surface_7Surface_6__init__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_size,PyObject * __pyx_v_flags,PyObject * __pyx_v_depth,PyObject * __pyx_v_masks)2291 static int __pyx_pf_11pygame_sdl2_7surface_7Surface_6__init__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_size, PyObject *__pyx_v_flags, PyObject *__pyx_v_depth, PyObject *__pyx_v_masks) {
2292 int __pyx_v_w;
2293 int __pyx_v_h;
2294 Uint32 __pyx_v_Rmask;
2295 Uint32 __pyx_v_Gmask;
2296 Uint32 __pyx_v_Bmask;
2297 Uint32 __pyx_v_Amask;
2298 SDL_Surface *__pyx_v_sample;
2299 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_pysample = 0;
2300 int __pyx_v_depth_int;
2301 SDL_Surface *__pyx_v_surface;
2302 int __pyx_r;
2303 __Pyx_RefNannyDeclarations
2304 PyObject *__pyx_t_1 = NULL;
2305 int __pyx_t_2;
2306 PyObject *__pyx_t_3 = NULL;
2307 PyObject *__pyx_t_4 = NULL;
2308 PyObject *(*__pyx_t_5)(PyObject *);
2309 int __pyx_t_6;
2310 int __pyx_t_7;
2311 int __pyx_t_8;
2312 PyObject *__pyx_t_9 = NULL;
2313 PyObject *__pyx_t_10 = NULL;
2314 Uint32 __pyx_t_11;
2315 Uint32 __pyx_t_12;
2316 Uint32 __pyx_t_13;
2317 Uint32 __pyx_t_14;
2318 SDL_Surface *__pyx_t_15;
2319 Uint8 __pyx_t_16;
2320 int __pyx_lineno = 0;
2321 const char *__pyx_filename = NULL;
2322 int __pyx_clineno = 0;
2323 __Pyx_RefNannySetupContext("__init__", 0);
2324
2325 /* "pygame_sdl2/surface.pyx":86
2326 * def __init__(self, size, flags=0, depth=32, masks=None):
2327 *
2328 * self.locklist = None # <<<<<<<<<<<<<<
2329 * self.parent = None
2330 *
2331 */
2332 __Pyx_INCREF(Py_None);
2333 __Pyx_GIVEREF(Py_None);
2334 __Pyx_GOTREF(__pyx_v_self->locklist);
2335 __Pyx_DECREF(__pyx_v_self->locklist);
2336 __pyx_v_self->locklist = Py_None;
2337
2338 /* "pygame_sdl2/surface.pyx":87
2339 *
2340 * self.locklist = None
2341 * self.parent = None # <<<<<<<<<<<<<<
2342 *
2343 * self.offset_x = 0
2344 */
2345 __Pyx_INCREF(Py_None);
2346 __Pyx_GIVEREF(Py_None);
2347 __Pyx_GOTREF(__pyx_v_self->parent);
2348 __Pyx_DECREF(((PyObject *)__pyx_v_self->parent));
2349 __pyx_v_self->parent = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None);
2350
2351 /* "pygame_sdl2/surface.pyx":89
2352 * self.parent = None
2353 *
2354 * self.offset_x = 0 # <<<<<<<<<<<<<<
2355 * self.offset_y = 0
2356 *
2357 */
2358 __pyx_v_self->offset_x = 0;
2359
2360 /* "pygame_sdl2/surface.pyx":90
2361 *
2362 * self.offset_x = 0
2363 * self.offset_y = 0 # <<<<<<<<<<<<<<
2364 *
2365 * self.get_window_flags = None
2366 */
2367 __pyx_v_self->offset_y = 0;
2368
2369 /* "pygame_sdl2/surface.pyx":92
2370 * self.offset_y = 0
2371 *
2372 * self.get_window_flags = None # <<<<<<<<<<<<<<
2373 *
2374 * # When size is an empty tuple, we do not create a surface, and
2375 */
2376 __Pyx_INCREF(Py_None);
2377 __Pyx_GIVEREF(Py_None);
2378 __Pyx_GOTREF(__pyx_v_self->get_window_flags);
2379 __Pyx_DECREF(__pyx_v_self->get_window_flags);
2380 __pyx_v_self->get_window_flags = Py_None;
2381
2382 /* "pygame_sdl2/surface.pyx":96
2383 * # When size is an empty tuple, we do not create a surface, and
2384 * # expect our caller to set this object up.
2385 * if size == (): # <<<<<<<<<<<<<<
2386 * return
2387 *
2388 */
2389 __pyx_t_1 = PyObject_RichCompare(__pyx_v_size, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2390 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 96, __pyx_L1_error)
2391 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2392 if (__pyx_t_2) {
2393
2394 /* "pygame_sdl2/surface.pyx":97
2395 * # expect our caller to set this object up.
2396 * if size == ():
2397 * return # <<<<<<<<<<<<<<
2398 *
2399 * cdef int w
2400 */
2401 __pyx_r = 0;
2402 goto __pyx_L0;
2403
2404 /* "pygame_sdl2/surface.pyx":96
2405 * # When size is an empty tuple, we do not create a surface, and
2406 * # expect our caller to set this object up.
2407 * if size == (): # <<<<<<<<<<<<<<
2408 * return
2409 *
2410 */
2411 }
2412
2413 /* "pygame_sdl2/surface.pyx":102
2414 * cdef int h
2415 *
2416 * w, h = size # <<<<<<<<<<<<<<
2417 * assert w >= 0
2418 * assert h >= 0
2419 */
2420 if ((likely(PyTuple_CheckExact(__pyx_v_size))) || (PyList_CheckExact(__pyx_v_size))) {
2421 PyObject* sequence = __pyx_v_size;
2422 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
2423 if (unlikely(size != 2)) {
2424 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
2425 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
2426 __PYX_ERR(0, 102, __pyx_L1_error)
2427 }
2428 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2429 if (likely(PyTuple_CheckExact(sequence))) {
2430 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
2431 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
2432 } else {
2433 __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
2434 __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
2435 }
2436 __Pyx_INCREF(__pyx_t_1);
2437 __Pyx_INCREF(__pyx_t_3);
2438 #else
2439 __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
2440 __Pyx_GOTREF(__pyx_t_1);
2441 __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error)
2442 __Pyx_GOTREF(__pyx_t_3);
2443 #endif
2444 } else {
2445 Py_ssize_t index = -1;
2446 __pyx_t_4 = PyObject_GetIter(__pyx_v_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error)
2447 __Pyx_GOTREF(__pyx_t_4);
2448 __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
2449 index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
2450 __Pyx_GOTREF(__pyx_t_1);
2451 index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
2452 __Pyx_GOTREF(__pyx_t_3);
2453 if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
2454 __pyx_t_5 = NULL;
2455 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2456 goto __pyx_L5_unpacking_done;
2457 __pyx_L4_unpacking_failed:;
2458 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2459 __pyx_t_5 = NULL;
2460 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
2461 __PYX_ERR(0, 102, __pyx_L1_error)
2462 __pyx_L5_unpacking_done:;
2463 }
2464 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error)
2465 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2466 __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error)
2467 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2468 __pyx_v_w = __pyx_t_6;
2469 __pyx_v_h = __pyx_t_7;
2470
2471 /* "pygame_sdl2/surface.pyx":103
2472 *
2473 * w, h = size
2474 * assert w >= 0 # <<<<<<<<<<<<<<
2475 * assert h >= 0
2476 *
2477 */
2478 #ifndef CYTHON_WITHOUT_ASSERTIONS
2479 if (unlikely(!Py_OptimizeFlag)) {
2480 if (unlikely(!((__pyx_v_w >= 0) != 0))) {
2481 PyErr_SetNone(PyExc_AssertionError);
2482 __PYX_ERR(0, 103, __pyx_L1_error)
2483 }
2484 }
2485 #endif
2486
2487 /* "pygame_sdl2/surface.pyx":104
2488 * w, h = size
2489 * assert w >= 0
2490 * assert h >= 0 # <<<<<<<<<<<<<<
2491 *
2492 * cdef Uint32 Rmask, Gmask, Bmask, Amask
2493 */
2494 #ifndef CYTHON_WITHOUT_ASSERTIONS
2495 if (unlikely(!Py_OptimizeFlag)) {
2496 if (unlikely(!((__pyx_v_h >= 0) != 0))) {
2497 PyErr_SetNone(PyExc_AssertionError);
2498 __PYX_ERR(0, 104, __pyx_L1_error)
2499 }
2500 }
2501 #endif
2502
2503 /* "pygame_sdl2/surface.pyx":111
2504 * cdef int depth_int
2505 *
2506 * if masks is not None: # <<<<<<<<<<<<<<
2507 * Rmask, Gmask, Bmask, Amask = masks
2508 * depth_int = depth
2509 */
2510 __pyx_t_2 = (__pyx_v_masks != Py_None);
2511 __pyx_t_8 = (__pyx_t_2 != 0);
2512 if (__pyx_t_8) {
2513
2514 /* "pygame_sdl2/surface.pyx":112
2515 *
2516 * if masks is not None:
2517 * Rmask, Gmask, Bmask, Amask = masks # <<<<<<<<<<<<<<
2518 * depth_int = depth
2519 *
2520 */
2521 if ((likely(PyTuple_CheckExact(__pyx_v_masks))) || (PyList_CheckExact(__pyx_v_masks))) {
2522 PyObject* sequence = __pyx_v_masks;
2523 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
2524 if (unlikely(size != 4)) {
2525 if (size > 4) __Pyx_RaiseTooManyValuesError(4);
2526 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
2527 __PYX_ERR(0, 112, __pyx_L1_error)
2528 }
2529 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2530 if (likely(PyTuple_CheckExact(sequence))) {
2531 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
2532 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
2533 __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2);
2534 __pyx_t_9 = PyTuple_GET_ITEM(sequence, 3);
2535 } else {
2536 __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
2537 __pyx_t_1 = PyList_GET_ITEM(sequence, 1);
2538 __pyx_t_4 = PyList_GET_ITEM(sequence, 2);
2539 __pyx_t_9 = PyList_GET_ITEM(sequence, 3);
2540 }
2541 __Pyx_INCREF(__pyx_t_3);
2542 __Pyx_INCREF(__pyx_t_1);
2543 __Pyx_INCREF(__pyx_t_4);
2544 __Pyx_INCREF(__pyx_t_9);
2545 #else
2546 {
2547 Py_ssize_t i;
2548 PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_1,&__pyx_t_4,&__pyx_t_9};
2549 for (i=0; i < 4; i++) {
2550 PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 112, __pyx_L1_error)
2551 __Pyx_GOTREF(item);
2552 *(temps[i]) = item;
2553 }
2554 }
2555 #endif
2556 } else {
2557 Py_ssize_t index = -1;
2558 PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_1,&__pyx_t_4,&__pyx_t_9};
2559 __pyx_t_10 = PyObject_GetIter(__pyx_v_masks); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error)
2560 __Pyx_GOTREF(__pyx_t_10);
2561 __pyx_t_5 = Py_TYPE(__pyx_t_10)->tp_iternext;
2562 for (index=0; index < 4; index++) {
2563 PyObject* item = __pyx_t_5(__pyx_t_10); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
2564 __Pyx_GOTREF(item);
2565 *(temps[index]) = item;
2566 }
2567 if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_10), 4) < 0) __PYX_ERR(0, 112, __pyx_L1_error)
2568 __pyx_t_5 = NULL;
2569 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2570 goto __pyx_L8_unpacking_done;
2571 __pyx_L7_unpacking_failed:;
2572 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2573 __pyx_t_5 = NULL;
2574 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
2575 __PYX_ERR(0, 112, __pyx_L1_error)
2576 __pyx_L8_unpacking_done:;
2577 }
2578 __pyx_t_11 = __Pyx_PyInt_As_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_11 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
2579 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2580 __pyx_t_12 = __Pyx_PyInt_As_uint32_t(__pyx_t_1); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
2581 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2582 __pyx_t_13 = __Pyx_PyInt_As_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_13 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
2583 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2584 __pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_t_9); if (unlikely((__pyx_t_14 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
2585 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2586 __pyx_v_Rmask = __pyx_t_11;
2587 __pyx_v_Gmask = __pyx_t_12;
2588 __pyx_v_Bmask = __pyx_t_13;
2589 __pyx_v_Amask = __pyx_t_14;
2590
2591 /* "pygame_sdl2/surface.pyx":113
2592 * if masks is not None:
2593 * Rmask, Gmask, Bmask, Amask = masks
2594 * depth_int = depth # <<<<<<<<<<<<<<
2595 *
2596 * elif isinstance(depth, Surface):
2597 */
2598 __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_depth); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error)
2599 __pyx_v_depth_int = __pyx_t_7;
2600
2601 /* "pygame_sdl2/surface.pyx":111
2602 * cdef int depth_int
2603 *
2604 * if masks is not None: # <<<<<<<<<<<<<<
2605 * Rmask, Gmask, Bmask, Amask = masks
2606 * depth_int = depth
2607 */
2608 goto __pyx_L6;
2609 }
2610
2611 /* "pygame_sdl2/surface.pyx":115
2612 * depth_int = depth
2613 *
2614 * elif isinstance(depth, Surface): # <<<<<<<<<<<<<<
2615 *
2616 * pysample = depth
2617 */
2618 __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_depth, __pyx_ptype_11pygame_sdl2_7surface_Surface);
2619 __pyx_t_2 = (__pyx_t_8 != 0);
2620 if (__pyx_t_2) {
2621
2622 /* "pygame_sdl2/surface.pyx":117
2623 * elif isinstance(depth, Surface):
2624 *
2625 * pysample = depth # <<<<<<<<<<<<<<
2626 * sample = pysample.surface
2627 * Rmask = sample.format.Rmask
2628 */
2629 if (!(likely(((__pyx_v_depth) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_depth, __pyx_ptype_11pygame_sdl2_7surface_Surface))))) __PYX_ERR(0, 117, __pyx_L1_error)
2630 __pyx_t_9 = __pyx_v_depth;
2631 __Pyx_INCREF(__pyx_t_9);
2632 __pyx_v_pysample = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_9);
2633 __pyx_t_9 = 0;
2634
2635 /* "pygame_sdl2/surface.pyx":118
2636 *
2637 * pysample = depth
2638 * sample = pysample.surface # <<<<<<<<<<<<<<
2639 * Rmask = sample.format.Rmask
2640 * Gmask = sample.format.Gmask
2641 */
2642 __pyx_t_15 = __pyx_v_pysample->surface;
2643 __pyx_v_sample = __pyx_t_15;
2644
2645 /* "pygame_sdl2/surface.pyx":119
2646 * pysample = depth
2647 * sample = pysample.surface
2648 * Rmask = sample.format.Rmask # <<<<<<<<<<<<<<
2649 * Gmask = sample.format.Gmask
2650 * Bmask = sample.format.Bmask
2651 */
2652 __pyx_t_14 = __pyx_v_sample->format->Rmask;
2653 __pyx_v_Rmask = __pyx_t_14;
2654
2655 /* "pygame_sdl2/surface.pyx":120
2656 * sample = pysample.surface
2657 * Rmask = sample.format.Rmask
2658 * Gmask = sample.format.Gmask # <<<<<<<<<<<<<<
2659 * Bmask = sample.format.Bmask
2660 * Amask = sample.format.Amask
2661 */
2662 __pyx_t_14 = __pyx_v_sample->format->Gmask;
2663 __pyx_v_Gmask = __pyx_t_14;
2664
2665 /* "pygame_sdl2/surface.pyx":121
2666 * Rmask = sample.format.Rmask
2667 * Gmask = sample.format.Gmask
2668 * Bmask = sample.format.Bmask # <<<<<<<<<<<<<<
2669 * Amask = sample.format.Amask
2670 * depth_int = sample.format.BitsPerPixel
2671 */
2672 __pyx_t_14 = __pyx_v_sample->format->Bmask;
2673 __pyx_v_Bmask = __pyx_t_14;
2674
2675 /* "pygame_sdl2/surface.pyx":122
2676 * Gmask = sample.format.Gmask
2677 * Bmask = sample.format.Bmask
2678 * Amask = sample.format.Amask # <<<<<<<<<<<<<<
2679 * depth_int = sample.format.BitsPerPixel
2680 *
2681 */
2682 __pyx_t_14 = __pyx_v_sample->format->Amask;
2683 __pyx_v_Amask = __pyx_t_14;
2684
2685 /* "pygame_sdl2/surface.pyx":123
2686 * Bmask = sample.format.Bmask
2687 * Amask = sample.format.Amask
2688 * depth_int = sample.format.BitsPerPixel # <<<<<<<<<<<<<<
2689 *
2690 * else:
2691 */
2692 __pyx_t_16 = __pyx_v_sample->format->BitsPerPixel;
2693 __pyx_v_depth_int = __pyx_t_16;
2694
2695 /* "pygame_sdl2/surface.pyx":115
2696 * depth_int = depth
2697 *
2698 * elif isinstance(depth, Surface): # <<<<<<<<<<<<<<
2699 *
2700 * pysample = depth
2701 */
2702 goto __pyx_L6;
2703 }
2704
2705 /* "pygame_sdl2/surface.pyx":127
2706 * else:
2707 *
2708 * pysample = pygame_sdl2.display.get_surface() # <<<<<<<<<<<<<<
2709 *
2710 * if pysample and pysample.surface.format.BitsPerPixel == 32:
2711 */
2712 /*else*/ {
2713 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pygame_sdl2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
2714 __Pyx_GOTREF(__pyx_t_4);
2715 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_display); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
2716 __Pyx_GOTREF(__pyx_t_1);
2717 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2718 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get_surface); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
2719 __Pyx_GOTREF(__pyx_t_4);
2720 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2721 __pyx_t_1 = NULL;
2722 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
2723 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
2724 if (likely(__pyx_t_1)) {
2725 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2726 __Pyx_INCREF(__pyx_t_1);
2727 __Pyx_INCREF(function);
2728 __Pyx_DECREF_SET(__pyx_t_4, function);
2729 }
2730 }
2731 __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
2732 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2733 if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 127, __pyx_L1_error)
2734 __Pyx_GOTREF(__pyx_t_9);
2735 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2736 if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_11pygame_sdl2_7surface_Surface))))) __PYX_ERR(0, 127, __pyx_L1_error)
2737 __pyx_v_pysample = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_9);
2738 __pyx_t_9 = 0;
2739
2740 /* "pygame_sdl2/surface.pyx":129
2741 * pysample = pygame_sdl2.display.get_surface()
2742 *
2743 * if pysample and pysample.surface.format.BitsPerPixel == 32: # <<<<<<<<<<<<<<
2744 * sample = pysample.surface
2745 * Rmask = sample.format.Rmask
2746 */
2747 __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_pysample)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 129, __pyx_L1_error)
2748 if (__pyx_t_8) {
2749 } else {
2750 __pyx_t_2 = __pyx_t_8;
2751 goto __pyx_L10_bool_binop_done;
2752 }
2753 __pyx_t_8 = ((__pyx_v_pysample->surface->format->BitsPerPixel == 32) != 0);
2754 __pyx_t_2 = __pyx_t_8;
2755 __pyx_L10_bool_binop_done:;
2756 if (__pyx_t_2) {
2757
2758 /* "pygame_sdl2/surface.pyx":130
2759 *
2760 * if pysample and pysample.surface.format.BitsPerPixel == 32:
2761 * sample = pysample.surface # <<<<<<<<<<<<<<
2762 * Rmask = sample.format.Rmask
2763 * Gmask = sample.format.Gmask
2764 */
2765 __pyx_t_15 = __pyx_v_pysample->surface;
2766 __pyx_v_sample = __pyx_t_15;
2767
2768 /* "pygame_sdl2/surface.pyx":131
2769 * if pysample and pysample.surface.format.BitsPerPixel == 32:
2770 * sample = pysample.surface
2771 * Rmask = sample.format.Rmask # <<<<<<<<<<<<<<
2772 * Gmask = sample.format.Gmask
2773 * Bmask = sample.format.Bmask
2774 */
2775 __pyx_t_14 = __pyx_v_sample->format->Rmask;
2776 __pyx_v_Rmask = __pyx_t_14;
2777
2778 /* "pygame_sdl2/surface.pyx":132
2779 * sample = pysample.surface
2780 * Rmask = sample.format.Rmask
2781 * Gmask = sample.format.Gmask # <<<<<<<<<<<<<<
2782 * Bmask = sample.format.Bmask
2783 * Amask = sample.format.Amask
2784 */
2785 __pyx_t_14 = __pyx_v_sample->format->Gmask;
2786 __pyx_v_Gmask = __pyx_t_14;
2787
2788 /* "pygame_sdl2/surface.pyx":133
2789 * Rmask = sample.format.Rmask
2790 * Gmask = sample.format.Gmask
2791 * Bmask = sample.format.Bmask # <<<<<<<<<<<<<<
2792 * Amask = sample.format.Amask
2793 *
2794 */
2795 __pyx_t_14 = __pyx_v_sample->format->Bmask;
2796 __pyx_v_Bmask = __pyx_t_14;
2797
2798 /* "pygame_sdl2/surface.pyx":134
2799 * Gmask = sample.format.Gmask
2800 * Bmask = sample.format.Bmask
2801 * Amask = sample.format.Amask # <<<<<<<<<<<<<<
2802 *
2803 * else:
2804 */
2805 __pyx_t_14 = __pyx_v_sample->format->Amask;
2806 __pyx_v_Amask = __pyx_t_14;
2807
2808 /* "pygame_sdl2/surface.pyx":129
2809 * pysample = pygame_sdl2.display.get_surface()
2810 *
2811 * if pysample and pysample.surface.format.BitsPerPixel == 32: # <<<<<<<<<<<<<<
2812 * sample = pysample.surface
2813 * Rmask = sample.format.Rmask
2814 */
2815 goto __pyx_L9;
2816 }
2817
2818 /* "pygame_sdl2/surface.pyx":139
2819 *
2820 * # RGB(A)
2821 * if SDL_BYTEORDER == SDL_BIG_ENDIAN: # <<<<<<<<<<<<<<
2822 * Rmask = 0xff000000
2823 * Gmask = 0x00ff0000
2824 */
2825 /*else*/ {
2826 __pyx_t_2 = ((SDL_BYTEORDER == SDL_BIG_ENDIAN) != 0);
2827 if (__pyx_t_2) {
2828
2829 /* "pygame_sdl2/surface.pyx":140
2830 * # RGB(A)
2831 * if SDL_BYTEORDER == SDL_BIG_ENDIAN:
2832 * Rmask = 0xff000000 # <<<<<<<<<<<<<<
2833 * Gmask = 0x00ff0000
2834 * Bmask = 0x0000ff00
2835 */
2836 __pyx_v_Rmask = 0xff000000;
2837
2838 /* "pygame_sdl2/surface.pyx":141
2839 * if SDL_BYTEORDER == SDL_BIG_ENDIAN:
2840 * Rmask = 0xff000000
2841 * Gmask = 0x00ff0000 # <<<<<<<<<<<<<<
2842 * Bmask = 0x0000ff00
2843 * Amask = 0
2844 */
2845 __pyx_v_Gmask = 0x00ff0000;
2846
2847 /* "pygame_sdl2/surface.pyx":142
2848 * Rmask = 0xff000000
2849 * Gmask = 0x00ff0000
2850 * Bmask = 0x0000ff00 # <<<<<<<<<<<<<<
2851 * Amask = 0
2852 * else:
2853 */
2854 __pyx_v_Bmask = 0x0000ff00;
2855
2856 /* "pygame_sdl2/surface.pyx":143
2857 * Gmask = 0x00ff0000
2858 * Bmask = 0x0000ff00
2859 * Amask = 0 # <<<<<<<<<<<<<<
2860 * else:
2861 * Rmask = 0x000000ff
2862 */
2863 __pyx_v_Amask = 0;
2864
2865 /* "pygame_sdl2/surface.pyx":139
2866 *
2867 * # RGB(A)
2868 * if SDL_BYTEORDER == SDL_BIG_ENDIAN: # <<<<<<<<<<<<<<
2869 * Rmask = 0xff000000
2870 * Gmask = 0x00ff0000
2871 */
2872 goto __pyx_L12;
2873 }
2874
2875 /* "pygame_sdl2/surface.pyx":145
2876 * Amask = 0
2877 * else:
2878 * Rmask = 0x000000ff # <<<<<<<<<<<<<<
2879 * Gmask = 0x0000ff00
2880 * Bmask = 0x00ff0000
2881 */
2882 /*else*/ {
2883 __pyx_v_Rmask = 0x000000ff;
2884
2885 /* "pygame_sdl2/surface.pyx":146
2886 * else:
2887 * Rmask = 0x000000ff
2888 * Gmask = 0x0000ff00 # <<<<<<<<<<<<<<
2889 * Bmask = 0x00ff0000
2890 * Amask = 0
2891 */
2892 __pyx_v_Gmask = 0x0000ff00;
2893
2894 /* "pygame_sdl2/surface.pyx":147
2895 * Rmask = 0x000000ff
2896 * Gmask = 0x0000ff00
2897 * Bmask = 0x00ff0000 # <<<<<<<<<<<<<<
2898 * Amask = 0
2899 *
2900 */
2901 __pyx_v_Bmask = 0x00ff0000;
2902
2903 /* "pygame_sdl2/surface.pyx":148
2904 * Gmask = 0x0000ff00
2905 * Bmask = 0x00ff0000
2906 * Amask = 0 # <<<<<<<<<<<<<<
2907 *
2908 * if (flags & SRCALPHA):
2909 */
2910 __pyx_v_Amask = 0;
2911 }
2912 __pyx_L12:;
2913 }
2914 __pyx_L9:;
2915
2916 /* "pygame_sdl2/surface.pyx":150
2917 * Amask = 0
2918 *
2919 * if (flags & SRCALPHA): # <<<<<<<<<<<<<<
2920 * if not Amask:
2921 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask)
2922 */
2923 __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 150, __pyx_L1_error)
2924 __Pyx_GOTREF(__pyx_t_9);
2925 __pyx_t_4 = PyNumber_And(__pyx_v_flags, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
2926 __Pyx_GOTREF(__pyx_t_4);
2927 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2928 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
2929 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2930 if (__pyx_t_2) {
2931
2932 /* "pygame_sdl2/surface.pyx":151
2933 *
2934 * if (flags & SRCALPHA):
2935 * if not Amask: # <<<<<<<<<<<<<<
2936 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask)
2937 * else:
2938 */
2939 __pyx_t_2 = ((!(__pyx_v_Amask != 0)) != 0);
2940 if (__pyx_t_2) {
2941
2942 /* "pygame_sdl2/surface.pyx":152
2943 * if (flags & SRCALPHA):
2944 * if not Amask:
2945 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask) # <<<<<<<<<<<<<<
2946 * else:
2947 * Amask = 0
2948 */
2949 __pyx_t_4 = __Pyx_PyInt_From_uint32_t((~((__pyx_v_Rmask | __pyx_v_Gmask) | __pyx_v_Bmask))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
2950 __Pyx_GOTREF(__pyx_t_4);
2951 __pyx_t_9 = PyNumber_And(__pyx_int_4294967295, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 152, __pyx_L1_error)
2952 __Pyx_GOTREF(__pyx_t_9);
2953 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2954 __pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_t_9); if (unlikely((__pyx_t_14 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
2955 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2956 __pyx_v_Amask = __pyx_t_14;
2957
2958 /* "pygame_sdl2/surface.pyx":151
2959 *
2960 * if (flags & SRCALPHA):
2961 * if not Amask: # <<<<<<<<<<<<<<
2962 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask)
2963 * else:
2964 */
2965 }
2966
2967 /* "pygame_sdl2/surface.pyx":150
2968 * Amask = 0
2969 *
2970 * if (flags & SRCALPHA): # <<<<<<<<<<<<<<
2971 * if not Amask:
2972 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask)
2973 */
2974 goto __pyx_L13;
2975 }
2976
2977 /* "pygame_sdl2/surface.pyx":154
2978 * Amask = 0xffffffff & ~(Rmask | Gmask | Bmask)
2979 * else:
2980 * Amask = 0 # <<<<<<<<<<<<<<
2981 *
2982 * depth_int = 32
2983 */
2984 /*else*/ {
2985 __pyx_v_Amask = 0;
2986 }
2987 __pyx_L13:;
2988
2989 /* "pygame_sdl2/surface.pyx":156
2990 * Amask = 0
2991 *
2992 * depth_int = 32 # <<<<<<<<<<<<<<
2993 *
2994 * cdef SDL_Surface *surface
2995 */
2996 __pyx_v_depth_int = 32;
2997 }
2998 __pyx_L6:;
2999
3000 /* "pygame_sdl2/surface.pyx":160
3001 * cdef SDL_Surface *surface
3002 *
3003 * with nogil: # <<<<<<<<<<<<<<
3004 * surface = SDL_CreateRGBSurface(0, w, h, depth_int, Rmask, Gmask, Bmask, Amask)
3005 *
3006 */
3007 {
3008 #ifdef WITH_THREAD
3009 PyThreadState *_save;
3010 Py_UNBLOCK_THREADS
3011 __Pyx_FastGIL_Remember();
3012 #endif
3013 /*try:*/ {
3014
3015 /* "pygame_sdl2/surface.pyx":161
3016 *
3017 * with nogil:
3018 * surface = SDL_CreateRGBSurface(0, w, h, depth_int, Rmask, Gmask, Bmask, Amask) # <<<<<<<<<<<<<<
3019 *
3020 * if not surface:
3021 */
3022 __pyx_v_surface = SDL_CreateRGBSurface(0, __pyx_v_w, __pyx_v_h, __pyx_v_depth_int, __pyx_v_Rmask, __pyx_v_Gmask, __pyx_v_Bmask, __pyx_v_Amask);
3023 }
3024
3025 /* "pygame_sdl2/surface.pyx":160
3026 * cdef SDL_Surface *surface
3027 *
3028 * with nogil: # <<<<<<<<<<<<<<
3029 * surface = SDL_CreateRGBSurface(0, w, h, depth_int, Rmask, Gmask, Bmask, Amask)
3030 *
3031 */
3032 /*finally:*/ {
3033 /*normal exit:*/{
3034 #ifdef WITH_THREAD
3035 __Pyx_FastGIL_Forget();
3036 Py_BLOCK_THREADS
3037 #endif
3038 goto __pyx_L17;
3039 }
3040 __pyx_L17:;
3041 }
3042 }
3043
3044 /* "pygame_sdl2/surface.pyx":163
3045 * surface = SDL_CreateRGBSurface(0, w, h, depth_int, Rmask, Gmask, Bmask, Amask)
3046 *
3047 * if not surface: # <<<<<<<<<<<<<<
3048 * raise error()
3049 *
3050 */
3051 __pyx_t_2 = ((!(__pyx_v_surface != 0)) != 0);
3052 if (unlikely(__pyx_t_2)) {
3053
3054 /* "pygame_sdl2/surface.pyx":164
3055 *
3056 * if not surface:
3057 * raise error() # <<<<<<<<<<<<<<
3058 *
3059 * self.take_surface(surface)
3060 */
3061 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L1_error)
3062 __Pyx_GOTREF(__pyx_t_4);
3063 __pyx_t_1 = NULL;
3064 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3065 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
3066 if (likely(__pyx_t_1)) {
3067 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3068 __Pyx_INCREF(__pyx_t_1);
3069 __Pyx_INCREF(function);
3070 __Pyx_DECREF_SET(__pyx_t_4, function);
3071 }
3072 }
3073 __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
3074 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3075 if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 164, __pyx_L1_error)
3076 __Pyx_GOTREF(__pyx_t_9);
3077 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3078 __Pyx_Raise(__pyx_t_9, 0, 0, 0);
3079 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3080 __PYX_ERR(0, 164, __pyx_L1_error)
3081
3082 /* "pygame_sdl2/surface.pyx":163
3083 * surface = SDL_CreateRGBSurface(0, w, h, depth_int, Rmask, Gmask, Bmask, Amask)
3084 *
3085 * if not surface: # <<<<<<<<<<<<<<
3086 * raise error()
3087 *
3088 */
3089 }
3090
3091 /* "pygame_sdl2/surface.pyx":166
3092 * raise error()
3093 *
3094 * self.take_surface(surface) # <<<<<<<<<<<<<<
3095 *
3096 * cdef void take_surface(self, SDL_Surface *surface):
3097 */
3098 ((struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *)__pyx_v_self->__pyx_vtab)->take_surface(__pyx_v_self, __pyx_v_surface);
3099
3100 /* "pygame_sdl2/surface.pyx":84
3101 * return 0
3102 *
3103 * def __init__(self, size, flags=0, depth=32, masks=None): # <<<<<<<<<<<<<<
3104 *
3105 * self.locklist = None
3106 */
3107
3108 /* function exit code */
3109 __pyx_r = 0;
3110 goto __pyx_L0;
3111 __pyx_L1_error:;
3112 __Pyx_XDECREF(__pyx_t_1);
3113 __Pyx_XDECREF(__pyx_t_3);
3114 __Pyx_XDECREF(__pyx_t_4);
3115 __Pyx_XDECREF(__pyx_t_9);
3116 __Pyx_XDECREF(__pyx_t_10);
3117 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3118 __pyx_r = -1;
3119 __pyx_L0:;
3120 __Pyx_XDECREF((PyObject *)__pyx_v_pysample);
3121 __Pyx_RefNannyFinishContext();
3122 return __pyx_r;
3123 }
3124
3125 /* "pygame_sdl2/surface.pyx":168
3126 * self.take_surface(surface)
3127 *
3128 * cdef void take_surface(self, SDL_Surface *surface): # <<<<<<<<<<<<<<
3129 * if not surface:
3130 * raise error("A null pointer was passed in.")
3131 */
3132
__pyx_f_11pygame_sdl2_7surface_7Surface_take_surface(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,SDL_Surface * __pyx_v_surface)3133 static void __pyx_f_11pygame_sdl2_7surface_7Surface_take_surface(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, SDL_Surface *__pyx_v_surface) {
3134 __Pyx_RefNannyDeclarations
3135 int __pyx_t_1;
3136 PyObject *__pyx_t_2 = NULL;
3137 PyObject *__pyx_t_3 = NULL;
3138 PyObject *__pyx_t_4 = NULL;
3139 int __pyx_lineno = 0;
3140 const char *__pyx_filename = NULL;
3141 int __pyx_clineno = 0;
3142 __Pyx_RefNannySetupContext("take_surface", 0);
3143
3144 /* "pygame_sdl2/surface.pyx":169
3145 *
3146 * cdef void take_surface(self, SDL_Surface *surface):
3147 * if not surface: # <<<<<<<<<<<<<<
3148 * raise error("A null pointer was passed in.")
3149 *
3150 */
3151 __pyx_t_1 = ((!(__pyx_v_surface != 0)) != 0);
3152 if (unlikely(__pyx_t_1)) {
3153
3154 /* "pygame_sdl2/surface.pyx":170
3155 * cdef void take_surface(self, SDL_Surface *surface):
3156 * if not surface:
3157 * raise error("A null pointer was passed in.") # <<<<<<<<<<<<<<
3158 *
3159 * self.surface = surface
3160 */
3161 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
3162 __Pyx_GOTREF(__pyx_t_3);
3163 __pyx_t_4 = NULL;
3164 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3165 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3166 if (likely(__pyx_t_4)) {
3167 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3168 __Pyx_INCREF(__pyx_t_4);
3169 __Pyx_INCREF(function);
3170 __Pyx_DECREF_SET(__pyx_t_3, function);
3171 }
3172 }
3173 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_s_A_null_pointer_was_passed_in) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_A_null_pointer_was_passed_in);
3174 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3175 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)
3176 __Pyx_GOTREF(__pyx_t_2);
3177 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3178 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3179 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3180 __PYX_ERR(0, 170, __pyx_L1_error)
3181
3182 /* "pygame_sdl2/surface.pyx":169
3183 *
3184 * cdef void take_surface(self, SDL_Surface *surface):
3185 * if not surface: # <<<<<<<<<<<<<<
3186 * raise error("A null pointer was passed in.")
3187 *
3188 */
3189 }
3190
3191 /* "pygame_sdl2/surface.pyx":172
3192 * raise error("A null pointer was passed in.")
3193 *
3194 * self.surface = surface # <<<<<<<<<<<<<<
3195 * self.owns_surface = True
3196 *
3197 */
3198 __pyx_v_self->surface = __pyx_v_surface;
3199
3200 /* "pygame_sdl2/surface.pyx":173
3201 *
3202 * self.surface = surface
3203 * self.owns_surface = True # <<<<<<<<<<<<<<
3204 *
3205 * global total_size
3206 */
3207 __pyx_v_self->owns_surface = 1;
3208
3209 /* "pygame_sdl2/surface.pyx":177
3210 * global total_size
3211 *
3212 * total_size += self.surface.pitch * self.surface.h # <<<<<<<<<<<<<<
3213 *
3214 * def __repr__(self):
3215 */
3216 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_total_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
3217 __Pyx_GOTREF(__pyx_t_2);
3218 __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->surface->pitch * __pyx_v_self->surface->h)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
3219 __Pyx_GOTREF(__pyx_t_3);
3220 __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
3221 __Pyx_GOTREF(__pyx_t_4);
3222 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3223 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3224 if (PyDict_SetItem(__pyx_d, __pyx_n_s_total_size, __pyx_t_4) < 0) __PYX_ERR(0, 177, __pyx_L1_error)
3225 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3226
3227 /* "pygame_sdl2/surface.pyx":168
3228 * self.take_surface(surface)
3229 *
3230 * cdef void take_surface(self, SDL_Surface *surface): # <<<<<<<<<<<<<<
3231 * if not surface:
3232 * raise error("A null pointer was passed in.")
3233 */
3234
3235 /* function exit code */
3236 goto __pyx_L0;
3237 __pyx_L1_error:;
3238 __Pyx_XDECREF(__pyx_t_2);
3239 __Pyx_XDECREF(__pyx_t_3);
3240 __Pyx_XDECREF(__pyx_t_4);
3241 __Pyx_WriteUnraisable("pygame_sdl2.surface.Surface.take_surface", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3242 __pyx_L0:;
3243 __Pyx_RefNannyFinishContext();
3244 }
3245
3246 /* "pygame_sdl2/surface.pyx":179
3247 * total_size += self.surface.pitch * self.surface.h
3248 *
3249 * def __repr__(self): # <<<<<<<<<<<<<<
3250 * return "<Surface({}x{}x{})>".format(self.surface.w, self.surface.h, self.surface.format.BitsPerPixel)
3251 *
3252 */
3253
3254 /* Python wrapper */
3255 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_9__repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_9__repr__(PyObject * __pyx_v_self)3256 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_9__repr__(PyObject *__pyx_v_self) {
3257 PyObject *__pyx_r = 0;
3258 __Pyx_RefNannyDeclarations
3259 __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
3260 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_8__repr__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
3261
3262 /* function exit code */
3263 __Pyx_RefNannyFinishContext();
3264 return __pyx_r;
3265 }
3266
__pyx_pf_11pygame_sdl2_7surface_7Surface_8__repr__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)3267 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_8__repr__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
3268 PyObject *__pyx_r = NULL;
3269 __Pyx_RefNannyDeclarations
3270 PyObject *__pyx_t_1 = NULL;
3271 PyObject *__pyx_t_2 = NULL;
3272 PyObject *__pyx_t_3 = NULL;
3273 PyObject *__pyx_t_4 = NULL;
3274 PyObject *__pyx_t_5 = NULL;
3275 PyObject *__pyx_t_6 = NULL;
3276 int __pyx_t_7;
3277 PyObject *__pyx_t_8 = NULL;
3278 int __pyx_lineno = 0;
3279 const char *__pyx_filename = NULL;
3280 int __pyx_clineno = 0;
3281 __Pyx_RefNannySetupContext("__repr__", 0);
3282
3283 /* "pygame_sdl2/surface.pyx":180
3284 *
3285 * def __repr__(self):
3286 * return "<Surface({}x{}x{})>".format(self.surface.w, self.surface.h, self.surface.format.BitsPerPixel) # <<<<<<<<<<<<<<
3287 *
3288 * def blit(self, Surface source, dest, area=None, int special_flags=0):
3289 */
3290 __Pyx_XDECREF(__pyx_r);
3291 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Surface_x_x, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
3292 __Pyx_GOTREF(__pyx_t_2);
3293 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
3294 __Pyx_GOTREF(__pyx_t_3);
3295 __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error)
3296 __Pyx_GOTREF(__pyx_t_4);
3297 __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->surface->format->BitsPerPixel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 180, __pyx_L1_error)
3298 __Pyx_GOTREF(__pyx_t_5);
3299 __pyx_t_6 = NULL;
3300 __pyx_t_7 = 0;
3301 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3302 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
3303 if (likely(__pyx_t_6)) {
3304 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3305 __Pyx_INCREF(__pyx_t_6);
3306 __Pyx_INCREF(function);
3307 __Pyx_DECREF_SET(__pyx_t_2, function);
3308 __pyx_t_7 = 1;
3309 }
3310 }
3311 #if CYTHON_FAST_PYCALL
3312 if (PyFunction_Check(__pyx_t_2)) {
3313 PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
3314 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
3315 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3316 __Pyx_GOTREF(__pyx_t_1);
3317 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3318 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3319 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3320 } else
3321 #endif
3322 #if CYTHON_FAST_PYCCALL
3323 if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
3324 PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
3325 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
3326 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3327 __Pyx_GOTREF(__pyx_t_1);
3328 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3329 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3330 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3331 } else
3332 #endif
3333 {
3334 __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 180, __pyx_L1_error)
3335 __Pyx_GOTREF(__pyx_t_8);
3336 if (__pyx_t_6) {
3337 __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
3338 }
3339 __Pyx_GIVEREF(__pyx_t_3);
3340 PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
3341 __Pyx_GIVEREF(__pyx_t_4);
3342 PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
3343 __Pyx_GIVEREF(__pyx_t_5);
3344 PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
3345 __pyx_t_3 = 0;
3346 __pyx_t_4 = 0;
3347 __pyx_t_5 = 0;
3348 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
3349 __Pyx_GOTREF(__pyx_t_1);
3350 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3351 }
3352 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3353 __pyx_r = __pyx_t_1;
3354 __pyx_t_1 = 0;
3355 goto __pyx_L0;
3356
3357 /* "pygame_sdl2/surface.pyx":179
3358 * total_size += self.surface.pitch * self.surface.h
3359 *
3360 * def __repr__(self): # <<<<<<<<<<<<<<
3361 * return "<Surface({}x{}x{})>".format(self.surface.w, self.surface.h, self.surface.format.BitsPerPixel)
3362 *
3363 */
3364
3365 /* function exit code */
3366 __pyx_L1_error:;
3367 __Pyx_XDECREF(__pyx_t_1);
3368 __Pyx_XDECREF(__pyx_t_2);
3369 __Pyx_XDECREF(__pyx_t_3);
3370 __Pyx_XDECREF(__pyx_t_4);
3371 __Pyx_XDECREF(__pyx_t_5);
3372 __Pyx_XDECREF(__pyx_t_6);
3373 __Pyx_XDECREF(__pyx_t_8);
3374 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3375 __pyx_r = NULL;
3376 __pyx_L0:;
3377 __Pyx_XGIVEREF(__pyx_r);
3378 __Pyx_RefNannyFinishContext();
3379 return __pyx_r;
3380 }
3381
3382 /* "pygame_sdl2/surface.pyx":182
3383 * return "<Surface({}x{}x{})>".format(self.surface.w, self.surface.h, self.surface.format.BitsPerPixel)
3384 *
3385 * def blit(self, Surface source, dest, area=None, int special_flags=0): # <<<<<<<<<<<<<<
3386 * cdef SDL_Rect dest_rect
3387 * cdef SDL_Rect area_rect
3388 */
3389
3390 /* Python wrapper */
3391 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_11blit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_11blit(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3392 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_11blit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3393 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_source = 0;
3394 PyObject *__pyx_v_dest = 0;
3395 PyObject *__pyx_v_area = 0;
3396 int __pyx_v_special_flags;
3397 int __pyx_lineno = 0;
3398 const char *__pyx_filename = NULL;
3399 int __pyx_clineno = 0;
3400 PyObject *__pyx_r = 0;
3401 __Pyx_RefNannyDeclarations
3402 __Pyx_RefNannySetupContext("blit (wrapper)", 0);
3403 {
3404 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_dest,&__pyx_n_s_area,&__pyx_n_s_special_flags,0};
3405 PyObject* values[4] = {0,0,0,0};
3406 values[2] = ((PyObject *)Py_None);
3407 if (unlikely(__pyx_kwds)) {
3408 Py_ssize_t kw_args;
3409 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3410 switch (pos_args) {
3411 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3412 CYTHON_FALLTHROUGH;
3413 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3414 CYTHON_FALLTHROUGH;
3415 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3416 CYTHON_FALLTHROUGH;
3417 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3418 CYTHON_FALLTHROUGH;
3419 case 0: break;
3420 default: goto __pyx_L5_argtuple_error;
3421 }
3422 kw_args = PyDict_Size(__pyx_kwds);
3423 switch (pos_args) {
3424 case 0:
3425 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
3426 else goto __pyx_L5_argtuple_error;
3427 CYTHON_FALLTHROUGH;
3428 case 1:
3429 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest)) != 0)) kw_args--;
3430 else {
3431 __Pyx_RaiseArgtupleInvalid("blit", 0, 2, 4, 1); __PYX_ERR(0, 182, __pyx_L3_error)
3432 }
3433 CYTHON_FALLTHROUGH;
3434 case 2:
3435 if (kw_args > 0) {
3436 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_area);
3437 if (value) { values[2] = value; kw_args--; }
3438 }
3439 CYTHON_FALLTHROUGH;
3440 case 3:
3441 if (kw_args > 0) {
3442 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_special_flags);
3443 if (value) { values[3] = value; kw_args--; }
3444 }
3445 }
3446 if (unlikely(kw_args > 0)) {
3447 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blit") < 0)) __PYX_ERR(0, 182, __pyx_L3_error)
3448 }
3449 } else {
3450 switch (PyTuple_GET_SIZE(__pyx_args)) {
3451 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3452 CYTHON_FALLTHROUGH;
3453 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3454 CYTHON_FALLTHROUGH;
3455 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3456 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3457 break;
3458 default: goto __pyx_L5_argtuple_error;
3459 }
3460 }
3461 __pyx_v_source = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)values[0]);
3462 __pyx_v_dest = values[1];
3463 __pyx_v_area = values[2];
3464 if (values[3]) {
3465 __pyx_v_special_flags = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_special_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L3_error)
3466 } else {
3467 __pyx_v_special_flags = ((int)0);
3468 }
3469 }
3470 goto __pyx_L4_argument_unpacking_done;
3471 __pyx_L5_argtuple_error:;
3472 __Pyx_RaiseArgtupleInvalid("blit", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 182, __pyx_L3_error)
3473 __pyx_L3_error:;
3474 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.blit", __pyx_clineno, __pyx_lineno, __pyx_filename);
3475 __Pyx_RefNannyFinishContext();
3476 return NULL;
3477 __pyx_L4_argument_unpacking_done:;
3478 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_source), __pyx_ptype_11pygame_sdl2_7surface_Surface, 1, "source", 0))) __PYX_ERR(0, 182, __pyx_L1_error)
3479 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_10blit(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_source, __pyx_v_dest, __pyx_v_area, __pyx_v_special_flags);
3480
3481 /* function exit code */
3482 goto __pyx_L0;
3483 __pyx_L1_error:;
3484 __pyx_r = NULL;
3485 __pyx_L0:;
3486 __Pyx_RefNannyFinishContext();
3487 return __pyx_r;
3488 }
3489
__pyx_pf_11pygame_sdl2_7surface_7Surface_10blit(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_source,PyObject * __pyx_v_dest,PyObject * __pyx_v_area,int __pyx_v_special_flags)3490 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_10blit(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_source, PyObject *__pyx_v_dest, PyObject *__pyx_v_area, int __pyx_v_special_flags) {
3491 SDL_Rect __pyx_v_dest_rect;
3492 SDL_Rect __pyx_v_area_rect;
3493 SDL_Rect *__pyx_v_area_ptr;
3494 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_temp = 0;
3495 int __pyx_v_err;
3496 Uint32 __pyx_v_key;
3497 Uint8 __pyx_v_alpha;
3498 int __pyx_v_colorkey;
3499 PyObject *__pyx_v_dirty = NULL;
3500 PyObject *__pyx_r = NULL;
3501 __Pyx_RefNannyDeclarations
3502 int __pyx_t_1;
3503 PyObject *__pyx_t_2 = NULL;
3504 PyObject *__pyx_t_3 = NULL;
3505 PyObject *__pyx_t_4 = NULL;
3506 int __pyx_t_5;
3507 int __pyx_t_6;
3508 struct __pyx_opt_args_11pygame_sdl2_4rect_to_sdl_rect __pyx_t_7;
3509 PyObject *__pyx_t_8 = NULL;
3510 PyObject *__pyx_t_9 = NULL;
3511 PyObject *__pyx_t_10 = NULL;
3512 PyObject *__pyx_t_11 = NULL;
3513 PyObject *__pyx_t_12 = NULL;
3514 int __pyx_lineno = 0;
3515 const char *__pyx_filename = NULL;
3516 int __pyx_clineno = 0;
3517 __Pyx_RefNannySetupContext("blit", 0);
3518 __Pyx_INCREF((PyObject *)__pyx_v_source);
3519 __Pyx_INCREF(__pyx_v_area);
3520
3521 /* "pygame_sdl2/surface.pyx":185
3522 * cdef SDL_Rect dest_rect
3523 * cdef SDL_Rect area_rect
3524 * cdef SDL_Rect *area_ptr = NULL # <<<<<<<<<<<<<<
3525 *
3526 * cdef Surface temp
3527 */
3528 __pyx_v_area_ptr = NULL;
3529
3530 /* "pygame_sdl2/surface.pyx":194
3531 * cdef bint colorkey
3532 *
3533 * colorkey = (SDL_GetColorKey(source.surface, &key) == 0) # <<<<<<<<<<<<<<
3534 *
3535 * if not source.surface.format.Amask:
3536 */
3537 __pyx_v_colorkey = (SDL_GetColorKey(__pyx_v_source->surface, (&__pyx_v_key)) == 0);
3538
3539 /* "pygame_sdl2/surface.pyx":196
3540 * colorkey = (SDL_GetColorKey(source.surface, &key) == 0)
3541 *
3542 * if not source.surface.format.Amask: # <<<<<<<<<<<<<<
3543 * if SDL_GetSurfaceAlphaMod(source.surface, &alpha):
3544 * raise error()
3545 */
3546 __pyx_t_1 = ((!(__pyx_v_source->surface->format->Amask != 0)) != 0);
3547 if (__pyx_t_1) {
3548
3549 /* "pygame_sdl2/surface.pyx":197
3550 *
3551 * if not source.surface.format.Amask:
3552 * if SDL_GetSurfaceAlphaMod(source.surface, &alpha): # <<<<<<<<<<<<<<
3553 * raise error()
3554 *
3555 */
3556 __pyx_t_1 = (SDL_GetSurfaceAlphaMod(__pyx_v_source->surface, (&__pyx_v_alpha)) != 0);
3557 if (unlikely(__pyx_t_1)) {
3558
3559 /* "pygame_sdl2/surface.pyx":198
3560 * if not source.surface.format.Amask:
3561 * if SDL_GetSurfaceAlphaMod(source.surface, &alpha):
3562 * raise error() # <<<<<<<<<<<<<<
3563 *
3564 * if alpha != 255 and (self.surface.format.Amask or colorkey):
3565 */
3566 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
3567 __Pyx_GOTREF(__pyx_t_3);
3568 __pyx_t_4 = NULL;
3569 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3570 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3571 if (likely(__pyx_t_4)) {
3572 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3573 __Pyx_INCREF(__pyx_t_4);
3574 __Pyx_INCREF(function);
3575 __Pyx_DECREF_SET(__pyx_t_3, function);
3576 }
3577 }
3578 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
3579 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3580 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
3581 __Pyx_GOTREF(__pyx_t_2);
3582 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3583 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3584 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3585 __PYX_ERR(0, 198, __pyx_L1_error)
3586
3587 /* "pygame_sdl2/surface.pyx":197
3588 *
3589 * if not source.surface.format.Amask:
3590 * if SDL_GetSurfaceAlphaMod(source.surface, &alpha): # <<<<<<<<<<<<<<
3591 * raise error()
3592 *
3593 */
3594 }
3595
3596 /* "pygame_sdl2/surface.pyx":200
3597 * raise error()
3598 *
3599 * if alpha != 255 and (self.surface.format.Amask or colorkey): # <<<<<<<<<<<<<<
3600 *
3601 * if area:
3602 */
3603 __pyx_t_5 = ((__pyx_v_alpha != 0xFF) != 0);
3604 if (__pyx_t_5) {
3605 } else {
3606 __pyx_t_1 = __pyx_t_5;
3607 goto __pyx_L6_bool_binop_done;
3608 }
3609 __pyx_t_5 = (__pyx_v_self->surface->format->Amask != 0);
3610 if (!__pyx_t_5) {
3611 } else {
3612 __pyx_t_1 = __pyx_t_5;
3613 goto __pyx_L6_bool_binop_done;
3614 }
3615 __pyx_t_5 = (__pyx_v_colorkey != 0);
3616 __pyx_t_1 = __pyx_t_5;
3617 __pyx_L6_bool_binop_done:;
3618 if (__pyx_t_1) {
3619
3620 /* "pygame_sdl2/surface.pyx":202
3621 * if alpha != 255 and (self.surface.format.Amask or colorkey):
3622 *
3623 * if area: # <<<<<<<<<<<<<<
3624 * source = source.subsurface(area)
3625 * area = None
3626 */
3627 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_area); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 202, __pyx_L1_error)
3628 if (__pyx_t_1) {
3629
3630 /* "pygame_sdl2/surface.pyx":203
3631 *
3632 * if area:
3633 * source = source.subsurface(area) # <<<<<<<<<<<<<<
3634 * area = None
3635 *
3636 */
3637 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_source), __pyx_n_s_subsurface); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
3638 __Pyx_GOTREF(__pyx_t_3);
3639 __pyx_t_4 = NULL;
3640 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3641 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3642 if (likely(__pyx_t_4)) {
3643 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3644 __Pyx_INCREF(__pyx_t_4);
3645 __Pyx_INCREF(function);
3646 __Pyx_DECREF_SET(__pyx_t_3, function);
3647 }
3648 }
3649 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_area) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_area);
3650 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3651 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
3652 __Pyx_GOTREF(__pyx_t_2);
3653 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3654 if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_11pygame_sdl2_7surface_Surface))))) __PYX_ERR(0, 203, __pyx_L1_error)
3655 __Pyx_DECREF_SET(__pyx_v_source, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
3656 __pyx_t_2 = 0;
3657
3658 /* "pygame_sdl2/surface.pyx":204
3659 * if area:
3660 * source = source.subsurface(area)
3661 * area = None # <<<<<<<<<<<<<<
3662 *
3663 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3664 */
3665 __Pyx_INCREF(Py_None);
3666 __Pyx_DECREF_SET(__pyx_v_area, Py_None);
3667
3668 /* "pygame_sdl2/surface.pyx":202
3669 * if alpha != 255 and (self.surface.format.Amask or colorkey):
3670 *
3671 * if area: # <<<<<<<<<<<<<<
3672 * source = source.subsurface(area)
3673 * area = None
3674 */
3675 }
3676
3677 /* "pygame_sdl2/surface.pyx":206
3678 * area = None
3679 *
3680 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE): # <<<<<<<<<<<<<<
3681 * raise error()
3682 * temp = Surface(source.get_size(), SRCALPHA)
3683 */
3684 __pyx_t_1 = (SDL_SetSurfaceBlendMode(__pyx_v_source->surface, SDL_BLENDMODE_NONE) != 0);
3685 if (unlikely(__pyx_t_1)) {
3686
3687 /* "pygame_sdl2/surface.pyx":207
3688 *
3689 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3690 * raise error() # <<<<<<<<<<<<<<
3691 * temp = Surface(source.get_size(), SRCALPHA)
3692 *
3693 */
3694 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
3695 __Pyx_GOTREF(__pyx_t_3);
3696 __pyx_t_4 = NULL;
3697 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3698 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3699 if (likely(__pyx_t_4)) {
3700 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3701 __Pyx_INCREF(__pyx_t_4);
3702 __Pyx_INCREF(function);
3703 __Pyx_DECREF_SET(__pyx_t_3, function);
3704 }
3705 }
3706 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
3707 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3708 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
3709 __Pyx_GOTREF(__pyx_t_2);
3710 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3711 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3712 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3713 __PYX_ERR(0, 207, __pyx_L1_error)
3714
3715 /* "pygame_sdl2/surface.pyx":206
3716 * area = None
3717 *
3718 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE): # <<<<<<<<<<<<<<
3719 * raise error()
3720 * temp = Surface(source.get_size(), SRCALPHA)
3721 */
3722 }
3723
3724 /* "pygame_sdl2/surface.pyx":208
3725 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3726 * raise error()
3727 * temp = Surface(source.get_size(), SRCALPHA) # <<<<<<<<<<<<<<
3728 *
3729 * with nogil:
3730 */
3731 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_source), __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error)
3732 __Pyx_GOTREF(__pyx_t_3);
3733 __pyx_t_4 = NULL;
3734 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3735 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3736 if (likely(__pyx_t_4)) {
3737 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3738 __Pyx_INCREF(__pyx_t_4);
3739 __Pyx_INCREF(function);
3740 __Pyx_DECREF_SET(__pyx_t_3, function);
3741 }
3742 }
3743 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
3744 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3745 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error)
3746 __Pyx_GOTREF(__pyx_t_2);
3747 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3748 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error)
3749 __Pyx_GOTREF(__pyx_t_3);
3750 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 208, __pyx_L1_error)
3751 __Pyx_GOTREF(__pyx_t_4);
3752 __Pyx_GIVEREF(__pyx_t_2);
3753 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
3754 __Pyx_GIVEREF(__pyx_t_3);
3755 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
3756 __pyx_t_2 = 0;
3757 __pyx_t_3 = 0;
3758 __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pygame_sdl2_7surface_Surface), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error)
3759 __Pyx_GOTREF(__pyx_t_3);
3760 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3761 __pyx_v_temp = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_3);
3762 __pyx_t_3 = 0;
3763
3764 /* "pygame_sdl2/surface.pyx":210
3765 * temp = Surface(source.get_size(), SRCALPHA)
3766 *
3767 * with nogil: # <<<<<<<<<<<<<<
3768 * err = SDL_UpperBlit(source.surface, NULL, temp.surface, NULL)
3769 *
3770 */
3771 {
3772 #ifdef WITH_THREAD
3773 PyThreadState *_save;
3774 Py_UNBLOCK_THREADS
3775 __Pyx_FastGIL_Remember();
3776 #endif
3777 /*try:*/ {
3778
3779 /* "pygame_sdl2/surface.pyx":211
3780 *
3781 * with nogil:
3782 * err = SDL_UpperBlit(source.surface, NULL, temp.surface, NULL) # <<<<<<<<<<<<<<
3783 *
3784 * if err:
3785 */
3786 __pyx_v_err = SDL_UpperBlit(__pyx_v_source->surface, NULL, __pyx_v_temp->surface, NULL);
3787 }
3788
3789 /* "pygame_sdl2/surface.pyx":210
3790 * temp = Surface(source.get_size(), SRCALPHA)
3791 *
3792 * with nogil: # <<<<<<<<<<<<<<
3793 * err = SDL_UpperBlit(source.surface, NULL, temp.surface, NULL)
3794 *
3795 */
3796 /*finally:*/ {
3797 /*normal exit:*/{
3798 #ifdef WITH_THREAD
3799 __Pyx_FastGIL_Forget();
3800 Py_BLOCK_THREADS
3801 #endif
3802 goto __pyx_L13;
3803 }
3804 __pyx_L13:;
3805 }
3806 }
3807
3808 /* "pygame_sdl2/surface.pyx":213
3809 * err = SDL_UpperBlit(source.surface, NULL, temp.surface, NULL)
3810 *
3811 * if err: # <<<<<<<<<<<<<<
3812 * raise error()
3813 *
3814 */
3815 __pyx_t_1 = (__pyx_v_err != 0);
3816 if (unlikely(__pyx_t_1)) {
3817
3818 /* "pygame_sdl2/surface.pyx":214
3819 *
3820 * if err:
3821 * raise error() # <<<<<<<<<<<<<<
3822 *
3823 * source = temp
3824 */
3825 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 214, __pyx_L1_error)
3826 __Pyx_GOTREF(__pyx_t_4);
3827 __pyx_t_2 = NULL;
3828 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3829 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
3830 if (likely(__pyx_t_2)) {
3831 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3832 __Pyx_INCREF(__pyx_t_2);
3833 __Pyx_INCREF(function);
3834 __Pyx_DECREF_SET(__pyx_t_4, function);
3835 }
3836 }
3837 __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
3838 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3839 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
3840 __Pyx_GOTREF(__pyx_t_3);
3841 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3842 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3843 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3844 __PYX_ERR(0, 214, __pyx_L1_error)
3845
3846 /* "pygame_sdl2/surface.pyx":213
3847 * err = SDL_UpperBlit(source.surface, NULL, temp.surface, NULL)
3848 *
3849 * if err: # <<<<<<<<<<<<<<
3850 * raise error()
3851 *
3852 */
3853 }
3854
3855 /* "pygame_sdl2/surface.pyx":216
3856 * raise error()
3857 *
3858 * source = temp # <<<<<<<<<<<<<<
3859 * colorkey = False
3860 *
3861 */
3862 __Pyx_INCREF(((PyObject *)__pyx_v_temp));
3863 __Pyx_DECREF_SET(__pyx_v_source, __pyx_v_temp);
3864
3865 /* "pygame_sdl2/surface.pyx":217
3866 *
3867 * source = temp
3868 * colorkey = False # <<<<<<<<<<<<<<
3869 *
3870 * if colorkey:
3871 */
3872 __pyx_v_colorkey = 0;
3873
3874 /* "pygame_sdl2/surface.pyx":200
3875 * raise error()
3876 *
3877 * if alpha != 255 and (self.surface.format.Amask or colorkey): # <<<<<<<<<<<<<<
3878 *
3879 * if area:
3880 */
3881 }
3882
3883 /* "pygame_sdl2/surface.pyx":196
3884 * colorkey = (SDL_GetColorKey(source.surface, &key) == 0)
3885 *
3886 * if not source.surface.format.Amask: # <<<<<<<<<<<<<<
3887 * if SDL_GetSurfaceAlphaMod(source.surface, &alpha):
3888 * raise error()
3889 */
3890 }
3891
3892 /* "pygame_sdl2/surface.pyx":219
3893 * colorkey = False
3894 *
3895 * if colorkey: # <<<<<<<<<<<<<<
3896 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3897 * raise error()
3898 */
3899 __pyx_t_1 = (__pyx_v_colorkey != 0);
3900 if (__pyx_t_1) {
3901
3902 /* "pygame_sdl2/surface.pyx":220
3903 *
3904 * if colorkey:
3905 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE): # <<<<<<<<<<<<<<
3906 * raise error()
3907 * else:
3908 */
3909 __pyx_t_1 = (SDL_SetSurfaceBlendMode(__pyx_v_source->surface, SDL_BLENDMODE_NONE) != 0);
3910 if (unlikely(__pyx_t_1)) {
3911
3912 /* "pygame_sdl2/surface.pyx":221
3913 * if colorkey:
3914 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3915 * raise error() # <<<<<<<<<<<<<<
3916 * else:
3917 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_BLEND):
3918 */
3919 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 221, __pyx_L1_error)
3920 __Pyx_GOTREF(__pyx_t_4);
3921 __pyx_t_2 = NULL;
3922 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3923 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
3924 if (likely(__pyx_t_2)) {
3925 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3926 __Pyx_INCREF(__pyx_t_2);
3927 __Pyx_INCREF(function);
3928 __Pyx_DECREF_SET(__pyx_t_4, function);
3929 }
3930 }
3931 __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
3932 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3933 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
3934 __Pyx_GOTREF(__pyx_t_3);
3935 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3936 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3937 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3938 __PYX_ERR(0, 221, __pyx_L1_error)
3939
3940 /* "pygame_sdl2/surface.pyx":220
3941 *
3942 * if colorkey:
3943 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE): # <<<<<<<<<<<<<<
3944 * raise error()
3945 * else:
3946 */
3947 }
3948
3949 /* "pygame_sdl2/surface.pyx":219
3950 * colorkey = False
3951 *
3952 * if colorkey: # <<<<<<<<<<<<<<
3953 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_NONE):
3954 * raise error()
3955 */
3956 goto __pyx_L15;
3957 }
3958
3959 /* "pygame_sdl2/surface.pyx":223
3960 * raise error()
3961 * else:
3962 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_BLEND): # <<<<<<<<<<<<<<
3963 * raise error()
3964 *
3965 */
3966 /*else*/ {
3967 __pyx_t_1 = (SDL_SetSurfaceBlendMode(__pyx_v_source->surface, SDL_BLENDMODE_BLEND) != 0);
3968 if (unlikely(__pyx_t_1)) {
3969
3970 /* "pygame_sdl2/surface.pyx":224
3971 * else:
3972 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_BLEND):
3973 * raise error() # <<<<<<<<<<<<<<
3974 *
3975 * to_sdl_rect(dest, &dest_rect, "dest")
3976 */
3977 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
3978 __Pyx_GOTREF(__pyx_t_4);
3979 __pyx_t_2 = NULL;
3980 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3981 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
3982 if (likely(__pyx_t_2)) {
3983 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3984 __Pyx_INCREF(__pyx_t_2);
3985 __Pyx_INCREF(function);
3986 __Pyx_DECREF_SET(__pyx_t_4, function);
3987 }
3988 }
3989 __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
3990 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3991 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
3992 __Pyx_GOTREF(__pyx_t_3);
3993 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3994 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3995 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3996 __PYX_ERR(0, 224, __pyx_L1_error)
3997
3998 /* "pygame_sdl2/surface.pyx":223
3999 * raise error()
4000 * else:
4001 * if SDL_SetSurfaceBlendMode(source.surface, SDL_BLENDMODE_BLEND): # <<<<<<<<<<<<<<
4002 * raise error()
4003 *
4004 */
4005 }
4006 }
4007 __pyx_L15:;
4008
4009 /* "pygame_sdl2/surface.pyx":226
4010 * raise error()
4011 *
4012 * to_sdl_rect(dest, &dest_rect, "dest") # <<<<<<<<<<<<<<
4013 *
4014 * if area is not None:
4015 */
4016 __pyx_t_7.__pyx_n = 1;
4017 __pyx_t_7.argname = __pyx_n_s_dest;
4018 __pyx_t_6 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_v_dest, (&__pyx_v_dest_rect), &__pyx_t_7); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 226, __pyx_L1_error)
4019
4020 /* "pygame_sdl2/surface.pyx":228
4021 * to_sdl_rect(dest, &dest_rect, "dest")
4022 *
4023 * if area is not None: # <<<<<<<<<<<<<<
4024 * to_sdl_rect(area, &area_rect, "area")
4025 * area_ptr = &area_rect
4026 */
4027 __pyx_t_1 = (__pyx_v_area != Py_None);
4028 __pyx_t_5 = (__pyx_t_1 != 0);
4029 if (__pyx_t_5) {
4030
4031 /* "pygame_sdl2/surface.pyx":229
4032 *
4033 * if area is not None:
4034 * to_sdl_rect(area, &area_rect, "area") # <<<<<<<<<<<<<<
4035 * area_ptr = &area_rect
4036 *
4037 */
4038 __pyx_t_7.__pyx_n = 1;
4039 __pyx_t_7.argname = __pyx_n_s_area;
4040 __pyx_t_6 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_v_area, (&__pyx_v_area_rect), &__pyx_t_7); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 229, __pyx_L1_error)
4041
4042 /* "pygame_sdl2/surface.pyx":230
4043 * if area is not None:
4044 * to_sdl_rect(area, &area_rect, "area")
4045 * area_ptr = &area_rect # <<<<<<<<<<<<<<
4046 *
4047 * with nogil:
4048 */
4049 __pyx_v_area_ptr = (&__pyx_v_area_rect);
4050
4051 /* "pygame_sdl2/surface.pyx":228
4052 * to_sdl_rect(dest, &dest_rect, "dest")
4053 *
4054 * if area is not None: # <<<<<<<<<<<<<<
4055 * to_sdl_rect(area, &area_rect, "area")
4056 * area_ptr = &area_rect
4057 */
4058 }
4059
4060 /* "pygame_sdl2/surface.pyx":232
4061 * area_ptr = &area_rect
4062 *
4063 * with nogil: # <<<<<<<<<<<<<<
4064 *
4065 * if source.surface.format.Amask or special_flags:
4066 */
4067 {
4068 #ifdef WITH_THREAD
4069 PyThreadState *_save;
4070 Py_UNBLOCK_THREADS
4071 __Pyx_FastGIL_Remember();
4072 #endif
4073 /*try:*/ {
4074
4075 /* "pygame_sdl2/surface.pyx":234
4076 * with nogil:
4077 *
4078 * if source.surface.format.Amask or special_flags: # <<<<<<<<<<<<<<
4079 * err = pygame_Blit(source.surface, area_ptr, self.surface, &dest_rect, special_flags)
4080 * else:
4081 */
4082 __pyx_t_1 = (__pyx_v_source->surface->format->Amask != 0);
4083 if (!__pyx_t_1) {
4084 } else {
4085 __pyx_t_5 = __pyx_t_1;
4086 goto __pyx_L23_bool_binop_done;
4087 }
4088 __pyx_t_1 = (__pyx_v_special_flags != 0);
4089 __pyx_t_5 = __pyx_t_1;
4090 __pyx_L23_bool_binop_done:;
4091 if (__pyx_t_5) {
4092
4093 /* "pygame_sdl2/surface.pyx":235
4094 *
4095 * if source.surface.format.Amask or special_flags:
4096 * err = pygame_Blit(source.surface, area_ptr, self.surface, &dest_rect, special_flags) # <<<<<<<<<<<<<<
4097 * else:
4098 * err = SDL_UpperBlit(source.surface, area_ptr, self.surface, &dest_rect)
4099 */
4100 __pyx_v_err = pygame_Blit(__pyx_v_source->surface, __pyx_v_area_ptr, __pyx_v_self->surface, (&__pyx_v_dest_rect), __pyx_v_special_flags);
4101
4102 /* "pygame_sdl2/surface.pyx":234
4103 * with nogil:
4104 *
4105 * if source.surface.format.Amask or special_flags: # <<<<<<<<<<<<<<
4106 * err = pygame_Blit(source.surface, area_ptr, self.surface, &dest_rect, special_flags)
4107 * else:
4108 */
4109 goto __pyx_L22;
4110 }
4111
4112 /* "pygame_sdl2/surface.pyx":237
4113 * err = pygame_Blit(source.surface, area_ptr, self.surface, &dest_rect, special_flags)
4114 * else:
4115 * err = SDL_UpperBlit(source.surface, area_ptr, self.surface, &dest_rect) # <<<<<<<<<<<<<<
4116 *
4117 * if err:
4118 */
4119 /*else*/ {
4120 __pyx_v_err = SDL_UpperBlit(__pyx_v_source->surface, __pyx_v_area_ptr, __pyx_v_self->surface, (&__pyx_v_dest_rect));
4121 }
4122 __pyx_L22:;
4123 }
4124
4125 /* "pygame_sdl2/surface.pyx":232
4126 * area_ptr = &area_rect
4127 *
4128 * with nogil: # <<<<<<<<<<<<<<
4129 *
4130 * if source.surface.format.Amask or special_flags:
4131 */
4132 /*finally:*/ {
4133 /*normal exit:*/{
4134 #ifdef WITH_THREAD
4135 __Pyx_FastGIL_Forget();
4136 Py_BLOCK_THREADS
4137 #endif
4138 goto __pyx_L21;
4139 }
4140 __pyx_L21:;
4141 }
4142 }
4143
4144 /* "pygame_sdl2/surface.pyx":239
4145 * err = SDL_UpperBlit(source.surface, area_ptr, self.surface, &dest_rect)
4146 *
4147 * if err: # <<<<<<<<<<<<<<
4148 * raise error()
4149 *
4150 */
4151 __pyx_t_5 = (__pyx_v_err != 0);
4152 if (unlikely(__pyx_t_5)) {
4153
4154 /* "pygame_sdl2/surface.pyx":240
4155 *
4156 * if err:
4157 * raise error() # <<<<<<<<<<<<<<
4158 *
4159 * dirty = Rect(dest[0], dest[1], source.surface.w, source.surface.h)
4160 */
4161 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 240, __pyx_L1_error)
4162 __Pyx_GOTREF(__pyx_t_4);
4163 __pyx_t_2 = NULL;
4164 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4165 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
4166 if (likely(__pyx_t_2)) {
4167 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4168 __Pyx_INCREF(__pyx_t_2);
4169 __Pyx_INCREF(function);
4170 __Pyx_DECREF_SET(__pyx_t_4, function);
4171 }
4172 }
4173 __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4174 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4175 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
4176 __Pyx_GOTREF(__pyx_t_3);
4177 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4178 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4179 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4180 __PYX_ERR(0, 240, __pyx_L1_error)
4181
4182 /* "pygame_sdl2/surface.pyx":239
4183 * err = SDL_UpperBlit(source.surface, area_ptr, self.surface, &dest_rect)
4184 *
4185 * if err: # <<<<<<<<<<<<<<
4186 * raise error()
4187 *
4188 */
4189 }
4190
4191 /* "pygame_sdl2/surface.pyx":242
4192 * raise error()
4193 *
4194 * dirty = Rect(dest[0], dest[1], source.surface.w, source.surface.h) # <<<<<<<<<<<<<<
4195 * return dirty.clip(self.get_rect())
4196 *
4197 */
4198 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Rect); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L1_error)
4199 __Pyx_GOTREF(__pyx_t_4);
4200 __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_dest, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
4201 __Pyx_GOTREF(__pyx_t_2);
4202 __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_dest, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L1_error)
4203 __Pyx_GOTREF(__pyx_t_8);
4204 __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_source->surface->w); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L1_error)
4205 __Pyx_GOTREF(__pyx_t_9);
4206 __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_source->surface->h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 242, __pyx_L1_error)
4207 __Pyx_GOTREF(__pyx_t_10);
4208 __pyx_t_11 = NULL;
4209 __pyx_t_6 = 0;
4210 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4211 __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
4212 if (likely(__pyx_t_11)) {
4213 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4214 __Pyx_INCREF(__pyx_t_11);
4215 __Pyx_INCREF(function);
4216 __Pyx_DECREF_SET(__pyx_t_4, function);
4217 __pyx_t_6 = 1;
4218 }
4219 }
4220 #if CYTHON_FAST_PYCALL
4221 if (PyFunction_Check(__pyx_t_4)) {
4222 PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_2, __pyx_t_8, __pyx_t_9, __pyx_t_10};
4223 __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error)
4224 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
4225 __Pyx_GOTREF(__pyx_t_3);
4226 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4227 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4228 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4229 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
4230 } else
4231 #endif
4232 #if CYTHON_FAST_PYCCALL
4233 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
4234 PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_2, __pyx_t_8, __pyx_t_9, __pyx_t_10};
4235 __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error)
4236 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
4237 __Pyx_GOTREF(__pyx_t_3);
4238 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4239 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4240 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4241 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
4242 } else
4243 #endif
4244 {
4245 __pyx_t_12 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L1_error)
4246 __Pyx_GOTREF(__pyx_t_12);
4247 if (__pyx_t_11) {
4248 __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
4249 }
4250 __Pyx_GIVEREF(__pyx_t_2);
4251 PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_6, __pyx_t_2);
4252 __Pyx_GIVEREF(__pyx_t_8);
4253 PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_6, __pyx_t_8);
4254 __Pyx_GIVEREF(__pyx_t_9);
4255 PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_6, __pyx_t_9);
4256 __Pyx_GIVEREF(__pyx_t_10);
4257 PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_6, __pyx_t_10);
4258 __pyx_t_2 = 0;
4259 __pyx_t_8 = 0;
4260 __pyx_t_9 = 0;
4261 __pyx_t_10 = 0;
4262 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error)
4263 __Pyx_GOTREF(__pyx_t_3);
4264 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
4265 }
4266 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4267 __pyx_v_dirty = __pyx_t_3;
4268 __pyx_t_3 = 0;
4269
4270 /* "pygame_sdl2/surface.pyx":243
4271 *
4272 * dirty = Rect(dest[0], dest[1], source.surface.w, source.surface.h)
4273 * return dirty.clip(self.get_rect()) # <<<<<<<<<<<<<<
4274 *
4275 * def convert(self, surface=None):
4276 */
4277 __Pyx_XDECREF(__pyx_r);
4278 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dirty, __pyx_n_s_clip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error)
4279 __Pyx_GOTREF(__pyx_t_4);
4280 __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_rect); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 243, __pyx_L1_error)
4281 __Pyx_GOTREF(__pyx_t_10);
4282 __pyx_t_9 = NULL;
4283 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
4284 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
4285 if (likely(__pyx_t_9)) {
4286 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
4287 __Pyx_INCREF(__pyx_t_9);
4288 __Pyx_INCREF(function);
4289 __Pyx_DECREF_SET(__pyx_t_10, function);
4290 }
4291 }
4292 __pyx_t_12 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
4293 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
4294 if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 243, __pyx_L1_error)
4295 __Pyx_GOTREF(__pyx_t_12);
4296 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
4297 __pyx_t_10 = NULL;
4298 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
4299 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
4300 if (likely(__pyx_t_10)) {
4301 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4302 __Pyx_INCREF(__pyx_t_10);
4303 __Pyx_INCREF(function);
4304 __Pyx_DECREF_SET(__pyx_t_4, function);
4305 }
4306 }
4307 __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_12);
4308 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
4309 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
4310 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error)
4311 __Pyx_GOTREF(__pyx_t_3);
4312 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4313 __pyx_r = __pyx_t_3;
4314 __pyx_t_3 = 0;
4315 goto __pyx_L0;
4316
4317 /* "pygame_sdl2/surface.pyx":182
4318 * return "<Surface({}x{}x{})>".format(self.surface.w, self.surface.h, self.surface.format.BitsPerPixel)
4319 *
4320 * def blit(self, Surface source, dest, area=None, int special_flags=0): # <<<<<<<<<<<<<<
4321 * cdef SDL_Rect dest_rect
4322 * cdef SDL_Rect area_rect
4323 */
4324
4325 /* function exit code */
4326 __pyx_L1_error:;
4327 __Pyx_XDECREF(__pyx_t_2);
4328 __Pyx_XDECREF(__pyx_t_3);
4329 __Pyx_XDECREF(__pyx_t_4);
4330 __Pyx_XDECREF(__pyx_t_8);
4331 __Pyx_XDECREF(__pyx_t_9);
4332 __Pyx_XDECREF(__pyx_t_10);
4333 __Pyx_XDECREF(__pyx_t_11);
4334 __Pyx_XDECREF(__pyx_t_12);
4335 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.blit", __pyx_clineno, __pyx_lineno, __pyx_filename);
4336 __pyx_r = NULL;
4337 __pyx_L0:;
4338 __Pyx_XDECREF((PyObject *)__pyx_v_temp);
4339 __Pyx_XDECREF(__pyx_v_dirty);
4340 __Pyx_XDECREF((PyObject *)__pyx_v_source);
4341 __Pyx_XDECREF(__pyx_v_area);
4342 __Pyx_XGIVEREF(__pyx_r);
4343 __Pyx_RefNannyFinishContext();
4344 return __pyx_r;
4345 }
4346
4347 /* "pygame_sdl2/surface.pyx":245
4348 * return dirty.clip(self.get_rect())
4349 *
4350 * def convert(self, surface=None): # <<<<<<<<<<<<<<
4351 * if not isinstance(surface, Surface):
4352 * surface = pygame_sdl2.display.get_surface()
4353 */
4354
4355 /* Python wrapper */
4356 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_13convert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_13convert(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4357 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_13convert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4358 PyObject *__pyx_v_surface = 0;
4359 int __pyx_lineno = 0;
4360 const char *__pyx_filename = NULL;
4361 int __pyx_clineno = 0;
4362 PyObject *__pyx_r = 0;
4363 __Pyx_RefNannyDeclarations
4364 __Pyx_RefNannySetupContext("convert (wrapper)", 0);
4365 {
4366 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,0};
4367 PyObject* values[1] = {0};
4368 values[0] = ((PyObject *)Py_None);
4369 if (unlikely(__pyx_kwds)) {
4370 Py_ssize_t kw_args;
4371 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4372 switch (pos_args) {
4373 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4374 CYTHON_FALLTHROUGH;
4375 case 0: break;
4376 default: goto __pyx_L5_argtuple_error;
4377 }
4378 kw_args = PyDict_Size(__pyx_kwds);
4379 switch (pos_args) {
4380 case 0:
4381 if (kw_args > 0) {
4382 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_surface);
4383 if (value) { values[0] = value; kw_args--; }
4384 }
4385 }
4386 if (unlikely(kw_args > 0)) {
4387 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "convert") < 0)) __PYX_ERR(0, 245, __pyx_L3_error)
4388 }
4389 } else {
4390 switch (PyTuple_GET_SIZE(__pyx_args)) {
4391 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4392 CYTHON_FALLTHROUGH;
4393 case 0: break;
4394 default: goto __pyx_L5_argtuple_error;
4395 }
4396 }
4397 __pyx_v_surface = values[0];
4398 }
4399 goto __pyx_L4_argument_unpacking_done;
4400 __pyx_L5_argtuple_error:;
4401 __Pyx_RaiseArgtupleInvalid("convert", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 245, __pyx_L3_error)
4402 __pyx_L3_error:;
4403 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.convert", __pyx_clineno, __pyx_lineno, __pyx_filename);
4404 __Pyx_RefNannyFinishContext();
4405 return NULL;
4406 __pyx_L4_argument_unpacking_done:;
4407 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_12convert(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_surface);
4408
4409 /* function exit code */
4410 __Pyx_RefNannyFinishContext();
4411 return __pyx_r;
4412 }
4413
__pyx_pf_11pygame_sdl2_7surface_7Surface_12convert(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_surface)4414 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_12convert(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_surface) {
4415 SDL_PixelFormat *__pyx_v_sample_format;
4416 Uint32 __pyx_v_amask;
4417 Uint32 __pyx_v_rmask;
4418 Uint32 __pyx_v_gmask;
4419 Uint32 __pyx_v_bmask;
4420 Uint32 __pyx_v_pixel_format;
4421 SDL_Surface *__pyx_v_new_surface;
4422 CYTHON_UNUSED SDL_PixelFormat *__pyx_v_use_format;
4423 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_rv = 0;
4424 PyObject *__pyx_r = NULL;
4425 __Pyx_RefNannyDeclarations
4426 int __pyx_t_1;
4427 int __pyx_t_2;
4428 PyObject *__pyx_t_3 = NULL;
4429 PyObject *__pyx_t_4 = NULL;
4430 PyObject *__pyx_t_5 = NULL;
4431 SDL_PixelFormat *__pyx_t_6;
4432 Uint32 __pyx_t_7;
4433 int __pyx_lineno = 0;
4434 const char *__pyx_filename = NULL;
4435 int __pyx_clineno = 0;
4436 __Pyx_RefNannySetupContext("convert", 0);
4437 __Pyx_INCREF(__pyx_v_surface);
4438
4439 /* "pygame_sdl2/surface.pyx":246
4440 *
4441 * def convert(self, surface=None):
4442 * if not isinstance(surface, Surface): # <<<<<<<<<<<<<<
4443 * surface = pygame_sdl2.display.get_surface()
4444 *
4445 */
4446 __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_surface, __pyx_ptype_11pygame_sdl2_7surface_Surface);
4447 __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
4448 if (__pyx_t_2) {
4449
4450 /* "pygame_sdl2/surface.pyx":247
4451 * def convert(self, surface=None):
4452 * if not isinstance(surface, Surface):
4453 * surface = pygame_sdl2.display.get_surface() # <<<<<<<<<<<<<<
4454 *
4455 * cdef SDL_PixelFormat *sample_format
4456 */
4457 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pygame_sdl2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
4458 __Pyx_GOTREF(__pyx_t_4);
4459 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_display); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error)
4460 __Pyx_GOTREF(__pyx_t_5);
4461 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4462 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_surface); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
4463 __Pyx_GOTREF(__pyx_t_4);
4464 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4465 __pyx_t_5 = NULL;
4466 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
4467 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4468 if (likely(__pyx_t_5)) {
4469 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4470 __Pyx_INCREF(__pyx_t_5);
4471 __Pyx_INCREF(function);
4472 __Pyx_DECREF_SET(__pyx_t_4, function);
4473 }
4474 }
4475 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4476 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4477 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
4478 __Pyx_GOTREF(__pyx_t_3);
4479 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4480 __Pyx_DECREF_SET(__pyx_v_surface, __pyx_t_3);
4481 __pyx_t_3 = 0;
4482
4483 /* "pygame_sdl2/surface.pyx":246
4484 *
4485 * def convert(self, surface=None):
4486 * if not isinstance(surface, Surface): # <<<<<<<<<<<<<<
4487 * surface = pygame_sdl2.display.get_surface()
4488 *
4489 */
4490 }
4491
4492 /* "pygame_sdl2/surface.pyx":251
4493 * cdef SDL_PixelFormat *sample_format
4494 *
4495 * if surface is None: # <<<<<<<<<<<<<<
4496 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRX8888)
4497 * else:
4498 */
4499 __pyx_t_2 = (__pyx_v_surface == Py_None);
4500 __pyx_t_1 = (__pyx_t_2 != 0);
4501 if (__pyx_t_1) {
4502
4503 /* "pygame_sdl2/surface.pyx":252
4504 *
4505 * if surface is None:
4506 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRX8888) # <<<<<<<<<<<<<<
4507 * else:
4508 * sample_format = (<Surface> surface).surface.format
4509 */
4510 __pyx_v_sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRX8888);
4511
4512 /* "pygame_sdl2/surface.pyx":251
4513 * cdef SDL_PixelFormat *sample_format
4514 *
4515 * if surface is None: # <<<<<<<<<<<<<<
4516 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRX8888)
4517 * else:
4518 */
4519 goto __pyx_L4;
4520 }
4521
4522 /* "pygame_sdl2/surface.pyx":254
4523 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRX8888)
4524 * else:
4525 * sample_format = (<Surface> surface).surface.format # <<<<<<<<<<<<<<
4526 *
4527 * cdef Uint32 amask
4528 */
4529 /*else*/ {
4530 __pyx_t_6 = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_surface)->surface->format;
4531 __pyx_v_sample_format = __pyx_t_6;
4532 }
4533 __pyx_L4:;
4534
4535 /* "pygame_sdl2/surface.pyx":265
4536 *
4537 * # If the sample surface has alpha, use it.
4538 * if not sample_format.Amask: # <<<<<<<<<<<<<<
4539 * use_format = sample_format
4540 *
4541 */
4542 __pyx_t_1 = ((!(__pyx_v_sample_format->Amask != 0)) != 0);
4543 if (__pyx_t_1) {
4544
4545 /* "pygame_sdl2/surface.pyx":266
4546 * # If the sample surface has alpha, use it.
4547 * if not sample_format.Amask:
4548 * use_format = sample_format # <<<<<<<<<<<<<<
4549 *
4550 * with nogil:
4551 */
4552 __pyx_v_use_format = __pyx_v_sample_format;
4553
4554 /* "pygame_sdl2/surface.pyx":268
4555 * use_format = sample_format
4556 *
4557 * with nogil: # <<<<<<<<<<<<<<
4558 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
4559 *
4560 */
4561 {
4562 #ifdef WITH_THREAD
4563 PyThreadState *_save;
4564 Py_UNBLOCK_THREADS
4565 __Pyx_FastGIL_Remember();
4566 #endif
4567 /*try:*/ {
4568
4569 /* "pygame_sdl2/surface.pyx":269
4570 *
4571 * with nogil:
4572 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0) # <<<<<<<<<<<<<<
4573 *
4574 * if not new_surface:
4575 */
4576 __pyx_v_new_surface = SDL_ConvertSurface(__pyx_v_self->surface, __pyx_v_sample_format, 0);
4577 }
4578
4579 /* "pygame_sdl2/surface.pyx":268
4580 * use_format = sample_format
4581 *
4582 * with nogil: # <<<<<<<<<<<<<<
4583 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
4584 *
4585 */
4586 /*finally:*/ {
4587 /*normal exit:*/{
4588 #ifdef WITH_THREAD
4589 __Pyx_FastGIL_Forget();
4590 Py_BLOCK_THREADS
4591 #endif
4592 goto __pyx_L8;
4593 }
4594 __pyx_L8:;
4595 }
4596 }
4597
4598 /* "pygame_sdl2/surface.pyx":271
4599 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
4600 *
4601 * if not new_surface: # <<<<<<<<<<<<<<
4602 * raise error()
4603 *
4604 */
4605 __pyx_t_1 = ((!(__pyx_v_new_surface != 0)) != 0);
4606 if (unlikely(__pyx_t_1)) {
4607
4608 /* "pygame_sdl2/surface.pyx":272
4609 *
4610 * if not new_surface:
4611 * raise error() # <<<<<<<<<<<<<<
4612 *
4613 * else:
4614 */
4615 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 272, __pyx_L1_error)
4616 __Pyx_GOTREF(__pyx_t_4);
4617 __pyx_t_5 = NULL;
4618 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4619 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4620 if (likely(__pyx_t_5)) {
4621 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4622 __Pyx_INCREF(__pyx_t_5);
4623 __Pyx_INCREF(function);
4624 __Pyx_DECREF_SET(__pyx_t_4, function);
4625 }
4626 }
4627 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4628 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4629 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
4630 __Pyx_GOTREF(__pyx_t_3);
4631 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4632 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4633 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4634 __PYX_ERR(0, 272, __pyx_L1_error)
4635
4636 /* "pygame_sdl2/surface.pyx":271
4637 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
4638 *
4639 * if not new_surface: # <<<<<<<<<<<<<<
4640 * raise error()
4641 *
4642 */
4643 }
4644
4645 /* "pygame_sdl2/surface.pyx":265
4646 *
4647 * # If the sample surface has alpha, use it.
4648 * if not sample_format.Amask: # <<<<<<<<<<<<<<
4649 * use_format = sample_format
4650 *
4651 */
4652 goto __pyx_L5;
4653 }
4654
4655 /* "pygame_sdl2/surface.pyx":276
4656 * else:
4657 *
4658 * rmask = sample_format.Rmask # <<<<<<<<<<<<<<
4659 * gmask = sample_format.Gmask
4660 * bmask = sample_format.Bmask
4661 */
4662 /*else*/ {
4663 __pyx_t_7 = __pyx_v_sample_format->Rmask;
4664 __pyx_v_rmask = __pyx_t_7;
4665
4666 /* "pygame_sdl2/surface.pyx":277
4667 *
4668 * rmask = sample_format.Rmask
4669 * gmask = sample_format.Gmask # <<<<<<<<<<<<<<
4670 * bmask = sample_format.Bmask
4671 * amask = 0
4672 */
4673 __pyx_t_7 = __pyx_v_sample_format->Gmask;
4674 __pyx_v_gmask = __pyx_t_7;
4675
4676 /* "pygame_sdl2/surface.pyx":278
4677 * rmask = sample_format.Rmask
4678 * gmask = sample_format.Gmask
4679 * bmask = sample_format.Bmask # <<<<<<<<<<<<<<
4680 * amask = 0
4681 *
4682 */
4683 __pyx_t_7 = __pyx_v_sample_format->Bmask;
4684 __pyx_v_bmask = __pyx_t_7;
4685
4686 /* "pygame_sdl2/surface.pyx":279
4687 * gmask = sample_format.Gmask
4688 * bmask = sample_format.Bmask
4689 * amask = 0 # <<<<<<<<<<<<<<
4690 *
4691 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
4692 */
4693 __pyx_v_amask = 0;
4694
4695 /* "pygame_sdl2/surface.pyx":281
4696 * amask = 0
4697 *
4698 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask) # <<<<<<<<<<<<<<
4699 *
4700 * with nogil:
4701 */
4702 __pyx_v_pixel_format = SDL_MasksToPixelFormatEnum(32, __pyx_v_rmask, __pyx_v_gmask, __pyx_v_bmask, __pyx_v_amask);
4703
4704 /* "pygame_sdl2/surface.pyx":283
4705 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
4706 *
4707 * with nogil: # <<<<<<<<<<<<<<
4708 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
4709 *
4710 */
4711 {
4712 #ifdef WITH_THREAD
4713 PyThreadState *_save;
4714 Py_UNBLOCK_THREADS
4715 __Pyx_FastGIL_Remember();
4716 #endif
4717 /*try:*/ {
4718
4719 /* "pygame_sdl2/surface.pyx":284
4720 *
4721 * with nogil:
4722 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0) # <<<<<<<<<<<<<<
4723 *
4724 * if not new_surface:
4725 */
4726 __pyx_v_new_surface = SDL_ConvertSurfaceFormat(__pyx_v_self->surface, __pyx_v_pixel_format, 0);
4727 }
4728
4729 /* "pygame_sdl2/surface.pyx":283
4730 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
4731 *
4732 * with nogil: # <<<<<<<<<<<<<<
4733 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
4734 *
4735 */
4736 /*finally:*/ {
4737 /*normal exit:*/{
4738 #ifdef WITH_THREAD
4739 __Pyx_FastGIL_Forget();
4740 Py_BLOCK_THREADS
4741 #endif
4742 goto __pyx_L12;
4743 }
4744 __pyx_L12:;
4745 }
4746 }
4747
4748 /* "pygame_sdl2/surface.pyx":286
4749 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
4750 *
4751 * if not new_surface: # <<<<<<<<<<<<<<
4752 * raise error()
4753 *
4754 */
4755 __pyx_t_1 = ((!(__pyx_v_new_surface != 0)) != 0);
4756 if (unlikely(__pyx_t_1)) {
4757
4758 /* "pygame_sdl2/surface.pyx":287
4759 *
4760 * if not new_surface:
4761 * raise error() # <<<<<<<<<<<<<<
4762 *
4763 * cdef Surface rv = Surface(())
4764 */
4765 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
4766 __Pyx_GOTREF(__pyx_t_4);
4767 __pyx_t_5 = NULL;
4768 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4769 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4770 if (likely(__pyx_t_5)) {
4771 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4772 __Pyx_INCREF(__pyx_t_5);
4773 __Pyx_INCREF(function);
4774 __Pyx_DECREF_SET(__pyx_t_4, function);
4775 }
4776 }
4777 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4778 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4779 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error)
4780 __Pyx_GOTREF(__pyx_t_3);
4781 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4782 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4783 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4784 __PYX_ERR(0, 287, __pyx_L1_error)
4785
4786 /* "pygame_sdl2/surface.pyx":286
4787 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
4788 *
4789 * if not new_surface: # <<<<<<<<<<<<<<
4790 * raise error()
4791 *
4792 */
4793 }
4794 }
4795 __pyx_L5:;
4796
4797 /* "pygame_sdl2/surface.pyx":289
4798 * raise error()
4799 *
4800 * cdef Surface rv = Surface(()) # <<<<<<<<<<<<<<
4801 * rv.take_surface(new_surface)
4802 *
4803 */
4804 __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pygame_sdl2_7surface_Surface), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
4805 __Pyx_GOTREF(__pyx_t_3);
4806 __pyx_v_rv = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_3);
4807 __pyx_t_3 = 0;
4808
4809 /* "pygame_sdl2/surface.pyx":290
4810 *
4811 * cdef Surface rv = Surface(())
4812 * rv.take_surface(new_surface) # <<<<<<<<<<<<<<
4813 *
4814 * return rv
4815 */
4816 ((struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *)__pyx_v_rv->__pyx_vtab)->take_surface(__pyx_v_rv, __pyx_v_new_surface);
4817
4818 /* "pygame_sdl2/surface.pyx":292
4819 * rv.take_surface(new_surface)
4820 *
4821 * return rv # <<<<<<<<<<<<<<
4822 *
4823 * def convert_alpha(self, Surface surface=None):
4824 */
4825 __Pyx_XDECREF(__pyx_r);
4826 __Pyx_INCREF(((PyObject *)__pyx_v_rv));
4827 __pyx_r = ((PyObject *)__pyx_v_rv);
4828 goto __pyx_L0;
4829
4830 /* "pygame_sdl2/surface.pyx":245
4831 * return dirty.clip(self.get_rect())
4832 *
4833 * def convert(self, surface=None): # <<<<<<<<<<<<<<
4834 * if not isinstance(surface, Surface):
4835 * surface = pygame_sdl2.display.get_surface()
4836 */
4837
4838 /* function exit code */
4839 __pyx_L1_error:;
4840 __Pyx_XDECREF(__pyx_t_3);
4841 __Pyx_XDECREF(__pyx_t_4);
4842 __Pyx_XDECREF(__pyx_t_5);
4843 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.convert", __pyx_clineno, __pyx_lineno, __pyx_filename);
4844 __pyx_r = NULL;
4845 __pyx_L0:;
4846 __Pyx_XDECREF((PyObject *)__pyx_v_rv);
4847 __Pyx_XDECREF(__pyx_v_surface);
4848 __Pyx_XGIVEREF(__pyx_r);
4849 __Pyx_RefNannyFinishContext();
4850 return __pyx_r;
4851 }
4852
4853 /* "pygame_sdl2/surface.pyx":294
4854 * return rv
4855 *
4856 * def convert_alpha(self, Surface surface=None): # <<<<<<<<<<<<<<
4857 * if surface is None:
4858 * surface = pygame_sdl2.display.get_surface()
4859 */
4860
4861 /* Python wrapper */
4862 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_15convert_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_15convert_alpha(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4863 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_15convert_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4864 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_surface = 0;
4865 int __pyx_lineno = 0;
4866 const char *__pyx_filename = NULL;
4867 int __pyx_clineno = 0;
4868 PyObject *__pyx_r = 0;
4869 __Pyx_RefNannyDeclarations
4870 __Pyx_RefNannySetupContext("convert_alpha (wrapper)", 0);
4871 {
4872 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,0};
4873 PyObject* values[1] = {0};
4874 values[0] = (PyObject *)((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None);
4875 if (unlikely(__pyx_kwds)) {
4876 Py_ssize_t kw_args;
4877 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4878 switch (pos_args) {
4879 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4880 CYTHON_FALLTHROUGH;
4881 case 0: break;
4882 default: goto __pyx_L5_argtuple_error;
4883 }
4884 kw_args = PyDict_Size(__pyx_kwds);
4885 switch (pos_args) {
4886 case 0:
4887 if (kw_args > 0) {
4888 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_surface);
4889 if (value) { values[0] = value; kw_args--; }
4890 }
4891 }
4892 if (unlikely(kw_args > 0)) {
4893 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "convert_alpha") < 0)) __PYX_ERR(0, 294, __pyx_L3_error)
4894 }
4895 } else {
4896 switch (PyTuple_GET_SIZE(__pyx_args)) {
4897 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4898 CYTHON_FALLTHROUGH;
4899 case 0: break;
4900 default: goto __pyx_L5_argtuple_error;
4901 }
4902 }
4903 __pyx_v_surface = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)values[0]);
4904 }
4905 goto __pyx_L4_argument_unpacking_done;
4906 __pyx_L5_argtuple_error:;
4907 __Pyx_RaiseArgtupleInvalid("convert_alpha", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 294, __pyx_L3_error)
4908 __pyx_L3_error:;
4909 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.convert_alpha", __pyx_clineno, __pyx_lineno, __pyx_filename);
4910 __Pyx_RefNannyFinishContext();
4911 return NULL;
4912 __pyx_L4_argument_unpacking_done:;
4913 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_surface), __pyx_ptype_11pygame_sdl2_7surface_Surface, 1, "surface", 0))) __PYX_ERR(0, 294, __pyx_L1_error)
4914 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_14convert_alpha(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_surface);
4915
4916 /* function exit code */
4917 goto __pyx_L0;
4918 __pyx_L1_error:;
4919 __pyx_r = NULL;
4920 __pyx_L0:;
4921 __Pyx_RefNannyFinishContext();
4922 return __pyx_r;
4923 }
4924
__pyx_pf_11pygame_sdl2_7surface_7Surface_14convert_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_surface)4925 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_14convert_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_surface) {
4926 SDL_PixelFormat *__pyx_v_sample_format;
4927 Uint32 __pyx_v_amask;
4928 Uint32 __pyx_v_rmask;
4929 Uint32 __pyx_v_gmask;
4930 Uint32 __pyx_v_bmask;
4931 Uint32 __pyx_v_pixel_format;
4932 SDL_Surface *__pyx_v_new_surface;
4933 CYTHON_UNUSED SDL_PixelFormat *__pyx_v_use_format;
4934 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_rv = 0;
4935 PyObject *__pyx_r = NULL;
4936 __Pyx_RefNannyDeclarations
4937 int __pyx_t_1;
4938 int __pyx_t_2;
4939 PyObject *__pyx_t_3 = NULL;
4940 PyObject *__pyx_t_4 = NULL;
4941 PyObject *__pyx_t_5 = NULL;
4942 SDL_PixelFormat *__pyx_t_6;
4943 Uint32 __pyx_t_7;
4944 int __pyx_lineno = 0;
4945 const char *__pyx_filename = NULL;
4946 int __pyx_clineno = 0;
4947 __Pyx_RefNannySetupContext("convert_alpha", 0);
4948 __Pyx_INCREF((PyObject *)__pyx_v_surface);
4949
4950 /* "pygame_sdl2/surface.pyx":295
4951 *
4952 * def convert_alpha(self, Surface surface=None):
4953 * if surface is None: # <<<<<<<<<<<<<<
4954 * surface = pygame_sdl2.display.get_surface()
4955 *
4956 */
4957 __pyx_t_1 = (((PyObject *)__pyx_v_surface) == Py_None);
4958 __pyx_t_2 = (__pyx_t_1 != 0);
4959 if (__pyx_t_2) {
4960
4961 /* "pygame_sdl2/surface.pyx":296
4962 * def convert_alpha(self, Surface surface=None):
4963 * if surface is None:
4964 * surface = pygame_sdl2.display.get_surface() # <<<<<<<<<<<<<<
4965 *
4966 * cdef SDL_PixelFormat *sample_format
4967 */
4968 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pygame_sdl2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
4969 __Pyx_GOTREF(__pyx_t_4);
4970 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_display); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error)
4971 __Pyx_GOTREF(__pyx_t_5);
4972 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4973 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_surface); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
4974 __Pyx_GOTREF(__pyx_t_4);
4975 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4976 __pyx_t_5 = NULL;
4977 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
4978 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4979 if (likely(__pyx_t_5)) {
4980 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4981 __Pyx_INCREF(__pyx_t_5);
4982 __Pyx_INCREF(function);
4983 __Pyx_DECREF_SET(__pyx_t_4, function);
4984 }
4985 }
4986 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4987 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4988 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
4989 __Pyx_GOTREF(__pyx_t_3);
4990 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4991 if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_11pygame_sdl2_7surface_Surface))))) __PYX_ERR(0, 296, __pyx_L1_error)
4992 __Pyx_DECREF_SET(__pyx_v_surface, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_3));
4993 __pyx_t_3 = 0;
4994
4995 /* "pygame_sdl2/surface.pyx":295
4996 *
4997 * def convert_alpha(self, Surface surface=None):
4998 * if surface is None: # <<<<<<<<<<<<<<
4999 * surface = pygame_sdl2.display.get_surface()
5000 *
5001 */
5002 }
5003
5004 /* "pygame_sdl2/surface.pyx":300
5005 * cdef SDL_PixelFormat *sample_format
5006 *
5007 * if surface is None: # <<<<<<<<<<<<<<
5008 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRA8888)
5009 * else:
5010 */
5011 __pyx_t_2 = (((PyObject *)__pyx_v_surface) == Py_None);
5012 __pyx_t_1 = (__pyx_t_2 != 0);
5013 if (__pyx_t_1) {
5014
5015 /* "pygame_sdl2/surface.pyx":301
5016 *
5017 * if surface is None:
5018 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRA8888) # <<<<<<<<<<<<<<
5019 * else:
5020 * sample_format = (<Surface> surface).surface.format
5021 */
5022 __pyx_v_sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRA8888);
5023
5024 /* "pygame_sdl2/surface.pyx":300
5025 * cdef SDL_PixelFormat *sample_format
5026 *
5027 * if surface is None: # <<<<<<<<<<<<<<
5028 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRA8888)
5029 * else:
5030 */
5031 goto __pyx_L4;
5032 }
5033
5034 /* "pygame_sdl2/surface.pyx":303
5035 * sample_format = SDL_AllocFormat(SDL_PIXELFORMAT_BGRA8888)
5036 * else:
5037 * sample_format = (<Surface> surface).surface.format # <<<<<<<<<<<<<<
5038 *
5039 * cdef Uint32 amask = 0xff000000
5040 */
5041 /*else*/ {
5042 __pyx_t_6 = __pyx_v_surface->surface->format;
5043 __pyx_v_sample_format = __pyx_t_6;
5044 }
5045 __pyx_L4:;
5046
5047 /* "pygame_sdl2/surface.pyx":305
5048 * sample_format = (<Surface> surface).surface.format
5049 *
5050 * cdef Uint32 amask = 0xff000000 # <<<<<<<<<<<<<<
5051 * cdef Uint32 rmask = 0x00ff0000
5052 * cdef Uint32 gmask = 0x0000ff00
5053 */
5054 __pyx_v_amask = 0xff000000;
5055
5056 /* "pygame_sdl2/surface.pyx":306
5057 *
5058 * cdef Uint32 amask = 0xff000000
5059 * cdef Uint32 rmask = 0x00ff0000 # <<<<<<<<<<<<<<
5060 * cdef Uint32 gmask = 0x0000ff00
5061 * cdef Uint32 bmask = 0x000000ff
5062 */
5063 __pyx_v_rmask = 0x00ff0000;
5064
5065 /* "pygame_sdl2/surface.pyx":307
5066 * cdef Uint32 amask = 0xff000000
5067 * cdef Uint32 rmask = 0x00ff0000
5068 * cdef Uint32 gmask = 0x0000ff00 # <<<<<<<<<<<<<<
5069 * cdef Uint32 bmask = 0x000000ff
5070 *
5071 */
5072 __pyx_v_gmask = 0x0000ff00;
5073
5074 /* "pygame_sdl2/surface.pyx":308
5075 * cdef Uint32 rmask = 0x00ff0000
5076 * cdef Uint32 gmask = 0x0000ff00
5077 * cdef Uint32 bmask = 0x000000ff # <<<<<<<<<<<<<<
5078 *
5079 * cdef Uint32 pixel_format
5080 */
5081 __pyx_v_bmask = 0x000000ff;
5082
5083 /* "pygame_sdl2/surface.pyx":314
5084 *
5085 * # If the sample surface has alpha, use it.
5086 * if sample_format.Amask: # <<<<<<<<<<<<<<
5087 * use_format = sample_format
5088 *
5089 */
5090 __pyx_t_1 = (__pyx_v_sample_format->Amask != 0);
5091 if (__pyx_t_1) {
5092
5093 /* "pygame_sdl2/surface.pyx":315
5094 * # If the sample surface has alpha, use it.
5095 * if sample_format.Amask:
5096 * use_format = sample_format # <<<<<<<<<<<<<<
5097 *
5098 * with nogil:
5099 */
5100 __pyx_v_use_format = __pyx_v_sample_format;
5101
5102 /* "pygame_sdl2/surface.pyx":317
5103 * use_format = sample_format
5104 *
5105 * with nogil: # <<<<<<<<<<<<<<
5106 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
5107 *
5108 */
5109 {
5110 #ifdef WITH_THREAD
5111 PyThreadState *_save;
5112 Py_UNBLOCK_THREADS
5113 __Pyx_FastGIL_Remember();
5114 #endif
5115 /*try:*/ {
5116
5117 /* "pygame_sdl2/surface.pyx":318
5118 *
5119 * with nogil:
5120 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0) # <<<<<<<<<<<<<<
5121 *
5122 * if not new_surface:
5123 */
5124 __pyx_v_new_surface = SDL_ConvertSurface(__pyx_v_self->surface, __pyx_v_sample_format, 0);
5125 }
5126
5127 /* "pygame_sdl2/surface.pyx":317
5128 * use_format = sample_format
5129 *
5130 * with nogil: # <<<<<<<<<<<<<<
5131 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
5132 *
5133 */
5134 /*finally:*/ {
5135 /*normal exit:*/{
5136 #ifdef WITH_THREAD
5137 __Pyx_FastGIL_Forget();
5138 Py_BLOCK_THREADS
5139 #endif
5140 goto __pyx_L8;
5141 }
5142 __pyx_L8:;
5143 }
5144 }
5145
5146 /* "pygame_sdl2/surface.pyx":320
5147 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
5148 *
5149 * if not new_surface: # <<<<<<<<<<<<<<
5150 * raise error()
5151 *
5152 */
5153 __pyx_t_1 = ((!(__pyx_v_new_surface != 0)) != 0);
5154 if (unlikely(__pyx_t_1)) {
5155
5156 /* "pygame_sdl2/surface.pyx":321
5157 *
5158 * if not new_surface:
5159 * raise error() # <<<<<<<<<<<<<<
5160 *
5161 * else:
5162 */
5163 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 321, __pyx_L1_error)
5164 __Pyx_GOTREF(__pyx_t_4);
5165 __pyx_t_5 = NULL;
5166 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
5167 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
5168 if (likely(__pyx_t_5)) {
5169 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5170 __Pyx_INCREF(__pyx_t_5);
5171 __Pyx_INCREF(function);
5172 __Pyx_DECREF_SET(__pyx_t_4, function);
5173 }
5174 }
5175 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
5176 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5177 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error)
5178 __Pyx_GOTREF(__pyx_t_3);
5179 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5180 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
5181 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5182 __PYX_ERR(0, 321, __pyx_L1_error)
5183
5184 /* "pygame_sdl2/surface.pyx":320
5185 * new_surface = SDL_ConvertSurface(self.surface, sample_format, 0)
5186 *
5187 * if not new_surface: # <<<<<<<<<<<<<<
5188 * raise error()
5189 *
5190 */
5191 }
5192
5193 /* "pygame_sdl2/surface.pyx":314
5194 *
5195 * # If the sample surface has alpha, use it.
5196 * if sample_format.Amask: # <<<<<<<<<<<<<<
5197 * use_format = sample_format
5198 *
5199 */
5200 goto __pyx_L5;
5201 }
5202
5203 /* "pygame_sdl2/surface.pyx":325
5204 * else:
5205 *
5206 * if sample_format.BytesPerPixel == 4: # <<<<<<<<<<<<<<
5207 * rmask = sample_format.Rmask
5208 * gmask = sample_format.Gmask
5209 */
5210 /*else*/ {
5211 __pyx_t_1 = ((__pyx_v_sample_format->BytesPerPixel == 4) != 0);
5212 if (__pyx_t_1) {
5213
5214 /* "pygame_sdl2/surface.pyx":326
5215 *
5216 * if sample_format.BytesPerPixel == 4:
5217 * rmask = sample_format.Rmask # <<<<<<<<<<<<<<
5218 * gmask = sample_format.Gmask
5219 * bmask = sample_format.Bmask
5220 */
5221 __pyx_t_7 = __pyx_v_sample_format->Rmask;
5222 __pyx_v_rmask = __pyx_t_7;
5223
5224 /* "pygame_sdl2/surface.pyx":327
5225 * if sample_format.BytesPerPixel == 4:
5226 * rmask = sample_format.Rmask
5227 * gmask = sample_format.Gmask # <<<<<<<<<<<<<<
5228 * bmask = sample_format.Bmask
5229 * amask = 0xffffffff & ~(rmask | gmask | bmask)
5230 */
5231 __pyx_t_7 = __pyx_v_sample_format->Gmask;
5232 __pyx_v_gmask = __pyx_t_7;
5233
5234 /* "pygame_sdl2/surface.pyx":328
5235 * rmask = sample_format.Rmask
5236 * gmask = sample_format.Gmask
5237 * bmask = sample_format.Bmask # <<<<<<<<<<<<<<
5238 * amask = 0xffffffff & ~(rmask | gmask | bmask)
5239 *
5240 */
5241 __pyx_t_7 = __pyx_v_sample_format->Bmask;
5242 __pyx_v_bmask = __pyx_t_7;
5243
5244 /* "pygame_sdl2/surface.pyx":329
5245 * gmask = sample_format.Gmask
5246 * bmask = sample_format.Bmask
5247 * amask = 0xffffffff & ~(rmask | gmask | bmask) # <<<<<<<<<<<<<<
5248 *
5249 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
5250 */
5251 __pyx_t_3 = __Pyx_PyInt_From_uint32_t((~((__pyx_v_rmask | __pyx_v_gmask) | __pyx_v_bmask))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 329, __pyx_L1_error)
5252 __Pyx_GOTREF(__pyx_t_3);
5253 __pyx_t_4 = PyNumber_And(__pyx_int_4294967295, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
5254 __Pyx_GOTREF(__pyx_t_4);
5255 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5256 __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 329, __pyx_L1_error)
5257 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5258 __pyx_v_amask = __pyx_t_7;
5259
5260 /* "pygame_sdl2/surface.pyx":325
5261 * else:
5262 *
5263 * if sample_format.BytesPerPixel == 4: # <<<<<<<<<<<<<<
5264 * rmask = sample_format.Rmask
5265 * gmask = sample_format.Gmask
5266 */
5267 }
5268
5269 /* "pygame_sdl2/surface.pyx":331
5270 * amask = 0xffffffff & ~(rmask | gmask | bmask)
5271 *
5272 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask) # <<<<<<<<<<<<<<
5273 *
5274 * with nogil:
5275 */
5276 __pyx_v_pixel_format = SDL_MasksToPixelFormatEnum(32, __pyx_v_rmask, __pyx_v_gmask, __pyx_v_bmask, __pyx_v_amask);
5277
5278 /* "pygame_sdl2/surface.pyx":333
5279 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
5280 *
5281 * with nogil: # <<<<<<<<<<<<<<
5282 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
5283 *
5284 */
5285 {
5286 #ifdef WITH_THREAD
5287 PyThreadState *_save;
5288 Py_UNBLOCK_THREADS
5289 __Pyx_FastGIL_Remember();
5290 #endif
5291 /*try:*/ {
5292
5293 /* "pygame_sdl2/surface.pyx":334
5294 *
5295 * with nogil:
5296 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0) # <<<<<<<<<<<<<<
5297 *
5298 * if not new_surface:
5299 */
5300 __pyx_v_new_surface = SDL_ConvertSurfaceFormat(__pyx_v_self->surface, __pyx_v_pixel_format, 0);
5301 }
5302
5303 /* "pygame_sdl2/surface.pyx":333
5304 * pixel_format = SDL_MasksToPixelFormatEnum(32, rmask, gmask, bmask, amask)
5305 *
5306 * with nogil: # <<<<<<<<<<<<<<
5307 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
5308 *
5309 */
5310 /*finally:*/ {
5311 /*normal exit:*/{
5312 #ifdef WITH_THREAD
5313 __Pyx_FastGIL_Forget();
5314 Py_BLOCK_THREADS
5315 #endif
5316 goto __pyx_L13;
5317 }
5318 __pyx_L13:;
5319 }
5320 }
5321
5322 /* "pygame_sdl2/surface.pyx":336
5323 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
5324 *
5325 * if not new_surface: # <<<<<<<<<<<<<<
5326 * raise error()
5327 *
5328 */
5329 __pyx_t_1 = ((!(__pyx_v_new_surface != 0)) != 0);
5330 if (unlikely(__pyx_t_1)) {
5331
5332 /* "pygame_sdl2/surface.pyx":337
5333 *
5334 * if not new_surface:
5335 * raise error() # <<<<<<<<<<<<<<
5336 *
5337 * cdef Surface rv = Surface(())
5338 */
5339 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error)
5340 __Pyx_GOTREF(__pyx_t_3);
5341 __pyx_t_5 = NULL;
5342 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5343 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
5344 if (likely(__pyx_t_5)) {
5345 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5346 __Pyx_INCREF(__pyx_t_5);
5347 __Pyx_INCREF(function);
5348 __Pyx_DECREF_SET(__pyx_t_3, function);
5349 }
5350 }
5351 __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
5352 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5353 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 337, __pyx_L1_error)
5354 __Pyx_GOTREF(__pyx_t_4);
5355 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5356 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
5357 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5358 __PYX_ERR(0, 337, __pyx_L1_error)
5359
5360 /* "pygame_sdl2/surface.pyx":336
5361 * new_surface = SDL_ConvertSurfaceFormat(self.surface, pixel_format, 0)
5362 *
5363 * if not new_surface: # <<<<<<<<<<<<<<
5364 * raise error()
5365 *
5366 */
5367 }
5368 }
5369 __pyx_L5:;
5370
5371 /* "pygame_sdl2/surface.pyx":339
5372 * raise error()
5373 *
5374 * cdef Surface rv = Surface(()) # <<<<<<<<<<<<<<
5375 * rv.take_surface(new_surface)
5376 *
5377 */
5378 __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pygame_sdl2_7surface_Surface), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error)
5379 __Pyx_GOTREF(__pyx_t_4);
5380 __pyx_v_rv = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_4);
5381 __pyx_t_4 = 0;
5382
5383 /* "pygame_sdl2/surface.pyx":340
5384 *
5385 * cdef Surface rv = Surface(())
5386 * rv.take_surface(new_surface) # <<<<<<<<<<<<<<
5387 *
5388 * return rv
5389 */
5390 ((struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *)__pyx_v_rv->__pyx_vtab)->take_surface(__pyx_v_rv, __pyx_v_new_surface);
5391
5392 /* "pygame_sdl2/surface.pyx":342
5393 * rv.take_surface(new_surface)
5394 *
5395 * return rv # <<<<<<<<<<<<<<
5396 *
5397 * def copy(self):
5398 */
5399 __Pyx_XDECREF(__pyx_r);
5400 __Pyx_INCREF(((PyObject *)__pyx_v_rv));
5401 __pyx_r = ((PyObject *)__pyx_v_rv);
5402 goto __pyx_L0;
5403
5404 /* "pygame_sdl2/surface.pyx":294
5405 * return rv
5406 *
5407 * def convert_alpha(self, Surface surface=None): # <<<<<<<<<<<<<<
5408 * if surface is None:
5409 * surface = pygame_sdl2.display.get_surface()
5410 */
5411
5412 /* function exit code */
5413 __pyx_L1_error:;
5414 __Pyx_XDECREF(__pyx_t_3);
5415 __Pyx_XDECREF(__pyx_t_4);
5416 __Pyx_XDECREF(__pyx_t_5);
5417 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.convert_alpha", __pyx_clineno, __pyx_lineno, __pyx_filename);
5418 __pyx_r = NULL;
5419 __pyx_L0:;
5420 __Pyx_XDECREF((PyObject *)__pyx_v_rv);
5421 __Pyx_XDECREF((PyObject *)__pyx_v_surface);
5422 __Pyx_XGIVEREF(__pyx_r);
5423 __Pyx_RefNannyFinishContext();
5424 return __pyx_r;
5425 }
5426
5427 /* "pygame_sdl2/surface.pyx":344
5428 * return rv
5429 *
5430 * def copy(self): # <<<<<<<<<<<<<<
5431 * if self.surface.format.Amask:
5432 * return self.convert_alpha(self)
5433 */
5434
5435 /* Python wrapper */
5436 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_17copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_17copy(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)5437 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_17copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5438 PyObject *__pyx_r = 0;
5439 __Pyx_RefNannyDeclarations
5440 __Pyx_RefNannySetupContext("copy (wrapper)", 0);
5441 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_16copy(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
5442
5443 /* function exit code */
5444 __Pyx_RefNannyFinishContext();
5445 return __pyx_r;
5446 }
5447
__pyx_pf_11pygame_sdl2_7surface_7Surface_16copy(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)5448 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_16copy(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
5449 PyObject *__pyx_r = NULL;
5450 __Pyx_RefNannyDeclarations
5451 int __pyx_t_1;
5452 PyObject *__pyx_t_2 = NULL;
5453 PyObject *__pyx_t_3 = NULL;
5454 PyObject *__pyx_t_4 = NULL;
5455 int __pyx_lineno = 0;
5456 const char *__pyx_filename = NULL;
5457 int __pyx_clineno = 0;
5458 __Pyx_RefNannySetupContext("copy", 0);
5459
5460 /* "pygame_sdl2/surface.pyx":345
5461 *
5462 * def copy(self):
5463 * if self.surface.format.Amask: # <<<<<<<<<<<<<<
5464 * return self.convert_alpha(self)
5465 * else:
5466 */
5467 __pyx_t_1 = (__pyx_v_self->surface->format->Amask != 0);
5468 if (__pyx_t_1) {
5469
5470 /* "pygame_sdl2/surface.pyx":346
5471 * def copy(self):
5472 * if self.surface.format.Amask:
5473 * return self.convert_alpha(self) # <<<<<<<<<<<<<<
5474 * else:
5475 * return self.convert(self)
5476 */
5477 __Pyx_XDECREF(__pyx_r);
5478 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_convert_alpha); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error)
5479 __Pyx_GOTREF(__pyx_t_3);
5480 __pyx_t_4 = NULL;
5481 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
5482 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5483 if (likely(__pyx_t_4)) {
5484 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5485 __Pyx_INCREF(__pyx_t_4);
5486 __Pyx_INCREF(function);
5487 __Pyx_DECREF_SET(__pyx_t_3, function);
5488 }
5489 }
5490 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_self)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self));
5491 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5492 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
5493 __Pyx_GOTREF(__pyx_t_2);
5494 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5495 __pyx_r = __pyx_t_2;
5496 __pyx_t_2 = 0;
5497 goto __pyx_L0;
5498
5499 /* "pygame_sdl2/surface.pyx":345
5500 *
5501 * def copy(self):
5502 * if self.surface.format.Amask: # <<<<<<<<<<<<<<
5503 * return self.convert_alpha(self)
5504 * else:
5505 */
5506 }
5507
5508 /* "pygame_sdl2/surface.pyx":348
5509 * return self.convert_alpha(self)
5510 * else:
5511 * return self.convert(self) # <<<<<<<<<<<<<<
5512 *
5513 * def fill(self, color, rect=None, special_flags=0):
5514 */
5515 /*else*/ {
5516 __Pyx_XDECREF(__pyx_r);
5517 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_convert); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 348, __pyx_L1_error)
5518 __Pyx_GOTREF(__pyx_t_3);
5519 __pyx_t_4 = NULL;
5520 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
5521 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5522 if (likely(__pyx_t_4)) {
5523 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5524 __Pyx_INCREF(__pyx_t_4);
5525 __Pyx_INCREF(function);
5526 __Pyx_DECREF_SET(__pyx_t_3, function);
5527 }
5528 }
5529 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_self)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self));
5530 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5531 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
5532 __Pyx_GOTREF(__pyx_t_2);
5533 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5534 __pyx_r = __pyx_t_2;
5535 __pyx_t_2 = 0;
5536 goto __pyx_L0;
5537 }
5538
5539 /* "pygame_sdl2/surface.pyx":344
5540 * return rv
5541 *
5542 * def copy(self): # <<<<<<<<<<<<<<
5543 * if self.surface.format.Amask:
5544 * return self.convert_alpha(self)
5545 */
5546
5547 /* function exit code */
5548 __pyx_L1_error:;
5549 __Pyx_XDECREF(__pyx_t_2);
5550 __Pyx_XDECREF(__pyx_t_3);
5551 __Pyx_XDECREF(__pyx_t_4);
5552 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
5553 __pyx_r = NULL;
5554 __pyx_L0:;
5555 __Pyx_XGIVEREF(__pyx_r);
5556 __Pyx_RefNannyFinishContext();
5557 return __pyx_r;
5558 }
5559
5560 /* "pygame_sdl2/surface.pyx":350
5561 * return self.convert(self)
5562 *
5563 * def fill(self, color, rect=None, special_flags=0): # <<<<<<<<<<<<<<
5564 *
5565 * cdef SDL_Rect sdl_rect
5566 */
5567
5568 /* Python wrapper */
5569 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_19fill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_19fill(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5570 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_19fill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5571 PyObject *__pyx_v_color = 0;
5572 PyObject *__pyx_v_rect = 0;
5573 CYTHON_UNUSED PyObject *__pyx_v_special_flags = 0;
5574 int __pyx_lineno = 0;
5575 const char *__pyx_filename = NULL;
5576 int __pyx_clineno = 0;
5577 PyObject *__pyx_r = 0;
5578 __Pyx_RefNannyDeclarations
5579 __Pyx_RefNannySetupContext("fill (wrapper)", 0);
5580 {
5581 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_color,&__pyx_n_s_rect,&__pyx_n_s_special_flags,0};
5582 PyObject* values[3] = {0,0,0};
5583 values[1] = ((PyObject *)Py_None);
5584 values[2] = ((PyObject *)__pyx_int_0);
5585 if (unlikely(__pyx_kwds)) {
5586 Py_ssize_t kw_args;
5587 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5588 switch (pos_args) {
5589 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5590 CYTHON_FALLTHROUGH;
5591 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5592 CYTHON_FALLTHROUGH;
5593 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5594 CYTHON_FALLTHROUGH;
5595 case 0: break;
5596 default: goto __pyx_L5_argtuple_error;
5597 }
5598 kw_args = PyDict_Size(__pyx_kwds);
5599 switch (pos_args) {
5600 case 0:
5601 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_color)) != 0)) kw_args--;
5602 else goto __pyx_L5_argtuple_error;
5603 CYTHON_FALLTHROUGH;
5604 case 1:
5605 if (kw_args > 0) {
5606 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rect);
5607 if (value) { values[1] = value; kw_args--; }
5608 }
5609 CYTHON_FALLTHROUGH;
5610 case 2:
5611 if (kw_args > 0) {
5612 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_special_flags);
5613 if (value) { values[2] = value; kw_args--; }
5614 }
5615 }
5616 if (unlikely(kw_args > 0)) {
5617 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fill") < 0)) __PYX_ERR(0, 350, __pyx_L3_error)
5618 }
5619 } else {
5620 switch (PyTuple_GET_SIZE(__pyx_args)) {
5621 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5622 CYTHON_FALLTHROUGH;
5623 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5624 CYTHON_FALLTHROUGH;
5625 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5626 break;
5627 default: goto __pyx_L5_argtuple_error;
5628 }
5629 }
5630 __pyx_v_color = values[0];
5631 __pyx_v_rect = values[1];
5632 __pyx_v_special_flags = values[2];
5633 }
5634 goto __pyx_L4_argument_unpacking_done;
5635 __pyx_L5_argtuple_error:;
5636 __Pyx_RaiseArgtupleInvalid("fill", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 350, __pyx_L3_error)
5637 __pyx_L3_error:;
5638 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.fill", __pyx_clineno, __pyx_lineno, __pyx_filename);
5639 __Pyx_RefNannyFinishContext();
5640 return NULL;
5641 __pyx_L4_argument_unpacking_done:;
5642 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_18fill(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_color, __pyx_v_rect, __pyx_v_special_flags);
5643
5644 /* function exit code */
5645 __Pyx_RefNannyFinishContext();
5646 return __pyx_r;
5647 }
5648
__pyx_pf_11pygame_sdl2_7surface_7Surface_18fill(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_color,PyObject * __pyx_v_rect,CYTHON_UNUSED PyObject * __pyx_v_special_flags)5649 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_18fill(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color, PyObject *__pyx_v_rect, CYTHON_UNUSED PyObject *__pyx_v_special_flags) {
5650 SDL_Rect __pyx_v_sdl_rect;
5651 Uint32 __pyx_v_pixel;
5652 int __pyx_v_err;
5653 PyObject *__pyx_r = NULL;
5654 __Pyx_RefNannyDeclarations
5655 Uint32 __pyx_t_1;
5656 int __pyx_t_2;
5657 int __pyx_t_3;
5658 int __pyx_t_4;
5659 PyObject *__pyx_t_5 = NULL;
5660 PyObject *__pyx_t_6 = NULL;
5661 PyObject *__pyx_t_7 = NULL;
5662 PyObject *__pyx_t_8 = NULL;
5663 PyObject *__pyx_t_9 = NULL;
5664 PyObject *__pyx_t_10 = NULL;
5665 PyObject *__pyx_t_11 = NULL;
5666 PyObject *__pyx_t_12 = NULL;
5667 int __pyx_lineno = 0;
5668 const char *__pyx_filename = NULL;
5669 int __pyx_clineno = 0;
5670 __Pyx_RefNannySetupContext("fill", 0);
5671
5672 /* "pygame_sdl2/surface.pyx":353
5673 *
5674 * cdef SDL_Rect sdl_rect
5675 * cdef Uint32 pixel = map_color(self.surface, color) # <<<<<<<<<<<<<<
5676 * cdef int err
5677 *
5678 */
5679 __pyx_t_1 = __pyx_f_11pygame_sdl2_5color_map_color(__pyx_v_self->surface, __pyx_v_color); if (unlikely(__pyx_t_1 == ((Uint32)0xaabbccdd) && PyErr_Occurred())) __PYX_ERR(0, 353, __pyx_L1_error)
5680 __pyx_v_pixel = __pyx_t_1;
5681
5682 /* "pygame_sdl2/surface.pyx":356
5683 * cdef int err
5684 *
5685 * if rect is not None: # <<<<<<<<<<<<<<
5686 * to_sdl_rect(rect, &sdl_rect)
5687 *
5688 */
5689 __pyx_t_2 = (__pyx_v_rect != Py_None);
5690 __pyx_t_3 = (__pyx_t_2 != 0);
5691 if (__pyx_t_3) {
5692
5693 /* "pygame_sdl2/surface.pyx":357
5694 *
5695 * if rect is not None:
5696 * to_sdl_rect(rect, &sdl_rect) # <<<<<<<<<<<<<<
5697 *
5698 * if sdl_rect.x < 0:
5699 */
5700 __pyx_t_4 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_v_rect, (&__pyx_v_sdl_rect), NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 357, __pyx_L1_error)
5701
5702 /* "pygame_sdl2/surface.pyx":359
5703 * to_sdl_rect(rect, &sdl_rect)
5704 *
5705 * if sdl_rect.x < 0: # <<<<<<<<<<<<<<
5706 * sdl_rect.w = sdl_rect.w + sdl_rect.x
5707 * sdl_rect.x = 0
5708 */
5709 __pyx_t_3 = ((__pyx_v_sdl_rect.x < 0) != 0);
5710 if (__pyx_t_3) {
5711
5712 /* "pygame_sdl2/surface.pyx":360
5713 *
5714 * if sdl_rect.x < 0:
5715 * sdl_rect.w = sdl_rect.w + sdl_rect.x # <<<<<<<<<<<<<<
5716 * sdl_rect.x = 0
5717 *
5718 */
5719 __pyx_v_sdl_rect.w = (__pyx_v_sdl_rect.w + __pyx_v_sdl_rect.x);
5720
5721 /* "pygame_sdl2/surface.pyx":361
5722 * if sdl_rect.x < 0:
5723 * sdl_rect.w = sdl_rect.w + sdl_rect.x
5724 * sdl_rect.x = 0 # <<<<<<<<<<<<<<
5725 *
5726 * if sdl_rect.y < 0:
5727 */
5728 __pyx_v_sdl_rect.x = 0;
5729
5730 /* "pygame_sdl2/surface.pyx":359
5731 * to_sdl_rect(rect, &sdl_rect)
5732 *
5733 * if sdl_rect.x < 0: # <<<<<<<<<<<<<<
5734 * sdl_rect.w = sdl_rect.w + sdl_rect.x
5735 * sdl_rect.x = 0
5736 */
5737 }
5738
5739 /* "pygame_sdl2/surface.pyx":363
5740 * sdl_rect.x = 0
5741 *
5742 * if sdl_rect.y < 0: # <<<<<<<<<<<<<<
5743 * sdl_rect.w = sdl_rect.h + sdl_rect.y
5744 * sdl_rect.y = 0
5745 */
5746 __pyx_t_3 = ((__pyx_v_sdl_rect.y < 0) != 0);
5747 if (__pyx_t_3) {
5748
5749 /* "pygame_sdl2/surface.pyx":364
5750 *
5751 * if sdl_rect.y < 0:
5752 * sdl_rect.w = sdl_rect.h + sdl_rect.y # <<<<<<<<<<<<<<
5753 * sdl_rect.y = 0
5754 *
5755 */
5756 __pyx_v_sdl_rect.w = (__pyx_v_sdl_rect.h + __pyx_v_sdl_rect.y);
5757
5758 /* "pygame_sdl2/surface.pyx":365
5759 * if sdl_rect.y < 0:
5760 * sdl_rect.w = sdl_rect.h + sdl_rect.y
5761 * sdl_rect.y = 0 # <<<<<<<<<<<<<<
5762 *
5763 * if sdl_rect.w <= 0 or sdl_rect.h <= 0:
5764 */
5765 __pyx_v_sdl_rect.y = 0;
5766
5767 /* "pygame_sdl2/surface.pyx":363
5768 * sdl_rect.x = 0
5769 *
5770 * if sdl_rect.y < 0: # <<<<<<<<<<<<<<
5771 * sdl_rect.w = sdl_rect.h + sdl_rect.y
5772 * sdl_rect.y = 0
5773 */
5774 }
5775
5776 /* "pygame_sdl2/surface.pyx":367
5777 * sdl_rect.y = 0
5778 *
5779 * if sdl_rect.w <= 0 or sdl_rect.h <= 0: # <<<<<<<<<<<<<<
5780 * return Rect(0, 0, 0, 0)
5781 *
5782 */
5783 __pyx_t_2 = ((__pyx_v_sdl_rect.w <= 0) != 0);
5784 if (!__pyx_t_2) {
5785 } else {
5786 __pyx_t_3 = __pyx_t_2;
5787 goto __pyx_L7_bool_binop_done;
5788 }
5789 __pyx_t_2 = ((__pyx_v_sdl_rect.h <= 0) != 0);
5790 __pyx_t_3 = __pyx_t_2;
5791 __pyx_L7_bool_binop_done:;
5792 if (__pyx_t_3) {
5793
5794 /* "pygame_sdl2/surface.pyx":368
5795 *
5796 * if sdl_rect.w <= 0 or sdl_rect.h <= 0:
5797 * return Rect(0, 0, 0, 0) # <<<<<<<<<<<<<<
5798 *
5799 * with nogil:
5800 */
5801 __Pyx_XDECREF(__pyx_r);
5802 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Rect); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L1_error)
5803 __Pyx_GOTREF(__pyx_t_5);
5804 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
5805 __Pyx_GOTREF(__pyx_t_6);
5806 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5807 __pyx_r = __pyx_t_6;
5808 __pyx_t_6 = 0;
5809 goto __pyx_L0;
5810
5811 /* "pygame_sdl2/surface.pyx":367
5812 * sdl_rect.y = 0
5813 *
5814 * if sdl_rect.w <= 0 or sdl_rect.h <= 0: # <<<<<<<<<<<<<<
5815 * return Rect(0, 0, 0, 0)
5816 *
5817 */
5818 }
5819
5820 /* "pygame_sdl2/surface.pyx":370
5821 * return Rect(0, 0, 0, 0)
5822 *
5823 * with nogil: # <<<<<<<<<<<<<<
5824 * err = SDL_FillRect(self.surface, &sdl_rect, pixel)
5825 *
5826 */
5827 {
5828 #ifdef WITH_THREAD
5829 PyThreadState *_save;
5830 Py_UNBLOCK_THREADS
5831 __Pyx_FastGIL_Remember();
5832 #endif
5833 /*try:*/ {
5834
5835 /* "pygame_sdl2/surface.pyx":371
5836 *
5837 * with nogil:
5838 * err = SDL_FillRect(self.surface, &sdl_rect, pixel) # <<<<<<<<<<<<<<
5839 *
5840 * if err:
5841 */
5842 __pyx_v_err = SDL_FillRect(__pyx_v_self->surface, (&__pyx_v_sdl_rect), __pyx_v_pixel);
5843 }
5844
5845 /* "pygame_sdl2/surface.pyx":370
5846 * return Rect(0, 0, 0, 0)
5847 *
5848 * with nogil: # <<<<<<<<<<<<<<
5849 * err = SDL_FillRect(self.surface, &sdl_rect, pixel)
5850 *
5851 */
5852 /*finally:*/ {
5853 /*normal exit:*/{
5854 #ifdef WITH_THREAD
5855 __Pyx_FastGIL_Forget();
5856 Py_BLOCK_THREADS
5857 #endif
5858 goto __pyx_L11;
5859 }
5860 __pyx_L11:;
5861 }
5862 }
5863
5864 /* "pygame_sdl2/surface.pyx":373
5865 * err = SDL_FillRect(self.surface, &sdl_rect, pixel)
5866 *
5867 * if err: # <<<<<<<<<<<<<<
5868 * raise error()
5869 *
5870 */
5871 __pyx_t_3 = (__pyx_v_err != 0);
5872 if (unlikely(__pyx_t_3)) {
5873
5874 /* "pygame_sdl2/surface.pyx":374
5875 *
5876 * if err:
5877 * raise error() # <<<<<<<<<<<<<<
5878 *
5879 * return Rect(sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h)
5880 */
5881 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 374, __pyx_L1_error)
5882 __Pyx_GOTREF(__pyx_t_5);
5883 __pyx_t_7 = NULL;
5884 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
5885 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
5886 if (likely(__pyx_t_7)) {
5887 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5888 __Pyx_INCREF(__pyx_t_7);
5889 __Pyx_INCREF(function);
5890 __Pyx_DECREF_SET(__pyx_t_5, function);
5891 }
5892 }
5893 __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
5894 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
5895 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
5896 __Pyx_GOTREF(__pyx_t_6);
5897 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5898 __Pyx_Raise(__pyx_t_6, 0, 0, 0);
5899 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5900 __PYX_ERR(0, 374, __pyx_L1_error)
5901
5902 /* "pygame_sdl2/surface.pyx":373
5903 * err = SDL_FillRect(self.surface, &sdl_rect, pixel)
5904 *
5905 * if err: # <<<<<<<<<<<<<<
5906 * raise error()
5907 *
5908 */
5909 }
5910
5911 /* "pygame_sdl2/surface.pyx":376
5912 * raise error()
5913 *
5914 * return Rect(sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h) # <<<<<<<<<<<<<<
5915 *
5916 * else:
5917 */
5918 __Pyx_XDECREF(__pyx_r);
5919 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Rect); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 376, __pyx_L1_error)
5920 __Pyx_GOTREF(__pyx_t_5);
5921 __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.x); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 376, __pyx_L1_error)
5922 __Pyx_GOTREF(__pyx_t_7);
5923 __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.y); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 376, __pyx_L1_error)
5924 __Pyx_GOTREF(__pyx_t_8);
5925 __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.w); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 376, __pyx_L1_error)
5926 __Pyx_GOTREF(__pyx_t_9);
5927 __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 376, __pyx_L1_error)
5928 __Pyx_GOTREF(__pyx_t_10);
5929 __pyx_t_11 = NULL;
5930 __pyx_t_4 = 0;
5931 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
5932 __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
5933 if (likely(__pyx_t_11)) {
5934 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5935 __Pyx_INCREF(__pyx_t_11);
5936 __Pyx_INCREF(function);
5937 __Pyx_DECREF_SET(__pyx_t_5, function);
5938 __pyx_t_4 = 1;
5939 }
5940 }
5941 #if CYTHON_FAST_PYCALL
5942 if (PyFunction_Check(__pyx_t_5)) {
5943 PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
5944 __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 376, __pyx_L1_error)
5945 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
5946 __Pyx_GOTREF(__pyx_t_6);
5947 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5948 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5949 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5950 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5951 } else
5952 #endif
5953 #if CYTHON_FAST_PYCCALL
5954 if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
5955 PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
5956 __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 376, __pyx_L1_error)
5957 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
5958 __Pyx_GOTREF(__pyx_t_6);
5959 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5960 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5961 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5962 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5963 } else
5964 #endif
5965 {
5966 __pyx_t_12 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 376, __pyx_L1_error)
5967 __Pyx_GOTREF(__pyx_t_12);
5968 if (__pyx_t_11) {
5969 __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
5970 }
5971 __Pyx_GIVEREF(__pyx_t_7);
5972 PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_4, __pyx_t_7);
5973 __Pyx_GIVEREF(__pyx_t_8);
5974 PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_4, __pyx_t_8);
5975 __Pyx_GIVEREF(__pyx_t_9);
5976 PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_4, __pyx_t_9);
5977 __Pyx_GIVEREF(__pyx_t_10);
5978 PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_4, __pyx_t_10);
5979 __pyx_t_7 = 0;
5980 __pyx_t_8 = 0;
5981 __pyx_t_9 = 0;
5982 __pyx_t_10 = 0;
5983 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 376, __pyx_L1_error)
5984 __Pyx_GOTREF(__pyx_t_6);
5985 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
5986 }
5987 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5988 __pyx_r = __pyx_t_6;
5989 __pyx_t_6 = 0;
5990 goto __pyx_L0;
5991
5992 /* "pygame_sdl2/surface.pyx":356
5993 * cdef int err
5994 *
5995 * if rect is not None: # <<<<<<<<<<<<<<
5996 * to_sdl_rect(rect, &sdl_rect)
5997 *
5998 */
5999 }
6000
6001 /* "pygame_sdl2/surface.pyx":379
6002 *
6003 * else:
6004 * with nogil: # <<<<<<<<<<<<<<
6005 * err = SDL_FillRect(self.surface, NULL, pixel)
6006 *
6007 */
6008 /*else*/ {
6009 {
6010 #ifdef WITH_THREAD
6011 PyThreadState *_save;
6012 Py_UNBLOCK_THREADS
6013 __Pyx_FastGIL_Remember();
6014 #endif
6015 /*try:*/ {
6016
6017 /* "pygame_sdl2/surface.pyx":380
6018 * else:
6019 * with nogil:
6020 * err = SDL_FillRect(self.surface, NULL, pixel) # <<<<<<<<<<<<<<
6021 *
6022 * if err:
6023 */
6024 __pyx_v_err = SDL_FillRect(__pyx_v_self->surface, NULL, __pyx_v_pixel);
6025 }
6026
6027 /* "pygame_sdl2/surface.pyx":379
6028 *
6029 * else:
6030 * with nogil: # <<<<<<<<<<<<<<
6031 * err = SDL_FillRect(self.surface, NULL, pixel)
6032 *
6033 */
6034 /*finally:*/ {
6035 /*normal exit:*/{
6036 #ifdef WITH_THREAD
6037 __Pyx_FastGIL_Forget();
6038 Py_BLOCK_THREADS
6039 #endif
6040 goto __pyx_L15;
6041 }
6042 __pyx_L15:;
6043 }
6044 }
6045
6046 /* "pygame_sdl2/surface.pyx":382
6047 * err = SDL_FillRect(self.surface, NULL, pixel)
6048 *
6049 * if err: # <<<<<<<<<<<<<<
6050 * raise error()
6051 *
6052 */
6053 __pyx_t_3 = (__pyx_v_err != 0);
6054 if (unlikely(__pyx_t_3)) {
6055
6056 /* "pygame_sdl2/surface.pyx":383
6057 *
6058 * if err:
6059 * raise error() # <<<<<<<<<<<<<<
6060 *
6061 * return Rect(0, 0, self.surface.w, self.surface.h)
6062 */
6063 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 383, __pyx_L1_error)
6064 __Pyx_GOTREF(__pyx_t_5);
6065 __pyx_t_12 = NULL;
6066 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
6067 __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5);
6068 if (likely(__pyx_t_12)) {
6069 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
6070 __Pyx_INCREF(__pyx_t_12);
6071 __Pyx_INCREF(function);
6072 __Pyx_DECREF_SET(__pyx_t_5, function);
6073 }
6074 }
6075 __pyx_t_6 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
6076 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
6077 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __pyx_L1_error)
6078 __Pyx_GOTREF(__pyx_t_6);
6079 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6080 __Pyx_Raise(__pyx_t_6, 0, 0, 0);
6081 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6082 __PYX_ERR(0, 383, __pyx_L1_error)
6083
6084 /* "pygame_sdl2/surface.pyx":382
6085 * err = SDL_FillRect(self.surface, NULL, pixel)
6086 *
6087 * if err: # <<<<<<<<<<<<<<
6088 * raise error()
6089 *
6090 */
6091 }
6092
6093 /* "pygame_sdl2/surface.pyx":385
6094 * raise error()
6095 *
6096 * return Rect(0, 0, self.surface.w, self.surface.h) # <<<<<<<<<<<<<<
6097 *
6098 *
6099 */
6100 __Pyx_XDECREF(__pyx_r);
6101 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Rect); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error)
6102 __Pyx_GOTREF(__pyx_t_5);
6103 __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 385, __pyx_L1_error)
6104 __Pyx_GOTREF(__pyx_t_12);
6105 __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error)
6106 __Pyx_GOTREF(__pyx_t_10);
6107 __pyx_t_9 = NULL;
6108 __pyx_t_4 = 0;
6109 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
6110 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
6111 if (likely(__pyx_t_9)) {
6112 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
6113 __Pyx_INCREF(__pyx_t_9);
6114 __Pyx_INCREF(function);
6115 __Pyx_DECREF_SET(__pyx_t_5, function);
6116 __pyx_t_4 = 1;
6117 }
6118 }
6119 #if CYTHON_FAST_PYCALL
6120 if (PyFunction_Check(__pyx_t_5)) {
6121 PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_int_0, __pyx_int_0, __pyx_t_12, __pyx_t_10};
6122 __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error)
6123 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6124 __Pyx_GOTREF(__pyx_t_6);
6125 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
6126 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6127 } else
6128 #endif
6129 #if CYTHON_FAST_PYCCALL
6130 if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
6131 PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_int_0, __pyx_int_0, __pyx_t_12, __pyx_t_10};
6132 __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error)
6133 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6134 __Pyx_GOTREF(__pyx_t_6);
6135 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
6136 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6137 } else
6138 #endif
6139 {
6140 __pyx_t_8 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
6141 __Pyx_GOTREF(__pyx_t_8);
6142 if (__pyx_t_9) {
6143 __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL;
6144 }
6145 __Pyx_INCREF(__pyx_int_0);
6146 __Pyx_GIVEREF(__pyx_int_0);
6147 PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_4, __pyx_int_0);
6148 __Pyx_INCREF(__pyx_int_0);
6149 __Pyx_GIVEREF(__pyx_int_0);
6150 PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_4, __pyx_int_0);
6151 __Pyx_GIVEREF(__pyx_t_12);
6152 PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_4, __pyx_t_12);
6153 __Pyx_GIVEREF(__pyx_t_10);
6154 PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_4, __pyx_t_10);
6155 __pyx_t_12 = 0;
6156 __pyx_t_10 = 0;
6157 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error)
6158 __Pyx_GOTREF(__pyx_t_6);
6159 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6160 }
6161 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6162 __pyx_r = __pyx_t_6;
6163 __pyx_t_6 = 0;
6164 goto __pyx_L0;
6165 }
6166
6167 /* "pygame_sdl2/surface.pyx":350
6168 * return self.convert(self)
6169 *
6170 * def fill(self, color, rect=None, special_flags=0): # <<<<<<<<<<<<<<
6171 *
6172 * cdef SDL_Rect sdl_rect
6173 */
6174
6175 /* function exit code */
6176 __pyx_L1_error:;
6177 __Pyx_XDECREF(__pyx_t_5);
6178 __Pyx_XDECREF(__pyx_t_6);
6179 __Pyx_XDECREF(__pyx_t_7);
6180 __Pyx_XDECREF(__pyx_t_8);
6181 __Pyx_XDECREF(__pyx_t_9);
6182 __Pyx_XDECREF(__pyx_t_10);
6183 __Pyx_XDECREF(__pyx_t_11);
6184 __Pyx_XDECREF(__pyx_t_12);
6185 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.fill", __pyx_clineno, __pyx_lineno, __pyx_filename);
6186 __pyx_r = NULL;
6187 __pyx_L0:;
6188 __Pyx_XGIVEREF(__pyx_r);
6189 __Pyx_RefNannyFinishContext();
6190 return __pyx_r;
6191 }
6192
6193 /* "pygame_sdl2/surface.pyx":388
6194 *
6195 *
6196 * def scroll(self, int dx=0, int dy=0): # <<<<<<<<<<<<<<
6197 * cdef int srcx, destx, move_width
6198 * cdef int srcy, desty, move_height
6199 */
6200
6201 /* Python wrapper */
6202 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_21scroll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_21scroll(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6203 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_21scroll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6204 int __pyx_v_dx;
6205 int __pyx_v_dy;
6206 int __pyx_lineno = 0;
6207 const char *__pyx_filename = NULL;
6208 int __pyx_clineno = 0;
6209 PyObject *__pyx_r = 0;
6210 __Pyx_RefNannyDeclarations
6211 __Pyx_RefNannySetupContext("scroll (wrapper)", 0);
6212 {
6213 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dx,&__pyx_n_s_dy,0};
6214 PyObject* values[2] = {0,0};
6215 if (unlikely(__pyx_kwds)) {
6216 Py_ssize_t kw_args;
6217 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6218 switch (pos_args) {
6219 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6220 CYTHON_FALLTHROUGH;
6221 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6222 CYTHON_FALLTHROUGH;
6223 case 0: break;
6224 default: goto __pyx_L5_argtuple_error;
6225 }
6226 kw_args = PyDict_Size(__pyx_kwds);
6227 switch (pos_args) {
6228 case 0:
6229 if (kw_args > 0) {
6230 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dx);
6231 if (value) { values[0] = value; kw_args--; }
6232 }
6233 CYTHON_FALLTHROUGH;
6234 case 1:
6235 if (kw_args > 0) {
6236 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy);
6237 if (value) { values[1] = value; kw_args--; }
6238 }
6239 }
6240 if (unlikely(kw_args > 0)) {
6241 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scroll") < 0)) __PYX_ERR(0, 388, __pyx_L3_error)
6242 }
6243 } else {
6244 switch (PyTuple_GET_SIZE(__pyx_args)) {
6245 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6246 CYTHON_FALLTHROUGH;
6247 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6248 CYTHON_FALLTHROUGH;
6249 case 0: break;
6250 default: goto __pyx_L5_argtuple_error;
6251 }
6252 }
6253 if (values[0]) {
6254 __pyx_v_dx = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_dx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L3_error)
6255 } else {
6256 __pyx_v_dx = ((int)0);
6257 }
6258 if (values[1]) {
6259 __pyx_v_dy = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_dy == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L3_error)
6260 } else {
6261 __pyx_v_dy = ((int)0);
6262 }
6263 }
6264 goto __pyx_L4_argument_unpacking_done;
6265 __pyx_L5_argtuple_error:;
6266 __Pyx_RaiseArgtupleInvalid("scroll", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 388, __pyx_L3_error)
6267 __pyx_L3_error:;
6268 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.scroll", __pyx_clineno, __pyx_lineno, __pyx_filename);
6269 __Pyx_RefNannyFinishContext();
6270 return NULL;
6271 __pyx_L4_argument_unpacking_done:;
6272 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_20scroll(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_dx, __pyx_v_dy);
6273
6274 /* function exit code */
6275 __Pyx_RefNannyFinishContext();
6276 return __pyx_r;
6277 }
6278
__pyx_pf_11pygame_sdl2_7surface_7Surface_20scroll(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,int __pyx_v_dx,int __pyx_v_dy)6279 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_20scroll(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, int __pyx_v_dx, int __pyx_v_dy) {
6280 int __pyx_v_srcx;
6281 int __pyx_v_destx;
6282 int __pyx_v_move_width;
6283 int __pyx_v_srcy;
6284 int __pyx_v_desty;
6285 int __pyx_v_move_height;
6286 int __pyx_v_width;
6287 int __pyx_v_height;
6288 int __pyx_v_per_pixel;
6289 Uint8 *__pyx_v_srcptr;
6290 Uint8 *__pyx_v_destptr;
6291 PyObject *__pyx_r = NULL;
6292 __Pyx_RefNannyDeclarations
6293 int __pyx_t_1;
6294 Uint8 __pyx_t_2;
6295 int __pyx_t_3;
6296 PyObject *__pyx_t_4 = NULL;
6297 PyObject *__pyx_t_5 = NULL;
6298 PyObject *__pyx_t_6 = NULL;
6299 int __pyx_lineno = 0;
6300 const char *__pyx_filename = NULL;
6301 int __pyx_clineno = 0;
6302 __Pyx_RefNannySetupContext("scroll", 0);
6303
6304 /* "pygame_sdl2/surface.pyx":392
6305 * cdef int srcy, desty, move_height
6306 *
6307 * cdef int width = self.surface.w # <<<<<<<<<<<<<<
6308 * cdef int height = self.surface.h
6309 *
6310 */
6311 __pyx_t_1 = __pyx_v_self->surface->w;
6312 __pyx_v_width = __pyx_t_1;
6313
6314 /* "pygame_sdl2/surface.pyx":393
6315 *
6316 * cdef int width = self.surface.w
6317 * cdef int height = self.surface.h # <<<<<<<<<<<<<<
6318 *
6319 * cdef int per_pixel = self.surface.format.BytesPerPixel
6320 */
6321 __pyx_t_1 = __pyx_v_self->surface->h;
6322 __pyx_v_height = __pyx_t_1;
6323
6324 /* "pygame_sdl2/surface.pyx":395
6325 * cdef int height = self.surface.h
6326 *
6327 * cdef int per_pixel = self.surface.format.BytesPerPixel # <<<<<<<<<<<<<<
6328 *
6329 * if dx >= 0:
6330 */
6331 __pyx_t_2 = __pyx_v_self->surface->format->BytesPerPixel;
6332 __pyx_v_per_pixel = __pyx_t_2;
6333
6334 /* "pygame_sdl2/surface.pyx":397
6335 * cdef int per_pixel = self.surface.format.BytesPerPixel
6336 *
6337 * if dx >= 0: # <<<<<<<<<<<<<<
6338 * srcx = 0
6339 * destx = dx
6340 */
6341 __pyx_t_3 = ((__pyx_v_dx >= 0) != 0);
6342 if (__pyx_t_3) {
6343
6344 /* "pygame_sdl2/surface.pyx":398
6345 *
6346 * if dx >= 0:
6347 * srcx = 0 # <<<<<<<<<<<<<<
6348 * destx = dx
6349 * move_width = width - dx
6350 */
6351 __pyx_v_srcx = 0;
6352
6353 /* "pygame_sdl2/surface.pyx":399
6354 * if dx >= 0:
6355 * srcx = 0
6356 * destx = dx # <<<<<<<<<<<<<<
6357 * move_width = width - dx
6358 * else:
6359 */
6360 __pyx_v_destx = __pyx_v_dx;
6361
6362 /* "pygame_sdl2/surface.pyx":400
6363 * srcx = 0
6364 * destx = dx
6365 * move_width = width - dx # <<<<<<<<<<<<<<
6366 * else:
6367 * srcx = -dx
6368 */
6369 __pyx_v_move_width = (__pyx_v_width - __pyx_v_dx);
6370
6371 /* "pygame_sdl2/surface.pyx":397
6372 * cdef int per_pixel = self.surface.format.BytesPerPixel
6373 *
6374 * if dx >= 0: # <<<<<<<<<<<<<<
6375 * srcx = 0
6376 * destx = dx
6377 */
6378 goto __pyx_L3;
6379 }
6380
6381 /* "pygame_sdl2/surface.pyx":402
6382 * move_width = width - dx
6383 * else:
6384 * srcx = -dx # <<<<<<<<<<<<<<
6385 * destx = 0
6386 * move_width = width + dx
6387 */
6388 /*else*/ {
6389 __pyx_v_srcx = (-__pyx_v_dx);
6390
6391 /* "pygame_sdl2/surface.pyx":403
6392 * else:
6393 * srcx = -dx
6394 * destx = 0 # <<<<<<<<<<<<<<
6395 * move_width = width + dx
6396 *
6397 */
6398 __pyx_v_destx = 0;
6399
6400 /* "pygame_sdl2/surface.pyx":404
6401 * srcx = -dx
6402 * destx = 0
6403 * move_width = width + dx # <<<<<<<<<<<<<<
6404 *
6405 * if dy >= 0:
6406 */
6407 __pyx_v_move_width = (__pyx_v_width + __pyx_v_dx);
6408 }
6409 __pyx_L3:;
6410
6411 /* "pygame_sdl2/surface.pyx":406
6412 * move_width = width + dx
6413 *
6414 * if dy >= 0: # <<<<<<<<<<<<<<
6415 * srcy = 0
6416 * desty = dy
6417 */
6418 __pyx_t_3 = ((__pyx_v_dy >= 0) != 0);
6419 if (__pyx_t_3) {
6420
6421 /* "pygame_sdl2/surface.pyx":407
6422 *
6423 * if dy >= 0:
6424 * srcy = 0 # <<<<<<<<<<<<<<
6425 * desty = dy
6426 * move_height = height - dy
6427 */
6428 __pyx_v_srcy = 0;
6429
6430 /* "pygame_sdl2/surface.pyx":408
6431 * if dy >= 0:
6432 * srcy = 0
6433 * desty = dy # <<<<<<<<<<<<<<
6434 * move_height = height - dy
6435 * else:
6436 */
6437 __pyx_v_desty = __pyx_v_dy;
6438
6439 /* "pygame_sdl2/surface.pyx":409
6440 * srcy = 0
6441 * desty = dy
6442 * move_height = height - dy # <<<<<<<<<<<<<<
6443 * else:
6444 * srcy = -dy
6445 */
6446 __pyx_v_move_height = (__pyx_v_height - __pyx_v_dy);
6447
6448 /* "pygame_sdl2/surface.pyx":406
6449 * move_width = width + dx
6450 *
6451 * if dy >= 0: # <<<<<<<<<<<<<<
6452 * srcy = 0
6453 * desty = dy
6454 */
6455 goto __pyx_L4;
6456 }
6457
6458 /* "pygame_sdl2/surface.pyx":411
6459 * move_height = height - dy
6460 * else:
6461 * srcy = -dy # <<<<<<<<<<<<<<
6462 * desty = 0
6463 * move_height = height + dy
6464 */
6465 /*else*/ {
6466 __pyx_v_srcy = (-__pyx_v_dy);
6467
6468 /* "pygame_sdl2/surface.pyx":412
6469 * else:
6470 * srcy = -dy
6471 * desty = 0 # <<<<<<<<<<<<<<
6472 * move_height = height + dy
6473 *
6474 */
6475 __pyx_v_desty = 0;
6476
6477 /* "pygame_sdl2/surface.pyx":413
6478 * srcy = -dy
6479 * desty = 0
6480 * move_height = height + dy # <<<<<<<<<<<<<<
6481 *
6482 * cdef Uint8 *srcptr = <Uint8 *> self.surface.pixels
6483 */
6484 __pyx_v_move_height = (__pyx_v_height + __pyx_v_dy);
6485 }
6486 __pyx_L4:;
6487
6488 /* "pygame_sdl2/surface.pyx":415
6489 * move_height = height + dy
6490 *
6491 * cdef Uint8 *srcptr = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
6492 * cdef Uint8 *destptr = <Uint8 *> self.surface.pixels
6493 *
6494 */
6495 __pyx_v_srcptr = ((Uint8 *)__pyx_v_self->surface->pixels);
6496
6497 /* "pygame_sdl2/surface.pyx":416
6498 *
6499 * cdef Uint8 *srcptr = <Uint8 *> self.surface.pixels
6500 * cdef Uint8 *destptr = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
6501 *
6502 * srcptr += srcy * self.surface.pitch + srcx * per_pixel
6503 */
6504 __pyx_v_destptr = ((Uint8 *)__pyx_v_self->surface->pixels);
6505
6506 /* "pygame_sdl2/surface.pyx":418
6507 * cdef Uint8 *destptr = <Uint8 *> self.surface.pixels
6508 *
6509 * srcptr += srcy * self.surface.pitch + srcx * per_pixel # <<<<<<<<<<<<<<
6510 * destptr += desty * self.surface.pitch + destx * per_pixel
6511 *
6512 */
6513 __pyx_v_srcptr = (__pyx_v_srcptr + ((__pyx_v_srcy * __pyx_v_self->surface->pitch) + (__pyx_v_srcx * __pyx_v_per_pixel)));
6514
6515 /* "pygame_sdl2/surface.pyx":419
6516 *
6517 * srcptr += srcy * self.surface.pitch + srcx * per_pixel
6518 * destptr += desty * self.surface.pitch + destx * per_pixel # <<<<<<<<<<<<<<
6519 *
6520 * self.lock()
6521 */
6522 __pyx_v_destptr = (__pyx_v_destptr + ((__pyx_v_desty * __pyx_v_self->surface->pitch) + (__pyx_v_destx * __pyx_v_per_pixel)));
6523
6524 /* "pygame_sdl2/surface.pyx":421
6525 * destptr += desty * self.surface.pitch + destx * per_pixel
6526 *
6527 * self.lock() # <<<<<<<<<<<<<<
6528 *
6529 * with nogil:
6530 */
6531 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __pyx_L1_error)
6532 __Pyx_GOTREF(__pyx_t_5);
6533 __pyx_t_6 = NULL;
6534 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
6535 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
6536 if (likely(__pyx_t_6)) {
6537 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
6538 __Pyx_INCREF(__pyx_t_6);
6539 __Pyx_INCREF(function);
6540 __Pyx_DECREF_SET(__pyx_t_5, function);
6541 }
6542 }
6543 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
6544 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
6545 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 421, __pyx_L1_error)
6546 __Pyx_GOTREF(__pyx_t_4);
6547 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6548 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6549
6550 /* "pygame_sdl2/surface.pyx":423
6551 * self.lock()
6552 *
6553 * with nogil: # <<<<<<<<<<<<<<
6554 * move_pixels(
6555 * srcptr,
6556 */
6557 {
6558 #ifdef WITH_THREAD
6559 PyThreadState *_save;
6560 Py_UNBLOCK_THREADS
6561 __Pyx_FastGIL_Remember();
6562 #endif
6563 /*try:*/ {
6564
6565 /* "pygame_sdl2/surface.pyx":424
6566 *
6567 * with nogil:
6568 * move_pixels( # <<<<<<<<<<<<<<
6569 * srcptr,
6570 * destptr,
6571 */
6572 __pyx_f_11pygame_sdl2_7surface_move_pixels(__pyx_v_srcptr, __pyx_v_destptr, __pyx_v_move_height, (__pyx_v_move_width * __pyx_v_per_pixel), __pyx_v_self->surface->pitch, __pyx_v_self->surface->pitch);
6573 }
6574
6575 /* "pygame_sdl2/surface.pyx":423
6576 * self.lock()
6577 *
6578 * with nogil: # <<<<<<<<<<<<<<
6579 * move_pixels(
6580 * srcptr,
6581 */
6582 /*finally:*/ {
6583 /*normal exit:*/{
6584 #ifdef WITH_THREAD
6585 __Pyx_FastGIL_Forget();
6586 Py_BLOCK_THREADS
6587 #endif
6588 goto __pyx_L7;
6589 }
6590 __pyx_L7:;
6591 }
6592 }
6593
6594 /* "pygame_sdl2/surface.pyx":432
6595 * self.surface.pitch)
6596 *
6597 * self.unlock() # <<<<<<<<<<<<<<
6598 *
6599 * def set_colorkey(self, color, flags=0):
6600 */
6601 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 432, __pyx_L1_error)
6602 __Pyx_GOTREF(__pyx_t_5);
6603 __pyx_t_6 = NULL;
6604 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
6605 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
6606 if (likely(__pyx_t_6)) {
6607 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
6608 __Pyx_INCREF(__pyx_t_6);
6609 __Pyx_INCREF(function);
6610 __Pyx_DECREF_SET(__pyx_t_5, function);
6611 }
6612 }
6613 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
6614 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
6615 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 432, __pyx_L1_error)
6616 __Pyx_GOTREF(__pyx_t_4);
6617 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6618 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6619
6620 /* "pygame_sdl2/surface.pyx":388
6621 *
6622 *
6623 * def scroll(self, int dx=0, int dy=0): # <<<<<<<<<<<<<<
6624 * cdef int srcx, destx, move_width
6625 * cdef int srcy, desty, move_height
6626 */
6627
6628 /* function exit code */
6629 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6630 goto __pyx_L0;
6631 __pyx_L1_error:;
6632 __Pyx_XDECREF(__pyx_t_4);
6633 __Pyx_XDECREF(__pyx_t_5);
6634 __Pyx_XDECREF(__pyx_t_6);
6635 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.scroll", __pyx_clineno, __pyx_lineno, __pyx_filename);
6636 __pyx_r = NULL;
6637 __pyx_L0:;
6638 __Pyx_XGIVEREF(__pyx_r);
6639 __Pyx_RefNannyFinishContext();
6640 return __pyx_r;
6641 }
6642
6643 /* "pygame_sdl2/surface.pyx":434
6644 * self.unlock()
6645 *
6646 * def set_colorkey(self, color, flags=0): # <<<<<<<<<<<<<<
6647 *
6648 * if color is None:
6649 */
6650
6651 /* Python wrapper */
6652 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_23set_colorkey(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_23set_colorkey(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6653 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_23set_colorkey(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6654 PyObject *__pyx_v_color = 0;
6655 CYTHON_UNUSED PyObject *__pyx_v_flags = 0;
6656 int __pyx_lineno = 0;
6657 const char *__pyx_filename = NULL;
6658 int __pyx_clineno = 0;
6659 PyObject *__pyx_r = 0;
6660 __Pyx_RefNannyDeclarations
6661 __Pyx_RefNannySetupContext("set_colorkey (wrapper)", 0);
6662 {
6663 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_color,&__pyx_n_s_flags,0};
6664 PyObject* values[2] = {0,0};
6665 values[1] = ((PyObject *)__pyx_int_0);
6666 if (unlikely(__pyx_kwds)) {
6667 Py_ssize_t kw_args;
6668 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6669 switch (pos_args) {
6670 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6671 CYTHON_FALLTHROUGH;
6672 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6673 CYTHON_FALLTHROUGH;
6674 case 0: break;
6675 default: goto __pyx_L5_argtuple_error;
6676 }
6677 kw_args = PyDict_Size(__pyx_kwds);
6678 switch (pos_args) {
6679 case 0:
6680 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_color)) != 0)) kw_args--;
6681 else goto __pyx_L5_argtuple_error;
6682 CYTHON_FALLTHROUGH;
6683 case 1:
6684 if (kw_args > 0) {
6685 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
6686 if (value) { values[1] = value; kw_args--; }
6687 }
6688 }
6689 if (unlikely(kw_args > 0)) {
6690 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_colorkey") < 0)) __PYX_ERR(0, 434, __pyx_L3_error)
6691 }
6692 } else {
6693 switch (PyTuple_GET_SIZE(__pyx_args)) {
6694 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6695 CYTHON_FALLTHROUGH;
6696 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6697 break;
6698 default: goto __pyx_L5_argtuple_error;
6699 }
6700 }
6701 __pyx_v_color = values[0];
6702 __pyx_v_flags = values[1];
6703 }
6704 goto __pyx_L4_argument_unpacking_done;
6705 __pyx_L5_argtuple_error:;
6706 __Pyx_RaiseArgtupleInvalid("set_colorkey", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 434, __pyx_L3_error)
6707 __pyx_L3_error:;
6708 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_colorkey", __pyx_clineno, __pyx_lineno, __pyx_filename);
6709 __Pyx_RefNannyFinishContext();
6710 return NULL;
6711 __pyx_L4_argument_unpacking_done:;
6712 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_22set_colorkey(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_color, __pyx_v_flags);
6713
6714 /* function exit code */
6715 __Pyx_RefNannyFinishContext();
6716 return __pyx_r;
6717 }
6718
__pyx_pf_11pygame_sdl2_7surface_7Surface_22set_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_color,CYTHON_UNUSED PyObject * __pyx_v_flags)6719 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_22set_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color, CYTHON_UNUSED PyObject *__pyx_v_flags) {
6720 PyObject *__pyx_r = NULL;
6721 __Pyx_RefNannyDeclarations
6722 int __pyx_t_1;
6723 int __pyx_t_2;
6724 PyObject *__pyx_t_3 = NULL;
6725 PyObject *__pyx_t_4 = NULL;
6726 PyObject *__pyx_t_5 = NULL;
6727 Uint32 __pyx_t_6;
6728 int __pyx_lineno = 0;
6729 const char *__pyx_filename = NULL;
6730 int __pyx_clineno = 0;
6731 __Pyx_RefNannySetupContext("set_colorkey", 0);
6732
6733 /* "pygame_sdl2/surface.pyx":436
6734 * def set_colorkey(self, color, flags=0):
6735 *
6736 * if color is None: # <<<<<<<<<<<<<<
6737 * if SDL_SetColorKey(self.surface, SDL_FALSE, 0):
6738 * raise error()
6739 */
6740 __pyx_t_1 = (__pyx_v_color == Py_None);
6741 __pyx_t_2 = (__pyx_t_1 != 0);
6742 if (__pyx_t_2) {
6743
6744 /* "pygame_sdl2/surface.pyx":437
6745 *
6746 * if color is None:
6747 * if SDL_SetColorKey(self.surface, SDL_FALSE, 0): # <<<<<<<<<<<<<<
6748 * raise error()
6749 *
6750 */
6751 __pyx_t_2 = (SDL_SetColorKey(__pyx_v_self->surface, SDL_FALSE, 0) != 0);
6752 if (unlikely(__pyx_t_2)) {
6753
6754 /* "pygame_sdl2/surface.pyx":438
6755 * if color is None:
6756 * if SDL_SetColorKey(self.surface, SDL_FALSE, 0):
6757 * raise error() # <<<<<<<<<<<<<<
6758 *
6759 * else:
6760 */
6761 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
6762 __Pyx_GOTREF(__pyx_t_4);
6763 __pyx_t_5 = NULL;
6764 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
6765 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
6766 if (likely(__pyx_t_5)) {
6767 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6768 __Pyx_INCREF(__pyx_t_5);
6769 __Pyx_INCREF(function);
6770 __Pyx_DECREF_SET(__pyx_t_4, function);
6771 }
6772 }
6773 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6774 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6775 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
6776 __Pyx_GOTREF(__pyx_t_3);
6777 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6778 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6779 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6780 __PYX_ERR(0, 438, __pyx_L1_error)
6781
6782 /* "pygame_sdl2/surface.pyx":437
6783 *
6784 * if color is None:
6785 * if SDL_SetColorKey(self.surface, SDL_FALSE, 0): # <<<<<<<<<<<<<<
6786 * raise error()
6787 *
6788 */
6789 }
6790
6791 /* "pygame_sdl2/surface.pyx":436
6792 * def set_colorkey(self, color, flags=0):
6793 *
6794 * if color is None: # <<<<<<<<<<<<<<
6795 * if SDL_SetColorKey(self.surface, SDL_FALSE, 0):
6796 * raise error()
6797 */
6798 goto __pyx_L3;
6799 }
6800
6801 /* "pygame_sdl2/surface.pyx":441
6802 *
6803 * else:
6804 * if SDL_SetColorKey(self.surface, SDL_TRUE, map_color(self.surface, color)): # <<<<<<<<<<<<<<
6805 * raise error()
6806 *
6807 */
6808 /*else*/ {
6809 __pyx_t_6 = __pyx_f_11pygame_sdl2_5color_map_color(__pyx_v_self->surface, __pyx_v_color); if (unlikely(__pyx_t_6 == ((Uint32)0xaabbccdd) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L1_error)
6810 __pyx_t_2 = (SDL_SetColorKey(__pyx_v_self->surface, SDL_TRUE, __pyx_t_6) != 0);
6811 if (unlikely(__pyx_t_2)) {
6812
6813 /* "pygame_sdl2/surface.pyx":442
6814 * else:
6815 * if SDL_SetColorKey(self.surface, SDL_TRUE, map_color(self.surface, color)):
6816 * raise error() # <<<<<<<<<<<<<<
6817 *
6818 * def get_colorkey(self):
6819 */
6820 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
6821 __Pyx_GOTREF(__pyx_t_4);
6822 __pyx_t_5 = NULL;
6823 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
6824 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
6825 if (likely(__pyx_t_5)) {
6826 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6827 __Pyx_INCREF(__pyx_t_5);
6828 __Pyx_INCREF(function);
6829 __Pyx_DECREF_SET(__pyx_t_4, function);
6830 }
6831 }
6832 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6833 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6834 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error)
6835 __Pyx_GOTREF(__pyx_t_3);
6836 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6837 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6838 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6839 __PYX_ERR(0, 442, __pyx_L1_error)
6840
6841 /* "pygame_sdl2/surface.pyx":441
6842 *
6843 * else:
6844 * if SDL_SetColorKey(self.surface, SDL_TRUE, map_color(self.surface, color)): # <<<<<<<<<<<<<<
6845 * raise error()
6846 *
6847 */
6848 }
6849 }
6850 __pyx_L3:;
6851
6852 /* "pygame_sdl2/surface.pyx":434
6853 * self.unlock()
6854 *
6855 * def set_colorkey(self, color, flags=0): # <<<<<<<<<<<<<<
6856 *
6857 * if color is None:
6858 */
6859
6860 /* function exit code */
6861 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6862 goto __pyx_L0;
6863 __pyx_L1_error:;
6864 __Pyx_XDECREF(__pyx_t_3);
6865 __Pyx_XDECREF(__pyx_t_4);
6866 __Pyx_XDECREF(__pyx_t_5);
6867 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_colorkey", __pyx_clineno, __pyx_lineno, __pyx_filename);
6868 __pyx_r = NULL;
6869 __pyx_L0:;
6870 __Pyx_XGIVEREF(__pyx_r);
6871 __Pyx_RefNannyFinishContext();
6872 return __pyx_r;
6873 }
6874
6875 /* "pygame_sdl2/surface.pyx":444
6876 * raise error()
6877 *
6878 * def get_colorkey(self): # <<<<<<<<<<<<<<
6879 * cdef Uint32 key
6880 *
6881 */
6882
6883 /* Python wrapper */
6884 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_25get_colorkey(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_25get_colorkey(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)6885 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_25get_colorkey(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
6886 PyObject *__pyx_r = 0;
6887 __Pyx_RefNannyDeclarations
6888 __Pyx_RefNannySetupContext("get_colorkey (wrapper)", 0);
6889 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_24get_colorkey(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
6890
6891 /* function exit code */
6892 __Pyx_RefNannyFinishContext();
6893 return __pyx_r;
6894 }
6895
__pyx_pf_11pygame_sdl2_7surface_7Surface_24get_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)6896 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_24get_colorkey(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
6897 Uint32 __pyx_v_key;
6898 PyObject *__pyx_r = NULL;
6899 __Pyx_RefNannyDeclarations
6900 int __pyx_t_1;
6901 PyObject *__pyx_t_2 = NULL;
6902 int __pyx_lineno = 0;
6903 const char *__pyx_filename = NULL;
6904 int __pyx_clineno = 0;
6905 __Pyx_RefNannySetupContext("get_colorkey", 0);
6906
6907 /* "pygame_sdl2/surface.pyx":447
6908 * cdef Uint32 key
6909 *
6910 * if SDL_GetColorKey(self.surface, &key): # <<<<<<<<<<<<<<
6911 * return None
6912 *
6913 */
6914 __pyx_t_1 = (SDL_GetColorKey(__pyx_v_self->surface, (&__pyx_v_key)) != 0);
6915 if (__pyx_t_1) {
6916
6917 /* "pygame_sdl2/surface.pyx":448
6918 *
6919 * if SDL_GetColorKey(self.surface, &key):
6920 * return None # <<<<<<<<<<<<<<
6921 *
6922 * return get_color(key, self.surface)
6923 */
6924 __Pyx_XDECREF(__pyx_r);
6925 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6926 goto __pyx_L0;
6927
6928 /* "pygame_sdl2/surface.pyx":447
6929 * cdef Uint32 key
6930 *
6931 * if SDL_GetColorKey(self.surface, &key): # <<<<<<<<<<<<<<
6932 * return None
6933 *
6934 */
6935 }
6936
6937 /* "pygame_sdl2/surface.pyx":450
6938 * return None
6939 *
6940 * return get_color(key, self.surface) # <<<<<<<<<<<<<<
6941 *
6942 * def set_alpha(self, value, flags=0):
6943 */
6944 __Pyx_XDECREF(__pyx_r);
6945 __pyx_t_2 = __pyx_f_11pygame_sdl2_5color_get_color(__pyx_v_key, __pyx_v_self->surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
6946 __Pyx_GOTREF(__pyx_t_2);
6947 __pyx_r = __pyx_t_2;
6948 __pyx_t_2 = 0;
6949 goto __pyx_L0;
6950
6951 /* "pygame_sdl2/surface.pyx":444
6952 * raise error()
6953 *
6954 * def get_colorkey(self): # <<<<<<<<<<<<<<
6955 * cdef Uint32 key
6956 *
6957 */
6958
6959 /* function exit code */
6960 __pyx_L1_error:;
6961 __Pyx_XDECREF(__pyx_t_2);
6962 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_colorkey", __pyx_clineno, __pyx_lineno, __pyx_filename);
6963 __pyx_r = NULL;
6964 __pyx_L0:;
6965 __Pyx_XGIVEREF(__pyx_r);
6966 __Pyx_RefNannyFinishContext();
6967 return __pyx_r;
6968 }
6969
6970 /* "pygame_sdl2/surface.pyx":452
6971 * return get_color(key, self.surface)
6972 *
6973 * def set_alpha(self, value, flags=0): # <<<<<<<<<<<<<<
6974 * if value is None:
6975 * value = 255
6976 */
6977
6978 /* Python wrapper */
6979 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_27set_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_27set_alpha(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6980 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_27set_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6981 PyObject *__pyx_v_value = 0;
6982 CYTHON_UNUSED PyObject *__pyx_v_flags = 0;
6983 int __pyx_lineno = 0;
6984 const char *__pyx_filename = NULL;
6985 int __pyx_clineno = 0;
6986 PyObject *__pyx_r = 0;
6987 __Pyx_RefNannyDeclarations
6988 __Pyx_RefNannySetupContext("set_alpha (wrapper)", 0);
6989 {
6990 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_flags,0};
6991 PyObject* values[2] = {0,0};
6992 values[1] = ((PyObject *)__pyx_int_0);
6993 if (unlikely(__pyx_kwds)) {
6994 Py_ssize_t kw_args;
6995 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6996 switch (pos_args) {
6997 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6998 CYTHON_FALLTHROUGH;
6999 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7000 CYTHON_FALLTHROUGH;
7001 case 0: break;
7002 default: goto __pyx_L5_argtuple_error;
7003 }
7004 kw_args = PyDict_Size(__pyx_kwds);
7005 switch (pos_args) {
7006 case 0:
7007 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
7008 else goto __pyx_L5_argtuple_error;
7009 CYTHON_FALLTHROUGH;
7010 case 1:
7011 if (kw_args > 0) {
7012 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
7013 if (value) { values[1] = value; kw_args--; }
7014 }
7015 }
7016 if (unlikely(kw_args > 0)) {
7017 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_alpha") < 0)) __PYX_ERR(0, 452, __pyx_L3_error)
7018 }
7019 } else {
7020 switch (PyTuple_GET_SIZE(__pyx_args)) {
7021 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7022 CYTHON_FALLTHROUGH;
7023 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7024 break;
7025 default: goto __pyx_L5_argtuple_error;
7026 }
7027 }
7028 __pyx_v_value = values[0];
7029 __pyx_v_flags = values[1];
7030 }
7031 goto __pyx_L4_argument_unpacking_done;
7032 __pyx_L5_argtuple_error:;
7033 __Pyx_RaiseArgtupleInvalid("set_alpha", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 452, __pyx_L3_error)
7034 __pyx_L3_error:;
7035 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_alpha", __pyx_clineno, __pyx_lineno, __pyx_filename);
7036 __Pyx_RefNannyFinishContext();
7037 return NULL;
7038 __pyx_L4_argument_unpacking_done:;
7039 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_26set_alpha(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_value, __pyx_v_flags);
7040
7041 /* function exit code */
7042 __Pyx_RefNannyFinishContext();
7043 return __pyx_r;
7044 }
7045
__pyx_pf_11pygame_sdl2_7surface_7Surface_26set_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_value,CYTHON_UNUSED PyObject * __pyx_v_flags)7046 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_26set_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_flags) {
7047 PyObject *__pyx_r = NULL;
7048 __Pyx_RefNannyDeclarations
7049 int __pyx_t_1;
7050 int __pyx_t_2;
7051 Uint8 __pyx_t_3;
7052 PyObject *__pyx_t_4 = NULL;
7053 PyObject *__pyx_t_5 = NULL;
7054 PyObject *__pyx_t_6 = NULL;
7055 int __pyx_lineno = 0;
7056 const char *__pyx_filename = NULL;
7057 int __pyx_clineno = 0;
7058 __Pyx_RefNannySetupContext("set_alpha", 0);
7059 __Pyx_INCREF(__pyx_v_value);
7060
7061 /* "pygame_sdl2/surface.pyx":453
7062 *
7063 * def set_alpha(self, value, flags=0):
7064 * if value is None: # <<<<<<<<<<<<<<
7065 * value = 255
7066 * self.has_alpha = False
7067 */
7068 __pyx_t_1 = (__pyx_v_value == Py_None);
7069 __pyx_t_2 = (__pyx_t_1 != 0);
7070 if (__pyx_t_2) {
7071
7072 /* "pygame_sdl2/surface.pyx":454
7073 * def set_alpha(self, value, flags=0):
7074 * if value is None:
7075 * value = 255 # <<<<<<<<<<<<<<
7076 * self.has_alpha = False
7077 * else:
7078 */
7079 __Pyx_INCREF(__pyx_int_255);
7080 __Pyx_DECREF_SET(__pyx_v_value, __pyx_int_255);
7081
7082 /* "pygame_sdl2/surface.pyx":455
7083 * if value is None:
7084 * value = 255
7085 * self.has_alpha = False # <<<<<<<<<<<<<<
7086 * else:
7087 * self.has_alpha = True
7088 */
7089 __pyx_v_self->has_alpha = 0;
7090
7091 /* "pygame_sdl2/surface.pyx":453
7092 *
7093 * def set_alpha(self, value, flags=0):
7094 * if value is None: # <<<<<<<<<<<<<<
7095 * value = 255
7096 * self.has_alpha = False
7097 */
7098 goto __pyx_L3;
7099 }
7100
7101 /* "pygame_sdl2/surface.pyx":457
7102 * self.has_alpha = False
7103 * else:
7104 * self.has_alpha = True # <<<<<<<<<<<<<<
7105 *
7106 * if SDL_SetSurfaceAlphaMod(self.surface, value):
7107 */
7108 /*else*/ {
7109 __pyx_v_self->has_alpha = 1;
7110 }
7111 __pyx_L3:;
7112
7113 /* "pygame_sdl2/surface.pyx":459
7114 * self.has_alpha = True
7115 *
7116 * if SDL_SetSurfaceAlphaMod(self.surface, value): # <<<<<<<<<<<<<<
7117 * raise error()
7118 *
7119 */
7120 __pyx_t_3 = __Pyx_PyInt_As_uint8_t(__pyx_v_value); if (unlikely((__pyx_t_3 == ((Uint8)-1)) && PyErr_Occurred())) __PYX_ERR(0, 459, __pyx_L1_error)
7121 __pyx_t_2 = (SDL_SetSurfaceAlphaMod(__pyx_v_self->surface, __pyx_t_3) != 0);
7122 if (unlikely(__pyx_t_2)) {
7123
7124 /* "pygame_sdl2/surface.pyx":460
7125 *
7126 * if SDL_SetSurfaceAlphaMod(self.surface, value):
7127 * raise error() # <<<<<<<<<<<<<<
7128 *
7129 * def get_alpha(self):
7130 */
7131 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 460, __pyx_L1_error)
7132 __Pyx_GOTREF(__pyx_t_5);
7133 __pyx_t_6 = NULL;
7134 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
7135 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
7136 if (likely(__pyx_t_6)) {
7137 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7138 __Pyx_INCREF(__pyx_t_6);
7139 __Pyx_INCREF(function);
7140 __Pyx_DECREF_SET(__pyx_t_5, function);
7141 }
7142 }
7143 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
7144 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7145 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 460, __pyx_L1_error)
7146 __Pyx_GOTREF(__pyx_t_4);
7147 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7148 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
7149 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7150 __PYX_ERR(0, 460, __pyx_L1_error)
7151
7152 /* "pygame_sdl2/surface.pyx":459
7153 * self.has_alpha = True
7154 *
7155 * if SDL_SetSurfaceAlphaMod(self.surface, value): # <<<<<<<<<<<<<<
7156 * raise error()
7157 *
7158 */
7159 }
7160
7161 /* "pygame_sdl2/surface.pyx":452
7162 * return get_color(key, self.surface)
7163 *
7164 * def set_alpha(self, value, flags=0): # <<<<<<<<<<<<<<
7165 * if value is None:
7166 * value = 255
7167 */
7168
7169 /* function exit code */
7170 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7171 goto __pyx_L0;
7172 __pyx_L1_error:;
7173 __Pyx_XDECREF(__pyx_t_4);
7174 __Pyx_XDECREF(__pyx_t_5);
7175 __Pyx_XDECREF(__pyx_t_6);
7176 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_alpha", __pyx_clineno, __pyx_lineno, __pyx_filename);
7177 __pyx_r = NULL;
7178 __pyx_L0:;
7179 __Pyx_XDECREF(__pyx_v_value);
7180 __Pyx_XGIVEREF(__pyx_r);
7181 __Pyx_RefNannyFinishContext();
7182 return __pyx_r;
7183 }
7184
7185 /* "pygame_sdl2/surface.pyx":462
7186 * raise error()
7187 *
7188 * def get_alpha(self): # <<<<<<<<<<<<<<
7189 * cdef Uint8 rv
7190 *
7191 */
7192
7193 /* Python wrapper */
7194 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_29get_alpha(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_29get_alpha(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)7195 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_29get_alpha(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
7196 PyObject *__pyx_r = 0;
7197 __Pyx_RefNannyDeclarations
7198 __Pyx_RefNannySetupContext("get_alpha (wrapper)", 0);
7199 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_28get_alpha(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
7200
7201 /* function exit code */
7202 __Pyx_RefNannyFinishContext();
7203 return __pyx_r;
7204 }
7205
__pyx_pf_11pygame_sdl2_7surface_7Surface_28get_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)7206 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_28get_alpha(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
7207 Uint8 __pyx_v_rv;
7208 PyObject *__pyx_r = NULL;
7209 __Pyx_RefNannyDeclarations
7210 int __pyx_t_1;
7211 int __pyx_t_2;
7212 PyObject *__pyx_t_3 = NULL;
7213 PyObject *__pyx_t_4 = NULL;
7214 PyObject *__pyx_t_5 = NULL;
7215 int __pyx_lineno = 0;
7216 const char *__pyx_filename = NULL;
7217 int __pyx_clineno = 0;
7218 __Pyx_RefNannySetupContext("get_alpha", 0);
7219
7220 /* "pygame_sdl2/surface.pyx":465
7221 * cdef Uint8 rv
7222 *
7223 * if self.has_alpha or self.surface.format.Amask: # <<<<<<<<<<<<<<
7224 *
7225 * if SDL_GetSurfaceAlphaMod(self.surface, &rv):
7226 */
7227 __pyx_t_2 = (__pyx_v_self->has_alpha != 0);
7228 if (!__pyx_t_2) {
7229 } else {
7230 __pyx_t_1 = __pyx_t_2;
7231 goto __pyx_L4_bool_binop_done;
7232 }
7233 __pyx_t_2 = (__pyx_v_self->surface->format->Amask != 0);
7234 __pyx_t_1 = __pyx_t_2;
7235 __pyx_L4_bool_binop_done:;
7236 if (__pyx_t_1) {
7237
7238 /* "pygame_sdl2/surface.pyx":467
7239 * if self.has_alpha or self.surface.format.Amask:
7240 *
7241 * if SDL_GetSurfaceAlphaMod(self.surface, &rv): # <<<<<<<<<<<<<<
7242 * raise error()
7243 *
7244 */
7245 __pyx_t_1 = (SDL_GetSurfaceAlphaMod(__pyx_v_self->surface, (&__pyx_v_rv)) != 0);
7246 if (unlikely(__pyx_t_1)) {
7247
7248 /* "pygame_sdl2/surface.pyx":468
7249 *
7250 * if SDL_GetSurfaceAlphaMod(self.surface, &rv):
7251 * raise error() # <<<<<<<<<<<<<<
7252 *
7253 * return rv
7254 */
7255 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 468, __pyx_L1_error)
7256 __Pyx_GOTREF(__pyx_t_4);
7257 __pyx_t_5 = NULL;
7258 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
7259 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
7260 if (likely(__pyx_t_5)) {
7261 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
7262 __Pyx_INCREF(__pyx_t_5);
7263 __Pyx_INCREF(function);
7264 __Pyx_DECREF_SET(__pyx_t_4, function);
7265 }
7266 }
7267 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
7268 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7269 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
7270 __Pyx_GOTREF(__pyx_t_3);
7271 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7272 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7273 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7274 __PYX_ERR(0, 468, __pyx_L1_error)
7275
7276 /* "pygame_sdl2/surface.pyx":467
7277 * if self.has_alpha or self.surface.format.Amask:
7278 *
7279 * if SDL_GetSurfaceAlphaMod(self.surface, &rv): # <<<<<<<<<<<<<<
7280 * raise error()
7281 *
7282 */
7283 }
7284
7285 /* "pygame_sdl2/surface.pyx":470
7286 * raise error()
7287 *
7288 * return rv # <<<<<<<<<<<<<<
7289 *
7290 * else:
7291 */
7292 __Pyx_XDECREF(__pyx_r);
7293 __pyx_t_3 = __Pyx_PyInt_From_uint8_t(__pyx_v_rv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __pyx_L1_error)
7294 __Pyx_GOTREF(__pyx_t_3);
7295 __pyx_r = __pyx_t_3;
7296 __pyx_t_3 = 0;
7297 goto __pyx_L0;
7298
7299 /* "pygame_sdl2/surface.pyx":465
7300 * cdef Uint8 rv
7301 *
7302 * if self.has_alpha or self.surface.format.Amask: # <<<<<<<<<<<<<<
7303 *
7304 * if SDL_GetSurfaceAlphaMod(self.surface, &rv):
7305 */
7306 }
7307
7308 /* "pygame_sdl2/surface.pyx":473
7309 *
7310 * else:
7311 * return None # <<<<<<<<<<<<<<
7312 *
7313 * def lock(self, lock=None):
7314 */
7315 /*else*/ {
7316 __Pyx_XDECREF(__pyx_r);
7317 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7318 goto __pyx_L0;
7319 }
7320
7321 /* "pygame_sdl2/surface.pyx":462
7322 * raise error()
7323 *
7324 * def get_alpha(self): # <<<<<<<<<<<<<<
7325 * cdef Uint8 rv
7326 *
7327 */
7328
7329 /* function exit code */
7330 __pyx_L1_error:;
7331 __Pyx_XDECREF(__pyx_t_3);
7332 __Pyx_XDECREF(__pyx_t_4);
7333 __Pyx_XDECREF(__pyx_t_5);
7334 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_alpha", __pyx_clineno, __pyx_lineno, __pyx_filename);
7335 __pyx_r = NULL;
7336 __pyx_L0:;
7337 __Pyx_XGIVEREF(__pyx_r);
7338 __Pyx_RefNannyFinishContext();
7339 return __pyx_r;
7340 }
7341
7342 /* "pygame_sdl2/surface.pyx":475
7343 * return None
7344 *
7345 * def lock(self, lock=None): # <<<<<<<<<<<<<<
7346 * cdef Surface root = self
7347 *
7348 */
7349
7350 /* Python wrapper */
7351 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_31lock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_31lock(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7352 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_31lock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7353 PyObject *__pyx_v_lock = 0;
7354 int __pyx_lineno = 0;
7355 const char *__pyx_filename = NULL;
7356 int __pyx_clineno = 0;
7357 PyObject *__pyx_r = 0;
7358 __Pyx_RefNannyDeclarations
7359 __Pyx_RefNannySetupContext("lock (wrapper)", 0);
7360 {
7361 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lock,0};
7362 PyObject* values[1] = {0};
7363 values[0] = ((PyObject *)Py_None);
7364 if (unlikely(__pyx_kwds)) {
7365 Py_ssize_t kw_args;
7366 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7367 switch (pos_args) {
7368 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7369 CYTHON_FALLTHROUGH;
7370 case 0: break;
7371 default: goto __pyx_L5_argtuple_error;
7372 }
7373 kw_args = PyDict_Size(__pyx_kwds);
7374 switch (pos_args) {
7375 case 0:
7376 if (kw_args > 0) {
7377 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lock);
7378 if (value) { values[0] = value; kw_args--; }
7379 }
7380 }
7381 if (unlikely(kw_args > 0)) {
7382 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lock") < 0)) __PYX_ERR(0, 475, __pyx_L3_error)
7383 }
7384 } else {
7385 switch (PyTuple_GET_SIZE(__pyx_args)) {
7386 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7387 CYTHON_FALLTHROUGH;
7388 case 0: break;
7389 default: goto __pyx_L5_argtuple_error;
7390 }
7391 }
7392 __pyx_v_lock = values[0];
7393 }
7394 goto __pyx_L4_argument_unpacking_done;
7395 __pyx_L5_argtuple_error:;
7396 __Pyx_RaiseArgtupleInvalid("lock", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 475, __pyx_L3_error)
7397 __pyx_L3_error:;
7398 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.lock", __pyx_clineno, __pyx_lineno, __pyx_filename);
7399 __Pyx_RefNannyFinishContext();
7400 return NULL;
7401 __pyx_L4_argument_unpacking_done:;
7402 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_30lock(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_lock);
7403
7404 /* function exit code */
7405 __Pyx_RefNannyFinishContext();
7406 return __pyx_r;
7407 }
7408
__pyx_pf_11pygame_sdl2_7surface_7Surface_30lock(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_lock)7409 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_30lock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_lock) {
7410 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_root = 0;
7411 PyObject *__pyx_r = NULL;
7412 __Pyx_RefNannyDeclarations
7413 int __pyx_t_1;
7414 PyObject *__pyx_t_2 = NULL;
7415 int __pyx_t_3;
7416 int __pyx_t_4;
7417 PyObject *__pyx_t_5 = NULL;
7418 PyObject *__pyx_t_6 = NULL;
7419 int __pyx_lineno = 0;
7420 const char *__pyx_filename = NULL;
7421 int __pyx_clineno = 0;
7422 __Pyx_RefNannySetupContext("lock", 0);
7423 __Pyx_INCREF(__pyx_v_lock);
7424
7425 /* "pygame_sdl2/surface.pyx":476
7426 *
7427 * def lock(self, lock=None):
7428 * cdef Surface root = self # <<<<<<<<<<<<<<
7429 *
7430 * while root.parent:
7431 */
7432 __Pyx_INCREF(((PyObject *)__pyx_v_self));
7433 __pyx_v_root = __pyx_v_self;
7434
7435 /* "pygame_sdl2/surface.pyx":478
7436 * cdef Surface root = self
7437 *
7438 * while root.parent: # <<<<<<<<<<<<<<
7439 * root = root.parent
7440 *
7441 */
7442 while (1) {
7443 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_root->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 478, __pyx_L1_error)
7444 if (!__pyx_t_1) break;
7445
7446 /* "pygame_sdl2/surface.pyx":479
7447 *
7448 * while root.parent:
7449 * root = root.parent # <<<<<<<<<<<<<<
7450 *
7451 * if lock is None:
7452 */
7453 __pyx_t_2 = ((PyObject *)__pyx_v_root->parent);
7454 __Pyx_INCREF(__pyx_t_2);
7455 __Pyx_DECREF_SET(__pyx_v_root, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
7456 __pyx_t_2 = 0;
7457 }
7458
7459 /* "pygame_sdl2/surface.pyx":481
7460 * root = root.parent
7461 *
7462 * if lock is None: # <<<<<<<<<<<<<<
7463 * lock = self
7464 *
7465 */
7466 __pyx_t_1 = (__pyx_v_lock == Py_None);
7467 __pyx_t_3 = (__pyx_t_1 != 0);
7468 if (__pyx_t_3) {
7469
7470 /* "pygame_sdl2/surface.pyx":482
7471 *
7472 * if lock is None:
7473 * lock = self # <<<<<<<<<<<<<<
7474 *
7475 * if root.locklist is None:
7476 */
7477 __Pyx_INCREF(((PyObject *)__pyx_v_self));
7478 __Pyx_DECREF_SET(__pyx_v_lock, ((PyObject *)__pyx_v_self));
7479
7480 /* "pygame_sdl2/surface.pyx":481
7481 * root = root.parent
7482 *
7483 * if lock is None: # <<<<<<<<<<<<<<
7484 * lock = self
7485 *
7486 */
7487 }
7488
7489 /* "pygame_sdl2/surface.pyx":484
7490 * lock = self
7491 *
7492 * if root.locklist is None: # <<<<<<<<<<<<<<
7493 * root.locklist = [ ]
7494 *
7495 */
7496 __pyx_t_3 = (__pyx_v_root->locklist == Py_None);
7497 __pyx_t_1 = (__pyx_t_3 != 0);
7498 if (__pyx_t_1) {
7499
7500 /* "pygame_sdl2/surface.pyx":485
7501 *
7502 * if root.locklist is None:
7503 * root.locklist = [ ] # <<<<<<<<<<<<<<
7504 *
7505 * root.locklist.append(lock)
7506 */
7507 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 485, __pyx_L1_error)
7508 __Pyx_GOTREF(__pyx_t_2);
7509 __Pyx_GIVEREF(__pyx_t_2);
7510 __Pyx_GOTREF(__pyx_v_root->locklist);
7511 __Pyx_DECREF(__pyx_v_root->locklist);
7512 __pyx_v_root->locklist = __pyx_t_2;
7513 __pyx_t_2 = 0;
7514
7515 /* "pygame_sdl2/surface.pyx":484
7516 * lock = self
7517 *
7518 * if root.locklist is None: # <<<<<<<<<<<<<<
7519 * root.locklist = [ ]
7520 *
7521 */
7522 }
7523
7524 /* "pygame_sdl2/surface.pyx":487
7525 * root.locklist = [ ]
7526 *
7527 * root.locklist.append(lock) # <<<<<<<<<<<<<<
7528 *
7529 * if SDL_LockSurface(root.surface):
7530 */
7531 __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_root->locklist, __pyx_v_lock); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 487, __pyx_L1_error)
7532
7533 /* "pygame_sdl2/surface.pyx":489
7534 * root.locklist.append(lock)
7535 *
7536 * if SDL_LockSurface(root.surface): # <<<<<<<<<<<<<<
7537 * raise error()
7538 *
7539 */
7540 __pyx_t_1 = (SDL_LockSurface(__pyx_v_root->surface) != 0);
7541 if (unlikely(__pyx_t_1)) {
7542
7543 /* "pygame_sdl2/surface.pyx":490
7544 *
7545 * if SDL_LockSurface(root.surface):
7546 * raise error() # <<<<<<<<<<<<<<
7547 *
7548 * def unlock(self, lock=None):
7549 */
7550 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 490, __pyx_L1_error)
7551 __Pyx_GOTREF(__pyx_t_5);
7552 __pyx_t_6 = NULL;
7553 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
7554 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
7555 if (likely(__pyx_t_6)) {
7556 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7557 __Pyx_INCREF(__pyx_t_6);
7558 __Pyx_INCREF(function);
7559 __Pyx_DECREF_SET(__pyx_t_5, function);
7560 }
7561 }
7562 __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
7563 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7564 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error)
7565 __Pyx_GOTREF(__pyx_t_2);
7566 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7567 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
7568 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7569 __PYX_ERR(0, 490, __pyx_L1_error)
7570
7571 /* "pygame_sdl2/surface.pyx":489
7572 * root.locklist.append(lock)
7573 *
7574 * if SDL_LockSurface(root.surface): # <<<<<<<<<<<<<<
7575 * raise error()
7576 *
7577 */
7578 }
7579
7580 /* "pygame_sdl2/surface.pyx":475
7581 * return None
7582 *
7583 * def lock(self, lock=None): # <<<<<<<<<<<<<<
7584 * cdef Surface root = self
7585 *
7586 */
7587
7588 /* function exit code */
7589 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7590 goto __pyx_L0;
7591 __pyx_L1_error:;
7592 __Pyx_XDECREF(__pyx_t_2);
7593 __Pyx_XDECREF(__pyx_t_5);
7594 __Pyx_XDECREF(__pyx_t_6);
7595 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.lock", __pyx_clineno, __pyx_lineno, __pyx_filename);
7596 __pyx_r = NULL;
7597 __pyx_L0:;
7598 __Pyx_XDECREF((PyObject *)__pyx_v_root);
7599 __Pyx_XDECREF(__pyx_v_lock);
7600 __Pyx_XGIVEREF(__pyx_r);
7601 __Pyx_RefNannyFinishContext();
7602 return __pyx_r;
7603 }
7604
7605 /* "pygame_sdl2/surface.pyx":492
7606 * raise error()
7607 *
7608 * def unlock(self, lock=None): # <<<<<<<<<<<<<<
7609 * cdef Surface root = self
7610 *
7611 */
7612
7613 /* Python wrapper */
7614 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_33unlock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_33unlock(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7615 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_33unlock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7616 PyObject *__pyx_v_lock = 0;
7617 int __pyx_lineno = 0;
7618 const char *__pyx_filename = NULL;
7619 int __pyx_clineno = 0;
7620 PyObject *__pyx_r = 0;
7621 __Pyx_RefNannyDeclarations
7622 __Pyx_RefNannySetupContext("unlock (wrapper)", 0);
7623 {
7624 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lock,0};
7625 PyObject* values[1] = {0};
7626 values[0] = ((PyObject *)Py_None);
7627 if (unlikely(__pyx_kwds)) {
7628 Py_ssize_t kw_args;
7629 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7630 switch (pos_args) {
7631 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7632 CYTHON_FALLTHROUGH;
7633 case 0: break;
7634 default: goto __pyx_L5_argtuple_error;
7635 }
7636 kw_args = PyDict_Size(__pyx_kwds);
7637 switch (pos_args) {
7638 case 0:
7639 if (kw_args > 0) {
7640 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lock);
7641 if (value) { values[0] = value; kw_args--; }
7642 }
7643 }
7644 if (unlikely(kw_args > 0)) {
7645 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unlock") < 0)) __PYX_ERR(0, 492, __pyx_L3_error)
7646 }
7647 } else {
7648 switch (PyTuple_GET_SIZE(__pyx_args)) {
7649 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7650 CYTHON_FALLTHROUGH;
7651 case 0: break;
7652 default: goto __pyx_L5_argtuple_error;
7653 }
7654 }
7655 __pyx_v_lock = values[0];
7656 }
7657 goto __pyx_L4_argument_unpacking_done;
7658 __pyx_L5_argtuple_error:;
7659 __Pyx_RaiseArgtupleInvalid("unlock", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 492, __pyx_L3_error)
7660 __pyx_L3_error:;
7661 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
7662 __Pyx_RefNannyFinishContext();
7663 return NULL;
7664 __pyx_L4_argument_unpacking_done:;
7665 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_32unlock(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_lock);
7666
7667 /* function exit code */
7668 __Pyx_RefNannyFinishContext();
7669 return __pyx_r;
7670 }
7671
__pyx_pf_11pygame_sdl2_7surface_7Surface_32unlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_lock)7672 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_32unlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_lock) {
7673 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_root = 0;
7674 PyObject *__pyx_r = NULL;
7675 __Pyx_RefNannyDeclarations
7676 int __pyx_t_1;
7677 PyObject *__pyx_t_2 = NULL;
7678 int __pyx_t_3;
7679 PyObject *__pyx_t_4 = NULL;
7680 PyObject *__pyx_t_5 = NULL;
7681 int __pyx_lineno = 0;
7682 const char *__pyx_filename = NULL;
7683 int __pyx_clineno = 0;
7684 __Pyx_RefNannySetupContext("unlock", 0);
7685 __Pyx_INCREF(__pyx_v_lock);
7686
7687 /* "pygame_sdl2/surface.pyx":493
7688 *
7689 * def unlock(self, lock=None):
7690 * cdef Surface root = self # <<<<<<<<<<<<<<
7691 *
7692 * while root.parent:
7693 */
7694 __Pyx_INCREF(((PyObject *)__pyx_v_self));
7695 __pyx_v_root = __pyx_v_self;
7696
7697 /* "pygame_sdl2/surface.pyx":495
7698 * cdef Surface root = self
7699 *
7700 * while root.parent: # <<<<<<<<<<<<<<
7701 * root = root.parent
7702 *
7703 */
7704 while (1) {
7705 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_root->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
7706 if (!__pyx_t_1) break;
7707
7708 /* "pygame_sdl2/surface.pyx":496
7709 *
7710 * while root.parent:
7711 * root = root.parent # <<<<<<<<<<<<<<
7712 *
7713 * if lock is None:
7714 */
7715 __pyx_t_2 = ((PyObject *)__pyx_v_root->parent);
7716 __Pyx_INCREF(__pyx_t_2);
7717 __Pyx_DECREF_SET(__pyx_v_root, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
7718 __pyx_t_2 = 0;
7719 }
7720
7721 /* "pygame_sdl2/surface.pyx":498
7722 * root = root.parent
7723 *
7724 * if lock is None: # <<<<<<<<<<<<<<
7725 * lock = self
7726 *
7727 */
7728 __pyx_t_1 = (__pyx_v_lock == Py_None);
7729 __pyx_t_3 = (__pyx_t_1 != 0);
7730 if (__pyx_t_3) {
7731
7732 /* "pygame_sdl2/surface.pyx":499
7733 *
7734 * if lock is None:
7735 * lock = self # <<<<<<<<<<<<<<
7736 *
7737 * if root.locklist is None:
7738 */
7739 __Pyx_INCREF(((PyObject *)__pyx_v_self));
7740 __Pyx_DECREF_SET(__pyx_v_lock, ((PyObject *)__pyx_v_self));
7741
7742 /* "pygame_sdl2/surface.pyx":498
7743 * root = root.parent
7744 *
7745 * if lock is None: # <<<<<<<<<<<<<<
7746 * lock = self
7747 *
7748 */
7749 }
7750
7751 /* "pygame_sdl2/surface.pyx":501
7752 * lock = self
7753 *
7754 * if root.locklist is None: # <<<<<<<<<<<<<<
7755 * root.locklist = [ ]
7756 *
7757 */
7758 __pyx_t_3 = (__pyx_v_root->locklist == Py_None);
7759 __pyx_t_1 = (__pyx_t_3 != 0);
7760 if (__pyx_t_1) {
7761
7762 /* "pygame_sdl2/surface.pyx":502
7763 *
7764 * if root.locklist is None:
7765 * root.locklist = [ ] # <<<<<<<<<<<<<<
7766 *
7767 * root.locklist.remove(lock)
7768 */
7769 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 502, __pyx_L1_error)
7770 __Pyx_GOTREF(__pyx_t_2);
7771 __Pyx_GIVEREF(__pyx_t_2);
7772 __Pyx_GOTREF(__pyx_v_root->locklist);
7773 __Pyx_DECREF(__pyx_v_root->locklist);
7774 __pyx_v_root->locklist = __pyx_t_2;
7775 __pyx_t_2 = 0;
7776
7777 /* "pygame_sdl2/surface.pyx":501
7778 * lock = self
7779 *
7780 * if root.locklist is None: # <<<<<<<<<<<<<<
7781 * root.locklist = [ ]
7782 *
7783 */
7784 }
7785
7786 /* "pygame_sdl2/surface.pyx":504
7787 * root.locklist = [ ]
7788 *
7789 * root.locklist.remove(lock) # <<<<<<<<<<<<<<
7790 *
7791 * SDL_UnlockSurface(root.surface)
7792 */
7793 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_root->locklist, __pyx_n_s_remove); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
7794 __Pyx_GOTREF(__pyx_t_4);
7795 __pyx_t_5 = NULL;
7796 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
7797 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
7798 if (likely(__pyx_t_5)) {
7799 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
7800 __Pyx_INCREF(__pyx_t_5);
7801 __Pyx_INCREF(function);
7802 __Pyx_DECREF_SET(__pyx_t_4, function);
7803 }
7804 }
7805 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_lock) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_lock);
7806 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7807 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error)
7808 __Pyx_GOTREF(__pyx_t_2);
7809 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7810 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7811
7812 /* "pygame_sdl2/surface.pyx":506
7813 * root.locklist.remove(lock)
7814 *
7815 * SDL_UnlockSurface(root.surface) # <<<<<<<<<<<<<<
7816 *
7817 * def mustlock(self):
7818 */
7819 SDL_UnlockSurface(__pyx_v_root->surface);
7820
7821 /* "pygame_sdl2/surface.pyx":492
7822 * raise error()
7823 *
7824 * def unlock(self, lock=None): # <<<<<<<<<<<<<<
7825 * cdef Surface root = self
7826 *
7827 */
7828
7829 /* function exit code */
7830 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7831 goto __pyx_L0;
7832 __pyx_L1_error:;
7833 __Pyx_XDECREF(__pyx_t_2);
7834 __Pyx_XDECREF(__pyx_t_4);
7835 __Pyx_XDECREF(__pyx_t_5);
7836 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
7837 __pyx_r = NULL;
7838 __pyx_L0:;
7839 __Pyx_XDECREF((PyObject *)__pyx_v_root);
7840 __Pyx_XDECREF(__pyx_v_lock);
7841 __Pyx_XGIVEREF(__pyx_r);
7842 __Pyx_RefNannyFinishContext();
7843 return __pyx_r;
7844 }
7845
7846 /* "pygame_sdl2/surface.pyx":508
7847 * SDL_UnlockSurface(root.surface)
7848 *
7849 * def mustlock(self): # <<<<<<<<<<<<<<
7850 * cdef Surface root = self
7851 *
7852 */
7853
7854 /* Python wrapper */
7855 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_35mustlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_35mustlock(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)7856 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_35mustlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
7857 PyObject *__pyx_r = 0;
7858 __Pyx_RefNannyDeclarations
7859 __Pyx_RefNannySetupContext("mustlock (wrapper)", 0);
7860 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_34mustlock(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
7861
7862 /* function exit code */
7863 __Pyx_RefNannyFinishContext();
7864 return __pyx_r;
7865 }
7866
__pyx_pf_11pygame_sdl2_7surface_7Surface_34mustlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)7867 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_34mustlock(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
7868 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_root = 0;
7869 PyObject *__pyx_r = NULL;
7870 __Pyx_RefNannyDeclarations
7871 int __pyx_t_1;
7872 PyObject *__pyx_t_2 = NULL;
7873 int __pyx_lineno = 0;
7874 const char *__pyx_filename = NULL;
7875 int __pyx_clineno = 0;
7876 __Pyx_RefNannySetupContext("mustlock", 0);
7877
7878 /* "pygame_sdl2/surface.pyx":509
7879 *
7880 * def mustlock(self):
7881 * cdef Surface root = self # <<<<<<<<<<<<<<
7882 *
7883 * while root.parent:
7884 */
7885 __Pyx_INCREF(((PyObject *)__pyx_v_self));
7886 __pyx_v_root = __pyx_v_self;
7887
7888 /* "pygame_sdl2/surface.pyx":511
7889 * cdef Surface root = self
7890 *
7891 * while root.parent: # <<<<<<<<<<<<<<
7892 * root = root.parent
7893 *
7894 */
7895 while (1) {
7896 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_root->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 511, __pyx_L1_error)
7897 if (!__pyx_t_1) break;
7898
7899 /* "pygame_sdl2/surface.pyx":512
7900 *
7901 * while root.parent:
7902 * root = root.parent # <<<<<<<<<<<<<<
7903 *
7904 * return SDL_MUSTLOCK(root.surface)
7905 */
7906 __pyx_t_2 = ((PyObject *)__pyx_v_root->parent);
7907 __Pyx_INCREF(__pyx_t_2);
7908 __Pyx_DECREF_SET(__pyx_v_root, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
7909 __pyx_t_2 = 0;
7910 }
7911
7912 /* "pygame_sdl2/surface.pyx":514
7913 * root = root.parent
7914 *
7915 * return SDL_MUSTLOCK(root.surface) # <<<<<<<<<<<<<<
7916 *
7917 * def get_locked(self):
7918 */
7919 __Pyx_XDECREF(__pyx_r);
7920 __pyx_t_2 = __Pyx_PyInt_From_int(SDL_MUSTLOCK(__pyx_v_root->surface)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 514, __pyx_L1_error)
7921 __Pyx_GOTREF(__pyx_t_2);
7922 __pyx_r = __pyx_t_2;
7923 __pyx_t_2 = 0;
7924 goto __pyx_L0;
7925
7926 /* "pygame_sdl2/surface.pyx":508
7927 * SDL_UnlockSurface(root.surface)
7928 *
7929 * def mustlock(self): # <<<<<<<<<<<<<<
7930 * cdef Surface root = self
7931 *
7932 */
7933
7934 /* function exit code */
7935 __pyx_L1_error:;
7936 __Pyx_XDECREF(__pyx_t_2);
7937 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.mustlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
7938 __pyx_r = NULL;
7939 __pyx_L0:;
7940 __Pyx_XDECREF((PyObject *)__pyx_v_root);
7941 __Pyx_XGIVEREF(__pyx_r);
7942 __Pyx_RefNannyFinishContext();
7943 return __pyx_r;
7944 }
7945
7946 /* "pygame_sdl2/surface.pyx":516
7947 * return SDL_MUSTLOCK(root.surface)
7948 *
7949 * def get_locked(self): # <<<<<<<<<<<<<<
7950 * if self.locklist:
7951 * return True
7952 */
7953
7954 /* Python wrapper */
7955 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_37get_locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_37get_locked(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)7956 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_37get_locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
7957 PyObject *__pyx_r = 0;
7958 __Pyx_RefNannyDeclarations
7959 __Pyx_RefNannySetupContext("get_locked (wrapper)", 0);
7960 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_36get_locked(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
7961
7962 /* function exit code */
7963 __Pyx_RefNannyFinishContext();
7964 return __pyx_r;
7965 }
7966
__pyx_pf_11pygame_sdl2_7surface_7Surface_36get_locked(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)7967 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_36get_locked(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
7968 PyObject *__pyx_r = NULL;
7969 __Pyx_RefNannyDeclarations
7970 int __pyx_t_1;
7971 int __pyx_lineno = 0;
7972 const char *__pyx_filename = NULL;
7973 int __pyx_clineno = 0;
7974 __Pyx_RefNannySetupContext("get_locked", 0);
7975
7976 /* "pygame_sdl2/surface.pyx":517
7977 *
7978 * def get_locked(self):
7979 * if self.locklist: # <<<<<<<<<<<<<<
7980 * return True
7981 *
7982 */
7983 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->locklist); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
7984 if (__pyx_t_1) {
7985
7986 /* "pygame_sdl2/surface.pyx":518
7987 * def get_locked(self):
7988 * if self.locklist:
7989 * return True # <<<<<<<<<<<<<<
7990 *
7991 * def get_locks(self):
7992 */
7993 __Pyx_XDECREF(__pyx_r);
7994 __Pyx_INCREF(Py_True);
7995 __pyx_r = Py_True;
7996 goto __pyx_L0;
7997
7998 /* "pygame_sdl2/surface.pyx":517
7999 *
8000 * def get_locked(self):
8001 * if self.locklist: # <<<<<<<<<<<<<<
8002 * return True
8003 *
8004 */
8005 }
8006
8007 /* "pygame_sdl2/surface.pyx":516
8008 * return SDL_MUSTLOCK(root.surface)
8009 *
8010 * def get_locked(self): # <<<<<<<<<<<<<<
8011 * if self.locklist:
8012 * return True
8013 */
8014
8015 /* function exit code */
8016 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8017 goto __pyx_L0;
8018 __pyx_L1_error:;
8019 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_locked", __pyx_clineno, __pyx_lineno, __pyx_filename);
8020 __pyx_r = NULL;
8021 __pyx_L0:;
8022 __Pyx_XGIVEREF(__pyx_r);
8023 __Pyx_RefNannyFinishContext();
8024 return __pyx_r;
8025 }
8026
8027 /* "pygame_sdl2/surface.pyx":520
8028 * return True
8029 *
8030 * def get_locks(self): # <<<<<<<<<<<<<<
8031 * cdef Surface root = self
8032 *
8033 */
8034
8035 /* Python wrapper */
8036 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_39get_locks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_39get_locks(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)8037 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_39get_locks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
8038 PyObject *__pyx_r = 0;
8039 __Pyx_RefNannyDeclarations
8040 __Pyx_RefNannySetupContext("get_locks (wrapper)", 0);
8041 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_38get_locks(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
8042
8043 /* function exit code */
8044 __Pyx_RefNannyFinishContext();
8045 return __pyx_r;
8046 }
8047
__pyx_pf_11pygame_sdl2_7surface_7Surface_38get_locks(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)8048 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_38get_locks(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
8049 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_root = 0;
8050 PyObject *__pyx_r = NULL;
8051 __Pyx_RefNannyDeclarations
8052 int __pyx_t_1;
8053 PyObject *__pyx_t_2 = NULL;
8054 int __pyx_t_3;
8055 int __pyx_lineno = 0;
8056 const char *__pyx_filename = NULL;
8057 int __pyx_clineno = 0;
8058 __Pyx_RefNannySetupContext("get_locks", 0);
8059
8060 /* "pygame_sdl2/surface.pyx":521
8061 *
8062 * def get_locks(self):
8063 * cdef Surface root = self # <<<<<<<<<<<<<<
8064 *
8065 * while root.parent:
8066 */
8067 __Pyx_INCREF(((PyObject *)__pyx_v_self));
8068 __pyx_v_root = __pyx_v_self;
8069
8070 /* "pygame_sdl2/surface.pyx":523
8071 * cdef Surface root = self
8072 *
8073 * while root.parent: # <<<<<<<<<<<<<<
8074 * root = root.parent
8075 *
8076 */
8077 while (1) {
8078 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_root->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
8079 if (!__pyx_t_1) break;
8080
8081 /* "pygame_sdl2/surface.pyx":524
8082 *
8083 * while root.parent:
8084 * root = root.parent # <<<<<<<<<<<<<<
8085 *
8086 * if root.locklist is None:
8087 */
8088 __pyx_t_2 = ((PyObject *)__pyx_v_root->parent);
8089 __Pyx_INCREF(__pyx_t_2);
8090 __Pyx_DECREF_SET(__pyx_v_root, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
8091 __pyx_t_2 = 0;
8092 }
8093
8094 /* "pygame_sdl2/surface.pyx":526
8095 * root = root.parent
8096 *
8097 * if root.locklist is None: # <<<<<<<<<<<<<<
8098 * root.locklist = [ ]
8099 *
8100 */
8101 __pyx_t_1 = (__pyx_v_root->locklist == Py_None);
8102 __pyx_t_3 = (__pyx_t_1 != 0);
8103 if (__pyx_t_3) {
8104
8105 /* "pygame_sdl2/surface.pyx":527
8106 *
8107 * if root.locklist is None:
8108 * root.locklist = [ ] # <<<<<<<<<<<<<<
8109 *
8110 * return root.locklist
8111 */
8112 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
8113 __Pyx_GOTREF(__pyx_t_2);
8114 __Pyx_GIVEREF(__pyx_t_2);
8115 __Pyx_GOTREF(__pyx_v_root->locklist);
8116 __Pyx_DECREF(__pyx_v_root->locklist);
8117 __pyx_v_root->locklist = __pyx_t_2;
8118 __pyx_t_2 = 0;
8119
8120 /* "pygame_sdl2/surface.pyx":526
8121 * root = root.parent
8122 *
8123 * if root.locklist is None: # <<<<<<<<<<<<<<
8124 * root.locklist = [ ]
8125 *
8126 */
8127 }
8128
8129 /* "pygame_sdl2/surface.pyx":529
8130 * root.locklist = [ ]
8131 *
8132 * return root.locklist # <<<<<<<<<<<<<<
8133 *
8134 * def get_at(self, pos):
8135 */
8136 __Pyx_XDECREF(__pyx_r);
8137 __Pyx_INCREF(__pyx_v_root->locklist);
8138 __pyx_r = __pyx_v_root->locklist;
8139 goto __pyx_L0;
8140
8141 /* "pygame_sdl2/surface.pyx":520
8142 * return True
8143 *
8144 * def get_locks(self): # <<<<<<<<<<<<<<
8145 * cdef Surface root = self
8146 *
8147 */
8148
8149 /* function exit code */
8150 __pyx_L1_error:;
8151 __Pyx_XDECREF(__pyx_t_2);
8152 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_locks", __pyx_clineno, __pyx_lineno, __pyx_filename);
8153 __pyx_r = NULL;
8154 __pyx_L0:;
8155 __Pyx_XDECREF((PyObject *)__pyx_v_root);
8156 __Pyx_XGIVEREF(__pyx_r);
8157 __Pyx_RefNannyFinishContext();
8158 return __pyx_r;
8159 }
8160
8161 /* "pygame_sdl2/surface.pyx":531
8162 * return root.locklist
8163 *
8164 * def get_at(self, pos): # <<<<<<<<<<<<<<
8165 * cdef int x, y
8166 * cdef Uint8 *p
8167 */
8168
8169 /* Python wrapper */
8170 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_41get_at(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_41get_at(PyObject * __pyx_v_self,PyObject * __pyx_v_pos)8171 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_41get_at(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) {
8172 PyObject *__pyx_r = 0;
8173 __Pyx_RefNannyDeclarations
8174 __Pyx_RefNannySetupContext("get_at (wrapper)", 0);
8175 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_40get_at(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_pos));
8176
8177 /* function exit code */
8178 __Pyx_RefNannyFinishContext();
8179 return __pyx_r;
8180 }
8181
__pyx_pf_11pygame_sdl2_7surface_7Surface_40get_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_pos)8182 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_40get_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos) {
8183 int __pyx_v_x;
8184 int __pyx_v_y;
8185 Uint8 *__pyx_v_p;
8186 Uint32 __pyx_v_pixel;
8187 PyObject *__pyx_r = NULL;
8188 __Pyx_RefNannyDeclarations
8189 PyObject *__pyx_t_1 = NULL;
8190 PyObject *__pyx_t_2 = NULL;
8191 PyObject *__pyx_t_3 = NULL;
8192 PyObject *(*__pyx_t_4)(PyObject *);
8193 int __pyx_t_5;
8194 int __pyx_t_6;
8195 int __pyx_t_7;
8196 int __pyx_t_8;
8197 int __pyx_t_9;
8198 int __pyx_lineno = 0;
8199 const char *__pyx_filename = NULL;
8200 int __pyx_clineno = 0;
8201 __Pyx_RefNannySetupContext("get_at", 0);
8202
8203 /* "pygame_sdl2/surface.pyx":535
8204 * cdef Uint8 *p
8205 *
8206 * x, y = pos # <<<<<<<<<<<<<<
8207 *
8208 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8209 */
8210 if ((likely(PyTuple_CheckExact(__pyx_v_pos))) || (PyList_CheckExact(__pyx_v_pos))) {
8211 PyObject* sequence = __pyx_v_pos;
8212 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8213 if (unlikely(size != 2)) {
8214 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
8215 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8216 __PYX_ERR(0, 535, __pyx_L1_error)
8217 }
8218 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8219 if (likely(PyTuple_CheckExact(sequence))) {
8220 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
8221 __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
8222 } else {
8223 __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
8224 __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
8225 }
8226 __Pyx_INCREF(__pyx_t_1);
8227 __Pyx_INCREF(__pyx_t_2);
8228 #else
8229 __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
8230 __Pyx_GOTREF(__pyx_t_1);
8231 __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
8232 __Pyx_GOTREF(__pyx_t_2);
8233 #endif
8234 } else {
8235 Py_ssize_t index = -1;
8236 __pyx_t_3 = PyObject_GetIter(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
8237 __Pyx_GOTREF(__pyx_t_3);
8238 __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
8239 index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
8240 __Pyx_GOTREF(__pyx_t_1);
8241 index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
8242 __Pyx_GOTREF(__pyx_t_2);
8243 if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) __PYX_ERR(0, 535, __pyx_L1_error)
8244 __pyx_t_4 = NULL;
8245 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8246 goto __pyx_L4_unpacking_done;
8247 __pyx_L3_unpacking_failed:;
8248 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8249 __pyx_t_4 = NULL;
8250 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8251 __PYX_ERR(0, 535, __pyx_L1_error)
8252 __pyx_L4_unpacking_done:;
8253 }
8254 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 535, __pyx_L1_error)
8255 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8256 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 535, __pyx_L1_error)
8257 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8258 __pyx_v_x = __pyx_t_5;
8259 __pyx_v_y = __pyx_t_6;
8260
8261 /* "pygame_sdl2/surface.pyx":537
8262 * x, y = pos
8263 *
8264 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8265 * raise IndexError("Position outside surface.")
8266 *
8267 */
8268 __pyx_t_8 = (0 <= __pyx_v_x);
8269 if (__pyx_t_8) {
8270 __pyx_t_8 = (__pyx_v_x < __pyx_v_self->surface->w);
8271 }
8272 __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
8273 if (!__pyx_t_9) {
8274 } else {
8275 __pyx_t_7 = __pyx_t_9;
8276 goto __pyx_L6_bool_binop_done;
8277 }
8278 __pyx_t_9 = (0 <= __pyx_v_y);
8279 if (__pyx_t_9) {
8280 __pyx_t_9 = (__pyx_v_y < __pyx_v_self->surface->h);
8281 }
8282 __pyx_t_8 = ((!(__pyx_t_9 != 0)) != 0);
8283 __pyx_t_7 = __pyx_t_8;
8284 __pyx_L6_bool_binop_done:;
8285 if (unlikely(__pyx_t_7)) {
8286
8287 /* "pygame_sdl2/surface.pyx":538
8288 *
8289 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8290 * raise IndexError("Position outside surface.") # <<<<<<<<<<<<<<
8291 *
8292 * if self.surface.format.BytesPerPixel != 4:
8293 */
8294 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
8295 __Pyx_GOTREF(__pyx_t_2);
8296 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8297 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8298 __PYX_ERR(0, 538, __pyx_L1_error)
8299
8300 /* "pygame_sdl2/surface.pyx":537
8301 * x, y = pos
8302 *
8303 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8304 * raise IndexError("Position outside surface.")
8305 *
8306 */
8307 }
8308
8309 /* "pygame_sdl2/surface.pyx":540
8310 * raise IndexError("Position outside surface.")
8311 *
8312 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
8313 * raise error("Surface has unsupported bytesize.")
8314 *
8315 */
8316 __pyx_t_7 = ((__pyx_v_self->surface->format->BytesPerPixel != 4) != 0);
8317 if (unlikely(__pyx_t_7)) {
8318
8319 /* "pygame_sdl2/surface.pyx":541
8320 *
8321 * if self.surface.format.BytesPerPixel != 4:
8322 * raise error("Surface has unsupported bytesize.") # <<<<<<<<<<<<<<
8323 *
8324 * self.lock()
8325 */
8326 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
8327 __Pyx_GOTREF(__pyx_t_1);
8328 __pyx_t_3 = NULL;
8329 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
8330 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8331 if (likely(__pyx_t_3)) {
8332 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8333 __Pyx_INCREF(__pyx_t_3);
8334 __Pyx_INCREF(function);
8335 __Pyx_DECREF_SET(__pyx_t_1, function);
8336 }
8337 }
8338 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_kp_s_Surface_has_unsupported_bytesize) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s_Surface_has_unsupported_bytesize);
8339 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8340 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 541, __pyx_L1_error)
8341 __Pyx_GOTREF(__pyx_t_2);
8342 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8343 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8344 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8345 __PYX_ERR(0, 541, __pyx_L1_error)
8346
8347 /* "pygame_sdl2/surface.pyx":540
8348 * raise IndexError("Position outside surface.")
8349 *
8350 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
8351 * raise error("Surface has unsupported bytesize.")
8352 *
8353 */
8354 }
8355
8356 /* "pygame_sdl2/surface.pyx":543
8357 * raise error("Surface has unsupported bytesize.")
8358 *
8359 * self.lock() # <<<<<<<<<<<<<<
8360 *
8361 * p = <Uint8 *> self.surface.pixels
8362 */
8363 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
8364 __Pyx_GOTREF(__pyx_t_1);
8365 __pyx_t_3 = NULL;
8366 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
8367 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8368 if (likely(__pyx_t_3)) {
8369 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8370 __Pyx_INCREF(__pyx_t_3);
8371 __Pyx_INCREF(function);
8372 __Pyx_DECREF_SET(__pyx_t_1, function);
8373 }
8374 }
8375 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
8376 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8377 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
8378 __Pyx_GOTREF(__pyx_t_2);
8379 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8380 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8381
8382 /* "pygame_sdl2/surface.pyx":545
8383 * self.lock()
8384 *
8385 * p = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
8386 * p += y * self.surface.pitch
8387 * p += x * 4
8388 */
8389 __pyx_v_p = ((Uint8 *)__pyx_v_self->surface->pixels);
8390
8391 /* "pygame_sdl2/surface.pyx":546
8392 *
8393 * p = <Uint8 *> self.surface.pixels
8394 * p += y * self.surface.pitch # <<<<<<<<<<<<<<
8395 * p += x * 4
8396 *
8397 */
8398 __pyx_v_p = (__pyx_v_p + (__pyx_v_y * __pyx_v_self->surface->pitch));
8399
8400 /* "pygame_sdl2/surface.pyx":547
8401 * p = <Uint8 *> self.surface.pixels
8402 * p += y * self.surface.pitch
8403 * p += x * 4 # <<<<<<<<<<<<<<
8404 *
8405 * cdef Uint32 pixel = (<Uint32 *> p)[0]
8406 */
8407 __pyx_v_p = (__pyx_v_p + (__pyx_v_x * 4));
8408
8409 /* "pygame_sdl2/surface.pyx":549
8410 * p += x * 4
8411 *
8412 * cdef Uint32 pixel = (<Uint32 *> p)[0] # <<<<<<<<<<<<<<
8413 *
8414 * self.unlock()
8415 */
8416 __pyx_v_pixel = (((Uint32 *)__pyx_v_p)[0]);
8417
8418 /* "pygame_sdl2/surface.pyx":551
8419 * cdef Uint32 pixel = (<Uint32 *> p)[0]
8420 *
8421 * self.unlock() # <<<<<<<<<<<<<<
8422 *
8423 * return get_color(pixel, self.surface)
8424 */
8425 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error)
8426 __Pyx_GOTREF(__pyx_t_1);
8427 __pyx_t_3 = NULL;
8428 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
8429 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8430 if (likely(__pyx_t_3)) {
8431 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8432 __Pyx_INCREF(__pyx_t_3);
8433 __Pyx_INCREF(function);
8434 __Pyx_DECREF_SET(__pyx_t_1, function);
8435 }
8436 }
8437 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
8438 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8439 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L1_error)
8440 __Pyx_GOTREF(__pyx_t_2);
8441 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8442 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8443
8444 /* "pygame_sdl2/surface.pyx":553
8445 * self.unlock()
8446 *
8447 * return get_color(pixel, self.surface) # <<<<<<<<<<<<<<
8448 *
8449 * def set_at(self, pos, color):
8450 */
8451 __Pyx_XDECREF(__pyx_r);
8452 __pyx_t_2 = __pyx_f_11pygame_sdl2_5color_get_color(__pyx_v_pixel, __pyx_v_self->surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 553, __pyx_L1_error)
8453 __Pyx_GOTREF(__pyx_t_2);
8454 __pyx_r = __pyx_t_2;
8455 __pyx_t_2 = 0;
8456 goto __pyx_L0;
8457
8458 /* "pygame_sdl2/surface.pyx":531
8459 * return root.locklist
8460 *
8461 * def get_at(self, pos): # <<<<<<<<<<<<<<
8462 * cdef int x, y
8463 * cdef Uint8 *p
8464 */
8465
8466 /* function exit code */
8467 __pyx_L1_error:;
8468 __Pyx_XDECREF(__pyx_t_1);
8469 __Pyx_XDECREF(__pyx_t_2);
8470 __Pyx_XDECREF(__pyx_t_3);
8471 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
8472 __pyx_r = NULL;
8473 __pyx_L0:;
8474 __Pyx_XGIVEREF(__pyx_r);
8475 __Pyx_RefNannyFinishContext();
8476 return __pyx_r;
8477 }
8478
8479 /* "pygame_sdl2/surface.pyx":555
8480 * return get_color(pixel, self.surface)
8481 *
8482 * def set_at(self, pos, color): # <<<<<<<<<<<<<<
8483 * cdef int x, y
8484 * cdef Uint8 *p
8485 */
8486
8487 /* Python wrapper */
8488 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_43set_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_43set_at(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8489 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_43set_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8490 PyObject *__pyx_v_pos = 0;
8491 PyObject *__pyx_v_color = 0;
8492 int __pyx_lineno = 0;
8493 const char *__pyx_filename = NULL;
8494 int __pyx_clineno = 0;
8495 PyObject *__pyx_r = 0;
8496 __Pyx_RefNannyDeclarations
8497 __Pyx_RefNannySetupContext("set_at (wrapper)", 0);
8498 {
8499 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pos,&__pyx_n_s_color,0};
8500 PyObject* values[2] = {0,0};
8501 if (unlikely(__pyx_kwds)) {
8502 Py_ssize_t kw_args;
8503 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8504 switch (pos_args) {
8505 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8506 CYTHON_FALLTHROUGH;
8507 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8508 CYTHON_FALLTHROUGH;
8509 case 0: break;
8510 default: goto __pyx_L5_argtuple_error;
8511 }
8512 kw_args = PyDict_Size(__pyx_kwds);
8513 switch (pos_args) {
8514 case 0:
8515 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--;
8516 else goto __pyx_L5_argtuple_error;
8517 CYTHON_FALLTHROUGH;
8518 case 1:
8519 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_color)) != 0)) kw_args--;
8520 else {
8521 __Pyx_RaiseArgtupleInvalid("set_at", 1, 2, 2, 1); __PYX_ERR(0, 555, __pyx_L3_error)
8522 }
8523 }
8524 if (unlikely(kw_args > 0)) {
8525 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_at") < 0)) __PYX_ERR(0, 555, __pyx_L3_error)
8526 }
8527 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
8528 goto __pyx_L5_argtuple_error;
8529 } else {
8530 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8531 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8532 }
8533 __pyx_v_pos = values[0];
8534 __pyx_v_color = values[1];
8535 }
8536 goto __pyx_L4_argument_unpacking_done;
8537 __pyx_L5_argtuple_error:;
8538 __Pyx_RaiseArgtupleInvalid("set_at", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 555, __pyx_L3_error)
8539 __pyx_L3_error:;
8540 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
8541 __Pyx_RefNannyFinishContext();
8542 return NULL;
8543 __pyx_L4_argument_unpacking_done:;
8544 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_42set_at(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_pos, __pyx_v_color);
8545
8546 /* function exit code */
8547 __Pyx_RefNannyFinishContext();
8548 return __pyx_r;
8549 }
8550
__pyx_pf_11pygame_sdl2_7surface_7Surface_42set_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_pos,PyObject * __pyx_v_color)8551 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_42set_at(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos, PyObject *__pyx_v_color) {
8552 int __pyx_v_x;
8553 int __pyx_v_y;
8554 Uint8 *__pyx_v_p;
8555 Uint32 __pyx_v_pixel;
8556 PyObject *__pyx_r = NULL;
8557 __Pyx_RefNannyDeclarations
8558 PyObject *__pyx_t_1 = NULL;
8559 PyObject *__pyx_t_2 = NULL;
8560 PyObject *__pyx_t_3 = NULL;
8561 PyObject *(*__pyx_t_4)(PyObject *);
8562 int __pyx_t_5;
8563 int __pyx_t_6;
8564 int __pyx_t_7;
8565 int __pyx_t_8;
8566 int __pyx_t_9;
8567 Uint32 __pyx_t_10;
8568 int __pyx_lineno = 0;
8569 const char *__pyx_filename = NULL;
8570 int __pyx_clineno = 0;
8571 __Pyx_RefNannySetupContext("set_at", 0);
8572
8573 /* "pygame_sdl2/surface.pyx":560
8574 * cdef Uint32 pixel
8575 *
8576 * x, y = pos # <<<<<<<<<<<<<<
8577 *
8578 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8579 */
8580 if ((likely(PyTuple_CheckExact(__pyx_v_pos))) || (PyList_CheckExact(__pyx_v_pos))) {
8581 PyObject* sequence = __pyx_v_pos;
8582 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8583 if (unlikely(size != 2)) {
8584 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
8585 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8586 __PYX_ERR(0, 560, __pyx_L1_error)
8587 }
8588 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8589 if (likely(PyTuple_CheckExact(sequence))) {
8590 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
8591 __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
8592 } else {
8593 __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
8594 __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
8595 }
8596 __Pyx_INCREF(__pyx_t_1);
8597 __Pyx_INCREF(__pyx_t_2);
8598 #else
8599 __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
8600 __Pyx_GOTREF(__pyx_t_1);
8601 __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L1_error)
8602 __Pyx_GOTREF(__pyx_t_2);
8603 #endif
8604 } else {
8605 Py_ssize_t index = -1;
8606 __pyx_t_3 = PyObject_GetIter(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 560, __pyx_L1_error)
8607 __Pyx_GOTREF(__pyx_t_3);
8608 __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
8609 index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
8610 __Pyx_GOTREF(__pyx_t_1);
8611 index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
8612 __Pyx_GOTREF(__pyx_t_2);
8613 if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
8614 __pyx_t_4 = NULL;
8615 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8616 goto __pyx_L4_unpacking_done;
8617 __pyx_L3_unpacking_failed:;
8618 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8619 __pyx_t_4 = NULL;
8620 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8621 __PYX_ERR(0, 560, __pyx_L1_error)
8622 __pyx_L4_unpacking_done:;
8623 }
8624 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 560, __pyx_L1_error)
8625 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8626 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 560, __pyx_L1_error)
8627 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8628 __pyx_v_x = __pyx_t_5;
8629 __pyx_v_y = __pyx_t_6;
8630
8631 /* "pygame_sdl2/surface.pyx":562
8632 * x, y = pos
8633 *
8634 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8635 * raise ValueError("Position outside surface.")
8636 *
8637 */
8638 __pyx_t_8 = (0 <= __pyx_v_x);
8639 if (__pyx_t_8) {
8640 __pyx_t_8 = (__pyx_v_x < __pyx_v_self->surface->w);
8641 }
8642 __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
8643 if (!__pyx_t_9) {
8644 } else {
8645 __pyx_t_7 = __pyx_t_9;
8646 goto __pyx_L6_bool_binop_done;
8647 }
8648 __pyx_t_9 = (0 <= __pyx_v_y);
8649 if (__pyx_t_9) {
8650 __pyx_t_9 = (__pyx_v_y < __pyx_v_self->surface->h);
8651 }
8652 __pyx_t_8 = ((!(__pyx_t_9 != 0)) != 0);
8653 __pyx_t_7 = __pyx_t_8;
8654 __pyx_L6_bool_binop_done:;
8655 if (unlikely(__pyx_t_7)) {
8656
8657 /* "pygame_sdl2/surface.pyx":563
8658 *
8659 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8660 * raise ValueError("Position outside surface.") # <<<<<<<<<<<<<<
8661 *
8662 * if self.surface.format.BytesPerPixel != 4:
8663 */
8664 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error)
8665 __Pyx_GOTREF(__pyx_t_2);
8666 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8667 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8668 __PYX_ERR(0, 563, __pyx_L1_error)
8669
8670 /* "pygame_sdl2/surface.pyx":562
8671 * x, y = pos
8672 *
8673 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8674 * raise ValueError("Position outside surface.")
8675 *
8676 */
8677 }
8678
8679 /* "pygame_sdl2/surface.pyx":565
8680 * raise ValueError("Position outside surface.")
8681 *
8682 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
8683 * raise error("Surface has unsupported bytesize.")
8684 *
8685 */
8686 __pyx_t_7 = ((__pyx_v_self->surface->format->BytesPerPixel != 4) != 0);
8687 if (unlikely(__pyx_t_7)) {
8688
8689 /* "pygame_sdl2/surface.pyx":566
8690 *
8691 * if self.surface.format.BytesPerPixel != 4:
8692 * raise error("Surface has unsupported bytesize.") # <<<<<<<<<<<<<<
8693 *
8694 * pixel = map_color(self.surface, color)
8695 */
8696 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
8697 __Pyx_GOTREF(__pyx_t_1);
8698 __pyx_t_3 = NULL;
8699 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
8700 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8701 if (likely(__pyx_t_3)) {
8702 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8703 __Pyx_INCREF(__pyx_t_3);
8704 __Pyx_INCREF(function);
8705 __Pyx_DECREF_SET(__pyx_t_1, function);
8706 }
8707 }
8708 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_kp_s_Surface_has_unsupported_bytesize) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s_Surface_has_unsupported_bytesize);
8709 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8710 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 566, __pyx_L1_error)
8711 __Pyx_GOTREF(__pyx_t_2);
8712 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8713 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8714 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8715 __PYX_ERR(0, 566, __pyx_L1_error)
8716
8717 /* "pygame_sdl2/surface.pyx":565
8718 * raise ValueError("Position outside surface.")
8719 *
8720 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
8721 * raise error("Surface has unsupported bytesize.")
8722 *
8723 */
8724 }
8725
8726 /* "pygame_sdl2/surface.pyx":568
8727 * raise error("Surface has unsupported bytesize.")
8728 *
8729 * pixel = map_color(self.surface, color) # <<<<<<<<<<<<<<
8730 *
8731 * self.lock()
8732 */
8733 __pyx_t_10 = __pyx_f_11pygame_sdl2_5color_map_color(__pyx_v_self->surface, __pyx_v_color); if (unlikely(__pyx_t_10 == ((Uint32)0xaabbccdd) && PyErr_Occurred())) __PYX_ERR(0, 568, __pyx_L1_error)
8734 __pyx_v_pixel = __pyx_t_10;
8735
8736 /* "pygame_sdl2/surface.pyx":570
8737 * pixel = map_color(self.surface, color)
8738 *
8739 * self.lock() # <<<<<<<<<<<<<<
8740 *
8741 * p = <Uint8 *> self.surface.pixels
8742 */
8743 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
8744 __Pyx_GOTREF(__pyx_t_1);
8745 __pyx_t_3 = NULL;
8746 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
8747 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8748 if (likely(__pyx_t_3)) {
8749 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8750 __Pyx_INCREF(__pyx_t_3);
8751 __Pyx_INCREF(function);
8752 __Pyx_DECREF_SET(__pyx_t_1, function);
8753 }
8754 }
8755 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
8756 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8757 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __pyx_L1_error)
8758 __Pyx_GOTREF(__pyx_t_2);
8759 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8760 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8761
8762 /* "pygame_sdl2/surface.pyx":572
8763 * self.lock()
8764 *
8765 * p = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
8766 * p += y * self.surface.pitch
8767 * p += x * 4
8768 */
8769 __pyx_v_p = ((Uint8 *)__pyx_v_self->surface->pixels);
8770
8771 /* "pygame_sdl2/surface.pyx":573
8772 *
8773 * p = <Uint8 *> self.surface.pixels
8774 * p += y * self.surface.pitch # <<<<<<<<<<<<<<
8775 * p += x * 4
8776 *
8777 */
8778 __pyx_v_p = (__pyx_v_p + (__pyx_v_y * __pyx_v_self->surface->pitch));
8779
8780 /* "pygame_sdl2/surface.pyx":574
8781 * p = <Uint8 *> self.surface.pixels
8782 * p += y * self.surface.pitch
8783 * p += x * 4 # <<<<<<<<<<<<<<
8784 *
8785 * (<Uint32 *> p)[0] = pixel
8786 */
8787 __pyx_v_p = (__pyx_v_p + (__pyx_v_x * 4));
8788
8789 /* "pygame_sdl2/surface.pyx":576
8790 * p += x * 4
8791 *
8792 * (<Uint32 *> p)[0] = pixel # <<<<<<<<<<<<<<
8793 *
8794 * self.unlock()
8795 */
8796 (((Uint32 *)__pyx_v_p)[0]) = __pyx_v_pixel;
8797
8798 /* "pygame_sdl2/surface.pyx":578
8799 * (<Uint32 *> p)[0] = pixel
8800 *
8801 * self.unlock() # <<<<<<<<<<<<<<
8802 *
8803 * def get_at_mapped(self, pos):
8804 */
8805 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 578, __pyx_L1_error)
8806 __Pyx_GOTREF(__pyx_t_1);
8807 __pyx_t_3 = NULL;
8808 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
8809 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
8810 if (likely(__pyx_t_3)) {
8811 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
8812 __Pyx_INCREF(__pyx_t_3);
8813 __Pyx_INCREF(function);
8814 __Pyx_DECREF_SET(__pyx_t_1, function);
8815 }
8816 }
8817 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
8818 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
8819 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 578, __pyx_L1_error)
8820 __Pyx_GOTREF(__pyx_t_2);
8821 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8822 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8823
8824 /* "pygame_sdl2/surface.pyx":555
8825 * return get_color(pixel, self.surface)
8826 *
8827 * def set_at(self, pos, color): # <<<<<<<<<<<<<<
8828 * cdef int x, y
8829 * cdef Uint8 *p
8830 */
8831
8832 /* function exit code */
8833 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8834 goto __pyx_L0;
8835 __pyx_L1_error:;
8836 __Pyx_XDECREF(__pyx_t_1);
8837 __Pyx_XDECREF(__pyx_t_2);
8838 __Pyx_XDECREF(__pyx_t_3);
8839 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
8840 __pyx_r = NULL;
8841 __pyx_L0:;
8842 __Pyx_XGIVEREF(__pyx_r);
8843 __Pyx_RefNannyFinishContext();
8844 return __pyx_r;
8845 }
8846
8847 /* "pygame_sdl2/surface.pyx":580
8848 * self.unlock()
8849 *
8850 * def get_at_mapped(self, pos): # <<<<<<<<<<<<<<
8851 * cdef int x, y
8852 * cdef Uint8 *p
8853 */
8854
8855 /* Python wrapper */
8856 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_45get_at_mapped(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_45get_at_mapped(PyObject * __pyx_v_self,PyObject * __pyx_v_pos)8857 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_45get_at_mapped(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) {
8858 PyObject *__pyx_r = 0;
8859 __Pyx_RefNannyDeclarations
8860 __Pyx_RefNannySetupContext("get_at_mapped (wrapper)", 0);
8861 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_44get_at_mapped(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_pos));
8862
8863 /* function exit code */
8864 __Pyx_RefNannyFinishContext();
8865 return __pyx_r;
8866 }
8867
__pyx_pf_11pygame_sdl2_7surface_7Surface_44get_at_mapped(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_pos)8868 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_44get_at_mapped(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pos) {
8869 int __pyx_v_x;
8870 int __pyx_v_y;
8871 Uint8 *__pyx_v_p;
8872 Uint32 __pyx_v_pixel;
8873 PyObject *__pyx_r = NULL;
8874 __Pyx_RefNannyDeclarations
8875 PyObject *__pyx_t_1 = NULL;
8876 PyObject *__pyx_t_2 = NULL;
8877 PyObject *__pyx_t_3 = NULL;
8878 PyObject *(*__pyx_t_4)(PyObject *);
8879 int __pyx_t_5;
8880 int __pyx_t_6;
8881 int __pyx_t_7;
8882 int __pyx_t_8;
8883 int __pyx_t_9;
8884 int __pyx_lineno = 0;
8885 const char *__pyx_filename = NULL;
8886 int __pyx_clineno = 0;
8887 __Pyx_RefNannySetupContext("get_at_mapped", 0);
8888
8889 /* "pygame_sdl2/surface.pyx":584
8890 * cdef Uint8 *p
8891 *
8892 * x, y = pos # <<<<<<<<<<<<<<
8893 *
8894 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8895 */
8896 if ((likely(PyTuple_CheckExact(__pyx_v_pos))) || (PyList_CheckExact(__pyx_v_pos))) {
8897 PyObject* sequence = __pyx_v_pos;
8898 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8899 if (unlikely(size != 2)) {
8900 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
8901 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8902 __PYX_ERR(0, 584, __pyx_L1_error)
8903 }
8904 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8905 if (likely(PyTuple_CheckExact(sequence))) {
8906 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
8907 __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
8908 } else {
8909 __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
8910 __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
8911 }
8912 __Pyx_INCREF(__pyx_t_1);
8913 __Pyx_INCREF(__pyx_t_2);
8914 #else
8915 __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __pyx_L1_error)
8916 __Pyx_GOTREF(__pyx_t_1);
8917 __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error)
8918 __Pyx_GOTREF(__pyx_t_2);
8919 #endif
8920 } else {
8921 Py_ssize_t index = -1;
8922 __pyx_t_3 = PyObject_GetIter(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
8923 __Pyx_GOTREF(__pyx_t_3);
8924 __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
8925 index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
8926 __Pyx_GOTREF(__pyx_t_1);
8927 index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
8928 __Pyx_GOTREF(__pyx_t_2);
8929 if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) __PYX_ERR(0, 584, __pyx_L1_error)
8930 __pyx_t_4 = NULL;
8931 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8932 goto __pyx_L4_unpacking_done;
8933 __pyx_L3_unpacking_failed:;
8934 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8935 __pyx_t_4 = NULL;
8936 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8937 __PYX_ERR(0, 584, __pyx_L1_error)
8938 __pyx_L4_unpacking_done:;
8939 }
8940 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L1_error)
8941 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8942 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L1_error)
8943 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8944 __pyx_v_x = __pyx_t_5;
8945 __pyx_v_y = __pyx_t_6;
8946
8947 /* "pygame_sdl2/surface.pyx":586
8948 * x, y = pos
8949 *
8950 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8951 * raise ValueError("Position outside surface.")
8952 *
8953 */
8954 __pyx_t_8 = (0 <= __pyx_v_x);
8955 if (__pyx_t_8) {
8956 __pyx_t_8 = (__pyx_v_x < __pyx_v_self->surface->w);
8957 }
8958 __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
8959 if (!__pyx_t_9) {
8960 } else {
8961 __pyx_t_7 = __pyx_t_9;
8962 goto __pyx_L6_bool_binop_done;
8963 }
8964 __pyx_t_9 = (0 <= __pyx_v_y);
8965 if (__pyx_t_9) {
8966 __pyx_t_9 = (__pyx_v_y < __pyx_v_self->surface->h);
8967 }
8968 __pyx_t_8 = ((!(__pyx_t_9 != 0)) != 0);
8969 __pyx_t_7 = __pyx_t_8;
8970 __pyx_L6_bool_binop_done:;
8971 if (unlikely(__pyx_t_7)) {
8972
8973 /* "pygame_sdl2/surface.pyx":587
8974 *
8975 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
8976 * raise ValueError("Position outside surface.") # <<<<<<<<<<<<<<
8977 *
8978 * if self.surface.format.BytesPerPixel != 4:
8979 */
8980 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 587, __pyx_L1_error)
8981 __Pyx_GOTREF(__pyx_t_2);
8982 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8983 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8984 __PYX_ERR(0, 587, __pyx_L1_error)
8985
8986 /* "pygame_sdl2/surface.pyx":586
8987 * x, y = pos
8988 *
8989 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h): # <<<<<<<<<<<<<<
8990 * raise ValueError("Position outside surface.")
8991 *
8992 */
8993 }
8994
8995 /* "pygame_sdl2/surface.pyx":589
8996 * raise ValueError("Position outside surface.")
8997 *
8998 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
8999 * raise error("Surface has unsupported bytesize.")
9000 *
9001 */
9002 __pyx_t_7 = ((__pyx_v_self->surface->format->BytesPerPixel != 4) != 0);
9003 if (unlikely(__pyx_t_7)) {
9004
9005 /* "pygame_sdl2/surface.pyx":590
9006 *
9007 * if self.surface.format.BytesPerPixel != 4:
9008 * raise error("Surface has unsupported bytesize.") # <<<<<<<<<<<<<<
9009 *
9010 * self.lock()
9011 */
9012 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
9013 __Pyx_GOTREF(__pyx_t_1);
9014 __pyx_t_3 = NULL;
9015 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
9016 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
9017 if (likely(__pyx_t_3)) {
9018 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
9019 __Pyx_INCREF(__pyx_t_3);
9020 __Pyx_INCREF(function);
9021 __Pyx_DECREF_SET(__pyx_t_1, function);
9022 }
9023 }
9024 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_kp_s_Surface_has_unsupported_bytesize) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s_Surface_has_unsupported_bytesize);
9025 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9026 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 590, __pyx_L1_error)
9027 __Pyx_GOTREF(__pyx_t_2);
9028 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9029 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
9030 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9031 __PYX_ERR(0, 590, __pyx_L1_error)
9032
9033 /* "pygame_sdl2/surface.pyx":589
9034 * raise ValueError("Position outside surface.")
9035 *
9036 * if self.surface.format.BytesPerPixel != 4: # <<<<<<<<<<<<<<
9037 * raise error("Surface has unsupported bytesize.")
9038 *
9039 */
9040 }
9041
9042 /* "pygame_sdl2/surface.pyx":592
9043 * raise error("Surface has unsupported bytesize.")
9044 *
9045 * self.lock() # <<<<<<<<<<<<<<
9046 *
9047 * p = <Uint8 *> self.surface.pixels
9048 */
9049 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
9050 __Pyx_GOTREF(__pyx_t_1);
9051 __pyx_t_3 = NULL;
9052 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
9053 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
9054 if (likely(__pyx_t_3)) {
9055 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
9056 __Pyx_INCREF(__pyx_t_3);
9057 __Pyx_INCREF(function);
9058 __Pyx_DECREF_SET(__pyx_t_1, function);
9059 }
9060 }
9061 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
9062 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9063 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
9064 __Pyx_GOTREF(__pyx_t_2);
9065 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9066 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9067
9068 /* "pygame_sdl2/surface.pyx":594
9069 * self.lock()
9070 *
9071 * p = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
9072 * p += y * self.surface.pitch
9073 * p += x * 4
9074 */
9075 __pyx_v_p = ((Uint8 *)__pyx_v_self->surface->pixels);
9076
9077 /* "pygame_sdl2/surface.pyx":595
9078 *
9079 * p = <Uint8 *> self.surface.pixels
9080 * p += y * self.surface.pitch # <<<<<<<<<<<<<<
9081 * p += x * 4
9082 *
9083 */
9084 __pyx_v_p = (__pyx_v_p + (__pyx_v_y * __pyx_v_self->surface->pitch));
9085
9086 /* "pygame_sdl2/surface.pyx":596
9087 * p = <Uint8 *> self.surface.pixels
9088 * p += y * self.surface.pitch
9089 * p += x * 4 # <<<<<<<<<<<<<<
9090 *
9091 * cdef Uint32 pixel = (<Uint32 *> p)[0]
9092 */
9093 __pyx_v_p = (__pyx_v_p + (__pyx_v_x * 4));
9094
9095 /* "pygame_sdl2/surface.pyx":598
9096 * p += x * 4
9097 *
9098 * cdef Uint32 pixel = (<Uint32 *> p)[0] # <<<<<<<<<<<<<<
9099 *
9100 * self.unlock()
9101 */
9102 __pyx_v_pixel = (((Uint32 *)__pyx_v_p)[0]);
9103
9104 /* "pygame_sdl2/surface.pyx":600
9105 * cdef Uint32 pixel = (<Uint32 *> p)[0]
9106 *
9107 * self.unlock() # <<<<<<<<<<<<<<
9108 *
9109 * return pixel
9110 */
9111 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 600, __pyx_L1_error)
9112 __Pyx_GOTREF(__pyx_t_1);
9113 __pyx_t_3 = NULL;
9114 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
9115 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
9116 if (likely(__pyx_t_3)) {
9117 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
9118 __Pyx_INCREF(__pyx_t_3);
9119 __Pyx_INCREF(function);
9120 __Pyx_DECREF_SET(__pyx_t_1, function);
9121 }
9122 }
9123 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
9124 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9125 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 600, __pyx_L1_error)
9126 __Pyx_GOTREF(__pyx_t_2);
9127 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9128 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9129
9130 /* "pygame_sdl2/surface.pyx":602
9131 * self.unlock()
9132 *
9133 * return pixel # <<<<<<<<<<<<<<
9134 *
9135 * def map_rgb(self, color):
9136 */
9137 __Pyx_XDECREF(__pyx_r);
9138 __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_pixel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 602, __pyx_L1_error)
9139 __Pyx_GOTREF(__pyx_t_2);
9140 __pyx_r = __pyx_t_2;
9141 __pyx_t_2 = 0;
9142 goto __pyx_L0;
9143
9144 /* "pygame_sdl2/surface.pyx":580
9145 * self.unlock()
9146 *
9147 * def get_at_mapped(self, pos): # <<<<<<<<<<<<<<
9148 * cdef int x, y
9149 * cdef Uint8 *p
9150 */
9151
9152 /* function exit code */
9153 __pyx_L1_error:;
9154 __Pyx_XDECREF(__pyx_t_1);
9155 __Pyx_XDECREF(__pyx_t_2);
9156 __Pyx_XDECREF(__pyx_t_3);
9157 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_at_mapped", __pyx_clineno, __pyx_lineno, __pyx_filename);
9158 __pyx_r = NULL;
9159 __pyx_L0:;
9160 __Pyx_XGIVEREF(__pyx_r);
9161 __Pyx_RefNannyFinishContext();
9162 return __pyx_r;
9163 }
9164
9165 /* "pygame_sdl2/surface.pyx":604
9166 * return pixel
9167 *
9168 * def map_rgb(self, color): # <<<<<<<<<<<<<<
9169 * return map_color(self.surface, color)
9170 *
9171 */
9172
9173 /* Python wrapper */
9174 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_47map_rgb(PyObject *__pyx_v_self, PyObject *__pyx_v_color); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_47map_rgb(PyObject * __pyx_v_self,PyObject * __pyx_v_color)9175 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_47map_rgb(PyObject *__pyx_v_self, PyObject *__pyx_v_color) {
9176 PyObject *__pyx_r = 0;
9177 __Pyx_RefNannyDeclarations
9178 __Pyx_RefNannySetupContext("map_rgb (wrapper)", 0);
9179 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_46map_rgb(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_color));
9180
9181 /* function exit code */
9182 __Pyx_RefNannyFinishContext();
9183 return __pyx_r;
9184 }
9185
__pyx_pf_11pygame_sdl2_7surface_7Surface_46map_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_color)9186 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_46map_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_color) {
9187 PyObject *__pyx_r = NULL;
9188 __Pyx_RefNannyDeclarations
9189 Uint32 __pyx_t_1;
9190 PyObject *__pyx_t_2 = NULL;
9191 int __pyx_lineno = 0;
9192 const char *__pyx_filename = NULL;
9193 int __pyx_clineno = 0;
9194 __Pyx_RefNannySetupContext("map_rgb", 0);
9195
9196 /* "pygame_sdl2/surface.pyx":605
9197 *
9198 * def map_rgb(self, color):
9199 * return map_color(self.surface, color) # <<<<<<<<<<<<<<
9200 *
9201 * def unmap_rgb(self, pixel):
9202 */
9203 __Pyx_XDECREF(__pyx_r);
9204 __pyx_t_1 = __pyx_f_11pygame_sdl2_5color_map_color(__pyx_v_self->surface, __pyx_v_color); if (unlikely(__pyx_t_1 == ((Uint32)0xaabbccdd) && PyErr_Occurred())) __PYX_ERR(0, 605, __pyx_L1_error)
9205 __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
9206 __Pyx_GOTREF(__pyx_t_2);
9207 __pyx_r = __pyx_t_2;
9208 __pyx_t_2 = 0;
9209 goto __pyx_L0;
9210
9211 /* "pygame_sdl2/surface.pyx":604
9212 * return pixel
9213 *
9214 * def map_rgb(self, color): # <<<<<<<<<<<<<<
9215 * return map_color(self.surface, color)
9216 *
9217 */
9218
9219 /* function exit code */
9220 __pyx_L1_error:;
9221 __Pyx_XDECREF(__pyx_t_2);
9222 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.map_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
9223 __pyx_r = NULL;
9224 __pyx_L0:;
9225 __Pyx_XGIVEREF(__pyx_r);
9226 __Pyx_RefNannyFinishContext();
9227 return __pyx_r;
9228 }
9229
9230 /* "pygame_sdl2/surface.pyx":607
9231 * return map_color(self.surface, color)
9232 *
9233 * def unmap_rgb(self, pixel): # <<<<<<<<<<<<<<
9234 * return get_color(pixel, self.surface)
9235 *
9236 */
9237
9238 /* Python wrapper */
9239 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_49unmap_rgb(PyObject *__pyx_v_self, PyObject *__pyx_v_pixel); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_49unmap_rgb(PyObject * __pyx_v_self,PyObject * __pyx_v_pixel)9240 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_49unmap_rgb(PyObject *__pyx_v_self, PyObject *__pyx_v_pixel) {
9241 PyObject *__pyx_r = 0;
9242 __Pyx_RefNannyDeclarations
9243 __Pyx_RefNannySetupContext("unmap_rgb (wrapper)", 0);
9244 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_48unmap_rgb(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_pixel));
9245
9246 /* function exit code */
9247 __Pyx_RefNannyFinishContext();
9248 return __pyx_r;
9249 }
9250
__pyx_pf_11pygame_sdl2_7surface_7Surface_48unmap_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_pixel)9251 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_48unmap_rgb(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_pixel) {
9252 PyObject *__pyx_r = NULL;
9253 __Pyx_RefNannyDeclarations
9254 Uint32 __pyx_t_1;
9255 PyObject *__pyx_t_2 = NULL;
9256 int __pyx_lineno = 0;
9257 const char *__pyx_filename = NULL;
9258 int __pyx_clineno = 0;
9259 __Pyx_RefNannySetupContext("unmap_rgb", 0);
9260
9261 /* "pygame_sdl2/surface.pyx":608
9262 *
9263 * def unmap_rgb(self, pixel):
9264 * return get_color(pixel, self.surface) # <<<<<<<<<<<<<<
9265 *
9266 * def set_clip(self, rect):
9267 */
9268 __Pyx_XDECREF(__pyx_r);
9269 __pyx_t_1 = __Pyx_PyInt_As_uint32_t(__pyx_v_pixel); if (unlikely((__pyx_t_1 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 608, __pyx_L1_error)
9270 __pyx_t_2 = __pyx_f_11pygame_sdl2_5color_get_color(__pyx_t_1, __pyx_v_self->surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
9271 __Pyx_GOTREF(__pyx_t_2);
9272 __pyx_r = __pyx_t_2;
9273 __pyx_t_2 = 0;
9274 goto __pyx_L0;
9275
9276 /* "pygame_sdl2/surface.pyx":607
9277 * return map_color(self.surface, color)
9278 *
9279 * def unmap_rgb(self, pixel): # <<<<<<<<<<<<<<
9280 * return get_color(pixel, self.surface)
9281 *
9282 */
9283
9284 /* function exit code */
9285 __pyx_L1_error:;
9286 __Pyx_XDECREF(__pyx_t_2);
9287 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.unmap_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
9288 __pyx_r = NULL;
9289 __pyx_L0:;
9290 __Pyx_XGIVEREF(__pyx_r);
9291 __Pyx_RefNannyFinishContext();
9292 return __pyx_r;
9293 }
9294
9295 /* "pygame_sdl2/surface.pyx":610
9296 * return get_color(pixel, self.surface)
9297 *
9298 * def set_clip(self, rect): # <<<<<<<<<<<<<<
9299 * cdef SDL_Rect sdl_rect
9300 *
9301 */
9302
9303 /* Python wrapper */
9304 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_51set_clip(PyObject *__pyx_v_self, PyObject *__pyx_v_rect); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_51set_clip(PyObject * __pyx_v_self,PyObject * __pyx_v_rect)9305 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_51set_clip(PyObject *__pyx_v_self, PyObject *__pyx_v_rect) {
9306 PyObject *__pyx_r = 0;
9307 __Pyx_RefNannyDeclarations
9308 __Pyx_RefNannySetupContext("set_clip (wrapper)", 0);
9309 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_50set_clip(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_rect));
9310
9311 /* function exit code */
9312 __Pyx_RefNannyFinishContext();
9313 return __pyx_r;
9314 }
9315
__pyx_pf_11pygame_sdl2_7surface_7Surface_50set_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_rect)9316 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_50set_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_rect) {
9317 SDL_Rect __pyx_v_sdl_rect;
9318 PyObject *__pyx_r = NULL;
9319 __Pyx_RefNannyDeclarations
9320 int __pyx_t_1;
9321 int __pyx_t_2;
9322 int __pyx_t_3;
9323 int __pyx_lineno = 0;
9324 const char *__pyx_filename = NULL;
9325 int __pyx_clineno = 0;
9326 __Pyx_RefNannySetupContext("set_clip", 0);
9327
9328 /* "pygame_sdl2/surface.pyx":613
9329 * cdef SDL_Rect sdl_rect
9330 *
9331 * if rect is None: # <<<<<<<<<<<<<<
9332 * SDL_SetClipRect(self.surface, NULL)
9333 * else:
9334 */
9335 __pyx_t_1 = (__pyx_v_rect == Py_None);
9336 __pyx_t_2 = (__pyx_t_1 != 0);
9337 if (__pyx_t_2) {
9338
9339 /* "pygame_sdl2/surface.pyx":614
9340 *
9341 * if rect is None:
9342 * SDL_SetClipRect(self.surface, NULL) # <<<<<<<<<<<<<<
9343 * else:
9344 * to_sdl_rect(rect, &sdl_rect)
9345 */
9346 (void)(SDL_SetClipRect(__pyx_v_self->surface, NULL));
9347
9348 /* "pygame_sdl2/surface.pyx":613
9349 * cdef SDL_Rect sdl_rect
9350 *
9351 * if rect is None: # <<<<<<<<<<<<<<
9352 * SDL_SetClipRect(self.surface, NULL)
9353 * else:
9354 */
9355 goto __pyx_L3;
9356 }
9357
9358 /* "pygame_sdl2/surface.pyx":616
9359 * SDL_SetClipRect(self.surface, NULL)
9360 * else:
9361 * to_sdl_rect(rect, &sdl_rect) # <<<<<<<<<<<<<<
9362 * SDL_SetClipRect(self.surface, &sdl_rect)
9363 *
9364 */
9365 /*else*/ {
9366 __pyx_t_3 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_v_rect, (&__pyx_v_sdl_rect), NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 616, __pyx_L1_error)
9367
9368 /* "pygame_sdl2/surface.pyx":617
9369 * else:
9370 * to_sdl_rect(rect, &sdl_rect)
9371 * SDL_SetClipRect(self.surface, &sdl_rect) # <<<<<<<<<<<<<<
9372 *
9373 * def get_clip(self):
9374 */
9375 (void)(SDL_SetClipRect(__pyx_v_self->surface, (&__pyx_v_sdl_rect)));
9376 }
9377 __pyx_L3:;
9378
9379 /* "pygame_sdl2/surface.pyx":610
9380 * return get_color(pixel, self.surface)
9381 *
9382 * def set_clip(self, rect): # <<<<<<<<<<<<<<
9383 * cdef SDL_Rect sdl_rect
9384 *
9385 */
9386
9387 /* function exit code */
9388 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9389 goto __pyx_L0;
9390 __pyx_L1_error:;
9391 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
9392 __pyx_r = NULL;
9393 __pyx_L0:;
9394 __Pyx_XGIVEREF(__pyx_r);
9395 __Pyx_RefNannyFinishContext();
9396 return __pyx_r;
9397 }
9398
9399 /* "pygame_sdl2/surface.pyx":619
9400 * SDL_SetClipRect(self.surface, &sdl_rect)
9401 *
9402 * def get_clip(self): # <<<<<<<<<<<<<<
9403 * cdef SDL_Rect sdl_rect
9404 *
9405 */
9406
9407 /* Python wrapper */
9408 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_53get_clip(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_53get_clip(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)9409 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_53get_clip(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9410 PyObject *__pyx_r = 0;
9411 __Pyx_RefNannyDeclarations
9412 __Pyx_RefNannySetupContext("get_clip (wrapper)", 0);
9413 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_52get_clip(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
9414
9415 /* function exit code */
9416 __Pyx_RefNannyFinishContext();
9417 return __pyx_r;
9418 }
9419
__pyx_pf_11pygame_sdl2_7surface_7Surface_52get_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)9420 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_52get_clip(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
9421 SDL_Rect __pyx_v_sdl_rect;
9422 PyObject *__pyx_r = NULL;
9423 __Pyx_RefNannyDeclarations
9424 PyObject *__pyx_t_1 = NULL;
9425 PyObject *__pyx_t_2 = NULL;
9426 PyObject *__pyx_t_3 = NULL;
9427 PyObject *__pyx_t_4 = NULL;
9428 PyObject *__pyx_t_5 = NULL;
9429 int __pyx_lineno = 0;
9430 const char *__pyx_filename = NULL;
9431 int __pyx_clineno = 0;
9432 __Pyx_RefNannySetupContext("get_clip", 0);
9433
9434 /* "pygame_sdl2/surface.pyx":622
9435 * cdef SDL_Rect sdl_rect
9436 *
9437 * SDL_GetClipRect(self.surface, &sdl_rect) # <<<<<<<<<<<<<<
9438 *
9439 * return (sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h)
9440 */
9441 SDL_GetClipRect(__pyx_v_self->surface, (&__pyx_v_sdl_rect));
9442
9443 /* "pygame_sdl2/surface.pyx":624
9444 * SDL_GetClipRect(self.surface, &sdl_rect)
9445 *
9446 * return (sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h) # <<<<<<<<<<<<<<
9447 *
9448 * def subsurface(self, *args):
9449 */
9450 __Pyx_XDECREF(__pyx_r);
9451 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
9452 __Pyx_GOTREF(__pyx_t_1);
9453 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
9454 __Pyx_GOTREF(__pyx_t_2);
9455 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
9456 __Pyx_GOTREF(__pyx_t_3);
9457 __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sdl_rect.h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error)
9458 __Pyx_GOTREF(__pyx_t_4);
9459 __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 624, __pyx_L1_error)
9460 __Pyx_GOTREF(__pyx_t_5);
9461 __Pyx_GIVEREF(__pyx_t_1);
9462 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
9463 __Pyx_GIVEREF(__pyx_t_2);
9464 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
9465 __Pyx_GIVEREF(__pyx_t_3);
9466 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
9467 __Pyx_GIVEREF(__pyx_t_4);
9468 PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
9469 __pyx_t_1 = 0;
9470 __pyx_t_2 = 0;
9471 __pyx_t_3 = 0;
9472 __pyx_t_4 = 0;
9473 __pyx_r = __pyx_t_5;
9474 __pyx_t_5 = 0;
9475 goto __pyx_L0;
9476
9477 /* "pygame_sdl2/surface.pyx":619
9478 * SDL_SetClipRect(self.surface, &sdl_rect)
9479 *
9480 * def get_clip(self): # <<<<<<<<<<<<<<
9481 * cdef SDL_Rect sdl_rect
9482 *
9483 */
9484
9485 /* function exit code */
9486 __pyx_L1_error:;
9487 __Pyx_XDECREF(__pyx_t_1);
9488 __Pyx_XDECREF(__pyx_t_2);
9489 __Pyx_XDECREF(__pyx_t_3);
9490 __Pyx_XDECREF(__pyx_t_4);
9491 __Pyx_XDECREF(__pyx_t_5);
9492 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
9493 __pyx_r = NULL;
9494 __pyx_L0:;
9495 __Pyx_XGIVEREF(__pyx_r);
9496 __Pyx_RefNannyFinishContext();
9497 return __pyx_r;
9498 }
9499
9500 /* "pygame_sdl2/surface.pyx":626
9501 * return (sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h)
9502 *
9503 * def subsurface(self, *args): # <<<<<<<<<<<<<<
9504 * cdef SDL_Rect sdl_rect
9505 *
9506 */
9507
9508 /* Python wrapper */
9509 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_55subsurface(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_55subsurface(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)9510 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_55subsurface(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9511 PyObject *__pyx_v_args = 0;
9512 PyObject *__pyx_r = 0;
9513 __Pyx_RefNannyDeclarations
9514 __Pyx_RefNannySetupContext("subsurface (wrapper)", 0);
9515 if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "subsurface", 0))) return NULL;
9516 __Pyx_INCREF(__pyx_args);
9517 __pyx_v_args = __pyx_args;
9518 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_54subsurface(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_args);
9519
9520 /* function exit code */
9521 __Pyx_XDECREF(__pyx_v_args);
9522 __Pyx_RefNannyFinishContext();
9523 return __pyx_r;
9524 }
9525
__pyx_pf_11pygame_sdl2_7surface_7Surface_54subsurface(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_args)9526 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_54subsurface(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_args) {
9527 SDL_Rect __pyx_v_sdl_rect;
9528 Uint8 *__pyx_v_pixels;
9529 SDL_Surface *__pyx_v_new_surface;
9530 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_rv = 0;
9531 PyObject *__pyx_r = NULL;
9532 __Pyx_RefNannyDeclarations
9533 Py_ssize_t __pyx_t_1;
9534 int __pyx_t_2;
9535 PyObject *__pyx_t_3 = NULL;
9536 int __pyx_t_4;
9537 int __pyx_t_5;
9538 PyObject *__pyx_t_6 = NULL;
9539 PyObject *__pyx_t_7 = NULL;
9540 PyObject *__pyx_t_8 = NULL;
9541 PyObject *__pyx_t_9 = NULL;
9542 int __pyx_lineno = 0;
9543 const char *__pyx_filename = NULL;
9544 int __pyx_clineno = 0;
9545 __Pyx_RefNannySetupContext("subsurface", 0);
9546
9547 /* "pygame_sdl2/surface.pyx":629
9548 * cdef SDL_Rect sdl_rect
9549 *
9550 * if len(args) == 1: # <<<<<<<<<<<<<<
9551 * to_sdl_rect(args[0], &sdl_rect)
9552 * else:
9553 */
9554 __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 629, __pyx_L1_error)
9555 __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
9556 if (__pyx_t_2) {
9557
9558 /* "pygame_sdl2/surface.pyx":630
9559 *
9560 * if len(args) == 1:
9561 * to_sdl_rect(args[0], &sdl_rect) # <<<<<<<<<<<<<<
9562 * else:
9563 * to_sdl_rect(args, &sdl_rect)
9564 */
9565 __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error)
9566 __Pyx_GOTREF(__pyx_t_3);
9567 __pyx_t_4 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_t_3, (&__pyx_v_sdl_rect), NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 630, __pyx_L1_error)
9568 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9569
9570 /* "pygame_sdl2/surface.pyx":629
9571 * cdef SDL_Rect sdl_rect
9572 *
9573 * if len(args) == 1: # <<<<<<<<<<<<<<
9574 * to_sdl_rect(args[0], &sdl_rect)
9575 * else:
9576 */
9577 goto __pyx_L3;
9578 }
9579
9580 /* "pygame_sdl2/surface.pyx":632
9581 * to_sdl_rect(args[0], &sdl_rect)
9582 * else:
9583 * to_sdl_rect(args, &sdl_rect) # <<<<<<<<<<<<<<
9584 *
9585 * if sdl_rect.w < 0 or sdl_rect.h < 0:
9586 */
9587 /*else*/ {
9588 __pyx_t_4 = __pyx_f_11pygame_sdl2_4rect_to_sdl_rect(__pyx_v_args, (&__pyx_v_sdl_rect), NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 632, __pyx_L1_error)
9589 }
9590 __pyx_L3:;
9591
9592 /* "pygame_sdl2/surface.pyx":634
9593 * to_sdl_rect(args, &sdl_rect)
9594 *
9595 * if sdl_rect.w < 0 or sdl_rect.h < 0: # <<<<<<<<<<<<<<
9596 * raise error("subsurface size must be non-negative.")
9597 *
9598 */
9599 __pyx_t_5 = ((__pyx_v_sdl_rect.w < 0) != 0);
9600 if (!__pyx_t_5) {
9601 } else {
9602 __pyx_t_2 = __pyx_t_5;
9603 goto __pyx_L5_bool_binop_done;
9604 }
9605 __pyx_t_5 = ((__pyx_v_sdl_rect.h < 0) != 0);
9606 __pyx_t_2 = __pyx_t_5;
9607 __pyx_L5_bool_binop_done:;
9608 if (unlikely(__pyx_t_2)) {
9609
9610 /* "pygame_sdl2/surface.pyx":635
9611 *
9612 * if sdl_rect.w < 0 or sdl_rect.h < 0:
9613 * raise error("subsurface size must be non-negative.") # <<<<<<<<<<<<<<
9614 *
9615 * if ((sdl_rect.x < 0)
9616 */
9617 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 635, __pyx_L1_error)
9618 __Pyx_GOTREF(__pyx_t_6);
9619 __pyx_t_7 = NULL;
9620 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
9621 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
9622 if (likely(__pyx_t_7)) {
9623 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
9624 __Pyx_INCREF(__pyx_t_7);
9625 __Pyx_INCREF(function);
9626 __Pyx_DECREF_SET(__pyx_t_6, function);
9627 }
9628 }
9629 __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_kp_s_subsurface_size_must_be_non_nega) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_subsurface_size_must_be_non_nega);
9630 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9631 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __pyx_L1_error)
9632 __Pyx_GOTREF(__pyx_t_3);
9633 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9634 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
9635 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9636 __PYX_ERR(0, 635, __pyx_L1_error)
9637
9638 /* "pygame_sdl2/surface.pyx":634
9639 * to_sdl_rect(args, &sdl_rect)
9640 *
9641 * if sdl_rect.w < 0 or sdl_rect.h < 0: # <<<<<<<<<<<<<<
9642 * raise error("subsurface size must be non-negative.")
9643 *
9644 */
9645 }
9646
9647 /* "pygame_sdl2/surface.pyx":637
9648 * raise error("subsurface size must be non-negative.")
9649 *
9650 * if ((sdl_rect.x < 0) # <<<<<<<<<<<<<<
9651 * or (sdl_rect.y < 0)
9652 * or (sdl_rect.x + sdl_rect.w > self.surface.w)
9653 */
9654 __pyx_t_5 = ((__pyx_v_sdl_rect.x < 0) != 0);
9655 if (!__pyx_t_5) {
9656 } else {
9657 __pyx_t_2 = __pyx_t_5;
9658 goto __pyx_L8_bool_binop_done;
9659 }
9660
9661 /* "pygame_sdl2/surface.pyx":638
9662 *
9663 * if ((sdl_rect.x < 0)
9664 * or (sdl_rect.y < 0) # <<<<<<<<<<<<<<
9665 * or (sdl_rect.x + sdl_rect.w > self.surface.w)
9666 * or (sdl_rect.y + sdl_rect.h > self.surface.h)):
9667 */
9668 __pyx_t_5 = ((__pyx_v_sdl_rect.y < 0) != 0);
9669 if (!__pyx_t_5) {
9670 } else {
9671 __pyx_t_2 = __pyx_t_5;
9672 goto __pyx_L8_bool_binop_done;
9673 }
9674
9675 /* "pygame_sdl2/surface.pyx":639
9676 * if ((sdl_rect.x < 0)
9677 * or (sdl_rect.y < 0)
9678 * or (sdl_rect.x + sdl_rect.w > self.surface.w) # <<<<<<<<<<<<<<
9679 * or (sdl_rect.y + sdl_rect.h > self.surface.h)):
9680 *
9681 */
9682 __pyx_t_5 = (((__pyx_v_sdl_rect.x + __pyx_v_sdl_rect.w) > __pyx_v_self->surface->w) != 0);
9683 if (!__pyx_t_5) {
9684 } else {
9685 __pyx_t_2 = __pyx_t_5;
9686 goto __pyx_L8_bool_binop_done;
9687 }
9688
9689 /* "pygame_sdl2/surface.pyx":640
9690 * or (sdl_rect.y < 0)
9691 * or (sdl_rect.x + sdl_rect.w > self.surface.w)
9692 * or (sdl_rect.y + sdl_rect.h > self.surface.h)): # <<<<<<<<<<<<<<
9693 *
9694 * raise error("subsurface rectangle outside surface area.")
9695 */
9696 __pyx_t_5 = (((__pyx_v_sdl_rect.y + __pyx_v_sdl_rect.h) > __pyx_v_self->surface->h) != 0);
9697 __pyx_t_2 = __pyx_t_5;
9698 __pyx_L8_bool_binop_done:;
9699
9700 /* "pygame_sdl2/surface.pyx":637
9701 * raise error("subsurface size must be non-negative.")
9702 *
9703 * if ((sdl_rect.x < 0) # <<<<<<<<<<<<<<
9704 * or (sdl_rect.y < 0)
9705 * or (sdl_rect.x + sdl_rect.w > self.surface.w)
9706 */
9707 if (unlikely(__pyx_t_2)) {
9708
9709 /* "pygame_sdl2/surface.pyx":642
9710 * or (sdl_rect.y + sdl_rect.h > self.surface.h)):
9711 *
9712 * raise error("subsurface rectangle outside surface area.") # <<<<<<<<<<<<<<
9713 *
9714 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
9715 */
9716 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error)
9717 __Pyx_GOTREF(__pyx_t_6);
9718 __pyx_t_7 = NULL;
9719 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
9720 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
9721 if (likely(__pyx_t_7)) {
9722 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
9723 __Pyx_INCREF(__pyx_t_7);
9724 __Pyx_INCREF(function);
9725 __Pyx_DECREF_SET(__pyx_t_6, function);
9726 }
9727 }
9728 __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_kp_s_subsurface_rectangle_outside_sur) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_subsurface_rectangle_outside_sur);
9729 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9730 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 642, __pyx_L1_error)
9731 __Pyx_GOTREF(__pyx_t_3);
9732 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9733 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
9734 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9735 __PYX_ERR(0, 642, __pyx_L1_error)
9736
9737 /* "pygame_sdl2/surface.pyx":637
9738 * raise error("subsurface size must be non-negative.")
9739 *
9740 * if ((sdl_rect.x < 0) # <<<<<<<<<<<<<<
9741 * or (sdl_rect.y < 0)
9742 * or (sdl_rect.x + sdl_rect.w > self.surface.w)
9743 */
9744 }
9745
9746 /* "pygame_sdl2/surface.pyx":644
9747 * raise error("subsurface rectangle outside surface area.")
9748 *
9749 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
9750 * pixels += sdl_rect.y * self.surface.pitch
9751 * pixels += sdl_rect.x * self.surface.format.BytesPerPixel
9752 */
9753 __pyx_v_pixels = ((Uint8 *)__pyx_v_self->surface->pixels);
9754
9755 /* "pygame_sdl2/surface.pyx":645
9756 *
9757 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
9758 * pixels += sdl_rect.y * self.surface.pitch # <<<<<<<<<<<<<<
9759 * pixels += sdl_rect.x * self.surface.format.BytesPerPixel
9760 *
9761 */
9762 __pyx_v_pixels = (__pyx_v_pixels + (__pyx_v_sdl_rect.y * __pyx_v_self->surface->pitch));
9763
9764 /* "pygame_sdl2/surface.pyx":646
9765 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
9766 * pixels += sdl_rect.y * self.surface.pitch
9767 * pixels += sdl_rect.x * self.surface.format.BytesPerPixel # <<<<<<<<<<<<<<
9768 *
9769 * cdef SDL_Surface *new_surface = SDL_CreateRGBSurfaceFrom(
9770 */
9771 __pyx_v_pixels = (__pyx_v_pixels + (__pyx_v_sdl_rect.x * __pyx_v_self->surface->format->BytesPerPixel));
9772
9773 /* "pygame_sdl2/surface.pyx":648
9774 * pixels += sdl_rect.x * self.surface.format.BytesPerPixel
9775 *
9776 * cdef SDL_Surface *new_surface = SDL_CreateRGBSurfaceFrom( # <<<<<<<<<<<<<<
9777 * pixels,
9778 * sdl_rect.w,
9779 */
9780 __pyx_v_new_surface = SDL_CreateRGBSurfaceFrom(__pyx_v_pixels, __pyx_v_sdl_rect.w, __pyx_v_sdl_rect.h, __pyx_v_self->surface->format->BitsPerPixel, __pyx_v_self->surface->pitch, __pyx_v_self->surface->format->Rmask, __pyx_v_self->surface->format->Gmask, __pyx_v_self->surface->format->Bmask, __pyx_v_self->surface->format->Amask);
9781
9782 /* "pygame_sdl2/surface.pyx":659
9783 * self.surface.format.Amask)
9784 *
9785 * if not new_surface: # <<<<<<<<<<<<<<
9786 * raise error()
9787 *
9788 */
9789 __pyx_t_2 = ((!(__pyx_v_new_surface != 0)) != 0);
9790 if (unlikely(__pyx_t_2)) {
9791
9792 /* "pygame_sdl2/surface.pyx":660
9793 *
9794 * if not new_surface:
9795 * raise error() # <<<<<<<<<<<<<<
9796 *
9797 * cdef Surface rv = Surface(())
9798 */
9799 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 660, __pyx_L1_error)
9800 __Pyx_GOTREF(__pyx_t_6);
9801 __pyx_t_7 = NULL;
9802 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
9803 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
9804 if (likely(__pyx_t_7)) {
9805 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
9806 __Pyx_INCREF(__pyx_t_7);
9807 __Pyx_INCREF(function);
9808 __Pyx_DECREF_SET(__pyx_t_6, function);
9809 }
9810 }
9811 __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
9812 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9813 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 660, __pyx_L1_error)
9814 __Pyx_GOTREF(__pyx_t_3);
9815 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9816 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
9817 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9818 __PYX_ERR(0, 660, __pyx_L1_error)
9819
9820 /* "pygame_sdl2/surface.pyx":659
9821 * self.surface.format.Amask)
9822 *
9823 * if not new_surface: # <<<<<<<<<<<<<<
9824 * raise error()
9825 *
9826 */
9827 }
9828
9829 /* "pygame_sdl2/surface.pyx":662
9830 * raise error()
9831 *
9832 * cdef Surface rv = Surface(()) # <<<<<<<<<<<<<<
9833 *
9834 * rv.surface = new_surface
9835 */
9836 __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pygame_sdl2_7surface_Surface), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 662, __pyx_L1_error)
9837 __Pyx_GOTREF(__pyx_t_3);
9838 __pyx_v_rv = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_3);
9839 __pyx_t_3 = 0;
9840
9841 /* "pygame_sdl2/surface.pyx":664
9842 * cdef Surface rv = Surface(())
9843 *
9844 * rv.surface = new_surface # <<<<<<<<<<<<<<
9845 * rv.parent = self
9846 * rv.offset_x = sdl_rect.x
9847 */
9848 __pyx_v_rv->surface = __pyx_v_new_surface;
9849
9850 /* "pygame_sdl2/surface.pyx":665
9851 *
9852 * rv.surface = new_surface
9853 * rv.parent = self # <<<<<<<<<<<<<<
9854 * rv.offset_x = sdl_rect.x
9855 * rv.offset_y = sdl_rect.y
9856 */
9857 __Pyx_INCREF(((PyObject *)__pyx_v_self));
9858 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
9859 __Pyx_GOTREF(__pyx_v_rv->parent);
9860 __Pyx_DECREF(((PyObject *)__pyx_v_rv->parent));
9861 __pyx_v_rv->parent = __pyx_v_self;
9862
9863 /* "pygame_sdl2/surface.pyx":666
9864 * rv.surface = new_surface
9865 * rv.parent = self
9866 * rv.offset_x = sdl_rect.x # <<<<<<<<<<<<<<
9867 * rv.offset_y = sdl_rect.y
9868 *
9869 */
9870 __pyx_t_4 = __pyx_v_sdl_rect.x;
9871 __pyx_v_rv->offset_x = __pyx_t_4;
9872
9873 /* "pygame_sdl2/surface.pyx":667
9874 * rv.parent = self
9875 * rv.offset_x = sdl_rect.x
9876 * rv.offset_y = sdl_rect.y # <<<<<<<<<<<<<<
9877 *
9878 * if self.has_alpha:
9879 */
9880 __pyx_t_4 = __pyx_v_sdl_rect.y;
9881 __pyx_v_rv->offset_y = __pyx_t_4;
9882
9883 /* "pygame_sdl2/surface.pyx":669
9884 * rv.offset_y = sdl_rect.y
9885 *
9886 * if self.has_alpha: # <<<<<<<<<<<<<<
9887 * rv.set_alpha(self.get_alpha())
9888 *
9889 */
9890 __pyx_t_2 = (__pyx_v_self->has_alpha != 0);
9891 if (__pyx_t_2) {
9892
9893 /* "pygame_sdl2/surface.pyx":670
9894 *
9895 * if self.has_alpha:
9896 * rv.set_alpha(self.get_alpha()) # <<<<<<<<<<<<<<
9897 *
9898 * return rv
9899 */
9900 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rv), __pyx_n_s_set_alpha); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 670, __pyx_L1_error)
9901 __Pyx_GOTREF(__pyx_t_6);
9902 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_alpha); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 670, __pyx_L1_error)
9903 __Pyx_GOTREF(__pyx_t_8);
9904 __pyx_t_9 = NULL;
9905 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
9906 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
9907 if (likely(__pyx_t_9)) {
9908 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
9909 __Pyx_INCREF(__pyx_t_9);
9910 __Pyx_INCREF(function);
9911 __Pyx_DECREF_SET(__pyx_t_8, function);
9912 }
9913 }
9914 __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
9915 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
9916 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 670, __pyx_L1_error)
9917 __Pyx_GOTREF(__pyx_t_7);
9918 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9919 __pyx_t_8 = NULL;
9920 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
9921 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
9922 if (likely(__pyx_t_8)) {
9923 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
9924 __Pyx_INCREF(__pyx_t_8);
9925 __Pyx_INCREF(function);
9926 __Pyx_DECREF_SET(__pyx_t_6, function);
9927 }
9928 }
9929 __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
9930 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9931 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9932 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 670, __pyx_L1_error)
9933 __Pyx_GOTREF(__pyx_t_3);
9934 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9935 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9936
9937 /* "pygame_sdl2/surface.pyx":669
9938 * rv.offset_y = sdl_rect.y
9939 *
9940 * if self.has_alpha: # <<<<<<<<<<<<<<
9941 * rv.set_alpha(self.get_alpha())
9942 *
9943 */
9944 }
9945
9946 /* "pygame_sdl2/surface.pyx":672
9947 * rv.set_alpha(self.get_alpha())
9948 *
9949 * return rv # <<<<<<<<<<<<<<
9950 *
9951 * def get_parent(self):
9952 */
9953 __Pyx_XDECREF(__pyx_r);
9954 __Pyx_INCREF(((PyObject *)__pyx_v_rv));
9955 __pyx_r = ((PyObject *)__pyx_v_rv);
9956 goto __pyx_L0;
9957
9958 /* "pygame_sdl2/surface.pyx":626
9959 * return (sdl_rect.x, sdl_rect.y, sdl_rect.w, sdl_rect.h)
9960 *
9961 * def subsurface(self, *args): # <<<<<<<<<<<<<<
9962 * cdef SDL_Rect sdl_rect
9963 *
9964 */
9965
9966 /* function exit code */
9967 __pyx_L1_error:;
9968 __Pyx_XDECREF(__pyx_t_3);
9969 __Pyx_XDECREF(__pyx_t_6);
9970 __Pyx_XDECREF(__pyx_t_7);
9971 __Pyx_XDECREF(__pyx_t_8);
9972 __Pyx_XDECREF(__pyx_t_9);
9973 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.subsurface", __pyx_clineno, __pyx_lineno, __pyx_filename);
9974 __pyx_r = NULL;
9975 __pyx_L0:;
9976 __Pyx_XDECREF((PyObject *)__pyx_v_rv);
9977 __Pyx_XGIVEREF(__pyx_r);
9978 __Pyx_RefNannyFinishContext();
9979 return __pyx_r;
9980 }
9981
9982 /* "pygame_sdl2/surface.pyx":674
9983 * return rv
9984 *
9985 * def get_parent(self): # <<<<<<<<<<<<<<
9986 * return self.parent
9987 *
9988 */
9989
9990 /* Python wrapper */
9991 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_57get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_57get_parent(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)9992 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_57get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9993 PyObject *__pyx_r = 0;
9994 __Pyx_RefNannyDeclarations
9995 __Pyx_RefNannySetupContext("get_parent (wrapper)", 0);
9996 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_56get_parent(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
9997
9998 /* function exit code */
9999 __Pyx_RefNannyFinishContext();
10000 return __pyx_r;
10001 }
10002
__pyx_pf_11pygame_sdl2_7surface_7Surface_56get_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10003 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_56get_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10004 PyObject *__pyx_r = NULL;
10005 __Pyx_RefNannyDeclarations
10006 __Pyx_RefNannySetupContext("get_parent", 0);
10007
10008 /* "pygame_sdl2/surface.pyx":675
10009 *
10010 * def get_parent(self):
10011 * return self.parent # <<<<<<<<<<<<<<
10012 *
10013 * def get_abs_parent(self):
10014 */
10015 __Pyx_XDECREF(__pyx_r);
10016 __Pyx_INCREF(((PyObject *)__pyx_v_self->parent));
10017 __pyx_r = ((PyObject *)__pyx_v_self->parent);
10018 goto __pyx_L0;
10019
10020 /* "pygame_sdl2/surface.pyx":674
10021 * return rv
10022 *
10023 * def get_parent(self): # <<<<<<<<<<<<<<
10024 * return self.parent
10025 *
10026 */
10027
10028 /* function exit code */
10029 __pyx_L0:;
10030 __Pyx_XGIVEREF(__pyx_r);
10031 __Pyx_RefNannyFinishContext();
10032 return __pyx_r;
10033 }
10034
10035 /* "pygame_sdl2/surface.pyx":677
10036 * return self.parent
10037 *
10038 * def get_abs_parent(self): # <<<<<<<<<<<<<<
10039 * rv = self
10040 *
10041 */
10042
10043 /* Python wrapper */
10044 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_59get_abs_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_59get_abs_parent(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10045 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_59get_abs_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10046 PyObject *__pyx_r = 0;
10047 __Pyx_RefNannyDeclarations
10048 __Pyx_RefNannySetupContext("get_abs_parent (wrapper)", 0);
10049 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_58get_abs_parent(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10050
10051 /* function exit code */
10052 __Pyx_RefNannyFinishContext();
10053 return __pyx_r;
10054 }
10055
__pyx_pf_11pygame_sdl2_7surface_7Surface_58get_abs_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10056 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_58get_abs_parent(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10057 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_rv = NULL;
10058 PyObject *__pyx_r = NULL;
10059 __Pyx_RefNannyDeclarations
10060 int __pyx_t_1;
10061 PyObject *__pyx_t_2 = NULL;
10062 int __pyx_lineno = 0;
10063 const char *__pyx_filename = NULL;
10064 int __pyx_clineno = 0;
10065 __Pyx_RefNannySetupContext("get_abs_parent", 0);
10066
10067 /* "pygame_sdl2/surface.pyx":678
10068 *
10069 * def get_abs_parent(self):
10070 * rv = self # <<<<<<<<<<<<<<
10071 *
10072 * while rv.parent:
10073 */
10074 __Pyx_INCREF(((PyObject *)__pyx_v_self));
10075 __pyx_v_rv = __pyx_v_self;
10076
10077 /* "pygame_sdl2/surface.pyx":680
10078 * rv = self
10079 *
10080 * while rv.parent: # <<<<<<<<<<<<<<
10081 * rv = rv.parent
10082 *
10083 */
10084 while (1) {
10085 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_rv->parent)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 680, __pyx_L1_error)
10086 if (!__pyx_t_1) break;
10087
10088 /* "pygame_sdl2/surface.pyx":681
10089 *
10090 * while rv.parent:
10091 * rv = rv.parent # <<<<<<<<<<<<<<
10092 *
10093 * return rv
10094 */
10095 __pyx_t_2 = ((PyObject *)__pyx_v_rv->parent);
10096 __Pyx_INCREF(__pyx_t_2);
10097 __Pyx_DECREF_SET(__pyx_v_rv, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
10098 __pyx_t_2 = 0;
10099 }
10100
10101 /* "pygame_sdl2/surface.pyx":683
10102 * rv = rv.parent
10103 *
10104 * return rv # <<<<<<<<<<<<<<
10105 *
10106 * def get_offset(self):
10107 */
10108 __Pyx_XDECREF(__pyx_r);
10109 __Pyx_INCREF(((PyObject *)__pyx_v_rv));
10110 __pyx_r = ((PyObject *)__pyx_v_rv);
10111 goto __pyx_L0;
10112
10113 /* "pygame_sdl2/surface.pyx":677
10114 * return self.parent
10115 *
10116 * def get_abs_parent(self): # <<<<<<<<<<<<<<
10117 * rv = self
10118 *
10119 */
10120
10121 /* function exit code */
10122 __pyx_L1_error:;
10123 __Pyx_XDECREF(__pyx_t_2);
10124 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_abs_parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
10125 __pyx_r = NULL;
10126 __pyx_L0:;
10127 __Pyx_XDECREF((PyObject *)__pyx_v_rv);
10128 __Pyx_XGIVEREF(__pyx_r);
10129 __Pyx_RefNannyFinishContext();
10130 return __pyx_r;
10131 }
10132
10133 /* "pygame_sdl2/surface.pyx":685
10134 * return rv
10135 *
10136 * def get_offset(self): # <<<<<<<<<<<<<<
10137 * return (self.offset_x, self.offset_y)
10138 *
10139 */
10140
10141 /* Python wrapper */
10142 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_61get_offset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_61get_offset(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10143 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_61get_offset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10144 PyObject *__pyx_r = 0;
10145 __Pyx_RefNannyDeclarations
10146 __Pyx_RefNannySetupContext("get_offset (wrapper)", 0);
10147 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_60get_offset(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10148
10149 /* function exit code */
10150 __Pyx_RefNannyFinishContext();
10151 return __pyx_r;
10152 }
10153
__pyx_pf_11pygame_sdl2_7surface_7Surface_60get_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10154 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_60get_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10155 PyObject *__pyx_r = NULL;
10156 __Pyx_RefNannyDeclarations
10157 PyObject *__pyx_t_1 = NULL;
10158 PyObject *__pyx_t_2 = NULL;
10159 PyObject *__pyx_t_3 = NULL;
10160 int __pyx_lineno = 0;
10161 const char *__pyx_filename = NULL;
10162 int __pyx_clineno = 0;
10163 __Pyx_RefNannySetupContext("get_offset", 0);
10164
10165 /* "pygame_sdl2/surface.pyx":686
10166 *
10167 * def get_offset(self):
10168 * return (self.offset_x, self.offset_y) # <<<<<<<<<<<<<<
10169 *
10170 * def get_abs_offset(self):
10171 */
10172 __Pyx_XDECREF(__pyx_r);
10173 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->offset_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
10174 __Pyx_GOTREF(__pyx_t_1);
10175 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->offset_y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 686, __pyx_L1_error)
10176 __Pyx_GOTREF(__pyx_t_2);
10177 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L1_error)
10178 __Pyx_GOTREF(__pyx_t_3);
10179 __Pyx_GIVEREF(__pyx_t_1);
10180 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
10181 __Pyx_GIVEREF(__pyx_t_2);
10182 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
10183 __pyx_t_1 = 0;
10184 __pyx_t_2 = 0;
10185 __pyx_r = __pyx_t_3;
10186 __pyx_t_3 = 0;
10187 goto __pyx_L0;
10188
10189 /* "pygame_sdl2/surface.pyx":685
10190 * return rv
10191 *
10192 * def get_offset(self): # <<<<<<<<<<<<<<
10193 * return (self.offset_x, self.offset_y)
10194 *
10195 */
10196
10197 /* function exit code */
10198 __pyx_L1_error:;
10199 __Pyx_XDECREF(__pyx_t_1);
10200 __Pyx_XDECREF(__pyx_t_2);
10201 __Pyx_XDECREF(__pyx_t_3);
10202 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_offset", __pyx_clineno, __pyx_lineno, __pyx_filename);
10203 __pyx_r = NULL;
10204 __pyx_L0:;
10205 __Pyx_XGIVEREF(__pyx_r);
10206 __Pyx_RefNannyFinishContext();
10207 return __pyx_r;
10208 }
10209
10210 /* "pygame_sdl2/surface.pyx":688
10211 * return (self.offset_x, self.offset_y)
10212 *
10213 * def get_abs_offset(self): # <<<<<<<<<<<<<<
10214 * cdef Surface surf = self
10215 *
10216 */
10217
10218 /* Python wrapper */
10219 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_63get_abs_offset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_63get_abs_offset(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10220 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_63get_abs_offset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10221 PyObject *__pyx_r = 0;
10222 __Pyx_RefNannyDeclarations
10223 __Pyx_RefNannySetupContext("get_abs_offset (wrapper)", 0);
10224 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_62get_abs_offset(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10225
10226 /* function exit code */
10227 __Pyx_RefNannyFinishContext();
10228 return __pyx_r;
10229 }
10230
__pyx_pf_11pygame_sdl2_7surface_7Surface_62get_abs_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10231 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_62get_abs_offset(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10232 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_surf = 0;
10233 int __pyx_v_offset_x;
10234 int __pyx_v_offset_y;
10235 PyObject *__pyx_r = NULL;
10236 __Pyx_RefNannyDeclarations
10237 int __pyx_t_1;
10238 PyObject *__pyx_t_2 = NULL;
10239 PyObject *__pyx_t_3 = NULL;
10240 PyObject *__pyx_t_4 = NULL;
10241 int __pyx_lineno = 0;
10242 const char *__pyx_filename = NULL;
10243 int __pyx_clineno = 0;
10244 __Pyx_RefNannySetupContext("get_abs_offset", 0);
10245
10246 /* "pygame_sdl2/surface.pyx":689
10247 *
10248 * def get_abs_offset(self):
10249 * cdef Surface surf = self # <<<<<<<<<<<<<<
10250 *
10251 * cdef int offset_x = 0
10252 */
10253 __Pyx_INCREF(((PyObject *)__pyx_v_self));
10254 __pyx_v_surf = __pyx_v_self;
10255
10256 /* "pygame_sdl2/surface.pyx":691
10257 * cdef Surface surf = self
10258 *
10259 * cdef int offset_x = 0 # <<<<<<<<<<<<<<
10260 * cdef int offset_y = 0
10261 *
10262 */
10263 __pyx_v_offset_x = 0;
10264
10265 /* "pygame_sdl2/surface.pyx":692
10266 *
10267 * cdef int offset_x = 0
10268 * cdef int offset_y = 0 # <<<<<<<<<<<<<<
10269 *
10270 * while surf:
10271 */
10272 __pyx_v_offset_y = 0;
10273
10274 /* "pygame_sdl2/surface.pyx":694
10275 * cdef int offset_y = 0
10276 *
10277 * while surf: # <<<<<<<<<<<<<<
10278 * offset_x += surf.offset_x
10279 * offset_y += surf.offset_y
10280 */
10281 while (1) {
10282 __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_surf)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 694, __pyx_L1_error)
10283 if (!__pyx_t_1) break;
10284
10285 /* "pygame_sdl2/surface.pyx":695
10286 *
10287 * while surf:
10288 * offset_x += surf.offset_x # <<<<<<<<<<<<<<
10289 * offset_y += surf.offset_y
10290 * surf = surf.parent
10291 */
10292 __pyx_v_offset_x = (__pyx_v_offset_x + __pyx_v_surf->offset_x);
10293
10294 /* "pygame_sdl2/surface.pyx":696
10295 * while surf:
10296 * offset_x += surf.offset_x
10297 * offset_y += surf.offset_y # <<<<<<<<<<<<<<
10298 * surf = surf.parent
10299 *
10300 */
10301 __pyx_v_offset_y = (__pyx_v_offset_y + __pyx_v_surf->offset_y);
10302
10303 /* "pygame_sdl2/surface.pyx":697
10304 * offset_x += surf.offset_x
10305 * offset_y += surf.offset_y
10306 * surf = surf.parent # <<<<<<<<<<<<<<
10307 *
10308 * return (offset_x, offset_y)
10309 */
10310 __pyx_t_2 = ((PyObject *)__pyx_v_surf->parent);
10311 __Pyx_INCREF(__pyx_t_2);
10312 __Pyx_DECREF_SET(__pyx_v_surf, ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_2));
10313 __pyx_t_2 = 0;
10314 }
10315
10316 /* "pygame_sdl2/surface.pyx":699
10317 * surf = surf.parent
10318 *
10319 * return (offset_x, offset_y) # <<<<<<<<<<<<<<
10320 *
10321 * def get_size(self):
10322 */
10323 __Pyx_XDECREF(__pyx_r);
10324 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_offset_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error)
10325 __Pyx_GOTREF(__pyx_t_2);
10326 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_offset_y); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 699, __pyx_L1_error)
10327 __Pyx_GOTREF(__pyx_t_3);
10328 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 699, __pyx_L1_error)
10329 __Pyx_GOTREF(__pyx_t_4);
10330 __Pyx_GIVEREF(__pyx_t_2);
10331 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
10332 __Pyx_GIVEREF(__pyx_t_3);
10333 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
10334 __pyx_t_2 = 0;
10335 __pyx_t_3 = 0;
10336 __pyx_r = __pyx_t_4;
10337 __pyx_t_4 = 0;
10338 goto __pyx_L0;
10339
10340 /* "pygame_sdl2/surface.pyx":688
10341 * return (self.offset_x, self.offset_y)
10342 *
10343 * def get_abs_offset(self): # <<<<<<<<<<<<<<
10344 * cdef Surface surf = self
10345 *
10346 */
10347
10348 /* function exit code */
10349 __pyx_L1_error:;
10350 __Pyx_XDECREF(__pyx_t_2);
10351 __Pyx_XDECREF(__pyx_t_3);
10352 __Pyx_XDECREF(__pyx_t_4);
10353 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_abs_offset", __pyx_clineno, __pyx_lineno, __pyx_filename);
10354 __pyx_r = NULL;
10355 __pyx_L0:;
10356 __Pyx_XDECREF((PyObject *)__pyx_v_surf);
10357 __Pyx_XGIVEREF(__pyx_r);
10358 __Pyx_RefNannyFinishContext();
10359 return __pyx_r;
10360 }
10361
10362 /* "pygame_sdl2/surface.pyx":701
10363 * return (offset_x, offset_y)
10364 *
10365 * def get_size(self): # <<<<<<<<<<<<<<
10366 * return self.surface.w, self.surface.h
10367 *
10368 */
10369
10370 /* Python wrapper */
10371 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_65get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_65get_size(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10372 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_65get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10373 PyObject *__pyx_r = 0;
10374 __Pyx_RefNannyDeclarations
10375 __Pyx_RefNannySetupContext("get_size (wrapper)", 0);
10376 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_64get_size(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10377
10378 /* function exit code */
10379 __Pyx_RefNannyFinishContext();
10380 return __pyx_r;
10381 }
10382
__pyx_pf_11pygame_sdl2_7surface_7Surface_64get_size(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10383 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_64get_size(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10384 PyObject *__pyx_r = NULL;
10385 __Pyx_RefNannyDeclarations
10386 PyObject *__pyx_t_1 = NULL;
10387 PyObject *__pyx_t_2 = NULL;
10388 PyObject *__pyx_t_3 = NULL;
10389 int __pyx_lineno = 0;
10390 const char *__pyx_filename = NULL;
10391 int __pyx_clineno = 0;
10392 __Pyx_RefNannySetupContext("get_size", 0);
10393
10394 /* "pygame_sdl2/surface.pyx":702
10395 *
10396 * def get_size(self):
10397 * return self.surface.w, self.surface.h # <<<<<<<<<<<<<<
10398 *
10399 * def get_width(self):
10400 */
10401 __Pyx_XDECREF(__pyx_r);
10402 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 702, __pyx_L1_error)
10403 __Pyx_GOTREF(__pyx_t_1);
10404 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L1_error)
10405 __Pyx_GOTREF(__pyx_t_2);
10406 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
10407 __Pyx_GOTREF(__pyx_t_3);
10408 __Pyx_GIVEREF(__pyx_t_1);
10409 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
10410 __Pyx_GIVEREF(__pyx_t_2);
10411 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
10412 __pyx_t_1 = 0;
10413 __pyx_t_2 = 0;
10414 __pyx_r = __pyx_t_3;
10415 __pyx_t_3 = 0;
10416 goto __pyx_L0;
10417
10418 /* "pygame_sdl2/surface.pyx":701
10419 * return (offset_x, offset_y)
10420 *
10421 * def get_size(self): # <<<<<<<<<<<<<<
10422 * return self.surface.w, self.surface.h
10423 *
10424 */
10425
10426 /* function exit code */
10427 __pyx_L1_error:;
10428 __Pyx_XDECREF(__pyx_t_1);
10429 __Pyx_XDECREF(__pyx_t_2);
10430 __Pyx_XDECREF(__pyx_t_3);
10431 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
10432 __pyx_r = NULL;
10433 __pyx_L0:;
10434 __Pyx_XGIVEREF(__pyx_r);
10435 __Pyx_RefNannyFinishContext();
10436 return __pyx_r;
10437 }
10438
10439 /* "pygame_sdl2/surface.pyx":704
10440 * return self.surface.w, self.surface.h
10441 *
10442 * def get_width(self): # <<<<<<<<<<<<<<
10443 * return self.surface.w
10444 *
10445 */
10446
10447 /* Python wrapper */
10448 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_67get_width(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_67get_width(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10449 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_67get_width(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10450 PyObject *__pyx_r = 0;
10451 __Pyx_RefNannyDeclarations
10452 __Pyx_RefNannySetupContext("get_width (wrapper)", 0);
10453 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_66get_width(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10454
10455 /* function exit code */
10456 __Pyx_RefNannyFinishContext();
10457 return __pyx_r;
10458 }
10459
__pyx_pf_11pygame_sdl2_7surface_7Surface_66get_width(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10460 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_66get_width(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10461 PyObject *__pyx_r = NULL;
10462 __Pyx_RefNannyDeclarations
10463 PyObject *__pyx_t_1 = NULL;
10464 int __pyx_lineno = 0;
10465 const char *__pyx_filename = NULL;
10466 int __pyx_clineno = 0;
10467 __Pyx_RefNannySetupContext("get_width", 0);
10468
10469 /* "pygame_sdl2/surface.pyx":705
10470 *
10471 * def get_width(self):
10472 * return self.surface.w # <<<<<<<<<<<<<<
10473 *
10474 * def get_height(self):
10475 */
10476 __Pyx_XDECREF(__pyx_r);
10477 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error)
10478 __Pyx_GOTREF(__pyx_t_1);
10479 __pyx_r = __pyx_t_1;
10480 __pyx_t_1 = 0;
10481 goto __pyx_L0;
10482
10483 /* "pygame_sdl2/surface.pyx":704
10484 * return self.surface.w, self.surface.h
10485 *
10486 * def get_width(self): # <<<<<<<<<<<<<<
10487 * return self.surface.w
10488 *
10489 */
10490
10491 /* function exit code */
10492 __pyx_L1_error:;
10493 __Pyx_XDECREF(__pyx_t_1);
10494 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_width", __pyx_clineno, __pyx_lineno, __pyx_filename);
10495 __pyx_r = NULL;
10496 __pyx_L0:;
10497 __Pyx_XGIVEREF(__pyx_r);
10498 __Pyx_RefNannyFinishContext();
10499 return __pyx_r;
10500 }
10501
10502 /* "pygame_sdl2/surface.pyx":707
10503 * return self.surface.w
10504 *
10505 * def get_height(self): # <<<<<<<<<<<<<<
10506 * return self.surface.h
10507 *
10508 */
10509
10510 /* Python wrapper */
10511 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_69get_height(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_69get_height(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10512 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_69get_height(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10513 PyObject *__pyx_r = 0;
10514 __Pyx_RefNannyDeclarations
10515 __Pyx_RefNannySetupContext("get_height (wrapper)", 0);
10516 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_68get_height(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10517
10518 /* function exit code */
10519 __Pyx_RefNannyFinishContext();
10520 return __pyx_r;
10521 }
10522
__pyx_pf_11pygame_sdl2_7surface_7Surface_68get_height(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10523 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_68get_height(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10524 PyObject *__pyx_r = NULL;
10525 __Pyx_RefNannyDeclarations
10526 PyObject *__pyx_t_1 = NULL;
10527 int __pyx_lineno = 0;
10528 const char *__pyx_filename = NULL;
10529 int __pyx_clineno = 0;
10530 __Pyx_RefNannySetupContext("get_height", 0);
10531
10532 /* "pygame_sdl2/surface.pyx":708
10533 *
10534 * def get_height(self):
10535 * return self.surface.h # <<<<<<<<<<<<<<
10536 *
10537 * def get_rect(self, **kwargs):
10538 */
10539 __Pyx_XDECREF(__pyx_r);
10540 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error)
10541 __Pyx_GOTREF(__pyx_t_1);
10542 __pyx_r = __pyx_t_1;
10543 __pyx_t_1 = 0;
10544 goto __pyx_L0;
10545
10546 /* "pygame_sdl2/surface.pyx":707
10547 * return self.surface.w
10548 *
10549 * def get_height(self): # <<<<<<<<<<<<<<
10550 * return self.surface.h
10551 *
10552 */
10553
10554 /* function exit code */
10555 __pyx_L1_error:;
10556 __Pyx_XDECREF(__pyx_t_1);
10557 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_height", __pyx_clineno, __pyx_lineno, __pyx_filename);
10558 __pyx_r = NULL;
10559 __pyx_L0:;
10560 __Pyx_XGIVEREF(__pyx_r);
10561 __Pyx_RefNannyFinishContext();
10562 return __pyx_r;
10563 }
10564
10565 /* "pygame_sdl2/surface.pyx":710
10566 * return self.surface.h
10567 *
10568 * def get_rect(self, **kwargs): # <<<<<<<<<<<<<<
10569 * rv = Rect((0, 0, self.surface.w, self.surface.h))
10570 *
10571 */
10572
10573 /* Python wrapper */
10574 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_71get_rect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_71get_rect(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)10575 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_71get_rect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10576 PyObject *__pyx_v_kwargs = 0;
10577 PyObject *__pyx_r = 0;
10578 __Pyx_RefNannyDeclarations
10579 __Pyx_RefNannySetupContext("get_rect (wrapper)", 0);
10580 if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
10581 __Pyx_RaiseArgtupleInvalid("get_rect", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return NULL;}
10582 if (__pyx_kwds && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "get_rect", 1))) return NULL;
10583 __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
10584 __Pyx_GOTREF(__pyx_v_kwargs);
10585 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_70get_rect(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_kwargs);
10586
10587 /* function exit code */
10588 __Pyx_XDECREF(__pyx_v_kwargs);
10589 __Pyx_RefNannyFinishContext();
10590 return __pyx_r;
10591 }
10592
__pyx_pf_11pygame_sdl2_7surface_7Surface_70get_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_kwargs)10593 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_70get_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_kwargs) {
10594 PyObject *__pyx_v_rv = NULL;
10595 PyObject *__pyx_v_k = NULL;
10596 PyObject *__pyx_v_v = NULL;
10597 PyObject *__pyx_r = NULL;
10598 __Pyx_RefNannyDeclarations
10599 PyObject *__pyx_t_1 = NULL;
10600 PyObject *__pyx_t_2 = NULL;
10601 PyObject *__pyx_t_3 = NULL;
10602 PyObject *__pyx_t_4 = NULL;
10603 PyObject *__pyx_t_5 = NULL;
10604 Py_ssize_t __pyx_t_6;
10605 PyObject *(*__pyx_t_7)(PyObject *);
10606 PyObject *(*__pyx_t_8)(PyObject *);
10607 int __pyx_t_9;
10608 int __pyx_lineno = 0;
10609 const char *__pyx_filename = NULL;
10610 int __pyx_clineno = 0;
10611 __Pyx_RefNannySetupContext("get_rect", 0);
10612
10613 /* "pygame_sdl2/surface.pyx":711
10614 *
10615 * def get_rect(self, **kwargs):
10616 * rv = Rect((0, 0, self.surface.w, self.surface.h)) # <<<<<<<<<<<<<<
10617 *
10618 * for k, v in kwargs.items():
10619 */
10620 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Rect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L1_error)
10621 __Pyx_GOTREF(__pyx_t_2);
10622 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 711, __pyx_L1_error)
10623 __Pyx_GOTREF(__pyx_t_3);
10624 __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 711, __pyx_L1_error)
10625 __Pyx_GOTREF(__pyx_t_4);
10626 __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 711, __pyx_L1_error)
10627 __Pyx_GOTREF(__pyx_t_5);
10628 __Pyx_INCREF(__pyx_int_0);
10629 __Pyx_GIVEREF(__pyx_int_0);
10630 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_0);
10631 __Pyx_INCREF(__pyx_int_0);
10632 __Pyx_GIVEREF(__pyx_int_0);
10633 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
10634 __Pyx_GIVEREF(__pyx_t_3);
10635 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
10636 __Pyx_GIVEREF(__pyx_t_4);
10637 PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
10638 __pyx_t_3 = 0;
10639 __pyx_t_4 = 0;
10640 __pyx_t_4 = NULL;
10641 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
10642 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
10643 if (likely(__pyx_t_4)) {
10644 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
10645 __Pyx_INCREF(__pyx_t_4);
10646 __Pyx_INCREF(function);
10647 __Pyx_DECREF_SET(__pyx_t_2, function);
10648 }
10649 }
10650 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
10651 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10652 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10653 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 711, __pyx_L1_error)
10654 __Pyx_GOTREF(__pyx_t_1);
10655 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10656 __pyx_v_rv = __pyx_t_1;
10657 __pyx_t_1 = 0;
10658
10659 /* "pygame_sdl2/surface.pyx":713
10660 * rv = Rect((0, 0, self.surface.w, self.surface.h))
10661 *
10662 * for k, v in kwargs.items(): # <<<<<<<<<<<<<<
10663 * setattr(rv, k, v)
10664 *
10665 */
10666 __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
10667 __Pyx_GOTREF(__pyx_t_1);
10668 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
10669 __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
10670 __pyx_t_7 = NULL;
10671 } else {
10672 __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
10673 __Pyx_GOTREF(__pyx_t_2);
10674 __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 713, __pyx_L1_error)
10675 }
10676 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10677 for (;;) {
10678 if (likely(!__pyx_t_7)) {
10679 if (likely(PyList_CheckExact(__pyx_t_2))) {
10680 if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
10681 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10682 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
10683 #else
10684 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
10685 __Pyx_GOTREF(__pyx_t_1);
10686 #endif
10687 } else {
10688 if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
10689 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10690 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
10691 #else
10692 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
10693 __Pyx_GOTREF(__pyx_t_1);
10694 #endif
10695 }
10696 } else {
10697 __pyx_t_1 = __pyx_t_7(__pyx_t_2);
10698 if (unlikely(!__pyx_t_1)) {
10699 PyObject* exc_type = PyErr_Occurred();
10700 if (exc_type) {
10701 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10702 else __PYX_ERR(0, 713, __pyx_L1_error)
10703 }
10704 break;
10705 }
10706 __Pyx_GOTREF(__pyx_t_1);
10707 }
10708 if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
10709 PyObject* sequence = __pyx_t_1;
10710 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
10711 if (unlikely(size != 2)) {
10712 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
10713 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
10714 __PYX_ERR(0, 713, __pyx_L1_error)
10715 }
10716 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10717 if (likely(PyTuple_CheckExact(sequence))) {
10718 __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
10719 __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
10720 } else {
10721 __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
10722 __pyx_t_4 = PyList_GET_ITEM(sequence, 1);
10723 }
10724 __Pyx_INCREF(__pyx_t_5);
10725 __Pyx_INCREF(__pyx_t_4);
10726 #else
10727 __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 713, __pyx_L1_error)
10728 __Pyx_GOTREF(__pyx_t_5);
10729 __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 713, __pyx_L1_error)
10730 __Pyx_GOTREF(__pyx_t_4);
10731 #endif
10732 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10733 } else {
10734 Py_ssize_t index = -1;
10735 __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 713, __pyx_L1_error)
10736 __Pyx_GOTREF(__pyx_t_3);
10737 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10738 __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext;
10739 index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
10740 __Pyx_GOTREF(__pyx_t_5);
10741 index = 1; __pyx_t_4 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
10742 __Pyx_GOTREF(__pyx_t_4);
10743 if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_3), 2) < 0) __PYX_ERR(0, 713, __pyx_L1_error)
10744 __pyx_t_8 = NULL;
10745 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10746 goto __pyx_L6_unpacking_done;
10747 __pyx_L5_unpacking_failed:;
10748 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10749 __pyx_t_8 = NULL;
10750 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
10751 __PYX_ERR(0, 713, __pyx_L1_error)
10752 __pyx_L6_unpacking_done:;
10753 }
10754 __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
10755 __pyx_t_5 = 0;
10756 __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_4);
10757 __pyx_t_4 = 0;
10758
10759 /* "pygame_sdl2/surface.pyx":714
10760 *
10761 * for k, v in kwargs.items():
10762 * setattr(rv, k, v) # <<<<<<<<<<<<<<
10763 *
10764 * return rv
10765 */
10766 __pyx_t_9 = PyObject_SetAttr(__pyx_v_rv, __pyx_v_k, __pyx_v_v); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 714, __pyx_L1_error)
10767
10768 /* "pygame_sdl2/surface.pyx":713
10769 * rv = Rect((0, 0, self.surface.w, self.surface.h))
10770 *
10771 * for k, v in kwargs.items(): # <<<<<<<<<<<<<<
10772 * setattr(rv, k, v)
10773 *
10774 */
10775 }
10776 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10777
10778 /* "pygame_sdl2/surface.pyx":716
10779 * setattr(rv, k, v)
10780 *
10781 * return rv # <<<<<<<<<<<<<<
10782 *
10783 * def get_bitsize(self):
10784 */
10785 __Pyx_XDECREF(__pyx_r);
10786 __Pyx_INCREF(__pyx_v_rv);
10787 __pyx_r = __pyx_v_rv;
10788 goto __pyx_L0;
10789
10790 /* "pygame_sdl2/surface.pyx":710
10791 * return self.surface.h
10792 *
10793 * def get_rect(self, **kwargs): # <<<<<<<<<<<<<<
10794 * rv = Rect((0, 0, self.surface.w, self.surface.h))
10795 *
10796 */
10797
10798 /* function exit code */
10799 __pyx_L1_error:;
10800 __Pyx_XDECREF(__pyx_t_1);
10801 __Pyx_XDECREF(__pyx_t_2);
10802 __Pyx_XDECREF(__pyx_t_3);
10803 __Pyx_XDECREF(__pyx_t_4);
10804 __Pyx_XDECREF(__pyx_t_5);
10805 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_rect", __pyx_clineno, __pyx_lineno, __pyx_filename);
10806 __pyx_r = NULL;
10807 __pyx_L0:;
10808 __Pyx_XDECREF(__pyx_v_rv);
10809 __Pyx_XDECREF(__pyx_v_k);
10810 __Pyx_XDECREF(__pyx_v_v);
10811 __Pyx_XGIVEREF(__pyx_r);
10812 __Pyx_RefNannyFinishContext();
10813 return __pyx_r;
10814 }
10815
10816 /* "pygame_sdl2/surface.pyx":718
10817 * return rv
10818 *
10819 * def get_bitsize(self): # <<<<<<<<<<<<<<
10820 * return self.surface.format.BitsPerPixel
10821 *
10822 */
10823
10824 /* Python wrapper */
10825 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_73get_bitsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_73get_bitsize(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10826 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_73get_bitsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10827 PyObject *__pyx_r = 0;
10828 __Pyx_RefNannyDeclarations
10829 __Pyx_RefNannySetupContext("get_bitsize (wrapper)", 0);
10830 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_72get_bitsize(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10831
10832 /* function exit code */
10833 __Pyx_RefNannyFinishContext();
10834 return __pyx_r;
10835 }
10836
__pyx_pf_11pygame_sdl2_7surface_7Surface_72get_bitsize(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10837 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_72get_bitsize(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10838 PyObject *__pyx_r = NULL;
10839 __Pyx_RefNannyDeclarations
10840 PyObject *__pyx_t_1 = NULL;
10841 int __pyx_lineno = 0;
10842 const char *__pyx_filename = NULL;
10843 int __pyx_clineno = 0;
10844 __Pyx_RefNannySetupContext("get_bitsize", 0);
10845
10846 /* "pygame_sdl2/surface.pyx":719
10847 *
10848 * def get_bitsize(self):
10849 * return self.surface.format.BitsPerPixel # <<<<<<<<<<<<<<
10850 *
10851 * def get_bytesize(self):
10852 */
10853 __Pyx_XDECREF(__pyx_r);
10854 __pyx_t_1 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->surface->format->BitsPerPixel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error)
10855 __Pyx_GOTREF(__pyx_t_1);
10856 __pyx_r = __pyx_t_1;
10857 __pyx_t_1 = 0;
10858 goto __pyx_L0;
10859
10860 /* "pygame_sdl2/surface.pyx":718
10861 * return rv
10862 *
10863 * def get_bitsize(self): # <<<<<<<<<<<<<<
10864 * return self.surface.format.BitsPerPixel
10865 *
10866 */
10867
10868 /* function exit code */
10869 __pyx_L1_error:;
10870 __Pyx_XDECREF(__pyx_t_1);
10871 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_bitsize", __pyx_clineno, __pyx_lineno, __pyx_filename);
10872 __pyx_r = NULL;
10873 __pyx_L0:;
10874 __Pyx_XGIVEREF(__pyx_r);
10875 __Pyx_RefNannyFinishContext();
10876 return __pyx_r;
10877 }
10878
10879 /* "pygame_sdl2/surface.pyx":721
10880 * return self.surface.format.BitsPerPixel
10881 *
10882 * def get_bytesize(self): # <<<<<<<<<<<<<<
10883 * return self.surface.format.BytesPerPixel
10884 *
10885 */
10886
10887 /* Python wrapper */
10888 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_75get_bytesize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_75get_bytesize(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10889 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_75get_bytesize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10890 PyObject *__pyx_r = 0;
10891 __Pyx_RefNannyDeclarations
10892 __Pyx_RefNannySetupContext("get_bytesize (wrapper)", 0);
10893 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_74get_bytesize(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10894
10895 /* function exit code */
10896 __Pyx_RefNannyFinishContext();
10897 return __pyx_r;
10898 }
10899
__pyx_pf_11pygame_sdl2_7surface_7Surface_74get_bytesize(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10900 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_74get_bytesize(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10901 PyObject *__pyx_r = NULL;
10902 __Pyx_RefNannyDeclarations
10903 PyObject *__pyx_t_1 = NULL;
10904 int __pyx_lineno = 0;
10905 const char *__pyx_filename = NULL;
10906 int __pyx_clineno = 0;
10907 __Pyx_RefNannySetupContext("get_bytesize", 0);
10908
10909 /* "pygame_sdl2/surface.pyx":722
10910 *
10911 * def get_bytesize(self):
10912 * return self.surface.format.BytesPerPixel # <<<<<<<<<<<<<<
10913 *
10914 * def get_flags(self):
10915 */
10916 __Pyx_XDECREF(__pyx_r);
10917 __pyx_t_1 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->surface->format->BytesPerPixel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
10918 __Pyx_GOTREF(__pyx_t_1);
10919 __pyx_r = __pyx_t_1;
10920 __pyx_t_1 = 0;
10921 goto __pyx_L0;
10922
10923 /* "pygame_sdl2/surface.pyx":721
10924 * return self.surface.format.BitsPerPixel
10925 *
10926 * def get_bytesize(self): # <<<<<<<<<<<<<<
10927 * return self.surface.format.BytesPerPixel
10928 *
10929 */
10930
10931 /* function exit code */
10932 __pyx_L1_error:;
10933 __Pyx_XDECREF(__pyx_t_1);
10934 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_bytesize", __pyx_clineno, __pyx_lineno, __pyx_filename);
10935 __pyx_r = NULL;
10936 __pyx_L0:;
10937 __Pyx_XGIVEREF(__pyx_r);
10938 __Pyx_RefNannyFinishContext();
10939 return __pyx_r;
10940 }
10941
10942 /* "pygame_sdl2/surface.pyx":724
10943 * return self.surface.format.BytesPerPixel
10944 *
10945 * def get_flags(self): # <<<<<<<<<<<<<<
10946 *
10947 * if self.get_window_flags:
10948 */
10949
10950 /* Python wrapper */
10951 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_77get_flags(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_77get_flags(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10952 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_77get_flags(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10953 PyObject *__pyx_r = 0;
10954 __Pyx_RefNannyDeclarations
10955 __Pyx_RefNannySetupContext("get_flags (wrapper)", 0);
10956 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_76get_flags(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
10957
10958 /* function exit code */
10959 __Pyx_RefNannyFinishContext();
10960 return __pyx_r;
10961 }
10962
__pyx_pf_11pygame_sdl2_7surface_7Surface_76get_flags(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)10963 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_76get_flags(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
10964 PyObject *__pyx_v_rv = NULL;
10965 PyObject *__pyx_r = NULL;
10966 __Pyx_RefNannyDeclarations
10967 int __pyx_t_1;
10968 PyObject *__pyx_t_2 = NULL;
10969 PyObject *__pyx_t_3 = NULL;
10970 PyObject *__pyx_t_4 = NULL;
10971 int __pyx_t_5;
10972 int __pyx_lineno = 0;
10973 const char *__pyx_filename = NULL;
10974 int __pyx_clineno = 0;
10975 __Pyx_RefNannySetupContext("get_flags", 0);
10976
10977 /* "pygame_sdl2/surface.pyx":726
10978 * def get_flags(self):
10979 *
10980 * if self.get_window_flags: # <<<<<<<<<<<<<<
10981 * rv = self.get_window_flags()
10982 * else:
10983 */
10984 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->get_window_flags); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 726, __pyx_L1_error)
10985 if (__pyx_t_1) {
10986
10987 /* "pygame_sdl2/surface.pyx":727
10988 *
10989 * if self.get_window_flags:
10990 * rv = self.get_window_flags() # <<<<<<<<<<<<<<
10991 * else:
10992 * rv = 0
10993 */
10994 __Pyx_INCREF(__pyx_v_self->get_window_flags);
10995 __pyx_t_3 = __pyx_v_self->get_window_flags; __pyx_t_4 = NULL;
10996 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
10997 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
10998 if (likely(__pyx_t_4)) {
10999 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11000 __Pyx_INCREF(__pyx_t_4);
11001 __Pyx_INCREF(function);
11002 __Pyx_DECREF_SET(__pyx_t_3, function);
11003 }
11004 }
11005 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
11006 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
11007 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 727, __pyx_L1_error)
11008 __Pyx_GOTREF(__pyx_t_2);
11009 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11010 __pyx_v_rv = __pyx_t_2;
11011 __pyx_t_2 = 0;
11012
11013 /* "pygame_sdl2/surface.pyx":726
11014 * def get_flags(self):
11015 *
11016 * if self.get_window_flags: # <<<<<<<<<<<<<<
11017 * rv = self.get_window_flags()
11018 * else:
11019 */
11020 goto __pyx_L3;
11021 }
11022
11023 /* "pygame_sdl2/surface.pyx":729
11024 * rv = self.get_window_flags()
11025 * else:
11026 * rv = 0 # <<<<<<<<<<<<<<
11027 *
11028 * if self.surface.format.Amask or self.has_alpha:
11029 */
11030 /*else*/ {
11031 __Pyx_INCREF(__pyx_int_0);
11032 __pyx_v_rv = __pyx_int_0;
11033 }
11034 __pyx_L3:;
11035
11036 /* "pygame_sdl2/surface.pyx":731
11037 * rv = 0
11038 *
11039 * if self.surface.format.Amask or self.has_alpha: # <<<<<<<<<<<<<<
11040 * rv = rv | SRCALPHA
11041 *
11042 */
11043 __pyx_t_5 = (__pyx_v_self->surface->format->Amask != 0);
11044 if (!__pyx_t_5) {
11045 } else {
11046 __pyx_t_1 = __pyx_t_5;
11047 goto __pyx_L5_bool_binop_done;
11048 }
11049 __pyx_t_5 = (__pyx_v_self->has_alpha != 0);
11050 __pyx_t_1 = __pyx_t_5;
11051 __pyx_L5_bool_binop_done:;
11052 if (__pyx_t_1) {
11053
11054 /* "pygame_sdl2/surface.pyx":732
11055 *
11056 * if self.surface.format.Amask or self.has_alpha:
11057 * rv = rv | SRCALPHA # <<<<<<<<<<<<<<
11058 *
11059 * return rv
11060 */
11061 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
11062 __Pyx_GOTREF(__pyx_t_2);
11063 __pyx_t_3 = PyNumber_Or(__pyx_v_rv, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 732, __pyx_L1_error)
11064 __Pyx_GOTREF(__pyx_t_3);
11065 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11066 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3);
11067 __pyx_t_3 = 0;
11068
11069 /* "pygame_sdl2/surface.pyx":731
11070 * rv = 0
11071 *
11072 * if self.surface.format.Amask or self.has_alpha: # <<<<<<<<<<<<<<
11073 * rv = rv | SRCALPHA
11074 *
11075 */
11076 }
11077
11078 /* "pygame_sdl2/surface.pyx":734
11079 * rv = rv | SRCALPHA
11080 *
11081 * return rv # <<<<<<<<<<<<<<
11082 *
11083 * def get_pitch(self):
11084 */
11085 __Pyx_XDECREF(__pyx_r);
11086 __Pyx_INCREF(__pyx_v_rv);
11087 __pyx_r = __pyx_v_rv;
11088 goto __pyx_L0;
11089
11090 /* "pygame_sdl2/surface.pyx":724
11091 * return self.surface.format.BytesPerPixel
11092 *
11093 * def get_flags(self): # <<<<<<<<<<<<<<
11094 *
11095 * if self.get_window_flags:
11096 */
11097
11098 /* function exit code */
11099 __pyx_L1_error:;
11100 __Pyx_XDECREF(__pyx_t_2);
11101 __Pyx_XDECREF(__pyx_t_3);
11102 __Pyx_XDECREF(__pyx_t_4);
11103 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
11104 __pyx_r = NULL;
11105 __pyx_L0:;
11106 __Pyx_XDECREF(__pyx_v_rv);
11107 __Pyx_XGIVEREF(__pyx_r);
11108 __Pyx_RefNannyFinishContext();
11109 return __pyx_r;
11110 }
11111
11112 /* "pygame_sdl2/surface.pyx":736
11113 * return rv
11114 *
11115 * def get_pitch(self): # <<<<<<<<<<<<<<
11116 * return self.surface.pitch
11117 *
11118 */
11119
11120 /* Python wrapper */
11121 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_79get_pitch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_79get_pitch(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11122 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_79get_pitch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11123 PyObject *__pyx_r = 0;
11124 __Pyx_RefNannyDeclarations
11125 __Pyx_RefNannySetupContext("get_pitch (wrapper)", 0);
11126 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_78get_pitch(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
11127
11128 /* function exit code */
11129 __Pyx_RefNannyFinishContext();
11130 return __pyx_r;
11131 }
11132
__pyx_pf_11pygame_sdl2_7surface_7Surface_78get_pitch(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)11133 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_78get_pitch(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
11134 PyObject *__pyx_r = NULL;
11135 __Pyx_RefNannyDeclarations
11136 PyObject *__pyx_t_1 = NULL;
11137 int __pyx_lineno = 0;
11138 const char *__pyx_filename = NULL;
11139 int __pyx_clineno = 0;
11140 __Pyx_RefNannySetupContext("get_pitch", 0);
11141
11142 /* "pygame_sdl2/surface.pyx":737
11143 *
11144 * def get_pitch(self):
11145 * return self.surface.pitch # <<<<<<<<<<<<<<
11146 *
11147 * def get_masks(self):
11148 */
11149 __Pyx_XDECREF(__pyx_r);
11150 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->surface->pitch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 737, __pyx_L1_error)
11151 __Pyx_GOTREF(__pyx_t_1);
11152 __pyx_r = __pyx_t_1;
11153 __pyx_t_1 = 0;
11154 goto __pyx_L0;
11155
11156 /* "pygame_sdl2/surface.pyx":736
11157 * return rv
11158 *
11159 * def get_pitch(self): # <<<<<<<<<<<<<<
11160 * return self.surface.pitch
11161 *
11162 */
11163
11164 /* function exit code */
11165 __pyx_L1_error:;
11166 __Pyx_XDECREF(__pyx_t_1);
11167 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_pitch", __pyx_clineno, __pyx_lineno, __pyx_filename);
11168 __pyx_r = NULL;
11169 __pyx_L0:;
11170 __Pyx_XGIVEREF(__pyx_r);
11171 __Pyx_RefNannyFinishContext();
11172 return __pyx_r;
11173 }
11174
11175 /* "pygame_sdl2/surface.pyx":739
11176 * return self.surface.pitch
11177 *
11178 * def get_masks(self): # <<<<<<<<<<<<<<
11179 * cdef SDL_PixelFormat *format = self.surface.format
11180 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask)
11181 */
11182
11183 /* Python wrapper */
11184 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_81get_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_81get_masks(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11185 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_81get_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11186 PyObject *__pyx_r = 0;
11187 __Pyx_RefNannyDeclarations
11188 __Pyx_RefNannySetupContext("get_masks (wrapper)", 0);
11189 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_80get_masks(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
11190
11191 /* function exit code */
11192 __Pyx_RefNannyFinishContext();
11193 return __pyx_r;
11194 }
11195
__pyx_pf_11pygame_sdl2_7surface_7Surface_80get_masks(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)11196 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_80get_masks(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
11197 SDL_PixelFormat *__pyx_v_format;
11198 PyObject *__pyx_r = NULL;
11199 __Pyx_RefNannyDeclarations
11200 SDL_PixelFormat *__pyx_t_1;
11201 PyObject *__pyx_t_2 = NULL;
11202 PyObject *__pyx_t_3 = NULL;
11203 PyObject *__pyx_t_4 = NULL;
11204 PyObject *__pyx_t_5 = NULL;
11205 PyObject *__pyx_t_6 = NULL;
11206 int __pyx_lineno = 0;
11207 const char *__pyx_filename = NULL;
11208 int __pyx_clineno = 0;
11209 __Pyx_RefNannySetupContext("get_masks", 0);
11210
11211 /* "pygame_sdl2/surface.pyx":740
11212 *
11213 * def get_masks(self):
11214 * cdef SDL_PixelFormat *format = self.surface.format # <<<<<<<<<<<<<<
11215 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask)
11216 *
11217 */
11218 __pyx_t_1 = __pyx_v_self->surface->format;
11219 __pyx_v_format = __pyx_t_1;
11220
11221 /* "pygame_sdl2/surface.pyx":741
11222 * def get_masks(self):
11223 * cdef SDL_PixelFormat *format = self.surface.format
11224 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask) # <<<<<<<<<<<<<<
11225 *
11226 * def set_masks(self, masks):
11227 */
11228 __Pyx_XDECREF(__pyx_r);
11229 __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_format->Rmask); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
11230 __Pyx_GOTREF(__pyx_t_2);
11231 __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_format->Gmask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
11232 __Pyx_GOTREF(__pyx_t_3);
11233 __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_format->Bmask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
11234 __Pyx_GOTREF(__pyx_t_4);
11235 __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_format->Amask); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 741, __pyx_L1_error)
11236 __Pyx_GOTREF(__pyx_t_5);
11237 __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 741, __pyx_L1_error)
11238 __Pyx_GOTREF(__pyx_t_6);
11239 __Pyx_GIVEREF(__pyx_t_2);
11240 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
11241 __Pyx_GIVEREF(__pyx_t_3);
11242 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
11243 __Pyx_GIVEREF(__pyx_t_4);
11244 PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
11245 __Pyx_GIVEREF(__pyx_t_5);
11246 PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
11247 __pyx_t_2 = 0;
11248 __pyx_t_3 = 0;
11249 __pyx_t_4 = 0;
11250 __pyx_t_5 = 0;
11251 __pyx_r = __pyx_t_6;
11252 __pyx_t_6 = 0;
11253 goto __pyx_L0;
11254
11255 /* "pygame_sdl2/surface.pyx":739
11256 * return self.surface.pitch
11257 *
11258 * def get_masks(self): # <<<<<<<<<<<<<<
11259 * cdef SDL_PixelFormat *format = self.surface.format
11260 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask)
11261 */
11262
11263 /* function exit code */
11264 __pyx_L1_error:;
11265 __Pyx_XDECREF(__pyx_t_2);
11266 __Pyx_XDECREF(__pyx_t_3);
11267 __Pyx_XDECREF(__pyx_t_4);
11268 __Pyx_XDECREF(__pyx_t_5);
11269 __Pyx_XDECREF(__pyx_t_6);
11270 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_masks", __pyx_clineno, __pyx_lineno, __pyx_filename);
11271 __pyx_r = NULL;
11272 __pyx_L0:;
11273 __Pyx_XGIVEREF(__pyx_r);
11274 __Pyx_RefNannyFinishContext();
11275 return __pyx_r;
11276 }
11277
11278 /* "pygame_sdl2/surface.pyx":743
11279 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask)
11280 *
11281 * def set_masks(self, masks): # <<<<<<<<<<<<<<
11282 * warnings.warn("Surface.set_masks is not supported.")
11283 *
11284 */
11285
11286 /* Python wrapper */
11287 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_83set_masks(PyObject *__pyx_v_self, PyObject *__pyx_v_masks); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_83set_masks(PyObject * __pyx_v_self,PyObject * __pyx_v_masks)11288 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_83set_masks(PyObject *__pyx_v_self, PyObject *__pyx_v_masks) {
11289 PyObject *__pyx_r = 0;
11290 __Pyx_RefNannyDeclarations
11291 __Pyx_RefNannySetupContext("set_masks (wrapper)", 0);
11292 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_82set_masks(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_masks));
11293
11294 /* function exit code */
11295 __Pyx_RefNannyFinishContext();
11296 return __pyx_r;
11297 }
11298
__pyx_pf_11pygame_sdl2_7surface_7Surface_82set_masks(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v_masks)11299 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_82set_masks(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_masks) {
11300 PyObject *__pyx_r = NULL;
11301 __Pyx_RefNannyDeclarations
11302 PyObject *__pyx_t_1 = NULL;
11303 PyObject *__pyx_t_2 = NULL;
11304 PyObject *__pyx_t_3 = NULL;
11305 int __pyx_lineno = 0;
11306 const char *__pyx_filename = NULL;
11307 int __pyx_clineno = 0;
11308 __Pyx_RefNannySetupContext("set_masks", 0);
11309
11310 /* "pygame_sdl2/surface.pyx":744
11311 *
11312 * def set_masks(self, masks):
11313 * warnings.warn("Surface.set_masks is not supported.") # <<<<<<<<<<<<<<
11314 *
11315 * def get_shifts(self):
11316 */
11317 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
11318 __Pyx_GOTREF(__pyx_t_2);
11319 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 744, __pyx_L1_error)
11320 __Pyx_GOTREF(__pyx_t_3);
11321 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11322 __pyx_t_2 = NULL;
11323 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
11324 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
11325 if (likely(__pyx_t_2)) {
11326 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11327 __Pyx_INCREF(__pyx_t_2);
11328 __Pyx_INCREF(function);
11329 __Pyx_DECREF_SET(__pyx_t_3, function);
11330 }
11331 }
11332 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_s_Surface_set_masks_is_not_support) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Surface_set_masks_is_not_support);
11333 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
11334 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
11335 __Pyx_GOTREF(__pyx_t_1);
11336 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11337 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11338
11339 /* "pygame_sdl2/surface.pyx":743
11340 * return (format.Rmask, format.Gmask, format.Bmask, format.Amask)
11341 *
11342 * def set_masks(self, masks): # <<<<<<<<<<<<<<
11343 * warnings.warn("Surface.set_masks is not supported.")
11344 *
11345 */
11346
11347 /* function exit code */
11348 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11349 goto __pyx_L0;
11350 __pyx_L1_error:;
11351 __Pyx_XDECREF(__pyx_t_1);
11352 __Pyx_XDECREF(__pyx_t_2);
11353 __Pyx_XDECREF(__pyx_t_3);
11354 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_masks", __pyx_clineno, __pyx_lineno, __pyx_filename);
11355 __pyx_r = NULL;
11356 __pyx_L0:;
11357 __Pyx_XGIVEREF(__pyx_r);
11358 __Pyx_RefNannyFinishContext();
11359 return __pyx_r;
11360 }
11361
11362 /* "pygame_sdl2/surface.pyx":746
11363 * warnings.warn("Surface.set_masks is not supported.")
11364 *
11365 * def get_shifts(self): # <<<<<<<<<<<<<<
11366 * cdef SDL_PixelFormat *format = self.surface.format
11367 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11368 */
11369
11370 /* Python wrapper */
11371 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_85get_shifts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_85get_shifts(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11372 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_85get_shifts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11373 PyObject *__pyx_r = 0;
11374 __Pyx_RefNannyDeclarations
11375 __Pyx_RefNannySetupContext("get_shifts (wrapper)", 0);
11376 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_84get_shifts(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
11377
11378 /* function exit code */
11379 __Pyx_RefNannyFinishContext();
11380 return __pyx_r;
11381 }
11382
__pyx_pf_11pygame_sdl2_7surface_7Surface_84get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)11383 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_84get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
11384 SDL_PixelFormat *__pyx_v_format;
11385 PyObject *__pyx_r = NULL;
11386 __Pyx_RefNannyDeclarations
11387 SDL_PixelFormat *__pyx_t_1;
11388 PyObject *__pyx_t_2 = NULL;
11389 PyObject *__pyx_t_3 = NULL;
11390 PyObject *__pyx_t_4 = NULL;
11391 PyObject *__pyx_t_5 = NULL;
11392 PyObject *__pyx_t_6 = NULL;
11393 int __pyx_lineno = 0;
11394 const char *__pyx_filename = NULL;
11395 int __pyx_clineno = 0;
11396 __Pyx_RefNannySetupContext("get_shifts", 0);
11397
11398 /* "pygame_sdl2/surface.pyx":747
11399 *
11400 * def get_shifts(self):
11401 * cdef SDL_PixelFormat *format = self.surface.format # <<<<<<<<<<<<<<
11402 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11403 *
11404 */
11405 __pyx_t_1 = __pyx_v_self->surface->format;
11406 __pyx_v_format = __pyx_t_1;
11407
11408 /* "pygame_sdl2/surface.pyx":748
11409 * def get_shifts(self):
11410 * cdef SDL_PixelFormat *format = self.surface.format
11411 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift) # <<<<<<<<<<<<<<
11412 *
11413 * def set_shifts(self, shifts):
11414 */
11415 __Pyx_XDECREF(__pyx_r);
11416 __pyx_t_2 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Rshift); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 748, __pyx_L1_error)
11417 __Pyx_GOTREF(__pyx_t_2);
11418 __pyx_t_3 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Gshift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
11419 __Pyx_GOTREF(__pyx_t_3);
11420 __pyx_t_4 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Bshift); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 748, __pyx_L1_error)
11421 __Pyx_GOTREF(__pyx_t_4);
11422 __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Ashift); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 748, __pyx_L1_error)
11423 __Pyx_GOTREF(__pyx_t_5);
11424 __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 748, __pyx_L1_error)
11425 __Pyx_GOTREF(__pyx_t_6);
11426 __Pyx_GIVEREF(__pyx_t_2);
11427 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
11428 __Pyx_GIVEREF(__pyx_t_3);
11429 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
11430 __Pyx_GIVEREF(__pyx_t_4);
11431 PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
11432 __Pyx_GIVEREF(__pyx_t_5);
11433 PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
11434 __pyx_t_2 = 0;
11435 __pyx_t_3 = 0;
11436 __pyx_t_4 = 0;
11437 __pyx_t_5 = 0;
11438 __pyx_r = __pyx_t_6;
11439 __pyx_t_6 = 0;
11440 goto __pyx_L0;
11441
11442 /* "pygame_sdl2/surface.pyx":746
11443 * warnings.warn("Surface.set_masks is not supported.")
11444 *
11445 * def get_shifts(self): # <<<<<<<<<<<<<<
11446 * cdef SDL_PixelFormat *format = self.surface.format
11447 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11448 */
11449
11450 /* function exit code */
11451 __pyx_L1_error:;
11452 __Pyx_XDECREF(__pyx_t_2);
11453 __Pyx_XDECREF(__pyx_t_3);
11454 __Pyx_XDECREF(__pyx_t_4);
11455 __Pyx_XDECREF(__pyx_t_5);
11456 __Pyx_XDECREF(__pyx_t_6);
11457 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_shifts", __pyx_clineno, __pyx_lineno, __pyx_filename);
11458 __pyx_r = NULL;
11459 __pyx_L0:;
11460 __Pyx_XGIVEREF(__pyx_r);
11461 __Pyx_RefNannyFinishContext();
11462 return __pyx_r;
11463 }
11464
11465 /* "pygame_sdl2/surface.pyx":750
11466 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11467 *
11468 * def set_shifts(self, shifts): # <<<<<<<<<<<<<<
11469 * warnings.warn("Surface.set_shifts is not supported.")
11470 *
11471 */
11472
11473 /* Python wrapper */
11474 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_87set_shifts(PyObject *__pyx_v_self, PyObject *__pyx_v_shifts); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_87set_shifts(PyObject * __pyx_v_self,PyObject * __pyx_v_shifts)11475 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_87set_shifts(PyObject *__pyx_v_self, PyObject *__pyx_v_shifts) {
11476 PyObject *__pyx_r = 0;
11477 __Pyx_RefNannyDeclarations
11478 __Pyx_RefNannySetupContext("set_shifts (wrapper)", 0);
11479 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_86set_shifts(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v_shifts));
11480
11481 /* function exit code */
11482 __Pyx_RefNannyFinishContext();
11483 return __pyx_r;
11484 }
11485
__pyx_pf_11pygame_sdl2_7surface_7Surface_86set_shifts(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v_shifts)11486 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_86set_shifts(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_shifts) {
11487 PyObject *__pyx_r = NULL;
11488 __Pyx_RefNannyDeclarations
11489 PyObject *__pyx_t_1 = NULL;
11490 PyObject *__pyx_t_2 = NULL;
11491 PyObject *__pyx_t_3 = NULL;
11492 int __pyx_lineno = 0;
11493 const char *__pyx_filename = NULL;
11494 int __pyx_clineno = 0;
11495 __Pyx_RefNannySetupContext("set_shifts", 0);
11496
11497 /* "pygame_sdl2/surface.pyx":751
11498 *
11499 * def set_shifts(self, shifts):
11500 * warnings.warn("Surface.set_shifts is not supported.") # <<<<<<<<<<<<<<
11501 *
11502 * def get_shifts(self):
11503 */
11504 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error)
11505 __Pyx_GOTREF(__pyx_t_2);
11506 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
11507 __Pyx_GOTREF(__pyx_t_3);
11508 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11509 __pyx_t_2 = NULL;
11510 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
11511 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
11512 if (likely(__pyx_t_2)) {
11513 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11514 __Pyx_INCREF(__pyx_t_2);
11515 __Pyx_INCREF(function);
11516 __Pyx_DECREF_SET(__pyx_t_3, function);
11517 }
11518 }
11519 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_s_Surface_set_shifts_is_not_suppor) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Surface_set_shifts_is_not_suppor);
11520 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
11521 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
11522 __Pyx_GOTREF(__pyx_t_1);
11523 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11524 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11525
11526 /* "pygame_sdl2/surface.pyx":750
11527 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11528 *
11529 * def set_shifts(self, shifts): # <<<<<<<<<<<<<<
11530 * warnings.warn("Surface.set_shifts is not supported.")
11531 *
11532 */
11533
11534 /* function exit code */
11535 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11536 goto __pyx_L0;
11537 __pyx_L1_error:;
11538 __Pyx_XDECREF(__pyx_t_1);
11539 __Pyx_XDECREF(__pyx_t_2);
11540 __Pyx_XDECREF(__pyx_t_3);
11541 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.set_shifts", __pyx_clineno, __pyx_lineno, __pyx_filename);
11542 __pyx_r = NULL;
11543 __pyx_L0:;
11544 __Pyx_XGIVEREF(__pyx_r);
11545 __Pyx_RefNannyFinishContext();
11546 return __pyx_r;
11547 }
11548
11549 /* "pygame_sdl2/surface.pyx":753
11550 * warnings.warn("Surface.set_shifts is not supported.")
11551 *
11552 * def get_shifts(self): # <<<<<<<<<<<<<<
11553 * cdef SDL_PixelFormat *format = self.surface.format
11554 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11555 */
11556
11557 /* Python wrapper */
11558 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_89get_shifts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_89get_shifts(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11559 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_89get_shifts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11560 PyObject *__pyx_r = 0;
11561 __Pyx_RefNannyDeclarations
11562 __Pyx_RefNannySetupContext("get_shifts (wrapper)", 0);
11563 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_88get_shifts(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
11564
11565 /* function exit code */
11566 __Pyx_RefNannyFinishContext();
11567 return __pyx_r;
11568 }
11569
__pyx_pf_11pygame_sdl2_7surface_7Surface_88get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)11570 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_88get_shifts(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
11571 SDL_PixelFormat *__pyx_v_format;
11572 PyObject *__pyx_r = NULL;
11573 __Pyx_RefNannyDeclarations
11574 SDL_PixelFormat *__pyx_t_1;
11575 PyObject *__pyx_t_2 = NULL;
11576 PyObject *__pyx_t_3 = NULL;
11577 PyObject *__pyx_t_4 = NULL;
11578 PyObject *__pyx_t_5 = NULL;
11579 PyObject *__pyx_t_6 = NULL;
11580 int __pyx_lineno = 0;
11581 const char *__pyx_filename = NULL;
11582 int __pyx_clineno = 0;
11583 __Pyx_RefNannySetupContext("get_shifts", 0);
11584
11585 /* "pygame_sdl2/surface.pyx":754
11586 *
11587 * def get_shifts(self):
11588 * cdef SDL_PixelFormat *format = self.surface.format # <<<<<<<<<<<<<<
11589 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11590 *
11591 */
11592 __pyx_t_1 = __pyx_v_self->surface->format;
11593 __pyx_v_format = __pyx_t_1;
11594
11595 /* "pygame_sdl2/surface.pyx":755
11596 * def get_shifts(self):
11597 * cdef SDL_PixelFormat *format = self.surface.format
11598 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift) # <<<<<<<<<<<<<<
11599 *
11600 * def get_losses(self):
11601 */
11602 __Pyx_XDECREF(__pyx_r);
11603 __pyx_t_2 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Rshift); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
11604 __Pyx_GOTREF(__pyx_t_2);
11605 __pyx_t_3 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Gshift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error)
11606 __Pyx_GOTREF(__pyx_t_3);
11607 __pyx_t_4 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Bshift); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 755, __pyx_L1_error)
11608 __Pyx_GOTREF(__pyx_t_4);
11609 __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Ashift); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 755, __pyx_L1_error)
11610 __Pyx_GOTREF(__pyx_t_5);
11611 __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 755, __pyx_L1_error)
11612 __Pyx_GOTREF(__pyx_t_6);
11613 __Pyx_GIVEREF(__pyx_t_2);
11614 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
11615 __Pyx_GIVEREF(__pyx_t_3);
11616 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
11617 __Pyx_GIVEREF(__pyx_t_4);
11618 PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
11619 __Pyx_GIVEREF(__pyx_t_5);
11620 PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
11621 __pyx_t_2 = 0;
11622 __pyx_t_3 = 0;
11623 __pyx_t_4 = 0;
11624 __pyx_t_5 = 0;
11625 __pyx_r = __pyx_t_6;
11626 __pyx_t_6 = 0;
11627 goto __pyx_L0;
11628
11629 /* "pygame_sdl2/surface.pyx":753
11630 * warnings.warn("Surface.set_shifts is not supported.")
11631 *
11632 * def get_shifts(self): # <<<<<<<<<<<<<<
11633 * cdef SDL_PixelFormat *format = self.surface.format
11634 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11635 */
11636
11637 /* function exit code */
11638 __pyx_L1_error:;
11639 __Pyx_XDECREF(__pyx_t_2);
11640 __Pyx_XDECREF(__pyx_t_3);
11641 __Pyx_XDECREF(__pyx_t_4);
11642 __Pyx_XDECREF(__pyx_t_5);
11643 __Pyx_XDECREF(__pyx_t_6);
11644 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_shifts", __pyx_clineno, __pyx_lineno, __pyx_filename);
11645 __pyx_r = NULL;
11646 __pyx_L0:;
11647 __Pyx_XGIVEREF(__pyx_r);
11648 __Pyx_RefNannyFinishContext();
11649 return __pyx_r;
11650 }
11651
11652 /* "pygame_sdl2/surface.pyx":757
11653 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11654 *
11655 * def get_losses(self): # <<<<<<<<<<<<<<
11656 * cdef SDL_PixelFormat *format = self.surface.format
11657 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss)
11658 */
11659
11660 /* Python wrapper */
11661 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_91get_losses(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_91get_losses(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11662 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_91get_losses(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11663 PyObject *__pyx_r = 0;
11664 __Pyx_RefNannyDeclarations
11665 __Pyx_RefNannySetupContext("get_losses (wrapper)", 0);
11666 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_90get_losses(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
11667
11668 /* function exit code */
11669 __Pyx_RefNannyFinishContext();
11670 return __pyx_r;
11671 }
11672
__pyx_pf_11pygame_sdl2_7surface_7Surface_90get_losses(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)11673 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_90get_losses(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
11674 SDL_PixelFormat *__pyx_v_format;
11675 PyObject *__pyx_r = NULL;
11676 __Pyx_RefNannyDeclarations
11677 SDL_PixelFormat *__pyx_t_1;
11678 PyObject *__pyx_t_2 = NULL;
11679 PyObject *__pyx_t_3 = NULL;
11680 PyObject *__pyx_t_4 = NULL;
11681 PyObject *__pyx_t_5 = NULL;
11682 PyObject *__pyx_t_6 = NULL;
11683 int __pyx_lineno = 0;
11684 const char *__pyx_filename = NULL;
11685 int __pyx_clineno = 0;
11686 __Pyx_RefNannySetupContext("get_losses", 0);
11687
11688 /* "pygame_sdl2/surface.pyx":758
11689 *
11690 * def get_losses(self):
11691 * cdef SDL_PixelFormat *format = self.surface.format # <<<<<<<<<<<<<<
11692 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss)
11693 *
11694 */
11695 __pyx_t_1 = __pyx_v_self->surface->format;
11696 __pyx_v_format = __pyx_t_1;
11697
11698 /* "pygame_sdl2/surface.pyx":759
11699 * def get_losses(self):
11700 * cdef SDL_PixelFormat *format = self.surface.format
11701 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss) # <<<<<<<<<<<<<<
11702 *
11703 * def get_bounding_rect(self, min_alpha=1):
11704 */
11705 __Pyx_XDECREF(__pyx_r);
11706 __pyx_t_2 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Rloss); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
11707 __Pyx_GOTREF(__pyx_t_2);
11708 __pyx_t_3 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Gloss); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
11709 __Pyx_GOTREF(__pyx_t_3);
11710 __pyx_t_4 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Bloss); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 759, __pyx_L1_error)
11711 __Pyx_GOTREF(__pyx_t_4);
11712 __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_format->Aloss); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 759, __pyx_L1_error)
11713 __Pyx_GOTREF(__pyx_t_5);
11714 __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 759, __pyx_L1_error)
11715 __Pyx_GOTREF(__pyx_t_6);
11716 __Pyx_GIVEREF(__pyx_t_2);
11717 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
11718 __Pyx_GIVEREF(__pyx_t_3);
11719 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
11720 __Pyx_GIVEREF(__pyx_t_4);
11721 PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
11722 __Pyx_GIVEREF(__pyx_t_5);
11723 PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
11724 __pyx_t_2 = 0;
11725 __pyx_t_3 = 0;
11726 __pyx_t_4 = 0;
11727 __pyx_t_5 = 0;
11728 __pyx_r = __pyx_t_6;
11729 __pyx_t_6 = 0;
11730 goto __pyx_L0;
11731
11732 /* "pygame_sdl2/surface.pyx":757
11733 * return (format.Rshift, format.Gshift, format.Bshift, format.Ashift)
11734 *
11735 * def get_losses(self): # <<<<<<<<<<<<<<
11736 * cdef SDL_PixelFormat *format = self.surface.format
11737 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss)
11738 */
11739
11740 /* function exit code */
11741 __pyx_L1_error:;
11742 __Pyx_XDECREF(__pyx_t_2);
11743 __Pyx_XDECREF(__pyx_t_3);
11744 __Pyx_XDECREF(__pyx_t_4);
11745 __Pyx_XDECREF(__pyx_t_5);
11746 __Pyx_XDECREF(__pyx_t_6);
11747 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_losses", __pyx_clineno, __pyx_lineno, __pyx_filename);
11748 __pyx_r = NULL;
11749 __pyx_L0:;
11750 __Pyx_XGIVEREF(__pyx_r);
11751 __Pyx_RefNannyFinishContext();
11752 return __pyx_r;
11753 }
11754
11755 /* "pygame_sdl2/surface.pyx":761
11756 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss)
11757 *
11758 * def get_bounding_rect(self, min_alpha=1): # <<<<<<<<<<<<<<
11759 *
11760 * cdef Uint32 amask = self.surface.format.Amask
11761 */
11762
11763 /* Python wrapper */
11764 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_93get_bounding_rect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_93get_bounding_rect(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)11765 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_93get_bounding_rect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11766 PyObject *__pyx_v_min_alpha = 0;
11767 int __pyx_lineno = 0;
11768 const char *__pyx_filename = NULL;
11769 int __pyx_clineno = 0;
11770 PyObject *__pyx_r = 0;
11771 __Pyx_RefNannyDeclarations
11772 __Pyx_RefNannySetupContext("get_bounding_rect (wrapper)", 0);
11773 {
11774 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_min_alpha,0};
11775 PyObject* values[1] = {0};
11776 values[0] = ((PyObject *)__pyx_int_1);
11777 if (unlikely(__pyx_kwds)) {
11778 Py_ssize_t kw_args;
11779 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11780 switch (pos_args) {
11781 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11782 CYTHON_FALLTHROUGH;
11783 case 0: break;
11784 default: goto __pyx_L5_argtuple_error;
11785 }
11786 kw_args = PyDict_Size(__pyx_kwds);
11787 switch (pos_args) {
11788 case 0:
11789 if (kw_args > 0) {
11790 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_alpha);
11791 if (value) { values[0] = value; kw_args--; }
11792 }
11793 }
11794 if (unlikely(kw_args > 0)) {
11795 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_bounding_rect") < 0)) __PYX_ERR(0, 761, __pyx_L3_error)
11796 }
11797 } else {
11798 switch (PyTuple_GET_SIZE(__pyx_args)) {
11799 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11800 CYTHON_FALLTHROUGH;
11801 case 0: break;
11802 default: goto __pyx_L5_argtuple_error;
11803 }
11804 }
11805 __pyx_v_min_alpha = values[0];
11806 }
11807 goto __pyx_L4_argument_unpacking_done;
11808 __pyx_L5_argtuple_error:;
11809 __Pyx_RaiseArgtupleInvalid("get_bounding_rect", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 761, __pyx_L3_error)
11810 __pyx_L3_error:;
11811 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_bounding_rect", __pyx_clineno, __pyx_lineno, __pyx_filename);
11812 __Pyx_RefNannyFinishContext();
11813 return NULL;
11814 __pyx_L4_argument_unpacking_done:;
11815 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_92get_bounding_rect(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_min_alpha);
11816
11817 /* function exit code */
11818 __Pyx_RefNannyFinishContext();
11819 return __pyx_r;
11820 }
11821
__pyx_pf_11pygame_sdl2_7surface_7Surface_92get_bounding_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,PyObject * __pyx_v_min_alpha)11822 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_92get_bounding_rect(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, PyObject *__pyx_v_min_alpha) {
11823 Uint32 __pyx_v_amask;
11824 Uint32 __pyx_v_amin;
11825 int __pyx_v_x;
11826 int __pyx_v_y;
11827 int __pyx_v_w;
11828 int __pyx_v_h;
11829 int __pyx_v_minx;
11830 int __pyx_v_maxx;
11831 int __pyx_v_miny;
11832 int __pyx_v_maxy;
11833 Uint32 *__pyx_v_row;
11834 Uint32 __pyx_v_topleft;
11835 Uint32 __pyx_v_botright;
11836 Uint8 *__pyx_v_pixels;
11837 PyObject *__pyx_r = NULL;
11838 __Pyx_RefNannyDeclarations
11839 Uint32 __pyx_t_1;
11840 PyObject *__pyx_t_2 = NULL;
11841 PyObject *__pyx_t_3 = NULL;
11842 PyObject *__pyx_t_4 = NULL;
11843 int __pyx_t_5;
11844 int __pyx_t_6;
11845 PyObject *__pyx_t_7 = NULL;
11846 PyObject *__pyx_t_8 = NULL;
11847 int __pyx_t_9;
11848 int __pyx_t_10;
11849 long __pyx_t_11;
11850 long __pyx_t_12;
11851 PyObject *__pyx_t_13 = NULL;
11852 PyObject *__pyx_t_14 = NULL;
11853 int __pyx_lineno = 0;
11854 const char *__pyx_filename = NULL;
11855 int __pyx_clineno = 0;
11856 __Pyx_RefNannySetupContext("get_bounding_rect", 0);
11857
11858 /* "pygame_sdl2/surface.pyx":763
11859 * def get_bounding_rect(self, min_alpha=1):
11860 *
11861 * cdef Uint32 amask = self.surface.format.Amask # <<<<<<<<<<<<<<
11862 * cdef Uint32 amin = (0x01010101 * min_alpha) & amask
11863 *
11864 */
11865 __pyx_t_1 = __pyx_v_self->surface->format->Amask;
11866 __pyx_v_amask = __pyx_t_1;
11867
11868 /* "pygame_sdl2/surface.pyx":764
11869 *
11870 * cdef Uint32 amask = self.surface.format.Amask
11871 * cdef Uint32 amin = (0x01010101 * min_alpha) & amask # <<<<<<<<<<<<<<
11872 *
11873 * cdef int x
11874 */
11875 __pyx_t_2 = PyNumber_Multiply(__pyx_int_16843009, __pyx_v_min_alpha); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
11876 __Pyx_GOTREF(__pyx_t_2);
11877 __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_amask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 764, __pyx_L1_error)
11878 __Pyx_GOTREF(__pyx_t_3);
11879 __pyx_t_4 = PyNumber_And(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 764, __pyx_L1_error)
11880 __Pyx_GOTREF(__pyx_t_4);
11881 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11882 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11883 __pyx_t_1 = __Pyx_PyInt_As_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_1 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 764, __pyx_L1_error)
11884 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11885 __pyx_v_amin = __pyx_t_1;
11886
11887 /* "pygame_sdl2/surface.pyx":771
11888 * cdef int h
11889 *
11890 * cdef int minx = self.surface.w - 1 # <<<<<<<<<<<<<<
11891 * cdef int maxx = 0
11892 * cdef int miny = self.surface.h - 1
11893 */
11894 __pyx_v_minx = (__pyx_v_self->surface->w - 1);
11895
11896 /* "pygame_sdl2/surface.pyx":772
11897 *
11898 * cdef int minx = self.surface.w - 1
11899 * cdef int maxx = 0 # <<<<<<<<<<<<<<
11900 * cdef int miny = self.surface.h - 1
11901 * cdef int maxy = 0
11902 */
11903 __pyx_v_maxx = 0;
11904
11905 /* "pygame_sdl2/surface.pyx":773
11906 * cdef int minx = self.surface.w - 1
11907 * cdef int maxx = 0
11908 * cdef int miny = self.surface.h - 1 # <<<<<<<<<<<<<<
11909 * cdef int maxy = 0
11910 *
11911 */
11912 __pyx_v_miny = (__pyx_v_self->surface->h - 1);
11913
11914 /* "pygame_sdl2/surface.pyx":774
11915 * cdef int maxx = 0
11916 * cdef int miny = self.surface.h - 1
11917 * cdef int maxy = 0 # <<<<<<<<<<<<<<
11918 *
11919 * cdef Uint32 *row
11920 */
11921 __pyx_v_maxy = 0;
11922
11923 /* "pygame_sdl2/surface.pyx":781
11924 * cdef Uint32 botright
11925 *
11926 * if (not amask) or (self.surface.w == 0) or (self.surface.h == 0): # <<<<<<<<<<<<<<
11927 * return Rect((0, 0, self.surface.w, self.surface.h))
11928 *
11929 */
11930 __pyx_t_6 = ((!(__pyx_v_amask != 0)) != 0);
11931 if (!__pyx_t_6) {
11932 } else {
11933 __pyx_t_5 = __pyx_t_6;
11934 goto __pyx_L4_bool_binop_done;
11935 }
11936 __pyx_t_6 = ((__pyx_v_self->surface->w == 0) != 0);
11937 if (!__pyx_t_6) {
11938 } else {
11939 __pyx_t_5 = __pyx_t_6;
11940 goto __pyx_L4_bool_binop_done;
11941 }
11942 __pyx_t_6 = ((__pyx_v_self->surface->h == 0) != 0);
11943 __pyx_t_5 = __pyx_t_6;
11944 __pyx_L4_bool_binop_done:;
11945 if (__pyx_t_5) {
11946
11947 /* "pygame_sdl2/surface.pyx":782
11948 *
11949 * if (not amask) or (self.surface.w == 0) or (self.surface.h == 0):
11950 * return Rect((0, 0, self.surface.w, self.surface.h)) # <<<<<<<<<<<<<<
11951 *
11952 * self.lock()
11953 */
11954 __Pyx_XDECREF(__pyx_r);
11955 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Rect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
11956 __Pyx_GOTREF(__pyx_t_3);
11957 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->surface->w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L1_error)
11958 __Pyx_GOTREF(__pyx_t_2);
11959 __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->surface->h); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 782, __pyx_L1_error)
11960 __Pyx_GOTREF(__pyx_t_7);
11961 __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 782, __pyx_L1_error)
11962 __Pyx_GOTREF(__pyx_t_8);
11963 __Pyx_INCREF(__pyx_int_0);
11964 __Pyx_GIVEREF(__pyx_int_0);
11965 PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_0);
11966 __Pyx_INCREF(__pyx_int_0);
11967 __Pyx_GIVEREF(__pyx_int_0);
11968 PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
11969 __Pyx_GIVEREF(__pyx_t_2);
11970 PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_2);
11971 __Pyx_GIVEREF(__pyx_t_7);
11972 PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
11973 __pyx_t_2 = 0;
11974 __pyx_t_7 = 0;
11975 __pyx_t_7 = NULL;
11976 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
11977 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
11978 if (likely(__pyx_t_7)) {
11979 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
11980 __Pyx_INCREF(__pyx_t_7);
11981 __Pyx_INCREF(function);
11982 __Pyx_DECREF_SET(__pyx_t_3, function);
11983 }
11984 }
11985 __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
11986 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
11987 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11988 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 782, __pyx_L1_error)
11989 __Pyx_GOTREF(__pyx_t_4);
11990 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11991 __pyx_r = __pyx_t_4;
11992 __pyx_t_4 = 0;
11993 goto __pyx_L0;
11994
11995 /* "pygame_sdl2/surface.pyx":781
11996 * cdef Uint32 botright
11997 *
11998 * if (not amask) or (self.surface.w == 0) or (self.surface.h == 0): # <<<<<<<<<<<<<<
11999 * return Rect((0, 0, self.surface.w, self.surface.h))
12000 *
12001 */
12002 }
12003
12004 /* "pygame_sdl2/surface.pyx":784
12005 * return Rect((0, 0, self.surface.w, self.surface.h))
12006 *
12007 * self.lock() # <<<<<<<<<<<<<<
12008 *
12009 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12010 */
12011 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
12012 __Pyx_GOTREF(__pyx_t_3);
12013 __pyx_t_8 = NULL;
12014 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
12015 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
12016 if (likely(__pyx_t_8)) {
12017 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12018 __Pyx_INCREF(__pyx_t_8);
12019 __Pyx_INCREF(function);
12020 __Pyx_DECREF_SET(__pyx_t_3, function);
12021 }
12022 }
12023 __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
12024 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
12025 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 784, __pyx_L1_error)
12026 __Pyx_GOTREF(__pyx_t_4);
12027 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12028 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12029
12030 /* "pygame_sdl2/surface.pyx":786
12031 * self.lock()
12032 *
12033 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
12034 *
12035 * with nogil:
12036 */
12037 __pyx_v_pixels = ((Uint8 *)__pyx_v_self->surface->pixels);
12038
12039 /* "pygame_sdl2/surface.pyx":788
12040 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12041 *
12042 * with nogil: # <<<<<<<<<<<<<<
12043 *
12044 * topleft = (<Uint32*> pixels)[0]
12045 */
12046 {
12047 #ifdef WITH_THREAD
12048 PyThreadState *_save;
12049 Py_UNBLOCK_THREADS
12050 __Pyx_FastGIL_Remember();
12051 #endif
12052 /*try:*/ {
12053
12054 /* "pygame_sdl2/surface.pyx":790
12055 * with nogil:
12056 *
12057 * topleft = (<Uint32*> pixels)[0] # <<<<<<<<<<<<<<
12058 * botright = (<Uint32*> (pixels + self.surface.pitch * (self.surface.h - 1)))[self.surface.w - 1]
12059 *
12060 */
12061 __pyx_v_topleft = (((Uint32 *)__pyx_v_pixels)[0]);
12062
12063 /* "pygame_sdl2/surface.pyx":791
12064 *
12065 * topleft = (<Uint32*> pixels)[0]
12066 * botright = (<Uint32*> (pixels + self.surface.pitch * (self.surface.h - 1)))[self.surface.w - 1] # <<<<<<<<<<<<<<
12067 *
12068 * if ((topleft & amask) > amin) and ((botright & amask) > amin):
12069 */
12070 __pyx_v_botright = (((Uint32 *)(__pyx_v_pixels + (__pyx_v_self->surface->pitch * (__pyx_v_self->surface->h - 1))))[(__pyx_v_self->surface->w - 1)]);
12071
12072 /* "pygame_sdl2/surface.pyx":793
12073 * botright = (<Uint32*> (pixels + self.surface.pitch * (self.surface.h - 1)))[self.surface.w - 1]
12074 *
12075 * if ((topleft & amask) > amin) and ((botright & amask) > amin): # <<<<<<<<<<<<<<
12076 *
12077 * # Bounding box covers image.
12078 */
12079 __pyx_t_6 = (((__pyx_v_topleft & __pyx_v_amask) > __pyx_v_amin) != 0);
12080 if (__pyx_t_6) {
12081 } else {
12082 __pyx_t_5 = __pyx_t_6;
12083 goto __pyx_L11_bool_binop_done;
12084 }
12085 __pyx_t_6 = (((__pyx_v_botright & __pyx_v_amask) > __pyx_v_amin) != 0);
12086 __pyx_t_5 = __pyx_t_6;
12087 __pyx_L11_bool_binop_done:;
12088 if (__pyx_t_5) {
12089
12090 /* "pygame_sdl2/surface.pyx":797
12091 * # Bounding box covers image.
12092 *
12093 * minx = 0 # <<<<<<<<<<<<<<
12094 * miny = 0
12095 * maxx = self.surface.w - 1
12096 */
12097 __pyx_v_minx = 0;
12098
12099 /* "pygame_sdl2/surface.pyx":798
12100 *
12101 * minx = 0
12102 * miny = 0 # <<<<<<<<<<<<<<
12103 * maxx = self.surface.w - 1
12104 * maxy = self.surface.h - 1
12105 */
12106 __pyx_v_miny = 0;
12107
12108 /* "pygame_sdl2/surface.pyx":799
12109 * minx = 0
12110 * miny = 0
12111 * maxx = self.surface.w - 1 # <<<<<<<<<<<<<<
12112 * maxy = self.surface.h - 1
12113 *
12114 */
12115 __pyx_v_maxx = (__pyx_v_self->surface->w - 1);
12116
12117 /* "pygame_sdl2/surface.pyx":800
12118 * miny = 0
12119 * maxx = self.surface.w - 1
12120 * maxy = self.surface.h - 1 # <<<<<<<<<<<<<<
12121 *
12122 * else:
12123 */
12124 __pyx_v_maxy = (__pyx_v_self->surface->h - 1);
12125
12126 /* "pygame_sdl2/surface.pyx":793
12127 * botright = (<Uint32*> (pixels + self.surface.pitch * (self.surface.h - 1)))[self.surface.w - 1]
12128 *
12129 * if ((topleft & amask) > amin) and ((botright & amask) > amin): # <<<<<<<<<<<<<<
12130 *
12131 * # Bounding box covers image.
12132 */
12133 goto __pyx_L10;
12134 }
12135
12136 /* "pygame_sdl2/surface.pyx":806
12137 * # Bounding box is smaller than image.
12138 *
12139 * for 0 <= y < self.surface.h: # <<<<<<<<<<<<<<
12140 * row = <Uint32*> (pixels + self.surface.pitch * y)
12141 *
12142 */
12143 /*else*/ {
12144 __pyx_t_9 = __pyx_v_self->surface->h;
12145 for (__pyx_v_y = 0; __pyx_v_y < __pyx_t_9; __pyx_v_y++) {
12146
12147 /* "pygame_sdl2/surface.pyx":807
12148 *
12149 * for 0 <= y < self.surface.h:
12150 * row = <Uint32*> (pixels + self.surface.pitch * y) # <<<<<<<<<<<<<<
12151 *
12152 * for 0 <= x < self.surface.w:
12153 */
12154 __pyx_v_row = ((Uint32 *)(__pyx_v_pixels + (__pyx_v_self->surface->pitch * __pyx_v_y)));
12155
12156 /* "pygame_sdl2/surface.pyx":809
12157 * row = <Uint32*> (pixels + self.surface.pitch * y)
12158 *
12159 * for 0 <= x < self.surface.w: # <<<<<<<<<<<<<<
12160 *
12161 * if (row[x] & amask) >= amin:
12162 */
12163 __pyx_t_10 = __pyx_v_self->surface->w;
12164 for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_10; __pyx_v_x++) {
12165
12166 /* "pygame_sdl2/surface.pyx":811
12167 * for 0 <= x < self.surface.w:
12168 *
12169 * if (row[x] & amask) >= amin: # <<<<<<<<<<<<<<
12170 *
12171 * if minx > x:
12172 */
12173 __pyx_t_5 = ((((__pyx_v_row[__pyx_v_x]) & __pyx_v_amask) >= __pyx_v_amin) != 0);
12174 if (__pyx_t_5) {
12175
12176 /* "pygame_sdl2/surface.pyx":813
12177 * if (row[x] & amask) >= amin:
12178 *
12179 * if minx > x: # <<<<<<<<<<<<<<
12180 * minx = x
12181 * if miny > y:
12182 */
12183 __pyx_t_5 = ((__pyx_v_minx > __pyx_v_x) != 0);
12184 if (__pyx_t_5) {
12185
12186 /* "pygame_sdl2/surface.pyx":814
12187 *
12188 * if minx > x:
12189 * minx = x # <<<<<<<<<<<<<<
12190 * if miny > y:
12191 * miny = y
12192 */
12193 __pyx_v_minx = __pyx_v_x;
12194
12195 /* "pygame_sdl2/surface.pyx":813
12196 * if (row[x] & amask) >= amin:
12197 *
12198 * if minx > x: # <<<<<<<<<<<<<<
12199 * minx = x
12200 * if miny > y:
12201 */
12202 }
12203
12204 /* "pygame_sdl2/surface.pyx":815
12205 * if minx > x:
12206 * minx = x
12207 * if miny > y: # <<<<<<<<<<<<<<
12208 * miny = y
12209 * if maxx < x:
12210 */
12211 __pyx_t_5 = ((__pyx_v_miny > __pyx_v_y) != 0);
12212 if (__pyx_t_5) {
12213
12214 /* "pygame_sdl2/surface.pyx":816
12215 * minx = x
12216 * if miny > y:
12217 * miny = y # <<<<<<<<<<<<<<
12218 * if maxx < x:
12219 * maxx = x
12220 */
12221 __pyx_v_miny = __pyx_v_y;
12222
12223 /* "pygame_sdl2/surface.pyx":815
12224 * if minx > x:
12225 * minx = x
12226 * if miny > y: # <<<<<<<<<<<<<<
12227 * miny = y
12228 * if maxx < x:
12229 */
12230 }
12231
12232 /* "pygame_sdl2/surface.pyx":817
12233 * if miny > y:
12234 * miny = y
12235 * if maxx < x: # <<<<<<<<<<<<<<
12236 * maxx = x
12237 * if maxy < y:
12238 */
12239 __pyx_t_5 = ((__pyx_v_maxx < __pyx_v_x) != 0);
12240 if (__pyx_t_5) {
12241
12242 /* "pygame_sdl2/surface.pyx":818
12243 * miny = y
12244 * if maxx < x:
12245 * maxx = x # <<<<<<<<<<<<<<
12246 * if maxy < y:
12247 * maxy = y
12248 */
12249 __pyx_v_maxx = __pyx_v_x;
12250
12251 /* "pygame_sdl2/surface.pyx":817
12252 * if miny > y:
12253 * miny = y
12254 * if maxx < x: # <<<<<<<<<<<<<<
12255 * maxx = x
12256 * if maxy < y:
12257 */
12258 }
12259
12260 /* "pygame_sdl2/surface.pyx":819
12261 * if maxx < x:
12262 * maxx = x
12263 * if maxy < y: # <<<<<<<<<<<<<<
12264 * maxy = y
12265 *
12266 */
12267 __pyx_t_5 = ((__pyx_v_maxy < __pyx_v_y) != 0);
12268 if (__pyx_t_5) {
12269
12270 /* "pygame_sdl2/surface.pyx":820
12271 * maxx = x
12272 * if maxy < y:
12273 * maxy = y # <<<<<<<<<<<<<<
12274 *
12275 * self.unlock()
12276 */
12277 __pyx_v_maxy = __pyx_v_y;
12278
12279 /* "pygame_sdl2/surface.pyx":819
12280 * if maxx < x:
12281 * maxx = x
12282 * if maxy < y: # <<<<<<<<<<<<<<
12283 * maxy = y
12284 *
12285 */
12286 }
12287
12288 /* "pygame_sdl2/surface.pyx":811
12289 * for 0 <= x < self.surface.w:
12290 *
12291 * if (row[x] & amask) >= amin: # <<<<<<<<<<<<<<
12292 *
12293 * if minx > x:
12294 */
12295 }
12296 }
12297 }
12298 }
12299 __pyx_L10:;
12300 }
12301
12302 /* "pygame_sdl2/surface.pyx":788
12303 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12304 *
12305 * with nogil: # <<<<<<<<<<<<<<
12306 *
12307 * topleft = (<Uint32*> pixels)[0]
12308 */
12309 /*finally:*/ {
12310 /*normal exit:*/{
12311 #ifdef WITH_THREAD
12312 __Pyx_FastGIL_Forget();
12313 Py_BLOCK_THREADS
12314 #endif
12315 goto __pyx_L9;
12316 }
12317 __pyx_L9:;
12318 }
12319 }
12320
12321 /* "pygame_sdl2/surface.pyx":822
12322 * maxy = y
12323 *
12324 * self.unlock() # <<<<<<<<<<<<<<
12325 *
12326 * # Totally empty surface.
12327 */
12328 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 822, __pyx_L1_error)
12329 __Pyx_GOTREF(__pyx_t_3);
12330 __pyx_t_8 = NULL;
12331 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
12332 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
12333 if (likely(__pyx_t_8)) {
12334 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12335 __Pyx_INCREF(__pyx_t_8);
12336 __Pyx_INCREF(function);
12337 __Pyx_DECREF_SET(__pyx_t_3, function);
12338 }
12339 }
12340 __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
12341 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
12342 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error)
12343 __Pyx_GOTREF(__pyx_t_4);
12344 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12345 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12346
12347 /* "pygame_sdl2/surface.pyx":825
12348 *
12349 * # Totally empty surface.
12350 * if minx > maxx: # <<<<<<<<<<<<<<
12351 * return Rect((0, 0, 0, 0))
12352 *
12353 */
12354 __pyx_t_5 = ((__pyx_v_minx > __pyx_v_maxx) != 0);
12355 if (__pyx_t_5) {
12356
12357 /* "pygame_sdl2/surface.pyx":826
12358 * # Totally empty surface.
12359 * if minx > maxx:
12360 * return Rect((0, 0, 0, 0)) # <<<<<<<<<<<<<<
12361 *
12362 * x = minx
12363 */
12364 __Pyx_XDECREF(__pyx_r);
12365 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Rect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 826, __pyx_L1_error)
12366 __Pyx_GOTREF(__pyx_t_3);
12367 __pyx_t_8 = NULL;
12368 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
12369 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
12370 if (likely(__pyx_t_8)) {
12371 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12372 __Pyx_INCREF(__pyx_t_8);
12373 __Pyx_INCREF(function);
12374 __Pyx_DECREF_SET(__pyx_t_3, function);
12375 }
12376 }
12377 __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_tuple__2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_tuple__2);
12378 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
12379 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 826, __pyx_L1_error)
12380 __Pyx_GOTREF(__pyx_t_4);
12381 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12382 __pyx_r = __pyx_t_4;
12383 __pyx_t_4 = 0;
12384 goto __pyx_L0;
12385
12386 /* "pygame_sdl2/surface.pyx":825
12387 *
12388 * # Totally empty surface.
12389 * if minx > maxx: # <<<<<<<<<<<<<<
12390 * return Rect((0, 0, 0, 0))
12391 *
12392 */
12393 }
12394
12395 /* "pygame_sdl2/surface.pyx":828
12396 * return Rect((0, 0, 0, 0))
12397 *
12398 * x = minx # <<<<<<<<<<<<<<
12399 * y = miny
12400 * w = min(maxx - minx + 1, self.surface.w - x)
12401 */
12402 __pyx_v_x = __pyx_v_minx;
12403
12404 /* "pygame_sdl2/surface.pyx":829
12405 *
12406 * x = minx
12407 * y = miny # <<<<<<<<<<<<<<
12408 * w = min(maxx - minx + 1, self.surface.w - x)
12409 * h = min(maxy - miny + 1, self.surface.h - y)
12410 */
12411 __pyx_v_y = __pyx_v_miny;
12412
12413 /* "pygame_sdl2/surface.pyx":830
12414 * x = minx
12415 * y = miny
12416 * w = min(maxx - minx + 1, self.surface.w - x) # <<<<<<<<<<<<<<
12417 * h = min(maxy - miny + 1, self.surface.h - y)
12418 *
12419 */
12420 __pyx_t_9 = (__pyx_v_self->surface->w - __pyx_v_x);
12421 __pyx_t_11 = ((__pyx_v_maxx - __pyx_v_minx) + 1);
12422 if (((__pyx_t_9 < __pyx_t_11) != 0)) {
12423 __pyx_t_12 = __pyx_t_9;
12424 } else {
12425 __pyx_t_12 = __pyx_t_11;
12426 }
12427 __pyx_v_w = __pyx_t_12;
12428
12429 /* "pygame_sdl2/surface.pyx":831
12430 * y = miny
12431 * w = min(maxx - minx + 1, self.surface.w - x)
12432 * h = min(maxy - miny + 1, self.surface.h - y) # <<<<<<<<<<<<<<
12433 *
12434 * return Rect((x, y, w, h))
12435 */
12436 __pyx_t_9 = (__pyx_v_self->surface->h - __pyx_v_y);
12437 __pyx_t_12 = ((__pyx_v_maxy - __pyx_v_miny) + 1);
12438 if (((__pyx_t_9 < __pyx_t_12) != 0)) {
12439 __pyx_t_11 = __pyx_t_9;
12440 } else {
12441 __pyx_t_11 = __pyx_t_12;
12442 }
12443 __pyx_v_h = __pyx_t_11;
12444
12445 /* "pygame_sdl2/surface.pyx":833
12446 * h = min(maxy - miny + 1, self.surface.h - y)
12447 *
12448 * return Rect((x, y, w, h)) # <<<<<<<<<<<<<<
12449 *
12450 * def get_view(self, kind='2'):
12451 */
12452 __Pyx_XDECREF(__pyx_r);
12453 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Rect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 833, __pyx_L1_error)
12454 __Pyx_GOTREF(__pyx_t_3);
12455 __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_x); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 833, __pyx_L1_error)
12456 __Pyx_GOTREF(__pyx_t_8);
12457 __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error)
12458 __Pyx_GOTREF(__pyx_t_7);
12459 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error)
12460 __Pyx_GOTREF(__pyx_t_2);
12461 __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 833, __pyx_L1_error)
12462 __Pyx_GOTREF(__pyx_t_13);
12463 __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 833, __pyx_L1_error)
12464 __Pyx_GOTREF(__pyx_t_14);
12465 __Pyx_GIVEREF(__pyx_t_8);
12466 PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8);
12467 __Pyx_GIVEREF(__pyx_t_7);
12468 PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_7);
12469 __Pyx_GIVEREF(__pyx_t_2);
12470 PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_2);
12471 __Pyx_GIVEREF(__pyx_t_13);
12472 PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_13);
12473 __pyx_t_8 = 0;
12474 __pyx_t_7 = 0;
12475 __pyx_t_2 = 0;
12476 __pyx_t_13 = 0;
12477 __pyx_t_13 = NULL;
12478 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
12479 __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
12480 if (likely(__pyx_t_13)) {
12481 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12482 __Pyx_INCREF(__pyx_t_13);
12483 __Pyx_INCREF(function);
12484 __Pyx_DECREF_SET(__pyx_t_3, function);
12485 }
12486 }
12487 __pyx_t_4 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_13, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_14);
12488 __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
12489 __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
12490 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 833, __pyx_L1_error)
12491 __Pyx_GOTREF(__pyx_t_4);
12492 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12493 __pyx_r = __pyx_t_4;
12494 __pyx_t_4 = 0;
12495 goto __pyx_L0;
12496
12497 /* "pygame_sdl2/surface.pyx":761
12498 * return (format.Rloss, format.Gloss, format.Bloss, format.Aloss)
12499 *
12500 * def get_bounding_rect(self, min_alpha=1): # <<<<<<<<<<<<<<
12501 *
12502 * cdef Uint32 amask = self.surface.format.Amask
12503 */
12504
12505 /* function exit code */
12506 __pyx_L1_error:;
12507 __Pyx_XDECREF(__pyx_t_2);
12508 __Pyx_XDECREF(__pyx_t_3);
12509 __Pyx_XDECREF(__pyx_t_4);
12510 __Pyx_XDECREF(__pyx_t_7);
12511 __Pyx_XDECREF(__pyx_t_8);
12512 __Pyx_XDECREF(__pyx_t_13);
12513 __Pyx_XDECREF(__pyx_t_14);
12514 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_bounding_rect", __pyx_clineno, __pyx_lineno, __pyx_filename);
12515 __pyx_r = NULL;
12516 __pyx_L0:;
12517 __Pyx_XGIVEREF(__pyx_r);
12518 __Pyx_RefNannyFinishContext();
12519 return __pyx_r;
12520 }
12521
12522 /* "pygame_sdl2/surface.pyx":835
12523 * return Rect((x, y, w, h))
12524 *
12525 * def get_view(self, kind='2'): # <<<<<<<<<<<<<<
12526 * raise error("Surface.get_view is not supported.")
12527 *
12528 */
12529
12530 /* Python wrapper */
12531 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_95get_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_95get_view(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)12532 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_95get_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12533 CYTHON_UNUSED PyObject *__pyx_v_kind = 0;
12534 int __pyx_lineno = 0;
12535 const char *__pyx_filename = NULL;
12536 int __pyx_clineno = 0;
12537 PyObject *__pyx_r = 0;
12538 __Pyx_RefNannyDeclarations
12539 __Pyx_RefNannySetupContext("get_view (wrapper)", 0);
12540 {
12541 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_kind,0};
12542 PyObject* values[1] = {0};
12543 values[0] = ((PyObject *)__pyx_kp_s_2);
12544 if (unlikely(__pyx_kwds)) {
12545 Py_ssize_t kw_args;
12546 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12547 switch (pos_args) {
12548 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12549 CYTHON_FALLTHROUGH;
12550 case 0: break;
12551 default: goto __pyx_L5_argtuple_error;
12552 }
12553 kw_args = PyDict_Size(__pyx_kwds);
12554 switch (pos_args) {
12555 case 0:
12556 if (kw_args > 0) {
12557 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kind);
12558 if (value) { values[0] = value; kw_args--; }
12559 }
12560 }
12561 if (unlikely(kw_args > 0)) {
12562 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_view") < 0)) __PYX_ERR(0, 835, __pyx_L3_error)
12563 }
12564 } else {
12565 switch (PyTuple_GET_SIZE(__pyx_args)) {
12566 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12567 CYTHON_FALLTHROUGH;
12568 case 0: break;
12569 default: goto __pyx_L5_argtuple_error;
12570 }
12571 }
12572 __pyx_v_kind = values[0];
12573 }
12574 goto __pyx_L4_argument_unpacking_done;
12575 __pyx_L5_argtuple_error:;
12576 __Pyx_RaiseArgtupleInvalid("get_view", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 835, __pyx_L3_error)
12577 __pyx_L3_error:;
12578 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
12579 __Pyx_RefNannyFinishContext();
12580 return NULL;
12581 __pyx_L4_argument_unpacking_done:;
12582 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_94get_view(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), __pyx_v_kind);
12583
12584 /* function exit code */
12585 __Pyx_RefNannyFinishContext();
12586 return __pyx_r;
12587 }
12588
__pyx_pf_11pygame_sdl2_7surface_7Surface_94get_view(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v_kind)12589 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_94get_view(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_kind) {
12590 PyObject *__pyx_r = NULL;
12591 __Pyx_RefNannyDeclarations
12592 PyObject *__pyx_t_1 = NULL;
12593 PyObject *__pyx_t_2 = NULL;
12594 PyObject *__pyx_t_3 = NULL;
12595 int __pyx_lineno = 0;
12596 const char *__pyx_filename = NULL;
12597 int __pyx_clineno = 0;
12598 __Pyx_RefNannySetupContext("get_view", 0);
12599
12600 /* "pygame_sdl2/surface.pyx":836
12601 *
12602 * def get_view(self, kind='2'):
12603 * raise error("Surface.get_view is not supported.") # <<<<<<<<<<<<<<
12604 *
12605 * def get_buffer(self):
12606 */
12607 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 836, __pyx_L1_error)
12608 __Pyx_GOTREF(__pyx_t_2);
12609 __pyx_t_3 = NULL;
12610 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
12611 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
12612 if (likely(__pyx_t_3)) {
12613 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
12614 __Pyx_INCREF(__pyx_t_3);
12615 __Pyx_INCREF(function);
12616 __Pyx_DECREF_SET(__pyx_t_2, function);
12617 }
12618 }
12619 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s_Surface_get_view_is_not_supporte) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_Surface_get_view_is_not_supporte);
12620 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12621 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 836, __pyx_L1_error)
12622 __Pyx_GOTREF(__pyx_t_1);
12623 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12624 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
12625 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12626 __PYX_ERR(0, 836, __pyx_L1_error)
12627
12628 /* "pygame_sdl2/surface.pyx":835
12629 * return Rect((x, y, w, h))
12630 *
12631 * def get_view(self, kind='2'): # <<<<<<<<<<<<<<
12632 * raise error("Surface.get_view is not supported.")
12633 *
12634 */
12635
12636 /* function exit code */
12637 __pyx_L1_error:;
12638 __Pyx_XDECREF(__pyx_t_1);
12639 __Pyx_XDECREF(__pyx_t_2);
12640 __Pyx_XDECREF(__pyx_t_3);
12641 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
12642 __pyx_r = NULL;
12643 __Pyx_XGIVEREF(__pyx_r);
12644 __Pyx_RefNannyFinishContext();
12645 return __pyx_r;
12646 }
12647
12648 /* "pygame_sdl2/surface.pyx":838
12649 * raise error("Surface.get_view is not supported.")
12650 *
12651 * def get_buffer(self): # <<<<<<<<<<<<<<
12652 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12653 * return pixels[self.surface.h * self.surface.pitch]
12654 */
12655
12656 /* Python wrapper */
12657 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_97get_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_97get_buffer(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)12658 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_97get_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
12659 PyObject *__pyx_r = 0;
12660 __Pyx_RefNannyDeclarations
12661 __Pyx_RefNannySetupContext("get_buffer (wrapper)", 0);
12662 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_96get_buffer(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
12663
12664 /* function exit code */
12665 __Pyx_RefNannyFinishContext();
12666 return __pyx_r;
12667 }
12668
__pyx_pf_11pygame_sdl2_7surface_7Surface_96get_buffer(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)12669 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_96get_buffer(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
12670 Uint8 *__pyx_v_pixels;
12671 PyObject *__pyx_r = NULL;
12672 __Pyx_RefNannyDeclarations
12673 PyObject *__pyx_t_1 = NULL;
12674 int __pyx_lineno = 0;
12675 const char *__pyx_filename = NULL;
12676 int __pyx_clineno = 0;
12677 __Pyx_RefNannySetupContext("get_buffer", 0);
12678
12679 /* "pygame_sdl2/surface.pyx":839
12680 *
12681 * def get_buffer(self):
12682 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels # <<<<<<<<<<<<<<
12683 * return pixels[self.surface.h * self.surface.pitch]
12684 *
12685 */
12686 __pyx_v_pixels = ((Uint8 *)__pyx_v_self->surface->pixels);
12687
12688 /* "pygame_sdl2/surface.pyx":840
12689 * def get_buffer(self):
12690 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12691 * return pixels[self.surface.h * self.surface.pitch] # <<<<<<<<<<<<<<
12692 *
12693 * property _pixels_address:
12694 */
12695 __Pyx_XDECREF(__pyx_r);
12696 __pyx_t_1 = __Pyx_PyInt_From_uint8_t((__pyx_v_pixels[(__pyx_v_self->surface->h * __pyx_v_self->surface->pitch)])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L1_error)
12697 __Pyx_GOTREF(__pyx_t_1);
12698 __pyx_r = __pyx_t_1;
12699 __pyx_t_1 = 0;
12700 goto __pyx_L0;
12701
12702 /* "pygame_sdl2/surface.pyx":838
12703 * raise error("Surface.get_view is not supported.")
12704 *
12705 * def get_buffer(self): # <<<<<<<<<<<<<<
12706 * cdef Uint8 *pixels = <Uint8 *> self.surface.pixels
12707 * return pixels[self.surface.h * self.surface.pitch]
12708 */
12709
12710 /* function exit code */
12711 __pyx_L1_error:;
12712 __Pyx_XDECREF(__pyx_t_1);
12713 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.get_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
12714 __pyx_r = NULL;
12715 __pyx_L0:;
12716 __Pyx_XGIVEREF(__pyx_r);
12717 __Pyx_RefNannyFinishContext();
12718 return __pyx_r;
12719 }
12720
12721 /* "pygame_sdl2/surface.pyx":843
12722 *
12723 * property _pixels_address:
12724 * def __get__(self): # <<<<<<<<<<<<<<
12725 * return <Uint64> self.surface.pixels
12726 *
12727 */
12728
12729 /* Python wrapper */
12730 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_15_pixels_address_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_15_pixels_address_1__get__(PyObject * __pyx_v_self)12731 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_15_pixels_address_1__get__(PyObject *__pyx_v_self) {
12732 PyObject *__pyx_r = 0;
12733 __Pyx_RefNannyDeclarations
12734 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
12735 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_15_pixels_address___get__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
12736
12737 /* function exit code */
12738 __Pyx_RefNannyFinishContext();
12739 return __pyx_r;
12740 }
12741
__pyx_pf_11pygame_sdl2_7surface_7Surface_15_pixels_address___get__(struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)12742 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_15_pixels_address___get__(struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
12743 PyObject *__pyx_r = NULL;
12744 __Pyx_RefNannyDeclarations
12745 PyObject *__pyx_t_1 = NULL;
12746 int __pyx_lineno = 0;
12747 const char *__pyx_filename = NULL;
12748 int __pyx_clineno = 0;
12749 __Pyx_RefNannySetupContext("__get__", 0);
12750
12751 /* "pygame_sdl2/surface.pyx":844
12752 * property _pixels_address:
12753 * def __get__(self):
12754 * return <Uint64> self.surface.pixels # <<<<<<<<<<<<<<
12755 *
12756 *
12757 */
12758 __Pyx_XDECREF(__pyx_r);
12759 __pyx_t_1 = __Pyx_PyInt_From_uint64_t(((Uint64)__pyx_v_self->surface->pixels)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
12760 __Pyx_GOTREF(__pyx_t_1);
12761 __pyx_r = __pyx_t_1;
12762 __pyx_t_1 = 0;
12763 goto __pyx_L0;
12764
12765 /* "pygame_sdl2/surface.pyx":843
12766 *
12767 * property _pixels_address:
12768 * def __get__(self): # <<<<<<<<<<<<<<
12769 * return <Uint64> self.surface.pixels
12770 *
12771 */
12772
12773 /* function exit code */
12774 __pyx_L1_error:;
12775 __Pyx_XDECREF(__pyx_t_1);
12776 __Pyx_AddTraceback("pygame_sdl2.surface.Surface._pixels_address.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12777 __pyx_r = NULL;
12778 __pyx_L0:;
12779 __Pyx_XGIVEREF(__pyx_r);
12780 __Pyx_RefNannyFinishContext();
12781 return __pyx_r;
12782 }
12783
12784 /* "(tree fragment)":1
12785 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
12786 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12787 * def __setstate_cython__(self, __pyx_state):
12788 */
12789
12790 /* Python wrapper */
12791 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_99__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_99__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)12792 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_99__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
12793 PyObject *__pyx_r = 0;
12794 __Pyx_RefNannyDeclarations
12795 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
12796 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_98__reduce_cython__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self));
12797
12798 /* function exit code */
12799 __Pyx_RefNannyFinishContext();
12800 return __pyx_r;
12801 }
12802
__pyx_pf_11pygame_sdl2_7surface_7Surface_98__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self)12803 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_98__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self) {
12804 PyObject *__pyx_r = NULL;
12805 __Pyx_RefNannyDeclarations
12806 PyObject *__pyx_t_1 = NULL;
12807 int __pyx_lineno = 0;
12808 const char *__pyx_filename = NULL;
12809 int __pyx_clineno = 0;
12810 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
12811
12812 /* "(tree fragment)":2
12813 * def __reduce_cython__(self):
12814 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
12815 * def __setstate_cython__(self, __pyx_state):
12816 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12817 */
12818 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
12819 __Pyx_GOTREF(__pyx_t_1);
12820 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
12821 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12822 __PYX_ERR(1, 2, __pyx_L1_error)
12823
12824 /* "(tree fragment)":1
12825 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
12826 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12827 * def __setstate_cython__(self, __pyx_state):
12828 */
12829
12830 /* function exit code */
12831 __pyx_L1_error:;
12832 __Pyx_XDECREF(__pyx_t_1);
12833 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12834 __pyx_r = NULL;
12835 __Pyx_XGIVEREF(__pyx_r);
12836 __Pyx_RefNannyFinishContext();
12837 return __pyx_r;
12838 }
12839
12840 /* "(tree fragment)":3
12841 * def __reduce_cython__(self):
12842 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12843 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
12844 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12845 */
12846
12847 /* Python wrapper */
12848 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_101__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_11pygame_sdl2_7surface_7Surface_101__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)12849 static PyObject *__pyx_pw_11pygame_sdl2_7surface_7Surface_101__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
12850 PyObject *__pyx_r = 0;
12851 __Pyx_RefNannyDeclarations
12852 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
12853 __pyx_r = __pyx_pf_11pygame_sdl2_7surface_7Surface_100__setstate_cython__(((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
12854
12855 /* function exit code */
12856 __Pyx_RefNannyFinishContext();
12857 return __pyx_r;
12858 }
12859
__pyx_pf_11pygame_sdl2_7surface_7Surface_100__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)12860 static PyObject *__pyx_pf_11pygame_sdl2_7surface_7Surface_100__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
12861 PyObject *__pyx_r = NULL;
12862 __Pyx_RefNannyDeclarations
12863 PyObject *__pyx_t_1 = NULL;
12864 int __pyx_lineno = 0;
12865 const char *__pyx_filename = NULL;
12866 int __pyx_clineno = 0;
12867 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
12868
12869 /* "(tree fragment)":4
12870 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12871 * def __setstate_cython__(self, __pyx_state):
12872 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
12873 */
12874 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
12875 __Pyx_GOTREF(__pyx_t_1);
12876 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
12877 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12878 __PYX_ERR(1, 4, __pyx_L1_error)
12879
12880 /* "(tree fragment)":3
12881 * def __reduce_cython__(self):
12882 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12883 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
12884 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12885 */
12886
12887 /* function exit code */
12888 __pyx_L1_error:;
12889 __Pyx_XDECREF(__pyx_t_1);
12890 __Pyx_AddTraceback("pygame_sdl2.surface.Surface.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12891 __pyx_r = NULL;
12892 __Pyx_XGIVEREF(__pyx_r);
12893 __Pyx_RefNannyFinishContext();
12894 return __pyx_r;
12895 }
12896
12897 /* "pygame_sdl2/surface.pyx":847
12898 *
12899 *
12900 * cdef api SDL_Surface *PySurface_AsSurface(surface): # <<<<<<<<<<<<<<
12901 * return (<Surface> surface).surface
12902 *
12903 */
12904
__pyx_f_11pygame_sdl2_7surface_PySurface_AsSurface(PyObject * __pyx_v_surface)12905 static SDL_Surface *__pyx_f_11pygame_sdl2_7surface_PySurface_AsSurface(PyObject *__pyx_v_surface) {
12906 SDL_Surface *__pyx_r;
12907 __Pyx_RefNannyDeclarations
12908 __Pyx_RefNannySetupContext("PySurface_AsSurface", 0);
12909
12910 /* "pygame_sdl2/surface.pyx":848
12911 *
12912 * cdef api SDL_Surface *PySurface_AsSurface(surface):
12913 * return (<Surface> surface).surface # <<<<<<<<<<<<<<
12914 *
12915 * cdef api object PySurface_New(SDL_Surface *surf):
12916 */
12917 __pyx_r = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_v_surface)->surface;
12918 goto __pyx_L0;
12919
12920 /* "pygame_sdl2/surface.pyx":847
12921 *
12922 *
12923 * cdef api SDL_Surface *PySurface_AsSurface(surface): # <<<<<<<<<<<<<<
12924 * return (<Surface> surface).surface
12925 *
12926 */
12927
12928 /* function exit code */
12929 __pyx_L0:;
12930 __Pyx_RefNannyFinishContext();
12931 return __pyx_r;
12932 }
12933
12934 /* "pygame_sdl2/surface.pyx":850
12935 * return (<Surface> surface).surface
12936 *
12937 * cdef api object PySurface_New(SDL_Surface *surf): # <<<<<<<<<<<<<<
12938 * cdef Surface rv = Surface(())
12939 * rv.take_surface(surf)
12940 */
12941
__pyx_f_11pygame_sdl2_7surface_PySurface_New(SDL_Surface * __pyx_v_surf)12942 static PyObject *__pyx_f_11pygame_sdl2_7surface_PySurface_New(SDL_Surface *__pyx_v_surf) {
12943 struct __pyx_obj_11pygame_sdl2_7surface_Surface *__pyx_v_rv = 0;
12944 PyObject *__pyx_r = NULL;
12945 __Pyx_RefNannyDeclarations
12946 PyObject *__pyx_t_1 = NULL;
12947 int __pyx_lineno = 0;
12948 const char *__pyx_filename = NULL;
12949 int __pyx_clineno = 0;
12950 __Pyx_RefNannySetupContext("PySurface_New", 0);
12951
12952 /* "pygame_sdl2/surface.pyx":851
12953 *
12954 * cdef api object PySurface_New(SDL_Surface *surf):
12955 * cdef Surface rv = Surface(()) # <<<<<<<<<<<<<<
12956 * rv.take_surface(surf)
12957 * return rv
12958 */
12959 __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pygame_sdl2_7surface_Surface), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 851, __pyx_L1_error)
12960 __Pyx_GOTREF(__pyx_t_1);
12961 __pyx_v_rv = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)__pyx_t_1);
12962 __pyx_t_1 = 0;
12963
12964 /* "pygame_sdl2/surface.pyx":852
12965 * cdef api object PySurface_New(SDL_Surface *surf):
12966 * cdef Surface rv = Surface(())
12967 * rv.take_surface(surf) # <<<<<<<<<<<<<<
12968 * return rv
12969 */
12970 ((struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface *)__pyx_v_rv->__pyx_vtab)->take_surface(__pyx_v_rv, __pyx_v_surf);
12971
12972 /* "pygame_sdl2/surface.pyx":853
12973 * cdef Surface rv = Surface(())
12974 * rv.take_surface(surf)
12975 * return rv # <<<<<<<<<<<<<<
12976 */
12977 __Pyx_XDECREF(__pyx_r);
12978 __Pyx_INCREF(((PyObject *)__pyx_v_rv));
12979 __pyx_r = ((PyObject *)__pyx_v_rv);
12980 goto __pyx_L0;
12981
12982 /* "pygame_sdl2/surface.pyx":850
12983 * return (<Surface> surface).surface
12984 *
12985 * cdef api object PySurface_New(SDL_Surface *surf): # <<<<<<<<<<<<<<
12986 * cdef Surface rv = Surface(())
12987 * rv.take_surface(surf)
12988 */
12989
12990 /* function exit code */
12991 __pyx_L1_error:;
12992 __Pyx_XDECREF(__pyx_t_1);
12993 __Pyx_AddTraceback("pygame_sdl2.surface.PySurface_New", __pyx_clineno, __pyx_lineno, __pyx_filename);
12994 __pyx_r = 0;
12995 __pyx_L0:;
12996 __Pyx_XDECREF((PyObject *)__pyx_v_rv);
12997 __Pyx_XGIVEREF(__pyx_r);
12998 __Pyx_RefNannyFinishContext();
12999 return __pyx_r;
13000 }
13001 static struct __pyx_vtabstruct_11pygame_sdl2_7surface_Surface __pyx_vtable_11pygame_sdl2_7surface_Surface;
13002
__pyx_tp_new_11pygame_sdl2_7surface_Surface(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)13003 static PyObject *__pyx_tp_new_11pygame_sdl2_7surface_Surface(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
13004 struct __pyx_obj_11pygame_sdl2_7surface_Surface *p;
13005 PyObject *o;
13006 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
13007 o = (*t->tp_alloc)(t, 0);
13008 } else {
13009 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
13010 }
13011 if (unlikely(!o)) return 0;
13012 p = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)o);
13013 p->__pyx_vtab = __pyx_vtabptr_11pygame_sdl2_7surface_Surface;
13014 p->locklist = Py_None; Py_INCREF(Py_None);
13015 p->parent = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None); Py_INCREF(Py_None);
13016 p->root = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None); Py_INCREF(Py_None);
13017 p->get_window_flags = Py_None; Py_INCREF(Py_None);
13018 if (unlikely(__pyx_pw_11pygame_sdl2_7surface_7Surface_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
13019 return o;
13020 bad:
13021 Py_DECREF(o); o = 0;
13022 return NULL;
13023 }
13024
__pyx_tp_dealloc_11pygame_sdl2_7surface_Surface(PyObject * o)13025 static void __pyx_tp_dealloc_11pygame_sdl2_7surface_Surface(PyObject *o) {
13026 struct __pyx_obj_11pygame_sdl2_7surface_Surface *p = (struct __pyx_obj_11pygame_sdl2_7surface_Surface *)o;
13027 #if CYTHON_USE_TP_FINALIZE
13028 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
13029 if (PyObject_CallFinalizerFromDealloc(o)) return;
13030 }
13031 #endif
13032 PyObject_GC_UnTrack(o);
13033 {
13034 PyObject *etype, *eval, *etb;
13035 PyErr_Fetch(&etype, &eval, &etb);
13036 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
13037 __pyx_pw_11pygame_sdl2_7surface_7Surface_3__dealloc__(o);
13038 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
13039 PyErr_Restore(etype, eval, etb);
13040 }
13041 if (p->__weakref__) PyObject_ClearWeakRefs(o);
13042 Py_CLEAR(p->locklist);
13043 Py_CLEAR(p->parent);
13044 Py_CLEAR(p->root);
13045 Py_CLEAR(p->get_window_flags);
13046 (*Py_TYPE(o)->tp_free)(o);
13047 }
13048
__pyx_tp_traverse_11pygame_sdl2_7surface_Surface(PyObject * o,visitproc v,void * a)13049 static int __pyx_tp_traverse_11pygame_sdl2_7surface_Surface(PyObject *o, visitproc v, void *a) {
13050 int e;
13051 struct __pyx_obj_11pygame_sdl2_7surface_Surface *p = (struct __pyx_obj_11pygame_sdl2_7surface_Surface *)o;
13052 if (p->locklist) {
13053 e = (*v)(p->locklist, a); if (e) return e;
13054 }
13055 if (p->parent) {
13056 e = (*v)(((PyObject *)p->parent), a); if (e) return e;
13057 }
13058 if (p->root) {
13059 e = (*v)(((PyObject *)p->root), a); if (e) return e;
13060 }
13061 if (p->get_window_flags) {
13062 e = (*v)(p->get_window_flags, a); if (e) return e;
13063 }
13064 return 0;
13065 }
13066
__pyx_tp_clear_11pygame_sdl2_7surface_Surface(PyObject * o)13067 static int __pyx_tp_clear_11pygame_sdl2_7surface_Surface(PyObject *o) {
13068 PyObject* tmp;
13069 struct __pyx_obj_11pygame_sdl2_7surface_Surface *p = (struct __pyx_obj_11pygame_sdl2_7surface_Surface *)o;
13070 tmp = ((PyObject*)p->locklist);
13071 p->locklist = Py_None; Py_INCREF(Py_None);
13072 Py_XDECREF(tmp);
13073 tmp = ((PyObject*)p->parent);
13074 p->parent = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None); Py_INCREF(Py_None);
13075 Py_XDECREF(tmp);
13076 tmp = ((PyObject*)p->root);
13077 p->root = ((struct __pyx_obj_11pygame_sdl2_7surface_Surface *)Py_None); Py_INCREF(Py_None);
13078 Py_XDECREF(tmp);
13079 tmp = ((PyObject*)p->get_window_flags);
13080 p->get_window_flags = Py_None; Py_INCREF(Py_None);
13081 Py_XDECREF(tmp);
13082 return 0;
13083 }
13084
__pyx_getprop_11pygame_sdl2_7surface_7Surface__pixels_address(PyObject * o,CYTHON_UNUSED void * x)13085 static PyObject *__pyx_getprop_11pygame_sdl2_7surface_7Surface__pixels_address(PyObject *o, CYTHON_UNUSED void *x) {
13086 return __pyx_pw_11pygame_sdl2_7surface_7Surface_15_pixels_address_1__get__(o);
13087 }
13088
13089 static PyMethodDef __pyx_methods_11pygame_sdl2_7surface_Surface[] = {
13090 {"__sizeof__", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_5__sizeof__, METH_NOARGS, 0},
13091 {"blit", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_11blit, METH_VARARGS|METH_KEYWORDS, 0},
13092 {"convert", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_13convert, METH_VARARGS|METH_KEYWORDS, 0},
13093 {"convert_alpha", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_15convert_alpha, METH_VARARGS|METH_KEYWORDS, 0},
13094 {"copy", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_17copy, METH_NOARGS, 0},
13095 {"fill", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_19fill, METH_VARARGS|METH_KEYWORDS, 0},
13096 {"scroll", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_21scroll, METH_VARARGS|METH_KEYWORDS, 0},
13097 {"set_colorkey", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_23set_colorkey, METH_VARARGS|METH_KEYWORDS, 0},
13098 {"get_colorkey", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_25get_colorkey, METH_NOARGS, 0},
13099 {"set_alpha", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_27set_alpha, METH_VARARGS|METH_KEYWORDS, 0},
13100 {"get_alpha", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_29get_alpha, METH_NOARGS, 0},
13101 {"lock", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_31lock, METH_VARARGS|METH_KEYWORDS, 0},
13102 {"unlock", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_33unlock, METH_VARARGS|METH_KEYWORDS, 0},
13103 {"mustlock", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_35mustlock, METH_NOARGS, 0},
13104 {"get_locked", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_37get_locked, METH_NOARGS, 0},
13105 {"get_locks", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_39get_locks, METH_NOARGS, 0},
13106 {"get_at", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_41get_at, METH_O, 0},
13107 {"set_at", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_43set_at, METH_VARARGS|METH_KEYWORDS, 0},
13108 {"get_at_mapped", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_45get_at_mapped, METH_O, 0},
13109 {"map_rgb", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_47map_rgb, METH_O, 0},
13110 {"unmap_rgb", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_49unmap_rgb, METH_O, 0},
13111 {"set_clip", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_51set_clip, METH_O, 0},
13112 {"get_clip", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_53get_clip, METH_NOARGS, 0},
13113 {"subsurface", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_55subsurface, METH_VARARGS|METH_KEYWORDS, 0},
13114 {"get_parent", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_57get_parent, METH_NOARGS, 0},
13115 {"get_abs_parent", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_59get_abs_parent, METH_NOARGS, 0},
13116 {"get_offset", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_61get_offset, METH_NOARGS, 0},
13117 {"get_abs_offset", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_63get_abs_offset, METH_NOARGS, 0},
13118 {"get_size", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_65get_size, METH_NOARGS, 0},
13119 {"get_width", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_67get_width, METH_NOARGS, 0},
13120 {"get_height", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_69get_height, METH_NOARGS, 0},
13121 {"get_rect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_71get_rect, METH_VARARGS|METH_KEYWORDS, 0},
13122 {"get_bitsize", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_73get_bitsize, METH_NOARGS, 0},
13123 {"get_bytesize", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_75get_bytesize, METH_NOARGS, 0},
13124 {"get_flags", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_77get_flags, METH_NOARGS, 0},
13125 {"get_pitch", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_79get_pitch, METH_NOARGS, 0},
13126 {"get_masks", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_81get_masks, METH_NOARGS, 0},
13127 {"set_masks", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_83set_masks, METH_O, 0},
13128 {"get_shifts", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_85get_shifts, METH_NOARGS, 0},
13129 {"set_shifts", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_87set_shifts, METH_O, 0},
13130 {"get_shifts", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_89get_shifts, METH_NOARGS, 0},
13131 {"get_losses", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_91get_losses, METH_NOARGS, 0},
13132 {"get_bounding_rect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_93get_bounding_rect, METH_VARARGS|METH_KEYWORDS, 0},
13133 {"get_view", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pygame_sdl2_7surface_7Surface_95get_view, METH_VARARGS|METH_KEYWORDS, 0},
13134 {"get_buffer", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_97get_buffer, METH_NOARGS, 0},
13135 {"__reduce_cython__", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_99__reduce_cython__, METH_NOARGS, 0},
13136 {"__setstate_cython__", (PyCFunction)__pyx_pw_11pygame_sdl2_7surface_7Surface_101__setstate_cython__, METH_O, 0},
13137 {0, 0, 0, 0}
13138 };
13139
13140 static struct PyGetSetDef __pyx_getsets_11pygame_sdl2_7surface_Surface[] = {
13141 {(char *)"_pixels_address", __pyx_getprop_11pygame_sdl2_7surface_7Surface__pixels_address, 0, (char *)0, 0},
13142 {0, 0, 0, 0, 0}
13143 };
13144
13145 static PyTypeObject __pyx_type_11pygame_sdl2_7surface_Surface = {
13146 PyVarObject_HEAD_INIT(0, 0)
13147 "pygame_sdl2.surface.Surface", /*tp_name*/
13148 sizeof(struct __pyx_obj_11pygame_sdl2_7surface_Surface), /*tp_basicsize*/
13149 0, /*tp_itemsize*/
13150 __pyx_tp_dealloc_11pygame_sdl2_7surface_Surface, /*tp_dealloc*/
13151 #if PY_VERSION_HEX < 0x030800b4
13152 0, /*tp_print*/
13153 #endif
13154 #if PY_VERSION_HEX >= 0x030800b4
13155 0, /*tp_vectorcall_offset*/
13156 #endif
13157 0, /*tp_getattr*/
13158 0, /*tp_setattr*/
13159 #if PY_MAJOR_VERSION < 3
13160 0, /*tp_compare*/
13161 #endif
13162 #if PY_MAJOR_VERSION >= 3
13163 0, /*tp_as_async*/
13164 #endif
13165 __pyx_pw_11pygame_sdl2_7surface_7Surface_9__repr__, /*tp_repr*/
13166 0, /*tp_as_number*/
13167 0, /*tp_as_sequence*/
13168 0, /*tp_as_mapping*/
13169 0, /*tp_hash*/
13170 0, /*tp_call*/
13171 0, /*tp_str*/
13172 0, /*tp_getattro*/
13173 0, /*tp_setattro*/
13174 0, /*tp_as_buffer*/
13175 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
13176 0, /*tp_doc*/
13177 __pyx_tp_traverse_11pygame_sdl2_7surface_Surface, /*tp_traverse*/
13178 __pyx_tp_clear_11pygame_sdl2_7surface_Surface, /*tp_clear*/
13179 0, /*tp_richcompare*/
13180 0, /*tp_weaklistoffset*/
13181 0, /*tp_iter*/
13182 0, /*tp_iternext*/
13183 __pyx_methods_11pygame_sdl2_7surface_Surface, /*tp_methods*/
13184 0, /*tp_members*/
13185 __pyx_getsets_11pygame_sdl2_7surface_Surface, /*tp_getset*/
13186 0, /*tp_base*/
13187 0, /*tp_dict*/
13188 0, /*tp_descr_get*/
13189 0, /*tp_descr_set*/
13190 0, /*tp_dictoffset*/
13191 __pyx_pw_11pygame_sdl2_7surface_7Surface_7__init__, /*tp_init*/
13192 0, /*tp_alloc*/
13193 __pyx_tp_new_11pygame_sdl2_7surface_Surface, /*tp_new*/
13194 0, /*tp_free*/
13195 0, /*tp_is_gc*/
13196 0, /*tp_bases*/
13197 0, /*tp_mro*/
13198 0, /*tp_cache*/
13199 0, /*tp_subclasses*/
13200 0, /*tp_weaklist*/
13201 0, /*tp_del*/
13202 0, /*tp_version_tag*/
13203 #if PY_VERSION_HEX >= 0x030400a1
13204 0, /*tp_finalize*/
13205 #endif
13206 #if PY_VERSION_HEX >= 0x030800b1
13207 0, /*tp_vectorcall*/
13208 #endif
13209 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
13210 0, /*tp_print*/
13211 #endif
13212 };
13213
13214 static PyMethodDef __pyx_methods[] = {
13215 {0, 0, 0, 0}
13216 };
13217
13218 #if PY_MAJOR_VERSION >= 3
13219 #if CYTHON_PEP489_MULTI_PHASE_INIT
13220 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
13221 static int __pyx_pymod_exec_surface(PyObject* module); /*proto*/
13222 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
13223 {Py_mod_create, (void*)__pyx_pymod_create},
13224 {Py_mod_exec, (void*)__pyx_pymod_exec_surface},
13225 {0, NULL}
13226 };
13227 #endif
13228
13229 static struct PyModuleDef __pyx_moduledef = {
13230 PyModuleDef_HEAD_INIT,
13231 "pygame_sdl2.surface",
13232 0, /* m_doc */
13233 #if CYTHON_PEP489_MULTI_PHASE_INIT
13234 0, /* m_size */
13235 #else
13236 -1, /* m_size */
13237 #endif
13238 __pyx_methods /* m_methods */,
13239 #if CYTHON_PEP489_MULTI_PHASE_INIT
13240 __pyx_moduledef_slots, /* m_slots */
13241 #else
13242 NULL, /* m_reload */
13243 #endif
13244 NULL, /* m_traverse */
13245 NULL, /* m_clear */
13246 NULL /* m_free */
13247 };
13248 #endif
13249 #ifndef CYTHON_SMALL_CODE
13250 #if defined(__clang__)
13251 #define CYTHON_SMALL_CODE
13252 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
13253 #define CYTHON_SMALL_CODE __attribute__((cold))
13254 #else
13255 #define CYTHON_SMALL_CODE
13256 #endif
13257 #endif
13258
13259 static __Pyx_StringTabEntry __pyx_string_tab[] = {
13260 {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
13261 {&__pyx_kp_s_A_null_pointer_was_passed_in, __pyx_k_A_null_pointer_was_passed_in, sizeof(__pyx_k_A_null_pointer_was_passed_in), 0, 0, 1, 0},
13262 {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
13263 {&__pyx_kp_s_Memory_leak_via_Surface_in_pygam, __pyx_k_Memory_leak_via_Surface_in_pygam, sizeof(__pyx_k_Memory_leak_via_Surface_in_pygam), 0, 0, 1, 0},
13264 {&__pyx_kp_s_Position_outside_surface, __pyx_k_Position_outside_surface, sizeof(__pyx_k_Position_outside_surface), 0, 0, 1, 0},
13265 {&__pyx_n_s_Rect, __pyx_k_Rect, sizeof(__pyx_k_Rect), 0, 0, 1, 1},
13266 {&__pyx_n_s_SRCALPHA, __pyx_k_SRCALPHA, sizeof(__pyx_k_SRCALPHA), 0, 0, 1, 1},
13267 {&__pyx_n_s_Surface, __pyx_k_Surface, sizeof(__pyx_k_Surface), 0, 0, 1, 1},
13268 {&__pyx_kp_s_Surface_get_view_is_not_supporte, __pyx_k_Surface_get_view_is_not_supporte, sizeof(__pyx_k_Surface_get_view_is_not_supporte), 0, 0, 1, 0},
13269 {&__pyx_kp_s_Surface_has_unsupported_bytesize, __pyx_k_Surface_has_unsupported_bytesize, sizeof(__pyx_k_Surface_has_unsupported_bytesize), 0, 0, 1, 0},
13270 {&__pyx_kp_s_Surface_set_masks_is_not_support, __pyx_k_Surface_set_masks_is_not_support, sizeof(__pyx_k_Surface_set_masks_is_not_support), 0, 0, 1, 0},
13271 {&__pyx_kp_s_Surface_set_shifts_is_not_suppor, __pyx_k_Surface_set_shifts_is_not_suppor, sizeof(__pyx_k_Surface_set_shifts_is_not_suppor), 0, 0, 1, 0},
13272 {&__pyx_kp_s_Surface_x_x, __pyx_k_Surface_x_x, sizeof(__pyx_k_Surface_x_x), 0, 0, 1, 0},
13273 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
13274 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
13275 {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
13276 {&__pyx_n_s_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 1, 1},
13277 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
13278 {&__pyx_n_s_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 0, 1, 1},
13279 {&__pyx_n_s_color, __pyx_k_color, sizeof(__pyx_k_color), 0, 0, 1, 1},
13280 {&__pyx_n_s_convert, __pyx_k_convert, sizeof(__pyx_k_convert), 0, 0, 1, 1},
13281 {&__pyx_n_s_convert_alpha, __pyx_k_convert_alpha, sizeof(__pyx_k_convert_alpha), 0, 0, 1, 1},
13282 {&__pyx_n_s_depth, __pyx_k_depth, sizeof(__pyx_k_depth), 0, 0, 1, 1},
13283 {&__pyx_n_s_dest, __pyx_k_dest, sizeof(__pyx_k_dest), 0, 0, 1, 1},
13284 {&__pyx_n_s_display, __pyx_k_display, sizeof(__pyx_k_display), 0, 0, 1, 1},
13285 {&__pyx_n_s_dx, __pyx_k_dx, sizeof(__pyx_k_dx), 0, 0, 1, 1},
13286 {&__pyx_n_s_dy, __pyx_k_dy, sizeof(__pyx_k_dy), 0, 0, 1, 1},
13287 {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
13288 {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
13289 {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
13290 {&__pyx_n_s_get_alpha, __pyx_k_get_alpha, sizeof(__pyx_k_get_alpha), 0, 0, 1, 1},
13291 {&__pyx_n_s_get_rect, __pyx_k_get_rect, sizeof(__pyx_k_get_rect), 0, 0, 1, 1},
13292 {&__pyx_n_s_get_size, __pyx_k_get_size, sizeof(__pyx_k_get_size), 0, 0, 1, 1},
13293 {&__pyx_n_s_get_surface, __pyx_k_get_surface, sizeof(__pyx_k_get_surface), 0, 0, 1, 1},
13294 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
13295 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
13296 {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
13297 {&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
13298 {&__pyx_n_s_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 0, 1, 1},
13299 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
13300 {&__pyx_n_s_masks, __pyx_k_masks, sizeof(__pyx_k_masks), 0, 0, 1, 1},
13301 {&__pyx_n_s_min_alpha, __pyx_k_min_alpha, sizeof(__pyx_k_min_alpha), 0, 0, 1, 1},
13302 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
13303 {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
13304 {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
13305 {&__pyx_n_s_pygame_sdl2, __pyx_k_pygame_sdl2, sizeof(__pyx_k_pygame_sdl2), 0, 0, 1, 1},
13306 {&__pyx_n_s_pygame_sdl2_error, __pyx_k_pygame_sdl2_error, sizeof(__pyx_k_pygame_sdl2_error), 0, 0, 1, 1},
13307 {&__pyx_n_s_pygame_sdl2_locals, __pyx_k_pygame_sdl2_locals, sizeof(__pyx_k_pygame_sdl2_locals), 0, 0, 1, 1},
13308 {&__pyx_n_s_pygame_sdl2_rect, __pyx_k_pygame_sdl2_rect, sizeof(__pyx_k_pygame_sdl2_rect), 0, 0, 1, 1},
13309 {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
13310 {&__pyx_n_s_rect, __pyx_k_rect, sizeof(__pyx_k_rect), 0, 0, 1, 1},
13311 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
13312 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
13313 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
13314 {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
13315 {&__pyx_n_s_set_alpha, __pyx_k_set_alpha, sizeof(__pyx_k_set_alpha), 0, 0, 1, 1},
13316 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
13317 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
13318 {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
13319 {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
13320 {&__pyx_n_s_special_flags, __pyx_k_special_flags, sizeof(__pyx_k_special_flags), 0, 0, 1, 1},
13321 {&__pyx_n_s_subsurface, __pyx_k_subsurface, sizeof(__pyx_k_subsurface), 0, 0, 1, 1},
13322 {&__pyx_kp_s_subsurface_rectangle_outside_sur, __pyx_k_subsurface_rectangle_outside_sur, sizeof(__pyx_k_subsurface_rectangle_outside_sur), 0, 0, 1, 0},
13323 {&__pyx_kp_s_subsurface_size_must_be_non_nega, __pyx_k_subsurface_size_must_be_non_nega, sizeof(__pyx_k_subsurface_size_must_be_non_nega), 0, 0, 1, 0},
13324 {&__pyx_n_s_surface, __pyx_k_surface, sizeof(__pyx_k_surface), 0, 0, 1, 1},
13325 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
13326 {&__pyx_n_s_total_size, __pyx_k_total_size, sizeof(__pyx_k_total_size), 0, 0, 1, 1},
13327 {&__pyx_n_s_unlock, __pyx_k_unlock, sizeof(__pyx_k_unlock), 0, 0, 1, 1},
13328 {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
13329 {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
13330 {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
13331 {0, 0, 0, 0, 0, 0, 0}
13332 };
__Pyx_InitCachedBuiltins(void)13333 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
13334 __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 538, __pyx_L1_error)
13335 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 563, __pyx_L1_error)
13336 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
13337 return 0;
13338 __pyx_L1_error:;
13339 return -1;
13340 }
13341
__Pyx_InitCachedConstants(void)13342 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
13343 __Pyx_RefNannyDeclarations
13344 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
13345
13346 /* "pygame_sdl2/surface.pyx":289
13347 * raise error()
13348 *
13349 * cdef Surface rv = Surface(()) # <<<<<<<<<<<<<<
13350 * rv.take_surface(new_surface)
13351 *
13352 */
13353 __pyx_tuple_ = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 289, __pyx_L1_error)
13354 __Pyx_GOTREF(__pyx_tuple_);
13355 __Pyx_GIVEREF(__pyx_tuple_);
13356
13357 /* "pygame_sdl2/surface.pyx":368
13358 *
13359 * if sdl_rect.w <= 0 or sdl_rect.h <= 0:
13360 * return Rect(0, 0, 0, 0) # <<<<<<<<<<<<<<
13361 *
13362 * with nogil:
13363 */
13364 __pyx_tuple__2 = PyTuple_Pack(4, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 368, __pyx_L1_error)
13365 __Pyx_GOTREF(__pyx_tuple__2);
13366 __Pyx_GIVEREF(__pyx_tuple__2);
13367
13368 /* "pygame_sdl2/surface.pyx":538
13369 *
13370 * if not (0 <= x < self.surface.w) or not (0 <= y < self.surface.h):
13371 * raise IndexError("Position outside surface.") # <<<<<<<<<<<<<<
13372 *
13373 * if self.surface.format.BytesPerPixel != 4:
13374 */
13375 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Position_outside_surface); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 538, __pyx_L1_error)
13376 __Pyx_GOTREF(__pyx_tuple__3);
13377 __Pyx_GIVEREF(__pyx_tuple__3);
13378
13379 /* "(tree fragment)":2
13380 * def __reduce_cython__(self):
13381 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
13382 * def __setstate_cython__(self, __pyx_state):
13383 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
13384 */
13385 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 2, __pyx_L1_error)
13386 __Pyx_GOTREF(__pyx_tuple__4);
13387 __Pyx_GIVEREF(__pyx_tuple__4);
13388
13389 /* "(tree fragment)":4
13390 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
13391 * def __setstate_cython__(self, __pyx_state):
13392 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
13393 */
13394 __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 4, __pyx_L1_error)
13395 __Pyx_GOTREF(__pyx_tuple__5);
13396 __Pyx_GIVEREF(__pyx_tuple__5);
13397 __Pyx_RefNannyFinishContext();
13398 return 0;
13399 __pyx_L1_error:;
13400 __Pyx_RefNannyFinishContext();
13401 return -1;
13402 }
13403
__Pyx_InitGlobals(void)13404 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
13405 __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
13406 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
13407 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
13408 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
13409 __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(0, 1, __pyx_L1_error)
13410 __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) __PYX_ERR(0, 1, __pyx_L1_error)
13411 __pyx_int_16843009 = PyInt_FromLong(16843009L); if (unlikely(!__pyx_int_16843009)) __PYX_ERR(0, 1, __pyx_L1_error)
13412 __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) __PYX_ERR(0, 1, __pyx_L1_error)
13413 return 0;
13414 __pyx_L1_error:;
13415 return -1;
13416 }
13417
13418 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
13419 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
13420 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
13421 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
13422 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
13423 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
13424 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
13425
__Pyx_modinit_global_init_code(void)13426 static int __Pyx_modinit_global_init_code(void) {
13427 __Pyx_RefNannyDeclarations
13428 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
13429 /*--- Global init code ---*/
13430 __Pyx_RefNannyFinishContext();
13431 return 0;
13432 }
13433
__Pyx_modinit_variable_export_code(void)13434 static int __Pyx_modinit_variable_export_code(void) {
13435 __Pyx_RefNannyDeclarations
13436 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
13437 /*--- Variable export code ---*/
13438 __Pyx_RefNannyFinishContext();
13439 return 0;
13440 }
13441
__Pyx_modinit_function_export_code(void)13442 static int __Pyx_modinit_function_export_code(void) {
13443 __Pyx_RefNannyDeclarations
13444 int __pyx_lineno = 0;
13445 const char *__pyx_filename = NULL;
13446 int __pyx_clineno = 0;
13447 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
13448 /*--- Function export code ---*/
13449 if (__Pyx_ExportFunction("PySurface_AsSurface", (void (*)(void))__pyx_f_11pygame_sdl2_7surface_PySurface_AsSurface, "SDL_Surface *(PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13450 if (__Pyx_ExportFunction("PySurface_New", (void (*)(void))__pyx_f_11pygame_sdl2_7surface_PySurface_New, "PyObject *(SDL_Surface *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13451 __Pyx_RefNannyFinishContext();
13452 return 0;
13453 __pyx_L1_error:;
13454 __Pyx_RefNannyFinishContext();
13455 return -1;
13456 }
13457
__Pyx_modinit_type_init_code(void)13458 static int __Pyx_modinit_type_init_code(void) {
13459 __Pyx_RefNannyDeclarations
13460 int __pyx_lineno = 0;
13461 const char *__pyx_filename = NULL;
13462 int __pyx_clineno = 0;
13463 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
13464 /*--- Type init code ---*/
13465 __pyx_vtabptr_11pygame_sdl2_7surface_Surface = &__pyx_vtable_11pygame_sdl2_7surface_Surface;
13466 __pyx_vtable_11pygame_sdl2_7surface_Surface.take_surface = (void (*)(struct __pyx_obj_11pygame_sdl2_7surface_Surface *, SDL_Surface *))__pyx_f_11pygame_sdl2_7surface_7Surface_take_surface;
13467 if (PyType_Ready(&__pyx_type_11pygame_sdl2_7surface_Surface) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
13468 #if PY_VERSION_HEX < 0x030800B1
13469 __pyx_type_11pygame_sdl2_7surface_Surface.tp_print = 0;
13470 #endif
13471 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11pygame_sdl2_7surface_Surface.tp_dictoffset && __pyx_type_11pygame_sdl2_7surface_Surface.tp_getattro == PyObject_GenericGetAttr)) {
13472 __pyx_type_11pygame_sdl2_7surface_Surface.tp_getattro = __Pyx_PyObject_GenericGetAttr;
13473 }
13474 if (__Pyx_SetVtable(__pyx_type_11pygame_sdl2_7surface_Surface.tp_dict, __pyx_vtabptr_11pygame_sdl2_7surface_Surface) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
13475 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Surface, (PyObject *)&__pyx_type_11pygame_sdl2_7surface_Surface) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
13476 if (__pyx_type_11pygame_sdl2_7surface_Surface.tp_weaklistoffset == 0) __pyx_type_11pygame_sdl2_7surface_Surface.tp_weaklistoffset = offsetof(struct __pyx_obj_11pygame_sdl2_7surface_Surface, __weakref__);
13477 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_11pygame_sdl2_7surface_Surface) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
13478 __pyx_ptype_11pygame_sdl2_7surface_Surface = &__pyx_type_11pygame_sdl2_7surface_Surface;
13479 __Pyx_RefNannyFinishContext();
13480 return 0;
13481 __pyx_L1_error:;
13482 __Pyx_RefNannyFinishContext();
13483 return -1;
13484 }
13485
__Pyx_modinit_type_import_code(void)13486 static int __Pyx_modinit_type_import_code(void) {
13487 __Pyx_RefNannyDeclarations
13488 PyObject *__pyx_t_1 = NULL;
13489 int __pyx_lineno = 0;
13490 const char *__pyx_filename = NULL;
13491 int __pyx_clineno = 0;
13492 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
13493 /*--- Type import code ---*/
13494 __pyx_t_1 = PyImport_ImportModule("pygame_sdl2.color"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 26, __pyx_L1_error)
13495 __Pyx_GOTREF(__pyx_t_1);
13496 __pyx_ptype_11pygame_sdl2_5color_Color = __Pyx_ImportType(__pyx_t_1, "pygame_sdl2.color", "Color", sizeof(struct __pyx_obj_11pygame_sdl2_5color_Color), __Pyx_ImportType_CheckSize_Warn);
13497 if (!__pyx_ptype_11pygame_sdl2_5color_Color) __PYX_ERR(2, 26, __pyx_L1_error)
13498 __pyx_vtabptr_11pygame_sdl2_5color_Color = (struct __pyx_vtabstruct_11pygame_sdl2_5color_Color*)__Pyx_GetVtable(__pyx_ptype_11pygame_sdl2_5color_Color->tp_dict); if (unlikely(!__pyx_vtabptr_11pygame_sdl2_5color_Color)) __PYX_ERR(2, 26, __pyx_L1_error)
13499 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13500 __pyx_t_1 = PyImport_ImportModule("pygame_sdl2.rect"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 21, __pyx_L1_error)
13501 __Pyx_GOTREF(__pyx_t_1);
13502 __pyx_ptype_11pygame_sdl2_4rect_Rect = __Pyx_ImportType(__pyx_t_1, "pygame_sdl2.rect", "Rect", sizeof(struct __pyx_obj_11pygame_sdl2_4rect_Rect), __Pyx_ImportType_CheckSize_Warn);
13503 if (!__pyx_ptype_11pygame_sdl2_4rect_Rect) __PYX_ERR(3, 21, __pyx_L1_error)
13504 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13505 __Pyx_RefNannyFinishContext();
13506 return 0;
13507 __pyx_L1_error:;
13508 __Pyx_XDECREF(__pyx_t_1);
13509 __Pyx_RefNannyFinishContext();
13510 return -1;
13511 }
13512
__Pyx_modinit_variable_import_code(void)13513 static int __Pyx_modinit_variable_import_code(void) {
13514 __Pyx_RefNannyDeclarations
13515 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
13516 /*--- Variable import code ---*/
13517 __Pyx_RefNannyFinishContext();
13518 return 0;
13519 }
13520
__Pyx_modinit_function_import_code(void)13521 static int __Pyx_modinit_function_import_code(void) {
13522 __Pyx_RefNannyDeclarations
13523 PyObject *__pyx_t_1 = NULL;
13524 PyObject *__pyx_t_2 = NULL;
13525 int __pyx_lineno = 0;
13526 const char *__pyx_filename = NULL;
13527 int __pyx_clineno = 0;
13528 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
13529 /*--- Function import code ---*/
13530 __pyx_t_1 = PyImport_ImportModule("pygame_sdl2.color"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
13531 if (__Pyx_ImportFunction(__pyx_t_1, "map_color", (void (**)(void))&__pyx_f_11pygame_sdl2_5color_map_color, "Uint32 (SDL_Surface *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13532 if (__Pyx_ImportFunction(__pyx_t_1, "get_color", (void (**)(void))&__pyx_f_11pygame_sdl2_5color_get_color, "PyObject *(Uint32, SDL_Surface *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13533 Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13534 __pyx_t_2 = PyImport_ImportModule("pygame_sdl2.rect"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
13535 if (__Pyx_ImportFunction(__pyx_t_2, "to_sdl_rect", (void (**)(void))&__pyx_f_11pygame_sdl2_4rect_to_sdl_rect, "int (PyObject *, SDL_Rect *, struct __pyx_opt_args_11pygame_sdl2_4rect_to_sdl_rect *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13536 Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13537 __Pyx_RefNannyFinishContext();
13538 return 0;
13539 __pyx_L1_error:;
13540 __Pyx_XDECREF(__pyx_t_1);
13541 __Pyx_XDECREF(__pyx_t_2);
13542 __Pyx_RefNannyFinishContext();
13543 return -1;
13544 }
13545
13546
13547 #ifndef CYTHON_NO_PYINIT_EXPORT
13548 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
13549 #elif PY_MAJOR_VERSION < 3
13550 #ifdef __cplusplus
13551 #define __Pyx_PyMODINIT_FUNC extern "C" void
13552 #else
13553 #define __Pyx_PyMODINIT_FUNC void
13554 #endif
13555 #else
13556 #ifdef __cplusplus
13557 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
13558 #else
13559 #define __Pyx_PyMODINIT_FUNC PyObject *
13560 #endif
13561 #endif
13562
13563
13564 #if PY_MAJOR_VERSION < 3
13565 __Pyx_PyMODINIT_FUNC initpygame_sdl2_surface(void) CYTHON_SMALL_CODE; /*proto*/
initpygame_sdl2_surface(void)13566 __Pyx_PyMODINIT_FUNC initpygame_sdl2_surface(void)
13567 #else
13568 __Pyx_PyMODINIT_FUNC PyInit_pygame_sdl2_surface(void) CYTHON_SMALL_CODE; /*proto*/
13569 __Pyx_PyMODINIT_FUNC PyInit_pygame_sdl2_surface(void)
13570 #if CYTHON_PEP489_MULTI_PHASE_INIT
13571 {
13572 return PyModuleDef_Init(&__pyx_moduledef);
13573 }
13574 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
13575 #if PY_VERSION_HEX >= 0x030700A1
13576 static PY_INT64_T main_interpreter_id = -1;
13577 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
13578 if (main_interpreter_id == -1) {
13579 main_interpreter_id = current_id;
13580 return (unlikely(current_id == -1)) ? -1 : 0;
13581 } else if (unlikely(main_interpreter_id != current_id))
13582 #else
13583 static PyInterpreterState *main_interpreter = NULL;
13584 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
13585 if (!main_interpreter) {
13586 main_interpreter = current_interpreter;
13587 } else if (unlikely(main_interpreter != current_interpreter))
13588 #endif
13589 {
13590 PyErr_SetString(
13591 PyExc_ImportError,
13592 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
13593 return -1;
13594 }
13595 return 0;
13596 }
13597 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
13598 PyObject *value = PyObject_GetAttrString(spec, from_name);
13599 int result = 0;
13600 if (likely(value)) {
13601 if (allow_none || value != Py_None) {
13602 result = PyDict_SetItemString(moddict, to_name, value);
13603 }
13604 Py_DECREF(value);
13605 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
13606 PyErr_Clear();
13607 } else {
13608 result = -1;
13609 }
13610 return result;
13611 }
13612 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
13613 PyObject *module = NULL, *moddict, *modname;
13614 if (__Pyx_check_single_interpreter())
13615 return NULL;
13616 if (__pyx_m)
13617 return __Pyx_NewRef(__pyx_m);
13618 modname = PyObject_GetAttrString(spec, "name");
13619 if (unlikely(!modname)) goto bad;
13620 module = PyModule_NewObject(modname);
13621 Py_DECREF(modname);
13622 if (unlikely(!module)) goto bad;
13623 moddict = PyModule_GetDict(module);
13624 if (unlikely(!moddict)) goto bad;
13625 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
13626 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
13627 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
13628 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
13629 return module;
13630 bad:
13631 Py_XDECREF(module);
13632 return NULL;
13633 }
13634
13635
13636 static CYTHON_SMALL_CODE int __pyx_pymod_exec_surface(PyObject *__pyx_pyinit_module)
13637 #endif
13638 #endif
13639 {
13640 PyObject *__pyx_t_1 = NULL;
13641 PyObject *__pyx_t_2 = NULL;
13642 int __pyx_lineno = 0;
13643 const char *__pyx_filename = NULL;
13644 int __pyx_clineno = 0;
13645 __Pyx_RefNannyDeclarations
13646 #if CYTHON_PEP489_MULTI_PHASE_INIT
13647 if (__pyx_m) {
13648 if (__pyx_m == __pyx_pyinit_module) return 0;
13649 PyErr_SetString(PyExc_RuntimeError, "Module 'surface' has already been imported. Re-initialisation is not supported.");
13650 return -1;
13651 }
13652 #elif PY_MAJOR_VERSION >= 3
13653 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
13654 #endif
13655 #if CYTHON_REFNANNY
13656 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
13657 if (!__Pyx_RefNanny) {
13658 PyErr_Clear();
13659 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
13660 if (!__Pyx_RefNanny)
13661 Py_FatalError("failed to import 'refnanny' module");
13662 }
13663 #endif
13664 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_surface(void)", 0);
13665 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13666 #ifdef __Pxy_PyFrame_Initialize_Offsets
13667 __Pxy_PyFrame_Initialize_Offsets();
13668 #endif
13669 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
13670 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
13671 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
13672 #ifdef __Pyx_CyFunction_USED
13673 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13674 #endif
13675 #ifdef __Pyx_FusedFunction_USED
13676 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13677 #endif
13678 #ifdef __Pyx_Coroutine_USED
13679 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13680 #endif
13681 #ifdef __Pyx_Generator_USED
13682 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13683 #endif
13684 #ifdef __Pyx_AsyncGen_USED
13685 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13686 #endif
13687 #ifdef __Pyx_StopAsyncIteration_USED
13688 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13689 #endif
13690 /*--- Library function declarations ---*/
13691 /*--- Threads initialization code ---*/
13692 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
13693 #ifdef WITH_THREAD /* Python build with threading support? */
13694 PyEval_InitThreads();
13695 #endif
13696 #endif
13697 /*--- Module creation code ---*/
13698 #if CYTHON_PEP489_MULTI_PHASE_INIT
13699 __pyx_m = __pyx_pyinit_module;
13700 Py_INCREF(__pyx_m);
13701 #else
13702 #if PY_MAJOR_VERSION < 3
13703 __pyx_m = Py_InitModule4("pygame_sdl2.surface", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
13704 #else
13705 __pyx_m = PyModule_Create(&__pyx_moduledef);
13706 #endif
13707 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
13708 #endif
13709 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
13710 Py_INCREF(__pyx_d);
13711 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
13712 Py_INCREF(__pyx_b);
13713 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
13714 Py_INCREF(__pyx_cython_runtime);
13715 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
13716 /*--- Initialize various global constants etc. ---*/
13717 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13718 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
13719 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13720 #endif
13721 if (__pyx_module_is_main_pygame_sdl2__surface) {
13722 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13723 }
13724 #if PY_MAJOR_VERSION >= 3
13725 {
13726 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
13727 if (!PyDict_GetItemString(modules, "pygame_sdl2.surface")) {
13728 if (unlikely(PyDict_SetItemString(modules, "pygame_sdl2.surface", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
13729 }
13730 }
13731 #endif
13732 /*--- Builtin init code ---*/
13733 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13734 /*--- Constants init code ---*/
13735 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13736 /*--- Global type/function init code ---*/
13737 (void)__Pyx_modinit_global_init_code();
13738 (void)__Pyx_modinit_variable_export_code();
13739 if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
13740 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
13741 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
13742 (void)__Pyx_modinit_variable_import_code();
13743 if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
13744 /*--- Execution code ---*/
13745 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
13746 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13747 #endif
13748
13749 /* "pygame_sdl2/surface.pyx":25
13750 * from pygame_sdl2.color cimport map_color, get_color
13751 * from pygame_sdl2.rect cimport to_sdl_rect
13752 * from pygame_sdl2.rect import Rect # <<<<<<<<<<<<<<
13753 *
13754 * from pygame_sdl2.error import error
13755 */
13756 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
13757 __Pyx_GOTREF(__pyx_t_1);
13758 __Pyx_INCREF(__pyx_n_s_Rect);
13759 __Pyx_GIVEREF(__pyx_n_s_Rect);
13760 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Rect);
13761 __pyx_t_2 = __Pyx_Import(__pyx_n_s_pygame_sdl2_rect, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
13762 __Pyx_GOTREF(__pyx_t_2);
13763 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13764 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Rect); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
13765 __Pyx_GOTREF(__pyx_t_1);
13766 if (PyDict_SetItem(__pyx_d, __pyx_n_s_Rect, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
13767 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13768 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13769
13770 /* "pygame_sdl2/surface.pyx":27
13771 * from pygame_sdl2.rect import Rect
13772 *
13773 * from pygame_sdl2.error import error # <<<<<<<<<<<<<<
13774 * from pygame_sdl2.locals import SRCALPHA
13775 * import pygame_sdl2
13776 */
13777 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
13778 __Pyx_GOTREF(__pyx_t_2);
13779 __Pyx_INCREF(__pyx_n_s_error);
13780 __Pyx_GIVEREF(__pyx_n_s_error);
13781 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_error);
13782 __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame_sdl2_error, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
13783 __Pyx_GOTREF(__pyx_t_1);
13784 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13785 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
13786 __Pyx_GOTREF(__pyx_t_2);
13787 if (PyDict_SetItem(__pyx_d, __pyx_n_s_error, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
13788 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13789 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13790
13791 /* "pygame_sdl2/surface.pyx":28
13792 *
13793 * from pygame_sdl2.error import error
13794 * from pygame_sdl2.locals import SRCALPHA # <<<<<<<<<<<<<<
13795 * import pygame_sdl2
13796 *
13797 */
13798 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
13799 __Pyx_GOTREF(__pyx_t_1);
13800 __Pyx_INCREF(__pyx_n_s_SRCALPHA);
13801 __Pyx_GIVEREF(__pyx_n_s_SRCALPHA);
13802 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_SRCALPHA);
13803 __pyx_t_2 = __Pyx_Import(__pyx_n_s_pygame_sdl2_locals, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
13804 __Pyx_GOTREF(__pyx_t_2);
13805 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13806 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
13807 __Pyx_GOTREF(__pyx_t_1);
13808 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SRCALPHA, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
13809 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13810 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13811
13812 /* "pygame_sdl2/surface.pyx":29
13813 * from pygame_sdl2.error import error
13814 * from pygame_sdl2.locals import SRCALPHA
13815 * import pygame_sdl2 # <<<<<<<<<<<<<<
13816 *
13817 * import warnings
13818 */
13819 __pyx_t_2 = __Pyx_Import(__pyx_n_s_pygame_sdl2, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
13820 __Pyx_GOTREF(__pyx_t_2);
13821 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pygame_sdl2, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
13822 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13823
13824 /* "pygame_sdl2/surface.pyx":31
13825 * import pygame_sdl2
13826 *
13827 * import warnings # <<<<<<<<<<<<<<
13828 *
13829 * cdef extern from "src/surface.h" nogil:
13830 */
13831 __pyx_t_2 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
13832 __Pyx_GOTREF(__pyx_t_2);
13833 if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
13834 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13835
13836 /* "pygame_sdl2/surface.pyx":51
13837 *
13838 * # The total size of all allocated surfaces
13839 * total_size = 0 # <<<<<<<<<<<<<<
13840 *
13841 * cdef class Surface:
13842 */
13843 if (PyDict_SetItem(__pyx_d, __pyx_n_s_total_size, __pyx_int_0) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
13844
13845 /* "pygame_sdl2/surface.pyx":1
13846 * # Copyright 2014 Patrick Dawson <pat@dw.is> # <<<<<<<<<<<<<<
13847 * # Copyright 2014 Tom Rothamel <tom@rothamel.us>
13848 * #
13849 */
13850 __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
13851 __Pyx_GOTREF(__pyx_t_2);
13852 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
13853 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13854
13855 /*--- Wrapped vars code ---*/
13856
13857 goto __pyx_L0;
13858 __pyx_L1_error:;
13859 __Pyx_XDECREF(__pyx_t_1);
13860 __Pyx_XDECREF(__pyx_t_2);
13861 if (__pyx_m) {
13862 if (__pyx_d) {
13863 __Pyx_AddTraceback("init pygame_sdl2.surface", __pyx_clineno, __pyx_lineno, __pyx_filename);
13864 }
13865 Py_CLEAR(__pyx_m);
13866 } else if (!PyErr_Occurred()) {
13867 PyErr_SetString(PyExc_ImportError, "init pygame_sdl2.surface");
13868 }
13869 __pyx_L0:;
13870 __Pyx_RefNannyFinishContext();
13871 #if CYTHON_PEP489_MULTI_PHASE_INIT
13872 return (__pyx_m != NULL) ? 0 : -1;
13873 #elif PY_MAJOR_VERSION >= 3
13874 return __pyx_m;
13875 #else
13876 return;
13877 #endif
13878 }
13879
13880 /* --- Runtime support code --- */
13881 /* Refnanny */
13882 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)13883 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
13884 PyObject *m = NULL, *p = NULL;
13885 void *r = NULL;
13886 m = PyImport_ImportModule(modname);
13887 if (!m) goto end;
13888 p = PyObject_GetAttrString(m, "RefNannyAPI");
13889 if (!p) goto end;
13890 r = PyLong_AsVoidPtr(p);
13891 end:
13892 Py_XDECREF(p);
13893 Py_XDECREF(m);
13894 return (__Pyx_RefNannyAPIStruct *)r;
13895 }
13896 #endif
13897
13898 /* PyObjectGetAttrStr */
13899 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)13900 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
13901 PyTypeObject* tp = Py_TYPE(obj);
13902 if (likely(tp->tp_getattro))
13903 return tp->tp_getattro(obj, attr_name);
13904 #if PY_MAJOR_VERSION < 3
13905 if (likely(tp->tp_getattr))
13906 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
13907 #endif
13908 return PyObject_GetAttr(obj, attr_name);
13909 }
13910 #endif
13911
13912 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)13913 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
13914 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
13915 if (unlikely(!result)) {
13916 PyErr_Format(PyExc_NameError,
13917 #if PY_MAJOR_VERSION >= 3
13918 "name '%U' is not defined", name);
13919 #else
13920 "name '%.200s' is not defined", PyString_AS_STRING(name));
13921 #endif
13922 }
13923 return result;
13924 }
13925
13926 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)13927 static void __Pyx_RaiseArgtupleInvalid(
13928 const char* func_name,
13929 int exact,
13930 Py_ssize_t num_min,
13931 Py_ssize_t num_max,
13932 Py_ssize_t num_found)
13933 {
13934 Py_ssize_t num_expected;
13935 const char *more_or_less;
13936 if (num_found < num_min) {
13937 num_expected = num_min;
13938 more_or_less = "at least";
13939 } else {
13940 num_expected = num_max;
13941 more_or_less = "at most";
13942 }
13943 if (exact) {
13944 more_or_less = "exactly";
13945 }
13946 PyErr_Format(PyExc_TypeError,
13947 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
13948 func_name, more_or_less, num_expected,
13949 (num_expected == 1) ? "" : "s", num_found);
13950 }
13951
13952 /* KeywordStringCheck */
__Pyx_CheckKeywordStrings(PyObject * kwdict,const char * function_name,int kw_allowed)13953 static int __Pyx_CheckKeywordStrings(
13954 PyObject *kwdict,
13955 const char* function_name,
13956 int kw_allowed)
13957 {
13958 PyObject* key = 0;
13959 Py_ssize_t pos = 0;
13960 #if CYTHON_COMPILING_IN_PYPY
13961 if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
13962 goto invalid_keyword;
13963 return 1;
13964 #else
13965 while (PyDict_Next(kwdict, &pos, &key, 0)) {
13966 #if PY_MAJOR_VERSION < 3
13967 if (unlikely(!PyString_Check(key)))
13968 #endif
13969 if (unlikely(!PyUnicode_Check(key)))
13970 goto invalid_keyword_type;
13971 }
13972 if ((!kw_allowed) && unlikely(key))
13973 goto invalid_keyword;
13974 return 1;
13975 invalid_keyword_type:
13976 PyErr_Format(PyExc_TypeError,
13977 "%.200s() keywords must be strings", function_name);
13978 return 0;
13979 #endif
13980 invalid_keyword:
13981 PyErr_Format(PyExc_TypeError,
13982 #if PY_MAJOR_VERSION < 3
13983 "%.200s() got an unexpected keyword argument '%.200s'",
13984 function_name, PyString_AsString(key));
13985 #else
13986 "%s() got an unexpected keyword argument '%U'",
13987 function_name, key);
13988 #endif
13989 return 0;
13990 }
13991
13992 /* PyDictVersioning */
13993 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)13994 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
13995 PyObject *dict = Py_TYPE(obj)->tp_dict;
13996 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
13997 }
__Pyx_get_object_dict_version(PyObject * obj)13998 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
13999 PyObject **dictptr = NULL;
14000 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
14001 if (offset) {
14002 #if CYTHON_COMPILING_IN_CPYTHON
14003 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
14004 #else
14005 dictptr = _PyObject_GetDictPtr(obj);
14006 #endif
14007 }
14008 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
14009 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)14010 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
14011 PyObject *dict = Py_TYPE(obj)->tp_dict;
14012 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
14013 return 0;
14014 return obj_dict_version == __Pyx_get_object_dict_version(obj);
14015 }
14016 #endif
14017
14018 /* GetModuleGlobalName */
14019 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)14020 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
14021 #else
14022 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
14023 #endif
14024 {
14025 PyObject *result;
14026 #if !CYTHON_AVOID_BORROWED_REFS
14027 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
14028 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
14029 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
14030 if (likely(result)) {
14031 return __Pyx_NewRef(result);
14032 } else if (unlikely(PyErr_Occurred())) {
14033 return NULL;
14034 }
14035 #else
14036 result = PyDict_GetItem(__pyx_d, name);
14037 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
14038 if (likely(result)) {
14039 return __Pyx_NewRef(result);
14040 }
14041 #endif
14042 #else
14043 result = PyObject_GetItem(__pyx_d, name);
14044 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
14045 if (likely(result)) {
14046 return __Pyx_NewRef(result);
14047 }
14048 PyErr_Clear();
14049 #endif
14050 return __Pyx_GetBuiltinName(name);
14051 }
14052
14053 /* PyCFunctionFastCall */
14054 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)14055 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
14056 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
14057 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
14058 PyObject *self = PyCFunction_GET_SELF(func);
14059 int flags = PyCFunction_GET_FLAGS(func);
14060 assert(PyCFunction_Check(func));
14061 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
14062 assert(nargs >= 0);
14063 assert(nargs == 0 || args != NULL);
14064 /* _PyCFunction_FastCallDict() must not be called with an exception set,
14065 because it may clear it (directly or indirectly) and so the
14066 caller loses its exception */
14067 assert(!PyErr_Occurred());
14068 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
14069 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
14070 } else {
14071 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
14072 }
14073 }
14074 #endif
14075
14076 /* PyFunctionFastCall */
14077 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)14078 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
14079 PyObject *globals) {
14080 PyFrameObject *f;
14081 PyThreadState *tstate = __Pyx_PyThreadState_Current;
14082 PyObject **fastlocals;
14083 Py_ssize_t i;
14084 PyObject *result;
14085 assert(globals != NULL);
14086 /* XXX Perhaps we should create a specialized
14087 PyFrame_New() that doesn't take locals, but does
14088 take builtins without sanity checking them.
14089 */
14090 assert(tstate != NULL);
14091 f = PyFrame_New(tstate, co, globals, NULL);
14092 if (f == NULL) {
14093 return NULL;
14094 }
14095 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
14096 for (i = 0; i < na; i++) {
14097 Py_INCREF(*args);
14098 fastlocals[i] = *args++;
14099 }
14100 result = PyEval_EvalFrameEx(f,0);
14101 ++tstate->recursion_depth;
14102 Py_DECREF(f);
14103 --tstate->recursion_depth;
14104 return result;
14105 }
14106 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)14107 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
14108 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
14109 PyObject *globals = PyFunction_GET_GLOBALS(func);
14110 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
14111 PyObject *closure;
14112 #if PY_MAJOR_VERSION >= 3
14113 PyObject *kwdefs;
14114 #endif
14115 PyObject *kwtuple, **k;
14116 PyObject **d;
14117 Py_ssize_t nd;
14118 Py_ssize_t nk;
14119 PyObject *result;
14120 assert(kwargs == NULL || PyDict_Check(kwargs));
14121 nk = kwargs ? PyDict_Size(kwargs) : 0;
14122 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
14123 return NULL;
14124 }
14125 if (
14126 #if PY_MAJOR_VERSION >= 3
14127 co->co_kwonlyargcount == 0 &&
14128 #endif
14129 likely(kwargs == NULL || nk == 0) &&
14130 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
14131 if (argdefs == NULL && co->co_argcount == nargs) {
14132 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
14133 goto done;
14134 }
14135 else if (nargs == 0 && argdefs != NULL
14136 && co->co_argcount == Py_SIZE(argdefs)) {
14137 /* function called with no arguments, but all parameters have
14138 a default value: use default values as arguments .*/
14139 args = &PyTuple_GET_ITEM(argdefs, 0);
14140 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
14141 goto done;
14142 }
14143 }
14144 if (kwargs != NULL) {
14145 Py_ssize_t pos, i;
14146 kwtuple = PyTuple_New(2 * nk);
14147 if (kwtuple == NULL) {
14148 result = NULL;
14149 goto done;
14150 }
14151 k = &PyTuple_GET_ITEM(kwtuple, 0);
14152 pos = i = 0;
14153 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
14154 Py_INCREF(k[i]);
14155 Py_INCREF(k[i+1]);
14156 i += 2;
14157 }
14158 nk = i / 2;
14159 }
14160 else {
14161 kwtuple = NULL;
14162 k = NULL;
14163 }
14164 closure = PyFunction_GET_CLOSURE(func);
14165 #if PY_MAJOR_VERSION >= 3
14166 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
14167 #endif
14168 if (argdefs != NULL) {
14169 d = &PyTuple_GET_ITEM(argdefs, 0);
14170 nd = Py_SIZE(argdefs);
14171 }
14172 else {
14173 d = NULL;
14174 nd = 0;
14175 }
14176 #if PY_MAJOR_VERSION >= 3
14177 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
14178 args, (int)nargs,
14179 k, (int)nk,
14180 d, (int)nd, kwdefs, closure);
14181 #else
14182 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
14183 args, (int)nargs,
14184 k, (int)nk,
14185 d, (int)nd, closure);
14186 #endif
14187 Py_XDECREF(kwtuple);
14188 done:
14189 Py_LeaveRecursiveCall();
14190 return result;
14191 }
14192 #endif
14193 #endif
14194
14195 /* PyObjectCall */
14196 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)14197 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
14198 PyObject *result;
14199 ternaryfunc call = func->ob_type->tp_call;
14200 if (unlikely(!call))
14201 return PyObject_Call(func, arg, kw);
14202 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
14203 return NULL;
14204 result = (*call)(func, arg, kw);
14205 Py_LeaveRecursiveCall();
14206 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
14207 PyErr_SetString(
14208 PyExc_SystemError,
14209 "NULL result without error in PyObject_Call");
14210 }
14211 return result;
14212 }
14213 #endif
14214
14215 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)14216 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
14217 PyObject *args, *result = NULL;
14218 #if CYTHON_FAST_PYCALL
14219 if (PyFunction_Check(function)) {
14220 PyObject *args[2] = {arg1, arg2};
14221 return __Pyx_PyFunction_FastCall(function, args, 2);
14222 }
14223 #endif
14224 #if CYTHON_FAST_PYCCALL
14225 if (__Pyx_PyFastCFunction_Check(function)) {
14226 PyObject *args[2] = {arg1, arg2};
14227 return __Pyx_PyCFunction_FastCall(function, args, 2);
14228 }
14229 #endif
14230 args = PyTuple_New(2);
14231 if (unlikely(!args)) goto done;
14232 Py_INCREF(arg1);
14233 PyTuple_SET_ITEM(args, 0, arg1);
14234 Py_INCREF(arg2);
14235 PyTuple_SET_ITEM(args, 1, arg2);
14236 Py_INCREF(function);
14237 result = __Pyx_PyObject_Call(function, args, NULL);
14238 Py_DECREF(args);
14239 Py_DECREF(function);
14240 done:
14241 return result;
14242 }
14243
14244 /* PyObjectCallMethO */
14245 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)14246 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
14247 PyObject *self, *result;
14248 PyCFunction cfunc;
14249 cfunc = PyCFunction_GET_FUNCTION(func);
14250 self = PyCFunction_GET_SELF(func);
14251 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
14252 return NULL;
14253 result = cfunc(self, arg);
14254 Py_LeaveRecursiveCall();
14255 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
14256 PyErr_SetString(
14257 PyExc_SystemError,
14258 "NULL result without error in PyObject_Call");
14259 }
14260 return result;
14261 }
14262 #endif
14263
14264 /* PyObjectCallOneArg */
14265 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)14266 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
14267 PyObject *result;
14268 PyObject *args = PyTuple_New(1);
14269 if (unlikely(!args)) return NULL;
14270 Py_INCREF(arg);
14271 PyTuple_SET_ITEM(args, 0, arg);
14272 result = __Pyx_PyObject_Call(func, args, NULL);
14273 Py_DECREF(args);
14274 return result;
14275 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)14276 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
14277 #if CYTHON_FAST_PYCALL
14278 if (PyFunction_Check(func)) {
14279 return __Pyx_PyFunction_FastCall(func, &arg, 1);
14280 }
14281 #endif
14282 if (likely(PyCFunction_Check(func))) {
14283 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
14284 return __Pyx_PyObject_CallMethO(func, arg);
14285 #if CYTHON_FAST_PYCCALL
14286 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
14287 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
14288 #endif
14289 }
14290 }
14291 return __Pyx__PyObject_CallOneArg(func, arg);
14292 }
14293 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)14294 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
14295 PyObject *result;
14296 PyObject *args = PyTuple_Pack(1, arg);
14297 if (unlikely(!args)) return NULL;
14298 result = __Pyx_PyObject_Call(func, args, NULL);
14299 Py_DECREF(args);
14300 return result;
14301 }
14302 #endif
14303
14304 /* PyErrFetchRestore */
14305 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)14306 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
14307 PyObject *tmp_type, *tmp_value, *tmp_tb;
14308 tmp_type = tstate->curexc_type;
14309 tmp_value = tstate->curexc_value;
14310 tmp_tb = tstate->curexc_traceback;
14311 tstate->curexc_type = type;
14312 tstate->curexc_value = value;
14313 tstate->curexc_traceback = tb;
14314 Py_XDECREF(tmp_type);
14315 Py_XDECREF(tmp_value);
14316 Py_XDECREF(tmp_tb);
14317 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)14318 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
14319 *type = tstate->curexc_type;
14320 *value = tstate->curexc_value;
14321 *tb = tstate->curexc_traceback;
14322 tstate->curexc_type = 0;
14323 tstate->curexc_value = 0;
14324 tstate->curexc_traceback = 0;
14325 }
14326 #endif
14327
14328 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)14329 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
14330 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
14331 int full_traceback, CYTHON_UNUSED int nogil) {
14332 PyObject *old_exc, *old_val, *old_tb;
14333 PyObject *ctx;
14334 __Pyx_PyThreadState_declare
14335 #ifdef WITH_THREAD
14336 PyGILState_STATE state;
14337 if (nogil)
14338 state = PyGILState_Ensure();
14339 #ifdef _MSC_VER
14340 else state = (PyGILState_STATE)-1;
14341 #endif
14342 #endif
14343 __Pyx_PyThreadState_assign
14344 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
14345 if (full_traceback) {
14346 Py_XINCREF(old_exc);
14347 Py_XINCREF(old_val);
14348 Py_XINCREF(old_tb);
14349 __Pyx_ErrRestore(old_exc, old_val, old_tb);
14350 PyErr_PrintEx(1);
14351 }
14352 #if PY_MAJOR_VERSION < 3
14353 ctx = PyString_FromString(name);
14354 #else
14355 ctx = PyUnicode_FromString(name);
14356 #endif
14357 __Pyx_ErrRestore(old_exc, old_val, old_tb);
14358 if (!ctx) {
14359 PyErr_WriteUnraisable(Py_None);
14360 } else {
14361 PyErr_WriteUnraisable(ctx);
14362 Py_DECREF(ctx);
14363 }
14364 #ifdef WITH_THREAD
14365 if (nogil)
14366 PyGILState_Release(state);
14367 #endif
14368 }
14369
14370 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)14371 static void __Pyx_RaiseDoubleKeywordsError(
14372 const char* func_name,
14373 PyObject* kw_name)
14374 {
14375 PyErr_Format(PyExc_TypeError,
14376 #if PY_MAJOR_VERSION >= 3
14377 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
14378 #else
14379 "%s() got multiple values for keyword argument '%s'", func_name,
14380 PyString_AsString(kw_name));
14381 #endif
14382 }
14383
14384 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)14385 static int __Pyx_ParseOptionalKeywords(
14386 PyObject *kwds,
14387 PyObject **argnames[],
14388 PyObject *kwds2,
14389 PyObject *values[],
14390 Py_ssize_t num_pos_args,
14391 const char* function_name)
14392 {
14393 PyObject *key = 0, *value = 0;
14394 Py_ssize_t pos = 0;
14395 PyObject*** name;
14396 PyObject*** first_kw_arg = argnames + num_pos_args;
14397 while (PyDict_Next(kwds, &pos, &key, &value)) {
14398 name = first_kw_arg;
14399 while (*name && (**name != key)) name++;
14400 if (*name) {
14401 values[name-argnames] = value;
14402 continue;
14403 }
14404 name = first_kw_arg;
14405 #if PY_MAJOR_VERSION < 3
14406 if (likely(PyString_Check(key))) {
14407 while (*name) {
14408 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
14409 && _PyString_Eq(**name, key)) {
14410 values[name-argnames] = value;
14411 break;
14412 }
14413 name++;
14414 }
14415 if (*name) continue;
14416 else {
14417 PyObject*** argname = argnames;
14418 while (argname != first_kw_arg) {
14419 if ((**argname == key) || (
14420 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
14421 && _PyString_Eq(**argname, key))) {
14422 goto arg_passed_twice;
14423 }
14424 argname++;
14425 }
14426 }
14427 } else
14428 #endif
14429 if (likely(PyUnicode_Check(key))) {
14430 while (*name) {
14431 int cmp = (**name == key) ? 0 :
14432 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
14433 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
14434 #endif
14435 PyUnicode_Compare(**name, key);
14436 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
14437 if (cmp == 0) {
14438 values[name-argnames] = value;
14439 break;
14440 }
14441 name++;
14442 }
14443 if (*name) continue;
14444 else {
14445 PyObject*** argname = argnames;
14446 while (argname != first_kw_arg) {
14447 int cmp = (**argname == key) ? 0 :
14448 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
14449 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
14450 #endif
14451 PyUnicode_Compare(**argname, key);
14452 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
14453 if (cmp == 0) goto arg_passed_twice;
14454 argname++;
14455 }
14456 }
14457 } else
14458 goto invalid_keyword_type;
14459 if (kwds2) {
14460 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
14461 } else {
14462 goto invalid_keyword;
14463 }
14464 }
14465 return 0;
14466 arg_passed_twice:
14467 __Pyx_RaiseDoubleKeywordsError(function_name, key);
14468 goto bad;
14469 invalid_keyword_type:
14470 PyErr_Format(PyExc_TypeError,
14471 "%.200s() keywords must be strings", function_name);
14472 goto bad;
14473 invalid_keyword:
14474 PyErr_Format(PyExc_TypeError,
14475 #if PY_MAJOR_VERSION < 3
14476 "%.200s() got an unexpected keyword argument '%.200s'",
14477 function_name, PyString_AsString(key));
14478 #else
14479 "%s() got an unexpected keyword argument '%U'",
14480 function_name, key);
14481 #endif
14482 bad:
14483 return -1;
14484 }
14485
14486 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)14487 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
14488 PyErr_Format(PyExc_ValueError,
14489 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
14490 }
14491
14492 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)14493 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
14494 PyErr_Format(PyExc_ValueError,
14495 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
14496 index, (index == 1) ? "" : "s");
14497 }
14498
14499 /* IterFinish */
__Pyx_IterFinish(void)14500 static CYTHON_INLINE int __Pyx_IterFinish(void) {
14501 #if CYTHON_FAST_THREAD_STATE
14502 PyThreadState *tstate = __Pyx_PyThreadState_Current;
14503 PyObject* exc_type = tstate->curexc_type;
14504 if (unlikely(exc_type)) {
14505 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
14506 PyObject *exc_value, *exc_tb;
14507 exc_value = tstate->curexc_value;
14508 exc_tb = tstate->curexc_traceback;
14509 tstate->curexc_type = 0;
14510 tstate->curexc_value = 0;
14511 tstate->curexc_traceback = 0;
14512 Py_DECREF(exc_type);
14513 Py_XDECREF(exc_value);
14514 Py_XDECREF(exc_tb);
14515 return 0;
14516 } else {
14517 return -1;
14518 }
14519 }
14520 return 0;
14521 #else
14522 if (unlikely(PyErr_Occurred())) {
14523 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
14524 PyErr_Clear();
14525 return 0;
14526 } else {
14527 return -1;
14528 }
14529 }
14530 return 0;
14531 #endif
14532 }
14533
14534 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)14535 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
14536 if (unlikely(retval)) {
14537 Py_DECREF(retval);
14538 __Pyx_RaiseTooManyValuesError(expected);
14539 return -1;
14540 } else {
14541 return __Pyx_IterFinish();
14542 }
14543 return 0;
14544 }
14545
14546 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)14547 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
14548 if (unlikely(!type)) {
14549 PyErr_SetString(PyExc_SystemError, "Missing type object");
14550 return 0;
14551 }
14552 if (likely(__Pyx_TypeCheck(obj, type)))
14553 return 1;
14554 PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
14555 Py_TYPE(obj)->tp_name, type->tp_name);
14556 return 0;
14557 }
14558
14559 /* PyObjectCallNoArg */
14560 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)14561 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
14562 #if CYTHON_FAST_PYCALL
14563 if (PyFunction_Check(func)) {
14564 return __Pyx_PyFunction_FastCall(func, NULL, 0);
14565 }
14566 #endif
14567 #ifdef __Pyx_CyFunction_USED
14568 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
14569 #else
14570 if (likely(PyCFunction_Check(func)))
14571 #endif
14572 {
14573 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
14574 return __Pyx_PyObject_CallMethO(func, NULL);
14575 }
14576 }
14577 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
14578 }
14579 #endif
14580
14581 /* RaiseException */
14582 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)14583 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
14584 CYTHON_UNUSED PyObject *cause) {
14585 __Pyx_PyThreadState_declare
14586 Py_XINCREF(type);
14587 if (!value || value == Py_None)
14588 value = NULL;
14589 else
14590 Py_INCREF(value);
14591 if (!tb || tb == Py_None)
14592 tb = NULL;
14593 else {
14594 Py_INCREF(tb);
14595 if (!PyTraceBack_Check(tb)) {
14596 PyErr_SetString(PyExc_TypeError,
14597 "raise: arg 3 must be a traceback or None");
14598 goto raise_error;
14599 }
14600 }
14601 if (PyType_Check(type)) {
14602 #if CYTHON_COMPILING_IN_PYPY
14603 if (!value) {
14604 Py_INCREF(Py_None);
14605 value = Py_None;
14606 }
14607 #endif
14608 PyErr_NormalizeException(&type, &value, &tb);
14609 } else {
14610 if (value) {
14611 PyErr_SetString(PyExc_TypeError,
14612 "instance exception may not have a separate value");
14613 goto raise_error;
14614 }
14615 value = type;
14616 type = (PyObject*) Py_TYPE(type);
14617 Py_INCREF(type);
14618 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
14619 PyErr_SetString(PyExc_TypeError,
14620 "raise: exception class must be a subclass of BaseException");
14621 goto raise_error;
14622 }
14623 }
14624 __Pyx_PyThreadState_assign
14625 __Pyx_ErrRestore(type, value, tb);
14626 return;
14627 raise_error:
14628 Py_XDECREF(value);
14629 Py_XDECREF(type);
14630 Py_XDECREF(tb);
14631 return;
14632 }
14633 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)14634 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
14635 PyObject* owned_instance = NULL;
14636 if (tb == Py_None) {
14637 tb = 0;
14638 } else if (tb && !PyTraceBack_Check(tb)) {
14639 PyErr_SetString(PyExc_TypeError,
14640 "raise: arg 3 must be a traceback or None");
14641 goto bad;
14642 }
14643 if (value == Py_None)
14644 value = 0;
14645 if (PyExceptionInstance_Check(type)) {
14646 if (value) {
14647 PyErr_SetString(PyExc_TypeError,
14648 "instance exception may not have a separate value");
14649 goto bad;
14650 }
14651 value = type;
14652 type = (PyObject*) Py_TYPE(value);
14653 } else if (PyExceptionClass_Check(type)) {
14654 PyObject *instance_class = NULL;
14655 if (value && PyExceptionInstance_Check(value)) {
14656 instance_class = (PyObject*) Py_TYPE(value);
14657 if (instance_class != type) {
14658 int is_subclass = PyObject_IsSubclass(instance_class, type);
14659 if (!is_subclass) {
14660 instance_class = NULL;
14661 } else if (unlikely(is_subclass == -1)) {
14662 goto bad;
14663 } else {
14664 type = instance_class;
14665 }
14666 }
14667 }
14668 if (!instance_class) {
14669 PyObject *args;
14670 if (!value)
14671 args = PyTuple_New(0);
14672 else if (PyTuple_Check(value)) {
14673 Py_INCREF(value);
14674 args = value;
14675 } else
14676 args = PyTuple_Pack(1, value);
14677 if (!args)
14678 goto bad;
14679 owned_instance = PyObject_Call(type, args, NULL);
14680 Py_DECREF(args);
14681 if (!owned_instance)
14682 goto bad;
14683 value = owned_instance;
14684 if (!PyExceptionInstance_Check(value)) {
14685 PyErr_Format(PyExc_TypeError,
14686 "calling %R should have returned an instance of "
14687 "BaseException, not %R",
14688 type, Py_TYPE(value));
14689 goto bad;
14690 }
14691 }
14692 } else {
14693 PyErr_SetString(PyExc_TypeError,
14694 "raise: exception class must be a subclass of BaseException");
14695 goto bad;
14696 }
14697 if (cause) {
14698 PyObject *fixed_cause;
14699 if (cause == Py_None) {
14700 fixed_cause = NULL;
14701 } else if (PyExceptionClass_Check(cause)) {
14702 fixed_cause = PyObject_CallObject(cause, NULL);
14703 if (fixed_cause == NULL)
14704 goto bad;
14705 } else if (PyExceptionInstance_Check(cause)) {
14706 fixed_cause = cause;
14707 Py_INCREF(fixed_cause);
14708 } else {
14709 PyErr_SetString(PyExc_TypeError,
14710 "exception causes must derive from "
14711 "BaseException");
14712 goto bad;
14713 }
14714 PyException_SetCause(value, fixed_cause);
14715 }
14716 PyErr_SetObject(type, value);
14717 if (tb) {
14718 #if CYTHON_COMPILING_IN_PYPY
14719 PyObject *tmp_type, *tmp_value, *tmp_tb;
14720 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
14721 Py_INCREF(tb);
14722 PyErr_Restore(tmp_type, tmp_value, tb);
14723 Py_XDECREF(tmp_tb);
14724 #else
14725 PyThreadState *tstate = __Pyx_PyThreadState_Current;
14726 PyObject* tmp_tb = tstate->curexc_traceback;
14727 if (tb != tmp_tb) {
14728 Py_INCREF(tb);
14729 tstate->curexc_traceback = tb;
14730 Py_XDECREF(tmp_tb);
14731 }
14732 #endif
14733 }
14734 bad:
14735 Py_XDECREF(owned_instance);
14736 return;
14737 }
14738 #endif
14739
14740 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)14741 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
14742 {
14743 if (unlikely(!type)) {
14744 PyErr_SetString(PyExc_SystemError, "Missing type object");
14745 return 0;
14746 }
14747 else if (exact) {
14748 #if PY_MAJOR_VERSION == 2
14749 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
14750 #endif
14751 }
14752 else {
14753 if (likely(__Pyx_TypeCheck(obj, type))) return 1;
14754 }
14755 PyErr_Format(PyExc_TypeError,
14756 "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
14757 name, type->tp_name, Py_TYPE(obj)->tp_name);
14758 return 0;
14759 }
14760
14761 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)14762 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
14763 PyObject *r;
14764 if (!j) return NULL;
14765 r = PyObject_GetItem(o, j);
14766 Py_DECREF(j);
14767 return r;
14768 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)14769 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
14770 CYTHON_NCP_UNUSED int wraparound,
14771 CYTHON_NCP_UNUSED int boundscheck) {
14772 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14773 Py_ssize_t wrapped_i = i;
14774 if (wraparound & unlikely(i < 0)) {
14775 wrapped_i += PyList_GET_SIZE(o);
14776 }
14777 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
14778 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
14779 Py_INCREF(r);
14780 return r;
14781 }
14782 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
14783 #else
14784 return PySequence_GetItem(o, i);
14785 #endif
14786 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)14787 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
14788 CYTHON_NCP_UNUSED int wraparound,
14789 CYTHON_NCP_UNUSED int boundscheck) {
14790 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14791 Py_ssize_t wrapped_i = i;
14792 if (wraparound & unlikely(i < 0)) {
14793 wrapped_i += PyTuple_GET_SIZE(o);
14794 }
14795 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
14796 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
14797 Py_INCREF(r);
14798 return r;
14799 }
14800 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
14801 #else
14802 return PySequence_GetItem(o, i);
14803 #endif
14804 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)14805 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
14806 CYTHON_NCP_UNUSED int wraparound,
14807 CYTHON_NCP_UNUSED int boundscheck) {
14808 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
14809 if (is_list || PyList_CheckExact(o)) {
14810 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
14811 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
14812 PyObject *r = PyList_GET_ITEM(o, n);
14813 Py_INCREF(r);
14814 return r;
14815 }
14816 }
14817 else if (PyTuple_CheckExact(o)) {
14818 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
14819 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
14820 PyObject *r = PyTuple_GET_ITEM(o, n);
14821 Py_INCREF(r);
14822 return r;
14823 }
14824 } else {
14825 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
14826 if (likely(m && m->sq_item)) {
14827 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
14828 Py_ssize_t l = m->sq_length(o);
14829 if (likely(l >= 0)) {
14830 i += l;
14831 } else {
14832 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
14833 return NULL;
14834 PyErr_Clear();
14835 }
14836 }
14837 return m->sq_item(o, i);
14838 }
14839 }
14840 #else
14841 if (is_list || PySequence_Check(o)) {
14842 return PySequence_GetItem(o, i);
14843 }
14844 #endif
14845 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
14846 }
14847
14848 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)14849 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
14850 PyObject *attr;
14851 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
14852 PyTypeObject *tp = Py_TYPE(obj);
14853 PyObject *descr;
14854 descrgetfunc f = NULL;
14855 PyObject **dictptr, *dict;
14856 int meth_found = 0;
14857 assert (*method == NULL);
14858 if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
14859 attr = __Pyx_PyObject_GetAttrStr(obj, name);
14860 goto try_unpack;
14861 }
14862 if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
14863 return 0;
14864 }
14865 descr = _PyType_Lookup(tp, name);
14866 if (likely(descr != NULL)) {
14867 Py_INCREF(descr);
14868 #if PY_MAJOR_VERSION >= 3
14869 #ifdef __Pyx_CyFunction_USED
14870 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
14871 #else
14872 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
14873 #endif
14874 #else
14875 #ifdef __Pyx_CyFunction_USED
14876 if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
14877 #else
14878 if (likely(PyFunction_Check(descr)))
14879 #endif
14880 #endif
14881 {
14882 meth_found = 1;
14883 } else {
14884 f = Py_TYPE(descr)->tp_descr_get;
14885 if (f != NULL && PyDescr_IsData(descr)) {
14886 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
14887 Py_DECREF(descr);
14888 goto try_unpack;
14889 }
14890 }
14891 }
14892 dictptr = _PyObject_GetDictPtr(obj);
14893 if (dictptr != NULL && (dict = *dictptr) != NULL) {
14894 Py_INCREF(dict);
14895 attr = __Pyx_PyDict_GetItemStr(dict, name);
14896 if (attr != NULL) {
14897 Py_INCREF(attr);
14898 Py_DECREF(dict);
14899 Py_XDECREF(descr);
14900 goto try_unpack;
14901 }
14902 Py_DECREF(dict);
14903 }
14904 if (meth_found) {
14905 *method = descr;
14906 return 1;
14907 }
14908 if (f != NULL) {
14909 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
14910 Py_DECREF(descr);
14911 goto try_unpack;
14912 }
14913 if (descr != NULL) {
14914 *method = descr;
14915 return 0;
14916 }
14917 PyErr_Format(PyExc_AttributeError,
14918 #if PY_MAJOR_VERSION >= 3
14919 "'%.50s' object has no attribute '%U'",
14920 tp->tp_name, name);
14921 #else
14922 "'%.50s' object has no attribute '%.400s'",
14923 tp->tp_name, PyString_AS_STRING(name));
14924 #endif
14925 return 0;
14926 #else
14927 attr = __Pyx_PyObject_GetAttrStr(obj, name);
14928 goto try_unpack;
14929 #endif
14930 try_unpack:
14931 #if CYTHON_UNPACK_METHODS
14932 if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
14933 PyObject *function = PyMethod_GET_FUNCTION(attr);
14934 Py_INCREF(function);
14935 Py_DECREF(attr);
14936 *method = function;
14937 return 1;
14938 }
14939 #endif
14940 *method = attr;
14941 return 0;
14942 }
14943
14944 /* PyObjectCallMethod1 */
__Pyx__PyObject_CallMethod1(PyObject * method,PyObject * arg)14945 static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
14946 PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
14947 Py_DECREF(method);
14948 return result;
14949 }
__Pyx_PyObject_CallMethod1(PyObject * obj,PyObject * method_name,PyObject * arg)14950 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
14951 PyObject *method = NULL, *result;
14952 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
14953 if (likely(is_method)) {
14954 result = __Pyx_PyObject_Call2Args(method, obj, arg);
14955 Py_DECREF(method);
14956 return result;
14957 }
14958 if (unlikely(!method)) return NULL;
14959 return __Pyx__PyObject_CallMethod1(method, arg);
14960 }
14961
14962 /* append */
__Pyx_PyObject_Append(PyObject * L,PyObject * x)14963 static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
14964 if (likely(PyList_CheckExact(L))) {
14965 if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
14966 } else {
14967 PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
14968 if (unlikely(!retval))
14969 return -1;
14970 Py_DECREF(retval);
14971 }
14972 return 0;
14973 }
14974
14975 /* UnpackUnboundCMethod */
__Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction * target)14976 static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
14977 PyObject *method;
14978 method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
14979 if (unlikely(!method))
14980 return -1;
14981 target->method = method;
14982 #if CYTHON_COMPILING_IN_CPYTHON
14983 #if PY_MAJOR_VERSION >= 3
14984 if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
14985 #endif
14986 {
14987 PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
14988 target->func = descr->d_method->ml_meth;
14989 target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
14990 }
14991 #endif
14992 return 0;
14993 }
14994
14995 /* CallUnboundCMethod0 */
__Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction * cfunc,PyObject * self)14996 static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
14997 PyObject *args, *result = NULL;
14998 if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
14999 #if CYTHON_ASSUME_SAFE_MACROS
15000 args = PyTuple_New(1);
15001 if (unlikely(!args)) goto bad;
15002 Py_INCREF(self);
15003 PyTuple_SET_ITEM(args, 0, self);
15004 #else
15005 args = PyTuple_Pack(1, self);
15006 if (unlikely(!args)) goto bad;
15007 #endif
15008 result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
15009 Py_DECREF(args);
15010 bad:
15011 return result;
15012 }
15013
15014 /* py_dict_items */
__Pyx_PyDict_Items(PyObject * d)15015 static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
15016 if (PY_MAJOR_VERSION >= 3)
15017 return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
15018 else
15019 return PyDict_Items(d);
15020 }
15021
15022 /* PyObject_GenericGetAttrNoDict */
15023 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)15024 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
15025 PyErr_Format(PyExc_AttributeError,
15026 #if PY_MAJOR_VERSION >= 3
15027 "'%.50s' object has no attribute '%U'",
15028 tp->tp_name, attr_name);
15029 #else
15030 "'%.50s' object has no attribute '%.400s'",
15031 tp->tp_name, PyString_AS_STRING(attr_name));
15032 #endif
15033 return NULL;
15034 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)15035 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
15036 PyObject *descr;
15037 PyTypeObject *tp = Py_TYPE(obj);
15038 if (unlikely(!PyString_Check(attr_name))) {
15039 return PyObject_GenericGetAttr(obj, attr_name);
15040 }
15041 assert(!tp->tp_dictoffset);
15042 descr = _PyType_Lookup(tp, attr_name);
15043 if (unlikely(!descr)) {
15044 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
15045 }
15046 Py_INCREF(descr);
15047 #if PY_MAJOR_VERSION < 3
15048 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
15049 #endif
15050 {
15051 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
15052 if (unlikely(f)) {
15053 PyObject *res = f(descr, obj, (PyObject *)tp);
15054 Py_DECREF(descr);
15055 return res;
15056 }
15057 }
15058 return descr;
15059 }
15060 #endif
15061
15062 /* PyObject_GenericGetAttr */
15063 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)15064 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
15065 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
15066 return PyObject_GenericGetAttr(obj, attr_name);
15067 }
15068 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
15069 }
15070 #endif
15071
15072 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)15073 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
15074 #if PY_VERSION_HEX >= 0x02070000
15075 PyObject *ob = PyCapsule_New(vtable, 0, 0);
15076 #else
15077 PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
15078 #endif
15079 if (!ob)
15080 goto bad;
15081 if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
15082 goto bad;
15083 Py_DECREF(ob);
15084 return 0;
15085 bad:
15086 Py_XDECREF(ob);
15087 return -1;
15088 }
15089
15090 /* PyErrExceptionMatches */
15091 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)15092 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
15093 Py_ssize_t i, n;
15094 n = PyTuple_GET_SIZE(tuple);
15095 #if PY_MAJOR_VERSION >= 3
15096 for (i=0; i<n; i++) {
15097 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
15098 }
15099 #endif
15100 for (i=0; i<n; i++) {
15101 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
15102 }
15103 return 0;
15104 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)15105 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
15106 PyObject *exc_type = tstate->curexc_type;
15107 if (exc_type == err) return 1;
15108 if (unlikely(!exc_type)) return 0;
15109 if (unlikely(PyTuple_Check(err)))
15110 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
15111 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
15112 }
15113 #endif
15114
15115 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)15116 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
15117 __Pyx_PyThreadState_declare
15118 __Pyx_PyThreadState_assign
15119 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
15120 __Pyx_PyErr_Clear();
15121 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)15122 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
15123 PyObject *result;
15124 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
15125 PyTypeObject* tp = Py_TYPE(obj);
15126 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
15127 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
15128 }
15129 #endif
15130 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
15131 if (unlikely(!result)) {
15132 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
15133 }
15134 return result;
15135 }
15136
15137 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)15138 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
15139 int ret;
15140 PyObject *name_attr;
15141 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
15142 if (likely(name_attr)) {
15143 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
15144 } else {
15145 ret = -1;
15146 }
15147 if (unlikely(ret < 0)) {
15148 PyErr_Clear();
15149 ret = 0;
15150 }
15151 Py_XDECREF(name_attr);
15152 return ret;
15153 }
__Pyx_setup_reduce(PyObject * type_obj)15154 static int __Pyx_setup_reduce(PyObject* type_obj) {
15155 int ret = 0;
15156 PyObject *object_reduce = NULL;
15157 PyObject *object_reduce_ex = NULL;
15158 PyObject *reduce = NULL;
15159 PyObject *reduce_ex = NULL;
15160 PyObject *reduce_cython = NULL;
15161 PyObject *setstate = NULL;
15162 PyObject *setstate_cython = NULL;
15163 #if CYTHON_USE_PYTYPE_LOOKUP
15164 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
15165 #else
15166 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
15167 #endif
15168 #if CYTHON_USE_PYTYPE_LOOKUP
15169 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
15170 #else
15171 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
15172 #endif
15173 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
15174 if (reduce_ex == object_reduce_ex) {
15175 #if CYTHON_USE_PYTYPE_LOOKUP
15176 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
15177 #else
15178 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
15179 #endif
15180 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
15181 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
15182 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
15183 if (likely(reduce_cython)) {
15184 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
15185 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
15186 } else if (reduce == object_reduce || PyErr_Occurred()) {
15187 goto __PYX_BAD;
15188 }
15189 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
15190 if (!setstate) PyErr_Clear();
15191 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
15192 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
15193 if (likely(setstate_cython)) {
15194 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
15195 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
15196 } else if (!setstate || PyErr_Occurred()) {
15197 goto __PYX_BAD;
15198 }
15199 }
15200 PyType_Modified((PyTypeObject*)type_obj);
15201 }
15202 }
15203 goto __PYX_GOOD;
15204 __PYX_BAD:
15205 if (!PyErr_Occurred())
15206 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
15207 ret = -1;
15208 __PYX_GOOD:
15209 #if !CYTHON_USE_PYTYPE_LOOKUP
15210 Py_XDECREF(object_reduce);
15211 Py_XDECREF(object_reduce_ex);
15212 #endif
15213 Py_XDECREF(reduce);
15214 Py_XDECREF(reduce_ex);
15215 Py_XDECREF(reduce_cython);
15216 Py_XDECREF(setstate);
15217 Py_XDECREF(setstate_cython);
15218 return ret;
15219 }
15220
15221 /* TypeImport */
15222 #ifndef __PYX_HAVE_RT_ImportType
15223 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)15224 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
15225 size_t size, enum __Pyx_ImportType_CheckSize check_size)
15226 {
15227 PyObject *result = 0;
15228 char warning[200];
15229 Py_ssize_t basicsize;
15230 #ifdef Py_LIMITED_API
15231 PyObject *py_basicsize;
15232 #endif
15233 result = PyObject_GetAttrString(module, class_name);
15234 if (!result)
15235 goto bad;
15236 if (!PyType_Check(result)) {
15237 PyErr_Format(PyExc_TypeError,
15238 "%.200s.%.200s is not a type object",
15239 module_name, class_name);
15240 goto bad;
15241 }
15242 #ifndef Py_LIMITED_API
15243 basicsize = ((PyTypeObject *)result)->tp_basicsize;
15244 #else
15245 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
15246 if (!py_basicsize)
15247 goto bad;
15248 basicsize = PyLong_AsSsize_t(py_basicsize);
15249 Py_DECREF(py_basicsize);
15250 py_basicsize = 0;
15251 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
15252 goto bad;
15253 #endif
15254 if ((size_t)basicsize < size) {
15255 PyErr_Format(PyExc_ValueError,
15256 "%.200s.%.200s size changed, may indicate binary incompatibility. "
15257 "Expected %zd from C header, got %zd from PyObject",
15258 module_name, class_name, size, basicsize);
15259 goto bad;
15260 }
15261 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
15262 PyErr_Format(PyExc_ValueError,
15263 "%.200s.%.200s size changed, may indicate binary incompatibility. "
15264 "Expected %zd from C header, got %zd from PyObject",
15265 module_name, class_name, size, basicsize);
15266 goto bad;
15267 }
15268 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
15269 PyOS_snprintf(warning, sizeof(warning),
15270 "%s.%s size changed, may indicate binary incompatibility. "
15271 "Expected %zd from C header, got %zd from PyObject",
15272 module_name, class_name, size, basicsize);
15273 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
15274 }
15275 return (PyTypeObject *)result;
15276 bad:
15277 Py_XDECREF(result);
15278 return NULL;
15279 }
15280 #endif
15281
15282 /* GetVTable */
__Pyx_GetVtable(PyObject * dict)15283 static void* __Pyx_GetVtable(PyObject *dict) {
15284 void* ptr;
15285 PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
15286 if (!ob)
15287 goto bad;
15288 #if PY_VERSION_HEX >= 0x02070000
15289 ptr = PyCapsule_GetPointer(ob, 0);
15290 #else
15291 ptr = PyCObject_AsVoidPtr(ob);
15292 #endif
15293 if (!ptr && !PyErr_Occurred())
15294 PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
15295 Py_DECREF(ob);
15296 return ptr;
15297 bad:
15298 Py_XDECREF(ob);
15299 return NULL;
15300 }
15301
15302 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)15303 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
15304 PyObject *empty_list = 0;
15305 PyObject *module = 0;
15306 PyObject *global_dict = 0;
15307 PyObject *empty_dict = 0;
15308 PyObject *list;
15309 #if PY_MAJOR_VERSION < 3
15310 PyObject *py_import;
15311 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
15312 if (!py_import)
15313 goto bad;
15314 #endif
15315 if (from_list)
15316 list = from_list;
15317 else {
15318 empty_list = PyList_New(0);
15319 if (!empty_list)
15320 goto bad;
15321 list = empty_list;
15322 }
15323 global_dict = PyModule_GetDict(__pyx_m);
15324 if (!global_dict)
15325 goto bad;
15326 empty_dict = PyDict_New();
15327 if (!empty_dict)
15328 goto bad;
15329 {
15330 #if PY_MAJOR_VERSION >= 3
15331 if (level == -1) {
15332 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
15333 module = PyImport_ImportModuleLevelObject(
15334 name, global_dict, empty_dict, list, 1);
15335 if (!module) {
15336 if (!PyErr_ExceptionMatches(PyExc_ImportError))
15337 goto bad;
15338 PyErr_Clear();
15339 }
15340 }
15341 level = 0;
15342 }
15343 #endif
15344 if (!module) {
15345 #if PY_MAJOR_VERSION < 3
15346 PyObject *py_level = PyInt_FromLong(level);
15347 if (!py_level)
15348 goto bad;
15349 module = PyObject_CallFunctionObjArgs(py_import,
15350 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
15351 Py_DECREF(py_level);
15352 #else
15353 module = PyImport_ImportModuleLevelObject(
15354 name, global_dict, empty_dict, list, level);
15355 #endif
15356 }
15357 }
15358 bad:
15359 #if PY_MAJOR_VERSION < 3
15360 Py_XDECREF(py_import);
15361 #endif
15362 Py_XDECREF(empty_list);
15363 Py_XDECREF(empty_dict);
15364 return module;
15365 }
15366
15367 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)15368 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
15369 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
15370 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
15371 PyErr_Format(PyExc_ImportError,
15372 #if PY_MAJOR_VERSION < 3
15373 "cannot import name %.230s", PyString_AS_STRING(name));
15374 #else
15375 "cannot import name %S", name);
15376 #endif
15377 }
15378 return value;
15379 }
15380
15381 /* CLineInTraceback */
15382 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)15383 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
15384 PyObject *use_cline;
15385 PyObject *ptype, *pvalue, *ptraceback;
15386 #if CYTHON_COMPILING_IN_CPYTHON
15387 PyObject **cython_runtime_dict;
15388 #endif
15389 if (unlikely(!__pyx_cython_runtime)) {
15390 return c_line;
15391 }
15392 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
15393 #if CYTHON_COMPILING_IN_CPYTHON
15394 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
15395 if (likely(cython_runtime_dict)) {
15396 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
15397 use_cline, *cython_runtime_dict,
15398 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
15399 } else
15400 #endif
15401 {
15402 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
15403 if (use_cline_obj) {
15404 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
15405 Py_DECREF(use_cline_obj);
15406 } else {
15407 PyErr_Clear();
15408 use_cline = NULL;
15409 }
15410 }
15411 if (!use_cline) {
15412 c_line = 0;
15413 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
15414 }
15415 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
15416 c_line = 0;
15417 }
15418 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
15419 return c_line;
15420 }
15421 #endif
15422
15423 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)15424 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
15425 int start = 0, mid = 0, end = count - 1;
15426 if (end >= 0 && code_line > entries[end].code_line) {
15427 return count;
15428 }
15429 while (start < end) {
15430 mid = start + (end - start) / 2;
15431 if (code_line < entries[mid].code_line) {
15432 end = mid;
15433 } else if (code_line > entries[mid].code_line) {
15434 start = mid + 1;
15435 } else {
15436 return mid;
15437 }
15438 }
15439 if (code_line <= entries[mid].code_line) {
15440 return mid;
15441 } else {
15442 return mid + 1;
15443 }
15444 }
__pyx_find_code_object(int code_line)15445 static PyCodeObject *__pyx_find_code_object(int code_line) {
15446 PyCodeObject* code_object;
15447 int pos;
15448 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
15449 return NULL;
15450 }
15451 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
15452 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
15453 return NULL;
15454 }
15455 code_object = __pyx_code_cache.entries[pos].code_object;
15456 Py_INCREF(code_object);
15457 return code_object;
15458 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)15459 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
15460 int pos, i;
15461 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
15462 if (unlikely(!code_line)) {
15463 return;
15464 }
15465 if (unlikely(!entries)) {
15466 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
15467 if (likely(entries)) {
15468 __pyx_code_cache.entries = entries;
15469 __pyx_code_cache.max_count = 64;
15470 __pyx_code_cache.count = 1;
15471 entries[0].code_line = code_line;
15472 entries[0].code_object = code_object;
15473 Py_INCREF(code_object);
15474 }
15475 return;
15476 }
15477 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
15478 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
15479 PyCodeObject* tmp = entries[pos].code_object;
15480 entries[pos].code_object = code_object;
15481 Py_DECREF(tmp);
15482 return;
15483 }
15484 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
15485 int new_max = __pyx_code_cache.max_count + 64;
15486 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
15487 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
15488 if (unlikely(!entries)) {
15489 return;
15490 }
15491 __pyx_code_cache.entries = entries;
15492 __pyx_code_cache.max_count = new_max;
15493 }
15494 for (i=__pyx_code_cache.count; i>pos; i--) {
15495 entries[i] = entries[i-1];
15496 }
15497 entries[pos].code_line = code_line;
15498 entries[pos].code_object = code_object;
15499 __pyx_code_cache.count++;
15500 Py_INCREF(code_object);
15501 }
15502
15503 /* AddTraceback */
15504 #include "compile.h"
15505 #include "frameobject.h"
15506 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)15507 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
15508 const char *funcname, int c_line,
15509 int py_line, const char *filename) {
15510 PyCodeObject *py_code = 0;
15511 PyObject *py_srcfile = 0;
15512 PyObject *py_funcname = 0;
15513 #if PY_MAJOR_VERSION < 3
15514 py_srcfile = PyString_FromString(filename);
15515 #else
15516 py_srcfile = PyUnicode_FromString(filename);
15517 #endif
15518 if (!py_srcfile) goto bad;
15519 if (c_line) {
15520 #if PY_MAJOR_VERSION < 3
15521 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
15522 #else
15523 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
15524 #endif
15525 }
15526 else {
15527 #if PY_MAJOR_VERSION < 3
15528 py_funcname = PyString_FromString(funcname);
15529 #else
15530 py_funcname = PyUnicode_FromString(funcname);
15531 #endif
15532 }
15533 if (!py_funcname) goto bad;
15534 py_code = __Pyx_PyCode_New(
15535 0,
15536 0,
15537 0,
15538 0,
15539 0,
15540 __pyx_empty_bytes, /*PyObject *code,*/
15541 __pyx_empty_tuple, /*PyObject *consts,*/
15542 __pyx_empty_tuple, /*PyObject *names,*/
15543 __pyx_empty_tuple, /*PyObject *varnames,*/
15544 __pyx_empty_tuple, /*PyObject *freevars,*/
15545 __pyx_empty_tuple, /*PyObject *cellvars,*/
15546 py_srcfile, /*PyObject *filename,*/
15547 py_funcname, /*PyObject *name,*/
15548 py_line,
15549 __pyx_empty_bytes /*PyObject *lnotab*/
15550 );
15551 Py_DECREF(py_srcfile);
15552 Py_DECREF(py_funcname);
15553 return py_code;
15554 bad:
15555 Py_XDECREF(py_srcfile);
15556 Py_XDECREF(py_funcname);
15557 return NULL;
15558 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)15559 static void __Pyx_AddTraceback(const char *funcname, int c_line,
15560 int py_line, const char *filename) {
15561 PyCodeObject *py_code = 0;
15562 PyFrameObject *py_frame = 0;
15563 PyThreadState *tstate = __Pyx_PyThreadState_Current;
15564 if (c_line) {
15565 c_line = __Pyx_CLineForTraceback(tstate, c_line);
15566 }
15567 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
15568 if (!py_code) {
15569 py_code = __Pyx_CreateCodeObjectForTraceback(
15570 funcname, c_line, py_line, filename);
15571 if (!py_code) goto bad;
15572 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
15573 }
15574 py_frame = PyFrame_New(
15575 tstate, /*PyThreadState *tstate,*/
15576 py_code, /*PyCodeObject *code,*/
15577 __pyx_d, /*PyObject *globals,*/
15578 0 /*PyObject *locals*/
15579 );
15580 if (!py_frame) goto bad;
15581 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
15582 PyTraceBack_Here(py_frame);
15583 bad:
15584 Py_XDECREF(py_code);
15585 Py_XDECREF(py_frame);
15586 }
15587
15588 /* CIntFromPyVerify */
15589 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
15590 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
15591 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
15592 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
15593 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
15594 {\
15595 func_type value = func_value;\
15596 if (sizeof(target_type) < sizeof(func_type)) {\
15597 if (unlikely(value != (func_type) (target_type) value)) {\
15598 func_type zero = 0;\
15599 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
15600 return (target_type) -1;\
15601 if (is_unsigned && unlikely(value < zero))\
15602 goto raise_neg_overflow;\
15603 else\
15604 goto raise_overflow;\
15605 }\
15606 }\
15607 return (target_type) value;\
15608 }
15609
15610 /* CIntToPy */
__Pyx_PyInt_From_int(int value)15611 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
15612 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
15613 const int is_unsigned = neg_one > const_zero;
15614 if (is_unsigned) {
15615 if (sizeof(int) < sizeof(long)) {
15616 return PyInt_FromLong((long) value);
15617 } else if (sizeof(int) <= sizeof(unsigned long)) {
15618 return PyLong_FromUnsignedLong((unsigned long) value);
15619 #ifdef HAVE_LONG_LONG
15620 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
15621 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
15622 #endif
15623 }
15624 } else {
15625 if (sizeof(int) <= sizeof(long)) {
15626 return PyInt_FromLong((long) value);
15627 #ifdef HAVE_LONG_LONG
15628 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
15629 return PyLong_FromLongLong((PY_LONG_LONG) value);
15630 #endif
15631 }
15632 }
15633 {
15634 int one = 1; int little = (int)*(unsigned char *)&one;
15635 unsigned char *bytes = (unsigned char *)&value;
15636 return _PyLong_FromByteArray(bytes, sizeof(int),
15637 little, !is_unsigned);
15638 }
15639 }
15640
15641 /* CIntToPy */
__Pyx_PyInt_From_uint32_t(uint32_t value)15642 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
15643 const uint32_t neg_one = (uint32_t) ((uint32_t) 0 - (uint32_t) 1), const_zero = (uint32_t) 0;
15644 const int is_unsigned = neg_one > const_zero;
15645 if (is_unsigned) {
15646 if (sizeof(uint32_t) < sizeof(long)) {
15647 return PyInt_FromLong((long) value);
15648 } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
15649 return PyLong_FromUnsignedLong((unsigned long) value);
15650 #ifdef HAVE_LONG_LONG
15651 } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
15652 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
15653 #endif
15654 }
15655 } else {
15656 if (sizeof(uint32_t) <= sizeof(long)) {
15657 return PyInt_FromLong((long) value);
15658 #ifdef HAVE_LONG_LONG
15659 } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
15660 return PyLong_FromLongLong((PY_LONG_LONG) value);
15661 #endif
15662 }
15663 }
15664 {
15665 int one = 1; int little = (int)*(unsigned char *)&one;
15666 unsigned char *bytes = (unsigned char *)&value;
15667 return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
15668 little, !is_unsigned);
15669 }
15670 }
15671
15672 /* CIntToPy */
__Pyx_PyInt_From_uint8_t(uint8_t value)15673 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
15674 const uint8_t neg_one = (uint8_t) ((uint8_t) 0 - (uint8_t) 1), const_zero = (uint8_t) 0;
15675 const int is_unsigned = neg_one > const_zero;
15676 if (is_unsigned) {
15677 if (sizeof(uint8_t) < sizeof(long)) {
15678 return PyInt_FromLong((long) value);
15679 } else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
15680 return PyLong_FromUnsignedLong((unsigned long) value);
15681 #ifdef HAVE_LONG_LONG
15682 } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
15683 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
15684 #endif
15685 }
15686 } else {
15687 if (sizeof(uint8_t) <= sizeof(long)) {
15688 return PyInt_FromLong((long) value);
15689 #ifdef HAVE_LONG_LONG
15690 } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
15691 return PyLong_FromLongLong((PY_LONG_LONG) value);
15692 #endif
15693 }
15694 }
15695 {
15696 int one = 1; int little = (int)*(unsigned char *)&one;
15697 unsigned char *bytes = (unsigned char *)&value;
15698 return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
15699 little, !is_unsigned);
15700 }
15701 }
15702
15703 /* CIntToPy */
__Pyx_PyInt_From_long(long value)15704 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
15705 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
15706 const int is_unsigned = neg_one > const_zero;
15707 if (is_unsigned) {
15708 if (sizeof(long) < sizeof(long)) {
15709 return PyInt_FromLong((long) value);
15710 } else if (sizeof(long) <= sizeof(unsigned long)) {
15711 return PyLong_FromUnsignedLong((unsigned long) value);
15712 #ifdef HAVE_LONG_LONG
15713 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
15714 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
15715 #endif
15716 }
15717 } else {
15718 if (sizeof(long) <= sizeof(long)) {
15719 return PyInt_FromLong((long) value);
15720 #ifdef HAVE_LONG_LONG
15721 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
15722 return PyLong_FromLongLong((PY_LONG_LONG) value);
15723 #endif
15724 }
15725 }
15726 {
15727 int one = 1; int little = (int)*(unsigned char *)&one;
15728 unsigned char *bytes = (unsigned char *)&value;
15729 return _PyLong_FromByteArray(bytes, sizeof(long),
15730 little, !is_unsigned);
15731 }
15732 }
15733
15734 /* CIntToPy */
__Pyx_PyInt_From_uint64_t(uint64_t value)15735 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
15736 const uint64_t neg_one = (uint64_t) ((uint64_t) 0 - (uint64_t) 1), const_zero = (uint64_t) 0;
15737 const int is_unsigned = neg_one > const_zero;
15738 if (is_unsigned) {
15739 if (sizeof(uint64_t) < sizeof(long)) {
15740 return PyInt_FromLong((long) value);
15741 } else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
15742 return PyLong_FromUnsignedLong((unsigned long) value);
15743 #ifdef HAVE_LONG_LONG
15744 } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
15745 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
15746 #endif
15747 }
15748 } else {
15749 if (sizeof(uint64_t) <= sizeof(long)) {
15750 return PyInt_FromLong((long) value);
15751 #ifdef HAVE_LONG_LONG
15752 } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
15753 return PyLong_FromLongLong((PY_LONG_LONG) value);
15754 #endif
15755 }
15756 }
15757 {
15758 int one = 1; int little = (int)*(unsigned char *)&one;
15759 unsigned char *bytes = (unsigned char *)&value;
15760 return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
15761 little, !is_unsigned);
15762 }
15763 }
15764
15765 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)15766 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
15767 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
15768 const int is_unsigned = neg_one > const_zero;
15769 #if PY_MAJOR_VERSION < 3
15770 if (likely(PyInt_Check(x))) {
15771 if (sizeof(int) < sizeof(long)) {
15772 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
15773 } else {
15774 long val = PyInt_AS_LONG(x);
15775 if (is_unsigned && unlikely(val < 0)) {
15776 goto raise_neg_overflow;
15777 }
15778 return (int) val;
15779 }
15780 } else
15781 #endif
15782 if (likely(PyLong_Check(x))) {
15783 if (is_unsigned) {
15784 #if CYTHON_USE_PYLONG_INTERNALS
15785 const digit* digits = ((PyLongObject*)x)->ob_digit;
15786 switch (Py_SIZE(x)) {
15787 case 0: return (int) 0;
15788 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
15789 case 2:
15790 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
15791 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
15792 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15793 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
15794 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
15795 }
15796 }
15797 break;
15798 case 3:
15799 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
15800 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
15801 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15802 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
15803 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
15804 }
15805 }
15806 break;
15807 case 4:
15808 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
15809 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
15810 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15811 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
15812 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
15813 }
15814 }
15815 break;
15816 }
15817 #endif
15818 #if CYTHON_COMPILING_IN_CPYTHON
15819 if (unlikely(Py_SIZE(x) < 0)) {
15820 goto raise_neg_overflow;
15821 }
15822 #else
15823 {
15824 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
15825 if (unlikely(result < 0))
15826 return (int) -1;
15827 if (unlikely(result == 1))
15828 goto raise_neg_overflow;
15829 }
15830 #endif
15831 if (sizeof(int) <= sizeof(unsigned long)) {
15832 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
15833 #ifdef HAVE_LONG_LONG
15834 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
15835 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
15836 #endif
15837 }
15838 } else {
15839 #if CYTHON_USE_PYLONG_INTERNALS
15840 const digit* digits = ((PyLongObject*)x)->ob_digit;
15841 switch (Py_SIZE(x)) {
15842 case 0: return (int) 0;
15843 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
15844 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
15845 case -2:
15846 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
15847 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
15848 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15849 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
15850 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15851 }
15852 }
15853 break;
15854 case 2:
15855 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
15856 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
15857 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15858 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
15859 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15860 }
15861 }
15862 break;
15863 case -3:
15864 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
15865 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
15866 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15867 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
15868 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15869 }
15870 }
15871 break;
15872 case 3:
15873 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
15874 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
15875 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15876 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
15877 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15878 }
15879 }
15880 break;
15881 case -4:
15882 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
15883 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
15884 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15885 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
15886 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15887 }
15888 }
15889 break;
15890 case 4:
15891 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
15892 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
15893 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15894 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
15895 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
15896 }
15897 }
15898 break;
15899 }
15900 #endif
15901 if (sizeof(int) <= sizeof(long)) {
15902 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
15903 #ifdef HAVE_LONG_LONG
15904 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
15905 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
15906 #endif
15907 }
15908 }
15909 {
15910 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
15911 PyErr_SetString(PyExc_RuntimeError,
15912 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
15913 #else
15914 int val;
15915 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
15916 #if PY_MAJOR_VERSION < 3
15917 if (likely(v) && !PyLong_Check(v)) {
15918 PyObject *tmp = v;
15919 v = PyNumber_Long(tmp);
15920 Py_DECREF(tmp);
15921 }
15922 #endif
15923 if (likely(v)) {
15924 int one = 1; int is_little = (int)*(unsigned char *)&one;
15925 unsigned char *bytes = (unsigned char *)&val;
15926 int ret = _PyLong_AsByteArray((PyLongObject *)v,
15927 bytes, sizeof(val),
15928 is_little, !is_unsigned);
15929 Py_DECREF(v);
15930 if (likely(!ret))
15931 return val;
15932 }
15933 #endif
15934 return (int) -1;
15935 }
15936 } else {
15937 int val;
15938 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
15939 if (!tmp) return (int) -1;
15940 val = __Pyx_PyInt_As_int(tmp);
15941 Py_DECREF(tmp);
15942 return val;
15943 }
15944 raise_overflow:
15945 PyErr_SetString(PyExc_OverflowError,
15946 "value too large to convert to int");
15947 return (int) -1;
15948 raise_neg_overflow:
15949 PyErr_SetString(PyExc_OverflowError,
15950 "can't convert negative value to int");
15951 return (int) -1;
15952 }
15953
15954 /* CIntFromPy */
__Pyx_PyInt_As_uint32_t(PyObject * x)15955 static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
15956 const uint32_t neg_one = (uint32_t) ((uint32_t) 0 - (uint32_t) 1), const_zero = (uint32_t) 0;
15957 const int is_unsigned = neg_one > const_zero;
15958 #if PY_MAJOR_VERSION < 3
15959 if (likely(PyInt_Check(x))) {
15960 if (sizeof(uint32_t) < sizeof(long)) {
15961 __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
15962 } else {
15963 long val = PyInt_AS_LONG(x);
15964 if (is_unsigned && unlikely(val < 0)) {
15965 goto raise_neg_overflow;
15966 }
15967 return (uint32_t) val;
15968 }
15969 } else
15970 #endif
15971 if (likely(PyLong_Check(x))) {
15972 if (is_unsigned) {
15973 #if CYTHON_USE_PYLONG_INTERNALS
15974 const digit* digits = ((PyLongObject*)x)->ob_digit;
15975 switch (Py_SIZE(x)) {
15976 case 0: return (uint32_t) 0;
15977 case 1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
15978 case 2:
15979 if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
15980 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
15981 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15982 } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
15983 return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
15984 }
15985 }
15986 break;
15987 case 3:
15988 if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
15989 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
15990 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
15991 } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
15992 return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
15993 }
15994 }
15995 break;
15996 case 4:
15997 if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
15998 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
15999 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16000 } else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
16001 return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
16002 }
16003 }
16004 break;
16005 }
16006 #endif
16007 #if CYTHON_COMPILING_IN_CPYTHON
16008 if (unlikely(Py_SIZE(x) < 0)) {
16009 goto raise_neg_overflow;
16010 }
16011 #else
16012 {
16013 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
16014 if (unlikely(result < 0))
16015 return (uint32_t) -1;
16016 if (unlikely(result == 1))
16017 goto raise_neg_overflow;
16018 }
16019 #endif
16020 if (sizeof(uint32_t) <= sizeof(unsigned long)) {
16021 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
16022 #ifdef HAVE_LONG_LONG
16023 } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
16024 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
16025 #endif
16026 }
16027 } else {
16028 #if CYTHON_USE_PYLONG_INTERNALS
16029 const digit* digits = ((PyLongObject*)x)->ob_digit;
16030 switch (Py_SIZE(x)) {
16031 case 0: return (uint32_t) 0;
16032 case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
16033 case 1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, +digits[0])
16034 case -2:
16035 if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
16036 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16037 __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16038 } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
16039 return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16040 }
16041 }
16042 break;
16043 case 2:
16044 if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
16045 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16046 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16047 } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
16048 return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16049 }
16050 }
16051 break;
16052 case -3:
16053 if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
16054 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16055 __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16056 } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
16057 return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16058 }
16059 }
16060 break;
16061 case 3:
16062 if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
16063 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16064 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16065 } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
16066 return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16067 }
16068 }
16069 break;
16070 case -4:
16071 if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
16072 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16073 __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16074 } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
16075 return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16076 }
16077 }
16078 break;
16079 case 4:
16080 if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
16081 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16082 __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16083 } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
16084 return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
16085 }
16086 }
16087 break;
16088 }
16089 #endif
16090 if (sizeof(uint32_t) <= sizeof(long)) {
16091 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
16092 #ifdef HAVE_LONG_LONG
16093 } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
16094 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
16095 #endif
16096 }
16097 }
16098 {
16099 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
16100 PyErr_SetString(PyExc_RuntimeError,
16101 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
16102 #else
16103 uint32_t val;
16104 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
16105 #if PY_MAJOR_VERSION < 3
16106 if (likely(v) && !PyLong_Check(v)) {
16107 PyObject *tmp = v;
16108 v = PyNumber_Long(tmp);
16109 Py_DECREF(tmp);
16110 }
16111 #endif
16112 if (likely(v)) {
16113 int one = 1; int is_little = (int)*(unsigned char *)&one;
16114 unsigned char *bytes = (unsigned char *)&val;
16115 int ret = _PyLong_AsByteArray((PyLongObject *)v,
16116 bytes, sizeof(val),
16117 is_little, !is_unsigned);
16118 Py_DECREF(v);
16119 if (likely(!ret))
16120 return val;
16121 }
16122 #endif
16123 return (uint32_t) -1;
16124 }
16125 } else {
16126 uint32_t val;
16127 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
16128 if (!tmp) return (uint32_t) -1;
16129 val = __Pyx_PyInt_As_uint32_t(tmp);
16130 Py_DECREF(tmp);
16131 return val;
16132 }
16133 raise_overflow:
16134 PyErr_SetString(PyExc_OverflowError,
16135 "value too large to convert to uint32_t");
16136 return (uint32_t) -1;
16137 raise_neg_overflow:
16138 PyErr_SetString(PyExc_OverflowError,
16139 "can't convert negative value to uint32_t");
16140 return (uint32_t) -1;
16141 }
16142
16143 /* CIntFromPy */
__Pyx_PyInt_As_uint8_t(PyObject * x)16144 static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *x) {
16145 const uint8_t neg_one = (uint8_t) ((uint8_t) 0 - (uint8_t) 1), const_zero = (uint8_t) 0;
16146 const int is_unsigned = neg_one > const_zero;
16147 #if PY_MAJOR_VERSION < 3
16148 if (likely(PyInt_Check(x))) {
16149 if (sizeof(uint8_t) < sizeof(long)) {
16150 __PYX_VERIFY_RETURN_INT(uint8_t, long, PyInt_AS_LONG(x))
16151 } else {
16152 long val = PyInt_AS_LONG(x);
16153 if (is_unsigned && unlikely(val < 0)) {
16154 goto raise_neg_overflow;
16155 }
16156 return (uint8_t) val;
16157 }
16158 } else
16159 #endif
16160 if (likely(PyLong_Check(x))) {
16161 if (is_unsigned) {
16162 #if CYTHON_USE_PYLONG_INTERNALS
16163 const digit* digits = ((PyLongObject*)x)->ob_digit;
16164 switch (Py_SIZE(x)) {
16165 case 0: return (uint8_t) 0;
16166 case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, digits[0])
16167 case 2:
16168 if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
16169 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16170 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16171 } else if (8 * sizeof(uint8_t) >= 2 * PyLong_SHIFT) {
16172 return (uint8_t) (((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
16173 }
16174 }
16175 break;
16176 case 3:
16177 if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
16178 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16179 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16180 } else if (8 * sizeof(uint8_t) >= 3 * PyLong_SHIFT) {
16181 return (uint8_t) (((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
16182 }
16183 }
16184 break;
16185 case 4:
16186 if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
16187 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16188 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16189 } else if (8 * sizeof(uint8_t) >= 4 * PyLong_SHIFT) {
16190 return (uint8_t) (((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
16191 }
16192 }
16193 break;
16194 }
16195 #endif
16196 #if CYTHON_COMPILING_IN_CPYTHON
16197 if (unlikely(Py_SIZE(x) < 0)) {
16198 goto raise_neg_overflow;
16199 }
16200 #else
16201 {
16202 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
16203 if (unlikely(result < 0))
16204 return (uint8_t) -1;
16205 if (unlikely(result == 1))
16206 goto raise_neg_overflow;
16207 }
16208 #endif
16209 if (sizeof(uint8_t) <= sizeof(unsigned long)) {
16210 __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned long, PyLong_AsUnsignedLong(x))
16211 #ifdef HAVE_LONG_LONG
16212 } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
16213 __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
16214 #endif
16215 }
16216 } else {
16217 #if CYTHON_USE_PYLONG_INTERNALS
16218 const digit* digits = ((PyLongObject*)x)->ob_digit;
16219 switch (Py_SIZE(x)) {
16220 case 0: return (uint8_t) 0;
16221 case -1: __PYX_VERIFY_RETURN_INT(uint8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
16222 case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, +digits[0])
16223 case -2:
16224 if (8 * sizeof(uint8_t) - 1 > 1 * PyLong_SHIFT) {
16225 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16226 __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16227 } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
16228 return (uint8_t) (((uint8_t)-1)*(((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16229 }
16230 }
16231 break;
16232 case 2:
16233 if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
16234 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16235 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16236 } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
16237 return (uint8_t) ((((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16238 }
16239 }
16240 break;
16241 case -3:
16242 if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
16243 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16244 __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16245 } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
16246 return (uint8_t) (((uint8_t)-1)*(((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16247 }
16248 }
16249 break;
16250 case 3:
16251 if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
16252 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16253 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16254 } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
16255 return (uint8_t) ((((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16256 }
16257 }
16258 break;
16259 case -4:
16260 if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
16261 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16262 __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16263 } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
16264 return (uint8_t) (((uint8_t)-1)*(((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16265 }
16266 }
16267 break;
16268 case 4:
16269 if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
16270 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16271 __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16272 } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
16273 return (uint8_t) ((((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
16274 }
16275 }
16276 break;
16277 }
16278 #endif
16279 if (sizeof(uint8_t) <= sizeof(long)) {
16280 __PYX_VERIFY_RETURN_INT_EXC(uint8_t, long, PyLong_AsLong(x))
16281 #ifdef HAVE_LONG_LONG
16282 } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
16283 __PYX_VERIFY_RETURN_INT_EXC(uint8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
16284 #endif
16285 }
16286 }
16287 {
16288 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
16289 PyErr_SetString(PyExc_RuntimeError,
16290 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
16291 #else
16292 uint8_t val;
16293 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
16294 #if PY_MAJOR_VERSION < 3
16295 if (likely(v) && !PyLong_Check(v)) {
16296 PyObject *tmp = v;
16297 v = PyNumber_Long(tmp);
16298 Py_DECREF(tmp);
16299 }
16300 #endif
16301 if (likely(v)) {
16302 int one = 1; int is_little = (int)*(unsigned char *)&one;
16303 unsigned char *bytes = (unsigned char *)&val;
16304 int ret = _PyLong_AsByteArray((PyLongObject *)v,
16305 bytes, sizeof(val),
16306 is_little, !is_unsigned);
16307 Py_DECREF(v);
16308 if (likely(!ret))
16309 return val;
16310 }
16311 #endif
16312 return (uint8_t) -1;
16313 }
16314 } else {
16315 uint8_t val;
16316 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
16317 if (!tmp) return (uint8_t) -1;
16318 val = __Pyx_PyInt_As_uint8_t(tmp);
16319 Py_DECREF(tmp);
16320 return val;
16321 }
16322 raise_overflow:
16323 PyErr_SetString(PyExc_OverflowError,
16324 "value too large to convert to uint8_t");
16325 return (uint8_t) -1;
16326 raise_neg_overflow:
16327 PyErr_SetString(PyExc_OverflowError,
16328 "can't convert negative value to uint8_t");
16329 return (uint8_t) -1;
16330 }
16331
16332 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)16333 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
16334 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
16335 const int is_unsigned = neg_one > const_zero;
16336 #if PY_MAJOR_VERSION < 3
16337 if (likely(PyInt_Check(x))) {
16338 if (sizeof(long) < sizeof(long)) {
16339 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
16340 } else {
16341 long val = PyInt_AS_LONG(x);
16342 if (is_unsigned && unlikely(val < 0)) {
16343 goto raise_neg_overflow;
16344 }
16345 return (long) val;
16346 }
16347 } else
16348 #endif
16349 if (likely(PyLong_Check(x))) {
16350 if (is_unsigned) {
16351 #if CYTHON_USE_PYLONG_INTERNALS
16352 const digit* digits = ((PyLongObject*)x)->ob_digit;
16353 switch (Py_SIZE(x)) {
16354 case 0: return (long) 0;
16355 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
16356 case 2:
16357 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
16358 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16359 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16360 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
16361 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
16362 }
16363 }
16364 break;
16365 case 3:
16366 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
16367 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16368 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16369 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
16370 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
16371 }
16372 }
16373 break;
16374 case 4:
16375 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
16376 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16377 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16378 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
16379 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
16380 }
16381 }
16382 break;
16383 }
16384 #endif
16385 #if CYTHON_COMPILING_IN_CPYTHON
16386 if (unlikely(Py_SIZE(x) < 0)) {
16387 goto raise_neg_overflow;
16388 }
16389 #else
16390 {
16391 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
16392 if (unlikely(result < 0))
16393 return (long) -1;
16394 if (unlikely(result == 1))
16395 goto raise_neg_overflow;
16396 }
16397 #endif
16398 if (sizeof(long) <= sizeof(unsigned long)) {
16399 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
16400 #ifdef HAVE_LONG_LONG
16401 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
16402 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
16403 #endif
16404 }
16405 } else {
16406 #if CYTHON_USE_PYLONG_INTERNALS
16407 const digit* digits = ((PyLongObject*)x)->ob_digit;
16408 switch (Py_SIZE(x)) {
16409 case 0: return (long) 0;
16410 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
16411 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
16412 case -2:
16413 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
16414 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16415 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16416 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
16417 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16418 }
16419 }
16420 break;
16421 case 2:
16422 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
16423 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
16424 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16425 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
16426 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16427 }
16428 }
16429 break;
16430 case -3:
16431 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
16432 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16433 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16434 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
16435 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16436 }
16437 }
16438 break;
16439 case 3:
16440 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
16441 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
16442 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16443 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
16444 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16445 }
16446 }
16447 break;
16448 case -4:
16449 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
16450 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16451 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16452 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
16453 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16454 }
16455 }
16456 break;
16457 case 4:
16458 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
16459 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
16460 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16461 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
16462 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
16463 }
16464 }
16465 break;
16466 }
16467 #endif
16468 if (sizeof(long) <= sizeof(long)) {
16469 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
16470 #ifdef HAVE_LONG_LONG
16471 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
16472 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
16473 #endif
16474 }
16475 }
16476 {
16477 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
16478 PyErr_SetString(PyExc_RuntimeError,
16479 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
16480 #else
16481 long val;
16482 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
16483 #if PY_MAJOR_VERSION < 3
16484 if (likely(v) && !PyLong_Check(v)) {
16485 PyObject *tmp = v;
16486 v = PyNumber_Long(tmp);
16487 Py_DECREF(tmp);
16488 }
16489 #endif
16490 if (likely(v)) {
16491 int one = 1; int is_little = (int)*(unsigned char *)&one;
16492 unsigned char *bytes = (unsigned char *)&val;
16493 int ret = _PyLong_AsByteArray((PyLongObject *)v,
16494 bytes, sizeof(val),
16495 is_little, !is_unsigned);
16496 Py_DECREF(v);
16497 if (likely(!ret))
16498 return val;
16499 }
16500 #endif
16501 return (long) -1;
16502 }
16503 } else {
16504 long val;
16505 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
16506 if (!tmp) return (long) -1;
16507 val = __Pyx_PyInt_As_long(tmp);
16508 Py_DECREF(tmp);
16509 return val;
16510 }
16511 raise_overflow:
16512 PyErr_SetString(PyExc_OverflowError,
16513 "value too large to convert to long");
16514 return (long) -1;
16515 raise_neg_overflow:
16516 PyErr_SetString(PyExc_OverflowError,
16517 "can't convert negative value to long");
16518 return (long) -1;
16519 }
16520
16521 /* FastTypeChecks */
16522 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)16523 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
16524 while (a) {
16525 a = a->tp_base;
16526 if (a == b)
16527 return 1;
16528 }
16529 return b == &PyBaseObject_Type;
16530 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)16531 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
16532 PyObject *mro;
16533 if (a == b) return 1;
16534 mro = a->tp_mro;
16535 if (likely(mro)) {
16536 Py_ssize_t i, n;
16537 n = PyTuple_GET_SIZE(mro);
16538 for (i = 0; i < n; i++) {
16539 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
16540 return 1;
16541 }
16542 return 0;
16543 }
16544 return __Pyx_InBases(a, b);
16545 }
16546 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)16547 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
16548 PyObject *exception, *value, *tb;
16549 int res;
16550 __Pyx_PyThreadState_declare
16551 __Pyx_PyThreadState_assign
16552 __Pyx_ErrFetch(&exception, &value, &tb);
16553 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
16554 if (unlikely(res == -1)) {
16555 PyErr_WriteUnraisable(err);
16556 res = 0;
16557 }
16558 if (!res) {
16559 res = PyObject_IsSubclass(err, exc_type2);
16560 if (unlikely(res == -1)) {
16561 PyErr_WriteUnraisable(err);
16562 res = 0;
16563 }
16564 }
16565 __Pyx_ErrRestore(exception, value, tb);
16566 return res;
16567 }
16568 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)16569 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
16570 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
16571 if (!res) {
16572 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
16573 }
16574 return res;
16575 }
16576 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)16577 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
16578 Py_ssize_t i, n;
16579 assert(PyExceptionClass_Check(exc_type));
16580 n = PyTuple_GET_SIZE(tuple);
16581 #if PY_MAJOR_VERSION >= 3
16582 for (i=0; i<n; i++) {
16583 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
16584 }
16585 #endif
16586 for (i=0; i<n; i++) {
16587 PyObject *t = PyTuple_GET_ITEM(tuple, i);
16588 #if PY_MAJOR_VERSION < 3
16589 if (likely(exc_type == t)) return 1;
16590 #endif
16591 if (likely(PyExceptionClass_Check(t))) {
16592 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
16593 } else {
16594 }
16595 }
16596 return 0;
16597 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)16598 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
16599 if (likely(err == exc_type)) return 1;
16600 if (likely(PyExceptionClass_Check(err))) {
16601 if (likely(PyExceptionClass_Check(exc_type))) {
16602 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
16603 } else if (likely(PyTuple_Check(exc_type))) {
16604 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
16605 } else {
16606 }
16607 }
16608 return PyErr_GivenExceptionMatches(err, exc_type);
16609 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)16610 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
16611 assert(PyExceptionClass_Check(exc_type1));
16612 assert(PyExceptionClass_Check(exc_type2));
16613 if (likely(err == exc_type1 || err == exc_type2)) return 1;
16614 if (likely(PyExceptionClass_Check(err))) {
16615 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
16616 }
16617 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
16618 }
16619 #endif
16620
16621 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)16622 static int __Pyx_check_binary_version(void) {
16623 char ctversion[4], rtversion[4];
16624 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
16625 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
16626 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
16627 char message[200];
16628 PyOS_snprintf(message, sizeof(message),
16629 "compiletime version %s of module '%.100s' "
16630 "does not match runtime version %s",
16631 ctversion, __Pyx_MODULE_NAME, rtversion);
16632 return PyErr_WarnEx(NULL, message, 1);
16633 }
16634 return 0;
16635 }
16636
16637 /* FunctionExport */
__Pyx_ExportFunction(const char * name,void (* f)(void),const char * sig)16638 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
16639 PyObject *d = 0;
16640 PyObject *cobj = 0;
16641 union {
16642 void (*fp)(void);
16643 void *p;
16644 } tmp;
16645 d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
16646 if (!d) {
16647 PyErr_Clear();
16648 d = PyDict_New();
16649 if (!d)
16650 goto bad;
16651 Py_INCREF(d);
16652 if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
16653 goto bad;
16654 }
16655 tmp.fp = f;
16656 #if PY_VERSION_HEX >= 0x02070000
16657 cobj = PyCapsule_New(tmp.p, sig, 0);
16658 #else
16659 cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
16660 #endif
16661 if (!cobj)
16662 goto bad;
16663 if (PyDict_SetItemString(d, name, cobj) < 0)
16664 goto bad;
16665 Py_DECREF(cobj);
16666 Py_DECREF(d);
16667 return 0;
16668 bad:
16669 Py_XDECREF(cobj);
16670 Py_XDECREF(d);
16671 return -1;
16672 }
16673
16674 /* FunctionImport */
16675 #ifndef __PYX_HAVE_RT_ImportFunction
16676 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)16677 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
16678 PyObject *d = 0;
16679 PyObject *cobj = 0;
16680 union {
16681 void (*fp)(void);
16682 void *p;
16683 } tmp;
16684 d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
16685 if (!d)
16686 goto bad;
16687 cobj = PyDict_GetItemString(d, funcname);
16688 if (!cobj) {
16689 PyErr_Format(PyExc_ImportError,
16690 "%.200s does not export expected C function %.200s",
16691 PyModule_GetName(module), funcname);
16692 goto bad;
16693 }
16694 #if PY_VERSION_HEX >= 0x02070000
16695 if (!PyCapsule_IsValid(cobj, sig)) {
16696 PyErr_Format(PyExc_TypeError,
16697 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
16698 PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
16699 goto bad;
16700 }
16701 tmp.p = PyCapsule_GetPointer(cobj, sig);
16702 #else
16703 {const char *desc, *s1, *s2;
16704 desc = (const char *)PyCObject_GetDesc(cobj);
16705 if (!desc)
16706 goto bad;
16707 s1 = desc; s2 = sig;
16708 while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
16709 if (*s1 != *s2) {
16710 PyErr_Format(PyExc_TypeError,
16711 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
16712 PyModule_GetName(module), funcname, sig, desc);
16713 goto bad;
16714 }
16715 tmp.p = PyCObject_AsVoidPtr(cobj);}
16716 #endif
16717 *f = tmp.fp;
16718 if (!(*f))
16719 goto bad;
16720 Py_DECREF(d);
16721 return 0;
16722 bad:
16723 Py_XDECREF(d);
16724 return -1;
16725 }
16726 #endif
16727
16728 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)16729 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
16730 while (t->p) {
16731 #if PY_MAJOR_VERSION < 3
16732 if (t->is_unicode) {
16733 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
16734 } else if (t->intern) {
16735 *t->p = PyString_InternFromString(t->s);
16736 } else {
16737 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
16738 }
16739 #else
16740 if (t->is_unicode | t->is_str) {
16741 if (t->intern) {
16742 *t->p = PyUnicode_InternFromString(t->s);
16743 } else if (t->encoding) {
16744 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
16745 } else {
16746 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
16747 }
16748 } else {
16749 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
16750 }
16751 #endif
16752 if (!*t->p)
16753 return -1;
16754 if (PyObject_Hash(*t->p) == -1)
16755 return -1;
16756 ++t;
16757 }
16758 return 0;
16759 }
16760
__Pyx_PyUnicode_FromString(const char * c_str)16761 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
16762 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
16763 }
__Pyx_PyObject_AsString(PyObject * o)16764 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
16765 Py_ssize_t ignore;
16766 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
16767 }
16768 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
16769 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)16770 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
16771 char* defenc_c;
16772 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
16773 if (!defenc) return NULL;
16774 defenc_c = PyBytes_AS_STRING(defenc);
16775 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
16776 {
16777 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
16778 char* c;
16779 for (c = defenc_c; c < end; c++) {
16780 if ((unsigned char) (*c) >= 128) {
16781 PyUnicode_AsASCIIString(o);
16782 return NULL;
16783 }
16784 }
16785 }
16786 #endif
16787 *length = PyBytes_GET_SIZE(defenc);
16788 return defenc_c;
16789 }
16790 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)16791 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
16792 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
16793 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
16794 if (likely(PyUnicode_IS_ASCII(o))) {
16795 *length = PyUnicode_GET_LENGTH(o);
16796 return PyUnicode_AsUTF8(o);
16797 } else {
16798 PyUnicode_AsASCIIString(o);
16799 return NULL;
16800 }
16801 #else
16802 return PyUnicode_AsUTF8AndSize(o, length);
16803 #endif
16804 }
16805 #endif
16806 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)16807 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
16808 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
16809 if (
16810 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
16811 __Pyx_sys_getdefaultencoding_not_ascii &&
16812 #endif
16813 PyUnicode_Check(o)) {
16814 return __Pyx_PyUnicode_AsStringAndSize(o, length);
16815 } else
16816 #endif
16817 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
16818 if (PyByteArray_Check(o)) {
16819 *length = PyByteArray_GET_SIZE(o);
16820 return PyByteArray_AS_STRING(o);
16821 } else
16822 #endif
16823 {
16824 char* result;
16825 int r = PyBytes_AsStringAndSize(o, &result, length);
16826 if (unlikely(r < 0)) {
16827 return NULL;
16828 } else {
16829 return result;
16830 }
16831 }
16832 }
__Pyx_PyObject_IsTrue(PyObject * x)16833 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
16834 int is_true = x == Py_True;
16835 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
16836 else return PyObject_IsTrue(x);
16837 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)16838 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
16839 int retval;
16840 if (unlikely(!x)) return -1;
16841 retval = __Pyx_PyObject_IsTrue(x);
16842 Py_DECREF(x);
16843 return retval;
16844 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)16845 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
16846 #if PY_MAJOR_VERSION >= 3
16847 if (PyLong_Check(result)) {
16848 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
16849 "__int__ returned non-int (type %.200s). "
16850 "The ability to return an instance of a strict subclass of int "
16851 "is deprecated, and may be removed in a future version of Python.",
16852 Py_TYPE(result)->tp_name)) {
16853 Py_DECREF(result);
16854 return NULL;
16855 }
16856 return result;
16857 }
16858 #endif
16859 PyErr_Format(PyExc_TypeError,
16860 "__%.4s__ returned non-%.4s (type %.200s)",
16861 type_name, type_name, Py_TYPE(result)->tp_name);
16862 Py_DECREF(result);
16863 return NULL;
16864 }
__Pyx_PyNumber_IntOrLong(PyObject * x)16865 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
16866 #if CYTHON_USE_TYPE_SLOTS
16867 PyNumberMethods *m;
16868 #endif
16869 const char *name = NULL;
16870 PyObject *res = NULL;
16871 #if PY_MAJOR_VERSION < 3
16872 if (likely(PyInt_Check(x) || PyLong_Check(x)))
16873 #else
16874 if (likely(PyLong_Check(x)))
16875 #endif
16876 return __Pyx_NewRef(x);
16877 #if CYTHON_USE_TYPE_SLOTS
16878 m = Py_TYPE(x)->tp_as_number;
16879 #if PY_MAJOR_VERSION < 3
16880 if (m && m->nb_int) {
16881 name = "int";
16882 res = m->nb_int(x);
16883 }
16884 else if (m && m->nb_long) {
16885 name = "long";
16886 res = m->nb_long(x);
16887 }
16888 #else
16889 if (likely(m && m->nb_int)) {
16890 name = "int";
16891 res = m->nb_int(x);
16892 }
16893 #endif
16894 #else
16895 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
16896 res = PyNumber_Int(x);
16897 }
16898 #endif
16899 if (likely(res)) {
16900 #if PY_MAJOR_VERSION < 3
16901 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
16902 #else
16903 if (unlikely(!PyLong_CheckExact(res))) {
16904 #endif
16905 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
16906 }
16907 }
16908 else if (!PyErr_Occurred()) {
16909 PyErr_SetString(PyExc_TypeError,
16910 "an integer is required");
16911 }
16912 return res;
16913 }
16914 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
16915 Py_ssize_t ival;
16916 PyObject *x;
16917 #if PY_MAJOR_VERSION < 3
16918 if (likely(PyInt_CheckExact(b))) {
16919 if (sizeof(Py_ssize_t) >= sizeof(long))
16920 return PyInt_AS_LONG(b);
16921 else
16922 return PyInt_AsSsize_t(b);
16923 }
16924 #endif
16925 if (likely(PyLong_CheckExact(b))) {
16926 #if CYTHON_USE_PYLONG_INTERNALS
16927 const digit* digits = ((PyLongObject*)b)->ob_digit;
16928 const Py_ssize_t size = Py_SIZE(b);
16929 if (likely(__Pyx_sst_abs(size) <= 1)) {
16930 ival = likely(size) ? digits[0] : 0;
16931 if (size == -1) ival = -ival;
16932 return ival;
16933 } else {
16934 switch (size) {
16935 case 2:
16936 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
16937 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16938 }
16939 break;
16940 case -2:
16941 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
16942 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16943 }
16944 break;
16945 case 3:
16946 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
16947 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16948 }
16949 break;
16950 case -3:
16951 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
16952 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16953 }
16954 break;
16955 case 4:
16956 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
16957 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16958 }
16959 break;
16960 case -4:
16961 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
16962 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
16963 }
16964 break;
16965 }
16966 }
16967 #endif
16968 return PyLong_AsSsize_t(b);
16969 }
16970 x = PyNumber_Index(b);
16971 if (!x) return -1;
16972 ival = PyInt_AsSsize_t(x);
16973 Py_DECREF(x);
16974 return ival;
16975 }
16976 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
16977 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
16978 }
16979 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
16980 return PyInt_FromSize_t(ival);
16981 }
16982
16983
16984 #endif /* Py_PYTHON_H */
16985
16986
16987 static struct _inittab pygame_sdl2_surface_inittab[] = {
16988 #if PY_MAJOR_VERSION < 3
16989 { "pygame_sdl2.surface", initpygame_sdl2_surface },
16990 #else
16991 { "pygame_sdl2.surface", PyInit_pygame_sdl2_surface },
16992 #endif
16993 { NULL, NULL },
16994 };
16995
16996 static void pygame_sdl2_surface_constructor(void) __attribute__((constructor));
16997
16998 static void pygame_sdl2_surface_constructor(void) {
16999 PyImport_ExtendInittab(pygame_sdl2_surface_inittab);
17000 }
17001