# HG changeset patch # User Emmanuel Gil Peyrot # Date 1427584100 -3600 # Node ID a6af3ff8661235c4b6325482e34746475bb15296 # Parent 4ce3ef053a25565f5cd23dcbd9c62d96f7d5cfa7 Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call. diff --git a/pytouhou/game/bullet.pxd b/pytouhou/game/bullet.pxd --- a/pytouhou/game/bullet.pxd +++ b/pytouhou/game/bullet.pxd @@ -24,7 +24,7 @@ cdef class Bullet(Element): cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height) nogil cpdef set_anim(self, sprite_idx_offset=*) - cdef void launch(self) except * - cdef void collide(self) except * - cdef void cancel(self) except * - cdef void update(self) except * + cdef bint launch(self) except True + cdef bint collide(self) except True + cdef bint cancel(self) except True + cdef bint update(self) except True diff --git a/pytouhou/game/bullet.pyx b/pytouhou/game/bullet.pyx --- a/pytouhou/game/bullet.pyx +++ b/pytouhou/game/bullet.pyx @@ -110,7 +110,7 @@ cdef class Bullet(Element): self.sprite, self.sprite_idx_offset) - cdef void launch(self) except *: + cdef bint launch(self) except True: self.state = LAUNCHED self.frame = 0 self.set_anim() @@ -121,13 +121,13 @@ cdef class Bullet(Element): (self.speed,), 16) - cdef void collide(self) except *: + cdef bint collide(self) except True: self.cancel() self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size. @cython.cdivision(True) - cdef void cancel(self) except *: + cdef bint cancel(self) except True: # Cancel animation bt = self._bullet_type self.sprite = Sprite() @@ -145,7 +145,7 @@ cdef class Bullet(Element): self.state = CANCELLED - cdef void update(self) except *: + cdef bint update(self) except True: cdef int frame, count, game_width, game_height cdef double length, angle, speed, acceleration, angular_speed diff --git a/pytouhou/game/enemy.pxd b/pytouhou/game/enemy.pxd --- a/pytouhou/game/enemy.pxd +++ b/pytouhou/game/enemy.pxd @@ -41,14 +41,14 @@ cdef class Enemy(Element): cpdef Player select_player(self, list players=*) cpdef double get_angle(self, Element target, tuple pos=*) except 42 cpdef set_anim(self, index) - cdef void die_anim(self) except * - cdef void drop_particles(self, long number, long color) except * + cdef bint die_anim(self) except True + cdef bint drop_particles(self, long number, long color) except True cpdef set_aux_anm(self, long number, long index) cpdef set_pos(self, double x, double y, double z) cpdef move_to(self, unsigned long duration, double x, double y, double z, formula) cpdef stop_in(self, unsigned long duration, formula) cpdef set_boss(self, bint enable) cdef bint is_visible(self, long screen_width, long screen_height) except -1 - cdef void check_collisions(self) except * - cdef void handle_callbacks(self) except * - cdef void update(self) except * + cdef bint check_collisions(self) except True + cdef bint handle_callbacks(self) except True + cdef bint update(self) except True diff --git a/pytouhou/game/enemy.pyx b/pytouhou/game/enemy.pyx --- a/pytouhou/game/enemy.pyx +++ b/pytouhou/game/enemy.pyx @@ -261,13 +261,13 @@ cdef class Enemy(Element): self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite) - cdef void die_anim(self) except *: + cdef bint die_anim(self) except True: anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs. self._game.new_effect((self.x, self.y), anim) self._game.sfx_player.play('enep00.wav') - cdef void drop_particles(self, long number, long color) except *: + cdef bint drop_particles(self, long number, long color) except True: if color == 0: if self._game.stage in [1, 2, 7]: color = 3 @@ -338,7 +338,7 @@ cdef class Enemy(Element): return True - cdef void check_collisions(self) except *: + cdef bint check_collisions(self) except True: cdef Bullet bullet cdef Player player cdef PlayerLaser laser @@ -426,7 +426,7 @@ cdef class Enemy(Element): self.life -= damages - cdef void handle_callbacks(self) except *: + cdef bint handle_callbacks(self) except True: #TODO: implement missing callbacks and clean up! if self.life <= 0 and self.touchable: self.timeout = -1 #TODO: not really true, the timeout is frozen @@ -459,7 +459,7 @@ cdef class Enemy(Element): if death_flags == 0: self.removed = True - return + return False if death_flags == 1: if self.boss: @@ -502,7 +502,7 @@ cdef class Enemy(Element): raise Exception('What the hell, man!') - cdef void update(self) except *: + cdef bint update(self) except True: cdef double x, y, speed if self.process is not None: diff --git a/pytouhou/game/game.pxd b/pytouhou/game/game.pxd --- a/pytouhou/game/game.pxd +++ b/pytouhou/game/game.pxd @@ -25,12 +25,12 @@ cdef class Game: cdef void modify_difficulty(self, long diff) nogil cpdef enable_spellcard_effect(self) cpdef disable_spellcard_effect(self) - cdef void set_player_bomb(self) except * - cdef void unset_player_bomb(self) except * + cdef bint set_player_bomb(self) except True + cdef bint unset_player_bomb(self) except True cpdef drop_bonus(self, double x, double y, long _type, end_pos=*, player=*) - cdef void autocollect(self, Player player) except * - cdef void cancel_bullets(self) except * - cdef void cancel_player_lasers(self) except * + cdef bint autocollect(self, Player player) except True + cdef bint cancel_bullets(self) except True + cdef bint cancel_player_lasers(self) except True cpdef change_bullets_into_star_items(self) cpdef change_bullets_into_bonus(self) cpdef kill_enemies(self) @@ -43,12 +43,12 @@ cdef class Game: cpdef Text new_hint(self, hint) cpdef new_face(self, side, effect) cpdef run_iter(self, list keystates) - cdef void update_background(self) except * - cdef void update_enemies(self) except * - cdef void update_msg(self, long keystate) except * - cdef void update_players(self, list keystates) except * - cdef void update_effects(self) except * - cdef void update_hints(self) except * - cdef void update_faces(self) except * - cdef void update_bullets(self) except * + cdef bint update_background(self) except True + cdef bint update_enemies(self) except True + cdef bint update_msg(self, long keystate) except True + cdef bint update_players(self, list keystates) except True + cdef bint update_effects(self) except True + cdef bint update_hints(self) except True + cdef bint update_faces(self) except True + cdef bint update_bullets(self) except True cpdef cleanup(self) diff --git a/pytouhou/game/game.pyx b/pytouhou/game/game.pyx --- a/pytouhou/game/game.pyx +++ b/pytouhou/game/game.pyx @@ -119,14 +119,14 @@ cdef class Game: del self.texts['enemy_spellcard'] - cdef void set_player_bomb(self) except *: + cdef bint set_player_bomb(self) except True: face = Effect((-32, -16), 1, self.msg_anm[0][0][0]) face.sprite.allow_dest_offset = True self.effects.append(face) self.texts['player_spellcard'] = self.new_native_text((24, 24), u'Player Spellcard') - cdef void unset_player_bomb(self) except *: + cdef bint unset_player_bomb(self) except True: del self.texts['player_spellcard'] @@ -140,14 +140,14 @@ cdef class Game: player=player)) - cdef void autocollect(self, Player player) except *: + cdef bint autocollect(self, Player player) except True: cdef Item item for item in self.items: item.autocollect(player) - cdef void cancel_bullets(self) except *: + cdef bint cancel_bullets(self) except True: cdef Bullet bullet cdef Laser laser @@ -156,7 +156,7 @@ cdef class Game: for laser in self.lasers: laser.cancel() - cdef void cancel_player_lasers(self) except *: + cdef bint cancel_player_lasers(self) except True: cdef PlayerLaser laser for laser in self.players_lasers: if laser is not None: @@ -319,22 +319,22 @@ cdef class Game: self.frame += 1 - cdef void update_background(self) except *: + cdef bint update_background(self) except True: if self.time_stop: - return + return False if self.spellcard_effect is not None: self.spellcard_effect.update() #TODO: update the actual background here? - cdef void update_enemies(self) except *: + cdef bint update_enemies(self) except True: cdef Enemy enemy for enemy in self.enemies: enemy.update() - cdef void update_msg(self, long keystate) except *: + cdef bint update_msg(self, long keystate) except True: cdef long k for k in (1, 256): @@ -346,13 +346,13 @@ cdef class Game: self.msg_runner.run_iteration() - cdef void update_players(self, list keystates) except *: + cdef bint update_players(self, list keystates) except True: cdef Bullet bullet cdef Player player cdef long keystate if self.time_stop: - return + return False for bullet in self.players_bullets: bullet.update() @@ -373,26 +373,26 @@ cdef class Game: player.play_sound('extend') - cdef void update_effects(self) except *: + cdef bint update_effects(self) except True: cdef Element effect for effect in self.effects: effect.update() - cdef void update_hints(self) except *: + cdef bint update_hints(self) except True: for hint in self.hints: if hint['Count'] == self.frame and hint['Base'] == 'start': self.new_hint(hint) - cdef void update_faces(self) except *: + cdef bint update_faces(self) except True: for face in self.faces: if face: face.update() - cdef void update_bullets(self) except *: + cdef bint update_bullets(self) except True: cdef Player player cdef Bullet bullet cdef Item item @@ -402,7 +402,7 @@ cdef class Game: cdef double player_pos[2] if self.time_stop: - return + return False for bullet in self.cancelled_bullets: bullet.update() diff --git a/pytouhou/game/item.pxd b/pytouhou/game/item.pxd --- a/pytouhou/game/item.pxd +++ b/pytouhou/game/item.pxd @@ -23,6 +23,6 @@ cdef class Item(Element): cdef Indicator indicator cdef Interpolator speed_interpolator, pos_interpolator - cdef void autocollect(self, Player player) except * - cdef void on_collect(self, Player player) except * + cdef bint autocollect(self, Player player) except True + cdef bint on_collect(self, Player player) except True cpdef update(self) diff --git a/pytouhou/game/item.pyx b/pytouhou/game/item.pyx --- a/pytouhou/game/item.pyx +++ b/pytouhou/game/item.pyx @@ -74,17 +74,17 @@ cdef class Item(Element): return [self] - cdef void autocollect(self, Player player) except *: + cdef bint autocollect(self, Player player) except True: if self.target is None and self.player is None: self.target = player self.speed = player.sht.autocollection_speed - cdef void on_collect(self, Player player) except *: + cdef bint on_collect(self, Player player) except True: cdef long level, poc if not (self.player is None or self.player is player): - return + return False old_power = player.power score = 0 diff --git a/pytouhou/game/laser.pxd b/pytouhou/game/laser.pxd --- a/pytouhou/game/laser.pxd +++ b/pytouhou/game/laser.pxd @@ -23,7 +23,7 @@ cdef class Laser(Element): cdef State state cdef LaserType _laser_type - cdef void set_anim(self, long sprite_idx_offset=*) except * + cdef bint set_anim(self, long sprite_idx_offset=*) except True cpdef set_base_pos(self, double x, double y) cdef bint _check_collision(self, double point[2], double border_size) cdef bint check_collision(self, double point[2]) @@ -40,6 +40,6 @@ cdef class PlayerLaser(Element): cdef Element origin cdef LaserType _laser_type - cdef void set_anim(self, long sprite_idx_offset=*) except * - cdef void cancel(self) except * - cdef void update(self) except * + cdef bint set_anim(self, long sprite_idx_offset=*) except True + cdef bint cancel(self) except True + cdef bint update(self) except True diff --git a/pytouhou/game/laser.pyx b/pytouhou/game/laser.pyx --- a/pytouhou/game/laser.pyx +++ b/pytouhou/game/laser.pyx @@ -85,7 +85,7 @@ cdef class Laser(Element): self.set_anim() - cdef void set_anim(self, long sprite_idx_offset=-1) except *: + cdef bint set_anim(self, long sprite_idx_offset=-1) except True: if sprite_idx_offset >= 0: self.sprite_idx_offset = sprite_idx_offset @@ -221,7 +221,7 @@ cdef class PlayerLaser(Element): self.set_anim() - cdef void set_anim(self, long sprite_idx_offset=-1) except *: + cdef bint set_anim(self, long sprite_idx_offset=-1) except True: if sprite_idx_offset >= 0: self.sprite_idx_offset = sprite_idx_offset @@ -232,11 +232,11 @@ cdef class PlayerLaser(Element): #self.sprite.blendfunc = 1 #XXX - cdef void cancel(self) except *: + cdef bint cancel(self) except True: self.anmrunner.interrupt(1) - cdef void update(self) except *: + cdef bint update(self) except True: if self.anmrunner is not None and not self.anmrunner.run_frame(): self.anmrunner = None self.removed = True diff --git a/pytouhou/game/player.pxd b/pytouhou/game/player.pxd --- a/pytouhou/game/player.pxd +++ b/pytouhou/game/player.pxd @@ -16,8 +16,8 @@ cdef class Player(Element): cdef tuple speeds cdef long fire_time, bomb_time, direction - cdef void set_anim(self, index) except * - cdef void play_sound(self, str name) except * - cdef void collide(self) except * - cdef void fire(self) except * + cdef bint set_anim(self, index) except True + cdef bint play_sound(self, str name) except True + cdef bint collide(self) except True + cdef bint fire(self) except True cpdef update(self, long keystate) diff --git a/pytouhou/game/player.pyx b/pytouhou/game/player.pyx --- a/pytouhou/game/player.pyx +++ b/pytouhou/game/player.pyx @@ -68,16 +68,16 @@ cdef class Player(Element): self.death_time = 0 - cdef void set_anim(self, index) except *: + cdef bint set_anim(self, index) except True: self.sprite = Sprite() self.anmrunner = ANMRunner(self.anm, index, self.sprite) - cdef void play_sound(self, str name) except *: + cdef bint play_sound(self, str name) except True: self._game.sfx_player.play('%s.wav' % name) - cdef void collide(self) except *: + cdef bint collide(self) except True: if not self.invulnerable_time and not self.death_time and self.touchable: # Border Between Life and Death self.death_time = self._game.frame self._game.new_effect((self.x, self.y), 17) @@ -95,7 +95,7 @@ cdef class Player(Element): self.focused = False - cdef void fire(self) except *: + cdef bint fire(self) except True: cdef long shot_power sht = self.focused_sht if self.focused else self.sht diff --git a/pytouhou/game/text.pxd b/pytouhou/game/text.pxd --- a/pytouhou/game/text.pxd +++ b/pytouhou/game/text.pxd @@ -39,7 +39,7 @@ cdef class Text(GlyphCollection): #def timeout_update(self) #def move_timeout_update(self) #def fadeout_timeout_update(self) - cdef void fade(self, unsigned long duration, unsigned char alpha, formula=*) except * + cdef bint fade(self, unsigned long duration, unsigned char alpha, formula=*) except True cpdef set_timeout(self, unsigned long timeout, str effect=*, unsigned long duration=*, unsigned long start=*) @@ -79,6 +79,6 @@ cdef class NativeText(Element): #def move_ex_timeout_update(self) #def fadeout_timeout_update(self) - cdef void fade(self, unsigned long duration, unsigned char alpha, formula=*) except * - cdef void move_in(self, unsigned long duration, double x, double y, formula=*) except * + cdef bint fade(self, unsigned long duration, unsigned char alpha, formula=*) except True + cdef bint move_in(self, unsigned long duration, double x, double y, formula=*) except True cpdef set_timeout(self, unsigned long timeout, str effect=*, unsigned long duration=*, unsigned long start=*, to=*, end=*) diff --git a/pytouhou/lib/sdl.pxd b/pytouhou/lib/sdl.pxd --- a/pytouhou/lib/sdl.pxd +++ b/pytouhou/lib/sdl.pxd @@ -93,7 +93,7 @@ cdef class Color: cdef class Surface: cdef SDL_Surface *surface - cdef void blit(self, Surface other) except * + cdef bint blit(self, Surface other) except True cdef void set_alpha(self, Surface alpha_surface) nogil @@ -117,17 +117,17 @@ cdef class Font: cdef Surface render(self, unicode text) -cdef void init(Uint32 flags) except * -cdef void img_init(int flags) except * -cdef void mix_init(int flags) except * -cdef void ttf_init() except * -cdef void gl_set_attribute(SDL_GLattr attr, int value) except * -cdef int gl_set_swap_interval(int interval) except * +cdef bint init(Uint32 flags) except True +cdef bint img_init(int flags) except True +cdef bint mix_init(int flags) except True +cdef bint ttf_init() except True +cdef bint gl_set_attribute(SDL_GLattr attr, int value) except True +cdef bint gl_set_swap_interval(int interval) except True cdef list poll_events() cdef Surface load_png(file_) cdef Surface create_rgb_surface(int width, int height, int depth, Uint32 rmask=*, Uint32 gmask=*, Uint32 bmask=*, Uint32 amask=*) -cdef void mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except * -cdef void mix_allocate_channels(int numchans) except * +cdef bint mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except True +cdef bint mix_allocate_channels(int numchans) except True cdef int mix_volume(int channel, float volume) nogil cdef int mix_volume_music(float volume) nogil cdef Music load_music(str filename) diff --git a/pytouhou/lib/sdl.pyx b/pytouhou/lib/sdl.pyx --- a/pytouhou/lib/sdl.pyx +++ b/pytouhou/lib/sdl.pyx @@ -204,7 +204,7 @@ cdef class Surface: def __get__(self): return bytes(self.surface.pixels[:self.surface.w * self.surface.h * 4]) - cdef void blit(self, Surface other) except *: + cdef bint blit(self, Surface other) except True: if SDL_BlitSurface(other.surface, NULL, self.surface, NULL) < 0: raise SDLError() @@ -265,31 +265,31 @@ cdef class Font: return surface -cdef void init(Uint32 flags) except *: +cdef bint init(Uint32 flags) except True: if SDL_Init(flags) < 0: raise SDLError() -cdef void img_init(int flags) except *: +cdef bint img_init(int flags) except True: if IMG_Init(flags) != flags: raise SDLError() -cdef void mix_init(int flags) except *: +cdef bint mix_init(int flags) except True: if Mix_Init(flags) != flags: raise SDLError() -cdef void ttf_init() except *: +cdef bint ttf_init() except True: if TTF_Init() < 0: raise SDLError() -cdef void gl_set_attribute(SDL_GLattr attr, int value) except *: +cdef bint gl_set_attribute(SDL_GLattr attr, int value) except True: if SDL_GL_SetAttribute(attr, value) < 0: raise SDLError() -cdef int gl_set_swap_interval(int interval) except *: +cdef bint gl_set_swap_interval(int interval) except True: if SDL_GL_SetSwapInterval(interval) < 0: raise SDLError() @@ -326,12 +326,12 @@ cdef Surface create_rgb_surface(int widt return surface -cdef void mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except *: +cdef bint mix_open_audio(int frequency, Uint16 format_, int channels, int chunksize) except True: if Mix_OpenAudio(frequency, format_, channels, chunksize) < 0: raise SDLError() -cdef void mix_allocate_channels(int numchans) except *: +cdef bint mix_allocate_channels(int numchans) except True: if Mix_AllocateChannels(numchans) != numchans: raise SDLError() diff --git a/pytouhou/ui/gamerunner.pyx b/pytouhou/ui/gamerunner.pyx --- a/pytouhou/ui/gamerunner.pyx +++ b/pytouhou/ui/gamerunner.pyx @@ -76,7 +76,7 @@ cdef class GameRunner(Runner): game.sfx_player = SFXPlayer(self.resource_loader) if not self.skip else null_player - cdef void set_input(self, replay=None) except *: + cdef bint set_input(self, replay=None) except True: if not replay or not replay.levels[self.game.stage-1]: self.replay_level = None else: @@ -85,7 +85,7 @@ cdef class GameRunner(Runner): @cython.cdivision(True) - cdef void set_renderer_size(self, long width, long height) except *: + cdef bint set_renderer_size(self, long width, long height) except True: if self.renderer is not None: runner_width = float(self.width) runner_height = float(self.height) @@ -102,13 +102,13 @@ cdef class GameRunner(Runner): self.renderer.size = x, y, new_width, new_height - cdef void start(self) except *: + cdef bint start(self) except True: if self.renderer is not None: self.set_renderer_size(self.width, self.height) self.renderer.start(self.common) - cdef void capture(self) except *: + cdef bint capture(self) except True: if self.renderer is not None: filename = 'screenshot/frame%06d.ppm' % self.game.frame self.renderer.capture(filename, self.width, self.height) diff --git a/pytouhou/ui/opengl/backend.pyx b/pytouhou/ui/opengl/backend.pyx --- a/pytouhou/ui/opengl/backend.pyx +++ b/pytouhou/ui/opengl/backend.pyx @@ -46,7 +46,7 @@ def init(options): from pytouhou.ui.opengl.gamerenderer import GameRenderer -cdef void discover_features() except *: +cdef bint discover_features() except True: '''Discover which features are supported by our context.''' global use_debug_group, use_vao, use_primitive_restart, use_framebuffer_blit, use_pack_invert, use_scaled_rendering diff --git a/pytouhou/ui/opengl/background.pxd b/pytouhou/ui/opengl/background.pxd --- a/pytouhou/ui/opengl/background.pxd +++ b/pytouhou/ui/opengl/background.pxd @@ -20,4 +20,4 @@ cdef class BackgroundRenderer: cdef void set_state(self) nogil cdef void render_background(self) nogil - cdef void load(self, background, GLuint[MAX_TEXTURES] textures) except * + cdef bint load(self, background, GLuint[MAX_TEXTURES] textures) except True diff --git a/pytouhou/ui/opengl/background.pyx b/pytouhou/ui/opengl/background.pyx --- a/pytouhou/ui/opengl/background.pyx +++ b/pytouhou/ui/opengl/background.pyx @@ -107,7 +107,7 @@ cdef class BackgroundRenderer: glPopDebugGroup() - cdef void load(self, background, GLuint[MAX_TEXTURES] textures) except *: + cdef bint load(self, background, GLuint[MAX_TEXTURES] textures) except True: cdef float ox, oy, oz, ox2, oy2, oz2 cdef GLsizei nb_vertices = 0, nb_indices = 0 diff --git a/pytouhou/ui/opengl/framebuffer.pxd b/pytouhou/ui/opengl/framebuffer.pxd --- a/pytouhou/ui/opengl/framebuffer.pxd +++ b/pytouhou/ui/opengl/framebuffer.pxd @@ -21,4 +21,4 @@ cdef class Framebuffer: cpdef bind(self) cdef void set_state(self) nogil - cdef void render(self, int x, int y, int width, int height) except * + cdef bint render(self, int x, int y, int width, int height) except True diff --git a/pytouhou/ui/opengl/framebuffer.pyx b/pytouhou/ui/opengl/framebuffer.pyx --- a/pytouhou/ui/opengl/framebuffer.pyx +++ b/pytouhou/ui/opengl/framebuffer.pyx @@ -125,7 +125,7 @@ cdef class Framebuffer: glVertexAttribPointer(1, 2, GL_FLOAT, False, sizeof(PassthroughVertex), 4) glEnableVertexAttribArray(1) - cdef void render(self, int x, int y, int width, int height) except *: + cdef bint render(self, int x, int y, int width, int height) except True: if use_debug_group: glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Framebuffer drawing") diff --git a/pytouhou/ui/opengl/gamerenderer.pxd b/pytouhou/ui/opengl/gamerenderer.pxd --- a/pytouhou/ui/opengl/gamerenderer.pxd +++ b/pytouhou/ui/opengl/gamerenderer.pxd @@ -14,6 +14,6 @@ cdef class GameRenderer(Renderer): cdef BackgroundRenderer background_renderer cdef object background - cdef void render_game(self, Game game) except * - cdef void render_text(self, dict texts) except * - cdef void render_interface(self, interface, game_boss) except * + cdef bint render_game(self, Game game) except True + cdef bint render_text(self, dict texts) except True + cdef bint render_interface(self, interface, game_boss) except True diff --git a/pytouhou/ui/opengl/gamerenderer.pyx b/pytouhou/ui/opengl/gamerenderer.pyx --- a/pytouhou/ui/opengl/gamerenderer.pyx +++ b/pytouhou/ui/opengl/gamerenderer.pyx @@ -121,7 +121,7 @@ cdef class GameRenderer(Renderer): free(capture_memory) - cdef void render_game(self, Game game) except *: + cdef bint render_game(self, Game game) except True: cdef long game_x, game_y cdef float x, y, z, dx, dy, dz cdef float fog_data[4] @@ -235,11 +235,11 @@ cdef class GameRenderer(Renderer): glPopDebugGroup() - cdef void render_text(self, dict texts) except *: + cdef bint render_text(self, dict texts) except True: cdef NativeText label if self.font_manager is None: - return + return False self.font_manager.load(texts) @@ -258,7 +258,7 @@ cdef class GameRenderer(Renderer): self.render_quads([rect], [gradient], texture) - cdef void render_interface(self, interface, game_boss) except *: + cdef bint render_interface(self, interface, game_boss) except True: cdef GlyphCollection label elements = [] diff --git a/pytouhou/ui/opengl/renderer.pxd b/pytouhou/ui/opengl/renderer.pxd --- a/pytouhou/ui/opengl/renderer.pxd +++ b/pytouhou/ui/opengl/renderer.pxd @@ -35,5 +35,5 @@ cdef class Renderer: cdef PyObject *elements[640*3] cdef void set_state(self) nogil - cdef void render_elements(self, elements) except * - cdef void render_quads(self, rects, colors, GLuint texture) except * + cdef bint render_elements(self, elements) except True + cdef bint render_quads(self, rects, colors, GLuint texture) except True diff --git a/pytouhou/ui/opengl/renderer.pyx b/pytouhou/ui/opengl/renderer.pyx --- a/pytouhou/ui/opengl/renderer.pyx +++ b/pytouhou/ui/opengl/renderer.pyx @@ -130,12 +130,12 @@ cdef class Renderer: glBindBuffer(GL_ARRAY_BUFFER, 0) - cdef void render_elements(self, elements) except *: + cdef bint render_elements(self, elements) except True: cdef Element element nb_elements = find_objects(self, elements) if not nb_elements: - return + return False nb_vertices = 0 memset(self.last_indices, 0, sizeof(self.last_indices)) @@ -232,7 +232,7 @@ cdef class Renderer: glPopDebugGroup() - cdef void render_quads(self, rects, colors, GLuint texture) except *: + cdef bint render_quads(self, rects, colors, GLuint texture) except True: # There is nothing that batch more than two quads on the same texture, currently. cdef Vertex buf[8] cdef unsigned short indices[12] diff --git a/pytouhou/ui/opengl/shader.pxd b/pytouhou/ui/opengl/shader.pxd --- a/pytouhou/ui/opengl/shader.pxd +++ b/pytouhou/ui/opengl/shader.pxd @@ -6,10 +6,10 @@ cdef class Shader: cdef bint linked cdef dict location_cache - cdef void create_shader(self, const GLchar *string, GLenum_shader shader_type) except * - cdef void link(self) except * + cdef bint create_shader(self, const GLchar *string, GLenum_shader shader_type) except True + cdef bint link(self) except True cdef GLint get_uniform_location(self, name) except -1 cdef void bind(self) nogil - cdef void uniform_1(self, name, GLfloat val) except * - cdef void uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except * - cdef void uniform_matrix(self, name, Matrix *mat) except * + cdef bint uniform_1(self, name, GLfloat val) except True + cdef bint uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except True + cdef bint uniform_matrix(self, name, Matrix *mat) except True diff --git a/pytouhou/ui/opengl/shader.pyx b/pytouhou/ui/opengl/shader.pyx --- a/pytouhou/ui/opengl/shader.pyx +++ b/pytouhou/ui/opengl/shader.pyx @@ -58,7 +58,7 @@ cdef class Shader: if use_debug_group: glPopDebugGroup() - cdef void create_shader(self, const GLchar *string, GLenum_shader shader_type) except *: + cdef bint create_shader(self, const GLchar *string, GLenum_shader shader_type) except True: cdef GLint temp cdef const GLchar *strings[2] strings[:] = [shader_header, string] @@ -91,7 +91,7 @@ cdef class Shader: # all is well, so attach the shader to the program glAttachShader(self.handle, shader) - cdef void link(self) except *: + cdef bint link(self) except True: cdef GLint temp # link the program @@ -132,11 +132,11 @@ cdef class Shader: # upload a floating point uniform # this program must be currently bound - cdef void uniform_1(self, name, GLfloat val) except *: + cdef bint uniform_1(self, name, GLfloat val) except True: glUniform1fv(self.get_uniform_location(name), 1, &val) # upload a vec4 uniform - cdef void uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except *: + cdef bint uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except True: cdef GLfloat vals[4] vals[0] = a vals[1] = b @@ -147,7 +147,7 @@ cdef class Shader: # upload a uniform matrix # works with matrices stored as lists, # as well as euclid matrices - cdef void uniform_matrix(self, name, Matrix *mat) except *: + cdef bint uniform_matrix(self, name, Matrix *mat) except True: # obtain the uniform location loc = self.get_uniform_location(name) # uplaod the 4x4 floating point matrix diff --git a/pytouhou/ui/opengl/texture.pxd b/pytouhou/ui/opengl/texture.pxd --- a/pytouhou/ui/opengl/texture.pxd +++ b/pytouhou/ui/opengl/texture.pxd @@ -3,10 +3,10 @@ from pytouhou.lib.sdl cimport Font cdef class TextureManager: cdef object loader, renderer, texture_class - cdef void load(self, dict anms) except * + cdef bint load(self, dict anms) except True cdef class FontManager: cdef Font font cdef object renderer, texture_class - cdef void load(self, dict labels) except * + cdef bint load(self, dict labels) except True diff --git a/pytouhou/ui/opengl/texture.pyx b/pytouhou/ui/opengl/texture.pyx --- a/pytouhou/ui/opengl/texture.pyx +++ b/pytouhou/ui/opengl/texture.pyx @@ -39,7 +39,7 @@ cdef class TextureManager: self.texture_class = texture_class - cdef void load(self, dict anms) except *: + cdef bint load(self, dict anms) except True: if use_debug_group: glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Texture loading") @@ -73,7 +73,7 @@ cdef class FontManager: self.texture_class = texture_class - cdef void load(self, dict labels) except *: + cdef bint load(self, dict labels) except True: cdef NativeText label if use_debug_group: diff --git a/pytouhou/ui/sdl/gamerenderer.pxd b/pytouhou/ui/sdl/gamerenderer.pxd --- a/pytouhou/ui/sdl/gamerenderer.pxd +++ b/pytouhou/ui/sdl/gamerenderer.pxd @@ -11,6 +11,6 @@ cdef class GameRenderer: cdef public size #XXX - cdef void render_game(self, Game game) except * - cdef void render_text(self, texts) except * - cdef void render_interface(self, interface, game_boss) except * + cdef bint render_game(self, Game game) except True + cdef bint render_text(self, texts) except True + cdef bint render_interface(self, interface, game_boss) except True diff --git a/pytouhou/ui/sdl/texture.pxd b/pytouhou/ui/sdl/texture.pxd --- a/pytouhou/ui/sdl/texture.pxd +++ b/pytouhou/ui/sdl/texture.pxd @@ -5,11 +5,11 @@ cdef class TextureManager: cdef object loader cdef Window window - cdef void load(self, dict anms) except * + cdef bint load(self, dict anms) except True cdef load_texture(self, Surface texture) cdef class FontManager: cdef Font font cdef Window window - cdef void load(self, dict labels) except * + cdef bint load(self, dict labels) except True diff --git a/pytouhou/ui/sdl/texture.pyx b/pytouhou/ui/sdl/texture.pyx --- a/pytouhou/ui/sdl/texture.pyx +++ b/pytouhou/ui/sdl/texture.pyx @@ -28,7 +28,7 @@ cdef class TextureManager: self.window = window - cdef void load(self, dict anms) except *: + cdef bint load(self, dict anms) except True: for anm in sorted(anms.values(), key=is_ascii): for entry in anm: if entry.texture is None: @@ -53,7 +53,7 @@ cdef class FontManager: self.window = window - cdef void load(self, dict labels) except *: + cdef bint load(self, dict labels) except True: cdef NativeText label for i, label in labels.items(): diff --git a/pytouhou/ui/window.pxd b/pytouhou/ui/window.pxd --- a/pytouhou/ui/window.pxd +++ b/pytouhou/ui/window.pxd @@ -7,14 +7,14 @@ cdef class Clock: cdef double fps cdef void set_target_fps(self, long fps) nogil - cdef void tick(self) nogil except * + cdef bint tick(self) nogil except True cdef class Runner: cdef long width, height - cdef void start(self) except * - cdef void finish(self) except * + cdef bint start(self) except True + cdef bint finish(self) except True cpdef bint update(self, bint render) except -1 diff --git a/pytouhou/ui/window.pyx b/pytouhou/ui/window.pyx --- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -33,7 +33,7 @@ cdef class Clock: @cython.cdivision(True) - cdef void tick(self) nogil except *: + cdef bint tick(self) nogil except True: current = sdl.get_ticks() if not self._ref_tick: @@ -65,10 +65,10 @@ cdef class Clock: cdef class Runner: - cdef void start(self) except *: + cdef bint start(self) except True: pass - cdef void finish(self) except *: + cdef bint finish(self) except True: pass cpdef bint update(self, bint render) except -1: