Rewrote the comments in the libraries under 'includes' in English (excluding those inside folders)

This commit is contained in:
2026-07-29 23:34:36 +08:00
parent 3633be1995
commit a2cc28a6ab
54 changed files with 7091 additions and 899 deletions

View File

@@ -6,31 +6,31 @@ import stdio
import string
# 最大提供者栈深度(编译器会检查是否够用,不够再往上提)
# Maximum provider stack depth (compiler verifies sufficiency; increase if needed)
_MAX_PROVIDER_DEPTH: t.CDefine = 32
@t.Object
class _ProviderStack:
"""提供者栈,存储字段名和指针对。"""
"""Provider stack, stores pairs of field names and pointers."""
names: t.CArray[VOIDPTR, 32]
ptrs: t.CArray[VOIDPTR, 32]
top: UINT64
# TLS 索引(全局,所有线程共享同一个索引)
# TLS index (global; all threads share the same index)
_tls_index: ULONG = 0
@t.TLS
def _init_tls():
"""初始化 TLS 索引(一次性执行,后续调用跳过)。"""
"""Initialize TLS index (executes once; subsequent calls are skipped)."""
global _tls_index
_tls_index = TlsAlloc()
def _get_stack() -> _ProviderStack | t.CPtr:
"""获取当前线程的提供者栈,不存在则分配。"""
"""Obtain current thread's provider stack. Allocate one if none exists."""
_init_tls()
stack: _ProviderStack | t.CPtr = TlsGetValue(_tls_index)
if stack == None:
@@ -41,7 +41,7 @@ def _get_stack() -> _ProviderStack | t.CPtr:
def _push_provider(field_name: str, ptr: t.CPtr):
"""压入提供者 (field_name, ptr) 到栈中。"""
"""Push a provider (field_name, ptr) onto the stack."""
stack: _ProviderStack | t.CPtr = _get_stack()
if stack.top >= _MAX_PROVIDER_DEPTH:
stdio.printf("[with] ERROR: provider stack overflow (depth=%lu, max=%d), field '%s' not injected\n", stack.top, _MAX_PROVIDER_DEPTH, field_name)
@@ -52,16 +52,17 @@ def _push_provider(field_name: str, ptr: t.CPtr):
def _pop_provider():
"""弹出栈顶提供者。"""
"""Pop the top provider entry from the stack."""
stack: _ProviderStack | t.CPtr = _get_stack()
if stack.top > 0:
stack.top = stack.top - 1
def _find_provider(field_name: str) -> t.CPtr:
"""从栈顶向下查找匹配 field_name 的提供者,返回对应的指针。找不到返回 NULL。"""
"""Search for matching field_name starting from stack top.
Return associated pointer, or NULL if no match found."""
stack: _ProviderStack | t.CPtr = _get_stack()
for i in range(stack.top - 1, -1, -1):
if stack.names[i] == field_name:
return stack.ptrs[i]
return None
return None