Mercurial > projects > dwt-linux
comparison dwt/browser/FilePicker_1_8.d @ 286:44258e0b6687
More fixes for xpcom
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 10:11:58 -0700 |
parents | 93409d9838c5 |
children | eec6ddb07873 |
comparison
equal
deleted
inserted
replaced
280:e72345914350 | 286:44258e0b6687 |
---|---|
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 * Port to the D programming language: | |
11 * John Reimer <terminal.node@gmail.com> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.browser.FilePicker_1_8; | 13 module dwt.browser.FilePicker_1_8; |
12 | 14 |
13 import dwt.dwthelper.utils; | 15 import dwt.dwthelper.utils; |
14 | 16 |
17 import dwt.browser.FilePicker; | |
15 import dwt.internal.mozilla.XPCOM; | 18 import dwt.internal.mozilla.XPCOM; |
16 import dwt.internal.mozilla.XPCOMObject; | 19 import dwt.internal.mozilla.nsStringAPI; |
17 | 20 |
18 class FilePicker_1_8 extends FilePicker { | 21 class FilePicker_1_8 : FilePicker { |
19 | 22 |
20 void createCOMInterfaces () { | 23 String parseAString (nsAString* string) { |
21 /* Create each of the interfaces that this object implements */ | 24 if (string is null) return null; |
22 supports = new XPCOMObject (new int[] {2, 0, 0}) { | 25 return Utf.toString(nsAString.getString16(string)); |
23 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} | |
24 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} | |
25 public int /*long*/ method2 (int /*long*/[] args) {return Release ();} | |
26 }; | |
27 | |
28 filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { | |
29 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} | |
30 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} | |
31 public int /*long*/ method2 (int /*long*/[] args) {return Release ();} | |
32 public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);} | |
33 public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);} | |
34 public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);} | |
35 public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);} | |
36 public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);} | |
37 public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);} | |
38 public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);} | |
39 public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);} | |
40 public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);} | |
41 public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);} | |
42 public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);} | |
43 public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);} | |
44 public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);} | |
45 public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);} | |
46 public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);} | |
47 }; | |
48 } | |
49 | |
50 /* | |
51 * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method | |
52 * answers a java string based on the type of string that is appropriate for the Mozilla | |
53 * version being used. | |
54 */ | |
55 String parseAString (int /*long*/ string) { | |
56 if (string is 0) return null; | |
57 int length = XPCOM.nsEmbedString_Length (string); | |
58 int /*long*/ buffer = XPCOM.nsEmbedString_get (string); | |
59 char[] chars = new char[length]; | |
60 XPCOM.memmove (chars, buffer, length * 2); | |
61 return new String (chars); | |
62 } | 26 } |
63 } | 27 } |