зеркало из https://github.com/mozilla/gecko-dev.git
b=46775. Adding ablity to generate a static module based on dougt/cls's work. There is a disagreement between us and warren about how exactly to do this. Since I have a working solution, I am checking this onto our embedding branch. This disagreement must be resolved before these changes land on the mozilla trunk.
This commit is contained in:
Родитель
56525a7354
Коммит
5d48538618
|
@ -0,0 +1,69 @@
|
|||
# Generated automatically from Makefile.in by configure.
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = ../..
|
||||
srcdir = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = staticmod
|
||||
LIBRARY_NAME = staticmod
|
||||
SHORT_LIBNAME = statcmod
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = nsStaticModule.cpp
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(foreach m, $(MOZ_STATIC_COMPONENTS), $(DIST)/lib/components/lib$(m).$(LIB_SUFFIX))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(ZLIB_LIBS) \
|
||||
$(XPCOM_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(PNG_LIBS) \
|
||||
-ljsdom
|
||||
|
||||
GARBAGE += nsStaticModule.cpp
|
||||
|
||||
list:
|
||||
echo $(MOZ_STATIC_COMPONENTS)
|
||||
|
||||
nsStaticModule.cpp: nsStaticModule.cpp.in Makefile Makefile.in $(DEPTH)/config/autoconf.mk
|
||||
rm -f $@
|
||||
cat $< | sed -e "s|@COMPONENT_NS_GET_MODULE@|$(foreach m, $(MOZ_STATIC_COMPONENTS), REGISTER_MODULE_USING($(m)_NSGetModule);)|" | \
|
||||
sed -e "s|@COMPONENT_LIST@|$(foreach m, $(MOZ_STATIC_COMPONENTS), { $(m)_NSGM_comps, $(m)_NSGM_comp_count }, )|" | \
|
||||
sed -e "s|@DECLARE_COMPONENT_LIST@|$(foreach m,$(MOZ_STATIC_COMPONENTS), extern \"C\" nsresult $(m)_NSGetModule(nsIComponentManager *servMgr, nsIFile* aPath, nsIModule** return_cobj); extern nsModuleComponentInfo* $(m)_NSGM_comps; extern PRUint32 $(m)_NSGM_comp_count;)|" > $@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Seawood <cls@seawood.org>
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsError.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#define REGISTER_MODULE_USING(mod) { \
|
||||
nsCOMPtr<nsIModule> module; \
|
||||
mod##(compMgr, aPath, getter_AddRefs(module)); \
|
||||
module->RegisterSelf(compMgr, aPath, "", ""); \
|
||||
}
|
||||
|
||||
struct nsModuleComponentInfoContainer {
|
||||
nsModuleComponentInfo *list;
|
||||
PRUint32 count;
|
||||
};
|
||||
|
||||
@DECLARE_COMPONENT_LIST@
|
||||
|
||||
static nsresult
|
||||
NS_RegisterStaticModules(nsIFile *aPath)
|
||||
{
|
||||
nsresult rv = PR_TRUE;
|
||||
nsIComponentManager *compMgr = nsnull;
|
||||
|
||||
rv = NS_GetGlobalComponentManager(&compMgr);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Static mods cannot get global component manager.");
|
||||
|
||||
@COMPONENT_NS_GET_MODULE@
|
||||
|
||||
{};
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void StaticModuleDestructor(nsIModule *self, nsModuleComponentInfo *components)
|
||||
{
|
||||
PR_Free(components);
|
||||
}
|
||||
|
||||
|
||||
#define NS_STATICMODULE_CID \
|
||||
{ 0x1926250e, 0xef22, 0x4c8d, { 0x94, 0x37, 0x86, 0xa8, 0x07, 0xeb, 0xe4, 0xca } }
|
||||
|
||||
#define NS_STATICMODULE_CONTRACTID "@mozilla.org/staticmodule;1"
|
||||
|
||||
|
||||
|
||||
class nsStaticModuleImpl : public nsISupports
|
||||
{
|
||||
public:
|
||||
nsStaticModuleImpl();
|
||||
virtual ~nsStaticModuleImpl();
|
||||
NS_DECL_ISUPPORTS
|
||||
};
|
||||
|
||||
nsStaticModuleImpl::nsStaticModuleImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsStaticModuleImpl::~nsStaticModuleImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsStaticModuleImpl, nsISupports);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStaticModuleImpl)
|
||||
|
||||
static NS_METHOD nsStaticModuleRegistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType)
|
||||
{
|
||||
NS_RegisterStaticModules(aPath);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_METHOD nsStaticModuleUnregistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Static Component",
|
||||
NS_STATICMODULE_CID,
|
||||
NS_STATICMODULE_CONTRACTID,
|
||||
nsStaticModuleImplConstructor,
|
||||
nsStaticModuleRegistrationProc,
|
||||
nsStaticModuleUnregistrationProc
|
||||
},
|
||||
};
|
||||
|
||||
static nsModuleComponentInfoContainer componentsList[] = {
|
||||
{ components, sizeof(components)/sizeof(components[0]) },
|
||||
@COMPONENT_LIST@
|
||||
{ nsnull, 0 }
|
||||
};
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
nsIFile* location,
|
||||
nsIModule** result)
|
||||
{
|
||||
nsModuleComponentInfo *outList = nsnull;
|
||||
nsModuleComponentInfoContainer *inList = componentsList;
|
||||
PRUint32 count = 0, i = 0, k=0, msize = sizeof(nsModuleComponentInfo);
|
||||
|
||||
while (inList[i].list != nsnull) {
|
||||
count += inList[i].count;
|
||||
i++;
|
||||
}
|
||||
|
||||
outList = (nsModuleComponentInfo *) PR_Calloc(count, sizeof(nsModuleComponentInfo));
|
||||
|
||||
i = 0; k =0;
|
||||
while (inList[i].list != nsnull) {
|
||||
memcpy(&outList[k], inList[i].list, msize * inList[i].count);
|
||||
k+= inList[i].count;
|
||||
i++;
|
||||
}
|
||||
return NS_NewGenericModule("nsStaticModule", count, outList, nsnull, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче