Mercurial > projects > dstep
diff dstep/foundation/NSPointerFunctions.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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/foundation/NSPointerFunctions.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,81 @@ +/** + * 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.NSPointerFunctions; + +import dstep.foundation.NSObject; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +alias NSUInteger NSPointerFunctionsOptions; + +enum +{ + NSPointerFunctionsStrongMemory = (0 << 0), + NSPointerFunctionsZeroingWeakMemory = (1 << 0), + NSPointerFunctionsOpaqueMemory = (2 << 0), + NSPointerFunctionsMallocMemory = (3 << 0), + NSPointerFunctionsMachVirtualMemory = (4 << 0), + NSPointerFunctionsObjectPersonality = (0 << 8), + NSPointerFunctionsOpaquePersonality = (1 << 8), + NSPointerFunctionsObjectPointerPersonality = (2 << 8), + NSPointerFunctionsCStringPersonality = (3 << 8), + NSPointerFunctionsStructPersonality = (4 << 8), + NSPointerFunctionsIntegerPersonality = (5 << 8), + NSPointerFunctionsCopyIn = (1 << 16) +} + +class NSPointerFunctions : NSObject, INSCopying +{ + mixin ObjcWrap; + + 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; + } + + static Object pointerFunctionsWithOptions (uint options) + { + return invokeObjcSelfClass!(Object, "pointerFunctionsWithOptions:", uint)(options); + } + + bool usesStrongWriteBarrier () + { + return invokeObjcSelf!(bool, "usesStrongWriteBarrier"); + } + + void setUsesStrongWriteBarrier (bool ) + { + return invokeObjcSelf!(void, "setUsesStrongWriteBarrier:", bool)(); + } + + bool usesWeakReadAndWriteBarriers () + { + return invokeObjcSelf!(bool, "usesWeakReadAndWriteBarriers"); + } + + void setUsesWeakReadAndWriteBarriers (bool ) + { + return invokeObjcSelf!(void, "setUsesWeakReadAndWriteBarriers:", bool)(); + } + + Object copyWithZone (NSZone* zone) + { + return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); + } +} +