extract_enums.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pg_query 作者: lelit 项目源码 文件源码
def determine_enum_type_and_value(enum):
    type = 'IntEnum'
    value = int_enum_value_factory

    for item in enum.values.enumerators:
        if item.value:
            if isinstance(item.value, c_ast.Constant) and item.value.type == 'char':
                type = 'str, Enum'
                value = char_enum_value_factory
                break
            elif isinstance(item.value, c_ast.BinaryOp) and item.value.op == '<<':
                type = 'IntFlag'
                break

    return type, value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号