Mercurial > projects > dstep
view dstep/foundation/NSSet.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSSet; import dstep.foundation.NSArray; import dstep.foundation.NSCoder; import dstep.foundation.NSDictionary; import dstep.foundation.NSEnumerator; import dstep.foundation.NSKeyValueObserving; import dstep.foundation.NSObject; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSPredicate; import dstep.foundation.NSString; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; const TNSSetCreation = ` static Object set () { return invokeObjcSuperClass!(Object, "set"); } static Object setWithObject (Object object) { return invokeObjcSuperClass!(Object, "setWithObject:", Object)(object); } static Object setWithObjects (id* objects, NSUInteger cnt) { return invokeObjcSuperClass!(Object, "setWithObjects:count:", id*, NSUInteger)(objects, cnt); } static Object setWithObjects (Object setWithObjects, ...) { return invokeObjcSuperClass!(Object, "setWithObjects:", Object)(setWithObjects); } static Object setWithSet (NSSet set) { return invokeObjcSuperClass!(Object, "setWithSet:", NSSet)(set); } static Object setWithArray (NSArray array) { return invokeObjcSuperClass!(Object, "setWithArray:", NSArray)(array); } Object initWithObjects (id* objects, NSUInteger cnt) { return invokeObjcSelf!(Object, "initWithObjects:count:", id*, NSUInteger)(objects, cnt); } this (id* objects, NSUInteger cnt) { typeof(this).alloc.initWithObjects(objects, cnt); } Object initWithObjects (Object initWithObjects, ...) { return invokeObjcSelf!(Object, "initWithObjects:", Object)(initWithObjects); } this (Object initWithObjects, ...) { typeof(this).alloc.initWithObjects(initWithObjects); } Object initWithSet (NSSet set) { return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); } this (NSSet set) { typeof(this).alloc.initWithSet(set); } Object initWithSet (NSSet set, bool flag) { return invokeObjcSelf!(Object, "initWithSet:copyItems:", NSSet, bool)(set, flag); } this (NSSet set, bool flag) { typeof(this).alloc.initWithSet(set, flag); } Object initWithArray (NSArray array) { return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); } this (NSArray array) { typeof(this).alloc.initWithArray(array); } `; const TNSExtendedSet = ` NSArray allObjects () { return invokeObjcSelf!(NSArray, "allObjects"); } Object anyObject () { return invokeObjcSelf!(Object, "anyObject"); } bool containsObject (Object anObject) { return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); } NSString description () { return invokeObjcSelf!(NSString, "description"); } NSString descriptionWithLocale (Object locale) { return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); } bool intersectsSet (NSSet otherSet) { return invokeObjcSelf!(bool, "intersectsSet:", NSSet)(otherSet); } bool isEqualToSet (NSSet otherSet) { return invokeObjcSelf!(bool, "isEqualToSet:", NSSet)(otherSet); } bool isSubsetOfSet (NSSet otherSet) { return invokeObjcSelf!(bool, "isSubsetOfSet:", NSSet)(otherSet); } void makeObjectsPerformSelector (SEL aSelector) { return invokeObjcSelf!(void, "makeObjectsPerformSelector:", SEL)(aSelector); } void makeObjectsPerformSelector (SEL aSelector, Object argument) { return invokeObjcSelf!(void, "makeObjectsPerformSelector:withObject:", SEL, Object)(aSelector, argument); } NSSet setByAddingObject (Object anObject) { return invokeObjcSelf!(NSSet, "setByAddingObject:", Object)(anObject); } NSSet setByAddingObjectsFromSet (NSSet other) { return invokeObjcSelf!(NSSet, "setByAddingObjectsFromSet:", NSSet)(other); } NSSet setByAddingObjectsFromArray (NSArray other) { return invokeObjcSelf!(NSSet, "setByAddingObjectsFromArray:", NSArray)(other); } `; const TNSMutableSetCreation = ` static Object setWithCapacity (NSUInteger numItems) { return invokeObjcSuperClass!(Object, "setWithCapacity:", NSUInteger)(numItems); } Object initWithCapacity (NSUInteger numItems) { return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); } this (NSUInteger numItems) { typeof(this).alloc.initWithCapacity(numItems); } `; const TNSExtendedMutableSet = ` void addObjectsFromArray (NSArray array) { return invokeObjcSelf!(void, "addObjectsFromArray:", NSArray)(array); } void intersectSet (NSSet otherSet) { return invokeObjcSelf!(void, "intersectSet:", NSSet)(otherSet); } void minusSet (NSSet otherSet) { return invokeObjcSelf!(void, "minusSet:", NSSet)(otherSet); } void removeAllObjects () { return invokeObjcSelf!(void, "removeAllObjects"); } void unionSet (NSSet otherSet) { return invokeObjcSelf!(void, "unionSet:", NSSet)(otherSet); } void setSet (NSSet otherSet) { return invokeObjcSelf!(void, "setSet:", NSSet)(otherSet); } `; class NSSet : NSObject, INSCopying, INSMutableCopying, INSCoding, INSFastEnumeration { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } NSUInteger count () { return invokeObjcSelf!(NSUInteger, "count"); } Object member (Object object) { return invokeObjcSelf!(Object, "member:", Object)(object); } NSEnumerator objectEnumerator () { return invokeObjcSelf!(NSEnumerator, "objectEnumerator"); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } Object mutableCopyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "mutableCopyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { typeof(this).alloc.initWithCoder(aDecoder); } NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) { return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); } // TNSSetCreation static Object set () { return invokeObjcSuperClass!(Object, "set"); } static Object setWithObject (Object object) { return invokeObjcSuperClass!(Object, "setWithObject:", Object)(object); } static Object setWithObjects (id* objects, NSUInteger cnt) { return invokeObjcSuperClass!(Object, "setWithObjects:count:", id*, NSUInteger)(objects, cnt); } static Object setWithObjects (Object setWithObjects, ...) { return invokeObjcSuperClass!(Object, "setWithObjects:", Object)(setWithObjects); } static Object setWithSet (NSSet set) { return invokeObjcSuperClass!(Object, "setWithSet:", NSSet)(set); } static Object setWithArray (NSArray array) { return invokeObjcSuperClass!(Object, "setWithArray:", NSArray)(array); } Object initWithObjects (id* objects, NSUInteger cnt) { return invokeObjcSelf!(Object, "initWithObjects:count:", id*, NSUInteger)(objects, cnt); } this (id* objects, NSUInteger cnt) { typeof(this).alloc.initWithObjects(objects, cnt); } Object initWithObjects (Object initWithObjects, ...) { return invokeObjcSelf!(Object, "initWithObjects:", Object)(initWithObjects); } this (Object initWithObjects, ...) { typeof(this).alloc.initWithObjects(initWithObjects); } Object initWithSet (NSSet set) { return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); } this (NSSet set) { typeof(this).alloc.initWithSet(set); } Object initWithSet (NSSet set, bool flag) { return invokeObjcSelf!(Object, "initWithSet:copyItems:", NSSet, bool)(set, flag); } this (NSSet set, bool flag) { typeof(this).alloc.initWithSet(set, flag); } Object initWithArray (NSArray array) { return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); } this (NSArray array) { typeof(this).alloc.initWithArray(array); } // TNSExtendedSet NSArray allObjects () { return invokeObjcSelf!(NSArray, "allObjects"); } Object anyObject () { return invokeObjcSelf!(Object, "anyObject"); } bool containsObject (Object anObject) { return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); } NSString description () { return invokeObjcSelf!(NSString, "description"); } NSString descriptionWithLocale (Object locale) { return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); } bool intersectsSet (NSSet otherSet) { return invokeObjcSelf!(bool, "intersectsSet:", NSSet)(otherSet); } bool isEqualToSet (NSSet otherSet) { return invokeObjcSelf!(bool, "isEqualToSet:", NSSet)(otherSet); } bool isSubsetOfSet (NSSet otherSet) { return invokeObjcSelf!(bool, "isSubsetOfSet:", NSSet)(otherSet); } void makeObjectsPerformSelector (SEL aSelector) { return invokeObjcSelf!(void, "makeObjectsPerformSelector:", SEL)(aSelector); } void makeObjectsPerformSelector (SEL aSelector, Object argument) { return invokeObjcSelf!(void, "makeObjectsPerformSelector:withObject:", SEL, Object)(aSelector, argument); } NSSet setByAddingObject (Object anObject) { return invokeObjcSelf!(NSSet, "setByAddingObject:", Object)(anObject); } NSSet setByAddingObjectsFromSet (NSSet other) { return invokeObjcSelf!(NSSet, "setByAddingObjectsFromSet:", NSSet)(other); } NSSet setByAddingObjectsFromArray (NSArray other) { return invokeObjcSelf!(NSSet, "setByAddingObjectsFromArray:", NSArray)(other); } // TNSKeyValueObserverRegistration void addObserver (NSObject observer, NSString keyPath, uint options, void* context) { return invokeObjcSelf!(void, "addObserver:forKeyPath:options:context:", NSObject, NSString, uint, void*)(observer, keyPath, options, context); } void removeObserver (NSObject observer, NSString keyPath) { return invokeObjcSelf!(void, "removeObserver:forKeyPath:", NSObject, NSString)(observer, keyPath); } } class NSMutableSet : NSSet { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } void addObject (Object object) { return invokeObjcSelf!(void, "addObject:", Object)(object); } void removeObject (Object object) { return invokeObjcSelf!(void, "removeObject:", Object)(object); } // TNSPredicateSupport void filterUsingPredicate (NSPredicate predicate) { return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate); } // TNSMutableSetCreation static Object setWithCapacity (NSUInteger numItems) { return invokeObjcSuperClass!(Object, "setWithCapacity:", NSUInteger)(numItems); } Object initWithCapacity (NSUInteger numItems) { return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); } this (NSUInteger numItems) { typeof(this).alloc.initWithCapacity(numItems); } // TNSExtendedMutableSet void addObjectsFromArray (NSArray array) { return invokeObjcSelf!(void, "addObjectsFromArray:", NSArray)(array); } void intersectSet (NSSet otherSet) { return invokeObjcSelf!(void, "intersectSet:", NSSet)(otherSet); } void minusSet (NSSet otherSet) { return invokeObjcSelf!(void, "minusSet:", NSSet)(otherSet); } void removeAllObjects () { return invokeObjcSelf!(void, "removeAllObjects"); } void unionSet (NSSet otherSet) { return invokeObjcSelf!(void, "unionSet:", NSSet)(otherSet); } void setSet (NSSet otherSet) { return invokeObjcSelf!(void, "setSet:", NSSet)(otherSet); } } class NSCountedSet : NSMutableSet { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } Object initWithCapacity (NSUInteger numItems) { return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); } this (NSUInteger numItems) { typeof(this).alloc.initWithCapacity(numItems); } Object initWithArray (NSArray array) { return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); } this (NSArray array) { typeof(this).alloc.initWithArray(array); } Object initWithSet (NSSet set) { return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); } this (NSSet set) { typeof(this).alloc.initWithSet(set); } NSUInteger countForObject (Object object) { return invokeObjcSelf!(NSUInteger, "countForObject:", Object)(object); } NSEnumerator objectEnumerator () { return invokeObjcSelf!(NSEnumerator, "objectEnumerator"); } void addObject (Object object) { return invokeObjcSelf!(void, "addObject:", Object)(object); } void removeObject (Object object) { return invokeObjcSelf!(void, "removeObject:", Object)(object); } }