clrtype.py 文件源码

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

项目:EdgeHTTP2Fuzzer 作者: sirusdv 项目源码 文件源码
def validate_clr_types(signature_types, var_signature = False):
    if not isinstance(signature_types, tuple):
        signature_types = (signature_types,)
    for t in signature_types:
        if type(t) is type(System.IComparable): # type overloaded on generic arity, eg IComparable and IComparable[T]
            t = t[()] # select non-generic version
        clr_type = clr.GetClrType(t)
        if t == Void: 
            raise TypeError("Void cannot be used in signature")
        is_typed = clr.GetPythonType(clr_type) == t
        # is_typed needs to be weakened until the generated type
        # gets explicitly published as the underlying CLR type
        is_typed = is_typed or (hasattr(t, "__metaclass__") and t.__metaclass__ in [ClrInterface, ClrClass])
        if not is_typed:
            raise Exception, "Invalid CLR type %s" % str(t)
        if not var_signature:
            if clr_type.IsByRef:
                raise TypeError("Byref can only be used as arguments and locals")
            # ArgIterator is not present in Silverlight
            if hasattr(System, "ArgIterator") and t == System.ArgIterator:
                raise TypeError("Stack-referencing types can only be used as arguments and locals")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号