Fix --disable-libxul from bug 568691. r=Mossop
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 02 Jul 2010 14:23:41 -0400
changeset 47146 d92fd4a1ddf55805afc69fbe98cc80505a18b98d
parent 47145 29ba8085d9f625c59300fae8ae8cb6c72536543c
child 47147 b7b8034c9f0530647fe41565f5dc1d2007676a8b
push idunknown
push userunknown
push dateunknown
reviewersMossop
bugs568691
milestone2.0b2pre
Fix --disable-libxul from bug 568691. r=Mossop
js/src/xpconnect/tests/components/xpctest_calljs.cpp
js/src/xpconnect/tests/components/xpctest_module.cpp
js/src/xpconnect/tests/components/xpctest_multiple.cpp
js/src/xpconnect/tests/components/xpctest_private.h
toolkit/xre/nsAppRunner.cpp
xpcom/components/ManifestParser.cpp
xpcom/components/nsComponentManager.cpp
xpcom/glue/nsIClassInfoImpl.h
--- a/js/src/xpconnect/tests/components/xpctest_calljs.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_calljs.cpp
@@ -52,16 +52,17 @@ public:
     xpcTestCallJS();
     virtual ~xpcTestCallJS();
 
 private:
     nsIXPCTestCallJS* jsobject;
 };
 
 
+NS_IMPL_CLASSINFO(xpcTestCallJS, NULL, 0, NS_XPCTESTCALLJS_CID);
 NS_IMPL_ISUPPORTS2_CI(xpcTestCallJS, nsIXPCTestCallJS, nsIXPCScriptable)
 
 // The nsIXPCScriptable map declaration that will generate stubs for us...
 #define XPC_MAP_CLASSNAME           xpcTestCallJS
 #define XPC_MAP_QUOTED_CLASSNAME   "xpcTestCallJS"
 #define XPC_MAP_FLAGS               0
 #include "xpc_map_end.h" /* This will #undef the above */
 
--- a/js/src/xpconnect/tests/components/xpctest_module.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_module.cpp
@@ -38,40 +38,91 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* module registration and factory code. */
 
 #include "xpctest_private.h"
 #include "nsCOMPtr.h"
 #include "nsIModule.h"
-#include "nsIGenericFactory.h"
+#include "mozilla/ModuleUtils.h"
 #include "nsCRT.h"
 #include "nsIClassInfoImpl.h"
 
-NS_DECL_CLASSINFO(xpcTestCallJS)
-NS_DECL_CLASSINFO(xpcTestChild2)
+NS_DEFINE_NAMED_CID(NS_ECHO_CID);
+NS_DEFINE_NAMED_CID(NS_CHILD_CID);
+NS_DEFINE_NAMED_CID(NS_NOISY_CID);
+NS_DEFINE_NAMED_CID(NS_STRING_TEST_CID);
+NS_DEFINE_NAMED_CID(NS_OVERLOADED_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADONLY_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADWRITE_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTIN_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTOUT_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTINOUT_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCONST_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCALLJS_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTPARENTONE_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTPARENTTWO_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCHILD2_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCHILD3_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCHILD4_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTCHILD5_CID);
+NS_DEFINE_NAMED_CID(NS_ARRAY_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTDOMSTRING_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTVARIANT_CID);
 
