Files
TransPyC/includes/ctraits.pyi
2026-07-18 19:25:40 +08:00

21 lines
572 B
Python
Raw Permalink 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.
"""ctraits — 编译时类型特征库
提供编译时类型判断函数,不纳入运行时编译。
所有函数仅在编译时求值,可与 c.CIf 等编译时条件配合使用。
"""
import t
def isptr(x: t.CType) -> bool:
"""编译时判断 x 的类型是否为指针类型。
返回 True 如果 x 是指针ptr_count > 0否则返回 False。
可与 c.CIf 配合使用实现条件编译。
示例:
if c.CIf(ctraits.isptr(my_var)):
# 仅当 my_var 是指针类型时编译此分支
...
"""
pass