2015-07-17 02:19:29 +03:00
|
|
|
from libc.stdint cimport uint64_t
|
2015-07-27 22:16:49 +03:00
|
|
|
from libc.stdint cimport int32_t, uint32_t
|
2015-07-17 02:19:29 +03:00
|
|
|
|
|
|
|
ctypedef unsigned char uchar
|
|
|
|
|
|
|
|
|
|
|
|
cdef struct Code:
|
|
|
|
uint64_t bits
|
|
|
|
char length
|
|
|
|
|
|
|
|
|
|
|
|
cdef Code bit_append(Code code, bint bit) nogil
|
|
|
|
|
|
|
|
|
|
|
|
cdef class BitArray:
|
2015-07-24 04:48:23 +03:00
|
|
|
cdef bytearray data
|
2015-07-17 02:19:29 +03:00
|
|
|
cdef uchar byte
|
|
|
|
cdef uchar bit_of_byte
|
|
|
|
cdef uint32_t i
|
|
|
|
|
|
|
|
cdef int extend(self, uint64_t code, char n_bits) except -1
|
2015-07-17 22:20:48 +03:00
|
|
|
|
2015-07-27 22:16:49 +03:00
|
|
|
cpdef int32_t read32(self) except 0
|