comparison dwt/browser/SimpleEnumerator.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 8198e6052012
children
comparison
equal deleted inserted replaced
347:ff6dd48f5248 348:9a4d7706df52
21 import dwt.internal.mozilla.nsID; 21 import dwt.internal.mozilla.nsID;
22 import dwt.internal.mozilla.nsISimpleEnumerator; 22 import dwt.internal.mozilla.nsISimpleEnumerator;
23 import dwt.internal.mozilla.nsISupports; 23 import dwt.internal.mozilla.nsISupports;
24 24
25 class SimpleEnumerator : nsISimpleEnumerator{ 25 class SimpleEnumerator : nsISimpleEnumerator{
26 // XPCOMObject supports;
27 // XPCOMObject simpleEnumerator;
28 int refCount = 0; 26 int refCount = 0;
29 nsISupports[] values; 27 nsISupports[] values;
30 int index = 0; 28 int index = 0;
31 29
32 this (nsISupports[] values) { 30 this (nsISupports[] values) {
33 this.values = values; 31 this.values = values;
34 for (int i = 0; i < values.length; i++) { 32 for (int i = 0; i < values.length; i++) {
35 values[i].AddRef (); 33 values[i].AddRef ();
36 } 34 }
37 //createCOMInterfaces ();
38 } 35 }
39 36
37 extern(System)
40 nsrefcnt AddRef () { 38 nsrefcnt AddRef () {
41 refCount++; 39 refCount++;
42 return refCount; 40 return refCount;
43 } 41 }
44 42
43 extern(System)
45 nsresult QueryInterface (nsID* riid, void** ppvObject) { 44 nsresult QueryInterface (nsID* riid, void** ppvObject) {
46 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; 45 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
47 //nsID guid = new nsID (); 46 //nsID guid = new nsID ();
48 //XPCOM.memmove (guid, riid, nsID.sizeof); 47 //XPCOM.memmove (guid, riid, nsID.sizeof);
49 48
60 59
61 *ppvObject = null; 60 *ppvObject = null;
62 return XPCOM.NS_ERROR_NO_INTERFACE; 61 return XPCOM.NS_ERROR_NO_INTERFACE;
63 } 62 }
64 63
64 extern(System)
65 nsresult Release () { 65 nsresult Release () {
66 refCount--; 66 refCount--;
67 //if (refCount is 0) disposeCOMInterfaces (); 67 //if (refCount is 0) disposeCOMInterfaces ();
68 return refCount; 68 return refCount;
69 } 69 }
70 70
71 extern(System)
71 nsresult HasMoreElements (PRBool* _retval) { 72 nsresult HasMoreElements (PRBool* _retval) {
72 bool more = values !is null && index < values.length; 73 bool more = values !is null && index < values.length;
73 *_retval = more ? 1 : 0; /*PRBool */ 74 *_retval = more ? 1 : 0; /*PRBool */
74 return XPCOM.NS_OK; 75 return XPCOM.NS_OK;
75 } 76 }
76 77
78 extern(System)
77 nsresult GetNext (nsISupports* _retval) { 79 nsresult GetNext (nsISupports* _retval) {
78 if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED; 80 if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED;
79 nsISupports value = values[index++]; 81 nsISupports value = values[index++];
80 value.AddRef (); 82 value.AddRef ();
81 *_retval = value; 83 *_retval = value;