-static const nsModuleComponentInfo components[] = {
-  {nsnull, NS_ECHO_CID,                   "@mozilla.org/js/xpc/test/Echo;1",                 xpctest::ConstructEcho                  },
-  {nsnull, NS_CHILD_CID,                  "@mozilla.org/js/xpc/test/Child;1",                xpctest::ConstructChild                 },
-  {nsnull, NS_NOISY_CID,                  "@mozilla.org/js/xpc/test/Noisy;1",                xpctest::ConstructNoisy                 },
-  {nsnull, NS_STRING_TEST_CID,            "@mozilla.org/js/xpc/test/StringTest;1",           xpctest::ConstructStringTest            },
-  {nsnull, NS_OVERLOADED_CID,             "@mozilla.org/js/xpc/test/Overloaded;1",           xpctest::ConstructOverloaded            },
-  {nsnull, NS_XPCTESTOBJECTREADONLY_CID,  "@mozilla.org/js/xpc/test/ObjectReadOnly;1",  xpctest::ConstructXPCTestObjectReadOnly },
-  {nsnull, NS_XPCTESTOBJECTREADWRITE_CID, "@mozilla.org/js/xpc/test/ObjectReadWrite;1", xpctest::ConstructXPCTestObjectReadWrite},
-  {nsnull, NS_XPCTESTIN_CID,              "@mozilla.org/js/xpc/test/In;1",              xpctest::ConstructXPCTestIn             },
-  {nsnull, NS_XPCTESTOUT_CID,             "@mozilla.org/js/xpc/test/Out;1",             xpctest::ConstructXPCTestOut            },
-  {nsnull, NS_XPCTESTINOUT_CID,           "@mozilla.org/js/xpc/test/InOut;1",           xpctest::ConstructXPCTestInOut          },
-  {nsnull, NS_XPCTESTCONST_CID,           "@mozilla.org/js/xpc/test/Const;1",           xpctest::ConstructXPCTestConst          },
-  {nsnull, NS_XPCTESTCALLJS_CID,          "@mozilla.org/js/xpc/test/CallJS;1",          xpctest::ConstructXPCTestCallJS, NULL, NULL, NULL, NS_CI_INTERFACE_GETTER_NAME(xpcTestCallJS), NULL, &NS_CLASSINFO_NAME(xpcTestCallJS) },
-  {nsnull, NS_XPCTESTPARENTONE_CID,       "@mozilla.org/js/xpc/test/ParentOne;1",       xpctest::ConstructXPCTestParentOne      },
-  {nsnull, NS_XPCTESTPARENTTWO_CID,       "@mozilla.org/js/xpc/test/ParentTwo;1",       xpctest::ConstructXPCTestParentTwo      },
-  {nsnull, NS_XPCTESTCHILD2_CID,          "@mozilla.org/js/xpc/test/Child2;1",          xpctest::ConstructXPCTestChild2, NULL, NULL, NULL, NS_CI_INTERFACE_GETTER_NAME(xpcTestChild2), NULL, &NS_CLASSINFO_NAME(xpcTestChild2) },
-  {nsnull, NS_XPCTESTCHILD3_CID,          "@mozilla.org/js/xpc/test/Child3;1",          xpctest::ConstructXPCTestChild3         },
-  {nsnull, NS_XPCTESTCHILD4_CID,          "@mozilla.org/js/xpc/test/Child4;1",          xpctest::ConstructXPCTestChild4         },
-  {nsnull, NS_XPCTESTCHILD5_CID,          "@mozilla.org/js/xpc/test/Child5;1",          xpctest::ConstructXPCTestChild5         },
-  {nsnull, NS_ARRAY_CID,                  "@mozilla.org/js/xpc/test/ArrayTest;1",       xpctest::ConstructArrayTest             },
-  {nsnull, NS_XPCTESTDOMSTRING_CID,       "@mozilla.org/js/xpc/test/DOMString;1",       xpctest::ConstructXPCTestDOMString      },
-  {nsnull, NS_XPCTESTVARIANT_CID,         "@mozilla.org/js/xpc/test/TestVariant;1",     xpctest::ConstructXPCTestVariant        }
+static const mozilla::Module::CIDEntry kXPCTestCIDs[] = {
+    { &kNS_ECHO_CID, false, NULL, xpctest::ConstructEcho },
+    { &kNS_CHILD_CID, false, NULL, xpctest::ConstructChild },
+    { &kNS_NOISY_CID, false, NULL, xpctest::ConstructNoisy },
+    { &kNS_STRING_TEST_CID, false, NULL, xpctest::ConstructStringTest },
+    { &kNS_OVERLOADED_CID, false, NULL, xpctest::ConstructOverloaded },
+    { &kNS_XPCTESTOBJECTREADONLY_CID, false, NULL, xpctest::ConstructXPCTestObjectReadOnly },
+    { &kNS_XPCTESTOBJECTREADWRITE_CID, false, NULL, xpctest::ConstructXPCTestObjectReadWrite },
+    { &kNS_XPCTESTIN_CID, false, NULL, xpctest::ConstructXPCTestIn },
+    { &kNS_XPCTESTOUT_CID, false, NULL, xpctest::ConstructXPCTestOut },
+    { &kNS_XPCTESTINOUT_CID, false, NULL, xpctest::ConstructXPCTestInOut },
+    { &kNS_XPCTESTCONST_CID, false, NULL, xpctest::ConstructXPCTestConst },
+    { &kNS_XPCTESTCALLJS_CID, false, NULL, xpctest::ConstructXPCTestCallJS },
+    { &kNS_XPCTESTPARENTONE_CID, false, NULL, xpctest::ConstructXPCTestParentOne },
+    { &kNS_XPCTESTPARENTTWO_CID, false, NULL, xpctest::ConstructXPCTestParentTwo },
+    { &kNS_XPCTESTCHILD2_CID, false, NULL, xpctest::ConstructXPCTestChild2 },
+    { &kNS_XPCTESTCHILD3_CID, false, NULL, xpctest::ConstructXPCTestChild3 },
+    { &kNS_XPCTESTCHILD4_CID, false, NULL, xpctest::ConstructXPCTestChild4 },
+    { &kNS_XPCTESTCHILD5_CID, false, NULL, xpctest::ConstructXPCTestChild5 },
+    { &kNS_ARRAY_CID, false, NULL, xpctest::ConstructArrayTest },
+    { &kNS_XPCTESTDOMSTRING_CID, false, NULL, xpctest::ConstructXPCTestDOMString },
+    { &kNS_XPCTESTVARIANT_CID, false, NULL, xpctest::ConstructXPCTestVariant },
+    { NULL }
 };
-                                                               
-NS_IMPL_NSGETMODULE(xpconnect_test, components)
+
+static const mozilla::Module::ContractIDEntry kXPCTestContracts[] = {
+    { "@mozilla.org/js/xpc/test/Echo;1", &kNS_ECHO_CID },
+    { "@mozilla.org/js/xpc/test/Child;1", &kNS_CHILD_CID },
+    { "@mozilla.org/js/xpc/test/Noisy;1", &kNS_NOISY_CID },
+    { "@mozilla.org/js/xpc/test/StringTest;1", &kNS_STRING_TEST_CID },
+    { "@mozilla.org/js/xpc/test/Overloaded;1", &kNS_OVERLOADED_CID },
+    { "@mozilla.org/js/xpc/test/ObjectReadOnly;1", &kNS_XPCTESTOBJECTREADONLY_CID },
+    { "@mozilla.org/js/xpc/test/ObjectReadWrite;1", &kNS_XPCTESTOBJECTREADWRITE_CID },
+    { "@mozilla.org/js/xpc/test/In;1", &kNS_XPCTESTIN_CID },
+    { "@mozilla.org/js/xpc/test/Out;1", &kNS_XPCTESTOUT_CID },
+    { "@mozilla.org/js/xpc/test/InOut;1", &kNS_XPCTESTINOUT_CID },
+    { "@mozilla.org/js/xpc/test/Const;1", &kNS_XPCTESTCONST_CID },
+    { "@mozilla.org/js/xpc/test/CallJS;1", &kNS_XPCTESTCALLJS_CID },
+    { "@mozilla.org/js/xpc/test/ParentOne;1", &kNS_XPCTESTPARENTONE_CID },
+    { "@mozilla.org/js/xpc/test/ParentTwo;1", &kNS_XPCTESTPARENTTWO_CID },
+    { "@mozilla.org/js/xpc/test/Child2;1", &kNS_XPCTESTCHILD2_CID },
+    { "@mozilla.org/js/xpc/test/Child3;1", &kNS_XPCTESTCHILD3_CID },
+    { "@mozilla.org/js/xpc/test/Child4;1", &kNS_XPCTESTCHILD4_CID },
+    { "@mozilla.org/js/xpc/test/Child5;1", &kNS_XPCTESTCHILD5_CID },
+    { "@mozilla.org/js/xpc/test/ArrayTest;1", &kNS_ARRAY_CID },
+    { "@mozilla.org/js/xpc/test/DOMString;1", &kNS_XPCTESTDOMSTRING_CID },
+    { "@mozilla.org/js/xpc/test/TestVariant;1", &kNS_XPCTESTVARIANT_CID },
+    { NULL }
+};
+
+static const mozilla::Module kXPCTestModule = {
+    mozilla::Module::kVersion,
+    kXPCTestCIDs,
+    kXPCTestContracts
+};
+
+NSMODULE_DEFN(xpconnect_test) = &kXPCTestModule;
--- a/js/src/xpconnect/tests/components/xpctest_multiple.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_multiple.cpp
@@ -180,16 +180,17 @@ public:
   NS_DECL_NSIXPCTESTPARENTONE
   NS_DECL_NSIXPCTESTPARENTTWO
   NS_DECL_ISUPPORTS
   xpcTestChild2();
 private:
     const char *name;
 };
 
