comparison pytouhou/utils/bitstream.pyx @ 468:feecdb4a8928

Add “except *” to cdef void functions, and type some more.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 12 Sep 2013 15:47:08 +0200
parents efae61ad6efe
children 1b532e7dd521
comparison
equal deleted inserted replaced
467:5bb7d2c0ff46 468:feecdb4a8928
45 45
46 def tell2(self): 46 def tell2(self):
47 return self.io.tell(), self.bits 47 return self.io.tell(), self.bits
48 48
49 49
50 cpdef unsigned char read_bit(self): 50 cpdef unsigned char read_bit(self) except? -1:
51 if not self.bits: 51 if not self.bits:
52 self.bytes = self.io.read(1) 52 self.bytes = self.io.read(1)
53 self.byte = (<unsigned char*> self.bytes)[0] 53 self.byte = (<unsigned char*> self.bytes)[0]
54 self.bits = 8 54 self.bits = 8
55 self.bits -= 1 55 self.bits -= 1
56 return (self.byte >> self.bits) & 0x01 56 return (self.byte >> self.bits) & 0x01
57 57
58 58
59 cpdef unsigned int read(self, unsigned int nb_bits): 59 cpdef unsigned int read(self, unsigned int nb_bits) except? -1:
60 cdef unsigned int value = 0, read = 0 60 cdef unsigned int value = 0, read = 0
61 cdef unsigned int nb_bits2 = nb_bits 61 cdef unsigned int nb_bits2 = nb_bits
62 62
63 while nb_bits2: 63 while nb_bits2:
64 if not self.bits: 64 if not self.bits: