diff dstep/foundation/NSTask.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/NSTask.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSTask.d	Sun Jan 03 22:06:11 2010 +0100
@@ -11,36 +11,47 @@
 import dstep.foundation.NSObject;
 import dstep.foundation.NSString;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+
 
 import bindings = dstep.foundation.NSTask_bindings;
 
-const NSString NSTaskDidTerminateNotification;
+private NSString NSTaskDidTerminateNotification_;
+
+NSString NSTaskDidTerminateNotification ()
+{
+	if (NSTaskDidTerminateNotification_)
+		return NSTaskDidTerminateNotification_;
+	
+	return NSTaskDidTerminateNotification_ = new NSString(bindings.NSTaskDidTerminateNotification);
+}
 
-static this ()
-{
-	NSTaskDidTerminateNotification = new NSString(bindings.NSTaskDidTerminateNotification);
-}
+const TNSTaskConveniences = `
+
+	static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments)
+	{
+		return invokeObjcSuperClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments);
+	}
+
+	void waitUntilExit ()
+	{
+		return invokeObjcSelf!(void, "waitUntilExit");
+	}
+`;
 
 class NSTask : NSObject
 {
-	mixin ObjcWrap;
-	mixin TNSTaskConveniences;
-
-	Object init ()
-	{
-		return invokeObjcSelf!(Object, "init");
-	}
-
+	mixin (ObjcWrap);
+	
 	this ()
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "init")(objcObject);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
 	}
 
 	void setLaunchPath (NSString path)
@@ -152,18 +163,15 @@
 	{
 		return invokeObjcSelf!(int, "terminationStatus");
 	}
-}
-
-template TNSTaskConveniences ()
-{
+	
+	// TNSTaskConveniences
 	static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments)
 	{
-		return invokeObjcSelfClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments);
+		return invokeObjcSuperClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments);
 	}
-
+	
 	void waitUntilExit ()
 	{
 		return invokeObjcSelf!(void, "waitUntilExit");
 	}
-}
-
+}
\ No newline at end of file