Bug 1332523 - Make the Bootstrap API entry point the same for both dependent and standalone linkage. r=bsmedberg
--- a/ipc/app/MozillaRuntimeMain.cpp
+++ b/ipc/app/MozillaRuntimeMain.cpp
@@ -13,15 +13,14 @@ using namespace mozilla;
int
main(int argc, char *argv[])
{
#ifdef HAS_DLL_BLOCKLIST
DllBlocklist_Initialize();
#endif
- Bootstrap::UniquePtr bootstrap;
- XRE_GetBootstrap(bootstrap);
+ Bootstrap::UniquePtr bootstrap = GetBootstrap();
if (!bootstrap) {
return 2;
}
return content_process_main(bootstrap.get(), argc, argv);
}
--- a/ipc/ipdl/test/cxx/app/TestIPDL.cpp
+++ b/ipc/ipdl/test/cxx/app/TestIPDL.cpp
@@ -14,15 +14,14 @@ using namespace mozilla;
int
main(int argc, char** argv)
{
// the first argument specifies which IPDL test case/suite to load
if (argc < 2)
return 1;
- Bootstrap::UniquePtr bootstrap;
- XRE_GetBootstrap(bootstrap);
+ Bootstrap::UniquePtr bootstrap = GetBootstrap();
if (!bootstrap) {
return 2;
}
return bootstrap->XRE_RunIPDLTest(argc, argv);
}
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -55,18 +55,17 @@ main(int argc, char** argv, char** envp)
#endif
XREShellData shellData;
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
shellData.sandboxBrokerServices =
mozilla::sandboxing::GetInitializedBrokerServices();
#endif
- mozilla::Bootstrap::UniquePtr bootstrap;
- XRE_GetBootstrap(bootstrap);
+ mozilla::Bootstrap::UniquePtr bootstrap = mozilla::GetBootstrap();
if (!bootstrap) {
return 2;
}
int result = bootstrap->XRE_XPCShellMain(argc, argv, envp, &shellData);
#ifdef XP_MACOSX
FinishAutoreleasePool();
--- a/toolkit/xre/Bootstrap.h
+++ b/toolkit/xre/Bootstrap.h
@@ -122,15 +122,26 @@ public:
/**
* Creates and returns the singleton instnace of the bootstrap object.
* @param `b` is an outparam. We use a parameter and not a return value
* because MSVC doesn't let us return a c++ class from a function with
* "C" linkage. On failure this will be null.
* @note This function may only be called once and will crash if called again.
*/
+#ifdef XPCOM_GLUE
+typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&);
+Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile=nullptr);
+#else
extern "C" NS_EXPORT void NS_FROZENCALL
XRE_GetBootstrap(Bootstrap::UniquePtr& b);
-typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&);
+
+inline Bootstrap::UniquePtr
+GetBootstrap(const char* aXPCOMFile=nullptr) {
+ Bootstrap::UniquePtr bootstrap;
+ XRE_GetBootstrap(bootstrap);
+ return bootstrap;
+}
+#endif
} // namespace mozilla
#endif // mozilla_Bootstrap_h