comparison pytouhou/lib/sdl.pyx @ 617:a6af3ff86612

Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 Mar 2015 00:08:20 +0100
parents 4ce3ef053a25
children 80687f258001
comparison
equal deleted inserted replaced
616:4ce3ef053a25 617:a6af3ff86612
202 202
203 property pixels: 203 property pixels:
204 def __get__(self): 204 def __get__(self):
205 return bytes(self.surface.pixels[:self.surface.w * self.surface.h * 4]) 205 return bytes(self.surface.pixels[:self.surface.w * self.surface.h * 4])
206 206
207 cdef void blit(self, Surface other) except *: 207 cdef bint blit(self, Surface other) except True:
208 if SDL_BlitSurface(other.surface, NULL, self.surface, NULL) < 0: 208 if SDL_BlitSurface(other.surface, NULL, self.surface, NULL) < 0:
209 raise SDLError() 209 raise SDLError()
210 210
211 cdef void set_alpha(self, Surface alpha_surface) nogil: 211 cdef void set_alpha(self, Surface alpha_surface) nogil:
212 nb_pixels = self.surface.w * self.surface.h 212 nb_pixels = self.surface.w * self.surface.h
263 if surface.surface == NULL: 263 if surface.surface == NULL:
264 raise SDLError() 264 raise SDLError()
265 return surface 265 return surface
266 266
267 267
268 cdef void init(Uint32 flags) except *: 268 cdef bint init(Uint32 flags) except True:
269 if SDL_Init(flags) < 0: 269 if SDL_Init(flags) < 0:
270 raise SDLError() 270 raise SDLError()
271 271
272 272
273 cdef void img_init(int flags) except *: 273 cdef bint img_init(int flags) except True:
274 if IMG_Init(flags) != flags: 274 if IMG_Init(flags) != flags:
275 raise SDLError() 275 raise SDLError()
276 276
277 277
278 cdef void mix_init(int flags) except *: 278 cdef bint mix_init(int flags) except True:
279 if Mix_Init(flags) != flags: 279 if Mix_Init(flags) != flags:
280 raise SDLError() 280 raise SDLError()
281 281
282 282
283 cdef void ttf_init() except *: 283 cdef bint ttf_init() except True:
284 if TTF_Init() < 0: 284 if TTF_Init() < 0:
285 raise SDLError() 285 raise SDLError()
286 286
287 287
288 cdef void gl_set_attribute(SDL_GLattr attr, int value) except *: 288 cdef bint gl_set_attribute(SDL_GLattr attr, int value) except True:
289 if SDL_GL_SetAttribute(attr, value) < 0: 289 if SDL_GL_SetAttribute(attr, value) < 0:
290 raise SDLError() 290 raise SDLError()
291 291
292 cdef int gl_set_swap_interval(int interval) except *: 292 cdef bint gl_set_swap_interval(int interval) except True:
293 if SDL_GL_SetSwapInterval(interval) < 0: 293 if SDL_GL_SetSwapInterval(interval) < 0:
294 raise SDLError() 294 raise SDLError()
295 295
296 296
297 cdef list poll_events(): 297 cdef list poll_events():
324 if surface.surface == NULL: 324 if surface.surface == NULL:
325 raise SDLError() 325 raise SDLError()
326 return surface 326 return surface
327 327
328 328
329 cdef void mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except *: 329 cdef bint mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except True:
330 if Mix_OpenAudio(frequency, format_, channels, chunksize) < 0: 330 if Mix_OpenAudio(frequency, format_, channels, chunksize) < 0:
331 raise SDLError() 331 raise SDLError()
332 332
333 333
334 cdef void mix_allocate_channels(int numchans) except *: 334 cdef bint mix_allocate_channels(int numchans) except True:
335 if Mix_AllocateChannels(numchans) != numchans: 335 if Mix_AllocateChannels(numchans) != numchans:
336 raise SDLError() 336 raise SDLError()
337 337
338 338
339 cdef int mix_volume(int channel, float volume) nogil: 339 cdef int mix_volume(int channel, float volume) nogil: