changeset 606:3c2f96f1d715

Fix compilation under Cython 0.22, by making the pyx and the pxd declarations’ except clause similar.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 26 Nov 2014 13:36:38 +0100
parents d6ead6f0ba80
children 9dbc234ea087
files pytouhou/game/bullet.pxd pytouhou/game/bullet.pyx pytouhou/game/enemy.pxd pytouhou/game/enemy.pyx pytouhou/game/game.pyx pytouhou/game/item.pyx pytouhou/game/laser.pyx pytouhou/game/player.pyx pytouhou/lib/sdl.pyx pytouhou/ui/gamerunner.pyx pytouhou/ui/opengl/background.pxd pytouhou/ui/opengl/background.pyx pytouhou/ui/opengl/gamerenderer.pyx pytouhou/ui/opengl/renderer.pyx pytouhou/ui/opengl/shader.pyx pytouhou/ui/opengl/texture.pyx pytouhou/ui/sdl/texture.pyx pytouhou/ui/window.pxd pytouhou/ui/window.pyx pytouhou/utils/bitstream.pxd pytouhou/utils/bitstream.pyx
diffstat 21 files changed, 64 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/bullet.pxd
+++ b/pytouhou/game/bullet.pxd
@@ -22,7 +22,7 @@ cdef class Bullet(Element):
     cdef Game _game
     cdef long player
 
-    cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height) except? False
+    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 *
--- a/pytouhou/game/bullet.pyx
+++ b/pytouhou/game/bullet.pyx
@@ -81,7 +81,7 @@ cdef class Bullet(Element):
             self.sprite.angle = angle
 
 
-    cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height):
+    cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height) nogil:
         tw, th = self.sprite._texcoords[2], self.sprite._texcoords[3]
         x, y = self.x, self.y
 
@@ -110,7 +110,7 @@ cdef class Bullet(Element):
                                    self.sprite, self.sprite_idx_offset)
 
 
-    cdef void launch(self):
+    cdef void launch(self) except *:
         self.state = LAUNCHED
         self.frame = 0
         self.set_anim()
@@ -121,13 +121,13 @@ cdef class Bullet(Element):
                                                    (self.speed,), 16)
 
 
-    cdef void collide(self):
+    cdef void collide(self) except *:
         self.cancel()
         self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size.
 
 
     @cython.cdivision(True)
-    cdef void cancel(self):
+    cdef void cancel(self) except *:
         # Cancel animation
         bt = self._bullet_type
         self.sprite = Sprite()
@@ -145,7 +145,7 @@ cdef class Bullet(Element):
         self.state = CANCELLED
 
 
-    cdef void update(self):
+    cdef void update(self) except *:
         cdef int frame, count, game_width, game_height
         cdef double length, angle, speed, acceleration, angular_speed
 
--- a/pytouhou/game/enemy.pxd
+++ b/pytouhou/game/enemy.pxd
@@ -48,7 +48,7 @@ cdef class Enemy(Element):
     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? False
+    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 *
--- a/pytouhou/game/enemy.pyx
+++ b/pytouhou/game/enemy.pyx
@@ -249,7 +249,7 @@ cdef class Enemy(Element):
         return min(players, key=self.select_player_key)
 
 
-    cpdef double get_angle(self, Element target, tuple pos=None):
+    cpdef double get_angle(self, Element target, tuple pos=None) except 42:
         cdef double x, y
         x, y = pos or (self.x, self.y)
         return atan2(target.y - y, target.x - x)
@@ -261,13 +261,13 @@ cdef class Enemy(Element):
         self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite)
 
 
-    cdef void die_anim(self):
+    cdef void die_anim(self) except *:
         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):
+    cdef void drop_particles(self, long number, long color) except *:
         if color == 0:
             if self._game.stage in [1, 2, 7]:
                 color = 3
@@ -318,7 +318,7 @@ cdef class Enemy(Element):
             self._game.boss = None
 
 
-    cdef bint is_visible(self, long screen_width, long screen_height):
+    cdef bint is_visible(self, long screen_width, long screen_height) except -1:
         if self.sprite is not None:
             if self.sprite.corner_relative_placement:
                 raise Exception #TODO
