Beispiel #1
0
def describe_type(typestr):

    nm = basic_types.get(typestr)
    if nm is not None:
        return nm

    if typestr == b"^?":
        return "<FUNCTION>"
    elif typestr == b"@?":
        return "<BLOCK>"

    if typestr.startswith(objc._C_PTR):
        nm = _nameForSignature(typestr)
        if nm is not None:
            return nm
        return describe_type(typestr[1:]) + '*'

    if typestr[:1] in prefixes:
        return prefixes[typestr[:1]] + describe_type(typestr[1:])

    if typestr.startswith(objc._C_STRUCT_B):
        nm = _nameForSignature(typestr)
        if nm is not None:
            return nm

        typestr = typestr[1:]
        idx = typestr.find(b'=')
        if idx == -1:
            return 'struct <?>'

        else:
            nm = typestr[:idx]
            if not nm:
                nm = b'<?>'
            return 'struct %s'%(nm.decode('utf-8'),)


    if typestr.startswith(objc._C_ARY_B):
        typestr = typestr[1:]
        d = b''
        while typestr[:1].isdigit():
            d += typestr[:1]
            typestr = typestr[1:]

        return '%s[%s]' % (describe_type(typestr), d.decode('utf-8'))

    if typestr.startswith(objc._C_UNION_B):
        typestr = typestr[1:]
        idx = typestr.find(b'=')
        if idx == -1:
            return 'union <?>'

        else:
            nm = typestr[:idx]
            if not nm:
                nm = b'<?>'
            return 'union %s'%(nm.decode('utf-8'),)

    return "<?>"
def describe_type(typestr):

    nm = basic_types.get(typestr)
    if nm is not None:
        return nm

    if typestr == b"^?":
        return "<FUNCTION>"
    elif typestr == b"@?":
        return "<BLOCK>"

    if typestr.startswith(objc._C_PTR):
        nm = _nameForSignature(typestr)
        if nm is not None:
            return nm
        return describe_type(typestr[1:]) + '*'

    if typestr[:1] in prefixes:
        return prefixes[typestr[:1]] + describe_type(typestr[1:])

    if typestr.startswith(objc._C_STRUCT_B):
        nm = _nameForSignature(typestr)
        if nm is not None:
            return nm

        typestr = typestr[1:]
        idx = typestr.find(b'=')
        if idx == -1:
            return 'struct <?>'

        else:
            nm = typestr[:idx]
            if not nm:
                nm = b'<?>'
            return 'struct %s'%(nm.decode('utf-8'),)


    if typestr.startswith(objc._C_ARY_B):
        typestr = typestr[1:]
        d = b''
        while typestr[:1].isdigit():
            d += typestr[:1]
            typestr = typestr[1:]

        return '%s[%s]' % (describe_type(typestr), d.decode('utf-8'))

    if typestr.startswith(objc._C_UNION_B):
        typestr = typestr[1:]
        idx = typestr.find(b'=')
        if idx == -1:
            return 'union <?>'

        else:
            nm = typestr[:idx]
            if not nm:
                nm = b'<?>'
            return 'union %s'%(nm.decode('utf-8'),)

    return "<?>"