diff dstep/foundation/NSPredicate.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 7ff919f595d5
children b9de51448c6b
line wrap: on
line diff
--- a/dstep/foundation/NSPredicate.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSPredicate.d	Sun Jan 03 22:06:11 2010 +0100
@@ -7,33 +7,56 @@
 module dstep.foundation.NSPredicate;
 
 import dstep.foundation.NSArray;
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSDictionary;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSSet;
+import dstep.foundation.NSString;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+
+const TNSPredicateSupport = `
+
+	void filterUsingPredicate (NSPredicate predicate)
+	{
+		return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate);
+	}
+`;
 
 class NSPredicate : NSObject, INSCoding, INSCopying
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments)
 	{
-		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, arguments);
+		return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, arguments);
 	}
 
 	static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...)
 	{
-		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormat);
+		return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormat);
 	}
 
 	static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList)
 	{
-		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argList);
+		return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argList);
 	}
 
 	static NSPredicate predicateWithValue (bool value)
 	{
-		return invokeObjcSelfClass!(NSPredicate, "predicateWithValue:", bool)(value);
+		return invokeObjcSuperClass!(NSPredicate, "predicateWithValue:", bool)(value);
 	}
 
 	NSString predicateFormat ()
@@ -69,26 +92,11 @@
 
 	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);
 	}
 
 	Object copyWithZone (NSZone* zone)
 	{
 		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
 	}
-}
-
-template TNSPredicateSupport ()
-{
-	void filterUsingPredicate (NSPredicate predicate)
-	{
-		return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate);
-	}
-}
-
+}
\ No newline at end of file