view dwt/internal/cocoa/NSIndexPath.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
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.NSIndexPath;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSComparisonResult;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSIndexPath : NSObject
{

    public this ()
    {
        super();
    }

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

    public NSComparisonResult compare (NSIndexPath otherObject)
    {
        return cast(NSComparisonResult) OS.objc_msgSend(this.id_, OS.sel_compare_1, otherObject !is null ? otherObject.id_ : null);
    }

    public void getIndexes (NSUInteger* indexes)
    {
        OS.objc_msgSend(this.id_, OS.sel_getIndexes_1, indexes);
    }

    public NSUInteger indexAtPosition (NSUInteger position)
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexAtPosition_1, position);
    }

    public NSIndexPath indexPathByAddingIndex (NSUInteger index)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_indexPathByAddingIndex_1, index);
        return result is this.id_ ? this : (result !is null ? new NSIndexPath(result) : null);
    }

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

    public static id indexPathWithIndex (NSUInteger index)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSIndexPath, OS.sel_indexPathWithIndex_1, index);
        return result !is null ? new id(result) : null;
    }

    public static id indexPathWithIndexes (NSUInteger* indexes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSIndexPath, OS.sel_indexPathWithIndexes_1length_1, indexes, length);
        return result !is null ? new id(result) : null;
    }

    public id initWithIndex (NSUInteger index)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithIndex_1, index);
        return result !is null ? new id(result) : null;
    }

    public id initWithIndexes (NSUInteger* indexes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithIndexes_1length_1, indexes, length);
        return result !is null ? new id(result) : null;
    }

    public NSUInteger length ()
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length);
    }

}