Bug 296561 - rework static component loading so that nsIXULAppInfo/Runtime/etc are available during autoregistration/xpcom-startup notification (and make static component loading saner in general) - r=shaver+dougt, a=asa

This commit is contained in:
bsmedberg%covad.net 2005-07-21 13:33:43 +00:00
Родитель 38de62e088
Коммит 5fba1c6aea
39 изменённых файлов: 492 добавлений и 601 удалений

Просмотреть файл

@ -11383,11 +11383,11 @@
};
82180AC907368BDF002EFA6D = {
isa = PBXFileReference;
lastKnownFileType = "compiled.mach-o.bundle";
lastKnownFileType = file;
name = libcomposer.dylib;
path = ../dist/bin/components/libcomposer.dylib;
refType = 2;
sourceTree = SOURCE_ROOT;
path = ../../dist/bin/components/libcomposer.dylib;
refType = 3;
sourceTree = BUILT_PRODUCTS_DIR;
};
82180ACB07368BF2002EFA6D = {
fileRef = 82180AC907368BDF002EFA6D;

Просмотреть файл

@ -71,6 +71,7 @@
#include "nsCOMPtr.h"
#include "nsEmbedAPI.h"
#include "nsString.h"
#include "nsStaticComponents.h"
#include "nsIWebBrowserChrome.h"
#include "nsIServiceManager.h"
@ -86,12 +87,6 @@
#include "nsIBrowserHistory.h"
#include "nsICacheService.h"
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#endif
extern const nsModuleComponentInfo* GetAppComponents(unsigned int * outNumComponents);
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
@ -190,11 +185,8 @@ const int kReuseWindowOnAE = 2;
NSString *path = [[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent];
setenv("MOZILLA_FIVE_HOME", [path fileSystemRepresentation], 1);
#ifdef _BUILD_STATIC_BIN
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
if (NS_SUCCEEDED(NS_InitEmbedding(nsnull, nsnull))) {
if (NS_SUCCEEDED(NS_InitEmbedding(nsnull, nsnull,
kPStaticModules, kStaticModuleCount))) {
// Register new chrome
nsCOMPtr<nsIChromeRegistry> chromeReg =
do_GetService("@mozilla.org/chrome/chrome-registry;1");

Просмотреть файл

@ -23,6 +23,7 @@
* Contributor(s):
* Christopher Seawood <cls@seawood.org>
* Chris Waterson <waterson@netscape.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -38,117 +39,73 @@
*
* ***** END LICENSE BLOCK ***** */
#line 26 "nsStaticComponents.cpp.in"
#define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
#include "nsIGenericFactory.h"
#include "nsStaticComponent.h"
#include "nsXPCOM.h"
#include "nsStaticComponents.h"
#include "nsMemory.h"
/**
* Construct a unique NSGetModule entry point for a generic module.
*/
#define NSGETMODULE(_name) _name##_NSGetmodule
#define NSGETMODULE(_name) _name##_NSGetModule
#define MODULES \
MODULE(xpcomObsoleteModule) \
MODULE(nsI18nModule) \
MODULE(nsUConvModule) \
MODULE(nsJarModule) \
MODULE(xpconnect) \
MODULE(necko_core_and_primary_protocols) \
MODULE(necko_secondary_protocols) \
MODULE(nsPrefModule) \
MODULE(nsCJVMManagerModule) \
MODULE(nsSecurityManagerModule) \
MODULE(nsChromeModule) \
MODULE(nsRDFModule) \
MODULE(nsParserModule) \
MODULE(nsGfxMacModule) \
MODULE(nsImageLib2Module) \
MODULE(nsPluginModule) \
MODULE(nsWidgetMacModule) \
MODULE(nsLayoutModule) \
MODULE(nsMorkModule) \
MODULE(docshell_provider) \
MODULE(embedcomponents) \
MODULE(Browser_Embedding_Module) \
MODULE(nsEditorModule) \
MODULE(nsTransactionManagerModule) \
MODULE(application) \
MODULE(nsCookieModule) \
MODULE(nsXMLExtrasModule) \
MODULE(nsUniversalCharDetModule) \
MODULE(nsTypeAheadFind) \
MODULE(TransformiixModule) \
MODULE(nsPermissionsModule) \
MODULE(nsComposerModule) \
MODULE(BOOT) \
MODULE(NSS) \
/* end of list */
/**
* Declare an NSGetModule() routine for a generic module.
* Declare the NSGetModule() routine for each module
*/
#define DECL_NSGETMODULE(_name) \
extern nsModuleInfo NSMODULEINFO(_name); \
extern "C" NS_EXPORT nsresult \
NSGETMODULE(_name) (nsIComponentManager* aCompMgr, \
nsIFile* aLocation, \
nsIModule** aResult) \
{ \
return NS_NewGenericModule2(&NSMODULEINFO(_name), aResult);\
}
#define MODULE(_name) \
NSGETMODULE_ENTRY_POINT(_name) (nsIComponentManager*, nsIFile*, nsIModule**);
// NSGetModule entry points
DECL_NSGETMODULE(xpcomObsoleteModule)
DECL_NSGETMODULE(nsI18nModule)
DECL_NSGETMODULE(nsUConvModule)
DECL_NSGETMODULE(nsJarModule)
DECL_NSGETMODULE(xpconnect)
DECL_NSGETMODULE(necko_core_and_primary_protocols)
DECL_NSGETMODULE(necko_secondary_protocols)
DECL_NSGETMODULE(nsPrefModule)
DECL_NSGETMODULE(nsCJVMManagerModule)
DECL_NSGETMODULE(nsSecurityManagerModule)
DECL_NSGETMODULE(nsChromeModule)
DECL_NSGETMODULE(nsRDFModule)
DECL_NSGETMODULE(nsParserModule)
DECL_NSGETMODULE(nsGfxMacModule)
DECL_NSGETMODULE(nsImageLib2Module)
DECL_NSGETMODULE(nsPluginModule)
DECL_NSGETMODULE(nsWidgetMacModule)
DECL_NSGETMODULE(nsLayoutModule)
DECL_NSGETMODULE(nsMorkModule)
DECL_NSGETMODULE(docshell_provider)
DECL_NSGETMODULE(embedcomponents)
DECL_NSGETMODULE(Browser_Embedding_Module)
DECL_NSGETMODULE(nsEditorModule)
DECL_NSGETMODULE(nsTransactionManagerModule)
DECL_NSGETMODULE(application)
DECL_NSGETMODULE(nsCookieModule)
DECL_NSGETMODULE(nsXMLExtrasModule)
DECL_NSGETMODULE(nsUniversalCharDetModule)
DECL_NSGETMODULE(nsTypeAheadFind)
DECL_NSGETMODULE(TransformiixModule)
DECL_NSGETMODULE(nsPermissionsModule)
DECL_NSGETMODULE(nsComposerModule)
DECL_NSGETMODULE(BOOT)
DECL_NSGETMODULE(NSS)
#line 52 "nsStaticComponents.cpp.in"
MODULES
#undef MODULE
#define MODULE(_name) { #_name, NSGETMODULE(_name) },
/**
* The nsStaticModuleInfo
*/
static nsStaticModuleInfo gStaticModuleInfo[] = {
#define MODULE(_name) { (#_name), NSGETMODULE(_name) }
MODULE(xpcomObsoleteModule),
MODULE(nsI18nModule),
MODULE(nsUConvModule),
MODULE(nsJarModule),
MODULE(xpconnect),
MODULE(necko_core_and_primary_protocols),
MODULE(necko_secondary_protocols),
MODULE(nsPrefModule),
MODULE(nsCJVMManagerModule),
MODULE(nsSecurityManagerModule),
MODULE(nsChromeModule),
MODULE(nsRDFModule),
MODULE(nsParserModule),
MODULE(nsGfxMacModule),
MODULE(nsImageLib2Module),
MODULE(nsPluginModule),
MODULE(nsWidgetMacModule),
MODULE(nsLayoutModule),
MODULE(nsMorkModule),
MODULE(docshell_provider),
MODULE(embedcomponents),
MODULE(Browser_Embedding_Module),
MODULE(nsEditorModule),
MODULE(nsTransactionManagerModule),
MODULE(application),
MODULE(nsCookieModule),
MODULE(nsXMLExtrasModule),
MODULE(nsUniversalCharDetModule),
MODULE(nsTypeAheadFind),
MODULE(TransformiixModule),
MODULE(nsPermissionsModule),
MODULE(nsComposerModule),
MODULE(BOOT),
MODULE(NSS),
#line 60 "nsStaticComponents.cpp.in"
static nsStaticModuleInfo const gStaticModuleInfo[] = {
MODULES
};
/**
* Our NSGetStaticModuleInfoFunc
*/
nsresult
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count)
{
*info = gStaticModuleInfo;
*count = sizeof(gStaticModuleInfo) / sizeof(gStaticModuleInfo[0]);
return NS_OK;
}
nsStaticModuleInfo const *const kPStaticModules = gStaticModuleInfo;
PRUint32 const kStaticModuleCount = NS_ARRAY_LENGTH(gStaticModuleInfo);

Просмотреть файл

@ -55,12 +55,11 @@
#include "AppDirServiceProvider.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIRegistry.h"
#include "nsStaticComponents.h"
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#ifndef _BUILD_STATIC_BIN
nsStaticModuleInfo const *const kPStaticModules = nsnull;
PRUint32 const kStaticModuleCount = 0;
#endif
// This is an arbitrary version stamp that gets written to the prefs file.
@ -215,11 +214,6 @@ static BOOL gMadePrefManager;
- (BOOL)initMozillaPrefs
{
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
nsresult rv;
NSString *path = [[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent];
@ -249,7 +243,8 @@ static BOOL gMadePrefManager;
if (!provider) return NO;
nsCOMPtr<nsIDirectoryServiceProvider> dirProvider = (nsIDirectoryServiceProvider*)provider;
rv = NS_InitEmbedding(binDir, dirProvider);
rv = NS_InitEmbedding(binDir, dirProvider,
kPStaticModules, kStaticModuleCount);
if (NS_FAILED(rv)) {
NSLog(@"Embedding init failed.");
return NO;

Просмотреть файл

@ -102,7 +102,11 @@ ifeq ($(OS_CONFIG),SunOS4.1)
NSPR_CFLAGS += -I$(srcdir)/../nsprpub/pr/include/md
endif
HEADERS = nsBuildID.h $(DEPTH)/mozilla-config.h
HEADERS = \
nsBuildID.h \
$(DEPTH)/mozilla-config.h \
$(srcdir)/nsStaticComponents.h \
$(NULL)
export:: $(TARGETS) $(HEADERS)
$(INSTALL) $(IFLAGS1) $(HEADERS) $(DIST)/include

Просмотреть файл

@ -104,7 +104,6 @@ MOZ_PLAINTEXT_EDITOR_ONLY = @MOZ_PLAINTEXT_EDITOR_ONLY@
MOZ_COMPOSER = @MOZ_COMPOSER@
BUILD_SHARED_LIBS = @BUILD_SHARED_LIBS@
BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
MOZ_STATIC_COMPONENT_LOADER = @MOZ_STATIC_COMPONENT_LOADER@
MOZ_STATIC_COMPONENT_LIBS = @MOZ_STATIC_COMPONENT_LIBS@
MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
ENABLE_TESTS = @ENABLE_TESTS@

Просмотреть файл

@ -64,7 +64,7 @@ $nofilelocks = 1 if defined($::opt_l);
$file = shift;
undef @entrylist;
while ($entry = shift) {
while (defined($entry = shift)) {
push @entrylist, $entry;
}

Просмотреть файл

@ -52,7 +52,7 @@ STATIC_EXTRA_LIBS += \
$(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS)))) \
$(NULL)
STATIC_COMPONENT_LIST := $(shell cat $(FINAL_LINK_COMP_NAMES))
STATIC_COMPONENT_LIST = $(shell cat $(FINAL_LINK_COMP_NAMES))
STATIC_EXTRA_DEPS += $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
@ -132,3 +132,4 @@ ifeq ($(OS_ARCH),AIX)
STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,odm cfg)
endif
LOCAL_INCLUDES += -I$(topsrcdir)/config

Просмотреть файл

@ -5,14 +5,15 @@ else
_TARGET = $@
endif
nsStaticComponents.cpp: $(MOZILLA_DIR)/xpfe/bootstrap/nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_LINK_COMP_NAMES)
$(warning FINAL_LINK_COMP_NAMES = $(FINAL_LINK_COMP_NAMES))
$(warning FINAL_LINK_COMPS = $(FINAL_LINK_COMPS))
nsStaticComponents.cpp: $(topsrcdir)/config/nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_LINK_COMP_NAMES)
rm -f $@
cat $< | \
sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(STATIC_COMPONENT_LIST),DECL_NSGETMODULE($(m)))|" | \
sed -e "s|%MODULE_LIST%|$(foreach m, $(STATIC_COMPONENT_LIST),MODULE($(m)),)|" \
sed -e "s|%MODULE_LIST%|$(foreach m, $(STATIC_COMPONENT_LIST),MODULE($(m)))|" \
> $(_TARGET)
ifeq ($(OS_ARCH),IRIX)
LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=80
endif

Просмотреть файл

@ -29,7 +29,7 @@ dnl Dan Mosedale <dmose@mozilla.org>
dnl LDAP support
dnl Seth Spitzer <sspitzer@netscape.com>
dnl xpctools support
dnl Benjamin Smedberg <bsmedberg@covad.net>
dnl Benjamin Smedberg <benjamin@smedbergs.us>
dnl Howard Chu <hyc@symas.com>
dnl MSYS support
dnl Mark Mentovai <mark@moxienet.com>:
@ -5968,19 +5968,6 @@ else
XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS"
fi
dnl ========================================================
dnl static component loader
dnl ========================================================
MOZ_STATIC_COMPONENT_LOADER=1
MOZ_ARG_DISABLE_BOOL(static-component-loader,
[ --disable-static-component-loader
Disable the static component loader],
MOZ_STATIC_COMPONENT_LOADER=)
if test -n "$MOZ_STATIC_COMPONENT_LOADER"; then
AC_DEFINE(ENABLE_STATIC_COMPONENT_LOADER)
fi
dnl ========================================================
dnl =
dnl = Standalone module options
@ -6599,7 +6586,6 @@ AC_SUBST(MOZ_ENABLE_XINERAMA)
AC_SUBST(XPCOM_USE_LEA)
AC_SUBST(BUILD_SHARED_LIBS)
AC_SUBST(BUILD_STATIC_LIBS)
AC_SUBST(MOZ_STATIC_COMPONENT_LOADER)
AC_SUBST(MOZ_STATIC_COMPONENT_LIBS)
AC_SUBST(MOZ_ENABLE_LIBXUL)
AC_SUBST(ENABLE_TESTS)
@ -6922,7 +6908,6 @@ HAVE_MBRTOWC
HAVE_SYS_MOUNT_H
HAVE_SYS_VFS_H
HAVE_WCRTOMB
ENABLE_STATIC_COMPONENT_LOADER
MOZ_V1_STRING_ABI
"

Просмотреть файл

@ -82,8 +82,11 @@ static XPCOMCleanupHack sXPCOMCleanupHack;
#endif
nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
nsIDirectoryServiceProvider *appFileLocProvider)
NS_METHOD
NS_InitEmbedding(nsILocalFile *mozBinDirectory,
nsIDirectoryServiceProvider *appFileLocProvider,
nsStaticModuleInfo const *aStaticComponents,
PRUint32 aStaticComponentCount)
{
nsresult rv;
@ -99,7 +102,8 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
#endif
{
// Initialise XPCOM
rv = NS_InitXPCOM2(&sServiceManager, mozBinDirectory, appFileLocProvider);
rv = NS_InitXPCOM3(&sServiceManager, mozBinDirectory, appFileLocProvider,
aStaticComponents, aStaticComponentCount);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
@ -193,7 +197,8 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
return NS_OK;
}
nsresult NS_TermEmbedding()
NS_METHOD
NS_TermEmbedding()
{
// Reentrant calls to this method do nothing except decrement a counter
if (sInitCounter > 1)

Просмотреть файл

@ -22,6 +22,7 @@
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -40,6 +41,8 @@
#ifndef NSEMBEDAPI_H
#define NSEMBEDAPI_H
#include "nscore.h"
#include "nsXPCOM.h"
#include "nsILocalFile.h"
#include "nsIDirectoryService.h"
@ -49,8 +52,6 @@
*/
/**
* @fn nsresult NS_InitEmbedding(nsILocalFile *aMozBinDirectory, nsIDirectoryServiceProvider *aAppFileLocProvider)
*
* Initialises the Gecko embedding layer. You <I>must</I>
* call this method before proceeding to use Gecko. This function ensures
* XPCOM is started, creates the component registry if necessary and
@ -71,6 +72,10 @@
* to Gecko where to find profiles, the component
* registry preferences and so on; or use
* <CODE>nsnull</CODE> for the default behaviour.
* @param aStaticComponents An array of static components (see NS_InitXPCOM3).
* may be null.
* @param aStaticComponentCount Number of static components in the
* aStaticComponents array.
*
* @see NS_NewLocalFile
* @see nsILocalFile
@ -80,13 +85,14 @@
* other error codes indicate a failure during initialisation.
*
*/
extern "C" nsresult NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
nsIDirectoryServiceProvider *aAppFileLocProvider);
extern "C" NS_HIDDEN NS_METHOD
NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
nsIDirectoryServiceProvider *aAppFileLocProvider,
nsStaticModuleInfo const *aStaticComponents = nsnull,
PRUint32 aStaticComponentCount = 0);
/**
* @fn nsresult NS_TermEmbedding()
*
* Terminates the Gecko embedding layer. Call this function during shutdown to
* ensure that global services are unloaded, files are closed and
* XPCOM is shutdown.
@ -98,7 +104,8 @@ extern "C" nsresult NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
*
* @return NS_OK
*/
extern "C" nsresult NS_TermEmbedding();
extern "C" NS_HIDDEN NS_METHOD
NS_TermEmbedding();
/*---------------------------------------------------------------------------*/
/* Event processing APIs. The native OS dependencies mean you must be */
@ -156,7 +163,8 @@ typedef QMSG nsEmbedNativeEvent;
*
* @return NS_OK
*/
extern "C" nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled);
extern "C" NS_HIDDEN NS_METHOD
NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled);
#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */

