diff dstep/foundation/NSURLProtectionSpace.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/NSURLProtectionSpace.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSURLProtectionSpace.d	Sun Jan 03 22:06:11 2010 +0100
@@ -6,39 +6,106 @@
  */
 module dstep.foundation.NSURLProtectionSpace;
 
-import dstep.AvailabilityMacros;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSString;
-import dstep.foundation.NSURLProtectionSpaceInternal;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+
 
 import bindings = dstep.foundation.NSURLProtectionSpace_bindings;
 
-const NSString NSURLProtectionSpaceHTTPProxy;
-const NSString NSURLProtectionSpaceHTTPSProxy;
-const NSString NSURLProtectionSpaceFTPProxy;
-const NSString NSURLProtectionSpaceSOCKSProxy;
-const NSString NSURLAuthenticationMethodDefault;
-const NSString NSURLAuthenticationMethodHTTPBasic;
-const NSString NSURLAuthenticationMethodHTTPDigest;
-const NSString NSURLAuthenticationMethodHTMLForm;
+private
+{
+	NSString NSURLProtectionSpaceHTTPProxy_;
+	NSString NSURLProtectionSpaceHTTPSProxy_;
+	NSString NSURLProtectionSpaceFTPProxy_;
+	NSString NSURLProtectionSpaceSOCKSProxy_;
+	NSString NSURLAuthenticationMethodDefault_;
+	NSString NSURLAuthenticationMethodHTTPBasic_;
+	NSString NSURLAuthenticationMethodHTTPDigest_;
+	NSString NSURLAuthenticationMethodHTMLForm_;
+}
+
+NSString NSURLProtectionSpaceHTTPProxy ()
+{
+	if (NSURLProtectionSpaceHTTPProxy_)
+		return NSURLProtectionSpaceHTTPProxy_;
+		
+	return NSURLProtectionSpaceHTTPProxy_ = new NSString(bindings.NSURLProtectionSpaceHTTPProxy);
+}
+
+NSString NSURLProtectionSpaceHTTPSProxy ()
+{
+	if (NSURLProtectionSpaceHTTPSProxy_)
+		return NSURLProtectionSpaceHTTPSProxy_;
+		
+	return NSURLProtectionSpaceHTTPSProxy_ = new NSString(bindings.NSURLProtectionSpaceHTTPSProxy);
+}
+
+NSString NSURLProtectionSpaceFTPProxy ()
+{
+	if (NSURLProtectionSpaceFTPProxy_)
+		return NSURLProtectionSpaceFTPProxy_;
+		
+	return NSURLProtectionSpaceFTPProxy_ = new NSString(bindings.NSURLProtectionSpaceFTPProxy);
+}
 
-static this ()
+NSString NSURLProtectionSpaceSOCKSProxy ()
+{
+	if (NSURLProtectionSpaceSOCKSProxy_)
+		return NSURLProtectionSpaceSOCKSProxy_;
+		
+	return NSURLProtectionSpaceSOCKSProxy_ = new NSString(bindings.NSURLProtectionSpaceSOCKSProxy);
+}
+
+NSString NSURLAuthenticationMethodDefault ()
+{
+	if (NSURLAuthenticationMethodDefault_)
+		return NSURLAuthenticationMethodDefault_;
+		
+	return NSURLAuthenticationMethodDefault_ = new NSString(bindings.NSURLAuthenticationMethodDefault);
+}
+
+NSString NSURLAuthenticationMethodHTTPBasic ()
 {
-	NSURLProtectionSpaceHTTPProxy = new NSString(bindings.NSURLProtectionSpaceHTTPProxy);
-	NSURLProtectionSpaceHTTPSProxy = new NSString(bindings.NSURLProtectionSpaceHTTPSProxy);
-	NSURLProtectionSpaceFTPProxy = new NSString(bindings.NSURLProtectionSpaceFTPProxy);
-	NSURLProtectionSpaceSOCKSProxy = new NSString(bindings.NSURLProtectionSpaceSOCKSProxy);
-	NSURLAuthenticationMethodDefault = new NSString(bindings.NSURLAuthenticationMethodDefault);
-	NSURLAuthenticationMethodHTTPBasic = new NSString(bindings.NSURLAuthenticationMethodHTTPBasic);
-	NSURLAuthenticationMethodHTTPDigest = new NSString(bindings.NSURLAuthenticationMethodHTTPDigest);
-	NSURLAuthenticationMethodHTMLForm = new NSString(bindings.NSURLAuthenticationMethodHTMLForm);
+	if (NSURLAuthenticationMethodHTTPBasic_)
+		return NSURLAuthenticationMethodHTTPBasic_;
+		
+	return NSURLAuthenticationMethodHTTPBasic_ = new NSString(bindings.NSURLAuthenticationMethodHTTPBasic);
+}
+
+NSString NSURLAuthenticationMethodHTTPDigest ()
+{
+	if (NSURLAuthenticationMethodHTTPDigest_)
+		return NSURLAuthenticationMethodHTTPDigest_;
+		
+	return NSURLAuthenticationMethodHTTPDigest_ = new NSString(bindings.NSURLAuthenticationMethodHTTPDigest);
+}
+
+NSString NSURLAuthenticationMethodHTMLForm ()
+{
+	if (NSURLAuthenticationMethodHTMLForm_)
+		return NSURLAuthenticationMethodHTMLForm_;
+		
+	return NSURLAuthenticationMethodHTMLForm_ = new NSString(bindings.NSURLAuthenticationMethodHTMLForm);
 }
 
 class NSURLProtectionSpace : NSObject, INSCopying
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Object initWithHost (NSString host, NSInteger port, NSString protocol, NSString realm, NSString authenticationMethod)
 	{
@@ -47,13 +114,7 @@
 
 	this (NSString host, NSInteger port, NSString protocol, NSString realm, NSString authenticationMethod)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithHost:port:protocol:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(objcObject, host, port, protocol, realm, authenticationMethod);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithHost(host, port, protocol, realm, authenticationMethod);
 	}
 
 	Object initWithProxyHost (NSString host, NSInteger port, NSString type, NSString realm, NSString authenticationMethod)
@@ -61,17 +122,6 @@
 		return invokeObjcSelf!(Object, "initWithProxyHost:port:type:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(host, port, type, realm, authenticationMethod);
 	}
 
-	this (NSString host, NSInteger port, NSString type, NSString realm, NSString authenticationMethod)
-	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithProxyHost:port:type:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(objcObject, host, port, type, realm, authenticationMethod);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
-	}
-
 	NSString realm ()
 	{
 		return invokeObjcSelf!(NSString, "realm");