mapped_struct.py 文件源码

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

项目:sharedbuffers 作者: jampp 项目源码 文件源码
def register_schema(cls, typ, schema, typecode):
        if typecode is not None and typ in cls.TYPE_CODES:
            if cls.TYPE_CODES[typ] != typecode or cls.OBJ_PACKERS[typecode][2].schema is not schema:
                raise ValueError("Registering different types with same typecode %r: %r" % (cls.TYPE_CODES[typ], typ))
            return cls.OBJ_PACKERS[typecode][2]

        if isinstance(typ, mapped_object_with_schema):
            packable = typ
        else:
            packable = mapped_object_with_schema(schema)
        class SchemaBufferProxyProperty(GenericBufferProxyProperty):
            typ = packable
        if typecode is not None:
            cls.TYPE_CODES[typ] = typecode
            cls.TYPE_CODES[packable] = typecode
            cls.OBJ_PACKERS[typecode] = (packable.pack_into, packable.unpack_from, packable)
        TYPES[typ] = packable
        TYPES[packable] = packable
        PROXY_TYPES[typ] = SchemaBufferProxyProperty
        PROXY_TYPES[packable] = SchemaBufferProxyProperty
        return packable
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号