+NS_IMPL_CLASSINFO(xpcTestChild2, NULL, 0, NS_XPCTESTCHILD2_CID);
 NS_IMPL_ISUPPORTS3_CI(xpcTestChild2,nsIXPCTestChild2,nsIXPCTestParentOne,nsIXPCTestParentTwo)
 
 xpcTestChild2 :: xpcTestChild2() 
 {
     NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP 
--- a/js/src/xpconnect/tests/components/xpctest_private.h
+++ b/js/src/xpconnect/tests/components/xpctest_private.h
@@ -44,17 +44,17 @@
 #define xpctest_private_h___
 
 #include "nsISupports.h"
 #include "nsIFactory.h"
 #include "nsMemory.h"
 #include "nsIXPConnect.h"
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
-#include "nsIGenericFactory.h"
+#include "mozilla/ModuleUtils.h"
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsAString.h"
 #include "nsVariant.h"
 #include <stdio.h>
 
 #include "xpctest.h"
 #include "jsapi.h"
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1130,26 +1130,16 @@ static const mozilla::Module::ContractID
 static const mozilla::Module kXREModule = {
   mozilla::Module::kVersion,
   kXRECIDs,
   kXREContracts
 };
 
 NSMODULE_DEFN(Apprunner) = &kXREModule;
 
-#if !defined(_BUILD_STATIC_BIN) && !defined(MOZ_ENABLE_LIBXUL)
-static mozilla::Module const *const kXREStaticModules[] =
-{
-  Apprunner_NSModule,
-  NULL
-};
-
-mozilla::Module const *const *const kPStaticModules = kXREStaticModule;
-#endif
-
 nsresult
 ScopedXPCOMStartup::Initialize()
 {
   NS_ASSERTION(gDirServiceProvider, "Should not get here!");
 
   nsresult rv;
 #ifdef MOZ_OMNIJAR
   nsCOMPtr<nsILocalFile> lf;
@@ -1157,16 +1147,20 @@ ScopedXPCOMStartup::Initialize()
   if (omnijarPath)
     rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE, getter_AddRefs(lf));
   else
     rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf));
   if (NS_SUCCEEDED(rv))
     mozilla::SetOmnijar(lf);
 #endif
 
