Mercurial > projects > dstep
diff dstep/foundation/NSNotificationQueue.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/NSNotificationQueue.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,73 @@ +/** + * 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.NSNotificationQueue; + +import dstep.foundation.NSArray; +import dstep.foundation.NSNotification; +import dstep.foundation.NSNotificationCenter; +import dstep.foundation.NSObject; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +alias NSUInteger NSPostingStyle; +alias NSUInteger NSNotificationCoalescing; + +enum +{ + NSPostWhenIdle = 1, + NSPostASAP = 2, + NSPostNow = 3 +} + +enum +{ + NSNotificationNoCoalescing = 0, + NSNotificationCoalescingOnName = 1, + NSNotificationCoalescingOnSender = 2 +} + +class NSNotificationQueue : NSObject +{ + mixin ObjcWrap; + + static Object defaultQueue () + { + return invokeObjcSelfClass!(Object, "defaultQueue"); + } + + Object initWithNotificationCenter (NSNotificationCenter notificationCenter) + { + return invokeObjcSelf!(Object, "initWithNotificationCenter:", NSNotificationCenter)(notificationCenter); + } + + this (NSNotificationCenter notificationCenter) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithNotificationCenter:", NSNotificationCenter)(objcObject, notificationCenter); + + if (result) + objcObject = ret; + + dObject = this; + } + + void enqueueNotification (NSNotification notification, uint postingStyle) + { + return invokeObjcSelf!(void, "enqueueNotification:postingStyle:", NSNotification, uint)(notification, postingStyle); + } + + void enqueueNotification (NSNotification notification, uint postingStyle, NSUInteger coalesceMask, NSArray modes) + { + return invokeObjcSelf!(void, "enqueueNotification:postingStyle:coalesceMask:forModes:", NSNotification, uint, NSUInteger, NSArray)(notification, postingStyle, coalesceMask, modes); + } + + void dequeueNotificationsMatching (NSNotification notification, NSUInteger coalesceMask) + { + return invokeObjcSelf!(void, "dequeueNotificationsMatching:coalesceMask:", NSNotification, NSUInteger)(notification, coalesceMask); + } +} +