From 3f701b6803ad90a65f23c52df5f75329dbf3dbad Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Mon, 25 Oct 2004 19:34:45 +0000 Subject: [PATCH] landing patch for bug 262218 "libxpcom.so should only export frozen symbols" r=bsmedberg sr=bryner git-svn-id: svn://10.0.0.236/trunk@164375 18797224-902f-48f8-a5cc-f745e15eee43 --- .../installer/windows/packages-static | 1 + mozilla/config/prebind-address-table | 1 + mozilla/configure.in | 9 +- mozilla/editor/idl/nsIEditor.idl | 3 - mozilla/embedding/base/Makefile.in | 2 + mozilla/embedding/base/nsEmbedAPI.cpp | 5 +- .../appstartup/src/nsIAppStartupNotifier.h | 3 - .../embedding/config/basebrowser-mac-macho | 1 + mozilla/embedding/config/basebrowser-qnx | 1 + mozilla/embedding/config/basebrowser-unix | 1 + mozilla/embedding/config/basebrowser-win | 1 + mozilla/embedding/config/minimo-qnx | 1 + mozilla/embedding/config/minimo-unix | 1 + .../tests/mfcembed/BrowserFrameGlue.cpp | 36 +- .../embedding/tests/mfcembed/BrowserView.cpp | 182 +++++++-- .../embedding/tests/mfcembed/BrowserView.h | 14 +- .../tests/mfcembed/CPageSetupPropSheet.cpp | 20 +- .../embedding/tests/mfcembed/EditorFrm.cpp | 33 +- mozilla/embedding/tests/mfcembed/EditorFrm.h | 11 +- mozilla/embedding/tests/mfcembed/Makefile.in | 5 +- mozilla/embedding/tests/mfcembed/MfcEmbed.cpp | 47 +-- .../tests/mfcembed/MostRecentUrls.cpp | 4 +- .../embedding/tests/mfcembed/ProfileMgr.cpp | 16 +- .../embedding/tests/mfcembed/ProfilesDlg.cpp | 10 +- .../embedding/tests/mfcembed/ProfilesDlg.h | 2 +- mozilla/embedding/tests/mfcembed/StdAfx.h | 6 +- .../mfcembed/winEmbedFileLocProvider.cpp | 26 +- .../tests/mfcembed/winEmbedFileLocProvider.h | 7 +- mozilla/mail/config/basemail-os2 | 1 + mozilla/mail/config/basemail-unix | 1 + mozilla/mail/installer/windows/basemail-win | 1 + mozilla/widget/public/nsILookAndFeel.h | 1 - .../widget/src/xpwidgets/nsXPLookAndFeel.cpp | 1 + mozilla/xpcom/Makefile.in | 1 + mozilla/xpcom/base/nsISupports.idl | 3 - mozilla/xpcom/build/Makefile.in | 12 +- mozilla/xpcom/build/dlldeps.cpp | 22 +- mozilla/xpcom/build/nsStringAPI.cpp | 1 - mozilla/xpcom/build/nsXPCOM.h | 14 + mozilla/xpcom/build/nsXPCOMPrivate.h | 7 + mozilla/xpcom/glue/nsMemory.cpp | 2 + mozilla/xpcom/glue/nsWeakReference.h | 1 + mozilla/xpcom/glue/standalone/Makefile.in | 2 +- mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp | 3 + mozilla/xpcom/sample/Makefile.in | 2 +- mozilla/xpcom/sample/nsTestSample.cpp | 3 + mozilla/xpcom/string/public/nsStringAPI.h | 18 +- mozilla/xpcom/stub/Makefile.in | 82 +++++ mozilla/xpcom/stub/nsStringAPI.cpp | 1 - mozilla/xpcom/stub/nsXPComStub.cpp | 144 ++++++++ mozilla/xpcom/tests/TestMinStringAPI.cpp | 50 +++ mozilla/xpcom/tools/registry/Makefile.in | 2 +- .../appshell/public/nsICmdLineHandler.idl | 2 - mozilla/xpfe/bootstrap/Makefile.in | 5 +- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 52 ++- .../xpfe/bootstrap/nsNativeAppSupportBeOS.cpp | 8 +- .../xpfe/bootstrap/nsNativeAppSupportGtk.cpp | 7 +- .../xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 8 +- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 27 +- mozilla/xpfe/bootstrap/nsStringSupport.h | 345 ++++++++++++++++++ mozilla/xpfe/bootstrap/nsWindowCreator.cpp | 1 + mozilla/xpfe/bootstrap/os2turbo/mozturbo.cpp | 1 + .../startup/public/nsICmdLineHandler.idl | 2 - mozilla/xpinstall/packager/packages-os2 | 1 + .../xpinstall/packager/packages-static-unix | 1 + mozilla/xpinstall/packager/packages-unix | 1 + .../xpinstall/packager/windows/browser.jst | 1 + mozilla/xpinstall/packager/xpcom-win.pkg | 1 + mozilla/xpinstall/public/nsISoftwareUpdate.h | 1 - 69 files changed, 1055 insertions(+), 233 deletions(-) create mode 100644 mozilla/xpcom/stub/Makefile.in create mode 100644 mozilla/xpcom/stub/nsXPComStub.cpp create mode 100644 mozilla/xpfe/bootstrap/nsStringSupport.h diff --git a/mozilla/calendar/installer/windows/packages-static b/mozilla/calendar/installer/windows/packages-static index 6bc3875a17f..f6a80146c02 100644 --- a/mozilla/calendar/installer/windows/packages-static +++ b/mozilla/calendar/installer/windows/packages-static @@ -39,6 +39,7 @@ bin\js3250.dll bin\plc4.dll bin\plds4.dll bin\xpcom.dll +bin\xpcom_core.dll bin\xpistub.dll bin\nspr4.dll bin\components\xpinstal.dll diff --git a/mozilla/config/prebind-address-table b/mozilla/config/prebind-address-table index ec331d857a6..e653a5860ac 100644 --- a/mozilla/config/prebind-address-table +++ b/mozilla/config/prebind-address-table @@ -11,3 +11,4 @@ 0x0d000000 @executable_path/libmozcomps.dylib 0x0e000000 @executable_path/libprldap50.dylib 0x0f000000 @executable_path/libldap50.dylib +0x10000000 @executable_path/libxpcom_core.dylib diff --git a/mozilla/configure.in b/mozilla/configure.in index 46a0afc108b..5b1d59fadc6 100644 --- a/mozilla/configure.in +++ b/mozilla/configure.in @@ -574,7 +574,7 @@ MOZ_PNG_CFLAGS= MOZ_PNG_LIBS='-L$(DIST)/lib -lmozpng' MOZ_JS_LIBS='-L$(DIST)/bin -lmozjs' -XPCOM_LIBS='-L$(DIST)/bin -lxpcom' +XPCOM_LIBS='-L$(DIST)/bin -lxpcom -lxpcom_core' MOZ_COMPONENT_NSPR_LIBS='-L$(DIST)/bin $(NSPR_LIBS)' MOZ_COMPONENT_XPCOM_LIBS='$(XPCOM_LIBS)' @@ -1145,7 +1145,7 @@ case "$target" in MOZ_ZLIB_LIBS='-L$(DIST)/lib -lmozz' MOZ_PNG_LIBS='-L$(DIST)/lib -lpng' MOZ_JS_LIBS='-L$(DIST)/lib -ljs$(MOZ_BITS)$(VERSION_NUMBER)' - XPCOM_LIBS='-L$(DIST)/lib -lxpcom' + XPCOM_LIBS='-L$(DIST)/lib -lxpcom -lxpcom_core' DLL_PREFIX= IMPORT_LIB_SUFFIX=dll.a else @@ -1181,7 +1181,7 @@ case "$target" in MOZ_ZLIB_LIBS='$(DIST)/lib/mozz.lib' MOZ_PNG_LIBS='$(DIST)/lib/png.lib' MOZ_JS_LIBS='$(DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib' - XPCOM_LIBS='$(DIST)/lib/xpcom.lib' + XPCOM_LIBS='$(DIST)/lib/xpcom.lib $(DIST)/lib/xpcom_core.lib' MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)' MOZ_COMPONENT_XPCOM_LIBS='$(XPCOM_LIBS)' MOZ_XPCOM_OBSOLETE_LIBS='$(DIST)/lib/xpcom_compat.lib' @@ -1426,6 +1426,7 @@ case "$target" in MOZ_WIDGET_TOOLKIT_LDFLAGS='-lwdgt$(MOZ_WIDGET_TOOLKIT)' MOZ_GFX_TOOLKIT_LDFLAGS='-lgfx_$(MOZ_GFX_TOOLKIT)' MOZ_XPCOM_OBSOLETE_LIBS='-L$(DIST)/lib $(DIST)/lib/xpcomct.lib' + XPCOM_LIBS='-L$(DIST)/lib $(DIST)/lib/xpcom.lib $(DIST)/lib/xpcomcor.lib' # GCC for OS/2 currently predefines these, but we don't want them _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__" @@ -1469,7 +1470,7 @@ case "$target" in MOZ_JS_LIBS='$(DIST)/lib/mozjs.lib' MOZ_COMPONENT_XPCOM_LIBS='$(DIST)/lib/xpcom.lib' MOZ_XPCOM_OBSOLETE_LIBS='$(DIST)/lib/xpcomct.lib' - XPCOM_LIBS='$(DIST)/lib/xpcom.lib' + XPCOM_LIBS='$(DIST)/lib/xpcom.lib $(DIST)/lib/xpcomcor.lib' MOZ_JPEG_LIBS='$(DIST)/lib/mozjpeg.$(LIB_SUFFIX)' MOZ_ZLIB_LIBS='$(DIST)/lib/mozz.$(LIB_SUFFIX)' MOZ_PNG_LIBS='$(DIST)/lib/mozpng.$(LIB_SUFFIX)' diff --git a/mozilla/editor/idl/nsIEditor.idl b/mozilla/editor/idl/nsIEditor.idl index 81c9f20852b..dbd1f966947 100644 --- a/mozilla/editor/idl/nsIEditor.idl +++ b/mozilla/editor/idl/nsIEditor.idl @@ -53,9 +53,6 @@ interface nsIEditorObserver; interface nsIEditActionListener; %{C++ - -#include "nsAString.h" - class nsIPresShell; class nsIContent; typedef short EDirection; diff --git a/mozilla/embedding/base/Makefile.in b/mozilla/embedding/base/Makefile.in index 8ca5f0c9a86..c964d389226 100644 --- a/mozilla/embedding/base/Makefile.in +++ b/mozilla/embedding/base/Makefile.in @@ -52,6 +52,8 @@ REQUIRES = xpcom \ embedcomponents \ $(NULL) +DEFINES += -DMOZILLA_STRICT_API + SDK_HEADERS = \ nsEmbedAPI.h \ $(NULL) diff --git a/mozilla/embedding/base/nsEmbedAPI.cpp b/mozilla/embedding/base/nsEmbedAPI.cpp index c4fddacff06..2f363808250 100644 --- a/mozilla/embedding/base/nsEmbedAPI.cpp +++ b/mozilla/embedding/base/nsEmbedAPI.cpp @@ -44,8 +44,11 @@ #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsXPCOM.h" #include "nsEmbedAPI.h" -#include "nsLiteralString.h" +#include "nsCOMPtr.h" +#include "nsComponentManagerUtils.h" +#include "nsIServiceManagerUtils.h" static nsIServiceManager *sServiceManager = nsnull; static PRBool sRegistryInitializedFlag = PR_FALSE; diff --git a/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h b/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h index 01d179a264c..cd1cc56dba0 100644 --- a/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h +++ b/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h @@ -74,8 +74,6 @@ and release them. */ -#include "nsString.h" - #define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1" #define NS_APPSTARTUPNOTIFIER_CLASSNAME "AppStartup Notifier" @@ -92,4 +90,3 @@ */ #endif /* nsIAppStartupNotifier_h___ */ - diff --git a/mozilla/embedding/config/basebrowser-mac-macho b/mozilla/embedding/config/basebrowser-mac-macho index 7a08935782e..7b8f02a2672 100644 --- a/mozilla/embedding/config/basebrowser-mac-macho +++ b/mozilla/embedding/config/basebrowser-mac-macho @@ -28,6 +28,7 @@ libmozjs.dylib ; XPCOM: ; libxpcom.dylib +libxpcom_core.dylib libxpcom_compat.dylib components/libxpcom_compat_c.dylib components/xpcom_obsolete.xpt diff --git a/mozilla/embedding/config/basebrowser-qnx b/mozilla/embedding/config/basebrowser-qnx index 858ea5d6403..20b46a3a5b8 100644 --- a/mozilla/embedding/config/basebrowser-qnx +++ b/mozilla/embedding/config/basebrowser-qnx @@ -27,6 +27,7 @@ libmozjs.so ; XPCOM: ; libxpcom.so +libxpcom_core.so components/xpcom_base.xpt components/xpcom_components.xpt components/xpcom_ds.xpt diff --git a/mozilla/embedding/config/basebrowser-unix b/mozilla/embedding/config/basebrowser-unix index 85de3037e05..81f7afed6d1 100644 --- a/mozilla/embedding/config/basebrowser-unix +++ b/mozilla/embedding/config/basebrowser-unix @@ -27,6 +27,7 @@ libmozjs.so ; XPCOM: ; libxpcom.so +libxpcom_core.so components/xpcom_base.xpt components/xpcom_components.xpt components/xpcom_ds.xpt diff --git a/mozilla/embedding/config/basebrowser-win b/mozilla/embedding/config/basebrowser-win index 1390441844b..2f84e245b0d 100644 --- a/mozilla/embedding/config/basebrowser-win +++ b/mozilla/embedding/config/basebrowser-win @@ -45,6 +45,7 @@ js3250.dll ; XPCOM: ; xpcom.dll +xpcom_core.dll xpcom_compat.dll components\xpcom_compat_c.dll components\xpcom_base.xpt diff --git a/mozilla/embedding/config/minimo-qnx b/mozilla/embedding/config/minimo-qnx index 59467ae59a3..586301add74 100644 --- a/mozilla/embedding/config/minimo-qnx +++ b/mozilla/embedding/config/minimo-qnx @@ -22,6 +22,7 @@ libmozjs.so ; XPCOM: ; libxpcom.so +libxpcom_core.so components/xpcom_base.xpt components/xpcom_components.xpt components/xpcom_ds.xpt diff --git a/mozilla/embedding/config/minimo-unix b/mozilla/embedding/config/minimo-unix index 2d29a3e7f5a..aff0951150b 100644 --- a/mozilla/embedding/config/minimo-unix +++ b/mozilla/embedding/config/minimo-unix @@ -22,6 +22,7 @@ libmozjs.so ; XPCOM: ; libxpcom.so +libxpcom_core.so components/xpcom_base.xpt components/xpcom_components.xpt components/xpcom_ds.xpt diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp index 8595fe5ee24..11620b7738e 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp @@ -56,7 +56,6 @@ #include "MfcEmbed.h" #include "BrowserFrm.h" #include "Dialogs.h" -#include "nsReadableUtils.h" ///////////////////////////////////////////////////////////////////////////// // IBrowserFrameGlue implementation @@ -99,7 +98,7 @@ void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation) if(aLocation) { USES_CONVERSION; - nsCAutoString uriString; + nsEmbedCString uriString; aLocation->GetSpec(uriString); pThis->m_wndUrlBar.SetCurrentURL(A2CT(uriString.get())); } @@ -115,9 +114,9 @@ void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle if(!title.IsEmpty()) { USES_CONVERSION; - nsString nsTitle; + nsEmbedString nsTitle; nsTitle.Assign(T2CW(title.GetBuffer(0))); - *aTitle = ToNewUnicode(nsTitle); + *aTitle = NS_StringCloneData(nsTitle); } } @@ -327,7 +326,7 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, // Reset the values from the last invocation // Clear image src & link url - nsAutoString empty; + nsEmbedString empty; pThis->m_wndBrowserView.SetCtxMenuImageSrc(empty); pThis->m_wndBrowserView.SetCtxMenuLinkUrl(empty); pThis->m_wndBrowserView.SetCurrentFrameURL(empty); @@ -354,10 +353,13 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, aInfo->GetBackgroundImageSrc(getter_AddRefs(imgURI)); if (!imgURI) return; - nsCAutoString uri; + nsEmbedCString uri; imgURI->GetSpec(uri); - pThis->m_wndBrowserView.SetCtxMenuImageSrc(NS_ConvertUTF8toUCS2(uri)); // Set the new Img Src + nsEmbedString uri2; + NS_CStringToUTF16(uri, NS_CSTRING_ENCODING_UTF8, uri2); + + pThis->m_wndBrowserView.SetCtxMenuImageSrc(uri2); // Set the new Img Src } } else if(aContextFlags & nsIContextMenuListener2::CONTEXT_TEXT) @@ -373,7 +375,7 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, // BrowserView will be invoked and the value of the URL // will be accesible in the view - nsAutoString strUrlUcs2; + nsEmbedString strUrlUcs2; nsresult rv = aInfo->GetAssociatedLink(strUrlUcs2); if(NS_FAILED(rv)) return; @@ -387,12 +389,14 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, aInfo->GetImageSrc(getter_AddRefs(imgURI)); if(imgURI) { - nsCAutoString strImgSrcUtf8; + nsEmbedCString strImgSrcUtf8; imgURI->GetSpec(strImgSrcUtf8); - if(!strImgSrcUtf8.IsEmpty()) + if(strImgSrcUtf8.Length() != 0) { // Set the new Img Src - pThis->m_wndBrowserView.SetCtxMenuImageSrc(NS_ConvertUTF8toUCS2(strImgSrcUtf8)); + nsEmbedString strImgSrc; + NS_CStringToUTF16(strImgSrcUtf8, NS_CSTRING_ENCODING_UTF8, strImgSrc); + pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrc); } } } @@ -405,13 +409,15 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, aInfo->GetImageSrc(getter_AddRefs(imgURI)); if(!imgURI) return; - nsCAutoString strImgSrcUtf8; + nsEmbedCString strImgSrcUtf8; imgURI->GetSpec(strImgSrcUtf8); - if(strImgSrcUtf8.IsEmpty()) + if(strImgSrcUtf8.Length() == 0) return; // Set the new Img Src - pThis->m_wndBrowserView.SetCtxMenuImageSrc(NS_ConvertUTF8toUCS2(strImgSrcUtf8)); + nsEmbedString strImgSrc; + NS_CStringToUTF16(strImgSrcUtf8, NS_CSTRING_ENCODING_UTF8, strImgSrc); + pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrc); } // Determine if we need to add the Frame related context menu items @@ -438,7 +444,7 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, if(NS_FAILED(rv)) GOTO_BUILD_CTX_MENU; - nsAutoString strFrameURL; + nsEmbedString strFrameURL; rv = htmlDoc->GetURL(strFrameURL); if(NS_FAILED(rv)) GOTO_BUILD_CTX_MENU; diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.cpp b/mozilla/embedding/tests/mfcembed/BrowserView.cpp index 37e232a2927..c59e2a0777d 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserView.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserView.cpp @@ -63,7 +63,117 @@ #include "CPageSetupPropSheet.h" // Mozilla Includes +#include "nsIIOService.h" #include "nsIWidget.h" +#include "nsIServiceManagerUtils.h" +#include "nsComponentManagerUtils.h" +#include "nsMemory.h" +#include "nsXPCOM.h" + +static nsresult +NewURI(nsIURI **result, const nsAString &spec) +{ + nsEmbedCString specUtf8; + NS_UTF16ToCString(spec, NS_CSTRING_ENCODING_UTF8, specUtf8); + + nsCOMPtr ios = do_GetService("@mozilla.org/network/io-service;1"); + NS_ENSURE_TRUE(ios, NS_ERROR_UNEXPECTED); + + return ios->NewURI(specUtf8, nsnull, nsnull, result); +} + +static void +ReplaceChar(nsAString &str, char oldChar, char newChar) +{ + // XXX this could be much more efficient + + PRUnichar *data = NS_StringCloneData(str); + for (; *data; ++data) + { + if ((char ) *data == oldChar) + *data = (PRUnichar) newChar; + } + NS_StringSetData(str, data); + nsMemory::Free(data); +} + +static void +StripChars(nsAString &str, const char *chars) +{ + // XXX this could be much more efficient + + PRUint32 len = str.Length(); + + PRUnichar *data = NS_StringCloneData(str); + PRUnichar *dataEnd = data + len; + for (; *data; ++data) + { + if (strchr(chars, (char ) *data)) + { + // include trailing null terminator in the memmove + memmove(data, data + 1, (dataEnd - data) * sizeof(PRUnichar)); + --dataEnd; + } + } + NS_StringSetData(str, data); + nsMemory::Free(data); +} + +static void +StripChars(nsACString &str, const char *chars) +{ + // XXX this could be much more efficient + + PRUint32 len = str.Length(); + + char *data = NS_CStringCloneData(str); + char *dataEnd = data + len; + for (; *data; ++data) + { + if (strchr(chars, *data)) + { + // include trailing null terminator in the memmove + memmove(data, data + 1, dataEnd - data); + --dataEnd; + } + } + NS_CStringSetData(str, data); + nsMemory::Free(data); +} + +static const char* kWhitespace="\b\t\r\n "; + +static void +CompressWhitespace(nsAString &str) +{ + const PRUnichar *p; + PRInt32 i, len = (PRInt32) NS_StringGetData(str, &p); + + // trim leading whitespace + + for (i=0; i0) + { + NS_StringCutData(str, 0, i); + len = (PRInt32) NS_StringGetData(str, &p); + } + + // trim trailing whitespace + + for (i=len-1; i>=0; --i) + { + if (!strchr(kWhitespace, (char) p[i])) + break; + } + + if (++i < len) + NS_StringCutData(str, i, len - i); +} #ifdef _DEBUG #define new DEBUG_NEW @@ -355,7 +465,9 @@ BOOL CBrowserView::IsViewSourceUrl(CString& strUrl) BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl) { - return OpenViewSourceWindow(NS_ConvertASCIItoUCS2(pUrl).get()); + nsEmbedString str; + NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_ASCII, str); + return OpenViewSourceWindow(str.get()); } BOOL CBrowserView::OpenViewSourceWindow(const PRUnichar* pUrl) @@ -391,14 +503,14 @@ void CBrowserView::OnViewSource() return; // Get the uri string associated with the nsIURI object - nsCAutoString uriString; + nsEmbedCString uriString; rv = currentURI->GetSpec(uriString); if(NS_FAILED(rv)) return; // Build the view-source: url - nsAutoString viewSrcUrl(L"view-source:"); - viewSrcUrl.AppendWithConversion(uriString.get()); + nsEmbedCString viewSrcUrl("view-source:"); + viewSrcUrl.Append(uriString); OpenViewSourceWindow(viewSrcUrl.get()); } @@ -626,26 +738,27 @@ void CBrowserView::OnFileOpen() void CBrowserView::GetBrowserWindowTitle(nsAString& title) { - nsXPIDLString idlStrTitle; + PRUnichar *idlStrTitle = nsnull; if(mBaseWindow) - mBaseWindow->GetTitle(getter_Copies(idlStrTitle)); + mBaseWindow->GetTitle(&idlStrTitle); title = idlStrTitle; + nsMemory::Free(idlStrTitle); } void CBrowserView::OnFileSaveAs() { - nsAutoString fileName; + nsEmbedString fileName; GetBrowserWindowTitle(fileName); // Suggest the window title as the filename // Sanitize the file name of all illegal characters USES_CONVERSION; - fileName.CompressWhitespace(); // Remove whitespace from the ends - fileName.StripChars("\\*|:\"> persist(do_QueryInterface(mWebBrowser)); if(persist) { - nsCAutoString fullPath(T2CA(pStrFullPath)); + nsEmbedCString fullPath(T2CA(pStrFullPath)); nsCOMPtr file; NS_NewNativeLocalFile(fullPath, TRUE, getter_AddRefs(file)); nsCOMPtr data; if (pStrDataPath) { - nsCAutoString dataPath(T2CA(pStrDataPath)); + nsEmbedCString dataPath(T2CA(pStrDataPath)); NS_NewNativeLocalFile(dataPath, TRUE, getter_AddRefs(data)); } @@ -709,7 +822,9 @@ void CBrowserView::OnFileSaveAs() void CBrowserView::OpenURL(const char* pUrl) { - OpenURL(NS_ConvertASCIItoUCS2(pUrl).get()); + nsEmbedString str; + NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_ASCII, str); + OpenURL(str.get()); } void CBrowserView::OpenURL(const PRUnichar* pUrl) @@ -765,7 +880,9 @@ void CBrowserView::OnCopyLinkLocation() if (! OpenClipboard()) return; - HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, mCtxMenuLinkUrl.Length() + 1); + PRUint32 size = mCtxMenuLinkUrl.Length() + 1; + + HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); if(! hClipData) return; @@ -773,7 +890,7 @@ void CBrowserView::OnCopyLinkLocation() if(!pszClipData) return; - mCtxMenuLinkUrl.ToCString(pszClipData, mCtxMenuLinkUrl.Length() + 1); + memcpy(pszClipData, mCtxMenuLinkUrl.get(), size); GlobalUnlock(hClipData); @@ -811,17 +928,17 @@ void CBrowserView::OnSaveLinkAs() // use it while saving this link to a file nsresult rv = NS_OK; nsCOMPtr linkURI; - rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl); + rv = NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl); if (NS_FAILED(rv)) return; // Get the "path" portion (see nsIURI.h for more info // on various parts of a URI) - nsCAutoString fileName; + nsEmbedCString fileName; linkURI->GetPath(fileName); // The path may have the "/" char in it - strip those - fileName.StripChars("\\/"); + StripChars(fileName, "\\/"); // Now, use this file name in a File Save As dlg... @@ -837,7 +954,7 @@ void CBrowserView::OnSaveLinkAs() if(cf.DoModal() == IDOK) { USES_CONVERSION; - nsCAutoString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); + nsEmbedCString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); nsCOMPtr persist(do_QueryInterface(mWebBrowser)); if(persist) { @@ -860,18 +977,18 @@ void CBrowserView::OnSaveImageAs() // use it while saving this link to a file nsresult rv = NS_OK; nsCOMPtr linkURI; - rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc); + rv = NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc); if (NS_FAILED(rv)) return; // Get the "path" portion (see nsIURI.h for more info // on various parts of a URI) - nsCAutoString path; + nsEmbedCString path; linkURI->GetPath(path); // The path may have the "/" char in it - strip those - nsCAutoString fileName(path); - fileName.StripChars("\\/"); + nsEmbedCString fileName(path); + StripChars(fileName, "\\/"); // Now, use this file name in a File Save As dlg... @@ -883,7 +1000,7 @@ void CBrowserView::OnSaveImageAs() if(cf.DoModal() == IDOK) { USES_CONVERSION; - nsCAutoString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); + nsEmbedCString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); nsCOMPtr persist(do_QueryInterface(mWebBrowser)); if(persist) @@ -918,9 +1035,10 @@ void CBrowserView::OnShowFindDlg() nsCOMPtr finder(do_GetInterface(mWebBrowser)); if(finder) { - nsXPIDLString stringBuf; - finder->GetSearchString(getter_Copies(stringBuf)); - csSearchStr = stringBuf.get(); + PRUnichar *stringBuf = nsnull; + finder->GetSearchString(&stringBuf); + csSearchStr = stringBuf; + nsMemory::Free(stringBuf); finder->GetMatchCase(&bMatchCase); finder->GetEntireWord(&bMatchWholeWord); @@ -1113,17 +1231,17 @@ void CBrowserView::UpdateBusyState(PRBool aBusy) mbDocumentLoading = aBusy; } -void CBrowserView::SetCtxMenuLinkUrl(nsAutoString& strLinkUrl) +void CBrowserView::SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl) { mCtxMenuLinkUrl = strLinkUrl; } -void CBrowserView::SetCtxMenuImageSrc(nsAutoString& strImgSrc) +void CBrowserView::SetCtxMenuImageSrc(nsEmbedString& strImgSrc) { mCtxMenuImgSrc = strImgSrc; } -void CBrowserView::SetCurrentFrameURL(nsAutoString& strCurrentFrameURL) +void CBrowserView::SetCurrentFrameURL(nsEmbedString& strCurrentFrameURL) { mCtxMenuCurrentFrameURL = strCurrentFrameURL; } @@ -1198,7 +1316,7 @@ void CBrowserView::OnViewFrameSource() { // Build the view-source: url // - nsAutoString viewSrcUrl; + nsEmbedString viewSrcUrl; viewSrcUrl.Append(L"view-source:"); viewSrcUrl.Append(mCtxMenuCurrentFrameURL); diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.h b/mozilla/embedding/tests/mfcembed/BrowserView.h index 48df52abe75..03bfd6d203b 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserView.h +++ b/mozilla/embedding/tests/mfcembed/BrowserView.h @@ -97,14 +97,14 @@ public: void UpdateBusyState(PRBool aBusy); PRBool mbDocumentLoading; - void SetCtxMenuLinkUrl(nsAutoString& strLinkUrl); - nsAutoString mCtxMenuLinkUrl; + void SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl); + nsEmbedString mCtxMenuLinkUrl; - void SetCtxMenuImageSrc(nsAutoString& strImgSrc); - nsAutoString mCtxMenuImgSrc; + void SetCtxMenuImageSrc(nsEmbedString& strImgSrc); + nsEmbedString mCtxMenuImgSrc; - void SetCurrentFrameURL(nsAutoString& strCurrentFrameURL); - nsString mCtxMenuCurrentFrameURL; + void SetCurrentFrameURL(nsEmbedString& strCurrentFrameURL); + nsEmbedString mCtxMenuCurrentFrameURL; inline void ClearFindDialog() { m_pFindDlg = NULL; } CFindDialog* m_pFindDlg; @@ -202,4 +202,4 @@ protected: DECLARE_MESSAGE_MAP() }; -#endif //_BROWSERVIEW_H \ No newline at end of file +#endif //_BROWSERVIEW_H diff --git a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp b/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp index 9ccf72bbdfa..684d90cc13c 100644 --- a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp +++ b/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp @@ -35,6 +35,7 @@ #include "stdafx.h" #include "resource.h" #include "CPageSetupPropSheet.h" +#include "nsMemory.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -100,11 +101,12 @@ static float GetFloatFromStr(const TCHAR * aStr, float aMaxVal = 1.0) static PRUnichar* GetUnicodeFromCString(const CString& aStr) { #ifdef _UNICODE - nsString str(aStr); + nsEmbedString str(aStr); #else - nsString str; str.AssignWithConversion(aStr); + nsEmbedString str; + NS_CStringToUTF16(nsEmbedCString(aStr), NS_CSTRING_ENCODING_ASCII, str); #endif - return ToNewUnicode(str); + return NS_StringCloneData(str); } ///////////////////////////////////////////////////////////////////////////// @@ -146,27 +148,27 @@ void CPageSetupPropSheet::SetPrintSettingsValues(nsIPrintSettings* aPrintSetting PRUnichar* uStr; aPrintSettings->GetHeaderStrLeft(&uStr); - m_MarginHeaderFooterTab.m_HeaderLeftText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_HeaderLeftText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); aPrintSettings->GetHeaderStrCenter(&uStr); - m_MarginHeaderFooterTab.m_HeaderCenterText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_HeaderCenterText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); aPrintSettings->GetHeaderStrRight(&uStr); - m_MarginHeaderFooterTab.m_HeaderRightText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_HeaderRightText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); aPrintSettings->GetFooterStrLeft(&uStr); - m_MarginHeaderFooterTab.m_FooterLeftText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_FooterLeftText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); aPrintSettings->GetFooterStrCenter(&uStr); - m_MarginHeaderFooterTab.m_FooterCenterText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_FooterCenterText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); aPrintSettings->GetFooterStrRight(&uStr); - m_MarginHeaderFooterTab.m_FooterRightText = NS_LossyConvertUCS2toASCII(uStr).get(); + m_MarginHeaderFooterTab.m_FooterRightText = uStr; if (uStr != nsnull) nsMemory::Free(uStr); } } diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp b/mozilla/embedding/tests/mfcembed/EditorFrm.cpp index 4f7939a51f1..5561173d836 100644 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp +++ b/mozilla/embedding/tests/mfcembed/EditorFrm.cpp @@ -35,6 +35,10 @@ #include "BrowserFrm.h" #include "EditorFrm.h" #include "Dialogs.h" +#include "nsComponentManagerUtils.h" +#include "nsMemory.h" +#include "nsIEditor.h" +#include "nsIHTMLEditor.h" //------------------------------------------------------------ // Editor Command/Parameter Names @@ -325,7 +329,7 @@ CEditorFrame::ExecuteAttribParam(const char *aCommand, const char *aAttribute) } NS_METHOD -CEditorFrame::GetAttributeParamValue(const char *aCommand, nsCString &aValue) +CEditorFrame::GetAttributeParamValue(const char *aCommand, nsEmbedCString &aValue) { nsresult rv; nsCOMPtr params; @@ -339,7 +343,8 @@ CEditorFrame::GetAttributeParamValue(const char *aCommand, nsCString &aValue) { char *tchar; rv = params->GetCStringValue(STATE_ATTRIBUTE,&tchar); - aValue.Adopt(tchar); + aValue.Assign(tchar); + nsMemory::Free(tchar); return rv; } return rv; @@ -419,12 +424,12 @@ void CEditorFrame::OnAlignleft() void CEditorFrame::OnUpdateAlignleft(CCmdUI* pCmdUI) { - nsCAutoString tValue; + nsEmbedCString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); if (NS_SUCCEEDED(rv)) { - if (tValue.Equals(ALIGN_LEFT)) + if (strcmp(tValue.get(), ALIGN_LEFT) == 0) pCmdUI->SetCheck(1); else pCmdUI->SetCheck(0); @@ -438,11 +443,11 @@ void CEditorFrame::OnAlignright() void CEditorFrame::OnUpdateAlignright(CCmdUI* pCmdUI) { - nsCAutoString tValue; + nsEmbedCString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); if (NS_SUCCEEDED(rv)) { - if (tValue.Equals(ALIGN_RIGHT)) + if (strcmp(tValue.get(), ALIGN_RIGHT) == 0) pCmdUI->SetCheck(1); else pCmdUI->SetCheck(0); @@ -456,11 +461,11 @@ void CEditorFrame::OnAligncenter() void CEditorFrame::OnUpdateAligncenter(CCmdUI* pCmdUI) { - nsCAutoString tValue; + nsEmbedCString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); if (NS_SUCCEEDED(rv)) { - if (tValue.Equals(ALIGN_CENTER)) + if (strcmp(tValue.get(), ALIGN_CENTER) == 0) pCmdUI->SetCheck(1); else pCmdUI->SetCheck(0); @@ -494,11 +499,13 @@ void CEditorFrame::InsertLink(CString& linkText, CString& linkLocation) void CEditorFrame::InsertHTML(CString& str) { - nsString htmlToInsert; + nsEmbedString htmlToInsert; #ifdef _UNICODE htmlToInsert.Assign(str.GetBuffer(0)); #else - htmlToInsert.AssignWithConversion(str.GetBuffer(0)); + NS_CStringToUTF16(nsEmbedCString(str.GetBuffer(0)), + NS_CSTRING_ENCODING_ASCII, + htmlToInsert); #endif nsCOMPtr htmlEditor; @@ -539,13 +546,13 @@ BOOL CEditorFrame::GetCurrentLinkInfo(CString& strLinkText, CString& strLinkLoca return FALSE; nsCOMPtr domElement; - htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"), + htmlEditor->GetElementOrParentByTagName(nsEmbedString(L"href"), nsnull, getter_AddRefs(domElement)); if (!domElement) return FALSE; - nsAutoString linkLocation, linkText; + nsEmbedString linkLocation, linkText; nsresult rv = NS_ERROR_FAILURE; // Determine linkLocation @@ -657,7 +664,7 @@ BOOL CEditorFrame::InLink() if (htmlEditor) { nsCOMPtr domElememt; - htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"), + htmlEditor->GetElementOrParentByTagName(nsEmbedString(L"href"), nsnull, getter_AddRefs(domElememt)); return domElememt ? TRUE : FALSE; diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.h b/mozilla/embedding/tests/mfcembed/EditorFrm.h index 0278a3bde53..af39f8f1e13 100644 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.h +++ b/mozilla/embedding/tests/mfcembed/EditorFrm.h @@ -33,13 +33,12 @@ #ifndef _EDITORFRM_H_ #define _EDITORFRM_H_ -#include "nsICommandParams.h" +class nsICommandParams; +class nsIEditor; +class nsIHTMLEditor; + #include "nsIEditingSession.h" #include "nsICommandManager.h" -#include "nsIScriptGlobalObject.h" -#include "nsISimpleEnumerator.h" -#include "nsIEditor.h" -#include "nsIHTMLEditor.h" class CEditorFrame : public CBrowserFrame { @@ -112,7 +111,7 @@ private: NS_METHOD ExecuteNoParam(const char *aCommand); NS_METHOD MakeCommandParams(const char *aCommand,nsICommandParams **aParams); NS_METHOD ExecuteAttribParam(const char *aCommand, const char *aAttribute); - NS_METHOD GetAttributeParamValue(const char *aCommand, nsCString &aValue); + NS_METHOD GetAttributeParamValue(const char *aCommand, nsEmbedCString &aValue); void UpdateStyleToolBarBtn(const char *aCommand, CCmdUI* pCmdUI); diff --git a/mozilla/embedding/tests/mfcembed/Makefile.in b/mozilla/embedding/tests/mfcembed/Makefile.in index d3619447183..e3c50157e55 100644 --- a/mozilla/embedding/tests/mfcembed/Makefile.in +++ b/mozilla/embedding/tests/mfcembed/Makefile.in @@ -47,7 +47,7 @@ GRE_BUILD = 1 endif ifdef GRE_BUILD -DEFINES += -DXPCOM_GLUE +DEFINES += -DXPCOM_GLUE -DMOZILLA_STRICT_API endif REQUIRES = \ @@ -109,7 +109,7 @@ CPPSRCS = \ StdAfx.cpp \ $(NULL) -EXTRA_DSO_LIBS = embed_base_s profdirserviceprovider_s +EXTRA_DSO_LIBS = embed_base_s profdirserviceprovidersa_s ifdef NS_TRACE_MALLOC EXTRA_DSO_LIBS += tracemalloc @@ -123,7 +123,6 @@ LIBS = \ ifdef GRE_BUILD LIBS += \ $(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \ - $(DIST)/lib/$(LIB_PREFIX)string_s.$(LIB_SUFFIX) \ $(NULL) else LIBS += $(XPCOM_LIBS) diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp index 3ce41e9c9c3..f83d0ae181b 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp @@ -47,8 +47,12 @@ // Local Includes #include "stdafx.h" #include "MfcEmbed.h" +#include "nsXPCOM.h" #include "nsXPCOMGlue.h" +#include "nsMemory.h" #include "nsIComponentRegistrar.h" +#include "nsIFactory.h" +#include "nsIServiceManagerUtils.h" #include "BrowserFrm.h" #include "EditorFrm.h" #include "winEmbedFileLocProvider.h" @@ -127,7 +131,7 @@ public: szParam++; // previous argument was a flag too, so process that first - if (!mLastFlag.IsEmpty()) + if (mLastFlag.Length() != 0) HandleFlag(mLastFlag); mLastFlag = szParam; @@ -137,10 +141,10 @@ public: HandleFlag(mLastFlag); } else { - if (!mLastFlag.IsEmpty()) + if (mLastFlag.Length() != 0) HandleFlag(mLastFlag, szParam); - mLastFlag.Truncate(); + mLastFlag.Cut(0, PR_UINT32_MAX); } } @@ -151,12 +155,12 @@ public: void HandleFlag(const nsACString& flag, const TCHAR * param = nsnull) #endif { - if (flag.Equals(_T("console"))) + if (_tcscmp(flag.BeginReading(), _T("console")) == 0) DoConsole(); - else if (flag.Equals(_T("chrome"))) + else if (_tcscmp(flag.BeginReading(), _T("chrome")) == 0) DoChrome(); #ifdef NS_TRACE_MALLOC - else if (flag.Equals(_T("trace-malloc"))) + else if (_tcscmp(flag.BeginReading(), _T("trace-malloc")) == 0) { USES_CONVERSION; DoTraceMalloc(flag, T2CA(param)); @@ -197,9 +201,9 @@ public: private: // autostring is fine, this is a stack based object anyway #ifdef _UNICODE - nsAutoString mLastFlag; + nsEmbedString mLastFlag; #else - nsCAutoString mLastFlag; + nsEmbedCString mLastFlag; #endif CMfcEmbedApp& mApp; @@ -383,11 +387,6 @@ BOOL CMfcEmbedApp::InitInstance() NSGetStaticModuleInfo = app_getModuleInfo; #endif - CMfcEmbedCommandLine cmdLine(*this); - ParseCommandLine(cmdLine); - - Enable3dControls(); - #ifdef XPCOM_GLUE if (NS_FAILED(XPCOMGlueStartup(GRE_GetXPCOMPath()))) { MessageBox(NULL, "Could not initialize XPCOM. Perhaps the GRE\nis not installed or could not be found?", "MFCEmbed", MB_OK | MB_ICONERROR); @@ -395,6 +394,11 @@ BOOL CMfcEmbedApp::InitInstance() } #endif + CMfcEmbedCommandLine cmdLine(*this); + ParseCommandLine(cmdLine); + + Enable3dControls(); + // // 1. Determine the name of the dir from which the GRE based app is being run // from [It's OK to do this even if you're not running in an GRE env] @@ -416,7 +420,7 @@ BOOL CMfcEmbedApp::InitInstance() USES_CONVERSION; nsresult rv; nsCOMPtr mreAppDir; - rv = NS_NewNativeLocalFile(nsDependentCString(T2A(path)), TRUE, getter_AddRefs(mreAppDir)); + rv = NS_NewNativeLocalFile(nsEmbedCString(T2A(path)), TRUE, getter_AddRefs(mreAppDir)); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create mreAppDir localfile"); // Take a look at @@ -425,7 +429,7 @@ BOOL CMfcEmbedApp::InitInstance() CString strRes; strRes.LoadString(IDS_PROFILES_FOLDER_NAME); - winEmbedFileLocProvider *provider = new winEmbedFileLocProvider(nsDependentCString(strRes)); + winEmbedFileLocProvider *provider = new winEmbedFileLocProvider(nsEmbedCString(strRes)); if(!provider) { ASSERT(FALSE); @@ -665,7 +669,7 @@ BOOL CMfcEmbedApp::InitializeProfiles() USES_CONVERSION; CString strRes; strRes.LoadString(IDS_PROFILES_NONSHARED_NAME); - nsDependentString nonSharedName(T2W(strRes)); + nsEmbedString nonSharedName(T2W(strRes)); sharingSetup->EnableSharing(nonSharedName); } #endif @@ -760,17 +764,18 @@ nsresult CMfcEmbedApp::InitializePrefs() prefs->GetIntPref("browser.startup.page", &m_iStartupPage); - nsXPIDLCString str; - prefs->GetCharPref("browser.startup.homepage", getter_Copies(str)); - if (!str.IsEmpty()) + char* str = nsnull; + prefs->GetCharPref("browser.startup.homepage", &str); + if (str) { USES_CONVERSION; - m_strHomePage = A2CT(str.get()); + m_strHomePage = A2CT(str); } else { m_strHomePage.Empty(); } + nsMemory::Free(str); } } else @@ -856,7 +861,7 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, c // Only make a new browser window on a switch. This also gets // called at start up and we already make a window then. - if (!wcscmp(someData, NS_LITERAL_STRING("switch").get())) + if (!wcscmp(someData, L"switch")) OnNewBrowser(); } return rv; diff --git a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp b/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp index d4fe2e9cc15..55a10d986d6 100644 --- a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp +++ b/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp @@ -41,7 +41,9 @@ #include "StdAfx.h" #include "nsIFile.h" #include "nsILocalFile.h" +#include "nsIServiceManagerUtils.h" #include "nsAppDirectoryServiceDefs.h" +#include "nsDirectoryServiceUtils.h" #include "MostRecentUrls.h" //-------------------------------------------------------- @@ -75,7 +77,7 @@ FILE * CMostRecentUrls::GetFD(const char * aMode) nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file)); if (NS_SUCCEEDED(rv)) { nsCOMPtr local_file(do_QueryInterface(file)); - local_file->AppendNative(NS_LITERAL_CSTRING("urls.txt")); + local_file->AppendNative(nsEmbedCString("urls.txt")); local_file->OpenANSIFileDesc(aMode, &fd); } diff --git a/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp b/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp index 14c05492897..656cec56b9a 100644 --- a/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp +++ b/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp @@ -35,13 +35,16 @@ #include "ProfilesDlg.h" // Mozilla Includes -#include "nsString.h" -#include "nsXPIDLString.h" +#include "nsEmbedString.h" #include "nsIRegistry.h" #include "nsIProfile.h" +#include "nsIServiceManagerUtils.h" +#include "nsComponentManagerUtils.h" +#include "nsCOMPtr.h" +#include "nsMemory.h" // Constants -#define kRegistryGlobalPrefsSubtreeString (NS_LITERAL_STRING("global-prefs")) +#define kRegistryGlobalPrefsSubtreeString (nsEmbedString(L"global-prefs")) #define kRegistryShowProfilesAtStartup "start-show-dialog" //***************************************************************************** @@ -75,7 +78,7 @@ nsresult CProfileMgr::StartUp() if (profileCount == 0) { // Make a new default profile - NS_NAMED_LITERAL_STRING(newProfileName, "default"); + nsEmbedString newProfileName(L"default"); rv = profileService->CreateNewProfile(newProfileName.get(), nsnull, nsnull, PR_FALSE); if (NS_FAILED(rv)) return rv; @@ -99,10 +102,11 @@ nsresult CProfileMgr::StartUp() // GetCurrentProfile returns the profile which was last used but is not nescesarily // active. Call SetCurrentProfile to make it installed and active. - nsXPIDLString currProfileName; - rv = profileService->GetCurrentProfile(getter_Copies(currProfileName)); + PRUnichar *currProfileName = nsnull; + rv = profileService->GetCurrentProfile(&currProfileName); if (NS_FAILED(rv)) return rv; rv = profileService->SetCurrentProfile(currProfileName); + nsMemory::Free(currProfileName); if (NS_FAILED(rv)) return rv; } } diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp index 24103c967a7..be8b22c54f8 100644 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp +++ b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp @@ -38,6 +38,8 @@ // Mozilla #include "nsIProfile.h" #include "nsIServiceManager.h" +#include "nsIServiceManagerUtils.h" +#include "nsMemory.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -208,14 +210,13 @@ BOOL CProfilesDlg::OnInitDialog() CDialog::OnInitDialog(); - nsCAutoString cStr; - nsXPIDLString curProfileName; + PRUnichar *curProfileName = nsnull; // Fill the list of profiles nsresult rv; nsCOMPtr profileService = do_GetService(NS_PROFILE_CONTRACTID, &rv); - profileService->GetCurrentProfile(getter_Copies(curProfileName)); + profileService->GetCurrentProfile(&curProfileName); PRInt32 selectedRow = 0; PRUint32 listLen; @@ -226,9 +227,10 @@ BOOL CProfilesDlg::OnInitDialog() { CString tmpStr(W2T(profileList[index])); m_ProfileList.AddString(tmpStr); - if (wcscmp(profileList[index], curProfileName.get()) == 0) + if (wcscmp(profileList[index], curProfileName) == 0) selectedRow = index; } + nsMemory::Free(curProfileName); m_ProfileList.SetCurSel(selectedRow); diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h b/mozilla/embedding/tests/mfcembed/ProfilesDlg.h index 5118711c54b..a4fe6fe0547 100644 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h +++ b/mozilla/embedding/tests/mfcembed/ProfilesDlg.h @@ -121,7 +121,7 @@ public: BOOL m_bAskAtStartUp; //}}AFX_DATA - nsAutoString m_SelectedProfile; + nsEmbedString m_SelectedProfile; // Overrides // ClassWizard generated virtual function overrides diff --git a/mozilla/embedding/tests/mfcembed/StdAfx.h b/mozilla/embedding/tests/mfcembed/StdAfx.h index 343625c9af6..180902f8820 100644 --- a/mozilla/embedding/tests/mfcembed/StdAfx.h +++ b/mozilla/embedding/tests/mfcembed/StdAfx.h @@ -72,11 +72,8 @@ #endif #include "nsCOMPtr.h" -#include "nsNetUtil.h" -#include "nsString.h" -#include "nsVoidArray.h" +#include "nsEmbedString.h" #include "nsCWebBrowser.h" -#include "nsXPIDLString.h" #include "nsWidgetsCID.h" #include "nsIDocShell.h" #include "nsIWebBrowser.h" @@ -100,7 +97,6 @@ #include "nsIDOMDocument.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLFrameSetElement.h" -#include "nsReadableUtils.h" #include "nsIPrompt.h" #include "nsEmbedAPI.h" #include "nsISHistory.h" diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp index 20f428fb091..55af558f72c 100644 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp +++ b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp @@ -31,13 +31,13 @@ * ***** END LICENSE BLOCK ***** */ #include "winEmbedFileLocProvider.h" +#include "nsXPCOM.h" #include "nsXPCOMGlue.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsILocalFile.h" -#include "nsString.h" -#include "nsXPIDLString.h" - +#include "nsIProperties.h" +#include "nsIServiceManagerUtils.h" #include #include @@ -45,17 +45,17 @@ // WARNING: These hard coded names need to go away. They need to // come from localizable resources -#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat") +#define APP_REGISTRY_NAME nsEmbedCString("registry.dat") -#define PROFILE_ROOT_DIR_NAME NS_LITERAL_CSTRING("Profiles") -#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults") -#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref") -#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("profile") -#define RES_DIR_NAME NS_LITERAL_CSTRING("res") -#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome") -#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins") -#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins") -#define COMPONENTS_DIR_NAME NS_LITERAL_CSTRING("components") +#define PROFILE_ROOT_DIR_NAME nsEmbedCString("Profiles") +#define DEFAULTS_DIR_NAME nsEmbedCString("defaults") +#define DEFAULTS_PREF_DIR_NAME nsEmbedCString("pref") +#define DEFAULTS_PROFILE_DIR_NAME nsEmbedCString("profile") +#define RES_DIR_NAME nsEmbedCString("res") +#define CHROME_DIR_NAME nsEmbedCString("chrome") +#define PLUGINS_DIR_NAME nsEmbedCString("plugins") +#define SEARCH_DIR_NAME nsEmbedCString("searchplugins") +#define COMPONENTS_DIR_NAME nsEmbedCString("components") //***************************************************************************** // winEmbedFileLocProvider::Constructor/Destructor diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h index 89bb6a62601..737ee63a8ef 100644 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h +++ b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h @@ -31,9 +31,10 @@ #include "nsIDirectoryService.h" #include "nsILocalFile.h" -#include "nsString.h" +#include "nsEmbedString.h" +#include "nsCOMPtr.h" -class nsIFile; +class nsILocalFile; //***************************************************************************** // class winEmbedFileLocProvider @@ -57,6 +58,6 @@ protected: NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile); - nsCString mProductDirName; + nsEmbedCString mProductDirName; nsCOMPtr mMozBinDirectory; }; diff --git a/mozilla/mail/config/basemail-os2 b/mozilla/mail/config/basemail-os2 index 0ecc86bce2a..e452d22c4bf 100644 --- a/mozilla/mail/config/basemail-os2 +++ b/mozilla/mail/config/basemail-os2 @@ -121,6 +121,7 @@ components\jsurl.xpt ; XPCOM: xpcom.dll +xpcomcor.dll xpcomct.dll xpistub.dll xpicleanup.exe diff --git a/mozilla/mail/config/basemail-unix b/mozilla/mail/config/basemail-unix index 5d6bcbf73e4..07281db6734 100644 --- a/mozilla/mail/config/basemail-unix +++ b/mozilla/mail/config/basemail-unix @@ -137,6 +137,7 @@ libmozjs.so ; XPCOM: ; libxpcom.so +libxpcom_core.so libxpistub.so libxpcom_compat.so components/xpcom_base.xpt diff --git a/mozilla/mail/installer/windows/basemail-win b/mozilla/mail/installer/windows/basemail-win index 546c13e28bb..5ce945f1b5c 100644 --- a/mozilla/mail/installer/windows/basemail-win +++ b/mozilla/mail/installer/windows/basemail-win @@ -20,6 +20,7 @@ bin\defaults\profile\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}\install.r [xpcom] bin\xpcom.dll +bin\xpcom_core.dll bin\xpcom_compat.dll bin\xpistub.dll bin\components\jar50.dll diff --git a/mozilla/widget/public/nsILookAndFeel.h b/mozilla/widget/public/nsILookAndFeel.h index 0ac0b590f49..0737febdd7b 100644 --- a/mozilla/widget/public/nsILookAndFeel.h +++ b/mozilla/widget/public/nsILookAndFeel.h @@ -39,7 +39,6 @@ #define __nsILookAndFeel #include "nsISupports.h" #include "nsColor.h" -#include "nsFont.h" // for |#ifdef NS_DEBUG| struct nsSize; diff --git a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp index 7dda088d036..f9a9ac34df3 100644 --- a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -43,6 +43,7 @@ static int PR_CALLBACK colorPrefChanged(const char* aPref, void* aData); #include "nsIServiceManager.h" #include "nsIPref.h" #include "nsCRT.h" +#include "nsFont.h" #ifdef DEBUG #include "nsSize.h" diff --git a/mozilla/xpcom/Makefile.in b/mozilla/xpcom/Makefile.in index 8bfe9abe399..70d040793d4 100644 --- a/mozilla/xpcom/Makefile.in +++ b/mozilla/xpcom/Makefile.in @@ -58,6 +58,7 @@ DIRS = \ reflect \ proxy \ build \ + stub \ tools \ $(NULL) diff --git a/mozilla/xpcom/base/nsISupports.idl b/mozilla/xpcom/base/nsISupports.idl index 6bf08ac4af7..b1127b4ce53 100644 --- a/mozilla/xpcom/base/nsISupports.idl +++ b/mozilla/xpcom/base/nsISupports.idl @@ -73,8 +73,5 @@ interface nsISupports { %{C++ #include "nsISupportsBase.h" - -#ifndef MOZILLA_STRICT_API #include "nsISupportsUtils.h" -#endif %} diff --git a/mozilla/xpcom/build/Makefile.in b/mozilla/xpcom/build/Makefile.in index 5c2386ce9a7..a22f84bf5fc 100644 --- a/mozilla/xpcom/build/Makefile.in +++ b/mozilla/xpcom/build/Makefile.in @@ -43,7 +43,10 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk MODULE = xpcom -LIBRARY_NAME = xpcom +LIBRARY_NAME = xpcom_core +ifneq ($(OS_ARCH),WINNT) +SHORT_LIBNAME = xpcomcor +endif PACKAGE_FILE = xpcom.pkg PACKAGE_VARS += USE_SHORT_LIBNAME @@ -64,9 +67,7 @@ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) REQUIRES += macmorefiles endif -CPPSRCS = nsXPComInit.cpp \ - nsStringAPI.cpp \ - $(NULL) +CPPSRCS = nsXPComInit.cpp ifeq ($(OS_ARCH),WINNT) CPPSRCS += dlldeps.cpp @@ -116,9 +117,6 @@ SDK_HEADERS = \ nsXPCOMCID.h \ $(NULL) -SDK_LIBRARY = $(IMPORT_LIBRARY) -SDK_BINARY = $(SHARED_LIBRARY) - # pull in MoreFiles for MacOSX ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) EXTRA_DSO_LIBS = macmorefiles_s diff --git a/mozilla/xpcom/build/dlldeps.cpp b/mozilla/xpcom/build/dlldeps.cpp index 5fc311897f8..49813cb5470 100644 --- a/mozilla/xpcom/build/dlldeps.cpp +++ b/mozilla/xpcom/build/dlldeps.cpp @@ -88,9 +88,7 @@ #include "nsVariant.h" #include "nsEscape.h" #include "nsStreamUtils.h" - -#define NS_STRINGAPI_IMPL -#include "nsStringAPI.h" +#include "nsNativeCharsetUtils.h" void XXXNeverCalled() { @@ -175,20 +173,6 @@ void XXXNeverCalled() NS_NewUTF8StringEnumerator(nsnull, &carray); NS_NewAdoptingUTF8StringEnumerator(nsnull, &carray); nsVoidableString str3; - nsCStringContainer sc1; - NS_CStringContainerInit(sc1); - NS_CStringContainerFinish(sc1); - NS_CStringGetData(str2, nsnull, nsnull); - NS_CStringSetData(str2, nsnull, 0); - NS_CStringSetDataRange(str2, 0, 0, nsnull, 0); - NS_CStringCopy(str2, str2); - nsStringContainer sc2; - NS_StringContainerInit(sc2); - NS_StringContainerFinish(sc2); - NS_StringGetData(str1, nsnull, nsnull); - NS_StringSetData(str1, nsnull, 0); - NS_StringSetDataRange(str1, 0, 0, nsnull, 0); - NS_StringCopy(str1, str1); { nsAdoptingCString foo, bar; foo = bar; @@ -197,6 +181,6 @@ void XXXNeverCalled() nsAdoptingString foo, bar; foo = bar; } - NS_UTF16ToCString(str1, NS_CSTRING_ENCODING_ASCII, str2); - NS_CStringToUTF16(str2, NS_CSTRING_ENCODING_ASCII, str1); + NS_CopyNativeToUnicode(str2, str1); + NS_CopyUnicodeToNative(str1, str2); } diff --git a/mozilla/xpcom/build/nsStringAPI.cpp b/mozilla/xpcom/build/nsStringAPI.cpp index ca9a76e4d7b..c8c21f77e45 100644 --- a/mozilla/xpcom/build/nsStringAPI.cpp +++ b/mozilla/xpcom/build/nsStringAPI.cpp @@ -38,7 +38,6 @@ #include "nsString.h" #include "nsCharTraits.h" -#define NS_STRINGAPI_IMPL #include "nsStringAPI.h" #include "nsNativeCharsetUtils.h" diff --git a/mozilla/xpcom/build/nsXPCOM.h b/mozilla/xpcom/build/nsXPCOM.h index 5fdb608995e..e8f5a13950b 100644 --- a/mozilla/xpcom/build/nsXPCOM.h +++ b/mozilla/xpcom/build/nsXPCOM.h @@ -38,6 +38,20 @@ #ifndef nsXPCOM_h__ #define nsXPCOM_h__ +// Map frozen functions to private symbol names if not using strict API. +#ifndef MOZILLA_STRICT_API +# define NS_InitXPCOM2 NS_InitXPCOM2_P +# define NS_ShutdownXPCOM NS_ShutdownXPCOM_P +# define NS_GetServiceManager NS_GetServiceManager_P +# define NS_GetComponentManager NS_GetComponentManager_P +# define NS_GetComponentRegistrar NS_GetComponentRegistrar_P +# define NS_GetMemoryManager NS_GetMemoryManager_P +# define NS_NewLocalFile NS_NewLocalFile_P +# define NS_NewNativeLocalFile NS_NewNativeLocalFile_P +# define NS_GetDebug NS_GetDebug_P +# define NS_GetTraceRefcnt NS_GetTraceRefcnt_P +#endif + #include "nscore.h" #include "nsXPCOMCID.h" diff --git a/mozilla/xpcom/build/nsXPCOMPrivate.h b/mozilla/xpcom/build/nsXPCOMPrivate.h index 1c9b698efcd..2b51390733b 100644 --- a/mozilla/xpcom/build/nsXPCOMPrivate.h +++ b/mozilla/xpcom/build/nsXPCOMPrivate.h @@ -39,6 +39,13 @@ #ifndef nsXPComPrivate_h__ #define nsXPComPrivate_h__ +// Map frozen functions to private symbol names if not using strict API. +#ifndef MOZILLA_STRICT_API +# define NS_RegisterXPCOMExitRoutine NS_RegisterXPCOMExitRoutine_P +# define NS_UnregisterXPCOMExitRoutine NS_UnregisterXPCOMExitRoutine_P +# define NS_GetFrozenFunctions NS_GetFrozenFunctions_P +#endif + #include "nscore.h" #include "nsXPCOM.h" diff --git a/mozilla/xpcom/glue/nsMemory.cpp b/mozilla/xpcom/glue/nsMemory.cpp index fdc1f8b51b5..ec578668346 100644 --- a/mozilla/xpcom/glue/nsMemory.cpp +++ b/mozilla/xpcom/glue/nsMemory.cpp @@ -38,6 +38,8 @@ #include "nsXPCOM.h" #include "nsMemory.h" #include "nsXPCOMPrivate.h" +#include "nsDebug.h" +#include "nsISupportsUtils.h" static nsIMemory* gMemory = nsnull; diff --git a/mozilla/xpcom/glue/nsWeakReference.h b/mozilla/xpcom/glue/nsWeakReference.h index 96e63f22793..27e778ef1e9 100644 --- a/mozilla/xpcom/glue/nsWeakReference.h +++ b/mozilla/xpcom/glue/nsWeakReference.h @@ -43,6 +43,7 @@ // nsWeakReference.h #include "nsIWeakReference.h" +#include "nsIWeakReferenceUtils.h" class nsWeakReference; diff --git a/mozilla/xpcom/glue/standalone/Makefile.in b/mozilla/xpcom/glue/standalone/Makefile.in index ae23d8e02e0..9bb88b270d1 100644 --- a/mozilla/xpcom/glue/standalone/Makefile.in +++ b/mozilla/xpcom/glue/standalone/Makefile.in @@ -85,4 +85,4 @@ include $(topsrcdir)/config/rules.mk export:: $(XPCOM_GLUE_SRC_CSRCS) $(INSTALL) $^ . -DEFINES += -DXPCOM_GLUE +DEFINES += -DXPCOM_GLUE -DMOZILLA_STRICT_API diff --git a/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp b/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp index 097835fca2d..44a139ec3c0 100644 --- a/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp +++ b/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp @@ -40,8 +40,11 @@ #include "nspr.h" #include "nsMemory.h" +#include "nsDebug.h" +#include "nsIServiceManager.h" #include "nsGREDirServiceProvider.h" #include "nsXPCOMPrivate.h" +#include "nsCOMPtr.h" #include #if XP_WIN32 diff --git a/mozilla/xpcom/sample/Makefile.in b/mozilla/xpcom/sample/Makefile.in index 5510e7950d7..a0f77df9c2b 100644 --- a/mozilla/xpcom/sample/Makefile.in +++ b/mozilla/xpcom/sample/Makefile.in @@ -52,7 +52,7 @@ MODULE_NAME = nsSampleModule # Ensure that the xpcom classes that we build # do not export themselves -DEFINES += -DXPCOM_GLUE +DEFINES += -DMOZILLA_STRICT_API -DXPCOM_GLUE REQUIRES = string \ diff --git a/mozilla/xpcom/sample/nsTestSample.cpp b/mozilla/xpcom/sample/nsTestSample.cpp index edf9ce780f8..84d86316180 100644 --- a/mozilla/xpcom/sample/nsTestSample.cpp +++ b/mozilla/xpcom/sample/nsTestSample.cpp @@ -44,8 +44,11 @@ #include +#include "nsXPCOM.h" +#include "nsCOMPtr.h" #include "nsISample.h" #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include "nsIComponentRegistrar.h" #ifdef XPCOM_GLUE diff --git a/mozilla/xpcom/string/public/nsStringAPI.h b/mozilla/xpcom/string/public/nsStringAPI.h index 9501fd1de75..8be1b858476 100644 --- a/mozilla/xpcom/string/public/nsStringAPI.h +++ b/mozilla/xpcom/string/public/nsStringAPI.h @@ -48,7 +48,13 @@ #include "nscore.h" -#define NS_STRINGAPI(x) extern "C" NS_COM x +#if defined( XPCOM_GLUE ) +#define NS_STRINGAPI(type) extern "C" type +#elif defined( _IMPL_NS_STRINGAPI ) +#define NS_STRINGAPI(type) extern "C" NS_EXPORT type +#else +#define NS_STRINGAPI(type) extern "C" NS_IMPORT type +#endif /* The base string types */ class nsAString; @@ -631,14 +637,14 @@ NS_UTF16ToCString(const nsAString &aSource, nsCStringEncoding aDestEncoding, * internal definition of these classes from nsAString.h in the Mozilla tree. */ -#ifndef NS_STRINGAPI_IMPL +#ifndef _IMPL_NS_STRINGAPI #define nsAString_external nsAString #define nsACString_external nsACString #endif class nsAString_external { -#ifndef NS_STRINGAPI_IMPL +#ifndef _IMPL_NS_STRINGAPI public: typedef PRUnichar char_type; @@ -712,7 +718,7 @@ public: NS_HIDDEN_(void) Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, nsnull, 0); } -#endif // NS_STRINGAPI_IMPL +#endif // _IMPL_NS_STRINGAPI private: void *v; @@ -720,7 +726,7 @@ private: class nsACString_external { -#ifndef NS_STRINGAPI_IMPL +#ifndef _IMPL_NS_STRINGAPI public: typedef char char_type; @@ -794,7 +800,7 @@ public: NS_HIDDEN_(void) Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, nsnull, 0); } -#endif // NS_STRINGAPI_IMPL +#endif // _IMPL_NS_STRINGAPI private: void *v; diff --git a/mozilla/xpcom/stub/Makefile.in b/mozilla/xpcom/stub/Makefile.in new file mode 100644 index 00000000000..0b365bba2b2 --- /dev/null +++ b/mozilla/xpcom/stub/Makefile.in @@ -0,0 +1,82 @@ +# vim:set ts=8 sw=8 sts=8 noet: +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is IBM Corporation. +# Portions created by IBM Corporation are Copyright (C) 2004 +# IBM Corporation. All Rights Reserved. +# +# Contributor(s): +# Darin Fisher +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = xpcom +LIBRARY_NAME = xpcom + +PACKAGE_FILE = xpcom.pkg +PACKAGE_VARS += USE_SHORT_LIBNAME + +ifdef ENABLE_TESTS +PACKAGE_FILE += xpcom-tests.pkg +endif + +# Do not set EXPORT_LIBRARY as we do not want xpcom in the static libs list +#EXPORT_LIBRARY = 1 +GRE_MODULE = 1 + +REQUIRES = string \ + $(NULL) + +DEFINES = -D_IMPL_NS_STRINGAPI +LOCAL_INCLUDES = -I$(srcdir)/../build + +CPPSRCS = nsXPComStub.cpp ../build/nsStringAPI.cpp + +SDK_LIBRARY = $(IMPORT_LIBRARY) +SDK_BINARY = $(SHARED_LIBRARY) + +# Force use of PIC +FORCE_USE_PIC = 1 + +FORCE_SHARED_LIB = 1 + +ifeq ($(OS_TARGET),OS2) +EXTRA_DSO_LIBS = xpcomcor +else +EXTRA_DSO_LIBS = xpcom_core +endif +EXTRA_DSO_LDOPTS = $(LIBS_DIR) $(EXTRA_DSO_LIBS) $(NSPR_LIBS) + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/xpcom/stub/nsStringAPI.cpp b/mozilla/xpcom/stub/nsStringAPI.cpp index ca9a76e4d7b..c8c21f77e45 100644 --- a/mozilla/xpcom/stub/nsStringAPI.cpp +++ b/mozilla/xpcom/stub/nsStringAPI.cpp @@ -38,7 +38,6 @@ #include "nsString.h" #include "nsCharTraits.h" -#define NS_STRINGAPI_IMPL #include "nsStringAPI.h" #include "nsNativeCharsetUtils.h" diff --git a/mozilla/xpcom/stub/nsXPComStub.cpp b/mozilla/xpcom/stub/nsXPComStub.cpp new file mode 100644 index 00000000000..045d7597f67 --- /dev/null +++ b/mozilla/xpcom/stub/nsXPComStub.cpp @@ -0,0 +1,144 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla. + * + * The Initial Developer of the Original Code is IBM Corporation. + * Portions created by IBM Corporation are Copyright (C) 2004 + * IBM Corporation. All Rights Reserved. + * + * Contributor(s): + * Darin Fisher + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsXPCOM.h" +#include "nsXPCOMPrivate.h" +#include "nsStringAPI.h" + +/* + * Stubs for nsXPCOM.h + */ + +#undef NS_InitXPCOM2 +extern "C" NS_EXPORT nsresult +NS_InitXPCOM2(nsIServiceManager **result, + nsIFile *binDirectory, + nsIDirectoryServiceProvider *dirProvider) +{ + return NS_InitXPCOM2_P(result, binDirectory, dirProvider); +} + +#undef NS_ShutdownXPCOM +extern "C" NS_EXPORT nsresult +NS_ShutdownXPCOM(nsIServiceManager *svcMgr) +{ + return NS_ShutdownXPCOM_P(svcMgr); +} + +#undef NS_GetServiceManager +extern "C" NS_EXPORT nsresult +NS_GetServiceManager(nsIServiceManager* *result) +{ + return NS_GetServiceManager_P(result); +} + +#undef NS_GetComponentManager +extern "C" NS_EXPORT nsresult +NS_GetComponentManager(nsIComponentManager* *result) +{ + return NS_GetComponentManager_P(result); +} + +#undef NS_GetComponentRegistrar +extern "C" NS_EXPORT nsresult +NS_GetComponentRegistrar(nsIComponentRegistrar* *result) +{ + return NS_GetComponentRegistrar_P(result); +} + +#undef NS_GetMemoryManager +extern "C" NS_EXPORT nsresult +NS_GetMemoryManager(nsIMemory* *result) +{ + return NS_GetMemoryManager_P(result); +} + +#undef NS_NewLocalFile +extern "C" NS_EXPORT nsresult +NS_NewLocalFile(const nsAString &path, + PRBool followLinks, + nsILocalFile **result) +{ + return NS_NewLocalFile_P(path, followLinks, result); +} + +#undef NS_NewNativeLocalFile +extern "C" NS_EXPORT nsresult +NS_NewNativeLocalFile(const nsACString &path, + PRBool followLinks, + nsILocalFile **result) +{ + return NS_NewNativeLocalFile_P(path, followLinks, result); +} + +#undef NS_GetDebug +extern "C" NS_EXPORT nsresult +NS_GetDebug(nsIDebug **result) +{ + return NS_GetDebug_P(result); +} + +#undef NS_GetTraceRefcnt +extern "C" NS_EXPORT nsresult +NS_GetTraceRefcnt(nsITraceRefcnt **result) +{ + return NS_GetTraceRefcnt_P(result); +} + +/* + * Stubs for nsXPCOMPrivate.h + */ + +#undef NS_RegisterXPCOMExitRoutine +extern "C" NS_EXPORT nsresult +NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority) +{ + return NS_RegisterXPCOMExitRoutine_P(exitRoutine, priority); +} + +#undef NS_UnregisterXPCOMExitRoutine +extern "C" NS_EXPORT nsresult +NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine) +{ + return NS_UnregisterXPCOMExitRoutine_P(exitRoutine); +} + +#undef NS_GetFrozenFunctions +extern "C" NS_EXPORT nsresult +NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath) +{ + return NS_GetFrozenFunctions_P(entryPoints, libraryPath); +} diff --git a/mozilla/xpcom/tests/TestMinStringAPI.cpp b/mozilla/xpcom/tests/TestMinStringAPI.cpp index 811df138702..5464673c712 100644 --- a/mozilla/xpcom/tests/TestMinStringAPI.cpp +++ b/mozilla/xpcom/tests/TestMinStringAPI.cpp @@ -294,6 +294,55 @@ static PRBool test_replace() return PR_TRUE; } +static const char* kWhitespace="\b\t\r\n "; + +static void +CompressWhitespace(nsACString &str) + { + const char *p; + PRInt32 i, len = (PRInt32) NS_CStringGetData(str, &p); + + // trim leading whitespace + + for (i=0; i0) + { + NS_CStringCutData(str, 0, i); + len = (PRInt32) NS_CStringGetData(str, &p); + } + + // trim trailing whitespace + + for (i=len-1; i>=0; --i) + { + if (!strchr(kWhitespace, (char) p[i])) + break; + } + + if (++i < len) + NS_CStringCutData(str, i, len - i); + } + +static PRBool test_compress_ws() + { + nsCStringContainer s; + NS_CStringContainerInit(s); + NS_CStringSetData(s, " \thello world\r \n"); + CompressWhitespace(s); + const char *d; + NS_CStringGetData(s, &d); + PRBool rv = !strcmp(d, "hello world"); + if (!rv) + printf("=> \"%s\"\n", d); + NS_CStringContainerFinish(s); + return rv; + } + //---- typedef PRBool (*TestFunc)(); @@ -310,6 +359,7 @@ tests[] = { "test_convert", test_convert }, { "test_append", test_append }, { "test_replace", test_replace }, + { "test_compress_ws", test_compress_ws }, { nsnull, nsnull } }; diff --git a/mozilla/xpcom/tools/registry/Makefile.in b/mozilla/xpcom/tools/registry/Makefile.in index 5c19d0148e7..a81de30ac25 100644 --- a/mozilla/xpcom/tools/registry/Makefile.in +++ b/mozilla/xpcom/tools/registry/Makefile.in @@ -45,7 +45,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = xpcom CPPSRCS = regxpcom.cpp -DEFINES += -DXPCOM_GLUE +DEFINES += -DXPCOM_GLUE -DMOZILLA_STRICT_API REQUIRES = \ string \ diff --git a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl index c577652ff66..aff3ed76c5f 100644 --- a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl @@ -48,8 +48,6 @@ #include "nsIComponentManager.h" #include "nsICategoryManager.h" #include "nsIFile.h" -#include "nsXPIDLString.h" -#include "nsReadableUtils.h" #include "nsIServiceManager.h" struct nsModuleComponentInfo; // forward declaration diff --git a/mozilla/xpfe/bootstrap/Makefile.in b/mozilla/xpfe/bootstrap/Makefile.in index 368c1da7a11..50fc4c91523 100644 --- a/mozilla/xpfe/bootstrap/Makefile.in +++ b/mozilla/xpfe/bootstrap/Makefile.in @@ -65,7 +65,7 @@ endif endif ifdef GRE_BUILD -DEFINES += -DXPCOM_GLUE +DEFINES += -DXPCOM_GLUE -DMOZILLA_STRICT_API endif MODULE = apprunner @@ -176,7 +176,6 @@ endif # If you change anything that mozilla links to, please talk to dougt@netscape.com ifdef GRE_BUILD LIBS += \ - $(DIST)/lib/$(LIB_PREFIX)string_s.$(LIB_SUFFIX) \ $(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \ $(NULL) else @@ -375,7 +374,7 @@ endif CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -LOCAL_INCLUDES = -I$(srcdir) -I. +LOCAL_INCLUDES = -I$(srcdir) -I. ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH))) $(MOZ_APP_NAME).1: mozilla.man.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index f18cbca45eb..d33c316fb49 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -39,10 +39,15 @@ #ifdef XPCOM_GLUE #include "nsXPCOMGlue.h" +#include "nsStringSupport.h" +#else +#include "nsString.h" #endif #include "nsIServiceManager.h" +#include "nsIServiceManagerUtils.h" #include "nsIComponentManager.h" +#include "nsComponentManagerUtils.h" #include "nsIGenericFactory.h" #include "nsIComponentRegistrar.h" @@ -67,6 +72,7 @@ #include "prprf.h" #include "nsCRT.h" #include "nsIDirectoryService.h" +#include "nsDirectoryServiceUtils.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIWindowMediator.h" #include "nsIDOMWindowInternal.h" @@ -74,7 +80,6 @@ #include "nsISupportsPrimitives.h" #include "nsICmdLineHandler.h" #include "nsICategoryManager.h" -#include "nsXPIDLString.h" #include "nsIXULWindow.h" #include "nsIChromeRegistrySea.h" #include "nsIEventQueueService.h" @@ -82,9 +87,9 @@ #include "nsBuildID.h" #include "nsWindowCreator.h" #include "nsIWindowWatcher.h" -#include "nsProcess.h" #include "nsILocalFile.h" #include "nsILookAndFeel.h" +#include "nsIProcess.h" #ifdef MOZ_XPINSTALL #include "InstallCleanupDefines.h" @@ -124,7 +129,6 @@ #define DEBUG_CMD_LINE #endif -static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); #include "nsWidgetsCID.h" static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -464,26 +468,26 @@ PrintUsage(void) fprintf(stderr, "\t: a fully defined url string like http:// etc..\n"); } -static nsresult OpenWindow(const nsAFlatCString& aChromeURL, - const nsAFlatString& aAppArgs, +static nsresult OpenWindow(const nsCString& aChromeURL, + const nsString& aAppArgs, PRInt32 aWidth, PRInt32 aHeight); -static nsresult OpenWindow(const nsAFlatCString& aChromeURL, - const nsAFlatString& aAppArgs) +static nsresult OpenWindow(const nsCString& aChromeURL, + const nsString& aAppArgs) { return OpenWindow(aChromeURL, aAppArgs, nsIAppShellService::SIZE_TO_CONTENT, nsIAppShellService::SIZE_TO_CONTENT); } -static nsresult OpenWindow(const nsAFlatCString& aChromeURL, +static nsresult OpenWindow(const nsCString& aChromeURL, PRInt32 aWidth, PRInt32 aHeight) { return OpenWindow(aChromeURL, EmptyString(), aWidth, aHeight); } -static nsresult OpenWindow(const nsAFlatCString& aChromeURL, - const nsAFlatString& aAppArgs, +static nsresult OpenWindow(const nsCString& aChromeURL, + const nsString& aAppArgs, PRInt32 aWidth, PRInt32 aHeight) { @@ -817,16 +821,26 @@ static char kMatchOSLocalePref[] = "intl.locale.matchOS"; nsresult getCountry(const nsAString& lc_name, nsAString& aCountry) { +#ifdef XPCOM_GLUE + const PRUnichar *begin = lc_name.BeginReading(); + const PRUnichar *end = lc_name.EndReading(); + while (begin != end) { + if (*begin == '-') + break; + ++begin; + } - nsresult result = NS_OK; + if (begin == end) + return NS_ERROR_FAILURE; - PRInt32 dash = lc_name.FindChar('-'); - if (dash > 0) - aCountry = Substring(lc_name, dash+1, lc_name.Length()-dash); - else - result = NS_ERROR_FAILURE; - - return result; + aCountry.Assign(begin + 1, end - begin); +#else + PRInt32 i = lc_name.FindChar('-'); + if (i == kNotFound) + return NS_ERROR_FAILURE; + aCountry = Substring(lc_name, i + 1, PR_UINT32_MAX); +#endif + return NS_OK; } static nsresult @@ -1035,7 +1049,7 @@ static nsresult VerifyInstallation(int argc, char **argv) cleanupUtility->SetNativeLeafName(CLEANUP_UTIL); //Create the process framework to run the cleanup utility - nsCOMPtr cleanupProcess = do_CreateInstance(kIProcessCID); + nsCOMPtr cleanupProcess = do_CreateInstance(NS_PROCESS_CONTRACTID); rv = cleanupProcess->Init(cleanupUtility); if (NS_SUCCEEDED(rv)) rv = cleanupProcess->Run(PR_FALSE,nsnull, 0, nsnull); diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportBeOS.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportBeOS.cpp index 9aef643cb54..f3d443a60ea 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportBeOS.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportBeOS.cpp @@ -35,8 +35,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsNativeAppSupportBase.h" + +#ifdef XPCOM_GLUE +#include "nsStringSupport.h" +#else #include "nsString.h" +#endif + +#include "nsNativeAppSupportBase.h" #include "nsIObserver.h" #include diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportGtk.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportGtk.cpp index de748e2068f..6434d6564c2 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportGtk.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportGtk.cpp @@ -39,10 +39,15 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef XPCOM_GLUE +#include "nsStringSupport.h" +#else +#include "nsString.h" +#endif + #include "nsNativeAppSupportBase.h" #include "gdk/gdk.h" #include "prenv.h" -#include "nsString.h" #ifdef MOZ_XUL_APP extern char* splash_xpm[]; #else diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 4dca9a8a8cf..f2f7cf9872c 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -44,12 +44,16 @@ #define INCL_DOSERRORS #include +#ifdef XPCOM_GLUE +#include "nsStringSupport.h" +#else +#include "nsString.h" +#endif + #include "nsNativeAppSupportBase.h" #include "nsNativeAppSupportOS2.h" -#include "nsString.h" #include "nsICmdLineService.h" #include "nsCOMPtr.h" -#include "nsXPIDLString.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsICmdLineHandler.h" diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index d812e9a5282..86e60941a9b 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -41,12 +41,12 @@ #include "nsNativeAppSupportBase.h" #include "nsNativeAppSupportWin.h" -#include "nsString.h" #include "nsICmdLineService.h" #include "nsCOMPtr.h" -#include "nsXPIDLString.h" #include "nsIComponentManager.h" +#include "nsComponentManagerUtils.h" #include "nsIServiceManager.h" +#include "nsIServiceManagerUtils.h" #include "nsICmdLineHandler.h" #include "nsIDOMWindow.h" #include "nsXPCOM.h" @@ -70,6 +70,12 @@ #include "nsIObserverService.h" #include "nsXPCOM.h" +#ifdef XPCOM_GLUE +#include "nsStringSupport.h" +#else +#include "nsString.h" +#endif + // These are needed to load a URL in a browser window. #include "nsIDOMLocation.h" #include "nsIJSContextStack.h" @@ -1349,7 +1355,7 @@ static nsCString hszValue( DWORD, HSZ ) { // Utility function to escape double-quotes within a string. -static void escapeQuotes( nsAString &aString ) { +static void escapeQuotes( nsString &aString ) { PRInt32 offset = -1; while( 1 ) { // Find next '"'. @@ -1509,7 +1515,7 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t // title outpt.Append( NS_LITERAL_CSTRING("\",\"") ); // Now copy the current page title to the return string - outpt.Append( NS_LossyConvertUCS2toASCII( title.get() )); + outpt.Append( NS_LossyConvertUCS2toASCII( title )); // Fill out the return string with the remainin ","" outpt.Append( NS_LITERAL_CSTRING( "\",\"\"" )); @@ -1682,14 +1688,14 @@ void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsCString& aString DWORD argLen = DdeQueryString( mInstance, args, NULL, NULL, CP_WINANSI ); // there wasn't any string, so return empty string if ( !argLen ) return; - nsCAutoString temp; // Ensure result's buffer is sufficiently big. - temp.SetLength( argLen ); + char *temp = (char *) malloc(argLen + 1); + if ( !temp ) return; // Now get the string contents. - DdeQueryString( mInstance, args, temp.BeginWriting(), argLen + 1, CP_WINANSI ); + DdeQueryString( mInstance, args, temp, argLen + 1, CP_WINANSI ); // Parse out the given arg. - ParseDDEArg(temp.get(), index, aString); - return; + ParseDDEArg(temp, index, aString); + free(temp); } void nsNativeAppSupportWin::ActivateLastWindow() { @@ -1872,8 +1878,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { if (NS_FAILED(rv) || !defaultArgs) return; if (defaultArgs) { - nsCAutoString url; - url.AssignWithConversion( defaultArgs ); + NS_LossyConvertUCS2toASCII url( defaultArgs ); OpenBrowserWindow(url.get()); } else { OpenBrowserWindow("about:blank"); diff --git a/mozilla/xpfe/bootstrap/nsStringSupport.h b/mozilla/xpfe/bootstrap/nsStringSupport.h new file mode 100644 index 00000000000..6644ad50558 --- /dev/null +++ b/mozilla/xpfe/bootstrap/nsStringSupport.h @@ -0,0 +1,345 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla. + * + * The Initial Developer of the Original Code is IBM Corporation. + * Portions created by IBM Corporation are Copyright (C) 2004 + * IBM Corporation. All Rights Reserved. + * + * Contributor(s): + * Darin Fisher + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsStringSupport_h__ +#define nsStringSupport_h__ + +/** + * This file attempts to implement the subset of string classes and methods + * used by xpfe/bootstrap in terms of the frozen string API. + * + * This code exists to allow xpfe/bootstrap to be optionally compiled as a + * standalone embedder of the GRE. However, since the module can also be built + * statically or as a non-GRE application, it is necessary to support compiling + * it directly against the internal xpcom string classes. Hence, this layer of + * indirection ;-) + */ + +#include "nsEmbedString.h" +#include "nsMemory.h" +#include "prprf.h" +#include "plstr.h" + +// rename class names that are redefined here +#define nsCString nsCString_local +#define nsCAutoString nsCAutoString_local +#define nsDependentCString nsDependentCString_local +#define nsXPIDLCString nsXPIDLCString_local +#define nsCGetterCopies nsCGetterCopies_local +#define nsString nsString_local +#define nsAutoString nsAutoString_local +#define nsDependentString nsDependentString_local +#define nsXPIDLString nsXPIDLString_local +#define nsGetterCopies nsGetterCopies_local +#define NS_ConvertUCS2toUTF8 NS_ConvertUCS2toUTF8_local +#define NS_LossyConvertUCS2toASCII NS_LossyConvertUCS2toASCII_local +#define getter_Copies getter_Copies_local + +#define kNotFound -1 + +class nsCString : public nsEmbedCString + { + public: + nsCString() {} + nsCString(const char *s) + { + Assign(s); + } + void AppendInt(PRInt32 value) + { + char buf[32]; + PR_snprintf(buf, sizeof(buf), "%d", value); + Append(buf); + } + PRBool IsEmpty() + { + return Length() == 0; + } + PRInt32 FindChar(char c, PRUint32 offset = 0) + { + NS_ASSERTION(offset <= Length(), "invalid offset"); + const char *data = get() + offset; + for (const char *p = data; *p; ++p) + if (*p == c) + return p - data; + return kNotFound; + } + PRInt32 Find(const char *needle, PRBool ignoreCase = PR_FALSE) + { + const char *data = get(), *p; + if (ignoreCase) + p = PL_strcasestr(data, needle); + else + p = PL_strstr(data, needle); + return p ? p - data : kNotFound; + } + PRBool Equals(const char *s) + { + return strcmp(get(), s) == 0; + } + }; + +class nsDependentCString : public nsCString + { + public: + nsDependentCString(const char *data) + { + Assign(data); // XXX forced to copy + } + nsDependentCString(const char *data, PRUint32 len) + { + Assign(data, len); // XXX forced to copy + } + }; + +class nsCAutoString : public nsCString + { + public: + nsCAutoString() {} + nsCAutoString(const char *data) + { + Assign(data); + } + nsCAutoString(const nsCString &s) + { + Assign(s); + } + }; + +class nsString : public nsEmbedString + { + public: + nsString() {} + PRBool IsEmpty() + { + return Length() == 0; + } + PRInt32 FindChar(PRUnichar c, PRUint32 offset = 0) + { + NS_ASSERTION(offset <= Length(), "invalid offset"); + const PRUnichar *data = get() + offset; + for (const PRUnichar *p = data; *p; ++p) + if (*p == c) + return p - data; + return kNotFound; + } + }; + +class nsDependentString : public nsString + { + public: + nsDependentString(const PRUnichar *data) + { + Assign(data); // XXX forced to copy + } + }; + +class nsAutoString : public nsString + { + public: + void AssignWithConversion(const char *data) + { + AssignLiteral(data); + } + void AssignLiteral(const char *data) + { + NS_CStringToUTF16(nsEmbedCString(data), NS_CSTRING_ENCODING_ASCII, *this); + } + nsAutoString &operator=(const PRUnichar *s) + { + Assign(s); + return *this; + } + }; + +class nsXPIDLCString : public nsCString + { + public: + nsXPIDLCString() : mVoided(PR_TRUE) {} + + const char *get() const + { + return mVoided ? nsnull : nsEmbedCString::get(); + } + operator const char*() const + { + return get(); + } + + void Adopt(char *data) + { + if (data) + { + // XXX unfortunately, we don't have a better way to do this. + Assign(data); + nsMemory::Free(data); + mVoided = PR_FALSE; + } + else + { + Cut(0, PR_UINT32_MAX); + mVoided = PR_TRUE; + } + } + + private: + PRBool mVoided; + }; + +class nsCGetterCopies + { + public: + typedef char char_type; + + nsCGetterCopies(nsXPIDLCString& str) + : mString(str), mData(nsnull) {} + + ~nsCGetterCopies() + { + mString.Adopt(mData); // OK if mData is null + } + + operator char_type**() + { + return &mData; + } + + private: + nsXPIDLCString& mString; + char_type* mData; + }; + +inline +nsCGetterCopies +getter_Copies( nsXPIDLCString& aString ) + { + return nsCGetterCopies(aString); + } + +class nsXPIDLString : public nsString + { + public: + nsXPIDLString() : mVoided(PR_TRUE) {} + + const PRUnichar *get() const + { + return mVoided ? nsnull : nsEmbedString::get(); + } + operator const PRUnichar*() const + { + return get(); + } + + void Adopt(PRUnichar *data) + { + if (data) + { + // XXX unfortunately, we don't have a better way to do this. + Assign(data); + nsMemory::Free(data); + mVoided = PR_FALSE; + } + else + { + Cut(0, PR_UINT32_MAX); + mVoided = PR_TRUE; + } + } + + private: + PRBool mVoided; + }; + +class nsGetterCopies + { + public: + typedef PRUnichar char_type; + + nsGetterCopies(nsXPIDLString& str) + : mString(str), mData(nsnull) {} + + ~nsGetterCopies() + { + mString.Adopt(mData); // OK if mData is null + } + + operator char_type**() + { + return &mData; + } + + private: + nsXPIDLString& mString; + char_type* mData; + }; + +inline +nsGetterCopies +getter_Copies( nsXPIDLString& aString ) + { + return nsGetterCopies(aString); + } + +class NS_ConvertUCS2toUTF8 : public nsCString + { + public: + NS_ConvertUCS2toUTF8(const nsAString &str) + { + NS_UTF16ToCString(str, NS_CSTRING_ENCODING_UTF8, *this); + } + }; + +class NS_LossyConvertUCS2toASCII : public nsCString + { + public: + NS_LossyConvertUCS2toASCII(const nsAString &str) + { + NS_UTF16ToCString(str, NS_CSTRING_ENCODING_ASCII, *this); + } + }; + +#define NS_LITERAL_CSTRING(s) nsDependentCString(s) + +#ifdef HAVE_CPP_2BYTE_WCHAR_T +#define NS_LITERAL_STRING(s) nsDependentString(L##s) +#else +#error "need implementation of NS_LITERAL_STRING" +#endif + +#define EmptyCString() nsCString() +#define EmptyString() nsString() + +#endif // !nsStringSupport_h__ diff --git a/mozilla/xpfe/bootstrap/nsWindowCreator.cpp b/mozilla/xpfe/bootstrap/nsWindowCreator.cpp index dba8b54c8a1..6cf6d3a7df6 100644 --- a/mozilla/xpfe/bootstrap/nsWindowCreator.cpp +++ b/mozilla/xpfe/bootstrap/nsWindowCreator.cpp @@ -74,6 +74,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIServiceManager.h" +#include "nsIServiceManagerUtils.h" #include "nsIURI.h" #include "nsIXULWindow.h" #include "nsIWebBrowserChrome.h" diff --git a/mozilla/xpfe/bootstrap/os2turbo/mozturbo.cpp b/mozilla/xpfe/bootstrap/os2turbo/mozturbo.cpp index 994b7071568..971f8126fb0 100644 --- a/mozilla/xpfe/bootstrap/os2turbo/mozturbo.cpp +++ b/mozilla/xpfe/bootstrap/os2turbo/mozturbo.cpp @@ -75,6 +75,7 @@ char *bindir[] = { "PLC4.DLL", "PLDS4.DLL", "XPCOM.DLL", + "XPCOMCOR.DLL", "XPCOMCT.DLL", 0 }; diff --git a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl index c577652ff66..aff3ed76c5f 100644 --- a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl @@ -48,8 +48,6 @@ #include "nsIComponentManager.h" #include "nsICategoryManager.h" #include "nsIFile.h" -#include "nsXPIDLString.h" -#include "nsReadableUtils.h" #include "nsIServiceManager.h" struct nsModuleComponentInfo; // forward declaration diff --git a/mozilla/xpinstall/packager/packages-os2 b/mozilla/xpinstall/packager/packages-os2 index c58ad724e7e..cc3c2556ec9 100644 --- a/mozilla/xpinstall/packager/packages-os2 +++ b/mozilla/xpinstall/packager/packages-os2 @@ -51,6 +51,7 @@ bin/nspr4.dll bin/plc4.dll bin/plds4.dll bin/xpcom.dll +bin/xpcomcor.dll bin/xpistub.dll ;bin/zlib.dll bin/mozz.dll diff --git a/mozilla/xpinstall/packager/packages-static-unix b/mozilla/xpinstall/packager/packages-static-unix index 8c63e2926ec..28b7ffdb2d2 100644 --- a/mozilla/xpinstall/packager/packages-static-unix +++ b/mozilla/xpinstall/packager/packages-static-unix @@ -48,6 +48,7 @@ bin/libplc4.so bin/libplds4.so bin/cpu/sparcv8plus/libnspr_flt4.so bin/libxpcom.so +bin/libxpcom_core.so bin/libxpistub.so bin/components/libxpinstall.so bin/components/libjar50.so diff --git a/mozilla/xpinstall/packager/packages-unix b/mozilla/xpinstall/packager/packages-unix index 34e11b5ec4a..86d8218bb16 100644 --- a/mozilla/xpinstall/packager/packages-unix +++ b/mozilla/xpinstall/packager/packages-unix @@ -50,6 +50,7 @@ bin/libplc4.so bin/libplds4.so bin/cpu/sparcv8plus/libnspr_flt4.so bin/libxpcom.so +bin/libxpcom_core.so bin/libxpistub.so bin/libmozz.so bin/components/libxpinstall.so diff --git a/mozilla/xpinstall/packager/windows/browser.jst b/mozilla/xpinstall/packager/windows/browser.jst index bc7a615bbd7..4c263b98f99 100644 --- a/mozilla/xpinstall/packager/windows/browser.jst +++ b/mozilla/xpinstall/packager/windows/browser.jst @@ -473,6 +473,7 @@ function upgradeCleanup() deleteThisFile("Program", "softokn3.dll"); deleteThisFile("Program", "ssl3.dll"); deleteThisFile("Program", "xpcom.dll"); + deleteThisFile("Program", "xpcom_core.dll"); deleteThisFile("Program", "xpistub.dll"); deleteThisFile("Program", "zlib.dll"); deleteThisFile("Program", "mozz.dll"); diff --git a/mozilla/xpinstall/packager/xpcom-win.pkg b/mozilla/xpinstall/packager/xpcom-win.pkg index a0799bbab3e..89ea08e6c9e 100644 --- a/mozilla/xpinstall/packager/xpcom-win.pkg +++ b/mozilla/xpinstall/packager/xpcom-win.pkg @@ -16,6 +16,7 @@ bin\nspr4.dll bin\plc4.dll bin\plds4.dll bin\xpcom.dll +bin\xpcom_core.dll bin\xpistub.dll bin\mozz.dll bin\components\jar50.dll diff --git a/mozilla/xpinstall/public/nsISoftwareUpdate.h b/mozilla/xpinstall/public/nsISoftwareUpdate.h index 43d7b0e004c..8899508fe1a 100644 --- a/mozilla/xpinstall/public/nsISoftwareUpdate.h +++ b/mozilla/xpinstall/public/nsISoftwareUpdate.h @@ -43,7 +43,6 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsString.h" #include "nsIXPINotifier.h" #include "nsCOMPtr.h"