Mercurial > touhou
comparison pytouhou/lib/sdl.pyx @ 616:4ce3ef053a25
Remove every case where an exception could be silently eaten by a cdef function.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 28 Mar 2015 23:21:15 +0100 |
parents | d1f0bb0b7a17 |
children | a6af3ff86612 |
comparison
equal
deleted
inserted
replaced
615:d1f0bb0b7a17 | 616:4ce3ef053a25 |
---|---|
107 if self.context != NULL: | 107 if self.context != NULL: |
108 SDL_GL_DeleteContext(self.context) | 108 SDL_GL_DeleteContext(self.context) |
109 if self.window != NULL: | 109 if self.window != NULL: |
110 SDL_DestroyWindow(self.window) | 110 SDL_DestroyWindow(self.window) |
111 | 111 |
112 cdef void gl_create_context(self) except *: | 112 cdef bint gl_create_context(self) except True: |
113 self.context = SDL_GL_CreateContext(self.window) | 113 self.context = SDL_GL_CreateContext(self.window) |
114 if self.context == NULL: | 114 if self.context == NULL: |
115 raise SDLError() | 115 raise SDLError() |
116 | 116 |
117 cdef void present(self) nogil: | 117 cdef void present(self) nogil: |
122 | 122 |
123 cdef void set_window_size(self, int width, int height) nogil: | 123 cdef void set_window_size(self, int width, int height) nogil: |
124 SDL_SetWindowSize(self.window, width, height) | 124 SDL_SetWindowSize(self.window, width, height) |
125 | 125 |
126 # The following functions are there for the pure SDL backend. | 126 # The following functions are there for the pure SDL backend. |
127 cdef void create_renderer(self, Uint32 flags): | 127 cdef bint create_renderer(self, Uint32 flags) except True: |
128 self.renderer = SDL_CreateRenderer(self.window, -1, flags) | 128 self.renderer = SDL_CreateRenderer(self.window, -1, flags) |
129 if self.renderer == NULL: | 129 if self.renderer == NULL: |
130 raise SDLError() | 130 raise SDLError() |
131 | 131 |
132 cdef void render_clear(self): | 132 cdef bint render_clear(self) except True: |
133 ret = SDL_RenderClear(self.renderer) | 133 ret = SDL_RenderClear(self.renderer) |
134 if ret == -1: | 134 if ret == -1: |
135 raise SDLError() | 135 raise SDLError() |
136 | 136 |
137 cdef void render_copy(self, Texture texture, Rect srcrect, Rect dstrect): | 137 cdef bint render_copy(self, Texture texture, Rect srcrect, Rect dstrect) except True: |
138 ret = SDL_RenderCopy(self.renderer, texture.texture, &srcrect.rect, &dstrect.rect) | 138 ret = SDL_RenderCopy(self.renderer, texture.texture, &srcrect.rect, &dstrect.rect) |
139 if ret == -1: | 139 if ret == -1: |
140 raise SDLError() | 140 raise SDLError() |
141 | 141 |
142 cdef void render_copy_ex(self, Texture texture, Rect srcrect, Rect dstrect, double angle, bint flip): | 142 cdef bint render_copy_ex(self, Texture texture, Rect srcrect, Rect dstrect, double angle, bint flip) except True: |
143 ret = SDL_RenderCopyEx(self.renderer, texture.texture, &srcrect.rect, &dstrect.rect, angle, NULL, flip) | 143 ret = SDL_RenderCopyEx(self.renderer, texture.texture, &srcrect.rect, &dstrect.rect, angle, NULL, flip) |
144 if ret == -1: | 144 if ret == -1: |
145 raise SDLError() | 145 raise SDLError() |
146 | 146 |
147 cdef void render_set_clip_rect(self, Rect rect): | 147 cdef bint render_set_clip_rect(self, Rect rect) except True: |
148 ret = SDL_RenderSetClipRect(self.renderer, &rect.rect) | 148 ret = SDL_RenderSetClipRect(self.renderer, &rect.rect) |
149 if ret == -1: | 149 if ret == -1: |
150 raise SDLError() | 150 raise SDLError() |
151 | 151 |
152 cdef void render_set_viewport(self, Rect rect): | 152 cdef bint render_set_viewport(self, Rect rect) except True: |
153 ret = SDL_RenderSetViewport(self.renderer, &rect.rect) | 153 ret = SDL_RenderSetViewport(self.renderer, &rect.rect) |
154 if ret == -1: | 154 if ret == -1: |
155 raise SDLError() | 155 raise SDLError() |
156 | 156 |
157 cdef Texture create_texture_from_surface(self, Surface surface): | 157 cdef Texture create_texture_from_surface(self, Surface surface): |
370 | 370 |
371 cdef void delay(Uint32 ms) nogil: | 371 cdef void delay(Uint32 ms) nogil: |
372 SDL_Delay(ms) | 372 SDL_Delay(ms) |
373 | 373 |
374 | 374 |
375 cpdef int show_simple_message_box(unicode message): | 375 cpdef bint show_simple_message_box(unicode message) except True: |
376 text = message.encode('UTF-8') | 376 text = message.encode('UTF-8') |
377 return SDL_ShowSimpleMessageBox(1, 'PyTouhou', text, NULL) | 377 ret = SDL_ShowSimpleMessageBox(1, 'PyTouhou', text, NULL) |
378 if ret == -1: | |
379 raise SDLError() |