objc.py 文件源码

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

项目:pythonista-scripts 作者: khilnani 项目源码 文件源码
def __call__(self, *args, **kwargs):
        type_encoding = c.method_getTypeEncoding(self.method)
        type_parser = kwargs.get('type_parser', parse_types)
        restype, argtypes = type_parser(type_encoding)
        if restype and issubclass(restype, Structure) and not LP64:
            retval = restype()
            c.objc_msgSend_stret.argtypes = [c_void_p] + argtypes
            c.objc_msgSend_stret.restype = None
            c.objc_msgSend_stret(ctypes.byref(retval), self.obj.ptr, sel(self.sel_name), *args)
            return retval
        else:
            c.objc_msgSend.argtypes = argtypes
            c.objc_msgSend.restype = restype
            res = c.objc_msgSend(self.obj.ptr, sel(self.sel_name), *args)
            if res and type_encoding[0] == '@':
                if res == self.obj.ptr:
                    return self.obj
                # If an object is returned, wrap the pointer in an ObjCInstance:
                return ObjCInstance(res)
            return res

#Some commonly-used Foundation classes:
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号