修正了部分代码的表达方式,最后可用版本,mlirlite 已基本完善
This commit is contained in:
1 parent
0d77b68cc4
commit
0f556463e7
116 files changed
+13896
-4938
No files matched your search
+9
-9
@@ -3,12 +3,12 @@ from stdint import *
|
||||
|
||||
|
||||
class Buf:
|
||||
data: t.CChar | t.CPtr
|
||||
length: t.CSizeT
|
||||
capacity: t.CSizeT
|
||||
data: char | t.CPtr
|
||||
length: sizet
|
||||
capacity: sizet
|
||||
owned: bool
|
||||
|
||||
def __init__(self, data: t.CChar | t.CPtr, capacity: t.CSizeT, length: t.CSizeT = 0, owned: bool = False):
|
||||
def __init__(self, data: char | t.CPtr, capacity: sizet, length: sizet = 0, owned: bool = False):
|
||||
self.data = data
|
||||
self.capacity = capacity
|
||||
self.length = length
|
||||
@@ -19,14 +19,14 @@ class Buf:
|
||||
if self.data != None and self.capacity > 0:
|
||||
self.data[0] = 0
|
||||
|
||||
def write(self, src: t.CChar | t.CPtr, count: t.CSizeT) -> t.CSizeT:
|
||||
def write(self, src: char | t.CPtr, count: sizet) -> sizet:
|
||||
if self.data == None: return 0
|
||||
if src == None: return 0
|
||||
if count == 0: return 0
|
||||
avail: t.CSizeT = self.capacity - self.length
|
||||
avail: sizet = self.capacity - self.length
|
||||
if avail <= 0: return 0
|
||||
n: t.CSizeT = count if count < avail else avail
|
||||
i: t.CSizeT = 0
|
||||
n: sizet = count if count < avail else avail
|
||||
i: sizet = 0
|
||||
while i < n:
|
||||
self.data[self.length + i] = src[i]
|
||||
i += 1
|
||||
@@ -36,7 +36,7 @@ class Buf:
|
||||
self.data[self.length] = 0
|
||||
return n
|
||||
|
||||
def cstr(self) -> t.CChar | t.CPtr:
|
||||
def cstr(self) -> char | t.CPtr:
|
||||
return self.data
|
||||
|
||||
def reset(self):
|
||||
|
||||
Reference in new issue
Block a user