Exemplo n.º 1
0
def objc_super(_self, _sel, *args, **kwargs):
    signature = getattr(kwargs, "signature", "@")
    restype, argtypes = decode_method_signature(signature)
    restype, argtypes = decode_method(argtypes=argtypes, restype=restype)
    su = get_super_struct(_self)
    argtypes = [POINTER(objc_super_struct), c_void_p]  # + argtypes
    objc_msgSendSuper.argtypes = argtypes
    objc_msgSendSuper.restype = c_void_p  # = restype
    return objc_msgSendSuper(byref(su), _sel)
Exemplo n.º 2
0
    def __init__(self, klass, sel_name):
        self.sel_name = sel_name
        self.sel = SEL(sel_name)
        self.class_ptr = klass._ptr
        self.klass = klass
        self.instance_ptr = klass._instance
        self.method = class_getInstanceMethod(self.class_ptr, self.sel)
        self._objc_msgSend = None

        signature = method_getTypeEncoding(self.method).decode()
        self.restype, self.argtypes = decode_method_signature(signature)
Exemplo n.º 3
0
    def __init__(self, klass, sel_name):
        self.sel_name = sel_name
        self.sel = SEL(sel_name)
        self.class_ptr = klass._ptr
        self.klass = klass
        self.method = class_getClassMethod(self.class_ptr, self.sel)
        self._objc_msgSend = None

        self.sig = method_getTypeEncoding(self.method).decode()
        self.restype, self.argtypes = decode_method_signature(self.sig)
        self.crestype, self.cargtypes = decode_method(argtypes=self.argtypes,
                                                      restype=self.restype)
Exemplo n.º 4
0
    def __init__(self, func):
        argtypes = func.__annotations__
        sigit = []
        if 'return' in argtypes:
            sigit.append(argtypes.pop('return'))
        else:
            sigit.append('v')
        sigit.extend(argtypes.values())
        signature = ''.join(sigit)
        restype, argtypes = decode_method_signature(signature)
        restype, argtypes = decode_method(argtypes=argtypes, restype=restype)
        InvokeFuncType = CFUNCTYPE(restype, *argtypes)
        self.invoke_method = InvokeFuncType(func)

        class Block_literal_1(Structure):
            _fields_ = [
                ('isa', c_void_p),
                ('flags', c_int),
                ('reserved', c_int),
                ('invoke', InvokeFuncType),
                ('descriptor', POINTER(Block_descriptor_1)),
            ]

        self._ctype = Block_literal_1
        block = Block_literal_1()
        klass = objc_getClass('__NSGlobalBlock'.encode())
        block.isa = klass
        # print(BLOCK_IS_GLOBAL | BLOCK_HAS_STRET)
        block.flags = 0x50000000  # BLOCK_IS_GLOBAL | BLOCK_HAS_STRET
        print(block.flags)
        block.reserved = 0
        block.invoke = self.invoke_method
        descriptor = Block_descriptor_1()
        descriptor.reserved = 0
        descriptor.size = sizeof(Block_literal_1)
        # descriptor.copy_helper = None
        # descriptor.dispose_helper = None
        descriptor.signature = signature.encode()
        block.descriptor = pointer(descriptor)
        self.block = block
        self._as_paramater_ = block
Exemplo n.º 5
0
        def __init__(self, function):
            self.func = function
            if self._funcname is None:
                self._funcname = function.__name__.replace("_", ":")
            if self._restype is None:
                self._restype = function.__annotations__['return'] \
                    if 'return' in function.__annotations__ else 'v'
            if self._argtypes is None:
                a = ['@', ':']
                for k, v in function.__annotations__.items():
                    if k == 'return':
                        continue
                    a.append(v if v else '?')
                self._argtypes = a
            self._signature = self._restype + "".join(self._argtypes)
            restype, argtypes = decode_method_signature(self._signature)
            restype, argtypes = decode_method(argtypes=argtypes,
                                              restype=restype)

            if self._cFunc is None:
                self._cFuncType = CFUNCTYPE(restype, *argtypes)
                self._cFunc = self._cFuncType(self.func)