changeset 417:efae61ad6efe

Remove the type of the self argument in extension types, as it clutters the code with useless information.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 22 Aug 2013 12:21:12 +0200
parents e23871eddb7a
children 63f59be04a54
files pytouhou/game/bullet.pyx pytouhou/utils/bitstream.pyx pytouhou/utils/matrix.pxd pytouhou/utils/matrix.pyx
diffstat 4 files changed, 32 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/bullet.pyx
+++ b/pytouhou/game/bullet.pyx
@@ -92,7 +92,7 @@ cdef class Bullet(object):
             self.sprite.angle = angle
 
 
-    cpdef is_visible(Bullet self, screen_width, screen_height):
+    cpdef is_visible(self, screen_width, screen_height):
         tx, ty, tw, th = self.sprite.texcoords
         x, y = self.x, self.y
 
@@ -107,7 +107,7 @@ cdef class Bullet(object):
         return True
 
 
-    def set_anim(Bullet self, sprite_idx_offset=None):
+    def set_anim(self, sprite_idx_offset=None):
         if sprite_idx_offset is not None:
             self.sprite_idx_offset = sprite_idx_offset
 
@@ -122,7 +122,7 @@ cdef class Bullet(object):
         self.anmrunner.run_frame()
 
 
-    def launch(Bullet self):
+    def launch(self):
         self.state = LAUNCHED
         self.frame = 0
         self.set_anim()
@@ -133,12 +133,12 @@ cdef class Bullet(object):
                                                    (self.speed,), 16)
 
 
-    def collide(Bullet self):
+    def collide(self):
         self.cancel()
         self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size.
 
 
-    def cancel(Bullet self):
+    def cancel(self):
         # Cancel animation
         bt = self._bullet_type
         self.sprite = Sprite()
@@ -154,7 +154,7 @@ cdef class Bullet(object):
         self.state = CANCELLED
 
 
-    def update(Bullet self):
+    def update(self):
         if self.anmrunner is not None and not self.anmrunner.run_frame():
             if self.state == LAUNCHING:
                 #TODO: check if it doesn't skip a frame
--- a/pytouhou/utils/bitstream.pyx
+++ b/pytouhou/utils/bitstream.pyx
@@ -19,7 +19,7 @@ cdef class BitStream:
     cdef bytes bytes
 
 
-    def __init__(BitStream self, io):
+    def __init__(self, io):
         self.io = io
         self.bits = 0
         self.byte = 0
@@ -33,21 +33,21 @@ cdef class BitStream:
         return self.io.__exit__(type, value, traceback)
 
 
-    def seek(BitStream self, offset, whence=0):
+    def seek(self, offset, whence=0):
         self.io.seek(offset, whence)
         self.byte = 0
         self.bits = 0
 
 
-    def tell(BitStream self):
+    def tell(self):
         return self.io.tell()
 
 
-    def tell2(BitStream self):
+    def tell2(self):
         return self.io.tell(), self.bits
 
 
-    cpdef unsigned char read_bit(BitStream self):
+    cpdef unsigned char read_bit(self):
         if not self.bits:
             self.bytes = self.io.read(1)
             self.byte = (<unsigned char*> self.bytes)[0]
@@ -56,7 +56,7 @@ cdef class BitStream:
         return (self.byte >> self.bits) & 0x01
 
 
-    cpdef unsigned int read(BitStream self, unsigned int nb_bits):
+    cpdef unsigned int read(self, unsigned int nb_bits):
         cdef unsigned int value = 0, read = 0
         cdef unsigned int nb_bits2 = nb_bits
 
@@ -72,7 +72,7 @@ cdef class BitStream:
         return value & ((1 << nb_bits) - 1)
 
 
-    cpdef write_bit(BitStream self, bit):
+    cpdef write_bit(self, bit):
         if self.bits == 8:
             self.io.write(chr(self.byte))
             self.bits = 0
@@ -82,12 +82,12 @@ cdef class BitStream:
         self.bits += 1
 
 
-    def write(BitStream self, bits, nb_bits):
+    def write(self, bits, nb_bits):
         for i in range(nb_bits):
             self.write_bit(bits >> (nb_bits - 1 - i) & 0x01)
 
 
