Mercurial > projects > dwt-linux
comparison dwt/browser/HelperAppLauncherDialogFactory.d @ 298:eec6ddb07873
More xpcom/mozilla port
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 22:25:43 -0700 |
parents | 93409d9838c5 |
children | 942da4b6558a |
comparison
equal
deleted
inserted
replaced
297:2f204a4aebc6 | 298:eec6ddb07873 |
---|---|
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.HelperAppLauncherDialogFactory; | 13 module dwt.browser.HelperAppLauncherDialogFactory; |
12 | 14 |
13 import dwt.dwthelper.utils; | 15 import dwt.dwthelper.utils; |
14 | 16 |
15 import dwt.internal.C; | 17 //import dwt.internal.C; |
16 import dwt.internal.mozilla.XPCOM; | 18 import dwt.internal.mozilla.XPCOM; |
17 import dwt.internal.mozilla.XPCOMObject; | 19 //import dwt.internal.mozilla.XPCOMObject; |
18 import dwt.internal.mozilla.nsID; | 20 import dwt.internal.mozilla.nsID; |
19 import dwt.internal.mozilla.nsIFactory; | 21 import dwt.internal.mozilla.nsIFactory; |
20 import dwt.internal.mozilla.nsISupports; | 22 import dwt.internal.mozilla.nsISupports; |
21 | 23 |
22 class HelperAppLauncherDialogFactory { | 24 class HelperAppLauncherDialogFactory : nsIFactory { |
23 XPCOMObject supports; | 25 //XPCOMObject supports; |
24 XPCOMObject factory; | 26 //XPCOMObject factory; |
25 int refCount = 0; | 27 int refCount = 0; |
26 | 28 |
27 HelperAppLauncherDialogFactory () { | 29 this () { |
28 createCOMInterfaces (); | 30 // createCOMInterfaces (); |
29 } | 31 } |
30 | 32 |
31 int AddRef () { | 33 nsrefcnt AddRef () { |
32 refCount++; | 34 refCount++; |
33 return refCount; | 35 return refCount; |
34 } | 36 } |
35 | 37 /+ |
36 void createCOMInterfaces () { | 38 void createCOMInterfaces () { |
37 /* Create each of the interfaces that this object implements */ | 39 /* Create each of the interfaces that this object implements */ |
38 supports = new XPCOMObject (new int[] {2, 0, 0}) { | 40 supports = new XPCOMObject (new int[] {2, 0, 0}) { |
39 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} | 41 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} |
40 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} | 42 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} |
62 } | 64 } |
63 | 65 |
64 int /*long*/ getAddress () { | 66 int /*long*/ getAddress () { |
65 return factory.getAddress (); | 67 return factory.getAddress (); |
66 } | 68 } |
67 | 69 +/ |
68 int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { | 70 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
69 if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; | 71 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
70 nsID guid = new nsID (); | 72 //nsID guid = new nsID (); |
71 XPCOM.memmove (guid, riid, nsID.sizeof); | 73 //XPCOM.memmove (guid, riid, nsID.sizeof); |
72 | 74 |
73 if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { | 75 if (*riid == nsISupports.IID) { |
74 XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); | 76 *ppvObject = cast(void*)cast(nsISupports)this; |
75 AddRef (); | 77 AddRef (); |
76 return XPCOM.NS_OK; | 78 return XPCOM.NS_OK; |
77 } | 79 } |
78 if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { | 80 if (*riid == nsIFactory.IID) { |
79 XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); | 81 *ppvObject = cast(void*)cast(nsIFactory)this; |
80 AddRef (); | 82 AddRef (); |
81 return XPCOM.NS_OK; | 83 return XPCOM.NS_OK; |
82 } | 84 } |
83 | 85 |
84 XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); | 86 *ppvObject = null; |
85 return XPCOM.NS_ERROR_NO_INTERFACE; | 87 return XPCOM.NS_ERROR_NO_INTERFACE; |
86 } | 88 } |
87 | 89 |
88 int Release () { | 90 nsrefcnt Release () { |
89 refCount--; | 91 refCount--; |
90 if (refCount is 0) disposeCOMInterfaces (); | 92 //if (refCount is 0) disposeCOMInterfaces (); |
91 return refCount; | 93 return refCount; |
92 } | 94 } |
93 | 95 |
94 /* nsIFactory */ | 96 /* nsIFactory */ |
95 | 97 |
96 int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { | 98 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) { |
97 HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog (); | 99 if (result is null) |
98 helperAppLauncherDialog.AddRef (); | 100 return XPCOM.NS_ERROR_INVALID_ARG; |
99 XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); | 101 auto helperAppLauncherDialog = new HelperAppLauncherDialog; |
100 return XPCOM.NS_OK; | 102 nsresult rv = helperAppLauncherDialog.QueryInterface( iid, result ); |
103 if (XPCOM.NS_FAILED(rv)) { | |
104 *result = null; | |
105 delete helperAppLauncherDialog; | |
106 } | |
107 return rv; | |
101 } | 108 } |
102 | 109 nsresult LockFactory (PRBool lock) { |
103 int LockFactory (int lock) { | |
104 return XPCOM.NS_OK; | 110 return XPCOM.NS_OK; |
105 } | 111 } |
106 } | 112 } |