+#if !defined(_BUILD_STATIC_BIN) && !defined(MOZ_ENABLE_LIBXUL)
+  XRE_AddStaticComponent(&kXREModule);
+#endif
+
   rv = NS_InitXPCOM2(&mServiceManager, gDirServiceProvider->GetAppDir(),
                      gDirServiceProvider);
   if (NS_FAILED(rv)) {
     NS_ERROR("Couldn't start xpcom!");
     mServiceManager = nsnull;
   }
   else {
     nsCOMPtr<nsIComponentRegistrar> reg =
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -48,17 +48,16 @@
 #elif defined(MOZ_WIDGET_GTK2)
 #include <gtk/gtk.h>
 #endif
 
 #include "mozilla/Services.h"
 
 #include "nsConsoleMessage.h"
 #include "nsTextFormatter.h"
-#include "nsUnicharUtils.h"
 #include "nsVersionComparator.h"
 #include "nsXPCOMCIDInternal.h"
 
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIXULAppInfo.h"
 #include "nsIXULRuntime.h"
 
@@ -388,16 +387,24 @@ CheckVersionFlag(const nsString& aFlag, 
       aResult = eOK;
     else
       aResult = eBad;
   }
 
   return true;
 }
 
+// In-place conversion of ascii characters to lower case
+static void
+ToLowerCase(char* token)
+{
+  for (; *token; ++token)
+    *token = NS_ToLower(*token);
+}
+
 namespace {
 
 struct CachedDirective
 {
   int lineno;
   char* argv[4];
 };
 
@@ -434,24 +441,24 @@ ParseManifestCommon(NSLocationType aType
     rv = xapp->GetVersion(s);
     if (NS_SUCCEEDED(rv))
       CopyUTF8toUTF16(s, appVersion);
     
     nsCOMPtr<nsIXULRuntime> xruntime (do_QueryInterface(xapp));
     if (xruntime) {
       rv = xruntime->GetOS(s);
       if (NS_SUCCEEDED(rv)) {
+        ToLowerCase(s);
         CopyUTF8toUTF16(s, osTarget);
-        ToLowerCase(osTarget);
       }
 
       rv = xruntime->GetXPCOMABI(s);
       if (NS_SUCCEEDED(rv) && osTarget.Length()) {
+        ToLowerCase(s);
         CopyUTF8toUTF16(s, abi);
-        ToLowerCase(abi);
         abi.Insert(PRUnichar('_'), 0);
         abi.Insert(osTarget, 0);
       }
     }
   }
 
   nsAutoString osVersion;
 #if defined(XP_WIN)
@@ -548,18 +555,18 @@ ParseManifestCommon(NSLocationType aType
     TriState stApp = eUnspecified;
     TriState stOsVersion = eUnspecified;
     TriState stOs = eUnspecified;
     TriState stABI = eUnspecified;
     bool platform = false;
     bool contentAccessible = false;
 
     while (NULL != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) && ok) {
+      ToLowerCase(token);
       NS_ConvertASCIItoUTF16 wtoken(token);
-      ToLowerCase(wtoken);
 
       if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
 	  CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
           CheckStringFlag(kABI, wtoken, abi, stABI) ||
 	  CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
 	  CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion))
 	continue;
 
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -311,19 +311,21 @@ nsTArray<const mozilla::Module*>* nsComp
 
 /* static */ void
 nsComponentManagerImpl::InitializeStaticModules()
 {
     if (sStaticModules)
         return;
 
     sStaticModules = new nsTArray<const mozilla::Module*>;
+#if defined(_BUILD_STATIC_BIN) || defined(MOZ_ENABLE_LIBXUL)
     for (const mozilla::Module *const *staticModules = kPStaticModules;
          *staticModules; ++staticModules)
         sStaticModules->AppendElement(*staticModules);
+#endif
 }
 
 nsTArray<nsComponentManagerImpl::ComponentLocation>*
 nsComponentManagerImpl::sModuleLocations;
 
 /* static */ void
 nsComponentManagerImpl::InitializeModuleLocations()
 {
--- a/xpcom/glue/nsIClassInfoImpl.h
+++ b/xpcom/glue/nsIClassInfoImpl.h
@@ -36,17 +36,17 @@
 #ifndef nsIClassInfoImpl_h__
 #define nsIClassInfoImpl_h__
 
 #include "nsIClassInfo.h"
 #include "nsISupportsImpl.h"
 
 #include NEW_H
 
-class GenericClassInfo : public nsIClassInfo
+class NS_COM_GLUE GenericClassInfo : public nsIClassInfo
 {
 public:
   struct ClassInfoData
   {
     typedef NS_CALLBACK(GetInterfacesProc)(PRUint32* NS_OUTPARAM countp,
                                            nsIID*** NS_OUTPARAM array);
     typedef NS_CALLBACK(GetLanguageHelperProc)(PRUint32 language,
                                                nsISupports** helper);