view dwt/internal/cocoa/NSPort.d @ 13:f565d3a95c0a

Ported dwt.internal
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 22 Aug 2008 16:46:34 +0200
parents 8b48be5454ce
children
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSPort;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSConnection;
import dwt.internal.cocoa.NSDate;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMutableArray;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSRunLoop;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSZone;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

alias int NSSocketNativeHandle;

public class NSPort : NSObject
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public void addConnection (NSConnection conn, NSRunLoop runLoop, NSString mode)
    {
        OS.objc_msgSend(this.id_, OS.sel_addConnection_1toRunLoop_1forMode_1, conn !is null ? conn.id_ : null, runLoop !is null ? runLoop.id_ : null,
                mode !is null ? mode.id_ : null);
    }

    public static id allocWithZone (NSZone* zone)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPort, OS.sel_allocWithZone_1, zone);
        return result !is null ? new id(result) : null;
    }

    public id delegatee ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
        return result !is null ? new id(result) : null;
    }

    public void invalidate ()
    {
        OS.objc_msgSend(this.id_, OS.sel_invalidate);
    }

    public bool isValid ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isValid) !is null;
    }

    public static NSPort port ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPort, OS.sel_port);
        return result !is null ? new NSPort(result) : null;
    }

    public void removeConnection (NSConnection conn, NSRunLoop runLoop, NSString mode)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeConnection_1fromRunLoop_1forMode_1, conn !is null ? conn.id_ : null,
                runLoop !is null ? runLoop.id_ : null, mode !is null ? mode.id_ : null);
    }

    public void removeFromRunLoop (NSRunLoop runLoop, NSString mode)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeFromRunLoop_1forMode_1, runLoop !is null ? runLoop.id_ : null, mode !is null ? mode.id_ : null);
    }

    public NSUInteger reservedSpaceLength ()
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_reservedSpaceLength);
    }

    public void scheduleInRunLoop (NSRunLoop runLoop, NSString mode)
    {
        OS.objc_msgSend(this.id_, OS.sel_scheduleInRunLoop_1forMode_1, runLoop !is null ? runLoop.id_ : null, mode !is null ? mode.id_ : null);
    }

    public bool sendBeforeDate_components_from_reserved_ (NSDate limitDate, NSMutableArray components, NSPort receivePort, NSUInteger headerSpaceReserved)
    {
        return OS.objc_msgSend(this.id_, OS.sel_sendBeforeDate_1components_1from_1reserved_1, limitDate !is null ? limitDate.id_ : null,
                components !is null ? components.id_ : null, receivePort !is null ? receivePort.id_ : null, headerSpaceReserved) !is null;
    }

    public bool sendBeforeDate_msgid_components_from_reserved_ (NSDate limitDate, NSUInteger msgID, NSMutableArray components, NSPort receivePort,
                                                                NSUInteger headerSpaceReserved)
    {
        return OS.objc_msgSend(this.id_, OS.sel_sendBeforeDate_1msgid_1components_1from_1reserved_1, limitDate !is null ? limitDate.id_ : null, msgID,
                components !is null ? components.id_ : null, receivePort !is null ? receivePort.id_ : null, headerSpaceReserved) !is null;
    }

    public void setDelegate (id anId)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anId !is null ? anId.id_ : null);
    }

}