diff dstep/foundation/NSIndexSet.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/NSIndexSet.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSIndexSet.d	Sun Jan 03 22:06:11 2010 +0100
@@ -6,14 +6,27 @@
  */
 module dstep.foundation.NSIndexSet;
 
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSRange;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
 
 class NSMutableIndexSet : NSIndexSet
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		typeof(this).alloc.init;
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	void addIndexes (NSIndexSet indexSet)
 	{
@@ -58,37 +71,31 @@
 
 class NSIndexSet : NSObject, INSCopying, INSMutableCopying, INSCoding
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		typeof(this).alloc.init;
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	static Object indexSet ()
 	{
-		return invokeObjcSelfClass!(Object, "indexSet");
+		return invokeObjcSuperClass!(Object, "indexSet");
 	}
 
 	static Object indexSetWithIndex (NSUInteger value)
 	{
-		return invokeObjcSelfClass!(Object, "indexSetWithIndex:", NSUInteger)(value);
+		return invokeObjcSuperClass!(Object, "indexSetWithIndex:", NSUInteger)(value);
 	}
 
 	static Object indexSetWithIndexesInRange (NSRange range)
 	{
-		return invokeObjcSelfClass!(Object, "indexSetWithIndexesInRange:", NSRange)(range);
-	}
-
-	Object init ()
-	{
-		return invokeObjcSelf!(Object, "init");
-	}
-
-	this ()
-	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "init")(objcObject);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		return invokeObjcSuperClass!(Object, "indexSetWithIndexesInRange:", NSRange)(range);
 	}
 
 	Object initWithIndex (NSUInteger value)
@@ -98,13 +105,7 @@
 
 	this (NSUInteger value)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithIndex:", NSUInteger)(objcObject, value);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithIndex(value);
 	}
 
 	Object initWithIndexesInRange (NSRange range)
@@ -114,13 +115,7 @@
 
 	this (NSRange range)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithIndexesInRange:", NSRange)(objcObject, range);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithIndexesInRange(range);
 	}
 
 	Object initWithIndexSet (NSIndexSet indexSet)
@@ -130,13 +125,7 @@
 
 	this (NSIndexSet indexSet)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithIndexSet:", NSIndexSet)(objcObject, indexSet);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithIndexSet(indexSet);
 	}
 
 	bool isEqualToIndexSet (NSIndexSet indexSet)
@@ -231,13 +220,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);
 	}
 }