修复了大量存在的问题,增加了假鸭子类型等等机制
This commit is contained in:
@@ -15,17 +15,17 @@ class zhuff_code:
|
||||
@t.Object
|
||||
class zhuff_tree:
|
||||
pool: mpool.MPool | t.CPtr
|
||||
codes: list[zhuff_code, ZHUFF_MAX_CODES]
|
||||
codes: t.CArray[zhuff_code, ZHUFF_MAX_CODES]
|
||||
count: t.CInt
|
||||
max_bits: t.CInt
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
self.pool = None
|
||||
|
||||
def build_codes(self, freqs: INTPTR, count: t.CInt, max_bits: t.CInt):
|
||||
lengths: list[t.CInt, ZHUFF_MAX_CODES]
|
||||
bl_count: list[t.CInt, ZHUFF_MAX_BITS + 1]
|
||||
next_code: list[UINT, ZHUFF_MAX_BITS + 1]
|
||||
lengths: t.CArray[t.CInt, ZHUFF_MAX_CODES]
|
||||
bl_count: t.CArray[t.CInt, ZHUFF_MAX_BITS + 1]
|
||||
next_code: t.CArray[UINT, ZHUFF_MAX_BITS + 1]
|
||||
self.count = count
|
||||
self.max_bits = max_bits
|
||||
self.build_code_lengths(lengths, freqs, count, max_bits)
|
||||
@@ -47,9 +47,9 @@ class zhuff_tree:
|
||||
self.codes[i].code = 0
|
||||
|
||||
def build_fixed_lit_tree(self):
|
||||
lengths: list[t.CInt, 288]
|
||||
bl_count: list[t.CInt, 16]
|
||||
next_code: list[t.CUnsignedInt, 16]
|
||||
lengths: t.CArray[t.CInt, 288]
|
||||
bl_count: t.CArray[t.CInt, 16]
|
||||
next_code: t.CArray[t.CUnsignedInt, 16]
|
||||
self.get_fixed_lit_lengths(lengths)
|
||||
memset(bl_count, 0, bl_count.__sizeof__())
|
||||
for i in range(288):
|
||||
@@ -71,9 +71,9 @@ class zhuff_tree:
|
||||
self.codes[i].code = 0
|
||||
|
||||
def build_fixed_dist_tree(self):
|
||||
lengths: list[t.CInt, 32]
|
||||
bl_count: list[t.CInt, 16]
|
||||
next_code: list[t.CUnsignedInt, 16]
|
||||
lengths: t.CArray[t.CInt, 32]
|
||||
bl_count: t.CArray[t.CInt, 16]
|
||||
next_code: t.CArray[t.CUnsignedInt, 16]
|
||||
self.get_fixed_dist_lengths(lengths)
|
||||
memset(bl_count, 0, bl_count.__sizeof__())
|
||||
for i in range(32):
|
||||
@@ -103,7 +103,7 @@ class zhuff_tree:
|
||||
|
||||
|
||||
def build_code_lengths(self, lengths: t.CInt | t.CPtr, freqs: t.CInt | t.CPtr, count: t.CInt, max_bits: t.CInt):
|
||||
bl_count: list[t.CInt, ZHUFF_MAX_BITS + 2]
|
||||
bl_count: t.CArray[t.CInt, ZHUFF_MAX_BITS + 2]
|
||||
sort_count: t.CInt = 0
|
||||
memset(bl_count, 0, bl_count.__sizeof__())
|
||||
memset(lengths, 0, int.__sizeof__() * count)
|
||||
@@ -272,8 +272,8 @@ class zhuff_tree:
|
||||
lengths[i] = 5
|
||||
|
||||
def build_tree_from_lengths(self, lengths: INTPTR, count: t.CInt, max_bits: t.CInt):
|
||||
bl_count: list[t.CInt, 16]
|
||||
next_code: list[t.CUnsignedInt, 16]
|
||||
bl_count: t.CArray[t.CInt, 16]
|
||||
next_code: t.CArray[t.CUnsignedInt, 16]
|
||||
|
||||
memset(bl_count, 0, bl_count.__sizeof__())
|
||||
for i in range(count):
|
||||
@@ -298,19 +298,19 @@ class zhuff_tree:
|
||||
|
||||
|
||||
class zhuff_decode_node:
|
||||
children: list[t.CInt, 2]
|
||||
children: t.CArray[t.CInt, 2]
|
||||
symbol: t.CInt
|
||||
|
||||
|
||||
@t.Object
|
||||
class zhuff_decode_tree:
|
||||
pool: mpool.MPool | t.CPtr
|
||||
nodes: list[zhuff_decode_node, 2 * ZHUFF_MAX_CODES]
|
||||
nodes: t.CArray[zhuff_decode_node, 2 * ZHUFF_MAX_CODES]
|
||||
node_count: t.CInt
|
||||
root: t.CInt
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
self.pool = None
|
||||
|
||||
def build_decode_tree(self, ht: zhuff_tree | t.CPtr):
|
||||
self.node_count = 1
|
||||
|
||||
Reference in New Issue
Block a user