(self, pointer, restype=AUTO, *argtypes)
The constructor takes a block object, which can be either an :class:`ObjCInstance`, or a raw
        :class:`~rubicon.objc.runtime.objc_id` pointer.

        .. note::

            :class:`~rubicon.objc.runtime.objc_block` is also accepted, because it is a subclass of
            :class:`~rubicon.objc.runtime.objc_id`). Normally you do not need to make use of this,
            because in most cases Rubicon will automatically convert :class:`~rubicon.objc.runtime.objc_block`\\s
            to a callable object.

        In most cases, Rubicon can automatically determine the block's return type and parameter types.
        If a block object doesn't have return/parameter type information at runtime, Rubicon will raise an error when
        attempting to convert it. In that case, you need to explicitly pass the correct return type and parameter types
        to :class:`ObjCBlock` using the ``restype`` and ``argtypes`` parameters.
The constructor takes a block object, which can be either an :class:`ObjCInstance`, or a raw
        :class:`~rubicon.objc.runtime.objc_id` pointer.
The constructor takes a block object which can be either an : class : ObjCInstance or a raw : class : ~rubicon . objc . runtime . objc_id pointer .
def __init__(self, pointer, restype=AUTO, *argtypes):
        """The constructor takes a block object, which can be either an :class:`ObjCInstance`, or a raw
        :class:`~rubicon.objc.runtime.objc_id` pointer.

        .. note::

            :class:`~rubicon.objc.runtime.objc_block` is also accepted, because it is a subclass of
            :class:`~rubicon.objc.runtime.objc_id`). Normally you do not need to make use of this,
            because in most cases Rubicon will automatically convert :class:`~rubicon.objc.runtime.objc_block`\\s
            to a callable object.

        In most cases, Rubicon can automatically determine the block's return type and parameter types.
        If a block object doesn't have return/parameter type information at runtime, Rubicon will raise an error when
        attempting to convert it. In that case, you need to explicitly pass the correct return type and parameter types
        to :class:`ObjCBlock` using the ``restype`` and ``argtypes`` parameters.
        """

        if isinstance(pointer, ObjCInstance):
            pointer = pointer.ptr
        self.pointer = pointer
        self.struct = cast(self.pointer, POINTER(ObjCBlockStruct))
        self.has_helpers = self.struct.contents.flags & BlockConsts.HAS_COPY_DISPOSE
        self.has_signature = self.struct.contents.flags & BlockConsts.HAS_SIGNATURE
        self.descriptor = cast_block_descriptor(self)
        self.signature = self.descriptor.contents.signature if self.has_signature else None
        if restype is AUTO:
            if argtypes:
                raise ValueError('Cannot use argtypes with restype AUTO')
            if not self.has_signature:
                raise ValueError('Cannot use AUTO types for blocks without signatures')
            restype, *argtypes = ctypes_for_method_encoding(self.signature)
        self.struct.contents.invoke.restype = ctype_for_type(restype)
        self.struct.contents.invoke.argtypes = (objc_id, ) + tuple(ctype_for_type(arg_type) for arg_type in argtypes)
def __init__ ( self , pointer , restype = AUTO , * argtypes ) : if isinstance ( pointer , ObjCInstance ) : pointer = pointer . ptr self . pointer = pointer self . struct = cast ( self . pointer , POINTER ( ObjCBlockStruct ) ) self . has_helpers = self . struct . contents . flags & BlockConsts . HAS_COPY_DISPOSE self . has_signature = self . struct . contents . flags & BlockConsts . HAS_SIGNATURE self . descriptor = cast_block_descriptor ( self ) self . signature = self . descriptor . contents . signature if self . has_signature else None if restype is AUTO : if argtypes : raise ValueError ( 'Cannot use argtypes with restype AUTO' ) if not self . has_signature : raise ValueError ( 'Cannot use AUTO types for blocks without signatures' ) restype , * argtypes = ctypes_for_method_encoding ( self . signature ) self . struct . contents . invoke . restype = ctype_for_type ( restype ) self . struct . contents . invoke . argtypes = ( objc_id , ) + tuple ( ctype_for_type ( arg_type ) for arg_type in argtypes )