Mercurial > projects > dwt-linux
annotate 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 |
rev | line source |
---|---|
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2003, 2007 IBM Corporation and others. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
7 * |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
10 * Port to the D programming language: |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
11 * John Reimer <terminal.node@gmail.com> |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
12 *******************************************************************************/ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
13 module dwt.browser.SimpleEnumerator; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
14 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
15 //import dwt.dwthelper.utils; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
16 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
17 //import dwt.internal.C; |
341
942da4b6558a
Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents:
302
diff
changeset
|
18 import XPCOM = dwt.internal.mozilla.XPCOM; |
344 | 19 |
20 import dwt.internal.mozilla.Common; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 import dwt.internal.mozilla.nsID; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
22 import dwt.internal.mozilla.nsISimpleEnumerator; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
23 import dwt.internal.mozilla.nsISupports; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
24 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
25 class SimpleEnumerator : nsISimpleEnumerator{ |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
26 int refCount = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
27 nsISupports[] values; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
28 int index = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
29 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
30 this (nsISupports[] values) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 this.values = values; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
32 for (int i = 0; i < values.length; i++) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
33 values[i].AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
34 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
35 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
36 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
37 extern(System) |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
38 nsrefcnt AddRef () { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
39 refCount++; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
40 return refCount; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
41 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
42 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
43 extern(System) |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
44 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
45 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
46 //nsID guid = new nsID (); |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
47 //XPCOM.memmove (guid, riid, nsID.sizeof); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
48 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
49 if (*riid == nsISupports.IID) { |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
50 *ppvObject = cast(void*)cast(nsISupports)this; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
51 AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
52 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
53 } |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
54 if (*riid == nsISimpleEnumerator.IID) { |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
55 *ppvObject = cast(void*)cast(nsISimpleEnumerator)this; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
56 AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
57 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
58 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
59 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
60 *ppvObject = null; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
61 return XPCOM.NS_ERROR_NO_INTERFACE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
62 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
63 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
64 extern(System) |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
65 nsresult Release () { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
66 refCount--; |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
67 //if (refCount is 0) disposeCOMInterfaces (); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
68 return refCount; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
69 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
70 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
71 extern(System) |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
72 nsresult HasMoreElements (PRBool* _retval) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
73 bool more = values !is null && index < values.length; |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
74 *_retval = more ? 1 : 0; /*PRBool */ |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
75 return XPCOM.NS_OK; |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
76 } |
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
77 |
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
78 extern(System) |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
79 nsresult GetNext (nsISupports* _retval) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
80 if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
81 nsISupports value = values[index++]; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
82 value.AddRef (); |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
278
diff
changeset
|
83 *_retval = value; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
84 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
85 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
86 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
87 |