Mercurial > projects > dstep
comparison dstep/foundation/NSXMLElement.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 |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
4 * Version: Initial created: Aug 3, 2009 | 4 * Version: Initial created: Aug 3, 2009 |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) |
6 */ | 6 */ |
7 module dstep.foundation.NSXMLElement; | 7 module dstep.foundation.NSXMLElement; |
8 | 8 |
9 import dstep.foundation.NSArray; | |
9 import dstep.foundation.NSDictionary; | 10 import dstep.foundation.NSDictionary; |
11 import dstep.foundation.NSError; | |
10 import dstep.foundation.NSEnumerator; | 12 import dstep.foundation.NSEnumerator; |
11 import dstep.foundation.NSMutableArray; | 13 import dstep.foundation.NSObjCRuntime; |
14 import dstep.foundation.NSString; | |
12 import dstep.foundation.NSXMLNode; | 15 import dstep.foundation.NSXMLNode; |
13 import dstep.objc.bridge.Bridge; | 16 import dstep.objc.bridge.Bridge; |
14 import dstep.objc.objc : id; | 17 import dstep.objc.objc; |
15 | 18 |
16 class NSXMLElement : NSXMLNode | 19 class NSXMLElement : NSXMLNode |
17 { | 20 { |
18 mixin ObjcWrap; | 21 mixin (ObjcWrap); |
22 | |
23 this () | |
24 { | |
25 super(typeof(this).alloc.init.objcObject); | |
26 } | |
27 | |
28 typeof(this) init () | |
29 { | |
30 return invokeObjcSelf!(typeof(this), "init"); | |
31 } | |
19 | 32 |
20 Object initWithName (NSString name) | 33 Object initWithName (NSString name) |
21 { | 34 { |
22 return invokeObjcSelf!(Object, "initWithName:", NSString)(name); | 35 return invokeObjcSelf!(Object, "initWithName:", NSString)(name); |
23 } | 36 } |
24 | 37 |
25 this (NSString name) | 38 this (NSString name) |
26 { | 39 { |
27 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 40 typeof(this).alloc.initWithName(name); |
28 id result = Bridge.invokeObjcMethod!(id, "initWithName:", NSString)(objcObject, name); | |
29 | |
30 if (result) | |
31 objcObject = ret; | |
32 | |
33 dObject = this; | |
34 } | 41 } |
35 | 42 |
36 Object initWithName (NSString name, NSString URI) | 43 Object initWithName_URL (NSString name, NSString URI) |
37 { | 44 { |
38 return invokeObjcSelf!(Object, "initWithName:URI:", NSString, NSString)(name, URI); | 45 return invokeObjcSelf!(Object, "initWithName:URI:", NSString, NSString)(name, URI); |
39 } | |
40 | |
41 this (NSString name, NSString URI) | |
42 { | |
43 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
44 id result = Bridge.invokeObjcMethod!(id, "initWithName:URI:", NSString, NSString)(objcObject, name, URI); | |
45 | |
46 if (result) | |
47 objcObject = ret; | |
48 | |
49 dObject = this; | |
50 } | 46 } |
51 | 47 |
52 Object initWithName (NSString name, NSString string) | 48 Object initWithName (NSString name, NSString string) |
53 { | 49 { |
54 return invokeObjcSelf!(Object, "initWithName:stringValue:", NSString, NSString)(name, string); | 50 return invokeObjcSelf!(Object, "initWithName:stringValue:", NSString, NSString)(name, string); |
55 } | 51 } |
56 | 52 |
57 this (NSString name, NSString string) | 53 this (NSString name, NSString string) |
58 { | 54 { |
59 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 55 typeof(this).alloc.initWithName(name, string); |
60 id result = Bridge.invokeObjcMethod!(id, "initWithName:stringValue:", NSString, NSString)(objcObject, name, string); | |
61 | |
62 if (result) | |
63 objcObject = ret; | |
64 | |
65 dObject = this; | |
66 } | 56 } |
67 | 57 |
68 Object initWithXMLString (NSString string, NSError** error) | 58 Object initWithXMLString (NSString string, ref NSError error) |
69 { | 59 { |
70 return invokeObjcSelf!(Object, "initWithXMLString:error:", NSString, NSError**)(string, error); | 60 id err = error ? new objc_object : null; |
61 Object result = invokeObjcSelf!(Object, "initWithXMLString:error:", NSString, id*)(string, &err); | |
62 | |
63 if (err) | |
64 error = new NSError(err); | |
65 | |
66 return result; | |
71 } | 67 } |
72 | 68 |
73 this (NSString string, NSError** error) | 69 this (NSString string, ref NSError error) |
74 { | 70 { |
75 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 71 typeof(this).alloc.initWithXMLString(string, error); |
76 id result = Bridge.invokeObjcMethod!(id, "initWithXMLString:error:", NSString, NSError**)(objcObject, string, error); | |
77 | |
78 if (result) | |
79 objcObject = ret; | |
80 | |
81 dObject = this; | |
82 } | 72 } |
83 | 73 |
84 NSArray elementsForName (NSString name) | 74 NSArray elementsForName (NSString name) |
85 { | 75 { |
86 return invokeObjcSelf!(NSArray, "elementsForName:", NSString)(name); | 76 return invokeObjcSelf!(NSArray, "elementsForName:", NSString)(name); |