Files
TransPyV/App/lib/__init__.py

29 lines
820 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import t, c
from stdint import *
import memhub
import lib.core.VLogger as VLogger
# ============================================================
# lib 包入口 - 声明全局 _mbuddy 内存池指针
# ============================================================
# 全局 mbuddy 内存池指针(由 App/main.py 初始化后注入)
# 注意: 使用 MemBuddy 类型而非 MemManager避免虚函数分派不工作时调用父类 alloc 返回 None
_mbuddy: memhub.MemBuddy | t.CPtr
def InitLib(mb: memhub.MemBuddy | t.CPtr) -> int:
"""初始化 lib 包的全局 _mbuddy 指针,并级联注入到所有子模块。
Args:
mb: memhub.MemBuddy 实例指针
Returns:
0 表示成功,非 0 表示失败
"""
if mb is None:
return 1
VLogger._mbuddy = mb
return 0