diff dstep/foundation/NSPointerArray.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/NSPointerArray.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSPointerArray.d	Sun Jan 03 22:06:11 2010 +0100
@@ -7,15 +7,46 @@
 module dstep.foundation.NSPointerArray;
 
 import dstep.foundation.NSArray;
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSEnumerator;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSPointerFunctions;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+const TNSArrayConveniences = `
+
+	static Object pointerArrayWithStrongObjects ()
+	{
+		return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects");
+	}
+
+	static Object pointerArrayWithWeakObjects ()
+	{
+		return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects");
+	}
+
+	NSArray allObjects ()
+	{
+		return invokeObjcSelf!(NSArray, "allObjects");
+	}
+`;
 
 class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding
 {
-	mixin ObjcWrap;
-	mixin TNSArrayConveniences;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Object initWithOptions (uint options)
 	{
@@ -24,13 +55,7 @@
 
 	this (uint options)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithOptions:", uint)(objcObject, options);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithOptions(options);
 	}
 
 	Object initWithPointerFunctions (NSPointerFunctions functions)
@@ -40,23 +65,17 @@
 
 	this (NSPointerFunctions functions)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:", NSPointerFunctions)(objcObject, functions);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithPointerFunctions(functions);
 	}
 
 	static Object pointerArrayWithOptions (uint options)
 	{
-		return invokeObjcSelfClass!(Object, "pointerArrayWithOptions:", uint)(options);
+		return invokeObjcSuperClass!(Object, "pointerArrayWithOptions:", uint)(options);
 	}
 
 	static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions)
 	{
-		return invokeObjcSelfClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions);
+		return invokeObjcSuperClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions);
 	}
 
 	NSPointerFunctions pointerFunctions ()
@@ -126,31 +145,22 @@
 
 	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);
 	}
-}
-
-template TNSArrayConveniences ()
-{
+	
+	// TNSArrayConveniences
 	static Object pointerArrayWithStrongObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "pointerArrayWithStrongObjects");
+		return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects");
 	}
-
+	
 	static Object pointerArrayWithWeakObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "pointerArrayWithWeakObjects");
+		return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects");
 	}
-
+	
 	NSArray allObjects ()
 	{
 		return invokeObjcSelf!(NSArray, "allObjects");
 	}
-}
-
+}
\ No newline at end of file