view dwt/internal/cocoa/NSMutableArray.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.NSMutableArray;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSIndexSet;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSPredicate;
import dwt.internal.cocoa.NSRange;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSMutableArray : NSArray
{

    public this ()
    {
        super();
    }

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

    public void addObject (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_addObject_1, anObject !is null ? anObject.id_ : null);
    }

    public void addObjectsFromArray (NSArray otherArray)
    {
        OS.objc_msgSend(this.id_, OS.sel_addObjectsFromArray_1, otherArray !is null ? otherArray.id_ : null);
    }

    public static id arrayWithCapacity (NSUInteger numItems)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_arrayWithCapacity_1, numItems);
        return result !is null ? new id(result) : null;
    }

    public void exchangeObjectAtIndex (NSUInteger idx1, NSUInteger idx2)
    {
        OS.objc_msgSend(this.id_, OS.sel_exchangeObjectAtIndex_1withObjectAtIndex_1, idx1, idx2);
    }

    public void filterUsingPredicate (NSPredicate predicate)
    {
        OS.objc_msgSend(this.id_, OS.sel_filterUsingPredicate_1, predicate !is null ? predicate.id_ : null);
    }

    public NSMutableArray initWithCapacity (NSUInteger numItems)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCapacity_1, numItems);
        return result !is null ? this : null;
    }

    public void insertObject (id anObject, NSUInteger index)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertObject_1atIndex_1, anObject !is null ? anObject.id_ : null, index);
    }

    public void insertObjects (NSArray objects, NSIndexSet indexes)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertObjects_1atIndexes_1, objects !is null ? objects.id_ : null, indexes !is null ? indexes.id_ : null);
    }

    public void removeAllObjects ()
    {
        OS.objc_msgSend(this.id_, OS.sel_removeAllObjects);
    }

    public void removeLastObject ()
    {
        OS.objc_msgSend(this.id_, OS.sel_removeLastObject);
    }

    public void removeObject_ (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObject_1, anObject !is null ? anObject.id_ : null);
    }

    public void removeObject_inRange_ (id anObject, NSRange range)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObject_1inRange_1, anObject !is null ? anObject.id_ : null, range);
    }

    public void removeObjectAtIndex (NSUInteger index)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectAtIndex_1, index);
    }

    public void removeObjectIdenticalTo_ (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectIdenticalTo_1, anObject !is null ? anObject.id_ : null);
    }

    public void removeObjectIdenticalTo_inRange_ (id anObject, NSRange range)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id_ : null, range);
    }

    public void removeObjectsAtIndexes (NSIndexSet indexes)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectsAtIndexes_1, indexes !is null ? indexes.id_ : null);
    }

    public void removeObjectsFromIndices (NSUInteger* indices, NSUInteger cnt)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectsFromIndices_1numIndices_1, indices, cnt);
    }

    public void removeObjectsInArray (NSArray otherArray)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectsInArray_1, otherArray !is null ? otherArray.id_ : null);
    }

    public void removeObjectsInRange (NSRange range)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeObjectsInRange_1, range);
    }

    public void replaceObjectAtIndex (NSUInteger index, id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceObjectAtIndex_1withObject_1, index, anObject !is null ? anObject.id_ : null);
    }

    public void replaceObjectsAtIndexes (NSIndexSet indexes, NSArray objects)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceObjectsAtIndexes_1withObjects_1, indexes !is null ? indexes.id_ : null,
                objects !is null ? objects.id_ : null);
    }

    public void replaceObjectsInRange_withObjectsFromArray_ (NSRange range, NSArray otherArray)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1, range, otherArray !is null ? otherArray.id_ : null);
    }

    public void replaceObjectsInRange_withObjectsFromArray_range_ (NSRange range, NSArray otherArray, NSRange otherRange)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1range_1, range, otherArray !is null ? otherArray.id_ : null,
                otherRange);
    }

    public void setArray (NSArray otherArray)
    {
        OS.objc_msgSend(this.id_, OS.sel_setArray_1, otherArray !is null ? otherArray.id_ : null);
    }

    public void sortUsingDescriptors (NSArray sortDescriptors)
    {
        OS.objc_msgSend(this.id_, OS.sel_sortUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id_ : null);
    }
    
    public void sortUsingFunction (int function (id, id, void*) compare, void* context)
    {
        OS.objc_msgSend(this.id_, OS.sel_sortUsingFunction_1context_1, compare, context);
    }

    public void sortUsingSelector (objc.SEL comparator)
    {
        OS.objc_msgSend(this.id_, OS.sel_sortUsingSelector_1, comparator);
    }

}