diff dstep/foundation/NSMapTable.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/NSMapTable.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSMapTable.d	Sun Jan 03 22:06:11 2010 +0100
@@ -7,18 +7,21 @@
 module dstep.foundation.NSMapTable;
 
 import dstep.foundation.NSArray;
+import dstep.foundation.NSCoder;
 import dstep.foundation.NSDictionary;
 import dstep.foundation.NSEnumerator;
 import dstep.foundation.NSMapTable;
+import dstep.foundation.NSObjCRuntime;
+import dstep.foundation.NSObject;
 import dstep.foundation.NSPointerFunctions;
 import dstep.foundation.NSString;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
 
 import bindings = dstep.foundation.NSMapTable_bindings;
 
 alias NSUInteger NSMapTableOptions;
-alias {NSUInteger _pi; NSUInteger _si; void*_bs;} NSMapEnumerator;
 
 extern (C)
 {
@@ -56,17 +59,35 @@
 
 struct NSMapTableKeyCallBacks
 {
-	void* notAKeyMarker;
+	extern (C) uint function (id table, /*const*/ void*) hash;
+	extern (C) bool function (id table, /*const*/ void*, /*const*/ void*) isEqual;
+	extern (C) void function (id table, /*const*/ void*) retain;
+	extern (C) void function (id table, void*) release;
+	extern (C) id function (id table, /*const*/ void*) describe;
+	
+	/*const*/ void* notAKeyMarker;
 }
 
-
 struct NSMapTableValueCallBacks
 {
+	extern (C) void function (id table, /*const*/ void*) retain;
+	extern (C) void function (id table, /*const*/ void*) release;
+	extern (C) id function (id table, /*const*/ void*) describe;
 }
 
 class NSMapTable : NSObject, INSCopying, INSCoding, INSFastEnumeration
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Object initWithKeyOptions (uint keyOptions, uint valueOptions, NSUInteger initialCapacity)
 	{
@@ -75,13 +96,7 @@
 
 	this (uint keyOptions, uint valueOptions, NSUInteger initialCapacity)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithKeyOptions:valueOptions:capacity:", uint, uint, NSUInteger)(objcObject, keyOptions, valueOptions, initialCapacity);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithKeyOptions(keyOptions, valueOptions, initialCapacity);
 	}
 
 	Object initWithKeyPointerFunctions (NSPointerFunctions keyFunctions, NSPointerFunctions valueFunctions, NSUInteger initialCapacity)
@@ -91,38 +106,32 @@
 
 	this (NSPointerFunctions keyFunctions, NSPointerFunctions valueFunctions, NSUInteger initialCapacity)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithKeyPointerFunctions:valuePointerFunctions:capacity:", NSPointerFunctions, NSPointerFunctions, NSUInteger)(objcObject, keyFunctions, valueFunctions, initialCapacity);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithKeyPointerFunctions(keyFunctions, valueFunctions, initialCapacity);
 	}
 
 	static Object mapTableWithKeyOptions (uint keyOptions, uint valueOptions)
 	{
-		return invokeObjcSelfClass!(Object, "mapTableWithKeyOptions:valueOptions:", uint, uint)(keyOptions, valueOptions);
+		return invokeObjcSuperClass!(Object, "mapTableWithKeyOptions:valueOptions:", uint, uint)(keyOptions, valueOptions);
 	}
 
 	static Object mapTableWithStrongToStrongObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "mapTableWithStrongToStrongObjects");
+		return invokeObjcSuperClass!(Object, "mapTableWithStrongToStrongObjects");
 	}
 
 	static Object mapTableWithWeakToStrongObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "mapTableWithWeakToStrongObjects");
+		return invokeObjcSuperClass!(Object, "mapTableWithWeakToStrongObjects");
 	}
 
 	static Object mapTableWithStrongToWeakObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "mapTableWithStrongToWeakObjects");
+		return invokeObjcSuperClass!(Object, "mapTableWithStrongToWeakObjects");
 	}
 
 	static Object mapTableWithWeakToWeakObjects ()
 	{
-		return invokeObjcSelfClass!(Object, "mapTableWithWeakToWeakObjects");
+		return invokeObjcSuperClass!(Object, "mapTableWithWeakToWeakObjects");
 	}
 
 	NSPointerFunctions keyPointerFunctions ()
@@ -192,13 +201,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);
 	}
 
 	NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len)