comparison dwt/internal/cocoa/NSURL.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSURL; 14 module dwt.internal.cocoa.NSURL;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.NSData; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSNumber;
19 import dwt.internal.cocoa.NSObject; 18 import dwt.internal.cocoa.NSObject;
19 import dwt.internal.cocoa.NSPasteboard;
20 import dwt.internal.cocoa.NSString; 20 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.NSURLHandle;
22 import dwt.internal.cocoa.OS; 21 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime; 22 import objc = dwt.internal.objc.runtime;
24 23
25 public class NSURL : NSObject 24 public class NSURL : NSObject {
26 {
27 25
28 public this () 26 public this() {
29 { 27 super();
30 super(); 28 }
31 }
32 29
33 public this (objc.id id) 30 public this(objc.id id) {
34 { 31 super(id);
35 super(id); 32 }
36 }
37 33
38 public NSURLHandle URLHandleUsingCache (bool shouldUseCache) 34 public this(cocoa.id id) {
39 { 35 super(id);
40 objc.id result = OS.objc_msgSend(this.id_, OS.sel_URLHandleUsingCache_1, shouldUseCache); 36 }
41 return result !is null ? new NSURLHandle(result) : null;
42 }
43 37
44 public static NSURL static_URLWithString_ (NSString URLString) 38 public static NSURL URLFromPasteboard(NSPasteboard pasteBoard) {
45 { 39 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLFromPasteboard_, pasteBoard !is null ? pasteBoard.id : null);
46 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLWithString_1, URLString !is null ? URLString.id_ : null); 40 return result !is null ? new NSURL(result) : null;
47 return result !is null ? new NSURL(result) : null; 41 }
48 }
49 42
50 public static id static_URLWithString_relativeToURL_ (NSString URLString, NSURL baseURL) 43 public void writeToPasteboard(NSPasteboard pasteBoard) {
51 { 44 OS.objc_msgSend(this.id, OS.sel_writeToPasteboard_, pasteBoard !is null ? pasteBoard.id : null);
52 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLWithString_1relativeToURL_1, URLString !is null ? URLString.id_ : null, 45 }
53 baseURL !is null ? baseURL.id_ : null);
54 return result !is null ? new id(result) : null;
55 }
56 46
57 public NSString absoluteString () 47 public static NSURL URLWithString(NSString URLString) {
58 { 48 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLWithString_, URLString !is null ? URLString.id : null);
59 objc.id result = OS.objc_msgSend(this.id_, OS.sel_absoluteString); 49 return result !is null ? new NSURL(result) : null;
60 return result !is null ? new NSString(result) : null; 50 }
61 }
62 51
63 public NSURL absoluteURL () 52 public NSString absoluteString() {
64 { 53 objc.id result = OS.objc_msgSend(this.id, OS.sel_absoluteString);
65 objc.id result = OS.objc_msgSend(this.id_, OS.sel_absoluteURL); 54 return result !is null ? new NSString(result) : null;
66 return result is this.id_ ? this : (result !is null ? new NSURL(result) : null); 55 }
67 }
68 56
69 public NSURL baseURL () 57 public static NSURL fileURLWithPath(NSString path) {
70 { 58 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_fileURLWithPath_, path !is null ? path.id : null);
71 objc.id result = OS.objc_msgSend(this.id_, OS.sel_baseURL); 59 return result !is null ? new NSURL(result) : null;
72 return result is this.id_ ? this : (result !is null ? new NSURL(result) : null); 60 }
73 }
74
75 public static NSURL static_fileURLWithPath_ (NSString path)
76 {
77 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_fileURLWithPath_1, path !is null ? path.id_ : null);
78 return result !is null ? new NSURL(result) : null;
79 }
80
81 public static id static_fileURLWithPath_isDirectory_ (NSString path, bool isDir)
82 {
83 objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_fileURLWithPath_1isDirectory_1, path !is null ? path.id_ : null, isDir);
84 return result !is null ? new id(result) : null;
85 }
86
87 public NSString fragment ()
88 {
89 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fragment);
90 return result !is null ? new NSString(result) : null;
91 }
92
93 public NSString host ()
94 {
95 objc.id result = OS.objc_msgSend(this.id_, OS.sel_host);
96 return result !is null ? new NSString(result) : null;
97 }
98
99 public id initFileURLWithPath_ (NSString path)
100 {
101 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initFileURLWithPath_1, path !is null ? path.id_ : null);
102 return result !is null ? new id(result) : null;
103 }
104
105 public id initFileURLWithPath_isDirectory_ (NSString path, bool isDir)
106 {
107 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initFileURLWithPath_1isDirectory_1, path !is null ? path.id_ : null, isDir);
108 return result !is null ? new id(result) : null;
109 }
110
111 public id initWithScheme (NSString scheme, NSString host, NSString path)
112 {
113 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithScheme_1host_1path_1, scheme !is null ? scheme.id_ : null,
114 host !is null ? host.id_ : null, path !is null ? path.id_ : null);
115 return result !is null ? new id(result) : null;
116 }
117
118 public id initWithString_ (NSString URLString)
119 {
120 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, URLString !is null ? URLString.id_ : null);
121 return result !is null ? new id(result) : null;
122 }
123
124 public id initWithString_relativeToURL_ (NSString URLString, NSURL baseURL)
125 {
126 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1relativeToURL_1, URLString !is null ? URLString.id_ : null,
127 baseURL !is null ? baseURL.id_ : null);
128 return result !is null ? new id(result) : null;
129 }
130
131 public bool isFileURL ()
132 {
133 return OS.objc_msgSend(this.id_, OS.sel_isFileURL) !is null;
134 }
135
136 public void loadResourceDataNotifyingClient (id client, bool shouldUseCache)
137 {
138 OS.objc_msgSend(this.id_, OS.sel_loadResourceDataNotifyingClient_1usingCache_1, client !is null ? client.id_ : null, shouldUseCache);
139 }
140
141 public NSString parameterString ()
142 {
143 objc.id result = OS.objc_msgSend(this.id_, OS.sel_parameterString);
144 return result !is null ? new NSString(result) : null;
145 }
146
147 public NSString password ()
148 {
149 objc.id result = OS.objc_msgSend(this.id_, OS.sel_password);
150 return result !is null ? new NSString(result) : null;
151 }
152
153 public NSString path ()
154 {
155 objc.id result = OS.objc_msgSend(this.id_, OS.sel_path);
156 return result !is null ? new NSString(result) : null;
157 }
158
159 public NSNumber port ()
160 {
161 objc.id result = OS.objc_msgSend(this.id_, OS.sel_port);
162 return result !is null ? new NSNumber(result) : null;
163 }
164
165 public id propertyForKey (NSString propertyKey)
166 {
167 objc.id result = OS.objc_msgSend(this.id_, OS.sel_propertyForKey_1, propertyKey !is null ? propertyKey.id_ : null);
168 return result !is null ? new id(result) : null;
169 }
170
171 public NSString query ()
172 {
173 objc.id result = OS.objc_msgSend(this.id_, OS.sel_query);
174 return result !is null ? new NSString(result) : null;
175 }
176
177 public NSString relativePath ()
178 {
179 objc.id result = OS.objc_msgSend(this.id_, OS.sel_relativePath);
180 return result !is null ? new NSString(result) : null;
181 }
182
183 public NSString relativeString ()
184 {
185 objc.id result = OS.objc_msgSend(this.id_, OS.sel_relativeString);
186 return result !is null ? new NSString(result) : null;
187 }
188
189 public NSData resourceDataUsingCache (bool shouldUseCache)
190 {
191 objc.id result = OS.objc_msgSend(this.id_, OS.sel_resourceDataUsingCache_1, shouldUseCache);
192 return result !is null ? new NSData(result) : null;
193 }
194
195 public NSString resourceSpecifier ()
196 {
197 objc.id result = OS.objc_msgSend(this.id_, OS.sel_resourceSpecifier);
198 return result !is null ? new NSString(result) : null;
199 }
200
201 public NSString scheme ()
202 {
203 objc.id result = OS.objc_msgSend(this.id_, OS.sel_scheme);
204 return result !is null ? new NSString(result) : null;
205 }
206
207 public bool setProperty (id property, NSString propertyKey)
208 {
209 return OS.objc_msgSend(this.id_, OS.sel_setProperty_1forKey_1, property !is null ? property.id_ : null,
210 propertyKey !is null ? propertyKey.id_ : null) !is null;
211 }
212
213 public bool setResourceData (NSData data)
214 {
215 return OS.objc_msgSend(this.id_, OS.sel_setResourceData_1, data !is null ? data.id_ : null) !is null;
216 }
217
218 public NSURL standardizedURL ()
219 {
220 objc.id result = OS.objc_msgSend(this.id_, OS.sel_standardizedURL);
221 return result is this.id_ ? this : (result !is null ? new NSURL(result) : null);
222 }
223
224 public NSString user ()
225 {
226 objc.id result = OS.objc_msgSend(this.id_, OS.sel_user);
227 return result !is null ? new NSString(result) : null;
228 }
229 61
230 } 62 }