Mercurial > projects > dstep
diff dstep/foundation/NSURLCache.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 | 7ff919f595d5 |
children | b9de51448c6b |
line wrap: on
line diff
--- a/dstep/foundation/NSURLCache.d Mon Aug 03 15:31:48 2009 +0200 +++ b/dstep/foundation/NSURLCache.d Sun Jan 03 22:06:11 2010 +0100 @@ -6,16 +6,17 @@ */ module dstep.foundation.NSURLCache; -import dstep.AvailabilityMacros; -import dstep.foundation.NSCachedURLResponseInternal; +import dstep.foundation.NSCoder; import dstep.foundation.NSData; import dstep.foundation.NSDictionary; +import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; -import dstep.foundation.NSURLCacheInternal; +import dstep.foundation.NSString; import dstep.foundation.NSURLRequest; import dstep.foundation.NSURLResponse; +import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; -import dstep.objc.objc : id; +import dstep.objc.objc; alias NSUInteger NSURLCacheStoragePolicy; @@ -28,7 +29,17 @@ class NSCachedURLResponse : NSObject, INSCoding, INSCopying { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } Object initWithResponse (NSURLResponse response, NSData data) { @@ -37,13 +48,7 @@ this (NSURLResponse response, NSData data) { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "initWithResponse:data:", NSURLResponse, NSData)(objcObject, response, data); - - if (result) - objcObject = ret; - - dObject = this; + typeof(this).alloc.initWithResponse(response, data); } Object initWithResponse (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) @@ -53,13 +58,7 @@ this (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "initWithResponse:data:userInfo:storagePolicy:", NSURLResponse, NSData, NSDictionary, uint)(objcObject, response, data, userInfo, storagePolicy); - - if (result) - objcObject = ret; - - dObject = this; + typeof(this).alloc.initWithResponse(response, data, userInfo, storagePolicy); } NSURLResponse response () @@ -94,13 +93,7 @@ this (NSCoder aDecoder) { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); - - if (result) - objcObject = ret; - - dObject = this; + typeof(this).alloc.initWithCoder(aDecoder); } Object copyWithZone (NSZone* zone) @@ -111,16 +104,26 @@ class NSURLCache : NSObject { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } static NSURLCache sharedURLCache () { - return invokeObjcSelfClass!(NSURLCache, "sharedURLCache"); + return invokeObjcSuperClass!(NSURLCache, "sharedURLCache"); } static void setSharedURLCache (NSURLCache cache) { - return invokeObjcSelfClass!(void, "setSharedURLCache:", NSURLCache)(cache); + return invokeObjcSuperClass!(void, "setSharedURLCache:", NSURLCache)(cache); } Object initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) @@ -130,13 +133,7 @@ this (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "initWithMemoryCapacity:diskCapacity:diskPath:", NSUInteger, NSUInteger, NSString)(objcObject, memoryCapacity, diskCapacity, path); - - if (result) - objcObject = ret; - - dObject = this; + typeof(this).alloc.initWithMemoryCapacity(memoryCapacity, diskCapacity, path); } NSCachedURLResponse cachedResponseForRequest (NSURLRequest request)