Просмотреть файл

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -36,19 +36,19 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsEmbedAPI.h"
#ifndef OS2
#error This file is for OS/2!
#endif
#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
{
aWasHandled = PR_FALSE;
return NS_OK;
}
#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */
#include "nsEmbedAPI.h"
#ifndef OS2
#error This file is for OS/2!
#endif
#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
NS_METHOD NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
{
aWasHandled = PR_FALSE;
return NS_OK;
}
#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */

Просмотреть файл

@ -45,7 +45,7 @@
#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
NS_METHOD NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
{
aWasHandled = PR_FALSE;
return NS_OK;

Просмотреть файл

@ -1,88 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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
* Netscape Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Christopher Seawood <cls@seawood.org>
* Chris Waterson <waterson@netscape.com>
*
* 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 ***** */
#line 26 "nsStaticComponents.cpp.in"
#define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
#include "nsIGenericFactory.h"
#include "nsStaticComponent.h"
/**
* Construct a unique NSGetModule entry point for a generic module.
*/
#define NSGETMODULE(_name) _name##_NSGetmodule
/**
* Declare an NSGetModule() routine for a generic module.
*/
#define DECL_NSGETMODULE(_name) \
extern nsModuleInfo NSMODULEINFO(_name); \
extern "C" NS_EXPORT nsresult \
NSGETMODULE(_name) (nsIComponentManager* aCompMgr, \
nsIFile* aLocation, \
nsIModule** aResult) \
{ \
return NS_NewGenericModule2(&NSMODULEINFO(_name), aResult);\
}
// NSGetModule entry points
%DECL_NSGETMODULES%
#line 52 "nsStaticComponents.cpp.in"
/**
* The nsStaticModuleInfo
*/
static nsStaticModuleInfo gStaticModuleInfo[] = {
#define MODULE(_name) { (#_name), NSGETMODULE(_name) }
%MODULE_LIST%
#line 60 "nsStaticComponents.cpp.in"
};
/**
* Our NSGetStaticModuleInfoFunc
*/
nsresult
gtk_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count)
{
*info = gStaticModuleInfo;
*count = sizeof(gStaticModuleInfo) / sizeof(gStaticModuleInfo[0]);
return NS_OK;
}

