diff dstep/foundation/NSProtocolChecker.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/NSProtocolChecker.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSProtocolChecker.d	Sun Jan 03 22:06:11 2010 +0100
@@ -9,12 +9,42 @@
 import dstep.foundation.NSObject;
 import dstep.foundation.NSProxy;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+
+import dstep.objc.runtime;
+
+const TNSProtocolCheckerCreation = `
+
+	static Object protocolCheckerWithTarget (NSObject anObject, Protocol aProtocol)
+	{
+		return invokeObjcSuperClass!(Object, "protocolCheckerWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
+	}
+
+	Object initWithTarget (NSObject anObject, Protocol aProtocol)
+	{
+		return invokeObjcSelf!(Object, "initWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
+	}
+
+	this (NSObject anObject, Protocol aProtocol)
+	{
+		typeof(this).alloc.initWithTarget(anObject, aProtocol);
+	}
+`;
 
 class NSProtocolChecker : NSProxy
 {
-	mixin ObjcWrap;
-	mixin TNSProtocolCheckerCreation;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Protocol protocol ()
 	{
@@ -25,29 +55,20 @@
 	{
 		return invokeObjcSelf!(NSObject, "target");
 	}
-}
-
-template TNSProtocolCheckerCreation ()
-{
+	
+	// TNSProtocolCheckerCreation
 	static Object protocolCheckerWithTarget (NSObject anObject, Protocol aProtocol)
 	{
-		return invokeObjcSelfClass!(Object, "protocolCheckerWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
+		return invokeObjcSuperClass!(Object, "protocolCheckerWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
 	}
-
+	
 	Object initWithTarget (NSObject anObject, Protocol aProtocol)
 	{
 		return invokeObjcSelf!(Object, "initWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
 	}
-
+	
 	this (NSObject anObject, Protocol aProtocol)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithTarget:protocol:", NSObject, Protocol)(objcObject, anObject, aProtocol);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithTarget(anObject, aProtocol);
 	}
-}
-
+}
\ No newline at end of file