@@ -338,7 +338,7 @@ cdef class Enemy(Element):
         return True
 
 
-    cdef void check_collisions(self):
+    cdef void check_collisions(self) except *:
         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):
+    cdef void handle_callbacks(self) except *:
         #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
@@ -502,7 +502,7 @@ cdef class Enemy(Element):
                 raise Exception('What the hell, man!')
 
 
-    cdef void update(self):
+    cdef void update(self) except *:
         cdef double x, y, speed
 
         if self.process is not None:
--- 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):
+    cdef void set_player_bomb(self) except *:
         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):
+    cdef void unset_player_bomb(self) except *:
         del self.texts['player_spellcard']
 
 
@@ -140,14 +140,14 @@ cdef class Game:
                                player=player))
 
 
-    cdef void autocollect(self, Player player):
+    cdef void autocollect(self, Player player) except *:
         cdef Item item
 
         for item in self.items:
             item.autocollect(player)
 
 
-    cdef void cancel_bullets(self):
+    cdef void cancel_bullets(self) except *:
         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):
+    cdef void cancel_player_lasers(self) except *:
         cdef PlayerLaser laser
         for laser in self.players_lasers:
             if laser is not None:
@@ -319,7 +319,7 @@ cdef class Game:
         self.frame += 1
 
 
-    cdef void update_background(self):
+    cdef void update_background(self) except *:
         if self.time_stop:
             return
         if self.spellcard_effect is not None:
@@ -327,14 +327,14 @@ cdef class Game:
         #TODO: update the actual background here?
 
 
-    cdef void update_enemies(self):
+    cdef void update_enemies(self) except *:
         cdef Enemy enemy
 
         for enemy in self.enemies:
             enemy.update()
 
 
-    cdef void update_msg(self, long keystate):
+    cdef void update_msg(self, long keystate) except *:
         cdef long k
 
         for k in (1, 256):
@@ -346,7 +346,7 @@ cdef class Game:
         self.msg_runner.run_iteration()
 
 
-    cdef void update_players(self, list keystates):
+    cdef void update_players(self, list keystates) except *:
         cdef Bullet bullet
         cdef Player player
         cdef long keystate
@@ -373,26 +373,26 @@ cdef class Game:
                         player.play_sound('extend')
 
 
-    cdef void update_effects(self):
+    cdef void update_effects(self) except *:
         cdef Element effect
 
         for effect in self.effects:
             effect.update()
 
 
-    cdef void update_hints(self):
+    cdef void update_hints(self) except *:
         for hint in self.hints:
             if hint['Count'] == self.frame and hint['Base'] == 'start':
                 self.new_hint(hint)
 
 
-    cdef void update_faces(self):
+    cdef void update_faces(self) except *:
         for face in self.faces:
             if face:
                 face.update()
 
 
-    cdef void update_bullets(self):
+    cdef void update_bullets(self) except *:
         cdef Player player
         cdef Bullet bullet
         cdef Item item
--- a/pytouhou/game/item.pyx
+++ b/pytouhou/game/item.pyx
@@ -74,13 +74,13 @@ cdef class Item(Element):
             return [self]
 
 
-    cdef void autocollect(self, Player player):
+    cdef void autocollect(self, Player player) except *:
         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):
+    cdef void on_collect(self, Player player) except *:
         cdef long level, poc
 
         if not (self.player is None or self.player is player):
--- 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):
+    cdef void set_anim(self, long sprite_idx_offset=-1) except *:
         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):
+    cdef void set_anim(self, long sprite_idx_offset=-1) except *:
         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):
+    cdef void cancel(self) except *:
         self.anmrunner.interrupt(1)
 
 
-    cdef void update(self):
+    cdef void update(self) except *:
         if self.anmrunner is not None and not self.anmrunner.run_frame():
             self.anmrunner = None
             self.removed = True
