Some simple information syncing
This commit is contained in:
@@ -52,71 +52,36 @@ def Load_project_config(path: str) -> int:
|
||||
global IncludesDir
|
||||
|
||||
if path is None:
|
||||
stdio.printf("[CFG] FAIL: path is None\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
if _mbuddy is None:
|
||||
stdio.printf("[CFG] FAIL: _mbuddy is None\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
|
||||
# 打开文件
|
||||
stdio.printf("[CFG] before File ctor path=%s\n", path)
|
||||
stdio.fflush(0)
|
||||
f: fileio.File | t.CPtr = fileio.File(path, fileio.MODE.R)
|
||||
f_closed_flag: int = 1
|
||||
if f is not None:
|
||||
if f.closed:
|
||||
f_closed_flag = 1
|
||||
else:
|
||||
f_closed_flag = 0
|
||||
stdio.printf("[CFG] after File ctor f=%p closed=%d\n", f, f_closed_flag)
|
||||
stdio.fflush(0)
|
||||
if f is None:
|
||||
stdio.printf("[CFG] FAIL: File ctor returned None\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
if f.closed:
|
||||
stdio.printf("[CFG] FAIL: f.closed is True\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
|
||||
# 分配读取缓冲区
|
||||
CFG_BUF_SIZE: t.CSizeT = 8192
|
||||
buf: bytes = _mbuddy.alloc(CFG_BUF_SIZE)
|
||||
if buf is None:
|
||||
stdio.printf("[CFG] FAIL: alloc buf failed\n")
|
||||
stdio.fflush(0)
|
||||
f.close()
|
||||
return 1
|
||||
|
||||
stdio.printf("[CFG] before read_all\n")
|
||||
stdio.fflush(0)
|
||||
bytes_read: t.CInt64T = f.read_all(buf, CFG_BUF_SIZE)
|
||||
f.close()
|
||||
stdio.printf("[CFG] after read_all bytes_read=%d\n", bytes_read)
|
||||
stdio.fflush(0)
|
||||
|
||||
if bytes_read <= 0:
|
||||
stdio.printf("[CFG] FAIL: bytes_read <= 0\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
|
||||
# 解析 JSON
|
||||
stdio.printf("[CFG] before json_parse\n")
|
||||
stdio.fflush(0)
|
||||
root: JsonValue | t.CPtr = json_parse(_mbuddy, buf)
|
||||
stdio.printf("[CFG] after json_parse root=%p\n", root)
|
||||
stdio.fflush(0)
|
||||
if root is None:
|
||||
stdio.printf("[CFG] FAIL: json_parse returned None\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
if not root.is_object():
|
||||
stdio.printf("[CFG] FAIL: root is not object\n")
|
||||
stdio.fflush(0)
|
||||
return 1
|
||||
stdio.printf("[CFG] root is object OK\n")
|
||||
stdio.fflush(0)
|
||||
|
||||
# 读取顶层字段(使用显式 __getitem__ 调用,兼容旧编译器二进制)
|
||||
sd_val: JsonValue | t.CPtr = root.__getitem__("source_dir")
|
||||
|
||||
Reference in New Issue
Block a user