diff dwt/browser/WindowCreator2.d @ 302:bfe1c57259e3

More browser code ported
author John Reimer<terminal.node@gmail.com>
date Tue, 12 Aug 2008 21:11:17 -0700
parents 44258e0b6687
children b72d84d1ba95
line wrap: on
line diff
--- a/dwt/browser/WindowCreator2.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/WindowCreator2.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,17 +7,19 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.WindowCreator2;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
 import dwt.DWT;
 import dwt.graphics.Point;
-import dwt.internal.C;
+//import dwt.internal.C;
 import dwt.internal.Platform;
 import dwt.internal.mozilla.XPCOM;
-import dwt.internal.mozilla.XPCOMObject;
+//import dwt.internal.mozilla.XPCOMObject;
 import dwt.internal.mozilla.nsIBaseWindow;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsISupports;
@@ -29,66 +31,22 @@
 import dwt.layout.FillLayout;
 import dwt.widgets.Shell;
 
-class WindowCreator2 {
-    XPCOMObject supports;
-    XPCOMObject windowCreator;
-    XPCOMObject windowCreator2;
+class WindowCreator2 : nsIWindowCreator2{
+//    XPCOMObject supports;
+//    XPCOMObject windowCreator;
+//    XPCOMObject windowCreator2;
     int refCount = 0;
 
-WindowCreator2 () {
-    createCOMInterfaces ();
+this () {
+//    createCOMInterfaces ();
 }
 
-int AddRef () {
+nsrefcnt AddRef () {
     refCount++;
     return refCount;
 }
 
-void createCOMInterfaces () {
-    /* Create each of the interfaces that this object implements */
-    supports = new XPCOMObject (new int[] {2, 0, 0}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-    };
-
-    windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
-    };
-
-    windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);}
-    };
-}
-
-void disposeCOMInterfaces () {
-    if (supports !is null) {
-        supports.dispose ();
-        supports = null;
-    }   
-    if (windowCreator !is null) {
-        windowCreator.dispose ();
-        windowCreator = null;   
-    }
-
-    if (windowCreator2 !is null) {
-        windowCreator2.dispose ();
-        windowCreator2 = null;  
-    }
-}
-
-int /*long*/ getAddress () {
-    return windowCreator.getAddress ();
-}
-
-int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+nsresult QueryInterface (nsID* riid, void** ppvObject) {
     if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
     nsID guid = new nsID ();
     XPCOM.memmove (guid, riid, nsID.sizeof);
@@ -113,9 +71,9 @@
     return XPCOM.NS_ERROR_NO_INTERFACE;
 }
             
-int Release () {
+nsresult Release () {
     refCount--;
-    if (refCount is 0) disposeCOMInterfaces ();
+    //if (refCount is 0) disposeCOMInterfaces ();
     return refCount;
 }