icrate 0.0.1

Bindings to Apple's frameworks
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use crate::common::*;
use crate::Foundation::*;

pub type NSSocketNativeHandle = c_int;

extern_static!(NSPortDidBecomeInvalidNotification: &'static NSNotificationName);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSPort;

    unsafe impl ClassType for NSPort {
        type Super = NSObject;
    }
);

extern_methods!(
    unsafe impl NSPort {
        #[method_id(@__retain_semantics Other port)]
        pub unsafe fn port() -> Id<NSPort, Shared>;

        #[method(invalidate)]
        pub unsafe fn invalidate(&self);

        #[method(isValid)]
        pub unsafe fn isValid(&self) -> bool;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(&self, anObject: Option<&NSPortDelegate>);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<NSPortDelegate, Shared>>;

        #[method(scheduleInRunLoop:forMode:)]
        pub unsafe fn scheduleInRunLoop_forMode(&self, runLoop: &NSRunLoop, mode: &NSRunLoopMode);

        #[method(removeFromRunLoop:forMode:)]
        pub unsafe fn removeFromRunLoop_forMode(&self, runLoop: &NSRunLoop, mode: &NSRunLoopMode);

        #[method(reservedSpaceLength)]
        pub unsafe fn reservedSpaceLength(&self) -> NSUInteger;

        #[method(sendBeforeDate:components:from:reserved:)]
        pub unsafe fn sendBeforeDate_components_from_reserved(
            &self,
            limitDate: &NSDate,
            components: Option<&NSMutableArray>,
            receivePort: Option<&NSPort>,
            headerSpaceReserved: NSUInteger,
        ) -> bool;

        #[method(sendBeforeDate:msgid:components:from:reserved:)]
        pub unsafe fn sendBeforeDate_msgid_components_from_reserved(
            &self,
            limitDate: &NSDate,
            msgID: NSUInteger,
            components: Option<&NSMutableArray>,
            receivePort: Option<&NSPort>,
            headerSpaceReserved: NSUInteger,
        ) -> bool;

        #[method(addConnection:toRunLoop:forMode:)]
        pub unsafe fn addConnection_toRunLoop_forMode(
            &self,
            conn: &NSConnection,
            runLoop: &NSRunLoop,
            mode: &NSRunLoopMode,
        );

        #[method(removeConnection:fromRunLoop:forMode:)]
        pub unsafe fn removeConnection_fromRunLoop_forMode(
            &self,
            conn: &NSConnection,
            runLoop: &NSRunLoop,
            mode: &NSRunLoopMode,
        );
    }
);

extern_protocol!(
    pub struct NSPortDelegate;

    unsafe impl ProtocolType for NSPortDelegate {
        #[optional]
        #[method(handlePortMessage:)]
        pub unsafe fn handlePortMessage(&self, message: &NSPortMessage);
    }
);

