Mercurial > projects > dstep
view dstep/foundation/NSPointerArray.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.NSPointerArray; import dstep.foundation.NSArray; import dstep.foundation.NSObject; import dstep.foundation.NSPointerFunctions; import dstep.objc.bridge.Bridge; import dstep.objc.objc : id; class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding { mixin ObjcWrap; mixin TNSArrayConveniences; Object initWithOptions (uint options) { return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); } this (uint options) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithOptions:", uint)(objcObject, options); if (result) objcObject = ret; dObject = this; } Object initWithPointerFunctions (NSPointerFunctions functions) { return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions); } this (NSPointerFunctions functions) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:", NSPointerFunctions)(objcObject, functions); if (result) objcObject = ret; dObject = this; } static Object pointerArrayWithOptions (uint options) { return invokeObjcSelfClass!(Object, "pointerArrayWithOptions:", uint)(options); } static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions) { return invokeObjcSelfClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions); } NSPointerFunctions pointerFunctions () { return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); } void* pointerAtIndex (NSUInteger index) { return invokeObjcSelf!(void*, "pointerAtIndex:", NSUInteger)(index); } void addPointer (void* pointer) { return invokeObjcSelf!(void, "addPointer:", void*)(pointer); } void removePointerAtIndex (NSUInteger index) { return invokeObjcSelf!(void, "removePointerAtIndex:", NSUInteger)(index); } void insertPointer (void* item, NSUInteger index) { return invokeObjcSelf!(void, "insertPointer:atIndex:", void*, NSUInteger)(item, index); } void replacePointerAtIndex (NSUInteger index, void* item) { return invokeObjcSelf!(void, "replacePointerAtIndex:withPointer:", NSUInteger, void*)(index, item); } void compact () { return invokeObjcSelf!(void, "compact"); } NSUInteger count () { return invokeObjcSelf!(NSUInteger, "count"); } void setCount (NSUInteger count) { return invokeObjcSelf!(void, "setCount:", NSUInteger)(count); } NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) { return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); } 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; } } template TNSArrayConveniences () { static Object pointerArrayWithStrongObjects () { return invokeObjcSelfClass!(Object, "pointerArrayWithStrongObjects"); } static Object pointerArrayWithWeakObjects () { return invokeObjcSelfClass!(Object, "pointerArrayWithWeakObjects"); } NSArray allObjects () { return invokeObjcSelf!(NSArray, "allObjects"); } }