Просмотреть файл

@ -75,6 +75,7 @@
// app component registration
#include <nsIGenericFactory.h>
#include <nsIComponentRegistrar.h>
#include "nsStaticComponents.h"
// all of our local includes
#include "EmbedPrivate.h"
@ -95,10 +96,9 @@
#include "nsIDOMDocument.h"
#endif
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
gtk_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#ifndef _BUILD_STATIC_BIN
nsStaticModuleInfo const *const kPStaticModules = nsnull;
PRUint32 const kStaticModuleCount = 0;
#endif
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
@ -495,12 +495,7 @@ EmbedPrivate::PushStartup(void)
return;
}
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = gtk_getModuleInfo;
#endif
rv = NS_InitEmbedding(binDir, sAppFileLocProvider);
rv = NS_InitEmbedding(binDir, sAppFileLocProvider, kPStaticModules, kStaticModuleCount);
if (NS_FAILED(rv))
return;

Просмотреть файл

@ -86,39 +86,23 @@ CPPSRCS += \
GtkPromptService.cpp
endif
# Include config.mk early for any overrides of BUILD_STATIC_LIBS
include $(topsrcdir)/config/config.mk
# Force applications to be built non-statically
# when building the mozcomps meta component
ifneq (,$(filter mozcomps,$(MOZ_META_COMPONENTS)))
BUILD_STATIC_LIBS=
BUILD_SHARED_LIBS=1
endif
# Save the "real" FINAL_LINK_COMP* before we override them
FAT_FINAL_LINK_COMPS := $(FINAL_LINK_COMPS)
FAT_FINAL_LINK_COMP_NAMES := $(FINAL_LINK_COMP_NAMES)
ifdef BUILD_STATIC_LIBS
# Static build stuff
DEFINES += -D_BUILD_STATIC_BIN=1
CPPSRCS += EmbedComponents.cpp
XP_LIBS += \
$(PNG_LIBS) \
$(JPEG_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_GDK_PIXBUF_LIBS) \
$(MOZ_XIE_LIBS) \
$(MOZ_XPRINT_LDFLAGS) \
$(NULL)
ifdef MOZ_PSM
XP_LIBS += \
$(NSS_LIBS) \
$(NULL)
include $(topsrcdir)/config/static-config.mk
DEFINES += $(STATIC_DEFINES)
CPPSRCS += $(STATIC_CPPSRCS)
EXTRA_DSO_LDOPTS += $(STATIC_EXTRA_LIBS)
EXTRA_DEPS += \
$(STATIC_EXTRA_DEPS) \
$(NULL)
endif
endif
SHARED_LIBRARY_LIBS= \
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
$(DIST)/lib/libprofdirserviceprovider_s.$(LIB_SUFFIX) \
$(NULL)
@ -142,25 +126,7 @@ endif
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS) $(MOZ_GTK2_LIBS)
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
DEFINES += -D_IMPL_GTKMOZEMBED
ifdef BUILD_STATIC_LIBS
# This is so sick! We'll work backwards from the embedding manifest to
# produce the set of components that we need to link in to a
# ``minimal'' embedding harness.
@ -170,20 +136,17 @@ else
EMBED_MANIFEST=$(topsrcdir)/embedding/config/basebrowser-unix
endif
ifdef MOZ_FAT_EMBED
EMBED_LINK_COMPS=$(FINAL_LINK_COMPS)
EMBED_LINK_COMP_NAMES=$(FINAL_LINK_COMP_NAMES)
else
EMBED_LINK_COMPS=embed-link-comps
EMBED_LINK_COMP_NAMES=embed-link-comp-names
ifndef MOZ_FAT_EMBED
FINAL_LINK_COMPS=embed-link-comps
FINAL_LINK_COMP_NAMES=embed-link-comp-names
endif
# Create a map that we can use to go from library name to component
# symbol. N.B. that this will break if the $(FINAL_LINK_COMP_NAMES)
# and $(FINAL_LINK_COMPS) somehow get out-of-sync and aren't in
# _exactly_ the same order. (Hey, this is a hack!)
components: $(FINAL_LINK_COMPS) $(FINAL_LINK_COMP_NAMES)
paste $(FINAL_LINK_COMPS) $(FINAL_LINK_COMP_NAMES) | sort -k 1,1 > $@
components: $(FAT_FINAL_LINK_COMPS) $(FAT_FINAL_LINK_COMP_NAMES)
paste $(FAT_FINAL_LINK_COMPS) $(FAT_FINAL_LINK_COMP_NAMES) | sort -k 1,1 > $@
# Compute the embedding libs by extracting them from the embedding
# manifest.
@ -210,13 +173,27 @@ embed-link-comps: $(EMBED_MANIFEST) components
embed-link-comp-names: embed-link-comps components
sort embed-link-comps | join -o 2.2 - components > $@
EmbedComponents.cpp: EmbedComponents.cpp.in Makefile Makefile.in $(EMBED_LINK_COMP_NAMES)
cat $< | \
sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(shell cat $(EMBED_LINK_COMP_NAMES)),DECL_NSGETMODULE($(m)))|" | \
sed -e "s|%MODULE_LIST%|$(foreach m, $(shell cat $(EMBED_LINK_COMP_NAMES)),MODULE($(m)),)|" \
> $@
GARBAGE += EmbedComponents.cpp embed-link-comp-names embed-link-comps components
GARBAGE += embed-link-comp-names embed-link-comps components
endif
include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/config/static-rules.mk
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
DEFINES += -D_IMPL_GTKMOZEMBED

