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:
评论列表
文章目录