Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSSet.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 |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSSet.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSSet.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,223 +1,52 @@ /******************************************************************************* - * 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.NSSet; -import dwt.internal.cocoa.id; -import dwt.internal.cocoa.NSArray; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; import dwt.internal.cocoa.NSEnumerator; -import dwt.internal.cocoa.NSInteger; -import dwt.internal.cocoa.NSKeyValueObserving; import dwt.internal.cocoa.NSObject; -import dwt.internal.cocoa.NSPredicate; -import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; -public class NSSet : NSObject -{ - - public this () - { - super(); - } - - public this (objc.id id) - { - super(id); - } - - public void addObserver (NSObject observer, NSString keyPath, NSKeyValueObservingOptions options, void* 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 class NSSet : NSObject { - public NSArray allObjects () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_allObjects); - return result !is null ? new NSArray(result) : null; - } - - public id anyObject () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_anyObject); - return result !is null ? new id(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 this() { + super(); +} - 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 NSSet filteredSetUsingPredicate (NSPredicate predicate) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_filteredSetUsingPredicate_1, predicate !is null ? predicate.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); - } - - public NSSet 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 this(objc.id id) { + super(id); +} - public NSSet 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 NSSet initWithObjects_count_ (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 NSSet initWithSet_ (NSSet set) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSet_1, set !is null ? set.id_ : null); - return result !is null ? this : null; - } - - public NSSet initWithSet_copyItems_ (NSSet set, bool flag) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSet_1copyItems_1, set !is null ? set.id_ : null, flag); - return result !is null ? this : null; - } - - public bool intersectsSet (NSSet otherSet) - { - return OS.objc_msgSend(this.id_, OS.sel_intersectsSet_1, otherSet !is null ? otherSet.id_ : null) !is null; - } +public this(cocoa.id id) { + super(id); +} - public bool isEqualToSet (NSSet otherSet) - { - return OS.objc_msgSend(this.id_, OS.sel_isEqualToSet_1, otherSet !is null ? otherSet.id_ : null) !is null; - } - - public bool isSubsetOfSet (NSSet otherSet) - { - return OS.objc_msgSend(this.id_, OS.sel_isSubsetOfSet_1, otherSet !is null ? otherSet.id_ : null) !is 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 id member (id object) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_member_1, object !is null ? object.id_ : null); - 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 void removeObserver (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 static id set () - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_set); - return result !is null ? new id(result) : null; - } - - public NSSet setByAddingObject (id anObject) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObject_1, anObject !is null ? anObject.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); - } +public NSUInteger count() { + return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_count); +} - public NSSet setByAddingObjectsFromArray (NSArray other) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObjectsFromArray_1, other !is null ? other.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); - } - - public NSSet setByAddingObjectsFromSet (NSSet other) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObjectsFromSet_1, other !is null ? other.id_ : null); - return result is this.id_ ? this : (result !is null ? new NSSet(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 static id setWithArray (NSArray array) - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithArray_1, array !is null ? array.id_ : null); - 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 static id setWithObject (id object) - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObject_1, object !is null ? object.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id static_setWithObjects_ (id setWithObjects) - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1, setWithObjects !is null ? setWithObjects.id_ : null); - return result !is null ? new id(result) : null; - } - - public static id static_setWithObjects_count_ (objc.id* objects, NSUInteger cnt) - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1count_1, objects, cnt); - return result !is null ? new id(result) : null; - } - - public static id setWithSet (NSSet set) - { - objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithSet_1, set !is null ? set.id_ : null); - return result !is null ? new id(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 static NSSet set() { + objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_set); + return result !is null ? new NSSet(result) : null; +} }