Просмотреть файл

@ -66,6 +66,7 @@
#include "WebBrowserChrome.h"
#include "WindowCreator.h"
#include "resource.h"
#include "nsStaticComponents.h"
// Printing header files
#include "nsIPrintSettings.h"
@ -75,13 +76,11 @@
#define MAX_LOADSTRING 100
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#ifndef _BUILD_STATIC_BIN
nsStaticModuleInfo const *const kPStaticModules = nsnull;
PRUint32 const kStaticModuleCount = 0;
#endif
const TCHAR *szWindowClass = _T("WINEMBED");
// Foward declarations of functions included in this code module:
@ -159,13 +158,8 @@ int main(int argc, char *argv[])
LoadString(ghInstanceResources, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
MyRegisterClass(ghInstanceApp);
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
// Init Embedding APIs
NS_InitEmbedding(nsnull, nsnull);
NS_InitEmbedding(nsnull, nsnull, kPStaticModules, kStaticModuleCount);
// Choose the new profile
if (NS_FAILED(StartupProfile()))

Просмотреть файл

@ -268,8 +268,8 @@ ifdef GC_LEAK_DETECTOR
EXTRA_DSO_LIBS += boehm
endif
ifdef NS_TRACE_MALLOC
EXTRA_DSO_LIBS += tracemalloc
ifdef NS_TRACE_MALLOC
EXTRA_DSO_LIBS += tracemalloc
endif
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
@ -277,6 +277,8 @@ EXTRA_DSO_LIBS += macmorefiles_s
EXTRA_DEPS += $(DIST)/lib/$(LIB_PREFIX)macmorefiles_s.$(LIB_SUFFIX)
endif
LOCAL_INCLUDES += -I$(topsrcdir)/config
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS)

Просмотреть файл

@ -41,9 +41,11 @@
#define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
#include "nsIGenericFactory.h"
#include "nsStaticComponent.h"
#include "nsXPCOM.h"
#include "nsStaticComponents.h"
#include "nsMemory.h"
#define NSGETMODULE(_name) _name##_NSGetmodule
#define NSGETMODULE(_name) _name##_NSGetModule
#ifdef MOZ_MATHML
#define MATHML_MODULES MODULE(nsUCvMathModule)
@ -184,6 +186,7 @@
MODULE(nsMorkModule) \
MODULE(nsFindComponent) \
MODULE(application) \
MODULE(Apprunner) \
MODULE(CommandLineModule) \
MODULE(nsToolkitCompsModule) \
XREMOTE_MODULES \
@ -191,36 +194,21 @@
MODULE(JavaScript_Debugger) \
/* end of list */
#define MODULE(_name) \
extern nsModuleInfo NSMODULEINFO(_name); \
extern "C" nsresult \
NSGETMODULE(_name) (nsIComponentManager* aCompMgr, \
nsIFile* aLocation, \
nsIModule** aResult) \
{ return NS_NewGenericModule2(&NSMODULEINFO(_name), aResult); }
#define MODULE(_name) \
NSGETMODULE_ENTRY_POINT(_name) (nsIComponentManager*, nsIFile*, nsIModule**);
XUL_MODULES
#undef MODULE
#define MODULE(_name) { (#_name), NSGETMODULE(_name) },
#define MODULE(_name) { #_name, NSGETMODULE(_name) },
/**
* The nsStaticModuleInfo
*/
static nsStaticModuleInfo gStaticModuleInfo[] = {
static nsStaticModuleInfo const gStaticModuleInfo[] = {
XUL_MODULES
};
/**
* Our NSGetStaticModuleInfoFunc
*/
static nsresult PR_CALLBACK
xul_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count)
{
*info = gStaticModuleInfo;
*count = sizeof(gStaticModuleInfo) / sizeof(gStaticModuleInfo[0]);
return NS_OK;
}
NS_EXPORT NSGetStaticModuleInfoFunc NSGetStaticModuleInfo = &xul_getModuleInfo;
nsStaticModuleInfo const *const kPStaticModules = gStaticModuleInfo;
PRUint32 const kStaticModuleCount = NS_ARRAY_LENGTH(gStaticModuleInfo);

Просмотреть файл

@ -20,6 +20,7 @@
#
# Contributor(s):
# Brian Ryner <bryner@brianryner.com>
# Benjamin Smedberg <benjamin@smedbergs.us>
#
# 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
@ -171,7 +172,20 @@ endif
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += -I$(topsrcdir)/xpfe/bootstrap -I$(srcdir)/../profile/src
ifdef BUILD_STATIC_LIBS
export::
@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMP_NAMES) Apprunner
# embedding/browser/gtk/src/Makefile.in sucks! we need to add an empty line to
# FINAL_LINK_COMPS to keep the two lists in sync :-(
@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMPS) ""
endif
LOCAL_INCLUDES += \
-I$(topsrcdir)/xpfe/bootstrap \
-I$(srcdir)/../profile/src \
-I$(topsrcdir)/config \
$(NULL)
CXXFLAGS += $(TK_CFLAGS)
ifdef BUILD_STATIC_LIBS

Просмотреть файл

