尝试进行 Qt 测试,增加了 AI 人机调试工具 _console,以及 TransPyV 进行修正

This commit is contained in:
2026-07-21 14:41:22 +08:00
parent a277ded8d4
commit 135aa05485
311 changed files with 7084 additions and 2131 deletions

View File

@@ -171,7 +171,6 @@ def compute_file_sha1(pool: memhub.MemBuddy | t.CPtr,
bytes_read: t.CInt64T = f.read_all(buf, BUF_SIZE)
f.close()
if bytes_read <= 0:
stdlib.free(buf)
return None
# 原地去除 \rCRLF → LF与 Projectrans.py 文本模式读取一致
@@ -190,21 +189,17 @@ def compute_file_sha1(pool: memhub.MemBuddy | t.CPtr,
# 计算 SHA1
ctx: hashlib.sha1 | t.CPtr = hashlib.sha1()
if ctx is None:
stdlib.free(buf)
return None
ctx.update(buf)
digest: bytes = stdlib.malloc(hashlib.SHA1_DIGEST_LEN)
if digest is None:
stdlib.free(buf)
return None
ctx.final(digest)
# 转为十六进制字符串(取前 8 字节 = 16 个十六进制字符)
hex_buf: str = stdlib.malloc(17)
if hex_buf is None:
stdlib.free(buf)
stdlib.free(digest)
return None
for i in range(8):
hi: int = (digest[i] >> 4) & 0xF
@@ -218,9 +213,6 @@ def compute_file_sha1(pool: memhub.MemBuddy | t.CPtr,
else:
hex_buf[i * 2 + 1] = 'a' + (lo - 10)
hex_buf[16] = '\0'
# 释放临时缓冲区hex_buf 由调用者负责释放)
stdlib.free(buf)
stdlib.free(digest)
return hex_buf
@@ -253,8 +245,6 @@ def scan_directory_recursive(pool: memhub.MemBuddy | t.CPtr,
handle: win32base.HANDLE = win32file.FindFirstFileA(pattern, find_data)
if handle == win32base.INVALID_HANDLE_VALUE:
stdlib.free(pattern)
stdlib.free(find_data)
return 1
# 遍历所有文件和子目录
@@ -294,7 +284,6 @@ def scan_directory_recursive(pool: memhub.MemBuddy | t.CPtr,
prefix_len = string.strlen(rel_prefix)
rel_path: bytes = stdlib.malloc(prefix_len + fname_len + 2)
if rel_path is None:
stdlib.free(full_path)
break
if rel_prefix is not None and prefix_len > 0:
viperlib.snprintf(rel_path, prefix_len + fname_len + 2, "%s/%s", rel_prefix, fname)
@@ -323,21 +312,13 @@ def scan_directory_recursive(pool: memhub.MemBuddy | t.CPtr,
sha1: str = compute_file_sha1(pool, full_path)
if sha1 is not None:
add_file_entry(result, pool, full_path, rel_path, sha1)
# 释放 compute_file_sha1 返回的临时 hex_buf
stdlib.free(sha1)
# 释放本次迭代分配的路径缓冲区
stdlib.free(full_path)
stdlib.free(rel_path)
stdio.printf(" [scan] %s -> %s\n", rel_path, sha1)
# 继续搜索下一个文件
nxt: t.CInt = win32file.FindNextFileA(handle, find_data)
if nxt == 0:
if win32file.FindNextFileA(handle, find_data) == 0:
break
win32file.FindClose(handle)
stdlib.free(pattern)
stdlib.free(find_data)
return 0
@@ -360,8 +341,7 @@ def scan_includes(pool: memhub.MemBuddy | t.CPtr,
scan_directory_recursive(pool, includes_dir, None, result)
count: t.CInt = result.Count
stdio.printf("[Phase1] 扫描完成: %d 个 .py 文件\n", count)
stdio.printf("[Phase1] 扫描完成: %d 个 .py 文件\n", result.Count)
return result