--- 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):
+    cdef void set_anim(self, index) except *:
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(self.anm, index, self.sprite)
 
 
-    cdef void play_sound(self, str name):
+    cdef void play_sound(self, str name) except *:
         self._game.sfx_player.play('%s.wav' % name)
 
 
-    cdef void collide(self):
+    cdef void collide(self) except *:
         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):
+    cdef void fire(self) except *:
         cdef long shot_power
 
         sht = self.focused_sht if self.focused else self.sht
--- a/pytouhou/lib/sdl.pyx
+++ b/pytouhou/lib/sdl.pyx
@@ -201,7 +201,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):
+    cdef void blit(self, Surface other) except *:
         if SDL_BlitSurface(other.surface, NULL, self.surface, NULL) < 0:
             raise SDLError()
 
--- a/pytouhou/ui/gamerunner.pyx
+++ b/pytouhou/ui/gamerunner.pyx
@@ -114,7 +114,7 @@ cdef class GameRunner(Runner):
             self.renderer.capture(filename, self.width, self.height)
 
 
-    cpdef bint update(self, bint render) except? False:
+    cpdef bint update(self, bint render) except -1:
         cdef long keystate
         capture = False
 
--- a/pytouhou/ui/opengl/background.pxd
+++ b/pytouhou/ui/opengl/background.pxd
@@ -19,5 +19,5 @@ cdef class BackgroundRenderer:
     cdef GLushort *indices
 
     cdef void set_state(self) nogil
-    cdef void render_background(self) except *
+    cdef void render_background(self) nogil
     cdef void load(self, background, GLuint[MAX_TEXTURES] textures) except *
--- a/pytouhou/ui/opengl/background.pyx
+++ b/pytouhou/ui/opengl/background.pyx
@@ -75,7 +75,7 @@ cdef class BackgroundRenderer:
         glEnableVertexAttribArray(2)
 
 
-    cdef void render_background(self):
+    cdef void render_background(self) nogil:
         if use_debug_group:
             glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background drawing")
 
@@ -108,7 +108,7 @@ cdef class BackgroundRenderer:
             glPopDebugGroup()
 
 
-    cdef void load(self, background, GLuint[MAX_TEXTURES] textures):
+    cdef void load(self, background, GLuint[MAX_TEXTURES] textures) except *:
         cdef float ox, oy, oz, ox2, oy2, oz2
         cdef GLsizei nb_vertices = 0, nb_indices = 0
 
--- a/pytouhou/ui/opengl/gamerenderer.pyx
+++ b/pytouhou/ui/opengl/gamerenderer.pyx
@@ -129,7 +129,7 @@ cdef class GameRenderer(Renderer):
         free(capture_memory)
 
 
-    cdef void render_game(self, Game game):
+    cdef void render_game(self, Game game) except *:
         cdef long game_x, game_y
         cdef float x, y, z, dx, dy, dz
         cdef float fog_data[4]
@@ -243,7 +243,7 @@ cdef class GameRenderer(Renderer):
             glPopDebugGroup()
 
 
-    cdef void render_text(self, dict texts):
+    cdef void render_text(self, dict texts) except *:
         cdef NativeText label
 
         if self.font_manager is None:
@@ -266,7 +266,7 @@ cdef class GameRenderer(Renderer):
                 self.render_quads([rect], [gradient], texture)
 
 
-    cdef void render_interface(self, interface, game_boss):
+    cdef void render_interface(self, interface, game_boss) except *:
         cdef GlyphCollection label
 
         elements = []
--- a/pytouhou/ui/opengl/renderer.pyx
+++ b/pytouhou/ui/opengl/renderer.pyx
@@ -130,7 +130,7 @@ cdef class Renderer:
         glBindBuffer(GL_ARRAY_BUFFER, 0)
 
 
-    cdef void render_elements(self, elements):
+    cdef void render_elements(self, elements) except *:
         cdef Element element
 
         nb_elements = find_objects(self, elements)
@@ -226,7 +226,7 @@ cdef class Renderer:
             glPopDebugGroup()
 
 