@ -40,6 +40,8 @@
* ***** END LICENSE BLOCK ***** */
#define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
#include "nsAppRunner.h"
#include "nsUpdateDriver.h"
#include "nsBuildID.h"
@ -73,6 +75,7 @@
#include "nsIEventQueueService.h"
#include "nsIExtensionManager.h"
#include "nsIFastLoadService.h" // for PLATFORM_FASL_SUFFIX
#include "nsIGenericFactory.h"
#include "nsIIOService.h"
#include "nsIObserverService.h"
#include "nsINativeAppSupport.h"
@ -99,6 +102,7 @@
#include "nsDirectoryServiceUtils.h"
#include "nsEmbedCID.h"
#include "nsNetUtil.h"
#include "nsStaticComponents.h"
#include "nsXPCOM.h"
#include "nsXPIDLString.h"
#include "nsXPFEComponentsCID.h"
@ -232,12 +236,6 @@ extern "C" {
}
#endif
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
extern void InstallUnixSignalHandlers(const char *ProgramName);
#endif
@ -365,20 +363,17 @@ PRBool gSafeMode = PR_FALSE;
* singleton.
*/
class nsXULAppInfo : public nsIXULAppInfo,
public nsIXULRuntime,
public nsIFactory
public nsIXULRuntime
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIXULAPPINFO
NS_DECL_NSIXULRUNTIME
NS_DECL_NSIFACTORY
};
NS_IMPL_QUERY_INTERFACE3(nsXULAppInfo,
NS_IMPL_QUERY_INTERFACE2(nsXULAppInfo,
nsIXULAppInfo,
nsIXULRuntime,
nsIFactory)
nsIXULRuntime)
NS_IMETHODIMP_(nsrefcnt)
nsXULAppInfo::AddRef()
@ -487,23 +482,16 @@ nsXULAppInfo::GetXPCOMABI(nsACString& aResult)
#endif
}
NS_IMETHODIMP
nsXULAppInfo::CreateInstance(nsISupports* aOuter,
REFNSIID aIID,
void** aResult)
static const nsXULAppInfo kAppInfo;
static NS_METHOD AppInfoConstructor(nsISupports* aOuter,
REFNSIID aIID, void **aResult)
{
NS_ENSURE_NO_AGGREGATION(aOuter);
return QueryInterface(aIID, aResult);
return NS_CONST_CAST(nsXULAppInfo*, &kAppInfo)->
QueryInterface(aIID, aResult);
}
NS_IMETHODIMP
nsXULAppInfo::LockFactory(PRBool aLock)
{
return NS_OK;
}
static const nsXULAppInfo kAppInfo;
PRBool gLogConsoleErrors
#ifdef DEBUG
= PR_TRUE;
@ -562,6 +550,30 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup()
static const nsCID kAppInfoCID =
{ 0x95d89e3e, 0xa169, 0x41a3, { 0x8e, 0x56, 0x71, 0x99, 0x78, 0xe1, 0x5b, 0x12 } };
static nsModuleComponentInfo kComponents[] =
{
{
"nsXULAppInfo",
kAppInfoCID,
XULAPPINFO_SERVICE_CONTRACTID,
AppInfoConstructor
}
};
NS_IMPL_NSGETMODULE(Apprunner, kComponents)
#if !defined(_BUILD_STATIC_BIN) && !defined(MOZ_ENABLE_LIBXUL)
static nsStaticModuleInfo const kXREStaticModules[] =
{
{
"Apprunner",
Apprunner_NSGetModule
}
};
nsStaticModuleInfo const *const kPStaticModules = kXREStaticModules;
PRUint32 const kStaticModuleCount = NS_ARRAY_LENGTH(kXREStaticModules);
#endif
nsresult
ScopedXPCOMStartup::Initialize()
@ -569,8 +581,9 @@ ScopedXPCOMStartup::Initialize()
NS_ASSERTION(gDirServiceProvider, "Should not get here!");
nsresult rv;
rv = NS_InitXPCOM2(&mServiceManager, gDirServiceProvider->GetAppDir(),
gDirServiceProvider);
rv = NS_InitXPCOM3(&mServiceManager, gDirServiceProvider->GetAppDir(),
gDirServiceProvider,
kPStaticModules, kStaticModuleCount);
if (NS_FAILED(rv)) {
NS_ERROR("Couldn't start xpcom!");
mServiceManager = nsnull;
@ -579,10 +592,6 @@ ScopedXPCOMStartup::Initialize()
nsCOMPtr<nsIComponentRegistrar> reg =
do_QueryInterface(mServiceManager);
NS_ASSERTION(reg, "Service Manager doesn't QI to Registrar.");
reg->RegisterFactory(kAppInfoCID, "nsXULAppInfo",
XULAPPINFO_SERVICE_CONTRACTID,
NS_CONST_CAST(nsXULAppInfo*,&kAppInfo));
}
return rv;
@ -1819,11 +1828,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
ScopedFPHandler handler;
#endif /* XP_OS2 */
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
if (CheckArg("safe-mode"))
gSafeMode = PR_TRUE;

Просмотреть файл

@ -58,6 +58,7 @@
class nsACString;
struct nsXREAppData;
struct nsStaticModuleInfo;
class nsINativeAppSupport;
class nsICmdLineService;

Просмотреть файл

@ -227,7 +227,6 @@ endif # BUILD_STATIC_LIBS
include $(topsrcdir)/config/rules.mk
ifdef BUILD_STATIC_LIBS
include $(topsrcdir)/config/static-rules.mk
endif # BUILD_STATIC_LIBS

Просмотреть файл