ns_options!(
    #[underlying(NSUInteger)]
    pub enum NSMachPortOptions {
        NSMachPortDeallocateNone = 0,
        NSMachPortDeallocateSendRight = 1 << 0,
        NSMachPortDeallocateReceiveRight = 1 << 1,
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSMachPort;

    unsafe impl ClassType for NSMachPort {
        #[inherits(NSObject)]
        type Super = NSPort;
    }
);

extern_methods!(
    unsafe impl NSMachPort {
        #[method_id(@__retain_semantics Other portWithMachPort:)]
        pub unsafe fn portWithMachPort(machPort: u32) -> Id<NSPort, Shared>;

        #[method_id(@__retain_semantics Init initWithMachPort:)]
        pub unsafe fn initWithMachPort(
            this: Option<Allocated<Self>>,
            machPort: u32,
        ) -> Id<Self, Shared>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(&self, anObject: Option<&NSMachPortDelegate>);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<NSMachPortDelegate, Shared>>;

        #[method_id(@__retain_semantics Other portWithMachPort:options:)]
        pub unsafe fn portWithMachPort_options(
            machPort: u32,
            f: NSMachPortOptions,
        ) -> Id<NSPort, Shared>;

        #[method_id(@__retain_semantics Init initWithMachPort:options:)]
        pub unsafe fn initWithMachPort_options(
            this: Option<Allocated<Self>>,
            machPort: u32,
            f: NSMachPortOptions,
        ) -> Id<Self, Shared>;

        #[method(machPort)]
        pub unsafe fn machPort(&self) -> u32;

        #[method(scheduleInRunLoop:forMode:)]
        pub unsafe fn scheduleInRunLoop_forMode(&self, runLoop: &NSRunLoop, mode: &NSRunLoopMode);

        #[method(removeFromRunLoop:forMode:)]
        pub unsafe fn removeFromRunLoop_forMode(&self, runLoop: &NSRunLoop, mode: &NSRunLoopMode);
    }
);

extern_protocol!(
    pub struct NSMachPortDelegate;

    unsafe impl ProtocolType for NSMachPortDelegate {
        #[optional]
        #[method(handleMachMessage:)]
        pub unsafe fn handleMachMessage(&self, msg: NonNull<c_void>);
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSMessagePort;

    unsafe impl ClassType for NSMessagePort {
        #[inherits(NSObject)]
        type Super = NSPort;
    }
);

extern_methods!(
    unsafe impl NSMessagePort {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSSocketPort;

    unsafe impl ClassType for NSSocketPort {
        #[inherits(NSObject)]
        type Super = NSPort;
    }
);

extern_methods!(
    unsafe impl NSSocketPort {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Option<Allocated<Self>>) -> Id<Self, Shared>;

        #[method_id(@__retain_semantics Init initWithTCPPort:)]
        pub unsafe fn initWithTCPPort(
            this: Option<Allocated<Self>>,
            port: c_ushort,
        ) -> Option<Id<Self, Shared>>;

        #[method_id(@__retain_semantics Init initWithProtocolFamily:socketType:protocol:address:)]
        pub unsafe fn initWithProtocolFamily_socketType_protocol_address(
            this: Option<Allocated<Self>>,
            family: c_int,
            type_: c_int,
            protocol: c_int,
            address: &NSData,
        ) -> Option<Id<Self, Shared>>;

        #[method_id(@__retain_semantics Init initWithProtocolFamily:socketType:protocol:socket:)]
        pub unsafe fn initWithProtocolFamily_socketType_protocol_socket(
            this: Option<Allocated<Self>>,
            family: c_int,
            type_: c_int,
            protocol: c_int,
            sock: NSSocketNativeHandle,
        ) -> Option<Id<Self, Shared>>;

        #[method_id(@__retain_semantics Init initRemoteWithTCPPort:host:)]
        pub unsafe fn initRemoteWithTCPPort_host(
            this: Option<Allocated<Self>>,
            port: c_ushort,
            hostName: Option<&NSString>,
        ) -> Option<Id<Self, Shared>>;

        #[method_id(@__retain_semantics Init initRemoteWithProtocolFamily:socketType:protocol:address:)]
        pub unsafe fn initRemoteWithProtocolFamily_socketType_protocol_address(
            this: Option<Allocated<Self>>,
            family: c_int,
            type_: c_int,
            protocol: c_int,
            address: &NSData,
        ) -> Id<Self, Shared>;

        #[method(protocolFamily)]
        pub unsafe fn protocolFamily(&self) -> c_int;

        #[method(socketType)]
        pub unsafe fn socketType(&self) -> c_int;

        #[method(protocol)]
        pub unsafe fn protocol(&self) -> c_int;

        #[method_id(@__retain_semantics Other address)]
        pub unsafe fn address(&self) -> Id<NSData, Shared>;

        #[method(socket)]
        pub unsafe fn socket(&self) -> NSSocketNativeHandle;
    }
);