Mercurial > projects > dstep
diff dstep/foundation/NSMetadata.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 diff
--- a/dstep/foundation/NSMetadata.d Mon Aug 03 15:31:48 2009 +0200 +++ b/dstep/foundation/NSMetadata.d Sun Jan 03 22:06:11 2010 +0100 @@ -9,41 +9,122 @@ import dstep.foundation.NSArray; import dstep.foundation.NSDate; import dstep.foundation.NSDictionary; -import dstep.foundation.NSMetadataItem; -import dstep.foundation.NSMetadataQueryAttributeValueTuple; -import dstep.foundation.NSMetadataQueryResultGroup; +import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSPredicate; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; -import dstep.objc.objc : id; +import dstep.objc.objc; + + import bindings = dstep.foundation.NSMetadata_bindings; -const NSString NSMetadataQueryDidStartGatheringNotification; -const NSString NSMetadataQueryGatheringProgressNotification; -const NSString NSMetadataQueryDidFinishGatheringNotification; -const NSString NSMetadataQueryDidUpdateNotification; -const NSString NSMetadataQueryResultContentRelevanceAttribute; -const NSString NSMetadataQueryUserHomeScope; -const NSString NSMetadataQueryLocalComputerScope; -const NSString NSMetadataQueryNetworkScope; +private +{ + NSString NSMetadataQueryDidStartGatheringNotification_; + NSString NSMetadataQueryGatheringProgressNotification_; + NSString NSMetadataQueryDidFinishGatheringNotification_; + NSString NSMetadataQueryDidUpdateNotification_; + NSString NSMetadataQueryResultContentRelevanceAttribute_; + NSString NSMetadataQueryUserHomeScope_; + NSString NSMetadataQueryLocalComputerScope_; + NSString NSMetadataQueryNetworkScope_; +} + +NSString NSMetadataQueryDidStartGatheringNotification () +{ + if (NSMetadataQueryDidStartGatheringNotification_) + return NSMetadataQueryDidStartGatheringNotification_; + + return NSMetadataQueryDidStartGatheringNotification_ = new NSString(bindings.NSMetadataQueryDidStartGatheringNotification); +} + +NSString NSMetadataQueryGatheringProgressNotification () +{ + if (NSMetadataQueryGatheringProgressNotification_) + return NSMetadataQueryGatheringProgressNotification_; + + return NSMetadataQueryGatheringProgressNotification_ = new NSString(bindings.NSMetadataQueryGatheringProgressNotification); +} + +NSString NSMetadataQueryDidFinishGatheringNotification () +{ + if (NSMetadataQueryDidFinishGatheringNotification_) + return NSMetadataQueryDidFinishGatheringNotification_; + + return NSMetadataQueryDidFinishGatheringNotification_ = new NSString(bindings.NSMetadataQueryDidFinishGatheringNotification); +} + +NSString NSMetadataQueryDidUpdateNotification () +{ + if (NSMetadataQueryDidUpdateNotification_) + return NSMetadataQueryDidUpdateNotification_; + + return NSMetadataQueryDidUpdateNotification_ = new NSString(bindings.NSMetadataQueryDidUpdateNotification); +} -static this () +NSString NSMetadataQueryResultContentRelevanceAttribute () +{ + if (NSMetadataQueryResultContentRelevanceAttribute_) + return NSMetadataQueryResultContentRelevanceAttribute_; + + return NSMetadataQueryResultContentRelevanceAttribute_ = new NSString(bindings.NSMetadataQueryResultContentRelevanceAttribute); +} + +NSString NSMetadataQueryUserHomeScope () +{ + if (NSMetadataQueryUserHomeScope_) + return NSMetadataQueryUserHomeScope_; + + return NSMetadataQueryUserHomeScope_ = new NSString(bindings.NSMetadataQueryUserHomeScope); +} + +NSString NSMetadataQueryLocalComputerScope () { - NSMetadataQueryDidStartGatheringNotification = new NSString(bindings.NSMetadataQueryDidStartGatheringNotification); - NSMetadataQueryGatheringProgressNotification = new NSString(bindings.NSMetadataQueryGatheringProgressNotification); - NSMetadataQueryDidFinishGatheringNotification = new NSString(bindings.NSMetadataQueryDidFinishGatheringNotification); - NSMetadataQueryDidUpdateNotification = new NSString(bindings.NSMetadataQueryDidUpdateNotification); - NSMetadataQueryResultContentRelevanceAttribute = new NSString(bindings.NSMetadataQueryResultContentRelevanceAttribute); - NSMetadataQueryUserHomeScope = new NSString(bindings.NSMetadataQueryUserHomeScope); - NSMetadataQueryLocalComputerScope = new NSString(bindings.NSMetadataQueryLocalComputerScope); - NSMetadataQueryNetworkScope = new NSString(bindings.NSMetadataQueryNetworkScope); + if (NSMetadataQueryLocalComputerScope_) + return NSMetadataQueryLocalComputerScope_; + + return NSMetadataQueryLocalComputerScope_ = new NSString(bindings.NSMetadataQueryLocalComputerScope); +} + +NSString NSMetadataQueryNetworkScope () +{ + if (NSMetadataQueryNetworkScope_) + return NSMetadataQueryNetworkScope_; + + return NSMetadataQueryNetworkScope_ = new NSString(bindings.NSMetadataQueryNetworkScope); } +const TNSMetadataQueryDelegate = ` + + Object metadataQuery (NSMetadataQuery query, NSMetadataItem result) + { + return invokeObjcSelf!(Object, "metadataQuery:replacementObjectForResultObject:", NSMetadataQuery, NSMetadataItem)(query, result); + } + + Object metadataQuery (NSMetadataQuery query, NSString attrName, Object attrValue) + { + return invokeObjcSelf!(Object, "metadataQuery:replacementValueForAttribute:value:", NSMetadataQuery, NSString, Object)(query, attrName, attrValue); + } + + //mixin ObjcBindMethod!(metadataQuery, "metadataQuery:replacementObjectForResultObject:"); + //mixin ObjcBindMethod!(metadataQuery, "metadataQuery:replacementValueForAttribute:value:"); +`; + class NSMetadataQueryResultGroup : NSObject { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } NSString attribute () { @@ -78,7 +159,17 @@ class NSMetadataItem : NSObject { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } Object valueForAttribute (NSString key) { @@ -98,22 +189,16 @@ class NSMetadataQuery : NSObject { - mixin ObjcWrap; - - Object init () - { - return invokeObjcSelf!(Object, "init"); - } - + mixin (ObjcWrap); + this () { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); - - if (result) - objcObject = ret; - - dObject = this; + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); } Object delegate_ () @@ -259,7 +344,17 @@ class NSMetadataQueryAttributeValueTuple : NSObject { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } NSString attribute () { @@ -275,11 +370,4 @@ { return invokeObjcSelf!(NSUInteger, "count"); } -} - -template TNSMetadataQueryDelegate () -{ - Object metadataQuery (NSMetadataQuery query, NSMetadataItem result); - Object metadataQuery (NSMetadataQuery query, NSString attrName, Object attrValue); -} - +} \ No newline at end of file