@ -69,6 +69,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsGUIEvent.h"
#include "nsStaticComponents.h"
// Needed for Dialog GUI
#include "nsICheckButton.h"
@ -130,13 +131,6 @@ static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
#define DEFAULT_HEIGHT 400
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#endif
nsViewerApp::nsViewerApp()
{
char * text = PR_GetEnv("NGLAYOUT_HOME");
@ -205,13 +199,20 @@ nsViewerApp::Destroy()
NS_IF_RELEASE(mPrefService);
}
#ifndef _BUILD_STATIC_BIN
nsStaticModuleInfo const *const kPStaticModules = nsnull;
PRUint32 const kStaticModuleCount = 0;
#endif
nsresult
nsViewerApp::SetupRegistry()
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servManager;
NS_GetServiceManager(getter_AddRefs(servManager));
rv = NS_InitXPCOM3(getter_AddRefs(servManager), nsnull, nsnull,
kPStaticModules, kStaticModuleCount);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servManager);
NS_ASSERTION(registrar, "No nsIComponentRegistrar from get service. see dougt");
rv = registrar->AutoRegister(nsnull);
@ -239,11 +240,6 @@ nsViewerApp::Initialize(int argc, char** argv)
{
nsresult rv;
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
rv = SetupRegistry();
if (NS_FAILED(rv)) {
return rv;

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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"),
@ -41,6 +42,7 @@
// Map frozen functions to private symbol names if not using strict API.
#ifdef MOZILLA_INTERNAL_API
# define NS_InitXPCOM2 NS_InitXPCOM2_P
# define NS_InitXPCOM3 NS_InitXPCOM3_P
# define NS_ShutdownXPCOM NS_ShutdownXPCOM_P
# define NS_GetServiceManager NS_GetServiceManager_P
# define NS_GetComponentManager NS_GetComponentManager_P
@ -61,6 +63,7 @@
class nsAString;
class nsACString;
class nsIModule;
class nsIComponentManager;
class nsIComponentRegistrar;
class nsIServiceManager;
@ -72,9 +75,19 @@ class nsIDebug;
class nsITraceRefcnt;
/**
* Initialises XPCOM. You must call this method before proceeding
* to use xpcom. The one exception is that you may call
* NS_NewLocalFile to create a nsIFile.
* Every XPCOM component implements this function signature, which is the
* only entrypoint XPCOM uses to the function.
*
* @status FROZEN
*/
typedef nsresult (PR_CALLBACK *nsGetModuleProc)(nsIComponentManager *aCompMgr,
nsIFile* location,
nsIModule** return_cobj);
/**
* Initialises XPCOM. You must call one of the NS_InitXPCOM methods
* before proceeding to use xpcom. The one exception is that you may
* call NS_NewLocalFile to create a nsIFile.
*
* @status FROZEN
*
@ -100,22 +113,81 @@ class nsITraceRefcnt;
* @see nsIDirectoryServiceProvider
*
* @return NS_OK for success;
* NS_ERROR_NOT_INITIALIZED if static globals were not initialied, which
* can happen if XPCOM is reloaded, but did not completly shutdown.
* other error codes indicate a failure during initialisation.
*
* NS_ERROR_NOT_INITIALIZED if static globals were not initialized,
* which can happen if XPCOM is reloaded, but did not completly
* shutdown. Other error codes indicate a failure during
* initialisation.
*/
extern "C" NS_COM nsresult
NS_InitXPCOM2(nsIServiceManager* *result,
nsIFile* binDirectory,
nsIDirectoryServiceProvider* appFileLocationProvider);
/**
* Some clients of XPCOM have statically linked components (not dynamically
* loaded component DLLs), which can be passed to NS_InitXPCOM3 using this
* structure.
*
* @status FROZEN
*/
struct nsStaticModuleInfo {
const char *name;
nsGetModuleProc getModule;
};
/**
* Initialises XPCOM with static components. You must call one of the
* NS_InitXPCOM methods before proceeding to use xpcom. The one
* exception is that you may call NS_NewLocalFile to create a nsIFile.
*
* @status FROZEN
*
* @note Use <CODE>NS_NewLocalFile</CODE> or <CODE>NS_NewNativeLocalFile</CODE>
* to create the file object you supply as the bin directory path in this
* call. The function may be safely called before the rest of XPCOM or
* embedding has been initialised.
*
* @param result The service manager. You may pass null.
*
* @param binDirectory The directory containing the component
* registry and runtime libraries;
* or use <CODE>nsnull</CODE> to use the working
* directory.
*
* @param appFileLocationProvider The object to be used by Gecko that specifies
* to Gecko where to find profiles, the component
* registry preferences and so on; or use
* <CODE>nsnull</CODE> for the default behaviour.
*
* @param staticComponents An array of static components. Passing null is
* Equivalent to NS_InitXPCOM2. These static components
* will be registered before any other components.
* @param componentCount Number of elements in staticComponents
*
* @see NS_NewLocalFile
* @see nsILocalFile
* @see nsIDirectoryServiceProvider
*
* @return NS_OK for success;
* NS_ERROR_NOT_INITIALIZED if static globals were not initialized,
* which can happen if XPCOM is reloaded, but did not completly
* shutdown. Other error codes indicate a failure during
* initialisation.
*/
extern "C" NS_COM nsresult
NS_InitXPCOM3(nsIServiceManager* *result,
nsIFile* binDirectory,
nsIDirectoryServiceProvider* appFileLocationProvider,
nsStaticModuleInfo const *staticComponents,
PRUint32 componentCount);
/**
* Shutdown XPCOM. You must call this method after you are finished
* using xpcom.
*
* @status FROZEN
*
* @param servMgr The service manager which was returned by NS_InitXPCOM2.
* @param servMgr The service manager which was returned by NS_InitXPCOM.
* This will release servMgr. You may pass null.
*
* @return NS_OK for success;
@ -180,7 +252,7 @@ NS_GetMemoryManager(nsIMemory* *result);
/**
* Public Method to create an instance of a nsILocalFile. This function
* may be called prior to NS_InitXPCOM2.
* may be called prior to NS_InitXPCOM.
*
* @status FROZEN
*
@ -276,7 +348,7 @@ NS_Free(void* ptr);
/**
* A category which is read after component registration but before
* NS_InitXPCOM2 returns. Each category entry is treated as the contractID of
* NS_InitXPCOM returns. Each category entry is treated as the contractID of
* a service: each service is instantiated, and if it implements nsIObserver
* the nsIObserver.observe method is called with the "xpcom-startup" topic.
*

Просмотреть файл

@ -51,6 +51,7 @@
class nsStringContainer;
class nsCStringContainer;
class nsIComponentLoader;
/**
* Private Method to register an exit routine. This method
@ -84,6 +85,7 @@ NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
// PUBLIC
typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
typedef nsresult (* Init3Func)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider, nsStaticModuleInfo const *staticComponents, PRUint32 componentCount);
typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr);
typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result);
typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result);
@ -172,7 +174,7 @@ typedef struct XPCOMFunctions{
CStringContainerInit2Func cstringContainerInit2;
StringGetMutableDataFunc stringGetMutableData;
CStringGetMutableDataFunc cstringGetMutableData;
Init3Func init3;
} XPCOMFunctions;
typedef nsresult (PR_CALLBACK *GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
@ -249,6 +251,9 @@ NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
#endif
#endif
nsresult
NewStaticComponentLoader(nsStaticModuleInfo const *aStaticModules,
PRUint32 aStaticModuleCount,
nsIComponentLoader **retval);
#endif

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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"),
@ -432,12 +433,21 @@ nsresult NS_COM NS_GetTraceRefcnt(nsITraceRefcnt** result)
nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
nsIFile* binDirectory)
{
return NS_InitXPCOM2(result, binDirectory, nsnull);
return NS_InitXPCOM3(result, binDirectory, nsnull, nsnull, 0);
}
nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
nsIFile* binDirectory,
nsIDirectoryServiceProvider* appFileLocationProvider)
{
return NS_InitXPCOM3(result, binDirectory, appFileLocationProvider, nsnull, 0);
}
nsresult NS_COM NS_InitXPCOM3(nsIServiceManager* *result,
nsIFile* binDirectory,
nsIDirectoryServiceProvider* appFileLocationProvider,
nsStaticModuleInfo const *staticComponents,
PRUint32 componentCount)
{
nsresult rv = NS_OK;
@ -516,7 +526,7 @@ nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
if (NS_FAILED(rv)) return rv;
}
rv = compMgr->Init();
rv = compMgr->Init(staticComponents, componentCount);
if (NS_FAILED(rv))
{
NS_RELEASE(compMgr);

Просмотреть файл

@ -55,20 +55,16 @@ CPPSRCS = \
nsCategoryManager.cpp \
nsComponentManager.cpp \
nsNativeComponentLoader.cpp \
nsStaticComponentLoader.cpp \
nsServiceManagerObsolete.cpp \
xcDll.cpp \
$(NULL)
ifdef MOZ_STATIC_COMPONENT_LOADER
CPPSRCS += nsStaticComponentLoader.cpp
endif
EXPORTS = \
nsCategoryManagerUtils.h \
nsIServiceManagerObsolete.h \
nsModule.h \
nsNativeComponentLoader.h \
nsStaticComponent.h \
nsObsoleteModuleLoading.h \
xcDll.h \
$(NULL)
@ -91,7 +87,7 @@ SDK_XPIDLSRCS = \
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
LOCAL_INCLUDES = -I$(srcdir)/../base -I$(srcdir)/../thread -I$(srcdir)/../ds -I..
LOCAL_INCLUDES = -I$(srcdir)/../base -I$(srcdir)/../thread -I$(srcdir)/../ds -I$(srcdir)/../build -I..
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1

Просмотреть файл

@ -72,6 +72,7 @@
#include "nsIObserverService.h"
#include "nsISimpleEnumerator.h"
#include "nsXPCOM.h"
#include "nsXPCOMPrivate.h"
#include "nsISupportsPrimitives.h"
#include "nsLocalFile.h"
#include "nsNativeComponentLoader.h"
@ -712,9 +713,7 @@ nsComponentManagerImpl::nsComponentManagerImpl()
:
mMon(NULL),
mNativeComponentLoader(0),
#ifdef ENABLE_STATIC_COMPONENT_LOADER
mStaticComponentLoader(0),
#endif
mShuttingDown(NS_SHUTDOWN_NEVERHAPPENED),
mLoaderData(nsnull),
mRegistryDirty(PR_FALSE)
@ -723,7 +722,8 @@ nsComponentManagerImpl::nsComponentManagerImpl()
mContractIDs.ops = nsnull;
}
nsresult nsComponentManagerImpl::Init(void)
nsresult nsComponentManagerImpl::Init(nsStaticModuleInfo const *aStaticModules,
PRUint32 aStaticModuleCount)
{
PR_ASSERT(mShuttingDown != NS_SHUTDOWN_INPROGRESS);
if (mShuttingDown == NS_SHUTDOWN_INPROGRESS)
@ -800,12 +800,12 @@ nsresult nsComponentManagerImpl::Init(void)
NS_ADDREF(mLoaderData[mNLoaderData].loader);
mNLoaderData++;
#ifdef ENABLE_STATIC_COMPONENT_LOADER
if (mStaticComponentLoader == nsnull) {
extern nsresult NS_NewStaticComponentLoader(nsIComponentLoader **);
NS_NewStaticComponentLoader(&mStaticComponentLoader);
if (!mStaticComponentLoader)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = NewStaticComponentLoader(aStaticModules,
aStaticModuleCount,
&mStaticComponentLoader);
if (NS_FAILED(rv))
return rv;
}
mLoaderData[mNLoaderData].type = PL_strdup(staticComponentType);
@ -817,7 +817,6 @@ nsresult nsComponentManagerImpl::Init(void)
/* Init the static loader */
mStaticComponentLoader->Init(this, nsnull);
}
#endif
GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(mComponentsDir));
if (!mComponentsDir)
return NS_ERROR_OUT_OF_MEMORY;
@ -914,9 +913,7 @@ nsresult nsComponentManagerImpl::Shutdown(void)
// we have an extra reference on this one, which is probably a good thing
NS_IF_RELEASE(mNativeComponentLoader);
#ifdef ENABLE_STATIC_COMPONENT_LOADER
NS_IF_RELEASE(mStaticComponentLoader);
#endif
mShuttingDown = NS_SHUTDOWN_COMPLETE;
@ -3185,14 +3182,14 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when,
nsnull,
"start");
/* do the native loader first, so we can find other loaders */
rv = mNativeComponentLoader->AutoRegisterComponents((PRInt32)when, dir);
if (NS_FAILED(rv)) return rv;
#ifdef ENABLE_STATIC_COMPONENT_LOADER
/* Load static components first, then the native component loader,
* which can find other loaders.
*/
rv = mStaticComponentLoader->AutoRegisterComponents((PRInt32)when, inDirSpec);
if (NS_FAILED(rv)) return rv;
#endif
rv = mNativeComponentLoader->AutoRegisterComponents((PRInt32)when, dir);
if (NS_FAILED(rv)) return rv;
/* do InterfaceInfoManager after native loader so it can use components. */
rv = iim->AutoRegisterInterfaces();

