# HG changeset patch # User John Reimer # Date 1217956318 25200 # Node ID 44258e0b66873981093f87365611bdc109d47d75 # Parent e72345914350aa9d42d5091188c033d9abfca6d9 More fixes for xpcom diff -r e72345914350 -r 44258e0b6687 dwt/browser/AppFileLocProvider.d --- a/dwt/browser/AppFileLocProvider.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/AppFileLocProvider.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,103 +7,91 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer + * Port to the D programming language: + * John Reimer *******************************************************************************/ +module dwt.browser.AppFileLocProvider; -module dwt.browser.AppFileLocProvider; +import tango.sys.Environment; +import tango.text.Util; import dwt.dwthelper.utils; import dwt.internal.Compatibility; - +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsEmbedString; import dwt.internal.mozilla.nsID; -import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIDirectoryServiceProvider; +import dwt.internal.mozilla.nsIDirectoryServiceProvider2; import dwt.internal.mozilla.nsIFile; import dwt.internal.mozilla.nsILocalFile; import dwt.internal.mozilla.nsISupports; -class AppFileLocProvider : nsISupports, nsIDirectoryServiceProvider2 -{ - // XPCOMObject supports; - // XPCOMObject directoryServiceProvider; - // XPCOMObject directoryServiceProvider2; - nsrefcnt _refCount = 0; - String mozillaPath, profilePath; +class AppFileLocProvider : directoryServiceProvider2 { + int refCount = 0; + String mozillaPath, profilePath; String[] pluginDirs; - bool isXULRunner; + bool isXULRunner; - static String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ - static String CHROME_DIR = "chrome"; //$NON-NLS-1$ - static String COMPONENTS_DIR = "components"; //$NON-NLS-1$ - static String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ - static String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ - static String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ - static String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ - static String USER_PLUGINS_DIR = ".mozilla" + SEPARATOR_OS + "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ - static String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ + static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ + static final String CHROME_DIR = "chrome"; //$NON-NLS-1$ + static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$ + static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ + static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ + static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ + static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ + static final String USER_PLUGINS_DIR = ".mozilla" ~ SEPARATOR_OS ~ "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ + static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ -AppFileLocProvider (String path) { - mozillaPath = path + SEPARATOR_OS; - createCOMInterfaces (); +this (String path) { + mozillaPath = path ~ SEPARATOR_OS;f +} + +int AddRef () { + refCount++; + return refCount; } - int AddRef () - { - refCount++; - return refCount; - } - - nsresult QueryInterface ( nsIID* riid, void** ppvObject) - { - if (riid is null || ppvObject is null) - return NS_ERROR_NO_INTERFACE; - - if (riid == nsISupports.IID) - { - *ppvObject =cast(void*)cast(nsISupports)this; - AddRef (); - return NS_OK; - } +int QueryInterface (nsID* riid, int void** ppvObject) { + if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; - if (riid == nsIDirectoryServiceProvider.IID) - { - *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; - AddRef (); - return NS_OK; - } + if (*riid == nsISupports.IID)) { + *ppvObject = cast(void*)cast(nsISupports)this; + AddRef (); + return XPCOM.NS_OK; + } + if (*riid == nsIDirectoryServiceProvider.IID) { + *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; + AddRef (); + return XPCOM.NS_OK; + } + if (*riid == nsIDirectoryServiceProvider2.IID) { + *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; + AddRef (); + return XPCOM.NS_OK; + } + + *ppvObject = null; + return XPCOM.NS_ERROR_NO_INTERFACE; +} - if (riid == nsDirectoryServiceProvider2.IID) { - *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; - AddRef (); - return NS_OK; - } - - *ppvObject = null; - return NS_ERROR_NO_INTERFACE; - } - - nsrefcnt Release () - { - _refCount--; - if (_refCount is 0) - return 0; - return _refCount; - } +int Release () { + refCount--; + if (refCount is 0) return 0; + return refCount; +} void setProfilePath (String path) { profilePath = path; if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ - int /*long*/[] result = new int /*long*/[1]; - nsEmbedString pathString = new nsEmbedString (path); - int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + nsILocalFile result; + scope auto nsEmbedString pathString = new nsEmbedString (path); + int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &result); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - pathString.dispose (); + if (result is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - nsILocalFile file = new nsILocalFile (result [0]); - rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700); + rc = result.Create (nsILocalFile.DIRECTORY_TYPE, 0700); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); file.Release (); } @@ -111,43 +99,20 @@ /* nsIDirectoryServiceProvider2 */ -int getFiles (int /*long*/ prop, int /*long*/ _retval) { - int size = XPCOM.strlen (prop); - byte[] bytes = new byte[size]; - XPCOM.memmove (bytes, prop, size); - String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); +nsresult GetFiles (char* prop, nsISimpleEnumerator* _retval) { + String propertyName = tango.stdc.stringz.fromStringz( prop ); String[] propertyValues = null; - if (propertyName.equals (XPCOM.NS_APP_PLUGINS_DIR_LIST)) { + if (propertyName == XPCOM.NS_APP_PLUGINS_DIR_LIST) { if (pluginDirs is null) { int index = 0; /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ - int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_PLUGIN_PATH, true)); - if (ptr !is 0) { - int length = C.strlen (ptr); - byte[] buffer = new byte[length]; - C.memmove (buffer, ptr, length); - String value = new String (MozillaDelegate.mbcsToWcs (null, buffer)); - if (value.length () > 0) { + String value = Environment.get (XPCOM.MOZILLA_PLUGIN_PATH); + if (ptr !is null) { + if (value.length > 0) { String separator = System.getProperty ("path.separator"); // $NON-NLS-1$ - Vector segments = new Vector (); - int start, end = -1; - do { - start = end + 1; - end = value.indexOf (separator, start); - String segment; - if (end is -1) { - segment = value.substring (start); - } else { - segment = value.substring (start, end); - } - if (segment.length () > 0) segments.addElement (segment); - } while (end !is -1); - int segmentsSize = segments.size (); - pluginDirs = new String [segmentsSize + 2]; - for (index = 0; index < segmentsSize; index++) { - pluginDirs[index] = (String)segments.elementAt (index); - } + foreach (segment; delimiter(value, separator)) + pluginDirs ~= segment; } } if (pluginDirs is null) { @@ -155,39 +120,36 @@ } /* set the next value to the GRE path + "plugins" */ - pluginDirs[index++] = mozillaPath + PLUGINS_DIR; + pluginDirs ~= mozillaPath ~ PLUGINS_DIR; /* set the next value to the home directory + "/.mozilla/plugins" */ - pluginDirs[index++] = System.getProperty("user.home") + SEPARATOR_OS + USER_PLUGINS_DIR; + pluginDirs ~= System.getProperty("user.home") ~ SEPARATOR_OS ~ USER_PLUGINS_DIR; } propertyValues = pluginDirs; } - XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); + *_retval = null; + //XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); if (propertyValues !is null) { - int /*long*/[] result = new int /*long*/[1]; + nsILocalFile localFile; + nsIFile file; nsISupports[] files = new nsISupports [propertyValues.length]; int index = 0; for (int i = 0; i < propertyValues.length; i++) { - nsEmbedString pathString = new nsEmbedString (propertyValues[i]); - int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + scope auto pathString = new nsEmbedString (propertyValues[i]); + int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) { /* value appears to be a valid pathname */ if (rc !is XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - nsILocalFile localFile = new nsILocalFile (result[0]); - result[0] = 0; - rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); + rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, &(cast(void*)file)); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); localFile.Release (); - nsIFile file = new nsIFile (result[0]); - files[index++] = file; + files[index++] = cast(nsISupports)file; } - pathString.dispose (); - result[0] = 0; } if (index < propertyValues.length) { @@ -197,9 +159,9 @@ files = temp; } - SimpleEnumerator enumerator = new SimpleEnumerator (files); + auto enumerator = new SimpleEnumerator (files); enumerator.AddRef (); - XPCOM.memmove (_retval, new int /*long*/[] {enumerator.getAddress ()}, C.PTR_SIZEOF); + *_retval = cast(nsISimpleEnumerator)enumerator; return XPCOM.NS_OK; } @@ -208,46 +170,43 @@ /* nsIDirectoryServiceProvider implementation */ -int getFile(int /*long*/ prop, int /*long*/ persistent, int /*long*/ _retval) { - int size = XPCOM.strlen (prop); - byte[] bytes = new byte[size]; - XPCOM.memmove (bytes, prop, size); - String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); +nsresult GetFile(char* prop, PRBool* persistent, nsIFile* _retval) { + String propertyName = tango.stdc.stringz.fromStringz( prop ); String propertyValue = null; - if (propertyName.equals (XPCOM.NS_APP_HISTORY_50_FILE)) { - propertyValue = profilePath + HISTORY_FILE; - } else if (propertyName.equals (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { - propertyValue = profilePath + MIMETYPES_FILE; - } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_FILE)) { - propertyValue = profilePath + PREFERENCES_FILE; - } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_DIR)) { + if (propertyName == (XPCOM.NS_APP_HISTORY_50_FILE)) { + propertyValue = profilePath ~ HISTORY_FILE; + } else if (propertyName == (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { + propertyValue = profilePath ~ MIMETYPES_FILE; + } else if (propertyName == (XPCOM.NS_APP_PREFS_50_FILE)) { + propertyValue = profilePath ~ PREFERENCES_FILE; + } else if (propertyName == (XPCOM.NS_APP_PREFS_50_DIR)) { propertyValue = profilePath; - } else if (propertyName.equals (XPCOM.NS_APP_USER_CHROME_DIR)) { - propertyValue = profilePath + CHROME_DIR; - } else if (propertyName.equals (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { + } else if (propertyName == (XPCOM.NS_APP_USER_CHROME_DIR)) { + propertyValue = profilePath ~ CHROME_DIR; + } else if (propertyName == (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { propertyValue = profilePath; - } else if (propertyName.equals (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { - propertyValue = profilePath + LOCALSTORE_FILE; - } else if (propertyName.equals (XPCOM.NS_APP_CACHE_PARENT_DIR)) { + } else if (propertyName == (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { + propertyValue = profilePath ~ LOCALSTORE_FILE; + } else if (propertyName == (XPCOM.NS_APP_CACHE_PARENT_DIR)) { propertyValue = profilePath; - } else if (propertyName.equals (XPCOM.NS_OS_HOME_DIR)) { + } else if (propertyName == (XPCOM.NS_OS_HOME_DIR)) { propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ - } else if (propertyName.equals (XPCOM.NS_OS_TEMP_DIR)) { + } else if (propertyName == (XPCOM.NS_OS_TEMP_DIR)) { propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ - } else if (propertyName.equals (XPCOM.NS_GRE_DIR)) { + } else if (propertyName == (XPCOM.NS_GRE_DIR)) { propertyValue = mozillaPath; - } else if (propertyName.equals (XPCOM.NS_GRE_COMPONENT_DIR)) { - propertyValue = mozillaPath + COMPONENTS_DIR; - } else if (propertyName.equals (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { + } else if (propertyName == (XPCOM.NS_GRE_COMPONENT_DIR)) { + propertyValue = mozillaPath ~ COMPONENTS_DIR; + } else if (propertyName == (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { propertyValue = mozillaPath; - } else if (propertyName.equals (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { + } else if (propertyName == (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { propertyValue = mozillaPath; - } else if (propertyName.equals (XPCOM.NS_XPCOM_COMPONENT_DIR)) { - propertyValue = mozillaPath + COMPONENTS_DIR; - } else if (propertyName.equals (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { + } else if (propertyName == (XPCOM.NS_XPCOM_COMPONENT_DIR)) { + propertyValue = mozillaPath ~ COMPONENTS_DIR; + } else if (propertyName == (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { propertyValue = mozillaPath; - } else if (propertyName.equals (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { + } else if (propertyName == (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { /* * Answering a value for this property causes problems in Mozilla versions * < 1.7. Unfortunately this property is queried early enough in the @@ -261,23 +220,21 @@ if (isXULRunner) propertyValue = profilePath; } - XPCOM.memmove (persistent, new int[] {1}, 4); /* PRBool */ - XPCOM.memmove (_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); - if (propertyValue !is null && propertyValue.length () > 0) { - int /*long*/[] result = new int /*long*/[1]; - nsEmbedString pathString = new nsEmbedString (propertyValue); - int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + *persistent = true; /* PRBool */ + *_retval = null; + if (propertyValue !is null && propertyValue.length > 0) { + nsILocalFile localFile; + scope auto pathString = new nsEmbedString (propertyValue); + int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - pathString.dispose (); + if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - nsILocalFile localFile = new nsILocalFile (result [0]); - result[0] = 0; - rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); + nsIFile file; + rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, &(cast(void*)file)); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); - XPCOM.memmove (_retval, new int /*long*/[] {result[0]}, C.PTR_SIZEOF); + *_retval = file; localFile.Release (); return XPCOM.NS_OK; } diff -r e72345914350 -r 44258e0b6687 dwt/browser/Browser.d --- a/dwt/browser/Browser.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/Browser.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.Browser; @@ -40,7 +42,7 @@ * @since 3.0 */ -public class Browser extends Composite { +public class Browser : Composite { WebBrowser webBrowser; int userStyle; @@ -77,40 +79,23 @@ * * @since 3.0 */ -public Browser (Composite parent, int style) { +public this (Composite parent, int style) { super (checkParent (parent), checkStyle (style)); userStyle = style; String platform = DWT.getPlatform (); Display display = parent.getDisplay (); - if ("gtk".equals (platform)) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$ + if ("gtk" == platform) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$ + /* String className = null; if ((style & DWT.MOZILLA) !is 0) { className = "dwt.browser.Mozilla"; //$NON-NLS-1$ } else { - if ("win32".equals (platform) || "wpf".equals (platform)) { //$NON-NLS-1$ $NON-NLS-2$ - className = "dwt.browser.IE"; //$NON-NLS-1$ - } else if ("motif".equals (platform)) { //$NON-NLS-1$ - className = "dwt.browser.Mozilla"; //$NON-NLS-1$ - } else if ("gtk".equals (platform)) { //$NON-NLS-1$ - className = "dwt.browser.Mozilla"; //$NON-NLS-1$ - } else if ("carbon".equals (platform) || "cocoa".equals (platform)) { //$NON-NLS-1$ - className = "dwt.browser.Safari"; //$NON-NLS-1$ - } else if ("photon".equals (platform)) { //$NON-NLS-1$ - className = "dwt.browser.Voyager"; //$NON-NLS-1$ - } else { - dispose (); - DWT.error (DWT.ERROR_NO_HANDLES); - } + dispose(); + DWT.error(DWT.ERROR_NO_HANDLES); } - - try { - Class clazz = Class.forName (className); - webBrowser = (WebBrowser)clazz.newInstance (); - } catch (ClassNotFoundException e) { - } catch (IllegalAccessException e) { - } catch (InstantiationException e) { - } + */ + auto webBrowser = new Mozilla; if (webBrowser is null) { dispose (); DWT.error (DWT.ERROR_NO_HANDLES); @@ -122,7 +107,7 @@ static Composite checkParent (Composite parent) { String platform = DWT.getPlatform (); - if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$ + if (!("gtk" == platform)) return parent; //$NON-NLS-1$ /* * Note. Mozilla provides all IM support needed for text input in web pages. @@ -144,18 +129,18 @@ static int checkStyle(int style) { String platform = DWT.getPlatform (); if ((style & DWT.MOZILLA) !is 0) { - if ("carbon".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$ - if ("motif".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$ + if ("carbon" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$ + if ("motif" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$ return style; } - if ("win32".equals (platform)) { //$NON-NLS-1$ + if ("win32" == platform) { //$NON-NLS-1$ /* * For IE on win32 the border is supplied by the embedded browser, so remove * the style so that the parent Composite will not draw a second border. */ return style & ~DWT.BORDER; - } else if ("motif".equals (platform)) { //$NON-NLS-1$ + } else if ("motif" == platform) { //$NON-NLS-1$ return style | DWT.EMBEDDED; } return style; @@ -371,9 +356,10 @@ } protected void checkSubclass () { - String name = getClass ().getName (); - int index = name.lastIndexOf ('.'); - if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) { + String name = this.classinfo.name; + + int index = tango.text.Util.locatePrior(name, '.'); + if (!(name[0 .. index + 1] == PACKAGE_PREFIX)) { DWT.error (DWT.ERROR_INVALID_SUBCLASS); } } diff -r e72345914350 -r 44258e0b6687 dwt/browser/CloseWindowListener.d --- a/dwt/browser/CloseWindowListener.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/CloseWindowListener.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,11 +7,11 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.CloseWindowListener; -import dwt.dwthelper.utils; - import dwt.internal.DWTEventListener; /** @@ -47,5 +47,5 @@ * * @since 3.0 */ - public void close(WindowEvent event); +public void close(WindowEvent event); } diff -r e72345914350 -r 44258e0b6687 dwt/browser/Download.d --- a/dwt/browser/Download.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/Download.d Tue Aug 05 10:11:58 2008 -0700 @@ -8,14 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation * Port to the D programming language: - * John Reimer + * John Reimer *******************************************************************************/ module dwt.browser.Download; import dwt.dwthelper.utils; import dwt.DWT; -import dwt.internal.C; + import dwt.internal.Compatibility; import dwt.internal.mozilla.XPCOM; import dwt.internal.mozilla.XPCOMObject; @@ -35,11 +35,7 @@ import dwt.widgets.Listener; import dwt.widgets.Shell; -class Download { - XPCOMObject supports; - XPCOMObject download; - XPCOMObject progressDialog; - XPCOMObject webProgressListener; +class Download : nsIProgressDialog { nsIHelperAppLauncher helperAppLauncher; int refCount = 0; @@ -47,8 +43,7 @@ Label status; Button cancel; -Download () { - createCOMInterfaces (); +this () { } int AddRef () { @@ -56,134 +51,46 @@ 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 ();} - }; - - download = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}) { - 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 Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);} - public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);} - public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);} - public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);} - public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);} - public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);} - public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);} - public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);} - public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);} - public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);} - public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);} - }; - - progressDialog = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { - 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 Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);} - public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);} - public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);} - public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);} - public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);} - public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);} - public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);} - public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);} - public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);} - public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);} - public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);} - public int /*long*/ method16 (int /*long*/[] args) {return Open (args[0]);} - public int /*long*/ method17 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);} - public int /*long*/ method18 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);} - public int /*long*/ method19 (int /*long*/[] args) {return GetDialog (args[0]);} - public int /*long*/ method20 (int /*long*/[] args) {return SetDialog (args[0]);} - }; - - webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 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 OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} - public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} - }; -} - -void disposeCOMInterfaces () { - if (supports !is null) { - supports.dispose (); - supports = null; - } - if (download !is null) { - download.dispose (); - download = null; - } - if (progressDialog !is null) { - progressDialog.dispose (); - progressDialog = null; - } - if (webProgressListener !is null) { - webProgressListener.dispose (); - webProgressListener = null; - } -} - -int /*long*/ getAddress () { - return progressDialog.getAddress (); -} - -int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { - if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; - nsID guid = new nsID (); - XPCOM.memmove (guid, riid, nsID.sizeof); - - if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); +int QueryInterface (nsID* riid, void** ppvObject) { + if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; + + if (*riid == nsISupports.IID)) { + *ppvObject = cast(void*)cast(nsISupports)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIDownload.NS_IDOWNLOAD_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIDownload.IID) { + *ppvObject = cast(void*)cast(nsIDownload)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIProgressDialog.NS_IPROGRESSDIALOG_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIProgressDialog.IID) { + *ppvObject = cast(void*)cast(nsIProgressDialog)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIWebProgressListener.IID) { + *ppvObject = cast(void*)cast(nsIWebProgressListener)this; AddRef(); return XPCOM.NS_OK; } - XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + *ppvObject = null; return XPCOM.NS_ERROR_NO_INTERFACE; } int Release () { refCount--; - if (refCount is 0) disposeCOMInterfaces (); + if (refCount is 0) return 0; return refCount; } /* nsIDownload */ /* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */ -int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aPersist) { +int Init (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, PRBool aPersist) { nsIURI source = new nsIURI (aSource); - int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); - int rc = source.GetHost (aSpec); + scope auto aSpec = new nsEmbedString; + int rc = source.GetHost (cast(nsAString*)aSpec); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); int length = XPCOM.nsEmbedCString_Length (aSpec); int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); @@ -280,7 +187,7 @@ return XPCOM.NS_ERROR_NOT_IMPLEMENTED; } -int GetPersist (int /*long*/ aPersist) { +int GetPersist (PRBool* aPersist) { return XPCOM.NS_ERROR_NOT_IMPLEMENTED; } @@ -312,11 +219,11 @@ return XPCOM.NS_ERROR_NOT_IMPLEMENTED; } -int GetObserver (int /*long*/ aObserver) { +nsresult GetObserver (nsIObserver* aObserver) { return XPCOM.NS_ERROR_NOT_IMPLEMENTED; } -int SetObserver (int /*long*/ aObserver) { +nsresult SetObserver (nsIOBserver aObserver) { if (aObserver !is 0) { nsISupports supports = new nsISupports (aObserver); int /*long*/[] result = new int /*long*/[1]; @@ -329,7 +236,7 @@ } /* nsIProgressDialog */ -int Open (int /*long*/ aParent) { +nsresult Open (int /*long*/ aParent) { return XPCOM.NS_ERROR_NOT_IMPLEMENTED; } diff -r e72345914350 -r 44258e0b6687 dwt/browser/DownloadFactory.d --- a/dwt/browser/DownloadFactory.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/DownloadFactory.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,72 +7,100 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.DownloadFactory; import dwt.dwthelper.utils; -import dwt.browser.Download; - +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsIFactory; import dwt.internal.mozilla.nsISupports; -class DownloadFactory : nsIFactory -{ - int _refCount = 0; +class DownloadFactory { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; + +DownloadFactory () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} - 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 ();} + }; + + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + 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 CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} - int QueryInterface ( ref nsIID riid, void** ppvObject) - { - if (riid is null || ppvObject is null) - return NS_ERROR_NO_INTERFACE; - - if ( riid == nsISupports.IID) - { - *ppvObject = cast(void*)cast(nsISupports)this; - AddRef (); - return NS_OK; - } +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (factory !is null) { + factory.dispose (); + factory = null; + } +} + +int /*long*/ getAddress () { + return factory.getAddress (); +} - if ( riid == nsIFactory.IID) - { - *ppvObject = cast(void*)cast(nsIFactory)this; - AddRef (); - return NS_OK; - } +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); - *ppvObject = null; - return NS_ERROR_NO_INTERFACE; + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; } + if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} - nsrefcnt Release () - { - _refCount--; - if (_refCount is 0) - _refCount = 0; - return _refCount; - } +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} /* nsIFactory */ - nsresult CreateInstance ( nsISupports aOuter, nsIID* iid, void** result) - { - Download download = new Download (); - download.AddRef (); - nsresult rv = download.QueryInterface( iid, result ); - return rv; - } +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + Download download = new Download (); + download.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} - nsresult LockFactory (int lock) - { - return NS_OK; - } +int LockFactory (int lock) { + return XPCOM.NS_OK; } +} diff -r e72345914350 -r 44258e0b6687 dwt/browser/DownloadFactory_1_8.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/Download_1_8.d --- a/dwt/browser/Download_1_8.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/Download_1_8.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,16 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.Download_1_8; import dwt.dwthelper.utils; import dwt.DWT; -import dwt.internal.C; + import dwt.internal.Compatibility; import dwt.internal.mozilla.XPCOM; -import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsICancelable; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsIDownload_1_8; @@ -32,11 +33,7 @@ import dwt.widgets.Listener; import dwt.widgets.Shell; -class Download_1_8 { - XPCOMObject supports; - XPCOMObject download; - XPCOMObject progressDialog; - XPCOMObject webProgressListener; +class Download_1_8 : nsIProgressDialog_1_8 { nsICancelable cancelable; int refCount = 0; @@ -44,10 +41,9 @@ Label status; Button cancel; - static final bool is32 = C.PTR_SIZEOF is 4; + //static final bool is32 = C.PTR_SIZEOF is 4; //determine if 32 or 64 bit platform? -Download_1_8 () { - createCOMInterfaces (); +this () { } int AddRef () { @@ -55,158 +51,36 @@ 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 ();} - }; - - download = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { - 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 OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} - public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} - public int /*long*/ method8 (int /*long*/[] args) { - if (args.length is 10) { - return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); - } else { - return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]); - } - } - public int /*long*/ method9 (int /*long*/[] args) { - if (args.length is 8) { - return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - } else { - return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - } - public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);} - public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);} - public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);} - public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);} - public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);} - public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);} - public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);} - public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);} - public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} - }; - - progressDialog = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { - 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 OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} - public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} - public int /*long*/ method8 (int /*long*/[] args) { - if (args.length is 10) { - return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); - } else { - return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]); - } - } - public int /*long*/ method9 (int /*long*/[] args) { - if (args.length is 8) { - return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - } else { - return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - } - public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);} - public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);} - public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);} - public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);} - public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);} - public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);} - public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);} - public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);} - public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} - public int /*long*/ method20 (int /*long*/[] args) {return Open (args[0]);} - public int /*long*/ method21 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);} - public int /*long*/ method22 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);} - public int /*long*/ method23 (int /*long*/[] args) {return GetObserver (args[0]);} - public int /*long*/ method24 (int /*long*/[] args) {return SetObserver (args[0]);} - public int /*long*/ method25 (int /*long*/[] args) {return GetDialog (args[0]);} - public int /*long*/ method26 (int /*long*/[] args) {return SetDialog (args[0]);} - }; - - webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 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 OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} - public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} - }; -} - -void disposeCOMInterfaces() { - if (supports !is null) { - supports.dispose (); - supports = null; - } - if (download !is null) { - download.dispose (); - download = null; - } - if (progressDialog !is null) { - progressDialog.dispose (); - progressDialog = null; - } - if (webProgressListener !is null) { - webProgressListener.dispose (); - webProgressListener = null; - } -} - -int /*long*/ getAddress () { - return progressDialog.getAddress (); -} - -int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { - if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; - nsID guid = new nsID (); - XPCOM.memmove (guid, riid, nsID.sizeof); - - if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); +int QueryInterface ( nsID* riid, void** ppvObject) { + if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; + + if (*riid == nsISupports.IID)) { + *ppvObject = cast(void*)cast(nsISupports)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIDownload_1_8.NS_IDOWNLOAD_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIDownload_1_8.IID)) { + *ppvObject = cast(void*)cast(nsIDownload_1_8)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIProgressDialog_1_8.NS_IPROGRESSDIALOG_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIProgressDialog_1_8.IID) { + *ppvObject = cast(void*)cast(nsIProgressDialog_1_8)this; AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIWebProgressListener.IID) { + *ppvObject = cast(void*)cast(nsIWebProgressListener)this; AddRef(); return XPCOM.NS_OK; } - XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + *ppvObject = null; return XPCOM.NS_ERROR_NO_INTERFACE; } int Release () { refCount--; - if (refCount is 0) disposeCOMInterfaces (); + if (refCount is 0) return 0; return refCount; } diff -r e72345914350 -r 44258e0b6687 dwt/browser/FilePicker.d --- a/dwt/browser/FilePicker.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/FilePicker.d Tue Aug 05 10:11:58 2008 -0700 @@ -8,446 +8,235 @@ * Contributors: * IBM Corporation - initial API and implementation * Port to the D programming language: - * John Reimer + * John Reimer *******************************************************************************/ - module dwt.browser.FilePicker; -import tango.io.model.IFile; -import Utf = tango.text.convert.Utf; - import dwt.dwthelper.utils; import dwt.DWT; -import XPCOM = dwt.internal.mozilla.nsXPCOM; - -import dwt.browser.Mozilla; -import dwt.browser.MozillaDelegate; - import dwt.internal.mozilla.nsEmbedString; -import dwt.internal.mozilla.nsIDOMWindow; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsIFilePicker; +import dwt.internal.mozilla.nsIFilePicker_1_8; import dwt.internal.mozilla.nsILocalFile; import dwt.internal.mozilla.nsISupports; -import dwt.internal.mozilla.nsSimpleEnumerator; -import dwt.internal.mozilla.nsStringAPI; -import dwt.internal.mozilla.nsError; - import dwt.widgets.DirectoryDialog; import dwt.widgets.Display; import dwt.widgets.FileDialog; import dwt.widgets.Shell; - -class FilePicker : nsISupports, nsIFilePicker -{ - /************************************************************************** - - **************************************************************************/ - - private - { - int _refCount = 0; - short _mode; - - nsIDOMWindow _parent; - - String[] _files; - String _masks; - String _defaultFilename, - _directory, - _title; - } - /************************************************************************** - - **************************************************************************/ - - static final String SEPARATOR = FileConst.FileSeparatorChar; - - /************************************************************************** - - **************************************************************************/ - - this () - { - } - - /************************************************************************** - - **************************************************************************/ +class FilePicker : nsIFilePicker { - nsrefcnt AddRef () - { - _refCount++; - return _refCount; - } - - /************************************************************************** - - **************************************************************************/ + int refCount = 0; + short mode; + nsIDOMWindow parentHandle; + String[] files, masks; + String defaultFilename, directory, title; - nsresult QueryInterface ( inout nsID riid, void** ppvObject) - { - if (riid is null || ppvObject is null) - return NS_ERROR_NO_INTERFACE; - - if (riid == nsISupports.IID) - { - *ppvObject = cast(void*)cast(nsISupports) this; - AddRef (); - return NS_OK; - } - - if (riid == nsIFilePicker.IID)) - { - *ppvObject = cast(void*)cast(nsIFilePicker) this; - AddRef (); - return NS_OK; - } - - if (riid == nsIFilePicker_1_8.IID) - { - *ppvObject = cast(void*)cast(nsIFilePicker_1_8) this; - AddRef (); - return NS_OK; - } - - *ppvObject = null; - return NS_ERROR_NO_INTERFACE; - } - - /************************************************************************** - - **************************************************************************/ + static final String SEPARATOR = System.getProperty ("file.separator"); //$NON-NLS-1$ - nsrefcnt Release () - { - _refCount--; - - if (_refCount is 0) - // No big deal here; just allow the GC to reap this object - // once all references are expired. -JJR - // delete this; - return 0; - - return _refCount; - } - - /************************************************************************** - - **************************************************************************/ - - /* SWT Comment: - * - * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method - * answers a java string based on the type of string that is appropriate for the Mozilla - * version being used. - */ - - override String parseAString (nsEmbedString str) - { - return null; - } - - /************************************************************************** - - **************************************************************************/ - - /* nsIFilePicker */ - - nsresult Init (nsIDOMWindow parent, nsAString* title, PRInt16 mode) - { - _parent = parent; - _mode = mode; - _title = parseAString (title); - return XPCOM; - } - - /************************************************************************** - - **************************************************************************/ +this () { +} - nsresult Show (PRUint32* retval) - { - if (_mode is nsIFilePicker.modeGetFolder) - { - /* picking a directory */ - int result = this.showDirectoryPicker (); - *retval = result; - return NS_OK; - } - - /* picking a file */ - int style = _mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN; - - if (_mode is nsIFilePicker.modeOpenMultiple) - style |= DWT.MULTI; - - Display display = Display.getCurrent (); - Shell parent = null; // TODO compute parent - - if (parent is null) - { - parent = new Shell (display); - } +nsrefcnt AddRef () { + refCount++; + return refCount; +} - FileDialog dialog = new FileDialog (parent, style); - - if (_title !is null) - dialog.setText (_title); - - if (_directory !is null) - dialog.setFilterPath (_directory); - - if (_masks !is null) { - String[] str ~= _masks; - dialog.setFilterExtensions ( str ); - } - - if (_defaultFilename !is null) - dialog.setFileName (_defaultFilename); - - String filename = dialog.open (); - files = dialog.getFileNames (); - _directory = dialog.getFilterPath (); - _title = _defaultFilename = null; - _masks = null; - int result = filename is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; - *retval = result; +nsresult QueryInterface (nsID* riid, void** ppvObject) { + if (riid is null || ppvObject is null) return NS_ERROR_NO_INTERFACE; + + if (riid == nsISupports.IID) { + *ppvObject = cast(void*)cast(nsISupports) this; + AddRef (); return NS_OK; } - - /************************************************************************** - - **************************************************************************/ + if (riid == nsIFilePicker.IID)) { + *ppvObject = cast(void*)cast(nsIFilePicker) this; + AddRef (); + return NS_OK; + } + if (riid == nsIFilePicker_1_8.IID) { + *ppvObject = cast(void*)cast(nsIFilePicker_1_8) this; + AddRef (); + return NS_OK; + } + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; +} + +nsrefcnt Release () { + refCount--; + if (refCount is 0) return 0; + return refCount; +} - int showDirectoryPicker () - { - Display display = Display.getCurrent (); - Shell parent = null; // TODO compute parent - - if (parent is null) - { - parent = new Shell (display); - } - - DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE); - - if (_title !is null) - dialog.setText (_title); - if (_directory !is null) - dialog.setFilterPath (_directory); - _directory = dialog.open (); - _title = _defaultFilename = null; - _files = _masks = null; - return _directory is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; +/* + * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method + * answers a java string based on the type of string that is appropriate for the Mozilla + * version being used. + */ +override String parseAString (nsAString* string) { + return null; +} + +/* nsIFilePicker */ + +nsresult Init (nsIDOMWindow parent, nsAString* title, PRInt16 mode) { + parentHandle = parent; + this.mode = mode; + this.title = parseAString (title); + return XPCOM.NS_OK; +} + +nsresult Show (PRUint32* _retval) { + if (mode is nsIFilePicker.modeGetFolder) { + /* picking a directory */ + int result = showDirectoryPicker (); + *_retval = cast(int)cast(short)result; /* PRInt16 */ + return XPCOM.NS_OK; } - /************************************************************************** - - **************************************************************************/ - - nsresult GetFiles ( nsISimpleEnumerator* aFiles) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** - - **************************************************************************/ - - nsresult GetFileURL (nsIFileURL aFileURL) - { - return NS_ERROR_NOT_IMPLEMENTED; + /* picking a file */ + int style = mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN; + if (mode is nsIFilePicker.modeOpenMultiple) style |= DWT.MULTI; + Display display = Display.getCurrent (); + Shell parent = null; // TODO compute parent + if (parent is null) { + parent = new Shell (display); } - - /************************************************************************** - - **************************************************************************/ - - nsresult GetFile (nsILocalFile* aFile) - { - String filename = ""; //$NON-NLS-1$ - - if (_directory !is null) - filename ~= _directory ~ SEPARATOR; - if (_files !is null && _files.length > 0) - filename ~= _files[0]; - - // Create a nsEmbedString which will be automatically disposed - // at the end of scope. - scope auto path = new nsEmbedString( filename ); - - nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aFile); - - if (rc !is NS_OK) - Mozilla.error (rc); - if (aFile is null) - Mozilla.error (NS_ERROR_NULL_POINTER); - - return NS_OK; - } - - /************************************************************************** - - **************************************************************************/ + FileDialog dialog = new FileDialog (parent, style); + if (title !is null) dialog.setText (title); + if (directory !is null) dialog.setFilterPath (directory); + if (masks !is null) dialog.setFilterExtensions (masks); + if (defaultFilename !is null) dialog.setFileName (defaultFilename); + String filename = dialog.open (); + files = dialog.getFileNames (); + directory = dialog.getFilterPath (); + title = defaultFilename = null; + masks = null; + int result = filename is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; + *_retval = cast(int)cast(short)result;; /* PRInt16 */ + return XPCOM.NS_OK; +} - nsresult SetDisplayDirectory (nsILocalFile aDisplayDirectory) - { - if (aDisplayDirectory is null) - return NS_OK; - - scope auto pathname = new nsEmbedCString; - aDisplayDirectory.GetNativePath ( cast(nsACString*)pathname ); - // TODO: CHECK IF THIS DOES CORRECT STRING CONVERSION -JJR - char[] buffer = pathname.toString(); - char[] chars = MozillaDelegate.mbcsToWcs (null, buffer); - // "buffer" contains a dup'ed string so we can safely reuse - // it's memory for the _directory member. -JJR - _directory = buffer; - return NS_OK; +int showDirectoryPicker () { + Display display = Display.getCurrent (); + Shell parent = null; // TODO compute parent + if (parent is null) { + parent = new Shell (display); } + DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE); + if (title !is null) dialog.setText (title); + if (directory !is null) dialog.setFilterPath (directory); + directory = dialog.open (); + title = defaultFilename = null; + files = masks = null; + return directory is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; +} - /************************************************************************** - - **************************************************************************/ +nsresult GetFiles (nsISimpleEnumerator* aFiles) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - nsresult GetDisplayDirectory (nsILocalFile* aDisplayDirectory) - { - String directoryName = _directory !is null ? _directory : ""; //$NON-NLS-1$ - scope auto path = new nsEmbedString (directoryName); - nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aDisplayDirectory); - - if (rc !is NS_OK) - Mozilla.error (rc); - if (aDisplayDirectory is null) - Mozilla.error (NS_ERROR_NULL_POINTER); - return NS_OK; - } - - /************************************************************************** +nsresult GetFileURL ( nsIFileURL aFileURL ) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - **************************************************************************/ - - nsresult SetFilterIndex (PRInt32 aFilterIndex) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** +nsresult GetFile (nsILocalFile* aFile) { + String filename = ""; //$NON-NLS-1$ + if (directory !is null) filename ~= directory ~ SEPARATOR; + if (files !is null && files.length > 0) filename ~= files[0]; + scope auto path = new nsEmbedString (filename); + int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)path, 1, aFile); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (aFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + return XPCOM.NS_OK; +} - **************************************************************************/ - - nresult GetFilterIndex (PRInt32* aFilterIndex) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** +nsresult SetDisplayDirectory (nsILocalFile aDisplayDirectory) { + if (aDisplayDirectory is null) return XPCOM.NS_OK; + scope auto pathname = new nsEmbedCString(); + aDisplayDirectory.GetNativePath (cast(nsACString*)pathname); + // wchar[] chars = MozillaDelegate.mbcsToWcs (null, bytes); + directory = pathname.toString; + return XPCOM.NS_OK; +} - **************************************************************************/ - - int SetDefaultExtension (nsAString* aDefaultExtension) - { - /* note that the type of argument 1 changed as of Mozilla 1.8 */ - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** +nsresult GetDisplayDirectory (nsILocalFile* aDisplayDirectory) { + String directoryName = directory !is null ? directory : ""; //$NON-NLS-1$ + scope auto path = new nsEmbedString (Utf.toString16(directoryName)); + int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)path, 1, aDisplayDirectory); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (aDisplayDirectory is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + return XPCOM.NS_OK; +} - **************************************************************************/ +nsresult SetFilterIndex (PRInt32 aFilterIndex) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - int GetDefaultExtension (nsAString* aDefaultExtension) - { - /* note that the type of argument 1 changed as of Mozilla 1.8 */ - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** - - **************************************************************************/ +nsresult GetFilterIndex (PRInt32* aFilterIndex) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - nresult SetDefaultString (nsAString* aDefaultString) - { - defaultFilename = parseAString (aDefaultString); - return NS_OK; - } +nsresult SetDefaultExtension (nsAString* aDefaultExtension) { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - /************************************************************************** - - **************************************************************************/ +nsresult GetDefaultExtension (nsAString* aDefaultExtension) { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - nresult GetDefaultString (nsAString* aDefaultString) - { - /* note that the type of argument 1 changed as of Mozilla 1.8 */ - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** - - **************************************************************************/ +nsresult SetDefaultString (nsAString* aDefaultString) { + defaultFilename = parseAString (aDefaultString); + return XPCOM.NS_OK; +} - nresult AppendFilter (nsAString* title, nsAString* filter) - { - /* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */ - return NS_ERROR_NOT_IMPLEMENTED; - } - - /************************************************************************** - - **************************************************************************/ +nsresult GetDefaultString (nsAString* aDefaultString) { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} - nresult AppendFilters (PRInt32 filterMask) - { - String addFilters; - - switch (filterMask) - { - case nsIFilePicker.filterAll: - case nsIFilePicker.filterApps: - _masks = null; /* this is equivalent to no filter */ - break; - case nsIFilePicker.filterHTML: - addFilters = "*.htm;*.html" ; - break; - case nsIFilePicker.filterImages: - addFilters = "*.gif;*.jpeg;*.jpg;*.png"; - break; - case nsIFilePicker.filterText: - addFilters = "*.txt"; - break; - case nsIFilePicker.filterXML: - addFilters = "*.xml"; - break; - case nsIFilePicker.filterXUL: - addFilters = "*.xul"; - break; +nsresult AppendFilter (nsAString* title, nsAString* filter) { + /* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */ + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult AppendFilters (PRInt32 filterMask) { + String[] addFilters = null; + switch (filterMask) { + case nsIFilePicker.filterAll: + case nsIFilePicker.filterApps: + masks = null; /* this is equivalent to no filter */ + break; + case nsIFilePicker.filterHTML: + addFilters[0] = "*.htm;*.html"; //$NON-NLS-1$ + break; + case nsIFilePicker.filterImages: + addFilters[0] = "*.gif;*.jpeg;*.jpg;*.png"; //$NON-NLS-1$ + break; + case nsIFilePicker.filterText: + addFilters[0] = "*.txt"; //$NON-NLS-1$ + break; + case nsIFilePicker.filterXML: + addFilters[0] = "*.xml"; //$NON-NLS-1$ + break; + case nsIFilePicker.filterXUL: + addFilters[0] = "*.xul"; //$NON-NLS-1$ + break; + } + if (masks is null) { + masks = addFilters; + } else { + if (addFilters !is null) { + masks ~= addFilters; } - - if (_masks is null) - { - _masks = addFilters; - } else { - if (addFilters !is null) - _masks ~= addFilters; - } - return NS_OK; } - -/****************************************************************************** - - FilePicker for Mozilla Version 1.8 - -******************************************************************************/ - -class FilePicker_1_8 : FilePicker -{ - String parseAString (nsEmbedString str) - { - if (str is null) - return null; - return Utf.toString( str.toString16() ); - } -} \ No newline at end of file + return XPCOM.NS_OK; +} +} diff -r e72345914350 -r 44258e0b6687 dwt/browser/FilePickerFactory.d --- a/dwt/browser/FilePickerFactory.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/FilePickerFactory.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,121 +7,100 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ - module dwt.browser.FilePickerFactory; import dwt.dwthelper.utils; +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsID; -import dwt.internal.mozilla. import dwt.internal.mozilla.nsIFactory; import dwt.internal.mozilla.nsISupports; -class FilePickerFactory : nsISupports, nsIFactory -{ - - /************************************************************************** - - **************************************************************************/ - - int _refCount = 0; - - /************************************************************************** - - **************************************************************************/ +class FilePickerFactory { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; - this () - { - } - - /************************************************************************** - - **************************************************************************/ +FilePickerFactory () { + createCOMInterfaces (); +} - nsrefcnt AddRef () - { - _refCount++; - return _refCount; - } - - /************************************************************************** - - **************************************************************************/ +int AddRef () { + refCount++; + return refCount; +} - int QueryInterface ( ref nsID riid, void** ppvObject) - { - if (riid is null || ppvObject is null) - return NS_ERROR_NO_INTERFACE; - - if (guid == nsISupports.IID)) - { - *ppvObject = cast(void*)cast(nsISupports) this; - AddRef (); - return NS_OK; - } +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 ();} + }; - if (guid == nsIFactory.IID) - { - *ppvObject = cast(void*)cast(nsIFactory) this; - AddRef (); - return NS_OK; - } - - *ppvObject = null; - return NS_ERROR_NO_INTERFACE; - } + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + 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 CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} - /************************************************************************** +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (factory !is null) { + factory.dispose (); + factory = null; + } +} - **************************************************************************/ +int /*long*/ getAddress () { + return factory.getAddress (); +} - nsrefcnt Release () - { - _refCount--; - if (_refCount is 0) - return 0; - return _refCount; +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; } - /************************************************************************** - - **************************************************************************/ - - /* nsIFactory */ + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} - nsresult CreateInstance (nsISupports aOuter, nsIID* iid, void** result) - { - if (result is null) - return NS_ERROR_INVALID_ARG; - - FilePicker picker = new FilePicker (); - picker.AddRef (); +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIFactory */ - nsresult rv = picker.QueryInterface( iid, result ); - - // TODO: If the query fails, the error should be checked and the - // newly created object deleted. In C++, this is done - // like so: - // - // if (NS_FAILED(rv)) { - // *result = nsnull; - // delete picker; - // } - // - // Deletion of the object really isn't critical here for D, but - // it may be considered "good habit" to do anyway for XPCOM objects. - // For now, just return the rv value. NS_FAILED needs to be - // ported first. -JJR +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + FilePicker picker = new FilePicker (); + picker.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} - return rv; - } - - nsresult LockFactory (int lock) - { - return NS_OK; - } - -} \ No newline at end of file +int LockFactory (int lock) { + return XPCOM.NS_OK; +} +} diff -r e72345914350 -r 44258e0b6687 dwt/browser/FilePickerFactory_1_8.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/FilePicker_1_8.d --- a/dwt/browser/FilePicker_1_8.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/FilePicker_1_8.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,57 +7,21 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.FilePicker_1_8; import dwt.dwthelper.utils; +import dwt.browser.FilePicker; import dwt.internal.mozilla.XPCOM; -import dwt.internal.mozilla.XPCOMObject; - -class FilePicker_1_8 extends FilePicker { - -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 ();} - }; +import dwt.internal.mozilla.nsStringAPI; - filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { - 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 Init (args[0], args[1], (short)args[2]);} - public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);} - public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);} - public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);} - public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);} - public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);} - public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);} - public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);} - public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);} - public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);} - public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);} - public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);} - public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);} - }; -} +class FilePicker_1_8 : FilePicker { -/* - * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method - * answers a java string based on the type of string that is appropriate for the Mozilla - * version being used. - */ -String parseAString (int /*long*/ string) { - if (string is 0) return null; - int length = XPCOM.nsEmbedString_Length (string); - int /*long*/ buffer = XPCOM.nsEmbedString_get (string); - char[] chars = new char[length]; - XPCOM.memmove (chars, buffer, length * 2); - return new String (chars); +String parseAString (nsAString* string) { + if (string is null) return null; + return Utf.toString(nsAString.getString16(string)); } } diff -r e72345914350 -r 44258e0b6687 dwt/browser/HelperAppLauncherDialog.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/HelperAppLauncherDialogFactory.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/InputStream.d --- a/dwt/browser/InputStream.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/InputStream.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,171 +7,129 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ - module dwt.browser.InputStream; import dwt.dwthelper.utils; -import dwt.internal.mozilla.nsError; +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsIInputStream; import dwt.internal.mozilla.nsISupports; -import Math = tango.math.Math; - -/****************************************************************************** - - COMMENTS: SWT implements this class as a replacement for the XPCOM - implementation; it may be possible to use the XPCOM one instead - (which also may be safer for D), but for now we'll follow SWT's example - and use this reimplementation of InputStream. It should be trivial to - move over to strict XPCOM implementation should the need arise. It appears - that the Java SWT source uses many workarounds in order to use the XPCOM - interface. For D, I remove much of the Java layered callback - approach since it is no longer necessary. -JJR - -******************************************************************************/ +class InputStream { + XPCOMObject inputStream; + int refCount = 0; -class InputStream : nsIInputStream -{ - int _refCount = 0; - int _index = 0; - byte[] _buffer; - - /************************************************************************** - - **************************************************************************/ + byte[] buffer; + int index = 0; + +InputStream (byte[] buffer) { + this.buffer = buffer; + index = 0; + createCOMInterfaces (); +} - this (byte[] buffer) - { - this._buffer = buffer; - index = 0; - } - - /************************************************************************** - - **************************************************************************/ +int AddRef () { + refCount++; + return refCount; +} - nsrefcnt AddRef () - { - _refCount++; - return _refCount; - } - - /************************************************************************** - - **************************************************************************/ +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + inputStream = new XPCOMObject (new int[] {2, 0, 0, 0, 1, 3, 4, 1}) { + 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 Close ();} + public int /*long*/ method4 (int /*long*/[] args) {return Available (args[0]);} + public int /*long*/ method5 (int /*long*/[] args) {return Read (args[0], (int)/*64*/args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return ReadSegments (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return IsNonBlocking (args[0]);} + }; +} - nsresult QueryInterface ( inout nsID riid, void** ppvObject) - { - if (riid is null || ppvObject is null) - return NS_ERROR_NO_INTERFACE; - - nsID guid = riid; - - if (guid == nsISupports.NS_ISUPPORTS_IID) - { - *ppvObject = cast(void*)cast(nsISupports) this; - this.AddRef (); - return NS_OK; - } +void disposeCOMInterfaces () { + if (inputStream !is null) { + inputStream.dispose (); + inputStream = null; + } +} - if (guid == nsIInputStream.NS_IINPUTSTREAM_IID) - { - *ppvObject = cast(void*)cast(nsIInputStream) this; - this.AddRef (); - return NS_OK; - } - - *ppvObject = null; - return NS_ERROR_NO_INTERFACE; - } - - /************************************************************************** - - **************************************************************************/ +int /*long*/ getAddress () { + return inputStream.getAddress (); +} - nsrefcnt Release () - { - _refCount--; - if (_refCount is 0) - return 0 - // delete this; - return _refCount; +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; } + if (guid.Equals (nsIInputStream.NS_IINPUTSTREAM_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} - /************************************************************************** - - **************************************************************************/ +/* nsIInputStream implementation */ - nsresult Close () - { - _buffer = null; - _index = 0; - return NS_OK; - } - - /************************************************************************** - - **************************************************************************/ - - nsresult Available ( PRUint32* retval) - { - PRUint32 available = buffer is null ? 0 : buffer.length - _index; - *retval = available; - return NS_OK; - } - - /************************************************************************** - - **************************************************************************/ +int Close () { + buffer = null; + index = 0; + return XPCOM.NS_OK; +} - nsresult Read(byte* aBuf, PRUint32 aCount, PRUint32* retval) - { - int max = Math.min (aCount, _buffer is null ? 0 : _buffer.length - _index); - - if (max > 0) - { - aBuf[0..max] = _buffer[_index..$]; - _index += max; - } +int Available (int /*long*/ _retval) { + int available = buffer is null ? 0 : buffer.length - index; + XPCOM.memmove (_retval, new int[] {available}, 4); + return XPCOM.NS_OK; +} - *retval = max; - return NS_OK; +int Read(int /*long*/ aBuf, int aCount, int /*long*/ _retval) { + int max = Math.min (aCount, buffer is null ? 0 : buffer.length - index); + if (max > 0) { + byte[] src = new byte[max]; + System.arraycopy (buffer, index, src, 0, max); + XPCOM.memmove (aBuf, src, max); + index += max; } - - /************************************************************************** - - **************************************************************************/ + XPCOM.memmove(_retval, new int[] {max}, 4); + return XPCOM.NS_OK; +} - nsresult ReadSegments (nsWriteSegmentFun aWriter, void* aClosure, PRUint32 aCount, PRUint32* retval) - { - int max = Math.min (aCount, buffer is null ? 0 : buffer.length - _index); - PRUint32 cnt = max; - - while (cnt > 0) - { - PRUint32 aWriteCount; - nsresult rc = aWriter ( cast(nsIInputStream)this, aClosure, buffer.ptr, _index, cnt, &aWriteCount); - if (rc !is NS_OK) break; - _index += aWriteCount; - cnt -= aWriteCount; - } +int ReadSegments (int /*long*/ aWriter, int /*long*/ aClosure, int aCount, int /*long*/ _retval) { + int max = Math.min (aCount, buffer is null ? 0 : buffer.length - index); + int cnt = max; + while (cnt > 0) { + int[] aWriteCount = new int[1]; + int /*long*/ rc = XPCOM.Call (aWriter, getAddress (), aClosure, buffer, index, cnt, aWriteCount); + if (rc !is XPCOM.NS_OK) break; + index += aWriteCount[0]; + cnt -= aWriteCount[0]; + } + XPCOM.memmove (_retval, new int[] {max - cnt}, 4); + return XPCOM.NS_OK; +} - *retval = (max - cnt); - return NS_OK; - } - - /************************************************************************** - - **************************************************************************/ - - nsresult IsNonBlocking ( PRUint32* retval) - { - *retval = 0; - return NS_OK; - } +int IsNonBlocking (int /*long*/ _retval) { + /* blocking */ + XPCOM.memmove (_retval, new int[] {0}, 4); + return XPCOM.NS_OK; +} } diff -r e72345914350 -r 44258e0b6687 dwt/browser/LocationAdapter.d --- a/dwt/browser/LocationAdapter.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/LocationAdapter.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,13 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.LocationAdapter; -import dwt.browser.LocationListener; -import dwt.browser.LocationEvent; import dwt.dwthelper.utils; /** @@ -27,11 +23,11 @@ * * @since 3.0 */ -public abstract class LocationAdapter : LocationListener { +public abstract class LocationAdapter implements LocationListener { - public void changing(LocationEvent event) { - } +public void changing(LocationEvent event) { +} - public void changed(LocationEvent event) { - } +public void changed(LocationEvent event) { } +} diff -r e72345914350 -r 44258e0b6687 dwt/browser/LocationEvent.d --- a/dwt/browser/LocationEvent.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/LocationEvent.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,8 +7,6 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.LocationEvent; @@ -27,7 +25,7 @@ * * @since 3.0 */ -public class LocationEvent : TypedEvent { +public class LocationEvent extends TypedEvent { /** current location */ public String location; diff -r e72345914350 -r 44258e0b6687 dwt/browser/LocationListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/Mozilla.d --- a/dwt/browser/Mozilla.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/Mozilla.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,13 +7,19 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.Mozilla; import dwt.dwthelper.utils; +//import java.io.UnsupportedEncodingException; +//import java.lang.reflect.Constructor; +//import java.lang.reflect.InvocationTargetException; +//import java.lang.reflect.Method; +//import java.util.Enumeration; +//import java.util.Locale; +//import java.util.Vector; + import dwt.DWT; import dwt.DWTError; import dwt.graphics.Device; @@ -24,9 +30,10 @@ import dwt.internal.LONG; import dwt.internal.Library; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMInit; + import dwt.internal.mozilla.nsEmbedString; -import dwt.internal.mozilla.nsError; - import dwt.internal.mozilla.nsIAppShell; import dwt.internal.mozilla.nsIBaseWindow; import dwt.internal.mozilla.nsICategoryManager; @@ -59,6 +66,7 @@ import dwt.internal.mozilla.nsIPrefLocalizedString; import dwt.internal.mozilla.nsIPrefService; import dwt.internal.mozilla.nsIProperties; +import dwt.internal.mozilla.nsIRequest; import dwt.internal.mozilla.nsIServiceManager; import dwt.internal.mozilla.nsISimpleEnumerator; import dwt.internal.mozilla.nsISupports; @@ -76,7 +84,6 @@ import dwt.internal.mozilla.nsIWebProgress; import dwt.internal.mozilla.nsIWebProgressListener; import dwt.internal.mozilla.nsIWindowWatcher; - import dwt.layout.FillLayout; import dwt.widgets.Composite; import dwt.widgets.Display; @@ -86,28 +93,45 @@ import dwt.widgets.Menu; import dwt.widgets.Shell; -class Mozilla : nsIWebBrowser, nsIWeakReference, - nsIWebProgressListener, nsIWebBrowserChrome, - nsIWebBrowserChromeFocus, nsIEmbeddingSiteWindow, - nsIInterfaceRequestor, nsISupportsWeakReference, - nsIContextMenuListener, nsIUriContentListener, - nsIToolTipListener, nsIDOMEventListener -{ - int /*long*/ embedHandle; - nsIWebBrowser webBrowser; - Object webBrowserObject; +class Mozilla : WebBrowser, + nsIWeakReference, + nsIWebProgressListener, + nsIWebBrowserChrome, + nsIWebBrowserFocus, + nsIEmbeddingSiteWindow, + nsIInterfaceRequestor, + nsISupportsWeakReference, + nsIContextMenuListener, + nsIUriContextListener, + nsITooltipListener, + nsIDomEventListener { + + GtkWidget* embedHandle; + nsIWebBrowser webBrowser; + Object webBrowserObject; MozillaDelegate mozDelegate; + /* Interfaces for this Mozilla embedding notification */ +// XPCOMObject supports; +// XPCOMObject weakReference; +// XPCOMObject webProgressListener; +// XPCOMObject webBrowserChrome; +// XPCOMObject webBrowserChromeFocus; +// XPCOMObject embeddingSiteWindow; +// XPCOMObject interfaceRequestor; +// XPCOMObject supportsWeakReference; +// XPCOMObject contextMenuListener; +// XPCOMObject uriContentListener; +// XPCOMObject tooltipListener; +// XPCOMObject domEventListener; int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT; int refCount, lastKeyCode, lastCharCode; - int /*long*/ request; + nsIRequest request; Point location, size; bool visible, isChild, ignoreDispose, awaitingNavigate; Shell tip = null; Listener listener; - - // replace with appropriate D/Tango data structure - Vector unhookedDOMWindows = new Vector (); + nsIDOMWindow[] unhookedDOMWindows; static nsIAppShell AppShell; static AppFileLocProvider LocationProvider; @@ -154,7 +178,7 @@ // TEMPORARY CODE static final String GRE_INITIALIZED = "dwt.browser.XULRunnerInitialized"; //$NON-NLS-1$ - static { + static this () { MozillaClearSessions = new Runnable () { public void run () { if (!Initialized) return; @@ -2045,68 +2069,65 @@ /* nsISupports */ -int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { - if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; +int QueryInterface (nsID* riid, void** ppvObject) { + if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; - nsID guid = new nsID (); - XPCOM.memmove (guid, riid, nsID.sizeof); - - if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsISupports.IID) { + *ppvObject = cast(void*)cast(nsISupports)this; + AddRef (); + return XPCOM.NS_OK; + } + if (*riid == nsIWeakReference.IID) { + *ppvObject = cast(void*)cast(nsIWeakReference)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIWeakReference.NS_IWEAKREFERENCE_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIWebProgressListener.IID) { + *ppvObject = cast(void*)cast(nsIWebProgressListener)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIWebBrowserChrome.IID) { + *ppvObject = cast(void*)cast(nsIWebBrowserChrome)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIWebBrowserChrome.NS_IWEBBROWSERCHROME_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChrome.getAddress ()}, C.PTR_SIZEOF); - AddRef (); - return XPCOM.NS_OK; - } - if (guid.Equals (nsIWebBrowserChromeFocus.NS_IWEBBROWSERCHROMEFOCUS_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChromeFocus.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIWebBrowserChromeFocus.IID) { + *ppvObject = cast(void*)cast(nsIWebBrowserChromeFocus)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {embeddingSiteWindow.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIEmbeddingSiteWindow.IID) { + *ppvObject = cast(void*)cast(nsIEmbeddingSiteWindow)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {interfaceRequestor.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIInterfaceRequestor.IID) { + *ppvObject = cast(void*)cast(nsIInterfaceRequestor)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {supportsWeakReference.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsISupportsWeakReference.IID) { + *ppvObject = cast(void*)cast(nsISupportsWeakReference)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIContextMenuListener.NS_ICONTEXTMENULISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {contextMenuListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIContextMenuListener.IID) { + *ppvObject = cast(void*)cast(nsIContextMenuListener)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsIURIContentListener.NS_IURICONTENTLISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {uriContentListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsIURIContentListener.IID) { + *ppvObject = cast(void*)cast(nsIUriContentListener)this; AddRef (); return XPCOM.NS_OK; } - if (guid.Equals (nsITooltipListener.NS_ITOOLTIPLISTENER_IID)) { - XPCOM.memmove (ppvObject, new int /*long*/[] {tooltipListener.getAddress ()}, C.PTR_SIZEOF); + if (*riid == nsITooltipListener.IID)) { + *ppvObject = cast(void*)cast(nsITooltipListener)this; AddRef (); return XPCOM.NS_OK; } - XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + *ppvObject = null; return XPCOM.NS_ERROR_NO_INTERFACE; } @@ -2117,19 +2138,19 @@ int Release () { refCount--; - if (refCount is 0) disposeCOMInterfaces (); + if (refCount is 0) return 0; return refCount; } /* nsIWeakReference */ -int QueryReferent (int /*long*/ riid, int /*long*/ ppvObject) { +int QueryReferent (nsID* riid, void** ppvObject) { return QueryInterface (riid, ppvObject); } /* nsIInterfaceRequestor */ -int GetInterface (int /*long*/ riid, int /*long*/ ppvObject) { +int GetInterface ( 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); diff -r e72345914350 -r 44258e0b6687 dwt/browser/MozillaDelegate.d --- a/dwt/browser/MozillaDelegate.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/MozillaDelegate.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.MozillaDelegate; @@ -24,20 +26,21 @@ class MozillaDelegate { Browser browser; - int /*long*/ mozillaHandle, embedHandle; + gpointer mozillaHandle; + GtkWidget* embedHandle; bool hasFocus; Listener listener; - static Callback eventCallback; - static int /*long*/ eventProc; - static final int STOP_PROPOGATE = 1; + //static Callback eventCallback; + // static int /*long*/ eventProc; + static const gpointer STOP_PROPOGATE = cast(gpointer)1; static bool IsLinux; - static { - String osName = System.getProperty ("os.name").toLowerCase (); //$NON-NLS-1$ - IsLinux = osName.startsWith ("linux"); //$NON-NLS-1$ + static this { + String osName = System.getProperty ("os.name"); //$NON-NLS-1$ + IsLinux = tango.text.Util.containsPattern(osName, "linux"); //$NON-NLS-1$ } -MozillaDelegate (Browser browser) { +this (Browser browser) { super (); if (!IsLinux) { browser.dispose (); @@ -46,27 +49,27 @@ this.browser = browser; } -static int /*long*/ eventProc (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) { - int /*long*/ parent = OS.gtk_widget_get_parent (handle); +static extern(C) int eventProc (GtkWidget* handle, GdkEvent* gdkEvent, gpointer pointer) { + GtkWidget* parent = OS.gtk_widget_get_parent (handle); parent = OS.gtk_widget_get_parent (parent); - if (parent is 0) return 0; + if (parent is null) return 0; Widget widget = Display.getCurrent ().findWidget (parent); - if (widget !is null && widget instanceof Browser) { - return ((Mozilla)((Browser)widget).webBrowser).delegate.gtk_event (handle, gdkEvent, pointer); + if (widget !is null && (cast(Browser)widget !is null) { + return (cast(Mozilla)(cast(Browser)widget).webBrowser).mozDelegate.gtk_event (handle, gdkEvent, pointer); } return 0; } -static Browser findBrowser (int /*long*/ handle) { +static Browser findBrowser (GtkWidget* handle) { /* * Note. On GTK, Mozilla is embedded into a GtkHBox handle * and not directly into the parent Composite handle. */ - int /*long*/ parent = OS.gtk_widget_get_parent (handle); + GtkWidget* parent = OS.gtk_widget_get_parent (handle); Display display = Display.getCurrent (); - return (Browser)display.findWidget (parent); + return cast(Browser)display.findWidget (parent); } - +/* static char[] mbcsToWcs (String codePage, byte [] buffer) { return Converter.mbcsToWcs (codePage, buffer); } @@ -74,8 +77,8 @@ static byte[] wcsToMbcs (String codePage, String string, bool terminate) { return Converter.wcsToMbcs (codePage, string, terminate); } - -int /*long*/ getHandle () { +*/ +GtkWidget* getHandle () { /* * Bug in Mozilla Linux GTK. Embedding Mozilla into a GtkFixed * handle causes problems with some Mozilla plug-ins. For some @@ -96,13 +99,13 @@ return "libxpcom.so"; //$NON-NLS-1$ } +/* String getSWTInitLibraryName () { return "swt-xpcominit"; //$NON-NLS-1$ } +*/ -int /*long*/ gtk_event (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) { - GdkEvent event = new GdkEvent (); - OS.memmove (event, gdkEvent, GdkEvent.sizeof); +int gtk_event (GtkWidget* handle, GdkEvent* event, gpointer pointer) { if (event.type is OS.GDK_BUTTON_PRESS) { if (!hasFocus) browser.setFocus (); } @@ -121,7 +124,7 @@ listener = new Listener () { public void handleEvent (Event event) { if (event.widget is browser) return; - ((Mozilla)browser.webBrowser).Deactivate (); + (cast(Mozilla)(browser.webBrowser)).Deactivate (); hasFocus = false; browser.getDisplay ().removeFilter (DWT.FocusIn, this); browser.getShell ().removeListener (DWT.Deactivate, this); @@ -138,7 +141,7 @@ browser.getDisplay ().asyncExec (new Runnable () { public void run () { if (browser is null || browser.isDisposed ()) return; - ((Mozilla)browser.webBrowser).Activate (); + (cast(Mozilla)(browser.webBrowser)).Activate (); } }); } @@ -148,15 +151,15 @@ return false; } -void init () { +void init () { /* if (eventCallback is null) { eventCallback = new Callback (getClass (), "eventProc", 3); //$NON-NLS-1$ eventProc = eventCallback.getAddress (); - if (eventProc is 0) { + if (eventProc is null) { browser.dispose (); Mozilla.error (DWT.ERROR_NO_MORE_CALLBACKS); } - } + } */ /* * Feature in Mozilla. GtkEvents such as key down, key pressed may be consumed @@ -166,14 +169,14 @@ * forward the event to the parent embedder before Mozilla received and consumed * them. */ - int /*long*/ list = OS.gtk_container_get_children (embedHandle); - if (list !is 0) { + GList* list = OS.gtk_container_get_children (embedHandle); + if (list !is null) { mozillaHandle = OS.g_list_data (list); OS.g_list_free (list); - if (mozillaHandle !is 0) { + if (mozillaHandle !is null) { /* Note. Callback to get events before Mozilla receives and consumes them. */ - OS.g_signal_connect (mozillaHandle, OS.event, eventProc, 0); + OS.g_signal_connect (mozillaHandle, OS.event, cast(GCallback)&eventProc, null); /* * Note. Callback to get the events not consumed by Mozilla - and to block @@ -181,9 +184,9 @@ * This hook is set after Mozilla and is therefore called after Mozilla's * handler because GTK dispatches events in their order of registration. */ - OS.g_signal_connect (mozillaHandle, OS.key_press_event, eventProc, STOP_PROPOGATE); - OS.g_signal_connect (mozillaHandle, OS.key_release_event, eventProc, STOP_PROPOGATE); - OS.g_signal_connect (mozillaHandle, OS.button_press_event, eventProc, STOP_PROPOGATE); + OS.g_signal_connect (mozillaHandle, OS.key_press_event, cast(GCallback)&eventProc, STOP_PROPOGATE); + OS.g_signal_connect (mozillaHandle, OS.key_release_event, cast(GCallback)&eventProc, STOP_PROPOGATE); + OS.g_signal_connect (mozillaHandle, OS.button_press_event, cast(GCallback)&eventProc, STOP_PROPOGATE); } } } @@ -201,7 +204,7 @@ browser = null; } -void setSize (int /*long*/ embedHandle, int width, int height) { +void setSize (GtkWidget* embedHandle, int width, int height) { OS.gtk_widget_set_size_request (embedHandle, width, height); } diff -r e72345914350 -r 44258e0b6687 dwt/browser/OpenWindowListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/ProgressAdapter.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/ProgressEvent.d --- a/dwt/browser/ProgressEvent.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/ProgressEvent.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,8 +7,6 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.ProgressEvent; @@ -25,7 +23,7 @@ * * @since 3.0 */ -public class ProgressEvent : TypedEvent { +public class ProgressEvent extends TypedEvent { /** current value */ public int current; /** total value */ @@ -33,19 +31,21 @@ static final long serialVersionUID = 3977018427045393972L; - this(Widget w) { - super(w); - } +ProgressEvent(Widget w) { + super(w); +} - /** - * Returns a string containing a concise, human-readable - * description of the receiver. - * - * @return a string representation of the event - */ - - public override String toString () { - return Format( "ProgressEvent { current={} total={} }", - current, total ); - } +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " current=" + current + + " total=" + total + + "}"; } +} diff -r e72345914350 -r 44258e0b6687 dwt/browser/ProgressListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/PromptDialog.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/PromptService2.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/PromptService2Factory.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/SimpleEnumerator.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/StatusTextEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/StatusTextListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/TitleEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/TitleListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/VisibilityWindowAdapter.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/VisibilityWindowListener.d diff -r e72345914350 -r 44258e0b6687 dwt/browser/WebBrowser.d --- a/dwt/browser/WebBrowser.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/WebBrowser.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.WebBrowser; @@ -17,13 +19,13 @@ abstract class WebBrowser { Browser browser; - CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0]; - LocationListener[] locationListeners = new LocationListener[0]; - OpenWindowListener[] openWindowListeners = new OpenWindowListener[0]; - ProgressListener[] progressListeners = new ProgressListener[0]; - StatusTextListener[] statusTextListeners = new StatusTextListener[0]; - TitleListener[] titleListeners = new TitleListener[0]; - VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0]; + CloseWindowListener[] closeWindowListeners; + LocationListener[] locationListeners; + OpenWindowListener[] openWindowListeners; + ProgressListener[] progressListeners; + StatusTextListener[] statusTextListeners; + TitleListener[] titleListeners; + VisibilityWindowListener[] visibilityWindowListeners; static Runnable MozillaClearSessions; static Runnable NativeClearSessions; diff -r e72345914350 -r 44258e0b6687 dwt/browser/WindowCreator2.d --- a/dwt/browser/WindowCreator2.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/WindowCreator2.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,16 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.WindowCreator2; import dwt.dwthelper.utils; +import dwt.DWT; +import dwt.graphics.Point; +import dwt.internal.C; import dwt.internal.Platform; - import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; import dwt.internal.mozilla.nsIBaseWindow; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsISupports; @@ -24,9 +25,7 @@ import dwt.internal.mozilla.nsIWebBrowser; import dwt.internal.mozilla.nsIWebBrowserChrome; import dwt.internal.mozilla.nsIWindowCreator; - -import dwt.DWT; -import dwt.graphics.Point; +import dwt.internal.mozilla.nsIWindowCreator2; import dwt.layout.FillLayout; import dwt.widgets.Shell; diff -r e72345914350 -r 44258e0b6687 dwt/browser/WindowEvent.d --- a/dwt/browser/WindowEvent.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/browser/WindowEvent.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,8 +7,6 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Port to the D programming language: - * John Reimer *******************************************************************************/ module dwt.browser.WindowEvent; @@ -125,8 +123,7 @@ * * @since 3.0 */ - -public class WindowEvent : TypedEvent { +public class WindowEvent extends TypedEvent { /** * Specifies whether the platform requires the user to provide a @@ -189,19 +186,27 @@ static final long serialVersionUID = 3617851997387174969L; - this(Widget w) { - super(w); - } +WindowEvent(Widget w) { + super(w); +} - /** - * Returns a string containing a concise, human-readable - * description of the receiver. - * - * @return a string representation of the event - */ - - public override String toString () { - return Format( "WindowEvent {required={} browser={} location={} size={} addressBar={} menuBar={} statusBar={} toolBar={} }", - required, browser, location, size, addressBar, menuBar, statusBar, tooBar ); - } +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " required=" + required + + " browser=" + browser + + " location=" + location + + " size=" + size + + " addressBar=" + addressBar + + " menuBar=" + menuBar + + " statusBar=" + statusBar + + " toolBar=" + toolBar + + "}"; } +} diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/Common.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/gfxIImageFrame.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/imgIContainer.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/imgIContainerObserver.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsEmbedString.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsEmbedString2.d --- a/dwt/internal/mozilla/nsEmbedString2.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsEmbedString2.d Tue Aug 05 10:11:58 2008 -0700 @@ -4,7 +4,7 @@ import dwt.internal.mozilla.nsStringAPI; class nsEmbedString -{ +{ this(wchar[] s) { nsresult result; @@ -31,11 +31,10 @@ wchar* buffer = null; PRBool terminated; uint len = NS_StringGetData(cast(nsAString*)&str, &buffer, &terminated); - wchar[] result = buffer[0 .. len].dup; - return result; + return buffer[0 .. len].dup; } - - ~this() + + ~this() { NS_StringContainerFinish(&str); } @@ -72,8 +71,7 @@ char* buffer = null; PRBool terminated; uint len = NS_CStringGetData(cast(nsACString*)&str, &buffer, &terminated); - char[] result = buffer[0 .. len].dup; - return result; + return buffer[0 .. len].dup; } ~this() diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsError.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIAppShell.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIAtom.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIAuthInformation.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIAuthPrompt.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIBaseWindow.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIBinaryInputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIBinaryOutputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICancelable.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICategoryManager.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIChannel.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIChromeEventHandler.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICollection.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIComponentManager.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIComponentRegistrar.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIContentViewer.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIContextMenuListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIContextMenuListener2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICookie.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICookie2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICookieManager.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsICookieManager2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsID.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMAbstractView.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMAttr.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMBarProp.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMCDATASection.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMCharacterData.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMComment.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMDOMImplementation.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMDocument.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMDocumentFragment.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMDocumentType.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMDocumentView.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMElement.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMEntityReference.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMEventGroup.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMEventListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMEventTarget.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMKeyEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMMouseEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMNamedNodeMap.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMNode.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMNodeList.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMProcessingInstruction.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMRange.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMSerializer.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMStorage.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMStorageItem.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMText.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMUIEvent.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMWindow.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMWindow2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDOMWindowCollection.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDebug.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDirectoryService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDocShell.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDocShellLoadInfo.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDocShellTreeItem.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDocShellTreeOwner.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDocumentCharsetInfo.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDownload.d --- a/dwt/internal/mozilla/nsIDownload.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsIDownload.d Tue Aug 05 10:11:58 2008 -0700 @@ -17,38 +17,22 @@ extern(System) -interface nsIDownload : nsITransfer { +interface nsIDownload : nsISuppports { static const char[] IID_STR = NS_IDOWNLOAD_IID_STR; static const nsIID IID = NS_IDOWNLOAD_IID; - - nsresult GetTargetFile(nsILocalFile *aTargetFile); - nsresult GetPercentComplete(PRInt32 *aPercentComplete); - nsresult GetAmountTransferred(PRUint64 *aAmountTransferred); - nsresult GetSize(PRUint64 *aSize); + + nsresult Init(nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, int /*long*/ aPersist); nsresult GetSource(nsIURI *aSource); nsresult GetTarget(nsIURI *aTarget); - nsresult GetCancelable(nsICancelable *aCancelable); + nsresult GetPersist(int *aPersist); + nsresult GetPercentComplete(PRInt32 *aPercentComplete); nsresult GetDisplayName(PRUnichar * *aDisplayName); + nsresult SetDisplayName(char[] aDisplayName); nsresult GetStartTime(PRInt64 *aStartTime); nsresult GetMIMEInfo(nsIMIMEInfo *aMIMEInfo); - + nsresult GetListener(int * aListener); + nsresult SetListener(int aListener); + nsresult GetObserver(int * aObserver); + nsresult SetObserver(int aObserver); } - -const char[] NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID_STR = "ff76f0c7-caaf-4e64-8896-154348322696"; - -const nsIID NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID= - {0xff76f0c7, 0xcaaf, 0x4e64, - [ 0x88, 0x96, 0x15, 0x43, 0x48, 0x32, 0x26, 0x96 ]}; - -extern(System) - -interface nsIDownload_MOZILLA_1_8_BRANCH : nsIDownload { - - static const char[] IID_STR = NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID_STR; - static const nsIID IID = NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID; - - nsresult GetSpeed(double *aSpeed); - -} - diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIDownload_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsIDownload_1_8.d Tue Aug 05 10:11:58 2008 -0700 @@ -0,0 +1,36 @@ +module dwt.internal.mozilla.nsIDownload; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsITransfer; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIObserver; +import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsIMIMEInfo; + +const char[] NS_IDOWNLOAD_IID_STR = "9e1fd9f2-9727-4926-85cd-f16c375bba6d"; + +const nsIID NS_IDOWNLOAD_IID= + {0x9e1fd9f2, 0x9727, 0x4926, + [ 0x85, 0xcd, 0xf1, 0x6c, 0x37, 0x5b, 0xba, 0x6d ]}; + +extern(System) + +interface nsIDownload_1_8 : nsITransfer { + + static const char[] IID_STR = NS_IDOWNLOAD_IID_STR; + static const nsIID IID = NS_IDOWNLOAD_IID; + + nsresult GetTargetFile(nsILocalFile *aTargetFile); + nsresult GetPercentComplete(PRInt32 *aPercentComplete); + nsresult GetAmountTransferred(PRUint64 *aAmountTransferred); + nsresult GetSize(PRUint64 *aSize); + nsresult GetSource(nsIURI *aSource); + nsresult GetTarget(nsIURI *aTarget); + nsresult GetCancelable(nsICancelable *aCancelable); + nsresult GetDisplayName(PRUnichar * *aDisplayName); + nsresult GetStartTime(PRInt64 *aStartTime); + nsresult GetMIMEInfo(nsIMIMEInfo *aMIMEInfo); + +} \ No newline at end of file diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIEmbeddingSiteWindow.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIEmbeddingSiteWindow2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIEnumerator.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIEventQueue.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIEventTarget.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIExternalHelperAppService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIFactory.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIFile.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIFilePicker.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIFileURL.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIHelperAppLauncherDialog.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIHistoryEntry.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIIOService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIIOService2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIInputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIInterfaceRequestor.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIJSContextStack.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsILoadGroup.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsILocalFile.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIMIMEInfo.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIMemory.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIModule.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIObjectInputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIObjectOutputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIObserver.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIObserverService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIOutputStream.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPrefBranch.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPrefBranch2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPrefLocalizedString.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPrefService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIProgressDialog.d --- a/dwt/internal/mozilla/nsIProgressDialog.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsIProgressDialog.d Tue Aug 05 10:11:58 2008 -0700 @@ -7,11 +7,11 @@ import dwt.internal.mozilla.nsIDOMWindow; import dwt.internal.mozilla.nsIObserver; -const char[] NS_IPROGRESSDIALOG_IID_STR = "20e790a2-76c6-462d-851a-22ab6cbbe48b"; +const char[] NS_IPROGRESSDIALOG_IID_STR = "88a478b3-af65-440a-94dc-ed9b154d2990"; const nsIID NS_IPROGRESSDIALOG_IID= - {0x20e790a2, 0x76c6, 0x462d, - [ 0x85, 0x1a, 0x22, 0xab, 0x6c, 0xbb, 0xe4, 0x8b ]}; + {0x88a478b3, 0xaf65, 0x440a, + [ 0x94, 0xdc, 0xed, 0x9b, 0x15, 0x4d, 0x29, 0x90 ]}; extern(System) @@ -23,8 +23,6 @@ nsresult Open(nsIDOMWindow aParent); nsresult GetCancelDownloadOnClose(PRBool *aCancelDownloadOnClose); nsresult SetCancelDownloadOnClose(PRBool aCancelDownloadOnClose); - nsresult GetObserver(nsIObserver *aObserver); - nsresult SetObserver(nsIObserver aObserver); nsresult GetDialog(nsIDOMWindow *aDialog); nsresult SetDialog(nsIDOMWindow aDialog); diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIProgressDialog_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsIProgressDialog_1_8.d Tue Aug 05 10:11:58 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIProgressDialog_1_8; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDownload; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIObserver; + +const char[] NS_IPROGRESSDIALOG_IID_STR = "20e790a2-76c6-462d-851a-22ab6cbbe48b"; + +const nsIID NS_IPROGRESSDIALOG_IID= + {0x20e790a2, 0x76c6, 0x462d, + [ 0x85, 0x1a, 0x22, 0xab, 0x6c, 0xbb, 0xe4, 0x8b ]}; + +extern(System) + +interface nsIProgressDialog_1_8 : nsIDownload_1_8 { + + static const char[] IID_STR = NS_IPROGRESSDIALOG_IID_STR; + static const nsIID IID = NS_IPROGRESSDIALOG_IID; + + nsresult Open(nsIDOMWindow aParent); + nsresult GetCancelDownloadOnClose(PRBool *aCancelDownloadOnClose); + nsresult SetCancelDownloadOnClose(PRBool aCancelDownloadOnClose); + nsresult GetObserver(nsIObserver *aObserver); + nsresult SetObserver(nsIObserver aObserver); + nsresult GetDialog(nsIDOMWindow *aDialog); + nsresult SetDialog(nsIDOMWindow aDialog); + +} + diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPrompt.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIPromptService.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIProperties.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIProtocolHandler.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIRequest.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIRequestObserver.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISHEntry.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISHistory.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISHistoryListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISecureBrowserUI.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISelection.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISerializable.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIServiceManager.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISimpleEnumerator.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIStreamListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIStringEnumerator.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISupports.d --- a/dwt/internal/mozilla/nsISupports.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsISupports.d Tue Aug 05 10:11:58 2008 -0700 @@ -16,7 +16,7 @@ static const char[] IID_STR = NS_ISUPPORTS_IID_STR; static const nsIID IID = NS_ISUPPORTS_IID; - nsresult QueryInterface(nsIID * uuid, void **result); + nsresult QueryInterface(ref nsIID uuid, void **result); nsrefcnt AddRef(); nsrefcnt Release(); diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISupports.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsISupports.d~ Tue Aug 05 10:11:58 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +const char[] NS_ISUPPORTS_IID_STR = "00000000-0000-0000-c000-000000000046"; + +const nsIID NS_ISUPPORTS_IID= + { 0x00000000, 0x0000, 0x0000, + [ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 ] }; + +extern(System) + +interface IUnknown +{ + static const char[] IID_STR = NS_ISUPPORTS_IID_STR; + static const nsIID IID = NS_ISUPPORTS_IID; + + nsresult QueryInterface(nsIID * uuid, void **result); + + nsrefcnt AddRef(); + nsrefcnt Release(); +} + +// WHY WE USE COM's IUnknown for XPCOM: +// +// The IUnknown interface is special-cased in D and is specifically designed to be +// compatible with MS COM. XPCOM's nsISupports interface is the exact equivalent +// of IUnknown so we alias it here to take advantage of D's COM support. -JJR + +alias IUnknown nsISupports; \ No newline at end of file diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsISupportsArray.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsITooltipListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsITraceRefcnt.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsITransfer.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIURI.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIURIContentListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIURL.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWeakReference.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebBrowser.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebBrowserChrome.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebBrowserChromeFocus.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebBrowserFocus.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebNavigation.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebNavigationInfo.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebProgress.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebProgressListener.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWebProgressListener2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWindowCreator.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWindowCreator2.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsIWindowWatcher.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsStringAPI.d --- a/dwt/internal/mozilla/nsStringAPI.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsStringAPI.d Tue Aug 05 10:11:58 2008 -0700 @@ -80,6 +80,14 @@ return result; } + static wchar[] getString16( nsAString* str ) + { + wchar* buffer = null; + PRBool terminated; + uint len = NS_StringGetData(str, &buffer, &terminated); + return buffer[0 .. len].dup; + } + private: void *v; } @@ -174,3 +182,14 @@ struct nsDependentSubstring_external{} struct nsDependentCSubstring_external{} +/****************************************************************************** + +******************************************************************************/ + +PRUint32 strlen_PRUnichar ( PRUnichar* str ) +{ + PRUint32 len = 0; + if (str !is null) + while (*(lparg0++) != 0) len++; + ret len; +} \ No newline at end of file diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsStringAPI.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsStringAPI.d~ Tue Aug 05 10:11:58 2008 -0700 @@ -0,0 +1,187 @@ +module dwt.internal.mozilla.nsStringAPI; + +import dwt.internal.mozilla.Common; + +extern (System): + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_STRING_CONTAINER_INIT_DEPEND = 2, + NS_STRING_CONTAINER_INIT_ADOPT = 4, + NS_STRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_StringContainerInit ( nsStringContainer *aContainer ); +nsresult NS_StringContainerInit2( nsStringContainer *aContainer, PRUnichar *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_StringContainerFinish(nsStringContainer *aContainer); +PRUint32 NS_StringGetData(nsAString *aStr, PRUnichar **aData, PRBool *aTerminated); +PRUint32 NS_StringGetMutableData(nsAString *aStr, PRUint32 aDataLength, PRUnichar **aData); +PRUnichar * NS_StringCloneData(nsAString *aStr); +nsresult NS_StringSetData(nsAString *aStr, PRUnichar *aData, PRUint32 aDataLength); +nsresult NS_StringSetDataRange( nsAString *aStr, PRUint32 aCutOffset, PRUint32 aCutLength, PRUnichar *aData, PRUint32 aDataLength ); +nsresult NS_StringCopy(nsAString *aDestStr, nsAString *aSrcStr); + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_CSTRING_CONTAINER_INIT_DEPEND = 2, + NS_CSTRING_CONTAINER_INIT_ADOPT = 4, + NS_CSTRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_CStringContainerInit( nsCStringContainer *aContainer ); +nsresult NS_CStringContainerInit2( nsCStringContainer *aContainer, char *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_CStringContainerFinish( nsCStringContainer *aContainer ); +PRUint32 NS_CStringGetData( nsACString *aStr, char **aData, PRBool *aTerminated ); +PRUint32 NS_CStringGetMutableData( nsACString *aStr, PRUint32 aDataLength, char **aData ); +char * NS_CStringCloneData( nsACString *aStr); +nsresult NS_CStringSetData( nsACString *aStr, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringSetDataRange( nsACString *aStr, PRUint32 aCutOffset, + PRUint32 aCutLength, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringCopy( nsACString *aDestStr, nsACString *aSrcStr ); + +/****************************************************************************** + +******************************************************************************/ + +enum nsCStringEncoding +{ + NS_CSTRING_ENCODING_ASCII, + NS_CSTRING_ENCODING_UTF8, + NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, +} + +nsresult NS_CStringToUTF16( nsACString *aSource, int aSrcEncoding, nsAString *aDest ); +nsresult NS_UTF16ToCString( nsAString *aSource, int aDestEncoding, nsACString *aDest ); + +/****************************************************************************** + +******************************************************************************/ + +alias nsAString nsAString_external; +alias nsACString nsACString_external; + +alias nsAString nsEmbedString; +alias nsACString nsEmbedCString; + +struct nsAString +{ + static nsAString opCall(wchar[] s) + { + nsAString result; + NS_StringSetData(&result, cast(PRUnichar*)s, uint.max); + return result; + } + + private: + void *v; +} + +struct nsACString +{ + static nsACString opCall(char[] s) + { + nsACString result; + NS_CStringSetData(&result, cast(char*)s, uint.max); + return result; + } + + private: + void *v; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsStringContainer// : public nsAString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +struct nsCStringContainer// : public nsACString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +/****************************************************************************** + +******************************************************************************/ + +// import mozilla.xpcom.nsDebug; + +alias nsString_external nsString; +alias nsCString_external nsCString; +alias nsDependentString_external nsDependentString; +alias nsDependentCString_external nsDependentCString; +alias NS_ConvertASCIItoUTF16_external NS_ConvertASCIItoUTF16; +alias NS_ConvertUTF8toUTF16_external NS_ConvertUTF8toUTF16; +alias NS_ConvertUTF16toUTF8_external NS_ConvertUTF16toUTF8; +alias NS_LossyConvertUTF16toASCII_external NS_LossyConvertUTF16toASCII; +alias nsGetterCopies_external nsGetterCopies; +alias nsCGetterCopies_external nsCGetterCopies; +alias nsDependentSubstring_external nsDependentSubstring; +alias nsDependentCSubstring_external nsDependentCSubstring; + +struct nsString_external{} +struct nsCString_external{} +struct nsDependentString_external{} +struct nsDependentCString_external{} +struct NS_ConvertASCIItoUTF16_external{} +struct NS_ConvertUTF8toUTF16_external{} +struct NS_ConvertUTF16toUTF8_external{} +struct NS_LossyConvertUTF16toASCII_external{} + +/****************************************************************************** + +******************************************************************************/ + +struct nsGetterCopies_external +{ + private: + alias PRUnichar char_type; + nsString_external *mString; + char_type *mData; +} + +struct nsCGetterCopies_external +{ + private: + alias char char_type; + nsCString_external *mString; + char_type *mData; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsDependentSubstring_external{} +struct nsDependentCSubstring_external{} + +/****************************************************************************** + +******************************************************************************/ + +PRUint32 strlen_PRUnichar ( PRUnichar* str ) +{ + PRUint32 len = 0; + if (str !is null) + while (*lparg0++ != 0) len++; + ret len; +} \ No newline at end of file diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsXPCOM.d --- a/dwt/internal/mozilla/nsXPCOM.d Thu Jul 31 21:56:03 2008 -0700 +++ b/dwt/internal/mozilla/nsXPCOM.d Tue Aug 05 10:11:58 2008 -0700 @@ -1,4 +1,3 @@ -/****************************************************************************** module dwt.internal.mozilla.nsXPCOM; @@ -45,10 +44,10 @@ nsresult NS_GetComponentManager(nsIComponentManager *result); nsresult NS_GetComponentRegistrar(nsIComponentRegistrar *result); nsresult NS_GetMemoryManager(nsIMemory *result); -nsresult NS_NewLocalFile(inout nsAString path, PRBool followLinks, nsILocalFile** result); -nsresult NS_NewNativeLocalFile(inout nsACString path, PRBool followLinks, nsILocalFile** result); +nsresult NS_NewLocalFile(inout nsAString path, PRBool followLinks, nsILocalFile* result); +nsresult NS_NewNativeLocalFile(inout nsACString path, PRBool followLinks, nsILocalFile* result); void * NS_Alloc(PRSize size); void * NS_Realloc(void *ptr, PRSize size); void NS_Free(void *ptr); -nsresult NS_GetDebug(nsIDebug **result); +nsresult NS_GetDebug(nsIDebug *result); nsresult NS_GetTraceRefcnt(nsITraceRefcnt *result); diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsXPCOM.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsXPCOM.d~ Tue Aug 05 10:11:58 2008 -0700 @@ -0,0 +1,54 @@ +/****************************************************************************** + +module dwt.internal.mozilla.nsXPCOM; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsIModule; +import dwt.internal.mozilla.nsIComponentManager; +import dwt.internal.mozilla.nsIComponentRegistrar; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIMemory; +import dwt.internal.mozilla.nsIDebug; +import dwt.internal.mozilla.nsITraceRefcnt; + +/****************************************************************************** + +******************************************************************************/ + +extern (System): + +struct nsStaticModuleInfo +{ + char *name; + nsGetModuleProc getModule; +} + +alias nsresult function (nsIComponentManager, nsIFile, nsIModule*) nsGetModuleProc; + +/****************************************************************************** + +******************************************************************************/ + +nsresult NS_InitXPCOM2( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider ); +nsresult NS_InitXPCOM3( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider, + nsStaticModuleInfo* staticComponents, + PRUint32 componentCount ); + +nsresult NS_ShutdownXPCOM(nsIServiceManager servMgr); +nsresult NS_GetServiceManager(nsIServiceManager *result); +nsresult NS_GetComponentManager(nsIComponentManager *result); +nsresult NS_GetComponentRegistrar(nsIComponentRegistrar *result); +nsresult NS_GetMemoryManager(nsIMemory *result); +nsresult NS_NewLocalFile(inout nsAString path, PRBool followLinks, nsILocalFile** result); +nsresult NS_NewNativeLocalFile(inout nsACString path, PRBool followLinks, nsILocalFile** result); +void * NS_Alloc(PRSize size); +void * NS_Realloc(void *ptr, PRSize size); +void NS_Free(void *ptr); +nsresult NS_GetDebug(nsIDebug **result); +nsresult NS_GetTraceRefcnt(nsITraceRefcnt *result); diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/nsXPCOMGlue.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/prinrval.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/prio.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/prlink.d diff -r e72345914350 -r 44258e0b6687 dwt/internal/mozilla/prtime.d