-    def flush(BitStream self):
+    def flush(self):
         self.io.write(chr(self.byte))
         self.bits = 0
         self.byte = 0
--- a/pytouhou/utils/matrix.pxd
+++ b/pytouhou/utils/matrix.pxd
@@ -1,10 +1,10 @@
 cdef class Matrix:
     cdef public list data
 
-    cpdef flip(Matrix self)
-    cpdef scale(Matrix self, x, y, z)
-    cpdef scale2d(Matrix self, x, y)
-    cpdef translate(Matrix self, x, y, z)
-    cpdef rotate_x(Matrix self, angle)
-    cpdef rotate_y(Matrix self, angle)
-    cpdef rotate_z(Matrix self, angle)
+    cpdef flip(self)
+    cpdef scale(self, x, y, z)
+    cpdef scale2d(self, x, y)
+    cpdef translate(self, x, y, z)
+    cpdef rotate_x(self, angle)
+    cpdef rotate_y(self, angle)
+    cpdef rotate_z(self, angle)
--- a/pytouhou/utils/matrix.pyx
+++ b/pytouhou/utils/matrix.pyx
@@ -17,14 +17,14 @@ from ctypes import c_float
 
 
 cdef class Matrix:
-    def __init__(Matrix self, data=None):
+    def __init__(self, data=None):
         self.data = data or [[1, 0, 0, 0],
                              [0, 1, 0, 0],
                              [0, 0, 1, 0],
                              [0, 0, 0, 1]]
 
 
-    def __mul__(Matrix self, Matrix other):
+    def __mul__(self, Matrix other):
         out = Matrix()
         d1 = self.data
         d2 = other.data
@@ -35,25 +35,25 @@ cdef class Matrix:
         return out
 
 
-    def get_c_data(Matrix self):
+    def get_c_data(self):
         data = sum(self.data, [])
         return (c_float * 16)(*data)
 
 
-    cpdef flip(Matrix self):
+    cpdef flip(self):
         data = self.data
         a, b, c, d = data[0]
         data[0] = [-a, -b, -c, -d]
 
 
-    cpdef scale(Matrix self, x, y, z):
+    cpdef scale(self, x, y, z):
         d1 = self.data
         d1[0] = [a * x for a in d1[0]]
         d1[1] = [a * y for a in d1[1]]
         d1[2] = [a * z for a in d1[2]]
 
 
-    cpdef scale2d(Matrix self, x, y):
+    cpdef scale2d(self, x, y):
         data = self.data
         d1a, d1b, d1c, d1d = data[0]
         d2a, d2b, d2c, d2d = data[1]
@@ -61,7 +61,7 @@ cdef class Matrix:
         data[1] = [d2a * y, d2b * y, d2c * y, d2d * y]
 
 
-    cpdef translate(Matrix self, x, y, z):
+    cpdef translate(self, x, y, z):
         data = self.data
         a, b, c = data[3][:3]
         a, b, c = a * x, b * y, c * z
@@ -73,7 +73,7 @@ cdef class Matrix:
         data[2] = [d3a + c, d3b + c, d3c + c, d3d + c]
 
 
-    cpdef rotate_x(Matrix self, angle):
+    cpdef rotate_x(self, angle):
         d1 = self.data
         cos_a = cos(angle)
         sin_a = sin(angle)
@@ -81,7 +81,7 @@ cdef class Matrix:
                         [sin_a * d1[1][i] + cos_a * d1[2][i] for i in range(4)])
 
 
-    cpdef rotate_y(Matrix self, angle):
+    cpdef rotate_y(self, angle):
         d1 = self.data
         cos_a = cos(angle)
         sin_a = sin(angle)
@@ -89,7 +89,7 @@ cdef class Matrix:
                         [- sin_a * d1[0][i] + cos_a * d1[2][i] for i in range(4)])
 
 
-    cpdef rotate_z(Matrix self, angle):
+    cpdef rotate_z(self, angle):
         d1 = self.data
         cos_a = cos(angle)
         sin_a = sin(angle)