Просмотреть файл

@ -151,7 +151,8 @@ public:
nsComponentManagerImpl();
static nsComponentManagerImpl* gComponentManager;
nsresult Init(void);
nsresult Init(nsStaticModuleInfo const *aStaticModules,
PRUint32 aStaticModuleCount);
nsresult WritePersistentRegistry();
nsresult ReadPersistentRegistry();
@ -215,9 +216,7 @@ public:
PRMonitor* mMon;
nsNativeComponentLoader *mNativeComponentLoader;
#ifdef ENABLE_STATIC_COMPONENT_LOADER
nsIComponentLoader *mStaticComponentLoader;
#endif
nsCOMPtr<nsIFile> mComponentsDir;
PRInt32 mComponentsOffset;

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIModule.h"
#include "nsIFile.h"
#include "nsIComponentManager.h"
#include "nsXPCOM.h"
// Exported Function from module dll to Create the nsIModule
#define NS_GET_MODULE_SYMBOL "NSGetModule"
@ -50,9 +51,4 @@ NSGetModule(nsIComponentManager *aCompMgr,
nsIFile* location,
nsIModule** return_cobj);
typedef nsresult (PR_CALLBACK *nsGetModuleProc)(nsIComponentManager *aCompMgr,
nsIFile* location,
nsIModule** return_cobj);
#endif /* nsModule_h__ */

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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"),
@ -35,8 +36,11 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsStaticComponent.h"
#include "nsXPCOMPrivate.h"
#include "nsIComponentLoader.h"
#include "nsIModule.h"
#include "nsVoidArray.h"
#include "pldhash.h"
#include NEW_H
@ -52,6 +56,10 @@ extern const char staticComponentType[];
struct StaticModuleInfo : public PLDHashEntryHdr {
nsStaticModuleInfo info;
nsCOMPtr<nsIModule> module;
// We want to autoregister the components in the order they come to us
// in the static component list, so we keep a linked list.
StaticModuleInfo *next;
};
class nsStaticComponentLoader : public nsIComponentLoader
@ -60,13 +68,13 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICOMPONENTLOADER
nsStaticComponentLoader() :
mAutoRegistered(PR_FALSE), mLoadedInfo(PR_FALSE) {
}
nsStaticComponentLoader() :
mAutoRegistered(PR_FALSE),
mFirst(nsnull)
{ }
static NS_HIDDEN_(PLDHashOperator) PR_CALLBACK
info_RegisterSelf(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg);
nsresult Init(nsStaticModuleInfo const *aStaticModules,
PRUint32 aModuleCount);
private:
~nsStaticComponentLoader() {
@ -75,15 +83,14 @@ private:
}
protected:
nsresult GetModuleInfo();
nsresult GetInfoFor(const char *aLocation, StaticModuleInfo **retval);
PRBool mAutoRegistered;
PRBool mLoadedInfo;
nsCOMPtr<nsIComponentManager> mComponentMgr;
PLDHashTable mInfoHash;
static PLDHashTableOps sInfoHashOps;
nsVoidArray mDeferredComponents;
StaticModuleInfo *mFirst;
};
PR_STATIC_CALLBACK(void)
@ -111,43 +118,38 @@ info_InitEntry(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
NS_IMPL_THREADSAFE_ISUPPORTS1(nsStaticComponentLoader, nsIComponentLoader)
#ifndef MOZ_ENABLE_LIBXUL
NS_COM NSGetStaticModuleInfoFunc NSGetStaticModuleInfo;
#endif
nsresult
nsStaticComponentLoader::GetModuleInfo()
nsStaticComponentLoader::Init(nsStaticModuleInfo const *aStaticModules,
PRUint32 aModuleCount)
{
if (mLoadedInfo)
return NS_OK;
if (!mInfoHash.ops) { // creation failed in init, why are we here?
NS_WARNING("operating on uninitialized static component loader");
return NS_ERROR_NOT_INITIALIZED;
if (!PL_DHashTableInit(&mInfoHash, &sInfoHashOps, nsnull,
sizeof(StaticModuleInfo), 1024)) {
mInfoHash.ops = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
if (! NSGetStaticModuleInfo) {
// We're a static build with no static modules to
// register. This can happen in shared uses (such as the GRE)
if (! aStaticModules)
return NS_OK;
}
nsStaticModuleInfo *infoList;
PRUint32 count;
nsresult rv;
if (NS_FAILED(rv = (*NSGetStaticModuleInfo)(&infoList, &count)))
return rv;
for (PRUint32 i = 0; i < count; i++) {
StaticModuleInfo *prev = nsnull;
for (PRUint32 i = 0; i < aModuleCount; ++i) {
StaticModuleInfo *info =
NS_STATIC_CAST(StaticModuleInfo *,
PL_DHashTableOperate(&mInfoHash, infoList[i].name,
PL_DHashTableOperate(&mInfoHash, aStaticModules[i].name,
PL_DHASH_ADD));
if (!info)
return NS_ERROR_OUT_OF_MEMORY;
info->info = infoList[i];
info->info = aStaticModules[i];
if (prev)
prev->next = info;
else
mFirst = info;
prev = info;
}
mLoadedInfo = PR_TRUE;
return NS_OK;
}
@ -156,9 +158,6 @@ nsStaticComponentLoader::GetInfoFor(const char *aLocation,
StaticModuleInfo **retval)
{
nsresult rv;
if (NS_FAILED(rv = GetModuleInfo()))
return rv;
StaticModuleInfo *info =
NS_STATIC_CAST(StaticModuleInfo *,
PL_DHashTableOperate(&mInfoHash, aLocation,
@ -183,42 +182,9 @@ NS_IMETHODIMP
nsStaticComponentLoader::Init(nsIComponentManager *mgr, nsISupports *aReg)
{
mComponentMgr = mgr;
if (!PL_DHashTableInit(&mInfoHash, &sInfoHashOps, nsnull,
sizeof(StaticModuleInfo), 1024)) {
mInfoHash.ops = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
PLDHashOperator PR_CALLBACK
nsStaticComponentLoader::info_RegisterSelf(PLDHashTable *table,
PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsStaticComponentLoader *loader = NS_STATIC_CAST(nsStaticComponentLoader *,
arg);
nsIComponentManager *mgr = loader->mComponentMgr;
StaticModuleInfo *info = NS_STATIC_CAST(StaticModuleInfo *, hdr);
nsresult rv;
if (!info->module) {
rv = info->info.getModule(mgr, nsnull, getter_AddRefs(info->module));
LOG(("nSCL: getModule(\"%s\"): %lx\n", info->info.name, rv));
if (NS_FAILED(rv))
return PL_DHASH_NEXT; // oh well.
}
rv = info->module->RegisterSelf(mgr, nsnull, info->info.name,
staticComponentType);
LOG(("nSCL: autoreg of \"%s\": %lx\n", info->info.name, rv));
if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
loader->mDeferredComponents.AppendElement(info);
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsStaticComponentLoader::AutoRegisterComponents(PRInt32 when, nsIFile *dir)
{
@ -231,10 +197,25 @@ nsStaticComponentLoader::AutoRegisterComponents(PRInt32 when, nsIFile *dir)
return NS_OK;
nsresult rv;
if (NS_FAILED(rv = GetModuleInfo()))
return rv;
StaticModuleInfo *info = mFirst;
PL_DHashTableEnumerate(&mInfoHash, info_RegisterSelf, this);
while (info) {
if (!info->module) {
rv = info->info.getModule(mComponentMgr, nsnull, getter_AddRefs(info->module));
LOG(("nSCL: getModule(\"%s\"): %lx\n", info->info.name, rv));
if (NS_FAILED(rv) || !info->module)
continue; // oh well
}
rv = info->module->RegisterSelf(mComponentMgr, nsnull, info->info.name,
staticComponentType);
LOG(("nSCL: autoreg of \"%s\": %lx\n", info->info.name, rv));
if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
mDeferredComponents.AppendElement(info);
info = info->next;
}
mAutoRegistered = PR_TRUE;
return NS_OK;
@ -312,9 +293,20 @@ nsStaticComponentLoader::GetFactory(const nsCID &aCID, const char *aLocation,
}
nsresult
NS_NewStaticComponentLoader(nsIComponentLoader **retval)
NewStaticComponentLoader(nsStaticModuleInfo const *aStaticModules,
PRUint32 aStaticModuleCount,
nsIComponentLoader **retval)
{
NS_IF_ADDREF(*retval = NS_STATIC_CAST(nsIComponentLoader *,
new nsStaticComponentLoader));
return *retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsStaticComponentLoader> lthis = new nsStaticComponentLoader();
if (!lthis)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = ((nsStaticComponentLoader*) lthis)->
Init(aStaticModules, aStaticModuleCount);
if (NS_FAILED(rv))
return rv;
NS_ADDREF(*retval = lthis);
return NS_OK;
}

Просмотреть файл

@ -475,7 +475,7 @@ nsGenericModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
}
NS_COM_GLUE nsresult
NS_NewGenericModule2(nsModuleInfo* info, nsIModule* *result)
NS_NewGenericModule2(nsModuleInfo const *info, nsIModule* *result)
{
nsresult rv = NS_OK;

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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"),
@ -42,6 +43,9 @@
#include "nsIModule.h"
#include "nsIClassInfo.h"
class nsIFile;
class nsIComponentManager;
// {3bc97f01-ccdf-11d2-bab8-b548654461fc}
#define NS_GENERICFACTORY_CID \
{ 0x3bc97f01, 0xccdf, 0x11d2, \
@ -283,7 +287,7 @@ typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self);
struct nsModuleInfo {
PRUint32 mVersion;
const char* mModuleName;
const nsModuleComponentInfo* mComponents;
const nsModuleComponentInfo *mComponents;
PRUint32 mCount;
nsModuleConstructorProc mCtor;
nsModuleDestructorProc mDtor;
@ -301,7 +305,7 @@ struct nsModuleInfo {
* one of its relatives, rather than using this directly.
*/
NS_COM_GLUE nsresult
NS_NewGenericModule2(nsModuleInfo *info, nsIModule* *result);
NS_NewGenericModule2(nsModuleInfo const *info, nsIModule* *result);
/**
* Obsolete. Use NS_NewGenericModule2() instead.
@ -314,20 +318,9 @@ NS_NewGenericModule(const char* moduleName,
nsIModule* *result);
#if defined(XPCOM_TRANSLATE_NSGM_ENTRY_POINT)
# define NS_MODULEINFO nsModuleInfo
# define NSMODULEINFO(_name) _name##_gModuleInfo
# define NSGETMODULE_ENTRY_POINT(_info)
# define NSGETMODULE_ENTRY_POINT(_name) NS_VISIBILITY_HIDDEN nsresult _name##_NSGetModule
#else
# define NS_MODULEINFO static nsModuleInfo
# define NSMODULEINFO(_name) gModuleInfo
# define NSGETMODULE_ENTRY_POINT(_info) \
extern "C" NS_EXPORT nsresult \
NSGetModule(nsIComponentManager *servMgr, \
nsIFile* location, \
nsIModule** result) \
{ \
return NS_NewGenericModule2(&(_info), result); \
}
# define NSGETMODULE_ENTRY_POINT(_name) extern "C" NS_EXPORT nsresult NSGetModule
#endif
/**
@ -346,7 +339,7 @@ NSGetModule(nsIComponentManager *servMgr, \
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, nsnull, _dtor)
#define NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, _ctor, _dtor) \
NS_MODULEINFO NSMODULEINFO(_name) = { \
static nsModuleInfo const kModuleInfo = { \
NS_MODULEINFO_VERSION, \
(#_name), \
(_components), \
@ -354,7 +347,13 @@ NS_MODULEINFO NSMODULEINFO(_name) = { \
(_ctor), \
(_dtor) \
}; \
NSGETMODULE_ENTRY_POINT(NSMODULEINFO(_name))
NSGETMODULE_ENTRY_POINT(_name) \
(nsIComponentManager *servMgr, \
nsIFile* location, \
nsIModule** result) \
{ \
return NS_NewGenericModule2(&kModuleInfo, result); \
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -150,6 +150,19 @@ NS_InitXPCOM2(nsIServiceManager* *result,
return xpcomFunctions.init(result, binDirectory, appFileLocationProvider);
}
extern "C" NS_COM nsresult
NS_InitXPCOM3(nsIServiceManager* *result,
nsIFile* binDirectory,
nsIDirectoryServiceProvider* appFileLocationProvider,
nsStaticModuleInfo const *staticComponents,
PRUint32 componentCount)
{
if (!xpcomFunctions.init3)
return NS_ERROR_NOT_INITIALIZED;
return xpcomFunctions.init3(result, binDirectory, appFileLocationProvider,
staticComponents, componentCount);
}
extern "C" NS_COM nsresult
NS_ShutdownXPCOM(nsIServiceManager* servMgr)
{

Просмотреть файл

@ -84,7 +84,8 @@ static const XPCOMFunctions kFrozenFunctions = {
&NS_StringContainerInit2_P,
&NS_CStringContainerInit2_P,
&NS_StringGetMutableData_P,
&NS_CStringGetMutableData_P
&NS_CStringGetMutableData_P,
&NS_InitXPCOM3_P
};
extern "C" NS_EXPORT nsresult
@ -120,6 +121,18 @@ NS_InitXPCOM2(nsIServiceManager **result,
return NS_InitXPCOM2_P(result, binDirectory, dirProvider);
}
#undef NS_InitXPCOM3
extern "C" NS_EXPORT nsresult
NS_InitXPCOM3(nsIServiceManager **result,
nsIFile *binDirectory,
nsIDirectoryServiceProvider *dirProvider,
nsStaticModuleInfo const *staticComponents,
PRUint32 componentCount)
{
return NS_InitXPCOM3_P(result, binDirectory, dirProvider,
staticComponents, componentCount);
}
#undef NS_ShutdownXPCOM
extern "C" NS_EXPORT nsresult
NS_ShutdownXPCOM(nsIServiceManager *svcMgr)

Просмотреть файл

@ -3,9 +3,6 @@
#ifndef _XPCOM_PRIVATE_H_
#define _XPCOM_PRIVATE_H_
/* Define to build the static component loader */
#undef ENABLE_STATIC_COMPONENT_LOADER
/* Define if getpagesize() is available */
#undef HAVE_GETPAGESIZE

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsComponentManagerUtils.h"
#include "nsIGenericFactory.h"
#include "nsIComponentRegistrar.h"
#include "nsStaticComponents.h"
#ifdef XP_OS2
#include "private/pprthred.h"
@ -214,33 +215,9 @@ extern "C" {
}
#endif
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
#ifdef _MOZCOMPS_SHARED_LIBRARY
extern "C" nsresult nsMetaModule_nsGetModule(nsIComponentManager *servMgr,
nsIFile *location,
nsIModule **result);
static nsStaticModuleInfo staticInfo[] = {
{
"meta component",
nsMetaModule_nsGetModule
}
};
static nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count) {
*info = staticInfo;
*count = 1;
return NS_OK;
}
#else
nsresult PR_CALLBACK
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#endif
#ifndef _BUILD_STATIC_BIN
nsStaticModuleInfo const *const kPStaticModules = nsnull;
PRUint32 const kStaticModuleCount = 0;
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
@ -1608,11 +1585,6 @@ int main(int argc, char* argv[])
InitializeMacOSXApp(argc, argv);
#endif
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
// Handle -help and -version command line arguments.
// They should% return quick, so we deal with them here.
if (HandleDumpArguments(argc, argv))
@ -1693,12 +1665,13 @@ int main(int argc, char* argv[])
return 1;
}
#else
NS_TIMELINE_MARK("NS_InitXPCOM2...");
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
NS_TIMELINE_MARK("...NS_InitXPCOM2 done");
NS_TIMELINE_MARK("NS_InitXPCOM3...");
nsresult rv = NS_InitXPCOM3(nsnull, nsnull, nsnull,
kPStaticModules, kStaticModuleCount);
NS_TIMELINE_MARK("...NS_InitXPCOM3 done");
if (NS_FAILED(rv)) {
// We should be displaying a dialog here with the reason why we failed.
NS_WARNING("NS_InitXPCOM2 failed");
NS_WARNING("NS_InitXPCOM3 failed");
return 1;
}
#endif