comparison dwt/browser/FilePickerFactory.d @ 348:9a4d7706df52

Test Update to fix linux XPCOM interface issues
author John Reimer <terminal.node@gmail.com>
date Fri, 31 Oct 2008 21:46:44 -0700
parents 5abc6f7f7a95
children
comparison
equal deleted inserted replaced
347:ff6dd48f5248 348:9a4d7706df52
27 class FilePickerFactory : nsIFactory { 27 class FilePickerFactory : nsIFactory {
28 //XPCOMObject supports; 28 //XPCOMObject supports;
29 //XPCOMObject factory; 29 //XPCOMObject factory;
30 int refCount = 0; 30 int refCount = 0;
31 31
32 this () { 32 this () { }
33 // createCOMInterfaces ();
34 }
35 33
34 extern(System)
36 nsrefcnt AddRef () { 35 nsrefcnt AddRef () {
37 refCount++; 36 refCount++;
38 return refCount; 37 return refCount;
39 } 38 }
40 /+
41 void createCOMInterfaces () {
42 /* Create each of the interfaces that this object implements */
43 supports = new XPCOMObject (new int[] {2, 0, 0}) {
44 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
45 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
46 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
47 };
48
49 factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
50 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
51 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
52 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
53 public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
54 public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
55 };
56 }
57 39
58 void disposeCOMInterfaces () { 40 extern(System)
59 if (supports !is null) {
60 supports.dispose ();
61 supports = null;
62 }
63 if (factory !is null) {
64 factory.dispose ();
65 factory = null;
66 }
67 }
68
69 int /*long*/ getAddress () {
70 return factory.getAddress ();
71 }
72 +/
73 nsresult QueryInterface (nsID* riid, void** ppvObject) { 41 nsresult QueryInterface (nsID* riid, void** ppvObject) {
74 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; 42 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
75 //nsID guid = new nsID (); 43 //nsID guid = new nsID ();
76 //XPCOM.memmove (guid, riid, nsID.sizeof); 44 //XPCOM.memmove (guid, riid, nsID.sizeof);
77 45
88 56
89 *ppvObject = null; 57 *ppvObject = null;
90 return XPCOM.NS_ERROR_NO_INTERFACE; 58 return XPCOM.NS_ERROR_NO_INTERFACE;
91 } 59 }
92 60
61 extern(System)
93 nsrefcnt Release () { 62 nsrefcnt Release () {
94 refCount--; 63 refCount--;
95 //if (refCount is 0) disposeCOMInterfaces (); 64 //if (refCount is 0) disposeCOMInterfaces ();
96 return refCount; 65 return refCount;
97 } 66 }
98 67
99 /* nsIFactory */ 68 /* nsIFactory */
100 69
70 extern(System)
101 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) { 71 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) {
102 if (result is null) 72 if (result is null)
103 return XPCOM.NS_ERROR_INVALID_ARG; 73 return XPCOM.NS_ERROR_INVALID_ARG;
104 auto picker = new FilePicker; 74 auto picker = new FilePicker;
105 nsresult rv = picker.QueryInterface( iid, result ); 75 nsresult rv = picker.QueryInterface( iid, result );
108 delete picker; 78 delete picker;
109 } 79 }
110 return rv; 80 return rv;
111 } 81 }
112 82
83 extern(System)
113 nsresult LockFactory (PRBool lock) { 84 nsresult LockFactory (PRBool lock) {
114 return XPCOM.NS_OK; 85 return XPCOM.NS_OK;
115 } 86 }
116 } 87 }