chore(comments): Test 仓注释英文化(R11)
把 81 个 .vp 文件的中文 # 注释与三引号文档串改写为简洁英文,每个连续注释块 <=2 行;运行时中文字符串字面量(testcheck.begin/print 等用户可见消息)保持原样。骨架比对 HEAD 与工作区 112 文件漂移 0,全量 77/77 顺序回归通过。
This commit is contained in:
1 parent
aa5a7e7250
commit
ee6461be46
81 files changed
+1231
-1925
No files matched your search
+40
-110
@@ -1,17 +1,13 @@
|
||||
import t, c
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyObject — 所有 Python 对象的基类
|
||||
# ============================================================
|
||||
# --- PyObject: base class of all Python objects ---
|
||||
class PyObject:
|
||||
ob_refcnt: t.CLong
|
||||
ob_type: t.CPtr
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 引用计数
|
||||
# ============================================================
|
||||
# --- Reference counting ---
|
||||
extern def Py_INCREF(op: PyObject*)
|
||||
extern def Py_DECREF(op: PyObject*)
|
||||
extern def Py_XINCREF(op: PyObject*)
|
||||
@@ -19,9 +15,7 @@ extern def Py_XDECREF(op: PyObject*)
|
||||
extern def Py_DecRef(op: PyObject*)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 解释器初始化/终止
|
||||
# ============================================================
|
||||
# --- Interpreter init/finalize ---
|
||||
extern def Py_Initialize()
|
||||
extern def Py_Finalize()
|
||||
extern def Py_InitializeEx(initsigs: int)
|
||||
@@ -29,9 +23,7 @@ extern def Py_FinalizeEx() -> int
|
||||
extern def Py_IsInitialized() -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyConfig
|
||||
# ============================================================
|
||||
# --- PyConfig ---
|
||||
class PySTATUS:
|
||||
func: const str
|
||||
err_msg: const str
|
||||
@@ -107,9 +99,7 @@ extern def Py_DecodeLocale(s: const str) -> str
|
||||
extern def PyStatus_Exception(status: PySTATUS) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 整数操作 (PyLong)
|
||||
# ============================================================
|
||||
# --- Integer ops (PyLong) ---
|
||||
extern def PyLong_FromLong(v: int) -> PyObject*
|
||||
extern def PyLong_FromUnsignedLong(v: t.CUnsignedLong) -> PyObject*
|
||||
extern def PyLong_FromLongLong(v: t.CLong) -> PyObject*
|
||||
@@ -126,17 +116,13 @@ extern def PyLong_AsSsize_t(obj: PyObject*) -> t.CPtrDiffT
|
||||
extern def PyLong_AsSize_t(obj: PyObject*) -> sizet
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 浮点数操作 (PyFloat)
|
||||
# ============================================================
|
||||
# --- Float ops (PyFloat) ---
|
||||
extern def PyFloat_FromDouble(v: double) -> PyObject*
|
||||
extern def PyFloat_AsDouble(obj: PyObject*) -> double
|
||||
extern def PyFloat_FromString(s: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 字符串操作 (PyUnicode / PyBytes)
|
||||
# ============================================================
|
||||
# --- String ops (PyUnicode / PyBytes) ---
|
||||
extern def PyUnicode_FromString(u: const str) -> PyObject*
|
||||
extern def PyUnicode_FromStringAndSize(u: const str, size: sizet) -> PyObject*
|
||||
extern def PyUnicode_FromFormat(fmt: const str) -> PyObject*
|
||||
@@ -161,9 +147,7 @@ extern def PyBytes_FromObject(o: PyObject*) -> PyObject*
|
||||
extern def PyBytes_FromFormat(fmt: const str) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 布尔 / None
|
||||
# ============================================================
|
||||
# --- Bool / None ---
|
||||
extern def PyBool_FromLong(v: t.CLong) -> PyObject*
|
||||
|
||||
Py_True: PyObject | t.CPtr | t.State
|
||||
@@ -171,9 +155,7 @@ Py_False: PyObject | t.CPtr | t.State
|
||||
Py_None: PyObject | t.CPtr | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 列表操作 (PyList)
|
||||
# ============================================================
|
||||
# --- List ops (PyList) ---
|
||||
extern def PyList_New(len: sizet) -> PyObject*
|
||||
extern def PyList_Size(lst: PyObject*) -> sizet
|
||||
extern def PyList_GetItem(lst: PyObject*, idx: sizet) -> PyObject*
|
||||
@@ -187,9 +169,7 @@ extern def PyList_Reverse(lst: PyObject*) -> int
|
||||
extern def PyList_AsTuple(lst: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 元组操作 (PyTuple)
|
||||
# ============================================================
|
||||
# --- Tuple ops (PyTuple) ---
|
||||
extern def PyTuple_New(len: sizet) -> PyObject*
|
||||
extern def PyTuple_Size(tup: PyObject*) -> sizet
|
||||
extern def PyTuple_GetItem(tup: PyObject*, idx: sizet) -> PyObject*
|
||||
@@ -198,9 +178,7 @@ extern def PyTuple_GetSlice(tup: PyObject*, lo: sizet, hi: sizet) -> PyObject*
|
||||
extern def PyTuple_Pack(n: sizet) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 字典操作 (PyDict)
|
||||
# ============================================================
|
||||
# --- Dict ops (PyDict) ---
|
||||
extern def PyDict_New() -> PyObject*
|
||||
extern def PyDict_GetItem(d: PyObject*, key: PyObject*) -> PyObject*
|
||||
extern def PyDict_GetItemString(d: PyObject*, key: const str) -> PyObject*
|
||||
@@ -220,9 +198,7 @@ extern def PyDict_Merge(d: PyObject*, other: PyObject*, override: int) -> int
|
||||
extern def PyDict_Update(d: PyObject*, other: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 对象通用操作
|
||||
# ============================================================
|
||||
# --- Object common ops ---
|
||||
extern def PyObject_Str(obj: PyObject*) -> PyObject*
|
||||
extern def PyObject_Repr(obj: PyObject*) -> PyObject*
|
||||
extern def PyObject_Type(obj: PyObject*) -> PyObject*
|
||||
@@ -254,9 +230,7 @@ extern def PyObject_GetIter(obj: PyObject*) -> PyObject*
|
||||
extern def PyIter_Next(obj: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 比较常量
|
||||
# ============================================================
|
||||
# --- Comparison constants ---
|
||||
Py_LT: int | t.State
|
||||
Py_LE: int | t.State
|
||||
Py_EQ: int | t.State
|
||||
@@ -265,9 +239,7 @@ Py_GT: int | t.State
|
||||
Py_GE: int | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 模块操作
|
||||
# ============================================================
|
||||
# --- Module ops ---
|
||||
extern def PyImport_ImportModule(name: const str) -> PyObject*
|
||||
extern def PyImport_Import(name: PyObject*) -> PyObject*
|
||||
extern def PyImport_ImportModuleLevelObject(name: PyObject*, globs: PyObject*, locs: PyObject*, fromlist: PyObject*, level: int) -> PyObject*
|
||||
@@ -277,9 +249,7 @@ extern def PyImport_GetModuleDict() -> PyObject*
|
||||
extern def PyImport_ImportModuleEx(name: const str, globs: PyObject*, locs: PyObject*, fromlist: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 模块创建
|
||||
# ============================================================
|
||||
# --- Module creation ---
|
||||
class PyMethodDef:
|
||||
ml_name: const str
|
||||
ml_meth: t.CPtr
|
||||
@@ -314,9 +284,7 @@ extern def PyModule_AddIntConstant(mod: PyObject*, name: const str, val: t.CLong
|
||||
extern def PyModule_AddStringConstant(mod: PyObject*, name: const str, val: const str) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# GIL 管理
|
||||
# ============================================================
|
||||
# --- GIL management ---
|
||||
extern def PyGILState_Ensure() -> int
|
||||
extern def PyGILState_Release(state: int): pass
|
||||
extern def PyEval_SaveThread() -> t.CPtr
|
||||
@@ -329,9 +297,7 @@ extern def PyEval_ThreadsInitialized() -> int
|
||||
extern def PyEval_InitThreads(): pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 错误处理
|
||||
# ============================================================
|
||||
# --- Error handling ---
|
||||
extern def PyErr_Occurred() -> PyObject*
|
||||
extern def PyErr_Clear(): pass
|
||||
extern def PyErr_Fetch(tp: PyObject**, val: PyObject**, tb: PyObject**): pass
|
||||
@@ -346,9 +312,7 @@ extern def PyErr_ExceptionMatches(exc: PyObject*) -> int | t.State: pass
|
||||
extern def PyErr_GivenExceptionMatches(given: PyObject*, exc: PyObject*) -> int | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内置异常类型
|
||||
# ============================================================
|
||||
# --- Built-in exception types ---
|
||||
PyExc_BaseException: PyObject | t.CPtr | t.State
|
||||
PyExc_Exception: PyObject | t.CPtr | t.State
|
||||
PyExc_TypeError: PyObject | t.CPtr | t.State
|
||||
@@ -373,16 +337,12 @@ PyExc_IsADirectoryError: PyObject | t.CPtr | t.State
|
||||
PyExc_NotADirectoryError: PyObject | t.CPtr | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内置函数
|
||||
# ============================================================
|
||||
# --- Built-in functions ---
|
||||
extern def Py_BuildValue(fmt: const str) -> PyObject*
|
||||
extern def Py_VaBuildValue(fmt: const str, va: t.CPtr) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 类型检查
|
||||
# ============================================================
|
||||
# --- Type checks ---
|
||||
extern def PyLong_Check(obj: PyObject*) -> int
|
||||
extern def PyFloat_Check(obj: PyObject*) -> int
|
||||
extern def PyUnicode_Check(obj: PyObject*) -> int
|
||||
@@ -394,9 +354,7 @@ extern def PyBool_Check(obj: PyObject*) -> int
|
||||
extern def PyNone_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内存管理
|
||||
# ============================================================
|
||||
# --- Memory management ---
|
||||
extern def PyMem_Malloc(size: sizet) -> t.CPtr
|
||||
extern def PyMem_Realloc(ptr: t.CPtr, size: sizet) -> t.CPtr
|
||||
extern def PyMem_Free(ptr: t.CPtr)
|
||||
@@ -409,18 +367,14 @@ extern def PyObject_Init(obj: PyObject*, tp: t.CPtr) -> PyObject*
|
||||
extern def PyObject_InitVar(obj: PyObject*, tp: t.CPtr, size: sizet) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 文件操作
|
||||
# ============================================================
|
||||
# --- File ops ---
|
||||
extern def PyFile_FromString(filename: const str, mode: const str) -> PyObject*
|
||||
extern def PyFile_AsFile(file: PyObject*) -> t.CPtr
|
||||
extern def PyFile_WriteObject(obj: PyObject*, file: PyObject*, flags: int) -> int
|
||||
extern def PyFile_WriteString(s: const str, file: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 编译/执行
|
||||
# ============================================================
|
||||
# --- Compile/execute ---
|
||||
extern def Py_CompileString(s: const str, filename: const str, start: int) -> PyObject*
|
||||
extern def PyEval_EvalCode(code: PyObject*, globs: PyObject*, locs: PyObject*) -> PyObject*
|
||||
extern def PyEval_EvalCodeEx(code: PyObject*, globs: PyObject*, locs: PyObject*, args: PyObject**, argc: int, kws: PyObject**, kwc: int, defs: PyObject**, defc: int, kwdefs: PyObject*, closure: PyObject*) -> PyObject*: pass
|
||||
@@ -430,9 +384,7 @@ extern def PyEval_CallFunction(callable: PyObject*, fmt: const str) -> PyObject*
|
||||
extern def PyEval_CallMethod(obj: PyObject*, method: const str, fmt: const str) -> PyObject*: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyRun
|
||||
# ============================================================
|
||||
# --- PyRun ---
|
||||
extern def PyRun_SimpleString(cmd: const str) -> int
|
||||
extern def PyRun_SimpleFile(fp: t.CPtr, filename: const str) -> int
|
||||
extern def PyRun_AnyFile(fp: t.CPtr, filename: const str) -> int
|
||||
@@ -444,9 +396,7 @@ Py_file_input: int | t.State
|
||||
Py_eval_input: int | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Capsule
|
||||
# ============================================================
|
||||
# --- Capsule ---
|
||||
extern def PyCapsule_New(ptr: t.CPtr, name: const str, dtor: t.CPtr) -> PyObject*
|
||||
extern def PyCapsule_GetPointer(cap: PyObject*, name: const str) -> t.CPtr
|
||||
extern def PyCapsule_GetName(cap: PyObject*) -> str
|
||||
@@ -456,9 +406,7 @@ extern def PyCapsule_SetName(cap: PyObject*, name: const str) -> int
|
||||
extern def PyCapsule_SetDestructor(cap: PyObject*, dtor: t.CPtr) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 序列操作
|
||||
# ============================================================
|
||||
# --- Sequence ops ---
|
||||
extern def PySequence_Check(obj: PyObject*) -> int
|
||||
extern def PySequence_Size(obj: PyObject*) -> sizet
|
||||
extern def PySequence_Length(obj: PyObject*) -> sizet
|
||||
@@ -477,9 +425,7 @@ extern def PySequence_List(obj: PyObject*) -> PyObject*
|
||||
extern def PySequence_Tuple(obj: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 映射操作
|
||||
# ============================================================
|
||||
# --- Mapping ops ---
|
||||
extern def PyMapping_Check(obj: PyObject*) -> int
|
||||
extern def PyMapping_Size(obj: PyObject*) -> sizet
|
||||
extern def PyMapping_Length(obj: PyObject*) -> sizet
|
||||
@@ -492,9 +438,7 @@ extern def PyMapping_Values(obj: PyObject*) -> PyObject*
|
||||
extern def PyMapping_Items(obj: PyObject*) -> PyObject*
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 数字操作
|
||||
# ============================================================
|
||||
# --- Number ops ---
|
||||
extern def PyNumber_Add(o1: PyObject*, o2: PyObject*) -> PyObject*
|
||||
extern def PyNumber_Subtract(o1: PyObject*, o2: PyObject*) -> PyObject*
|
||||
extern def PyNumber_Multiply(o1: PyObject*, o2: PyObject*) -> PyObject*
|
||||
@@ -518,17 +462,13 @@ extern def PyNumber_Float(obj: PyObject*) -> PyObject*
|
||||
extern def PyNumber_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 弱引用
|
||||
# ============================================================
|
||||
# --- Weak references ---
|
||||
extern def PyWeakref_NewRef(obj: PyObject*, cb: PyObject*) -> PyObject*
|
||||
extern def PyWeakref_GetObject(ref: PyObject*) -> PyObject*
|
||||
extern def PyWeakref_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 属性描述符
|
||||
# ============================================================
|
||||
# --- Property descriptors ---
|
||||
class PyGetSetDef:
|
||||
name: const str
|
||||
get: t.CPtr
|
||||
@@ -544,9 +484,7 @@ class PyMemberDef:
|
||||
doc: const str
|
||||
|
||||
|
||||
# ============================================================
|
||||
# sys 模块
|
||||
# ============================================================
|
||||
# --- sys module ---
|
||||
extern def PySys_GetObject(name: const str) -> PyObject*
|
||||
extern def PySys_SetObject(name: const str, val: PyObject*) -> int
|
||||
extern def PySys_ResetWarnOptions(): pass
|
||||
@@ -558,17 +496,13 @@ extern def PySys_FormatStdout(fmt: const str): pass
|
||||
extern def PySys_FormatStderr(fmt: const str): pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内存视图
|
||||
# ============================================================
|
||||
# --- Memory view ---
|
||||
extern def PyMemoryView_FromObject(obj: PyObject*) -> PyObject*
|
||||
extern def PyMemoryView_GetContiguous(obj: PyObject*, btype: int, order: char) -> PyObject*
|
||||
extern def PyMemoryView_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# set / frozenset
|
||||
# ============================================================
|
||||
# --- set / frozenset ---
|
||||
extern def PySet_New(iterable: PyObject*) -> PyObject*
|
||||
extern def PySet_Add(s: PyObject*, key: PyObject*) -> int
|
||||
extern def PySet_Discard(s: PyObject*, key: PyObject*) -> int
|
||||
@@ -580,9 +514,7 @@ extern def PyFrozenSet_New(iterable: PyObject*) -> PyObject*
|
||||
extern def PyFrozenSet_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# slice
|
||||
# ============================================================
|
||||
# --- slice ---
|
||||
extern def PySlice_New(start: PyObject*, stop: PyObject*, step: PyObject*) -> PyObject*
|
||||
extern def PySlice_GetIndicesEx(sl: PyObject*, length: sizet, start: sizet*, stop: sizet*, step: sizet*, slicelen: sizet*) -> int
|
||||
extern def PySlice_Unpack(sl: PyObject*, start: t.CPtrDiffT*, stop: t.CPtrDiffT*, step: t.CPtrDiffT*): pass
|
||||
@@ -590,11 +522,9 @@ extern def PySlice_AdjustIndices(length: sizet, start: t.CPtrDiffT*, stop: t.CPt
|
||||
extern def PySlice_Check(obj: PyObject*) -> int
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 类型包装类 — 带运算符重载
|
||||
# ============================================================
|
||||
# --- Type wrapper classes: operator overloading ---
|
||||
|
||||
# --- PyLongObj: Python 整数包装 ---
|
||||
# --- PyLongObj: Python integer wrapper ---
|
||||
class PyLongObj:
|
||||
ptr: PyObject*
|
||||
|
||||
@@ -637,7 +567,7 @@ class PyLongObj:
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyFloatObj: Python 浮点数包装 ---
|
||||
# --- PyFloatObj: Python float wrapper ---
|
||||
class PyFloatObj:
|
||||
ptr: PyObject*
|
||||
|
||||
@@ -685,7 +615,7 @@ class PyFloatObj:
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyUnicodeObj: Python 字符串包装 ---
|
||||
# --- PyUnicodeObj: Python string wrapper ---
|
||||
class PyUnicodeObj:
|
||||
ptr: PyObject*
|
||||
|
||||
@@ -716,7 +646,7 @@ class PyUnicodeObj:
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyListObj: Python 列表包装 ---
|
||||
# --- PyListObj: Python list wrapper ---
|
||||
class PyListObj:
|
||||
ptr: PyObject*
|
||||
|
||||
@@ -745,7 +675,7 @@ class PyListObj:
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyDictObj: Python 字典包装 ---
|
||||
# --- PyDictObj: Python dict wrapper ---
|
||||
class PyDictObj:
|
||||
ptr: PyObject*
|
||||
|
||||
|
||||
Reference in new issue
Block a user