diff dstep/foundation/NSURLResponse.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/NSURLResponse.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSURLResponse.d	Sun Jan 03 22:06:11 2010 +0100
@@ -6,20 +6,30 @@
  */
 module dstep.foundation.NSURLResponse;
 
-import dstep.AvailabilityMacros;
+import dstep.foundation.NSCoder;
 import dstep.foundation.NSDictionary;
-import dstep.foundation.NSHTTPURLResponseInternal;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSString;
 import dstep.foundation.NSURL;
 import dstep.foundation.NSURLRequest;
-import dstep.foundation.NSURLResponseInternal;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
 
 class NSHTTPURLResponse : NSURLResponse
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	NSInteger statusCode ()
 	{
@@ -33,13 +43,23 @@
 
 	static NSString localizedStringForStatusCode (NSInteger statusCode)
 	{
-		return invokeObjcSelfClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode);
+		return invokeObjcSuperClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode);
 	}
 }
 
 class NSURLResponse : NSObject, INSCoding, INSCopying
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Object initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
 	{
@@ -48,13 +68,7 @@
 
 	this (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(objcObject, URL, MIMEType, length, name);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithURL(URL, MIMEType, length, name);
 	}
 
 	NSURL URL ()
@@ -94,13 +108,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)