diff dstep/objc/bridge/Wrapper.d @ 2:9fd439a28ce3

Adapted the scripts for the new bridge + a lot more
author Jacob Carlborg <doob@me.com>
date Sun, 05 Jul 2009 17:16:19 +0200
parents 033d260cfc9b
children 19885b43130e
line wrap: on
line diff
--- a/dstep/objc/bridge/Wrapper.d	Thu Jun 18 22:00:13 2009 +0200
+++ b/dstep/objc/bridge/Wrapper.d	Sun Jul 05 17:16:19 2009 +0200
@@ -15,12 +15,22 @@
 
 class ObjcWrapper
 {	
-	package objc_super* objcSuper;
-	
 	static private Class objcClass_;
 	static private Class objcSuperClass_;
 	
 	private id objcObject_;
+	private objc_super* objcSuper_;
+	
+	this ()
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id ret = Bridge.invokeObjcMethod!(id, "init")(objcObject);
+		
+		if (ret)
+			objcObject = ret;
+		
+		dObject = this;
+	}
 		
 	/// Initialize object from an Objective-C object instance to wrap.
 	this (id object)
@@ -57,24 +67,15 @@
 		Bridge.setDObject(dObject, objcObject);
 	}
 	
-	/*this (bool init = true, bool alloc = true)
+	objc_super* objcSuper ()
 	{
-		if (init && alloc)
+		if (!objcSuper_)
 		{
-			id result = objc_msgSend!(id)(objc_getClass(this.classinfo.name), sel.registerName!("alloc"));
-			id result2;
-			
-			if (result)
-				result2 = objc_msgSend(result, sel.registerName!("init"));
-			
-			if (result2)
-				objc.object = result2;
-			
-			else
-				objc.object = result;
+			objcSuper_ = new objc_super;
+			objcSuper_.receiver = objcObject;
+			objcSuper_.cls = objcSuperClass;
 		}
 		
-		else if (alloc)
-			objc.object = objc_msgSend(objc_getClass(this.classinfo.name), sel.registerName!("alloc"));
-	}*/
+		return objcSuper_;
+	}
 }
\ No newline at end of file