comparison 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
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
7 module dstep.foundation.NSXMLNode; 7 module dstep.foundation.NSXMLNode;
8 8
9 import dstep.foundation.NSArray; 9 import dstep.foundation.NSArray;
10 import dstep.foundation.NSDictionary; 10 import dstep.foundation.NSDictionary;
11 import dstep.foundation.NSError; 11 import dstep.foundation.NSError;
12 import dstep.foundation.NSObjCRuntime;
12 import dstep.foundation.NSObject; 13 import dstep.foundation.NSObject;
13 import dstep.foundation.NSString; 14 import dstep.foundation.NSString;
14 import dstep.foundation.NSURL; 15 import dstep.foundation.NSURL;
15 import dstep.foundation.NSXMLDocument; 16 import dstep.foundation.NSXMLDocument;
16 import dstep.foundation.NSXMLElement; 17 import dstep.foundation.NSXMLElement;
17 import dstep.foundation.NSXMLNodeOptions; 18 import dstep.foundation.NSXMLNodeOptions;
19 import dstep.foundation.NSZone;
18 import dstep.objc.bridge.Bridge; 20 import dstep.objc.bridge.Bridge;
19 import dstep.objc.objc : id; 21 import dstep.objc.objc;
20 22
21 alias NSUInteger NSXMLNodeKind; 23 alias NSUInteger NSXMLNodeKind;
22 24
23 enum 25 enum
24 { 26 {
37 NSXMLNotationDeclarationKind 39 NSXMLNotationDeclarationKind
38 } 40 }
39 41
40 class NSXMLNode : NSObject, INSCopying 42 class NSXMLNode : NSObject, INSCopying
41 { 43 {
42 mixin ObjcWrap; 44 mixin (ObjcWrap);
45
46 this ()
47 {
48 super(typeof(this).alloc.init.objcObject);
49 }
50
51 typeof(this) init ()
52 {
53 return invokeObjcSelf!(typeof(this), "init");
54 }
43 55
44 Object initWithKind (uint kind) 56 Object initWithKind (uint kind)
45 { 57 {
46 return invokeObjcSelf!(Object, "initWithKind:", uint)(kind); 58 return invokeObjcSelf!(Object, "initWithKind:", uint)(kind);
47 } 59 }
48 60
49 this (uint kind) 61 this (uint kind)
50 { 62 {
51 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 63 typeof(this).alloc.initWithKind(kind);
52 id result = Bridge.invokeObjcMethod!(id, "initWithKind:", uint)(objcObject, kind);
53
54 if (result)
55 objcObject = ret;
56
57 dObject = this;
58 } 64 }
59 65
60 Object initWithKind (uint kind, NSUInteger options) 66 Object initWithKind (uint kind, NSUInteger options)
61 { 67 {
62 return invokeObjcSelf!(Object, "initWithKind:options:", uint, NSUInteger)(kind, options); 68 return invokeObjcSelf!(Object, "initWithKind:options:", uint, NSUInteger)(kind, options);
63 } 69 }
64 70
65 this (uint kind, NSUInteger options) 71 this (uint kind, NSUInteger options)
66 { 72 {
67 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 73 typeof(this).alloc.initWithKind(kind, options);
68 id result = Bridge.invokeObjcMethod!(id, "initWithKind:options:", uint, NSUInteger)(objcObject, kind, options);
69
70 if (result)
71 objcObject = ret;
72
73 dObject = this;
74 } 74 }
75 75
76 static Object document () 76 static Object document ()
77 { 77 {
78 return invokeObjcSelfClass!(Object, "document"); 78 return invokeObjcSuperClass!(Object, "document");
79 } 79 }
80 80
81 static Object documentWithRootElement (NSXMLElement element) 81 static Object documentWithRootElement (NSXMLElement element)
82 { 82 {
83 return invokeObjcSelfClass!(Object, "documentWithRootElement:", NSXMLElement)(element); 83 return invokeObjcSuperClass!(Object, "documentWithRootElement:", NSXMLElement)(element);
84 } 84 }
85 85
86 static Object elementWithName (NSString name) 86 static Object elementWithName (NSString name)
87 { 87 {
88 return invokeObjcSelfClass!(Object, "elementWithName:", NSString)(name); 88 return invokeObjcSuperClass!(Object, "elementWithName:", NSString)(name);
89 } 89 }
90 90
91 static Object elementWithName (NSString name, NSString URI) 91 static Object elementWithName_URI (NSString name, NSString URI)
92 { 92 {
93 return invokeObjcSelfClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI); 93 return invokeObjcSuperClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI);
94 } 94 }
95 95
96 static Object elementWithName (NSString name, NSString string) 96 static Object elementWithName (NSString name, NSString string)
97 { 97 {
98 return invokeObjcSelfClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string); 98 return invokeObjcSuperClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string);
99 } 99 }
100 100
101 static Object elementWithName (NSString name, NSArray children, NSArray attributes) 101 static Object elementWithName (NSString name, NSArray children, NSArray attributes)
102 { 102 {
103 return invokeObjcSelfClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes); 103 return invokeObjcSuperClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes);
104 } 104 }
105 105
106 static Object attributeWithName (NSString name, NSString stringValue) 106 static Object attributeWithName (NSString name, NSString stringValue)
107 { 107 {
108 return invokeObjcSelfClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue); 108 return invokeObjcSuperClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue);
109 } 109 }
110 110
111 static Object attributeWithName (NSString name, NSString URI, NSString stringValue) 111 static Object attributeWithName (NSString name, NSString URI, NSString stringValue)
112 { 112 {
113 return invokeObjcSelfClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue); 113 return invokeObjcSuperClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue);
114 } 114 }
115 115
116 static Object namespaceWithName (NSString name, NSString stringValue) 116 static Object namespaceWithName (NSString name, NSString stringValue)
117 { 117 {
118 return invokeObjcSelfClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue); 118 return invokeObjcSuperClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue);
119 } 119 }
120 120
121 static Object processingInstructionWithName (NSString name, NSString stringValue) 121 static Object processingInstructionWithName (NSString name, NSString stringValue)
122 { 122 {
123 return invokeObjcSelfClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue); 123 return invokeObjcSuperClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue);
124 } 124 }
125 125
126 static Object commentWithStringValue (NSString stringValue) 126 static Object commentWithStringValue (NSString stringValue)
127 { 127 {
128 return invokeObjcSelfClass!(Object, "commentWithStringValue:", NSString)(stringValue); 128 return invokeObjcSuperClass!(Object, "commentWithStringValue:", NSString)(stringValue);
129 } 129 }
130 130
131 static Object textWithStringValue (NSString stringValue) 131 static Object textWithStringValue (NSString stringValue)
132 { 132 {
133 return invokeObjcSelfClass!(Object, "textWithStringValue:", NSString)(stringValue); 133 return invokeObjcSuperClass!(Object, "textWithStringValue:", NSString)(stringValue);
134 } 134 }
135 135
136 static Object DTDNodeWithXMLString (NSString string) 136 static Object DTDNodeWithXMLString (NSString string)
137 { 137 {
138 return invokeObjcSelfClass!(Object, "DTDNodeWithXMLString:", NSString)(string); 138 return invokeObjcSuperClass!(Object, "DTDNodeWithXMLString:", NSString)(string);
139 } 139 }
140 140
141 uint kind () 141 uint kind ()
142 { 142 {
143 return invokeObjcSelf!(uint, "kind"); 143 return invokeObjcSelf!(uint, "kind");
269 return invokeObjcSelf!(NSString, "URI"); 269 return invokeObjcSelf!(NSString, "URI");
270 } 270 }
271 271
272 static NSString localNameForName (NSString name) 272 static NSString localNameForName (NSString name)
273 { 273 {
274 return invokeObjcSelfClass!(NSString, "localNameForName:", NSString)(name); 274 return invokeObjcSuperClass!(NSString, "localNameForName:", NSString)(name);
275 } 275 }
276 276
277 static NSString prefixForName (NSString name) 277 static NSString prefixForName (NSString name)
278 { 278 {
279 return invokeObjcSelfClass!(NSString, "prefixForName:", NSString)(name); 279 return invokeObjcSuperClass!(NSString, "prefixForName:", NSString)(name);
280 } 280 }
281 281
282 static NSXMLNode predefinedNamespaceForPrefix (NSString name) 282 static NSXMLNode predefinedNamespaceForPrefix (NSString name)
283 { 283 {
284 return invokeObjcSelfClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name); 284 return invokeObjcSuperClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name);
285 } 285 }
286 286
287 NSString description () 287 NSString description ()
288 { 288 {
289 return invokeObjcSelf!(NSString, "description"); 289 return invokeObjcSelf!(NSString, "description");
302 NSString canonicalXMLStringPreservingComments (bool comments) 302 NSString canonicalXMLStringPreservingComments (bool comments)
303 { 303 {
304 return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments); 304 return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments);
305 } 305 }
306 306
307 NSArray nodesForXPath (NSString xpath, NSError** error) 307 NSArray nodesForXPath (NSString xpath, ref NSError error)
308 { 308 {
309 return invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, NSError**)(xpath, error); 309 id err = error ? new objc_object : null;
310 } 310 NSArray result = invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, id*)(xpath, &err);
311 311
312 NSArray objectsForXQuery (NSString xquery, NSDictionary constants, NSError** error) 312 if (err)
313 { 313 error = new NSError(err);
314 return invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, NSError**)(xquery, constants, error); 314
315 } 315 return result;
316 316 }
317 NSArray objectsForXQuery (NSString xquery, NSError** error) 317
318 { 318 NSArray objectsForXQuery (NSString xquery, NSDictionary constants, ref NSError error)
319 return invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, NSError**)(xquery, error); 319 {
320 id err = error ? new objc_object : null;
321 NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, id*)(xquery, constants, &err);
322
323 if (err)
324 error = new NSError(err);
325
326 return result;
327 }
328
329 NSArray objectsForXQuery (NSString xquery, ref NSError error)
330 {
331 id err = error ? new objc_object : null;
332 NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, id*)(xquery, &err);
333
334 if (err)
335 error = new NSError(err);
336
337 return result;
320 } 338 }
321 339
322 Object copyWithZone (NSZone* zone) 340 Object copyWithZone (NSZone* zone)
323 { 341 {
324 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); 342 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);