-    cdef void render_quads(self, rects, colors, GLuint texture):
+    cdef void render_quads(self, rects, colors, GLuint texture) except *:
         # There is nothing that batch more than two quads on the same texture, currently.
         cdef Vertex buf[8]
         cdef unsigned short indices[12]
--- 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):
+    cdef void create_shader(self, const GLchar *string, GLenum_shader shader_type) except *:
         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):
+    cdef void link(self) except *:
         cdef GLint temp
 
         # link the program
@@ -116,7 +116,7 @@ cdef class Shader:
             # all is well, so we are linked
             self.linked = True
 
-    cdef GLint get_uniform_location(self, name):
+    cdef GLint get_uniform_location(self, name) except -1:
         if isinstance(name, str):
             name = name.encode()
         if name not in self.location_cache:
@@ -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):
+    cdef void uniform_1(self, name, GLfloat val) except *:
         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):
+    cdef void uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except *:
         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):
+    cdef void uniform_matrix(self, name, Matrix *mat) except *:
         # obtain the uniform location
         loc = self.get_uniform_location(name)
         # uplaod the 4x4 floating point matrix
--- 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):
+    cdef void load(self, dict anms) except *:
         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):
+    cdef void load(self, dict labels) except *:
         cdef NativeText label
 
         if use_debug_group:
--- 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):
+    cdef void load(self, dict anms) except *:
         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):
+    cdef void load(self, dict labels) except *:
         cdef NativeText label
 
         for i, label in labels.items():
--- a/pytouhou/ui/window.pxd
+++ b/pytouhou/ui/window.pxd
@@ -15,7 +15,7 @@ cdef class Runner:
 
     cdef void start(self) except *
     cdef void finish(self) except *
-    cpdef bint update(self, bint render) except? False
+    cpdef bint update(self, bint render) except -1
 
 
 cdef class Window:
@@ -28,5 +28,5 @@ cdef class Window:
     cdef void set_size(self, int width, int height) nogil
     cpdef set_runner(self, Runner runner=*)
     cpdef run(self)
-    cdef bint run_frame(self) except? False
+    cdef bint run_frame(self) except -1
     cdef double get_fps(self) nogil
--- a/pytouhou/ui/window.pyx
+++ b/pytouhou/ui/window.pyx
@@ -71,7 +71,7 @@ cdef class Runner:
     cdef void finish(self) except *:
         pass
 
-    cpdef bint update(self, bint render) except? False:
+    cpdef bint update(self, bint render) except -1:
         return False
 
 
@@ -112,7 +112,7 @@ cdef class Window:
 
 
     @cython.cdivision(True)
-    cdef bint run_frame(self) except? False:
+    cdef bint run_frame(self) except -1:
         cdef bint render = (self.win is not None and
                             (self.frameskip <= 1 or not self.frame % self.frameskip))
 
--- a/pytouhou/utils/bitstream.pxd
+++ b/pytouhou/utils/bitstream.pxd
@@ -3,7 +3,7 @@ cdef class BitStream:
     cdef unsigned int bits
     cdef unsigned char byte
 
-    cdef bint read_bit(self) except? -1
+    cdef bint read_bit(self) except -1
     cpdef unsigned int read(self, unsigned int nb_bits) except? 4242
     cpdef write_bit(self, bint bit)
     cpdef write(self, unsigned int bits, unsigned int nb_bits)
--- a/pytouhou/utils/bitstream.pyx
+++ b/pytouhou/utils/bitstream.pyx
@@ -33,7 +33,7 @@ cdef class BitStream:
         self.bits = 0
 
 
-    cdef bint read_bit(self):
+    cdef bint read_bit(self) except -1:
         cdef bytes byte
         if not self.bits:
             byte = self.io.read(1)
@@ -43,7 +43,7 @@ cdef class BitStream:
         return (self.byte >> self.bits) & 0x01
 
 
-    cpdef unsigned int read(self, unsigned int nb_bits):
+    cpdef unsigned int read(self, unsigned int nb_bits) except? 4242:
         cdef unsigned int value = 0, read = 0
         cdef unsigned int nb_bits2 = nb_bits
         cdef bytes byte