Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSArray.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | 62202ce0039f |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSArray.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSArray.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,342 +1,60 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSArray; -import dwt.internal.cocoa.id; -import dwt.internal.cocoa.NSData; -import dwt.internal.cocoa.NSEnumerator; -import dwt.internal.cocoa.NSIndexSet; -import dwt.internal.cocoa.NSInteger; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; import dwt.internal.cocoa.NSObject; -import dwt.internal.cocoa.NSPredicate; -import dwt.internal.cocoa.NSRange; -import dwt.internal.cocoa.NSString; -import dwt.internal.cocoa.NSURL; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; -public class NSArray : NSObject -{ - - public this () - { - super(); - } - - public this (objc.id id) - { - super(id); - } - - public void addObserver_forKeyPath_options_context_ (NSObject observer, NSString keyPath, objc.id options, objc.id context) - { - OS.objc_msgSend(this.id_, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id_ : null, - keyPath !is null ? keyPath.id_ : null, options, context); - } - - public void addObserver_toObjectsAtIndexes_forKeyPath_options_context_ (NSObject observer, NSIndexSet indexes, NSString keyPath, objc.id options, - objc.id context) - { - OS.objc_msgSend(this.id_, OS.sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1, observer !is null ? observer.id_ : null, - indexes !is null ? indexes.id_ : null, keyPath !is null ? keyPath.id_ : null, options, context); - } - - public static id array () - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array); - return result !is null ? new id(result) : null; - } +public class NSArray : NSObject { - public NSArray arrayByAddingObject (id anObject) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrayByAddingObject_1, anObject !is null ? anObject.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public NSArray arrayByAddingObjectsFromArray (NSArray otherArray) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_arrayByAddingObjectsFromArray_1, otherArray !is null ? otherArray.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public static id arrayWithArray (NSArray array) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithArray_1, array !is null ? array.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id arrayWithContentsOfFile (NSString path) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfFile_1, path !is null ? path.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id arrayWithContentsOfURL (NSURL url) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfURL_1, url !is null ? url.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id arrayWithObject (id anObject) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_1, anObject !is null ? anObject.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id static_arrayWithObjects_ (id arrayWithObjects) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1, arrayWithObjects !is null ? arrayWithObjects.id_ : null); - return result !is null ? new id(result) : null; - } +public this() { + super(); +} - public static id static_arrayWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt) - { - objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1count_1, objects, cnt); - return result !is null ? new id(result) : null; - } - - public NSString componentsJoinedByString (NSString separator) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_componentsJoinedByString_1, separator !is null ? separator.id_ : null); - return result !is null ? new NSString(result) : null; - } - - public bool containsObject (id anObject) - { - return OS.objc_msgSend(this.id_, OS.sel_containsObject_1, anObject !is null ? anObject.id_ : null) !is null; - } - - public NSUInteger count () - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_count); - } - - public NSString description () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_description); - return result !is null ? new NSString(result) : null; - } - - public NSString descriptionWithLocale_ (id locale) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null); - return result !is null ? new NSString(result) : null; - } - - public NSString descriptionWithLocale_indent_ (id locale, objc.id level) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id_ : null, level); - return result !is null ? new NSString(result) : null; - } +public this(objc.id id) { + super(id); +} - public NSArray filteredArrayUsingPredicate (NSPredicate predicate) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_filteredArrayUsingPredicate_1, predicate !is null ? predicate.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public id firstObjectCommonWithArray (NSArray otherArray) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_firstObjectCommonWithArray_1, otherArray !is null ? otherArray.id_ : null); - return result !is null ? new id(result) : null; - } - - public void getObjects_ (objc.id objects) - { - OS.objc_msgSend(this.id_, OS.sel_getObjects_1, objects); - } - - public void getObjects_range_ (objc.id objects, NSRange range) - { - OS.objc_msgSend(this.id_, OS.sel_getObjects_1range_1, objects, range); - } - - public NSUInteger indexOfObject_ (id anObject) - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObject_1, anObject !is null ? anObject.id_ : null); - } - - public NSUInteger indexOfObject_inRange_ (id anObject, NSRange range) - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObject_1inRange_1, anObject !is null ? anObject.id_ : null, range); - } - - public NSUInteger indexOfObjectIdenticalTo_ (id anObject) - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObjectIdenticalTo_1, anObject !is null ? anObject.id_ : null); - } - - public NSUInteger indexOfObjectIdenticalTo_inRange_ (id anObject, NSRange range) - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id_ : null, range); - } +public this(cocoa.id id) { + super(id); +} - public NSArray initWithArray_ (NSArray array) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithArray_1, array !is null ? array.id_ : null); - return result !is null ? this : null; - } - - public NSArray initWithArray_copyItems_ (NSArray array, bool flag) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithArray_1copyItems_1, array !is null ? array.id_ : null, flag); - return result !is null ? this : null; - } - - public NSArray initWithContentsOfFile (NSString path) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null); - return result !is null ? this : null; - } - - public NSArray initWithContentsOfURL (NSURL url) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null); - return result !is null ? this : null; - } - - public NSArray initWithObjects_ (id initWithObjects) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id_ : null); - return result !is null ? this : null; - } - - public NSArray initWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1count_1, objects, cnt); - return result !is null ? this : null; - } +public static NSArray array() { + objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array); + return result !is null ? new NSArray(result) : null; +} - public bool isEqualToArray (NSArray otherArray) - { - return OS.objc_msgSend(this.id_, OS.sel_isEqualToArray_1, otherArray !is null ? otherArray.id_ : null) !is null; - } - - public id lastObject () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_lastObject); - return result !is null ? new id(result) : null; - } - - public void makeObjectsPerformSelector_ (objc.SEL aSelector) - { - OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1, aSelector); - } - - public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument) - { - OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id_ : null); - } - - public objc.id objectAtIndex (NSUInteger index) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectAtIndex_1, index); - return result; - // return result !is null ? new id(result) : null; - } - - public NSEnumerator objectEnumerator () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator); - return result !is null ? new NSEnumerator(result) : null; - } - - public NSArray objectsAtIndexes (NSIndexSet indexes) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectsAtIndexes_1, indexes !is null ? indexes.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } +public static NSArray arrayWithObject(cocoa.id anObject) { + objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_, anObject !is null ? anObject.id : null); + return result !is null ? new NSArray(result) : null; +} - public NSArray pathsMatchingExtensions (NSArray filterTypes) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathsMatchingExtensions_1, filterTypes !is null ? filterTypes.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public void removeObserver_forKeyPath_ (NSObject observer, NSString keyPath) - { - OS.objc_msgSend(this.id_, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id_ : null, keyPath !is null ? keyPath.id_ : null); - } - - public void removeObserver_fromObjectsAtIndexes_forKeyPath_ (NSObject observer, NSIndexSet indexes, NSString keyPath) - { - OS.objc_msgSend(this.id_, OS.sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1, observer !is null ? observer.id_ : null, - indexes !is null ? indexes.id_ : null, keyPath !is null ? keyPath.id_ : null); - } - - public NSEnumerator reverseObjectEnumerator () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_reverseObjectEnumerator); - return result !is null ? new NSEnumerator(result) : null; - } - - public void setValue (id value, NSString key) - { - OS.objc_msgSend(this.id_, OS.sel_setValue_1forKey_1, value !is null ? value.id_ : null, key !is null ? key.id_ : null); - } - - public NSData sortedArrayHint () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayHint); - return result !is null ? new NSData(result) : null; - } - - public NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } +public bool containsObject(cocoa.id anObject) { + return OS.objc_msgSend_bool(this.id, OS.sel_containsObject_, anObject !is null ? anObject.id : null); +} - public NSArray sortedArrayUsingFunction_context_ (objc.id comparator, objc.id context) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingFunction_1context_1, comparator, context); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public NSArray sortedArrayUsingFunction_context_hint_ (objc.id comparator, objc.id context, NSData hint) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingFunction_1context_1hint_1, comparator, context, - hint !is null ? hint.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public NSArray sortedArrayUsingSelector (objc.id comparator) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_sortedArrayUsingSelector_1, comparator); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } +public NSUInteger count() { + return OS.objc_msgSend(this.id, OS.sel_count); +} - public NSArray subarrayWithRange (NSRange range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_subarrayWithRange_1, range); - return result is this.id_ ? this : (result !is null ? new NSArray(result) : null); - } - - public id valueForKey (NSString key) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForKey_1, key !is null ? key.id_ : null); - return result !is null ? new id(result) : null; - } - - public bool writeToFile (NSString path, bool useAuxiliaryFile) - { - return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null; - } - - public bool writeToURL (NSURL url, bool atomically) - { - return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null; - } +public cocoa.id objectAtIndex(NSUInteger index) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_objectAtIndex_, index); + return result !is null ? new cocoa.id(result) : null; +} }