Mercurial > projects > dstep
view dstep/foundation/NSHashTable.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
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.NSHashTable; import dstep.foundation.NSArray; import dstep.foundation.NSEnumerator; import dstep.foundation.NSHashTable; import dstep.foundation.NSPointerFunctions; import dstep.foundation.NSSet; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc : id; import bindings = dstep.foundation.NSHashTable_bindings; alias NSUInteger NSHashTableOptions; alias {NSUInteger _pi; NSUInteger _si; void*_bs;} NSHashEnumerator; extern (C) { extern { const NSHashTableCallBacks NSIntegerHashCallBacks; const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks; const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks; const NSHashTableCallBacks NSObjectHashCallBacks; const NSHashTableCallBacks NSOwnedObjectIdentityHashCallBacks; const NSHashTableCallBacks NSOwnedPointerHashCallBacks; const NSHashTableCallBacks NSPointerToStructHashCallBacks; } } enum { NSHashTableStrongMemory = 0, NSHashTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory, NSHashTableCopyIn = NSPointerFunctionsCopyIn, NSHashTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality } struct NSHashEnumerator { NSUInteger _pi; NSUInteger _si; void* _bs; } struct NSHashTableCallBacks { } class NSHashTable : NSObject, INSCopying, INSCoding, INSFastEnumeration { mixin ObjcWrap; Object initWithOptions (uint options, NSUInteger initialCapacity) { return invokeObjcSelf!(Object, "initWithOptions:capacity:", uint, NSUInteger)(options, initialCapacity); } this (uint options, NSUInteger initialCapacity) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithOptions:capacity:", uint, NSUInteger)(objcObject, options, initialCapacity); if (result) objcObject = ret; dObject = this; } Object initWithPointerFunctions (NSPointerFunctions functions, NSUInteger initialCapacity) { return invokeObjcSelf!(Object, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(functions, initialCapacity); } this (NSPointerFunctions functions, NSUInteger initialCapacity) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(objcObject, functions, initialCapacity); if (result) objcObject = ret; dObject = this; } static Object hashTableWithOptions (uint options) { return invokeObjcSelfClass!(Object, "hashTableWithOptions:", uint)(options); } static Object hashTableWithWeakObjects () { return invokeObjcSelfClass!(Object, "hashTableWithWeakObjects"); } NSPointerFunctions pointerFunctions () { return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); } NSUInteger count () { return invokeObjcSelf!(NSUInteger, "count"); } Object member (Object object) { return invokeObjcSelf!(Object, "member:", 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); } void removeAllObjects () { return invokeObjcSelf!(void, "removeAllObjects"); } NSArray allObjects () { return invokeObjcSelf!(NSArray, "allObjects"); } Object anyObject () { return invokeObjcSelf!(Object, "anyObject"); } bool containsObject (Object anObject) { return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); } bool intersectsHashTable (NSHashTable other) { return invokeObjcSelf!(bool, "intersectsHashTable:", NSHashTable)(other); } bool isEqualToHashTable (NSHashTable other) { return invokeObjcSelf!(bool, "isEqualToHashTable:", NSHashTable)(other); } bool isSubsetOfHashTable (NSHashTable other) { return invokeObjcSelf!(bool, "isSubsetOfHashTable:", NSHashTable)(other); } void intersectHashTable (NSHashTable other) { return invokeObjcSelf!(void, "intersectHashTable:", NSHashTable)(other); } void unionHashTable (NSHashTable other) { return invokeObjcSelf!(void, "unionHashTable:", NSHashTable)(other); } void minusHashTable (NSHashTable other) { return invokeObjcSelf!(void, "minusHashTable:", NSHashTable)(other); } NSSet setRepresentation () { return invokeObjcSelf!(NSSet, "setRepresentation"); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", 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) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); if (result) objcObject = ret; dObject = this; } NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) { return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); } } void NSFreeHashTable (NSHashTable table) { return Bridge.invokeObjcFunction!(void, bindings.NSFreeHashTable, NSHashTable)(table); } void NSResetHashTable (NSHashTable table) { return Bridge.invokeObjcFunction!(void, bindings.NSResetHashTable, NSHashTable)(table); } bool NSCompareHashTables (NSHashTable table1, NSHashTable table2) { return Bridge.invokeObjcFunction!(bool, bindings.NSCompareHashTables, NSHashTable, NSHashTable)(table1, table2); } NSHashTable NSCopyHashTableWithZone (NSHashTable table, NSZone* zone) { return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCopyHashTableWithZone, NSHashTable, NSZone*)(table, zone); } void* NSHashGet (NSHashTable table, void* pointer) { return Bridge.invokeObjcFunction!(void*, bindings.NSHashGet, NSHashTable, void*)(table, pointer); } void NSHashInsert (NSHashTable table, void* pointer) { return Bridge.invokeObjcFunction!(void, bindings.NSHashInsert, NSHashTable, void*)(table, pointer); } void NSHashInsertKnownAbsent (NSHashTable table, void* pointer) { return Bridge.invokeObjcFunction!(void, bindings.NSHashInsertKnownAbsent, NSHashTable, void*)(table, pointer); } void* NSHashInsertIfAbsent (NSHashTable table, void* pointer) { return Bridge.invokeObjcFunction!(void*, bindings.NSHashInsertIfAbsent, NSHashTable, void*)(table, pointer); } void NSHashRemove (NSHashTable table, void* pointer) { return Bridge.invokeObjcFunction!(void, bindings.NSHashRemove, NSHashTable, void*)(table, pointer); } NSHashEnumerator NSEnumerateHashTable (NSHashTable table) { return Bridge.invokeObjcFunction!(NSHashEnumerator, bindings.NSEnumerateHashTable, NSHashTable)(table); } NSUInteger NSCountHashTable (NSHashTable table) { return Bridge.invokeObjcFunction!(NSUInteger, bindings.NSCountHashTable, NSHashTable)(table); } NSString NSStringFromHashTable (NSHashTable table) { return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromHashTable, NSHashTable)(table); } NSArray NSAllHashTableObjects (NSHashTable table) { return Bridge.invokeObjcFunction!(NSArray, bindings.NSAllHashTableObjects, NSHashTable)(table); } NSHashTable NSCreateHashTableWithZone (NSHashTableCallBacks callBacks, NSUInteger capacity, NSZone* zone) { return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCreateHashTableWithZone, NSHashTableCallBacks, NSUInteger, NSZone*)(callBacks, capacity, zone); } NSHashTable NSCreateHashTable (NSHashTableCallBacks callBacks, NSUInteger capacity) { return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCreateHashTable, NSHashTableCallBacks, NSUInteger)(callBacks, capacity); } extern (C) { void* NSNextHashEnumeratorItem (NSHashEnumerator* enumerator); void NSEndHashTableEnumeration (NSHashEnumerator* enumerator); }