diff dstep/foundation/NSXMLNode.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/NSXMLNode.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSXMLNode.d	Sun Jan 03 22:06:11 2010 +0100
@@ -9,14 +9,16 @@
 import dstep.foundation.NSArray;
 import dstep.foundation.NSDictionary;
 import dstep.foundation.NSError;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSString;
 import dstep.foundation.NSURL;
 import dstep.foundation.NSXMLDocument;
 import dstep.foundation.NSXMLElement;
 import dstep.foundation.NSXMLNodeOptions;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
 
 alias NSUInteger NSXMLNodeKind;
 
@@ -39,7 +41,17 @@
 
 class NSXMLNode : NSObject, INSCopying
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	Object initWithKind (uint kind)
 	{
@@ -48,13 +60,7 @@
 
 	this (uint kind)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithKind:", uint)(objcObject, kind);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithKind(kind);
 	}
 
 	Object initWithKind (uint kind, NSUInteger options)
@@ -64,78 +70,72 @@
 
 	this (uint kind, NSUInteger options)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithKind:options:", uint, NSUInteger)(objcObject, kind, options);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithKind(kind, options);
 	}
 
 	static Object document ()
 	{
-		return invokeObjcSelfClass!(Object, "document");
+		return invokeObjcSuperClass!(Object, "document");
 	}
 
 	static Object documentWithRootElement (NSXMLElement element)
 	{
-		return invokeObjcSelfClass!(Object, "documentWithRootElement:", NSXMLElement)(element);
+		return invokeObjcSuperClass!(Object, "documentWithRootElement:", NSXMLElement)(element);
 	}
 
 	static Object elementWithName (NSString name)
 	{
-		return invokeObjcSelfClass!(Object, "elementWithName:", NSString)(name);
+		return invokeObjcSuperClass!(Object, "elementWithName:", NSString)(name);
 	}
 
-	static Object elementWithName (NSString name, NSString URI)
+	static Object elementWithName_URI (NSString name, NSString URI)
 	{
-		return invokeObjcSelfClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI);
+		return invokeObjcSuperClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI);
 	}
 
 	static Object elementWithName (NSString name, NSString string)
 	{
-		return invokeObjcSelfClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string);
+		return invokeObjcSuperClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string);
 	}
 
 	static Object elementWithName (NSString name, NSArray children, NSArray attributes)
 	{
-		return invokeObjcSelfClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes);
+		return invokeObjcSuperClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes);
 	}
 
 	static Object attributeWithName (NSString name, NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue);
+		return invokeObjcSuperClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue);
 	}
 
 	static Object attributeWithName (NSString name, NSString URI, NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue);
+		return invokeObjcSuperClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue);
 	}
 
 	static Object namespaceWithName (NSString name, NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue);
+		return invokeObjcSuperClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue);
 	}
 
 	static Object processingInstructionWithName (NSString name, NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue);
+		return invokeObjcSuperClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue);
 	}
 
 	static Object commentWithStringValue (NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "commentWithStringValue:", NSString)(stringValue);
+		return invokeObjcSuperClass!(Object, "commentWithStringValue:", NSString)(stringValue);
 	}
 
 	static Object textWithStringValue (NSString stringValue)
 	{
-		return invokeObjcSelfClass!(Object, "textWithStringValue:", NSString)(stringValue);
+		return invokeObjcSuperClass!(Object, "textWithStringValue:", NSString)(stringValue);
 	}
 
 	static Object DTDNodeWithXMLString (NSString string)
 	{
-		return invokeObjcSelfClass!(Object, "DTDNodeWithXMLString:", NSString)(string);
+		return invokeObjcSuperClass!(Object, "DTDNodeWithXMLString:", NSString)(string);
 	}
 
 	uint kind ()
@@ -271,17 +271,17 @@
 
 	static NSString localNameForName (NSString name)
 	{
-		return invokeObjcSelfClass!(NSString, "localNameForName:", NSString)(name);
+		return invokeObjcSuperClass!(NSString, "localNameForName:", NSString)(name);
 	}
 
 	static NSString prefixForName (NSString name)
 	{
-		return invokeObjcSelfClass!(NSString, "prefixForName:", NSString)(name);
+		return invokeObjcSuperClass!(NSString, "prefixForName:", NSString)(name);
 	}
 
 	static NSXMLNode predefinedNamespaceForPrefix (NSString name)
 	{
-		return invokeObjcSelfClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name);
+		return invokeObjcSuperClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name);
 	}
 
 	NSString description ()
@@ -304,19 +304,37 @@
 		return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments);
 	}
 
-	NSArray nodesForXPath (NSString xpath, NSError** error)
+	NSArray nodesForXPath (NSString xpath, ref NSError error)
 	{
-		return invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, NSError**)(xpath, error);
+		id err = error ? new objc_object : null;
+		NSArray result = invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, id*)(xpath, &err);
+		
+		if (err)
+			error = new NSError(err);
+		
+		return result;
 	}
 
-	NSArray objectsForXQuery (NSString xquery, NSDictionary constants, NSError** error)
+	NSArray objectsForXQuery (NSString xquery, NSDictionary constants, ref NSError error)
 	{
-		return invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, NSError**)(xquery, constants, error);
+		id err = error ? new objc_object : null;
+		NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, id*)(xquery, constants, &err);
+		
+		if (err)
+			error = new NSError(err);
+		
+		return result;
 	}
 
-	NSArray objectsForXQuery (NSString xquery, NSError** error)
+	NSArray objectsForXQuery (NSString xquery, ref NSError error)
 	{
-		return invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, NSError**)(xquery, error);
+		id err = error ? new objc_object : null;
+		NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, id*)(xquery, &err);
+		
+		if (err)
+			error = new NSError(err);
+		
+		return result;
 	}
 
 	Object copyWithZone (NSZone* zone)