Compare commits
1 Commits
NSFILE_REM
...
src
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
258dc9fead |
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# 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 = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
GRE_MODULE = 1
|
||||
|
||||
DIRS = \
|
||||
typelib \
|
||||
glue \
|
||||
base \
|
||||
ds \
|
||||
io \
|
||||
components \
|
||||
threads \
|
||||
reflect \
|
||||
proxy \
|
||||
build \
|
||||
tools \
|
||||
obsolete \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ifdef MOZ_DEBUG
|
||||
DIRS += windbgdlg
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += \
|
||||
tests \
|
||||
sample \
|
||||
typelib/xpt/tests \
|
||||
reflect/xptinfo/tests \
|
||||
reflect/xptcall/tests \
|
||||
proxy/tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
nsAgg.h
|
||||
nsIAllocator.h
|
||||
nsCom.h
|
||||
nsComObsolete.h
|
||||
nsCWeakReference.h
|
||||
nsError.h
|
||||
nsID.h
|
||||
nsIID.h
|
||||
nsISupportsBase.h
|
||||
nsISupportsObsolete.h
|
||||
nsTraceRefcnt.h
|
||||
nsWeakPtr.h
|
||||
nscore.h
|
||||
@@ -1,11 +0,0 @@
|
||||
nsISupports.idl
|
||||
nsIMemory.idl
|
||||
nsrootidl.idl
|
||||
nsIInterfaceRequestor.idl
|
||||
nsIConsoleService.idl
|
||||
nsIConsoleMessage.idl
|
||||
nsIConsoleListener.idl
|
||||
nsIWeakReference.idl
|
||||
nsIException.idl
|
||||
nsIExceptionService.idl
|
||||
nsIProgrammingLanguage.idl
|
||||
@@ -1,119 +0,0 @@
|
||||
#
|
||||
# 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 = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpcom
|
||||
XPIDL_MODULE = xpcom_base
|
||||
LIBRARY_NAME = xpcombase_s
|
||||
GRE_MODULE = 1
|
||||
|
||||
REQUIRES = string \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsAllocator.cpp \
|
||||
nsMemoryImpl.cpp \
|
||||
nsErrorService.cpp \
|
||||
nsTraceRefcnt.cpp \
|
||||
nsID.cpp \
|
||||
nsCWeakReference.cpp \
|
||||
nsConsoleService.cpp \
|
||||
nsConsoleMessage.cpp \
|
||||
nsExceptionService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef GC_LEAK_DETECTOR
|
||||
CSRCS += nsGarbageCollector.c
|
||||
CPPSRCS += nsLeakDetector.cpp
|
||||
REQUIRES += boehm
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsAgg.h \
|
||||
nsIAllocator.h \
|
||||
nsCom.h \
|
||||
nsComObsolete.h \
|
||||
nsCWeakReference.h \
|
||||
nsIID.h \
|
||||
nsISupportsObsolete.h \
|
||||
nsTraceRefcnt.h \
|
||||
nsWeakPtr.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ifdef MOZ_DEBUG
|
||||
CSRCS += pure_api.c
|
||||
EXPORTS += pure.h
|
||||
endif
|
||||
CPPSRCS += nsStackFrameWin.cpp
|
||||
endif
|
||||
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS += nsStackFrameUnix.cpp
|
||||
endif
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIInterfaceRequestor.idl \
|
||||
nsIProgrammingLanguage.idl \
|
||||
nsISupports.idl \
|
||||
nsIWeakReference.idl \
|
||||
nsIMemory.idl \
|
||||
nsrootidl.idl \
|
||||
|
||||
SDK_HEADERS = \
|
||||
nsError.h \
|
||||
nsISupportsBase.h \
|
||||
nscore.h \
|
||||
nsID.h \
|
||||
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIErrorService.idl \
|
||||
nsIConsoleService.idl \
|
||||
nsIConsoleMessage.idl \
|
||||
nsIConsoleListener.idl \
|
||||
nsIException.idl \
|
||||
nsIExceptionService.idl \
|
||||
$(NULL)
|
||||
|
||||
ifdef GC_LEAK_DETECTOR
|
||||
XPIDLSRCS += nsILeakDetector.idl
|
||||
endif
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_COM
|
||||
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
DEFINES += -D_BSD_SOURCE
|
||||
endif
|
||||
@@ -1,2 +0,0 @@
|
||||
en-US.jar:
|
||||
locale/en-US/global/xpcom.properties
|
||||
@@ -1,155 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsAgg_h___
|
||||
#define nsAgg_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Put this in your class's declaration:
|
||||
#define NS_DECL_AGGREGATED \
|
||||
NS_DECL_ISUPPORTS \
|
||||
\
|
||||
public: \
|
||||
\
|
||||
/* You must implement this operation instead of the nsISupports */ \
|
||||
/* methods if you inherit from nsAggregated. */ \
|
||||
NS_IMETHOD \
|
||||
AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr); \
|
||||
\
|
||||
protected: \
|
||||
\
|
||||
class Internal : public nsISupports { \
|
||||
public: \
|
||||
\
|
||||
Internal() {} \
|
||||
\
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, \
|
||||
void** aInstancePtr); \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void); \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void); \
|
||||
\
|
||||
}; \
|
||||
\
|
||||
friend class Internal; \
|
||||
\
|
||||
nsISupports* fOuter; \
|
||||
Internal fAggregated; \
|
||||
\
|
||||
nsISupports* GetInner(void) { return &fAggregated; } \
|
||||
\
|
||||
public: \
|
||||
|
||||
|
||||
// Put this in your class's constructor:
|
||||
#define NS_INIT_AGGREGATED(outer) \
|
||||
PR_BEGIN_MACRO \
|
||||
fOuter = outer ? outer : &fAggregated; \
|
||||
PR_END_MACRO
|
||||
|
||||
|
||||
// Put this in your class's implementation file:
|
||||
#define NS_IMPL_AGGREGATED(_class) \
|
||||
NS_IMETHODIMP \
|
||||
_class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
return fOuter->QueryInterface(aIID, aInstancePtr); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP_(nsrefcnt) \
|
||||
_class::AddRef(void) \
|
||||
{ \
|
||||
return fOuter->AddRef(); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP_(nsrefcnt) \
|
||||
_class::Release(void) \
|
||||
{ \
|
||||
return fOuter->Release(); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP \
|
||||
_class::Internal::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
|
||||
return agg->AggregatedQueryInterface(aIID, aInstancePtr); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP_(nsrefcnt) \
|
||||
_class::Internal::AddRef(void) \
|
||||
{ \
|
||||
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
|
||||
NS_PRECONDITION(PRInt32(agg->mRefCnt) >= 0, "illegal refcnt"); \
|
||||
++agg->mRefCnt; \
|
||||
NS_LOG_ADDREF(this, agg->mRefCnt, #_class, sizeof(*this)); \
|
||||
return agg->mRefCnt; \
|
||||
} \
|
||||
\
|
||||
NS_IMETHODIMP_(nsrefcnt) \
|
||||
_class::Internal::Release(void) \
|
||||
{ \
|
||||
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
|
||||
NS_PRECONDITION(0 != agg->mRefCnt, "dup release"); \
|
||||
--agg->mRefCnt; \
|
||||
NS_LOG_RELEASE(this, agg->mRefCnt, #_class); \
|
||||
if (agg->mRefCnt == 0) { \
|
||||
agg->mRefCnt = 1; /* stabilize */ \
|
||||
NS_DELETEXPCOM(agg); \
|
||||
return 0; \
|
||||
} \
|
||||
return agg->mRefCnt; \
|
||||
} \
|
||||
|
||||
// for use with QI macros in nsISupportsUtils.h:
|
||||
|
||||
#define NS_INTERFACE_MAP_BEGIN_AGGREGATED(_class) \
|
||||
NS_IMPL_AGGREGATED_QUERY_HEAD(_class)
|
||||
|
||||
#define NS_IMPL_AGGREGATED_QUERY_HEAD(_class) \
|
||||
NS_IMETHODIMP \
|
||||
_class::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
NS_ASSERTION(aInstancePtr, \
|
||||
"AggregatedQueryInterface requires a non-NULL result ptr!"); \
|
||||
if ( !aInstancePtr ) \
|
||||
return NS_ERROR_NULL_POINTER; \
|
||||
nsISupports* foundInterface;
|
||||
|
||||
#endif /* nsAgg_h___ */
|
||||
@@ -1,41 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// obsolete
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// obsolete
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef nsAllocator_h__
|
||||
#define nsAllocator_h__
|
||||
|
||||
#include "nsIAllocator.h"
|
||||
#include "prmem.h"
|
||||
#include "nsAgg.h"
|
||||
#include "nsIFactory.h"
|
||||
|
||||
#endif // nsAllocator_h__
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,84 +0,0 @@
|
||||
/* -*- 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* 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):
|
||||
*/
|
||||
|
||||
/* A set of support classes for defining weak references, rather like
|
||||
nsIWeakReference, but for use with non-COM objects
|
||||
*/
|
||||
|
||||
#include "nsCWeakReference.h"
|
||||
|
||||
/************ a thing supporting weak references to itself ***********/
|
||||
nsCWeakReferent::nsCWeakReferent(void *aRealThing) :
|
||||
mRealThing(aRealThing),
|
||||
mProxy(0) {
|
||||
|
||||
}
|
||||
|
||||
nsCWeakReferent::~nsCWeakReferent() {
|
||||
|
||||
if (mProxy)
|
||||
mProxy->RealThingDeleted();
|
||||
}
|
||||
|
||||
void nsCWeakReferent::SetReferent(void *aRealThing) {
|
||||
|
||||
NS_ASSERTION(!mRealThing && !mProxy, "weak referent set twice");
|
||||
mRealThing = aRealThing;
|
||||
mProxy = 0;
|
||||
}
|
||||
|
||||
nsCWeakProxy *nsCWeakReferent::GetProxy() {
|
||||
|
||||
if (!mProxy)
|
||||
mProxy = new nsCWeakProxy(mRealThing, this);
|
||||
return mProxy;
|
||||
}
|
||||
|
||||
/************ a reference proxy whose lifetime we control ***********/
|
||||
/* the nsCWeakProxy object is an object whose creation and lifetime is
|
||||
under our control, unlike the nsCWeakReferent and its family of
|
||||
nsCWeakReferences. An nsCWeakProxy is created by the nsCWeakReferent
|
||||
when the first weak reference is necessary, and refcounted for each
|
||||
additional reference. It knows about the lifetime of the nsCWeakReferent,
|
||||
and deletes itself once all weak references have been broken.
|
||||
*/
|
||||
nsCWeakProxy::nsCWeakProxy(void *aRealThing, nsCWeakReferent *aReferent) :
|
||||
mRealPointer(aRealThing),
|
||||
mReferent(aReferent),
|
||||
mRefCount(0) {
|
||||
|
||||
NS_ASSERTION(aRealThing && aReferent, "weak proxy constructed with null ptr");
|
||||
}
|
||||
|
||||
nsCWeakProxy::~nsCWeakProxy() {
|
||||
if (mReferent)
|
||||
mReferent->ProxyDeleted();
|
||||
}
|
||||
|
||||
void nsCWeakProxy::ReleaseReference() {
|
||||
|
||||
if (--mRefCount == 0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/* -*- 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* 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):
|
||||
*/
|
||||
|
||||
#ifndef nsCWeakReference_h___
|
||||
#define nsCWeakReference_h___
|
||||
|
||||
#include "nsDebug.h"
|
||||
|
||||
/* A set of support classes for defining weak references, rather like
|
||||
nsIWeakReference, but for use with non-COM objects.
|
||||
|
||||
Expected use is when an object, call it A, holds a reference to an object B,
|
||||
and B may be unexpectedly deleted from underneath A. To use these classes
|
||||
to solve that problem, add an nsCWeakReferent member variable to B and
|
||||
construct that member in B's constructor. (B::B():mWeakRef(this)).
|
||||
Hold an nsCWeakReference<B> variable in A, rather than a B directly, and
|
||||
dereference B from that variable afresh each time that B may have been
|
||||
deleted.
|
||||
*/
|
||||
|
||||
class nsCWeakProxy;
|
||||
|
||||
/* An object wishing to support weak references to itself has an nsCWeakReferent
|
||||
member variable and provides an accessor for getting to it. Notice that
|
||||
nsCWeakReferent has no default constructor, so must be initialized with
|
||||
a pointer to the object.
|
||||
*/
|
||||
class NS_COM nsCWeakReferent {
|
||||
|
||||
public:
|
||||
nsCWeakReferent(void *aRealThing);
|
||||
virtual ~nsCWeakReferent();
|
||||
|
||||
void SetReferent(void *aRealThing);
|
||||
nsCWeakProxy *GetProxy();
|
||||
void ProxyDeleted()
|
||||
{ mProxy = 0; }
|
||||
|
||||
private:
|
||||
// copy and assignment constructors can't be implemented without help
|
||||
// from the containing class, so they're made inaccessible, forcing
|
||||
// the container to address this issue explicitly.
|
||||
nsCWeakReferent(const nsCWeakReferent &aOriginal);
|
||||
nsCWeakReferent& operator= (const nsCWeakReferent &aOriginal);
|
||||
|
||||
void *mRealThing;
|
||||
nsCWeakProxy *mProxy;
|
||||
};
|
||||
|
||||
/* The nsCWeakProxy object is an object whose creation and lifetime is
|
||||
under our control, unlike the nsCWeakReferent and its family of
|
||||
nsCWeakReferences. An nsCWeakProxy is created by the nsCWeakReferent
|
||||
when the first weak reference is necessary, and refcounted for each
|
||||
additional reference. It knows about the lifetime of the nsCWeakReferent,
|
||||
and deletes itself once all weak references have been broken.
|
||||
This is an internal-use class; clients need not use it or ever see it.
|
||||
*/
|
||||
class NS_COM nsCWeakProxy {
|
||||
|
||||
public:
|
||||
nsCWeakProxy(void *aRealThing, nsCWeakReferent *aReferent);
|
||||
virtual ~nsCWeakProxy();
|
||||
|
||||
void *Reference()
|
||||
{ return mRealPointer; }
|
||||
|
||||
void AddReference()
|
||||
{ ++mRefCount; }
|
||||
|
||||
void ReleaseReference();
|
||||
void RealThingDeleted()
|
||||
{ mRealPointer = 0; mReferent = 0; }
|
||||
|
||||
private:
|
||||
void *mRealPointer;
|
||||
nsCWeakReferent *mReferent;
|
||||
PRUint32 mRefCount;
|
||||
};
|
||||
|
||||
/* internal use only: there's no need for clients to use this class */
|
||||
class nsCWeakReferenceBase {
|
||||
public:
|
||||
nsCWeakReferenceBase() {};
|
||||
virtual ~nsCWeakReferenceBase() {};
|
||||
};
|
||||
|
||||
/* This class is the actual weak reference. Clients hold one of these
|
||||
and access the actual object by dereferencing this weak reference
|
||||
using operator*, operator-> or Reference().
|
||||
*/
|
||||
template<class T> class nsCWeakReference : public nsCWeakReferenceBase {
|
||||
|
||||
public:
|
||||
nsCWeakReference()
|
||||
{ mProxy = 0; }
|
||||
|
||||
nsCWeakReference(nsCWeakReferent *aReferent) {
|
||||
mProxy = 0;
|
||||
SetReference(aReferent);
|
||||
}
|
||||
|
||||
nsCWeakReference(const nsCWeakReference<T> &aOriginal) {
|
||||
mProxy = aOriginal.mProxy;
|
||||
if (mProxy)
|
||||
mProxy->AddReference();
|
||||
}
|
||||
|
||||
nsCWeakReference<T>& operator= (const nsCWeakReference<T> &aOriginal) {
|
||||
nsCWeakProxy *temp = mProxy;
|
||||
mProxy = aOriginal.mProxy;
|
||||
if (mProxy)
|
||||
mProxy->AddReference();
|
||||
if (temp)
|
||||
temp->ReleaseReference();
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator*() const {
|
||||
NS_ASSERTION(mProxy, "weak reference used without being set");
|
||||
return (T&) *(T*)mProxy->Reference();
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
NS_ASSERTION(mProxy, "weak reference used without being set");
|
||||
return (T*) mProxy->Reference();
|
||||
}
|
||||
|
||||
virtual ~nsCWeakReference() {
|
||||
mProxy->ReleaseReference();
|
||||
}
|
||||
|
||||
T* Reference() {
|
||||
NS_ASSERTION(mProxy, "weak reference used without being set");
|
||||
return (T*) mProxy->Reference();
|
||||
}
|
||||
|
||||
void SetReference(nsCWeakReferent *aReferent) {
|
||||
NS_ASSERTION(aReferent, "weak reference set with null referent");
|
||||
if (mProxy)
|
||||
mProxy->ReleaseReference();
|
||||
mProxy = aReferent->GetProxy();
|
||||
NS_ASSERTION(mProxy, "weak reference proxy allocation failed");
|
||||
mProxy->AddReference();
|
||||
}
|
||||
|
||||
private:
|
||||
nsCWeakProxy *mProxy;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsCom_h__
|
||||
#define nsCom_h__
|
||||
#include "nscore.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/* ***** 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 XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 nsComObsolete_h__
|
||||
#define nsComObsolete_h__
|
||||
|
||||
/* These _IMPL_NS_* defines should move into their own directories. */
|
||||
#ifdef _IMPL_NS_WIDGET
|
||||
#define NS_WIDGET NS_EXPORT
|
||||
#else
|
||||
#define NS_WIDGET NS_IMPORT
|
||||
#endif
|
||||
|
||||
#ifdef _IMPL_NS_GFX
|
||||
#define NS_GFX NS_EXPORT
|
||||
#define NS_GFX_(type) NS_EXPORT_(type)
|
||||
#else
|
||||
#define NS_GFX NS_IMPORT
|
||||
#define NS_GFX_(type) NS_IMPORT_(type)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* People who create their own Win32 MSDev projects to compile against mozilla
|
||||
* code *often* neglect to define XP_WIN and XP_WIN32. Rather than force
|
||||
* those definitions here - and risk having some code get compiled incorrectly
|
||||
* before this code is reached - we #error here to let the programmers know
|
||||
* that they must modify their build projects.
|
||||
* We would *like* to reduce the usage of these roughly synonymous defines.
|
||||
* But it is a big modular project with a lot of brainprint issues...
|
||||
* See bug: http://bugzilla.mozilla.org/show_bug.cgi?id=65727
|
||||
*/
|
||||
#if defined(_WIN32) && (!defined(XP_WIN) || !defined(XP_WIN32))
|
||||
#error Add defines for XP_WIN and XP_WIN32 to your Win32 build project.
|
||||
#endif
|
||||
|
||||
|
||||
/* Define brackets for protecting C code from C++ */
|
||||
#ifdef __cplusplus
|
||||
#define NS_BEGIN_EXTERN_C extern "C" {
|
||||
#define NS_END_EXTERN_C }
|
||||
#else
|
||||
#define NS_BEGIN_EXTERN_C
|
||||
#define NS_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
#define PUBLIC
|
||||
#define MODULE_PRIVATE
|
||||
|
||||
#ifdef PRIVATE
|
||||
#undef PRIVATE
|
||||
#endif
|
||||
#define PRIVATE static
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "nsDebug.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Base implementation for console messages.
|
||||
*/
|
||||
|
||||
#include "nsConsoleMessage.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage);
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage()
|
||||
{
|
||||
}
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage(const PRUnichar *message)
|
||||
{
|
||||
mMessage.Assign(message);
|
||||
}
|
||||
|
||||
nsConsoleMessage::~nsConsoleMessage() {};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetMessage(PRUnichar **result) {
|
||||
*result = ToNewUnicode(mMessage);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// NS_IMETHODIMP
|
||||
// nsConsoleMessage::Init(const PRUnichar *message) {
|
||||
// nsAutoString newMessage(message);
|
||||
// mMessage = ToNewUnicode(newMessage);
|
||||
// return NS_OK;
|
||||
// }
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsconsolemessage_h__
|
||||
#define __nsconsolemessage_h__
|
||||
|
||||
#include "nsIConsoleMessage.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsConsoleMessage : public nsIConsoleMessage {
|
||||
public:
|
||||
nsConsoleMessage();
|
||||
nsConsoleMessage(const PRUnichar *message);
|
||||
|
||||
virtual ~nsConsoleMessage();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONSOLEMESSAGE
|
||||
|
||||
private:
|
||||
nsString mMessage;
|
||||
};
|
||||
|
||||
#endif /* __nsconsolemessage_h__ */
|
||||
@@ -1,321 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Maintains a circular buffer of recent messages, and notifies
|
||||
* listeners when new messages are logged.
|
||||
*/
|
||||
|
||||
/* Threadsafe. */
|
||||
|
||||
#include "nsMemory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsSupportsArray.h"
|
||||
|
||||
#include "nsConsoleService.h"
|
||||
#include "nsConsoleMessage.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleService, nsIConsoleService);
|
||||
|
||||
nsConsoleService::nsConsoleService()
|
||||
: mCurrent(0), mFull(PR_FALSE), mListening(PR_FALSE), mLock(nsnull)
|
||||
{
|
||||
// XXX grab this from a pref!
|
||||
// hm, but worry about circularity, bc we want to be able to report
|
||||
// prefs errs...
|
||||
mBufferSize = 250;
|
||||
|
||||
// XXX deal with these two allocations by detecting null mLock in factory?
|
||||
mMessages = (nsIConsoleMessage **)
|
||||
nsMemory::Alloc(mBufferSize * sizeof(nsIConsoleMessage *));
|
||||
|
||||
mLock = PR_NewLock();
|
||||
|
||||
// Array elements should be 0 initially for circular buffer algorithm.
|
||||
for (PRUint32 i = 0; i < mBufferSize; i++) {
|
||||
mMessages[i] = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nsConsoleService::~nsConsoleService()
|
||||
{
|
||||
PRUint32 i = 0;
|
||||
while (i < mBufferSize && mMessages[i] != nsnull) {
|
||||
NS_RELEASE(mMessages[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_mccabe
|
||||
if (mListeners.Count() != 0) {
|
||||
fprintf(stderr,
|
||||
"WARNING - %d console error listeners still registered!\n"
|
||||
"More calls to nsIConsoleService::UnregisterListener needed.\n",
|
||||
mListeners.Count());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsMemory::Free(mMessages);
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK snapshot_enum_func(nsHashKey *key, void *data, void* closure)
|
||||
{
|
||||
nsISupportsArray *array = (nsISupportsArray *)closure;
|
||||
|
||||
// Copy each element into the temporary nsSupportsArray...
|
||||
array->AppendElement((nsISupports*)data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// nsIConsoleService methods
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
||||
{
|
||||
if (message == nsnull)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsSupportsArray listenersSnapshot;
|
||||
nsIConsoleMessage *retiredMessage;
|
||||
|
||||
NS_ADDREF(message); // early, in case it's same as replaced below.
|
||||
|
||||
/*
|
||||
* Lock while updating buffer, and while taking snapshot of
|
||||
* listeners array.
|
||||
*/
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
/*
|
||||
* If there's already a message in the slot we're about to replace,
|
||||
* we've wrapped around, and we need to release the old message. We
|
||||
* save a pointer to it, so we can release below outside the lock.
|
||||
*/
|
||||
retiredMessage = mMessages[mCurrent];
|
||||
|
||||
mMessages[mCurrent++] = message;
|
||||
if (mCurrent == mBufferSize) {
|
||||
mCurrent = 0; // wrap around.
|
||||
mFull = PR_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the listeners into the snapshot array - in case a listener
|
||||
* is removed during an Observe(...) notification...
|
||||
*/
|
||||
mListeners.Enumerate(snapshot_enum_func, &listenersSnapshot);
|
||||
}
|
||||
if (retiredMessage != nsnull)
|
||||
NS_RELEASE(retiredMessage);
|
||||
|
||||
/*
|
||||
* Iterate through any registered listeners and tell them about
|
||||
* the message. We use the mListening flag to guard against
|
||||
* recursive message logs. This could sometimes result in
|
||||
* listeners being skipped because of activity on other threads,
|
||||
* when we only care about the recursive case.
|
||||
*/
|
||||
nsCOMPtr<nsIConsoleListener> listener;
|
||||
nsresult rv;
|
||||
nsresult returned_rv;
|
||||
PRUint32 snapshotCount;
|
||||
rv = listenersSnapshot.Count(&snapshotCount);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
if (mListening)
|
||||
return NS_OK;
|
||||
mListening = PR_TRUE;
|
||||
}
|
||||
|
||||
returned_rv = NS_OK;
|
||||
for (PRUint32 i = 0; i < snapshotCount; i++) {
|
||||
rv = listenersSnapshot.GetElementAt(i, getter_AddRefs(listener));
|
||||
if (NS_FAILED(rv)) {
|
||||
returned_rv = rv;
|
||||
break; // fall thru to mListening restore code below.
|
||||
}
|
||||
listener->Observe(message);
|
||||
}
|
||||
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
mListening = PR_FALSE;
|
||||
}
|
||||
|
||||
return returned_rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::LogStringMessage(const PRUnichar *message)
|
||||
{
|
||||
nsConsoleMessage *msg = new nsConsoleMessage(message);
|
||||
return this->LogMessage(msg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::GetMessageArray(nsIConsoleMessage ***messages, PRUint32 *count)
|
||||
{
|
||||
nsIConsoleMessage **messageArray;
|
||||
|
||||
/*
|
||||
* Lock the whole method, as we don't want anyone mucking with mCurrent or
|
||||
* mFull while we're copying out the buffer.
|
||||
*/
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
if (mCurrent == 0 && !mFull) {
|
||||
/*
|
||||
* Make a 1-length output array so that nobody gets confused,
|
||||
* and return a count of 0. This should result in a 0-length
|
||||
* array object when called from script.
|
||||
*/
|
||||
messageArray = (nsIConsoleMessage **)
|
||||
nsMemory::Alloc(sizeof (nsIConsoleMessage *));
|
||||
*messageArray = nsnull;
|
||||
*messages = messageArray;
|
||||
*count = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 resultSize = mFull ? mBufferSize : mCurrent;
|
||||
messageArray =
|
||||
(nsIConsoleMessage **)nsMemory::Alloc((sizeof (nsIConsoleMessage *))
|
||||
* resultSize);
|
||||
|
||||
if (messageArray == nsnull) {
|
||||
*messages = nsnull;
|
||||
*count = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
if (mFull) {
|
||||
for (i = 0; i < mBufferSize; i++) {
|
||||
// if full, fill the buffer starting from mCurrent (which'll be
|
||||
// oldest) wrapping around the buffer to the most recent.
|
||||
messageArray[i] = mMessages[(mCurrent + i) % mBufferSize];
|
||||
NS_ADDREF(messageArray[i]);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < mCurrent; i++) {
|
||||
messageArray[i] = mMessages[i];
|
||||
NS_ADDREF(messageArray[i]);
|
||||
}
|
||||
}
|
||||
*count = resultSize;
|
||||
*messages = messageArray;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::RegisterListener(nsIConsoleListener *listener) {
|
||||
nsresult rv;
|
||||
|
||||
/*
|
||||
* Store a threadsafe proxy to the listener rather than the
|
||||
* listener itself; we want the console service to be callable
|
||||
* from any thread, but listeners can be implemented in
|
||||
* thread-specific ways, and we always want to call them on their
|
||||
* originating thread. JavaScript is the motivating example.
|
||||
*/
|
||||
nsCOMPtr<nsIConsoleListener> proxiedListener;
|
||||
|
||||
rv = GetProxyForListener(listener, getter_AddRefs(proxiedListener));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
nsISupportsKey key(listener);
|
||||
|
||||
/*
|
||||
* Put the proxy event listener into a hashtable using the *real*
|
||||
* listener as the key.
|
||||
*
|
||||
* This is necessary because proxy objects do *not* maintain
|
||||
* nsISupports identity. Therefore, since GetProxyForListener(...)
|
||||
* can return different proxies for the same object (see bug #85831)
|
||||
* we need to use the real object as the unique key...
|
||||
*/
|
||||
mListeners.Put(&key, proxiedListener);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::UnregisterListener(nsIConsoleListener *listener) {
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
nsISupportsKey key(listener);
|
||||
mListeners.Remove(&key);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsConsoleService::GetProxyForListener(nsIConsoleListener* aListener,
|
||||
nsIConsoleListener** aProxy)
|
||||
{
|
||||
nsresult rv;
|
||||
*aProxy = nsnull;
|
||||
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyManager =
|
||||
(do_GetService(NS_XPCOMPROXY_CONTRACTID));
|
||||
|
||||
if (proxyManager == nsnull)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
/*
|
||||
* NOTE this will fail if the calling thread doesn't have an eventQ.
|
||||
*
|
||||
* Would it be better to catch that case and leave the listener unproxied?
|
||||
*/
|
||||
rv = proxyManager->GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
NS_GET_IID(nsIConsoleListener),
|
||||
aListener,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
(void**) aProxy);
|
||||
return rv;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* nsConsoleService class declaration.
|
||||
*/
|
||||
|
||||
#ifndef __nsconsoleservice_h__
|
||||
#define __nsconsoleservice_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsAutoLock.h"
|
||||
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
class nsConsoleService : public nsIConsoleService
|
||||
{
|
||||
public:
|
||||
nsConsoleService();
|
||||
virtual ~nsConsoleService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONSOLESERVICE
|
||||
|
||||
private:
|
||||
// build (or find) a proxy for the listener
|
||||
nsresult GetProxyForListener(nsIConsoleListener* aListener,
|
||||
nsIConsoleListener** aProxy);
|
||||
|
||||
// Circular buffer of saved messages
|
||||
nsIConsoleMessage **mMessages;
|
||||
|
||||
// How big?
|
||||
PRUint32 mBufferSize;
|
||||
|
||||
// Index of slot in mMessages that'll be filled by *next* log message
|
||||
PRUint32 mCurrent;
|
||||
|
||||
// Is the buffer full? (Has mCurrent wrapped around at least once?)
|
||||
PRBool mFull;
|
||||
|
||||
// Listeners to notify whenever a new message is logged.
|
||||
nsSupportsHashtable mListeners;
|
||||
|
||||
// Current listener being notified of a logged error - to prevent
|
||||
// stack overflows.
|
||||
PRBool mListening;
|
||||
|
||||
// To serialize interesting methods.
|
||||
PRLock *mLock;
|
||||
};
|
||||
|
||||
#endif /* __nsconsoleservice_h__ */
|
||||
@@ -1,496 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Win32 x86 code for stack walking, symbol resolution, and function hooking */
|
||||
|
||||
#if defined(_WIN32) && defined(_M_IX86)
|
||||
// This is the .cpp file where the globals live
|
||||
#define DHW_IMPLEMENT_GLOBALS
|
||||
#include <stdio.h>
|
||||
#include "prtypes.h"
|
||||
#include "prprf.h"
|
||||
#include "prlog.h"
|
||||
#include "plstr.h"
|
||||
#include "prlock.h"
|
||||
#include "nscore.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsDebugHelpWin32.h"
|
||||
#else
|
||||
#error "nsDebugHelpWin32.cpp should only be built in Win32 x86 builds"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
dhwEnsureImageHlpInitialized()
|
||||
{
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
static PRBool gTried = PR_FALSE;
|
||||
|
||||
if (!gInitialized && !gTried) {
|
||||
gTried = PR_TRUE;
|
||||
HMODULE module = ::LoadLibrary("DBGHELP.DLL");
|
||||
if (!module) {
|
||||
DWORD dw = GetLastError();
|
||||
printf("DumpStack Error: DBGHELP.DLL wasn't found. GetLastError() returned 0x%8.8X\n"
|
||||
" This DLL is needed for succeessfully implementing trace-malloc.\n"
|
||||
" This dll ships by default on Win2k. Disabling trace-malloc functionality.\n"
|
||||
, dw);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#define INIT_PROC(typename_, name_) \
|
||||
dhw##name_ = (typename_) ::GetProcAddress(module, #name_); \
|
||||
if(!dhw##name_) return PR_FALSE;
|
||||
|
||||
INIT_PROC(SYMINITIALIZEPROC, SymInitialize);
|
||||
INIT_PROC(SYMSETOPTIONS, SymSetOptions);
|
||||
INIT_PROC(SYMGETOPTIONS, SymGetOptions);
|
||||
INIT_PROC(SYMGETMODULEINFO, SymGetModuleInfo);
|
||||
INIT_PROC(SYMGETSYMFROMADDRPROC, SymGetSymFromAddr);
|
||||
INIT_PROC(ENUMERATELOADEDMODULES, EnumerateLoadedModules);
|
||||
INIT_PROC(IMAGEDIRECTORYENTRYTODATA, ImageDirectoryEntryToData);
|
||||
|
||||
// INIT_PROC(SYMGETLINEFROMADDR, SymGetLineFromAddr);
|
||||
// INIT_PROC(SYMCLEANUPPROC, SymCleanup);
|
||||
// INIT_PROC(STACKWALKPROC, StackWalk);
|
||||
// INIT_PROC(SYMFUNCTIONTABLEACCESSPROC, SymFunctionTableAccess);
|
||||
// INIT_PROC(SYMGETMODULEBASEPROC, SymGetModuleBase);
|
||||
// INIT_PROC(SYMLOADMODULE, SymLoadModule);
|
||||
// INIT_PROC(UNDECORATESYMBOLNAME, UnDecorateSymbolName);
|
||||
// INIT_PROC(SYMUNDNAME, SymUnDName);
|
||||
|
||||
|
||||
#undef INIT_PROC
|
||||
|
||||
gInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
return gInitialized;
|
||||
}
|
||||
|
||||
PRBool
|
||||
dhwEnsureSymInitialized()
|
||||
{
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
|
||||
if (! gInitialized) {
|
||||
if (! dhwEnsureImageHlpInitialized())
|
||||
return PR_FALSE;
|
||||
dhwSymSetOptions(
|
||||
#if defined(NS_TRACE_MALLOC)
|
||||
SYMOPT_LOAD_LINES |
|
||||
#endif
|
||||
SYMOPT_UNDNAME);
|
||||
// dhwSymSetOptions(SYMOPT_UNDNAME);
|
||||
if (! dhwSymInitialize(::GetCurrentProcess(), NULL, TRUE))
|
||||
return PR_FALSE;
|
||||
gInitialized = PR_TRUE;
|
||||
}
|
||||
return gInitialized;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
PRLock* DHWImportHooker::gLock = nsnull;
|
||||
DHWImportHooker* DHWImportHooker::gHooks = nsnull;
|
||||
GETPROCADDRESS DHWImportHooker::gRealGetProcAddress = nsnull;
|
||||
|
||||
DHWImportHooker&
|
||||
DHWImportHooker::getGetProcAddressHooker()
|
||||
{
|
||||
static DHWImportHooker gGetProcAddress("Kernel32.dll", "GetProcAddress",
|
||||
(PROC)DHWImportHooker::GetProcAddress);
|
||||
return gGetProcAddress;
|
||||
}
|
||||
|
||||
|
||||
DHWImportHooker&
|
||||
DHWImportHooker::getLoadLibraryWHooker()
|
||||
{
|
||||
static DHWImportHooker gLoadLibraryW("Kernel32.dll", "LoadLibraryW",
|
||||
(PROC)DHWImportHooker::LoadLibraryW);
|
||||
return gLoadLibraryW;
|
||||
}
|
||||
|
||||
DHWImportHooker&
|
||||
DHWImportHooker::getLoadLibraryExWHooker()
|
||||
{
|
||||
static DHWImportHooker gLoadLibraryExW("Kernel32.dll", "LoadLibraryExW",
|
||||
(PROC)DHWImportHooker::LoadLibraryExW);
|
||||
return gLoadLibraryExW;
|
||||
}
|
||||
|
||||
DHWImportHooker&
|
||||
DHWImportHooker::getLoadLibraryAHooker()
|
||||
{
|
||||
static DHWImportHooker gLoadLibraryA("Kernel32.dll", "LoadLibraryA",
|
||||
(PROC)DHWImportHooker::LoadLibraryA);
|
||||
return gLoadLibraryA;
|
||||
}
|
||||
|
||||
DHWImportHooker&
|
||||
DHWImportHooker::getLoadLibraryExAHooker()
|
||||
{
|
||||
static DHWImportHooker gLoadLibraryExA("Kernel32.dll", "LoadLibraryExA",
|
||||
(PROC)DHWImportHooker::LoadLibraryExA);
|
||||
return gLoadLibraryExA;
|
||||
}
|
||||
|
||||
|
||||
static HMODULE ThisModule()
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
return VirtualQuery(ThisModule, &info, sizeof(info)) ?
|
||||
(HMODULE) info.AllocationBase : nsnull;
|
||||
}
|
||||
|
||||
DHWImportHooker::DHWImportHooker(const char* aModuleName,
|
||||
const char* aFunctionName,
|
||||
PROC aHook,
|
||||
PRBool aExcludeOurModule /* = PR_FALSE */)
|
||||
: mNext(nsnull),
|
||||
mModuleName(aModuleName),
|
||||
mFunctionName(aFunctionName),
|
||||
mOriginal(nsnull),
|
||||
mHook(aHook),
|
||||
mIgnoreModule(aExcludeOurModule ? ThisModule() : nsnull),
|
||||
mHooking(PR_TRUE)
|
||||
{
|
||||
//printf("DHWImportHooker hooking %s, function %s\n",aModuleName, aFunctionName);
|
||||
|
||||
if(!gLock)
|
||||
gLock = PR_NewLock();
|
||||
nsAutoLock lock(gLock);
|
||||
|
||||
dhwEnsureImageHlpInitialized();
|
||||
|
||||
if(!gRealGetProcAddress)
|
||||
gRealGetProcAddress = ::GetProcAddress;
|
||||
|
||||
mOriginal = gRealGetProcAddress(::GetModuleHandleA(aModuleName),
|
||||
aFunctionName),
|
||||
|
||||
mNext = gHooks;
|
||||
gHooks = this;
|
||||
|
||||
PatchAllModules();
|
||||
}
|
||||
|
||||
DHWImportHooker::~DHWImportHooker()
|
||||
{
|
||||
nsAutoLock lock(gLock);
|
||||
|
||||
mHooking = PR_FALSE;
|
||||
PatchAllModules();
|
||||
|
||||
if(gHooks == this)
|
||||
gHooks = mNext;
|
||||
else
|
||||
{
|
||||
for(DHWImportHooker* cur = gHooks; cur; cur = cur->mNext)
|
||||
{
|
||||
if(cur->mNext == this)
|
||||
{
|
||||
cur->mNext = mNext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(cur, "we were not in the list!");
|
||||
}
|
||||
|
||||
if(!gHooks)
|
||||
{
|
||||
PRLock* theLock = gLock;
|
||||
gLock = nsnull;
|
||||
lock.unlock();
|
||||
PR_DestroyLock(theLock);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL CALLBACK ModuleEnumCallback(LPSTR ModuleName,
|
||||
ULONG ModuleBase,
|
||||
ULONG ModuleSize,
|
||||
PVOID UserContext)
|
||||
{
|
||||
//printf("Module Name %s\n",ModuleName);
|
||||
DHWImportHooker* self = (DHWImportHooker*) UserContext;
|
||||
HMODULE aModule = (HMODULE) ModuleBase;
|
||||
return self->PatchOneModule(aModule, ModuleName);
|
||||
}
|
||||
|
||||
PRBool
|
||||
DHWImportHooker::PatchAllModules()
|
||||
{
|
||||
return dhwEnumerateLoadedModules(::GetCurrentProcess(),
|
||||
ModuleEnumCallback, this);
|
||||
}
|
||||
|
||||
PRBool
|
||||
DHWImportHooker::PatchOneModule(HMODULE aModule, const char* name)
|
||||
{
|
||||
if(aModule == mIgnoreModule)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// do the fun stuff...
|
||||
|
||||
PIMAGE_IMPORT_DESCRIPTOR desc;
|
||||
uint32 size;
|
||||
|
||||
desc = (PIMAGE_IMPORT_DESCRIPTOR)
|
||||
dhwImageDirectoryEntryToData(aModule, PR_TRUE,
|
||||
IMAGE_DIRECTORY_ENTRY_IMPORT, &size);
|
||||
|
||||
if(!desc)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
for(; desc->Name; desc++)
|
||||
{
|
||||
const char* entryModuleName = (const char*)
|
||||
((char*)aModule + desc->Name);
|
||||
if(!lstrcmpi(entryModuleName, mModuleName))
|
||||
break;
|
||||
}
|
||||
|
||||
if(!desc->Name)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PIMAGE_THUNK_DATA thunk = (PIMAGE_THUNK_DATA)
|
||||
((char*) aModule + desc->FirstThunk);
|
||||
|
||||
for(; thunk->u1.Function; thunk++)
|
||||
{
|
||||
PROC original;
|
||||
PROC replacement;
|
||||
|
||||
if(mHooking)
|
||||
{
|
||||
original = mOriginal;
|
||||
replacement = mHook;
|
||||
}
|
||||
else
|
||||
{
|
||||
original = mHook;
|
||||
replacement = mOriginal;
|
||||
}
|
||||
|
||||
PROC* ppfn = (PROC*) &thunk->u1.Function;
|
||||
if(*ppfn == original)
|
||||
{
|
||||
DWORD dwDummy;
|
||||
VirtualProtect(ppfn, sizeof(ppfn), PAGE_EXECUTE_READWRITE, &dwDummy);
|
||||
BOOL result = WriteProcessMemory(GetCurrentProcess(),
|
||||
ppfn, &replacement, sizeof(replacement), nsnull);
|
||||
if (!result) //failure
|
||||
{
|
||||
printf("failure name %s func %x\n",name,*ppfn);
|
||||
DWORD error = GetLastError();
|
||||
return PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("success name %s func %x\n",name,*ppfn);
|
||||
DWORD filler = result+1;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
DHWImportHooker::ModuleLoaded(HMODULE aModule, DWORD flags)
|
||||
{
|
||||
//printf("ModuleLoaded\n");
|
||||
if(aModule && !(flags & LOAD_LIBRARY_AS_DATAFILE))
|
||||
{
|
||||
nsAutoLock lock(gLock);
|
||||
// We don't know that the newly loaded module didn't drag in implicitly
|
||||
// linked modules, so we patch everything in sight.
|
||||
for(DHWImportHooker* cur = gHooks; cur; cur = cur->mNext)
|
||||
cur->PatchAllModules();
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
HMODULE WINAPI
|
||||
DHWImportHooker::LoadLibraryW(PCWSTR path)
|
||||
{
|
||||
//wprintf(L"LoadLibraryW %s\n",path);
|
||||
DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYW_, (PCWSTR));
|
||||
HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYW_, getLoadLibraryWHooker())(path);
|
||||
ModuleLoaded(hmod, 0);
|
||||
return hmod;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
HMODULE WINAPI
|
||||
DHWImportHooker::LoadLibraryExW(PCWSTR path, HANDLE file, DWORD flags)
|
||||
{
|
||||
//wprintf(L"LoadLibraryExW %s\n",path);
|
||||
DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYEXW_, (PCWSTR, HANDLE, DWORD));
|
||||
HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYEXW_, getLoadLibraryExWHooker())(path, file, flags);
|
||||
ModuleLoaded(hmod, flags);
|
||||
return hmod;
|
||||
}
|
||||
|
||||
// static
|
||||
HMODULE WINAPI
|
||||
DHWImportHooker::LoadLibraryA(PCSTR path)
|
||||
{
|
||||
//printf("LoadLibraryA %s\n",path);
|
||||
|
||||
DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYA_, (PCSTR));
|
||||
HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYA_, getLoadLibraryAHooker())(path);
|
||||
ModuleLoaded(hmod, 0);
|
||||
return hmod;
|
||||
}
|
||||
|
||||
// static
|
||||
HMODULE WINAPI
|
||||
DHWImportHooker::LoadLibraryExA(PCSTR path, HANDLE file, DWORD flags)
|
||||
{
|
||||
//printf("LoadLibraryExA %s\n",path);
|
||||
DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYEXA_, (PCSTR, HANDLE, DWORD));
|
||||
HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYEXA_, getLoadLibraryExAHooker())(path, file, flags);
|
||||
ModuleLoaded(hmod, flags);
|
||||
return hmod;
|
||||
}
|
||||
// static
|
||||
FARPROC WINAPI
|
||||
DHWImportHooker::GetProcAddress(HMODULE aModule, PCSTR aFunctionName)
|
||||
{
|
||||
FARPROC pfn = gRealGetProcAddress(aModule, aFunctionName);
|
||||
|
||||
if(pfn)
|
||||
{
|
||||
nsAutoLock lock(gLock);
|
||||
for(DHWImportHooker* cur = gHooks; cur; cur = cur->mNext)
|
||||
{
|
||||
if(pfn == cur->mOriginal)
|
||||
{
|
||||
pfn = cur->mHook;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pfn;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
#if 0
|
||||
|
||||
static _CRT_ALLOC_HOOK defaultDbgAllocHook = nsnull;
|
||||
static DHWAllocationSizeDebugHook* gAllocationSizeHook = nsnull;
|
||||
|
||||
int __cdecl dhw_DbgAllocHook(int nAllocType, void *pvData,
|
||||
size_t nSize, int nBlockUse, long lRequest,
|
||||
const unsigned char * szFileName, int nLine )
|
||||
{
|
||||
DHWAllocationSizeDebugHook* hook = gAllocationSizeHook;
|
||||
|
||||
if(hook)
|
||||
{
|
||||
PRBool res;
|
||||
_CrtSetAllocHook(defaultDbgAllocHook);
|
||||
|
||||
switch(nAllocType)
|
||||
{
|
||||
case _HOOK_ALLOC:
|
||||
res = hook->AllocHook(nSize);
|
||||
break;
|
||||
case _HOOK_REALLOC:
|
||||
res = hook->ReallocHook(nSize, pvData ?
|
||||
_msize_dbg(pvData, nBlockUse) : 0);
|
||||
break;
|
||||
case _HOOK_FREE:
|
||||
res = hook->FreeHook(pvData ?
|
||||
_msize_dbg(pvData, nBlockUse) : 0);
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(0,"huh?");
|
||||
res = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
_CrtSetAllocHook(dhw_DbgAllocHook);
|
||||
return (int) res;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRBool
|
||||
dhwSetAllocationSizeDebugHook(DHWAllocationSizeDebugHook* hook)
|
||||
{
|
||||
if(!hook || gAllocationSizeHook)
|
||||
return PR_FALSE;
|
||||
|
||||
gAllocationSizeHook = hook;
|
||||
|
||||
if(!defaultDbgAllocHook)
|
||||
defaultDbgAllocHook = _CrtSetAllocHook(dhw_DbgAllocHook);
|
||||
else
|
||||
_CrtSetAllocHook(dhw_DbgAllocHook);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
dhwClearAllocationSizeDebugHook()
|
||||
{
|
||||
if(!gAllocationSizeHook)
|
||||
return PR_FALSE;
|
||||
gAllocationSizeHook = nsnull;
|
||||
_CrtSetAllocHook(defaultDbgAllocHook);
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif //0
|
||||
@@ -1,229 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Win32 x86 code for stack walking, symbol resolution, and function hooking */
|
||||
|
||||
#ifndef __nsDebugHelpWin32_h__
|
||||
#define __nsDebugHelpWin32_h__
|
||||
|
||||
#if defined(_WIN32) && defined(_M_IX86)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <imagehlp.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#error "nsDebugHelpWin32.h should only be included in Win32 x86 builds"
|
||||
#endif
|
||||
|
||||
// XXX temporary hack...
|
||||
//#include "hacky_defines.h"
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
// useful macros...
|
||||
|
||||
#define DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_) \
|
||||
typedef retval_ ( conv_ * typename_ ) args_ ;
|
||||
|
||||
#ifdef DHW_IMPLEMENT_GLOBALS
|
||||
#define DHW_DECLARE_FUN_GLOBAL(typename_, name_) typename_ dhw##name_
|
||||
#else
|
||||
#define DHW_DECLARE_FUN_GLOBAL(typename_, name_) extern typename_ dhw##name_
|
||||
#endif
|
||||
|
||||
#define DHW_DECLARE_FUN_PROTO(retval_, conv_, name_, args_) \
|
||||
retval_ conv_ name_ args_
|
||||
|
||||
#define DHW_DECLARE_FUN_STATIC_PROTO(retval_, name_, args_) \
|
||||
static retval_ conv_ name_ args_
|
||||
|
||||
#define DHW_DECLARE_FUN_TYPE_AND_PROTO(name_, retval_, conv_, typename_, args_) \
|
||||
DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
|
||||
DHW_DECLARE_FUN_PROTO(retval_, conv_, name_, args_)
|
||||
|
||||
#define DHW_DECLARE_FUN_TYPE_AND_STATIC_PROTO(name_, retval_, conv_, typename_, args_) \
|
||||
DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
|
||||
DHW_DECLARE_FUN_STATIC_PROTO(retval_, conv_, name_, args_)
|
||||
|
||||
#define DHW_DECLARE_FUN_TYPE_AND_GLOBAL(typename_, name_, retval_, conv_, args_) \
|
||||
DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
|
||||
DHW_DECLARE_FUN_GLOBAL(typename_, name_)
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
// These are used to get 'original' function addresses from DHWImportHooker.
|
||||
|
||||
#define DHW_DECLARE_ORIGINAL(type_, name_, hooker_) \
|
||||
type_ name_ = (type_) hooker_ . GetOriginalFunction()
|
||||
|
||||
#define DHW_DECLARE_ORIGINAL_PTR(type_, name_, hooker_) \
|
||||
type_ name_ = (type_) hooker_ -> GetOriginalFunction()
|
||||
|
||||
#define DHW_ORIGINAL(type_, hooker_) \
|
||||
((type_) hooker_ . GetOriginalFunction())
|
||||
|
||||
#define DHW_ORIGINAL_PTR(type_, hooker_) \
|
||||
((type_) hooker_ -> GetOriginalFunction())
|
||||
|
||||
/***************************************************************************/
|
||||
// Global declarations of entry points into ImgHelp functions
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMINITIALIZEPROC, SymInitialize, \
|
||||
BOOL, __stdcall, (HANDLE, LPSTR, BOOL));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMSETOPTIONS, SymSetOptions, \
|
||||
DWORD, __stdcall, (DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETOPTIONS, SymGetOptions, \
|
||||
DWORD, __stdcall, ());
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETMODULEINFO, SymGetModuleInfo, \
|
||||
BOOL, __stdcall, (HANDLE, DWORD, PIMAGEHLP_MODULE));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETSYMFROMADDRPROC, SymGetSymFromAddr, \
|
||||
BOOL, __stdcall, (HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(ENUMERATELOADEDMODULES, EnumerateLoadedModules, \
|
||||
BOOL, __stdcall, (HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(IMAGEDIRECTORYENTRYTODATA, ImageDirectoryEntryToData, \
|
||||
PVOID, __stdcall, (PVOID, BOOL, USHORT, PULONG));
|
||||
|
||||
|
||||
// We aren't using any of the below yet...
|
||||
|
||||
/*
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMCLEANUPPROC, SymCleanup, \
|
||||
BOOL, __stdcall, (HANDLE));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(STACKWALKPROC, StackWalk, \
|
||||
BOOL,
|
||||
__stdcall,
|
||||
(DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID, \
|
||||
PREAD_PROCESS_MEMORY_ROUTINE, \
|
||||
PFUNCTION_TABLE_ACCESS_ROUTINE, \
|
||||
PGET_MODULE_BASE_ROUTINE, \
|
||||
PTRANSLATE_ADDRESS_ROUTINE));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMFUNCTIONTABLEACCESSPROC, SymFunctionTableAccess, \
|
||||
LPVOID, __stdcall, (HANDLE, DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETMODULEBASEPROC, SymGetModuleBase, \
|
||||
DWORD, __stdcall, (HANDLE, DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMLOADMODULE, SymLoadModule, \
|
||||
DWORD, __stdcall, (HANDLE, HANDLE, PSTR, PSTR, DWORD, DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(UNDECORATESYMBOLNAME, _UnDecorateSymbolName, \
|
||||
DWORD, __stdcall, (LPCSTR, LPSTR, DWORD, DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMUNDNAME, SymUnDName, \
|
||||
BOOL, __stdcall, (PIMAGEHLP_SYMBOL, LPSTR, DWORD));
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETLINEFROMADDR, SymGetLineFromAddr, \
|
||||
BOOL, __stdcall, (HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE));
|
||||
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
extern PRBool
|
||||
dhwEnsureImageHlpInitialized();
|
||||
|
||||
extern PRBool
|
||||
dhwEnsureSymInitialized();
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
DHW_DECLARE_FUN_TYPE(FARPROC, __stdcall, GETPROCADDRESS, (HMODULE, PCSTR));
|
||||
|
||||
class DHWImportHooker
|
||||
{
|
||||
public:
|
||||
|
||||
DHWImportHooker(const char* aModuleName,
|
||||
const char* aFunctionName,
|
||||
PROC aHook,
|
||||
PRBool aExcludeOurModule = PR_FALSE);
|
||||
|
||||
~DHWImportHooker();
|
||||
|
||||
PROC GetOriginalFunction() {return mOriginal;}
|
||||
|
||||
PRBool PatchAllModules();
|
||||
PRBool PatchOneModule(HMODULE aModule, const char* name);
|
||||
static PRBool ModuleLoaded(HMODULE aModule, DWORD flags);
|
||||
|
||||
|
||||
// I think that these should be made not static members, but allocated
|
||||
// things created in an explicit static 'init' method and cleaned up in
|
||||
// an explicit static 'finish' method. This would allow the application
|
||||
// to have proper lifetime control over all the hooks.
|
||||
|
||||
static DHWImportHooker &getLoadLibraryWHooker();
|
||||
static DHWImportHooker &getLoadLibraryExWHooker();
|
||||
static DHWImportHooker &getLoadLibraryAHooker();
|
||||
static DHWImportHooker &getLoadLibraryExAHooker();
|
||||
static DHWImportHooker &getGetProcAddressHooker();
|
||||
|
||||
static HMODULE WINAPI LoadLibraryA(PCSTR path);
|
||||
|
||||
private:
|
||||
DHWImportHooker* mNext;
|
||||
const char* mModuleName;
|
||||
const char* mFunctionName;
|
||||
PROC mOriginal;
|
||||
PROC mHook;
|
||||
HMODULE mIgnoreModule;
|
||||
PRBool mHooking;
|
||||
|
||||
private:
|
||||
static PRLock* gLock;
|
||||
static DHWImportHooker* gHooks;
|
||||
static GETPROCADDRESS gRealGetProcAddress;
|
||||
|
||||
static HMODULE WINAPI LoadLibraryW(PCWSTR path);
|
||||
static HMODULE WINAPI LoadLibraryExW(PCWSTR path, HANDLE file, DWORD flags);
|
||||
static HMODULE WINAPI LoadLibraryExA(PCSTR path, HANDLE file, DWORD flags);
|
||||
|
||||
static FARPROC WINAPI GetProcAddress(HMODULE aModule, PCSTR aFunctionName);
|
||||
};
|
||||
|
||||
#endif /* __nsDebugHelpWin32_h__ */
|
||||
@@ -1,306 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsError_h__
|
||||
#define nsError_h__
|
||||
|
||||
#ifndef nscore_h___
|
||||
#include "nscore.h" /* needed for nsresult */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* To add error code to your module, you need to do the following:
|
||||
*
|
||||
* 1) Add a module offset code. Add yours to the bottom of the list
|
||||
* right below this comment, adding 1.
|
||||
*
|
||||
* 2) In your module, define a header file which uses one of the
|
||||
* NE_ERROR_GENERATExxxxxx macros. Some examples below:
|
||||
*
|
||||
* #define NS_ERROR_MYMODULE_MYERROR1 NS_ERROR_GENERATE(NS_ERROR_SEVERITY_ERROR,NS_ERROR_MODULE_MYMODULE,1)
|
||||
* #define NS_ERROR_MYMODULE_MYERROR2 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MYMODULE,2)
|
||||
* #define NS_ERROR_MYMODULE_MYERROR3 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MYMODULE,3)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Standard Module Offset Code. Each Module should identify a unique number
|
||||
* and then all errors associated with that module become offsets from the
|
||||
* base associated with that module id. There are 16 bits of code bits for
|
||||
* each module.
|
||||
*/
|
||||
|
||||
#define NS_ERROR_MODULE_XPCOM 1
|
||||
#define NS_ERROR_MODULE_BASE 2
|
||||
#define NS_ERROR_MODULE_GFX 3
|
||||
#define NS_ERROR_MODULE_WIDGET 4
|
||||
#define NS_ERROR_MODULE_CALENDAR 5
|
||||
#define NS_ERROR_MODULE_NETWORK 6
|
||||
#define NS_ERROR_MODULE_PLUGINS 7
|
||||
#define NS_ERROR_MODULE_LAYOUT 8
|
||||
#define NS_ERROR_MODULE_HTMLPARSER 9
|
||||
#define NS_ERROR_MODULE_RDF 10
|
||||
#define NS_ERROR_MODULE_UCONV 11
|
||||
#define NS_ERROR_MODULE_REG 12
|
||||
#define NS_ERROR_MODULE_FILES 13
|
||||
#define NS_ERROR_MODULE_DOM 14
|
||||
#define NS_ERROR_MODULE_IMGLIB 15
|
||||
#define NS_ERROR_MODULE_MAILNEWS 16
|
||||
#define NS_ERROR_MODULE_EDITOR 17
|
||||
#define NS_ERROR_MODULE_XPCONNECT 18
|
||||
#define NS_ERROR_MODULE_PROFILE 19
|
||||
#define NS_ERROR_MODULE_LDAP 20
|
||||
#define NS_ERROR_MODULE_SECURITY 21
|
||||
#define NS_ERROR_MODULE_DOM_XPATH 22
|
||||
#define NS_ERROR_MODULE_DOM_RANGE 23
|
||||
#define NS_ERROR_MODULE_URILOADER 24
|
||||
#define NS_ERROR_MODULE_CONTENT 25
|
||||
#define NS_ERROR_MODULE_PYXPCOM 26
|
||||
|
||||
/* NS_ERROR_MODULE_GENERAL should be used by modules that do not
|
||||
* care if return code values overlap. Callers of methods that
|
||||
* return such codes should be aware that they are not
|
||||
* globally unique. Implementors should be careful about blindly
|
||||
* returning codes from other modules that might also use
|
||||
* the generic base.
|
||||
*/
|
||||
#define NS_ERROR_MODULE_GENERAL 51
|
||||
|
||||
/**
|
||||
* @name Standard Error Handling Macros
|
||||
*/
|
||||
|
||||
#define NS_FAILED(_nsresult) ((_nsresult) & 0x80000000)
|
||||
#define NS_SUCCEEDED(_nsresult) (!((_nsresult) & 0x80000000))
|
||||
|
||||
/**
|
||||
* @name Severity Code. This flag identifies the level of warning
|
||||
*/
|
||||
|
||||
#define NS_ERROR_SEVERITY_SUCCESS 0
|
||||
#define NS_ERROR_SEVERITY_ERROR 1
|
||||
|
||||
/**
|
||||
* @name Mozilla Code. This flag separates consumers of mozilla code
|
||||
* from the native platform
|
||||
*/
|
||||
|
||||
#define NS_ERROR_MODULE_BASE_OFFSET 0x45
|
||||
|
||||
/**
|
||||
* @name Standard Error Generating Macros
|
||||
*/
|
||||
|
||||
#define NS_ERROR_GENERATE(sev,module,code) \
|
||||
((nsresult) (((PRUint32)(sev)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
||||
|
||||
#define NS_ERROR_GENERATE_SUCCESS(module,code) \
|
||||
((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_SUCCESS)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
||||
|
||||
#define NS_ERROR_GENERATE_FAILURE(module,code) \
|
||||
((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_ERROR)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
||||
|
||||
/**
|
||||
* @name Standard Macros for retrieving error bits
|
||||
*/
|
||||
|
||||
#define NS_ERROR_GET_CODE(err) ((err) & 0xffff)
|
||||
#define NS_ERROR_GET_MODULE(err) (((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff))
|
||||
#define NS_ERROR_GET_SEVERITY(err) (((err) >> 31) & 0x1)
|
||||
|
||||
/**
|
||||
* @name Standard return values
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/* Standard "it worked" return value */
|
||||
#define NS_OK 0
|
||||
|
||||
#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
|
||||
|
||||
/* Returned when an instance is not initialized */
|
||||
#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
|
||||
|
||||
/* Returned when an instance is already initialized */
|
||||
#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
|
||||
|
||||
/* Returned by a not implemented function */
|
||||
#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
|
||||
|
||||
/* Returned when a given interface is not supported. */
|
||||
#define NS_NOINTERFACE ((nsresult) 0x80004002L)
|
||||
#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
|
||||
|
||||
#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
|
||||
#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
|
||||
|
||||
/* Returned when a function aborts */
|
||||
#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
|
||||
|
||||
/* Returned when a function fails */
|
||||
#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
|
||||
|
||||
/* Returned when an unexpected error occurs */
|
||||
#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
|
||||
|
||||
/* Returned when a memory allocation fails */
|
||||
#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
|
||||
|
||||
/* Returned when an illegal value is passed */
|
||||
#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
|
||||
#define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
|
||||
|
||||
/* Returned when a class doesn't allow aggregation */
|
||||
#define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
|
||||
|
||||
/* Returned when an operation can't complete due to an unavailable resource */
|
||||
#define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
|
||||
|
||||
/* Returned when a class is not registered */
|
||||
#define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
|
||||
|
||||
/* Returned when a class cannot be registered, but may be tried again later */
|
||||
#define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
|
||||
|
||||
/* Returned when a dynamically loaded factory couldn't be found */
|
||||
#define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
|
||||
|
||||
/* Returned when a factory doesn't support signatures */
|
||||
#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
|
||||
(NS_ERROR_BASE + 0x101)
|
||||
|
||||
/* Returned when a factory already is registered */
|
||||
#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
|
||||
|
||||
|
||||
/* For COM compatibility reasons, we want to use exact error code numbers
|
||||
for NS_ERROR_PROXY_INVALID_IN_PARAMETER and NS_ERROR_PROXY_INVALID_OUT_PARAMETER.
|
||||
The first matches:
|
||||
|
||||
#define RPC_E_INVALID_PARAMETER _HRESULT_TYPEDEF_(0x80010010L)
|
||||
|
||||
Errors returning this mean that the xpcom proxy code could not create a proxy for
|
||||
one of the in paramaters.
|
||||
|
||||
Because of this, we are ignoring the convention if using a base and offset for
|
||||
error numbers.
|
||||
|
||||
*/
|
||||
|
||||
/* Returned when a proxy could not be create a proxy for one of the IN parameters
|
||||
This is returned only when the "real" meathod has NOT been invoked.
|
||||
*/
|
||||
|
||||
#define NS_ERROR_PROXY_INVALID_IN_PARAMETER ((nsresult) 0x80010010L)
|
||||
|
||||
/* Returned when a proxy could not be create a proxy for one of the OUT parameters
|
||||
This is returned only when the "real" meathod has ALREADY been invoked.
|
||||
*/
|
||||
|
||||
#define NS_ERROR_PROXY_INVALID_OUT_PARAMETER ((nsresult) 0x80010011L)
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
/* I/O Errors */
|
||||
|
||||
/* Stream closed */
|
||||
#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
|
||||
/* Error from the operating system */
|
||||
#define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3)
|
||||
/* Illegal arguments */
|
||||
#define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4)
|
||||
/* For unichar streams */
|
||||
#define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5)
|
||||
/* For unichar streams */
|
||||
#define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6)
|
||||
|
||||
#define NS_BASE_STREAM_WOULD_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 7)
|
||||
|
||||
|
||||
#define NS_ERROR_FILE_UNRECOGNIZED_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 1)
|
||||
#define NS_ERROR_FILE_UNRESOLVABLE_SYMLINK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 2)
|
||||
#define NS_ERROR_FILE_EXECUTION_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 3)
|
||||
#define NS_ERROR_FILE_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 4)
|
||||
#define NS_ERROR_FILE_DESTINATION_NOT_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 5)
|
||||
#define NS_ERROR_FILE_TARGET_DOES_NOT_EXIST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 6)
|
||||
#define NS_ERROR_FILE_COPY_OR_MOVE_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 7)
|
||||
#define NS_ERROR_FILE_ALREADY_EXISTS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 8)
|
||||
#define NS_ERROR_FILE_INVALID_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 9)
|
||||
#define NS_ERROR_FILE_DISK_FULL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 10)
|
||||
#define NS_ERROR_FILE_CORRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 11)
|
||||
#define NS_ERROR_FILE_NOT_DIRECTORY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 12)
|
||||
#define NS_ERROR_FILE_IS_DIRECTORY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 13)
|
||||
#define NS_ERROR_FILE_IS_LOCKED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 14)
|
||||
#define NS_ERROR_FILE_TOO_BIG NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 15)
|
||||
#define NS_ERROR_FILE_NO_DEVICE_SPACE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 16)
|
||||
#define NS_ERROR_FILE_NAME_TOO_LONG NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 17)
|
||||
#define NS_ERROR_FILE_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 18)
|
||||
#define NS_ERROR_FILE_READ_ONLY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 19)
|
||||
#define NS_ERROR_FILE_DIR_NOT_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 20)
|
||||
#define NS_ERROR_FILE_ACCESS_DENIED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 21)
|
||||
|
||||
/* Result codes used by nsIVariant */
|
||||
|
||||
#define NS_ERROR_CANNOT_CONVERT_DATA NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 1)
|
||||
#define NS_ERROR_OBJECT_IS_IMMUTABLE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 2)
|
||||
#define NS_ERROR_LOSS_OF_SIGNIFICANT_DATA NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 3)
|
||||
|
||||
#define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 1)
|
||||
|
||||
|
||||
/*
|
||||
* This will return the nsresult corresponding to the most recent NSPR failure
|
||||
* returned by PR_GetError.
|
||||
*
|
||||
***********************************************************************
|
||||
* Do not depend on this function. It will be going away!
|
||||
***********************************************************************
|
||||
*/
|
||||
extern NS_COM nsresult
|
||||
NS_ErrorAccordingToNSPR();
|
||||
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#pragma warning(disable: 4251) /* 'nsCOMPtr<class nsIInputStream>' needs to have dll-interface to be used by clients of class 'nsInputStream' */
|
||||
#pragma warning(disable: 4275) /* non dll-interface class 'nsISupports' used as base for dll-interface class 'nsIRDFNode' */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsErrorService.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static void* PR_CALLBACK
|
||||
CloneCString(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
return nsCRT::strdup((const char*)aData);
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK
|
||||
DeleteCString(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
nsCRT::free((char*)aData);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsInt2StrHashtable::nsInt2StrHashtable()
|
||||
: mHashtable(CloneCString, nsnull, DeleteCString, nsnull, 16)
|
||||
{
|
||||
}
|
||||
|
||||
nsInt2StrHashtable::~nsInt2StrHashtable()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInt2StrHashtable::Put(PRUint32 key, const char* aData)
|
||||
{
|
||||
char* value = nsCRT::strdup(aData);
|
||||
if (value == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsVoidKey k((void*)key);
|
||||
char* oldValue = (char*)mHashtable.Put(&k, value);
|
||||
if (oldValue)
|
||||
nsCRT::free(oldValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char*
|
||||
nsInt2StrHashtable::Get(PRUint32 key)
|
||||
{
|
||||
nsVoidKey k((void*)key);
|
||||
const char* value = (const char*)mHashtable.Get(&k);
|
||||
if (value == nsnull)
|
||||
return nsnull;
|
||||
return nsCRT::strdup(value);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInt2StrHashtable::Remove(PRUint32 key)
|
||||
{
|
||||
nsVoidKey k((void*)key);
|
||||
char* oldValue = (char*)mHashtable.Remove(&k);
|
||||
if (oldValue)
|
||||
nsCRT::free(oldValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsErrorService, nsIErrorService)
|
||||
|
||||
NS_METHOD
|
||||
nsErrorService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_NO_AGGREGATION(outer);
|
||||
nsErrorService* serv = new nsErrorService();
|
||||
if (serv == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(serv);
|
||||
nsresult rv = serv->QueryInterface(aIID, aInstancePtr);
|
||||
NS_RELEASE(serv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::RegisterErrorStringBundle(PRInt16 errorModule, const char *stringBundleURL)
|
||||
{
|
||||
return mErrorStringBundleURLMap.Put(errorModule, stringBundleURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::UnregisterErrorStringBundle(PRInt16 errorModule)
|
||||
{
|
||||
return mErrorStringBundleURLMap.Remove(errorModule);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::GetErrorStringBundle(PRInt16 errorModule, char **result)
|
||||
{
|
||||
char* value = mErrorStringBundleURLMap.Get(errorModule);
|
||||
if (value == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*result = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::RegisterErrorStringBundleKey(nsresult error, const char *stringBundleKey)
|
||||
{
|
||||
return mErrorStringBundleKeyMap.Put(error, stringBundleKey);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::UnregisterErrorStringBundleKey(nsresult error)
|
||||
{
|
||||
return mErrorStringBundleKeyMap.Remove(error);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsErrorService::GetErrorStringBundleKey(nsresult error, char **result)
|
||||
{
|
||||
char* value = mErrorStringBundleKeyMap.Get(error);
|
||||
if (value == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*result = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsErrorService_h__
|
||||
#define nsErrorService_h__
|
||||
|
||||
#include "nsIErrorService.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class nsInt2StrHashtable
|
||||
{
|
||||
public:
|
||||
nsInt2StrHashtable();
|
||||
virtual ~nsInt2StrHashtable();
|
||||
|
||||
nsresult Put(PRUint32 key, const char* aData);
|
||||
char* Get(PRUint32 key);
|
||||
nsresult Remove(PRUint32 key);
|
||||
|
||||
protected:
|
||||
nsObjectHashtable mHashtable;
|
||||
};
|
||||
|
||||
class nsErrorService : public nsIErrorService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIERRORSERVICE
|
||||
|
||||
nsErrorService() {}
|
||||
virtual ~nsErrorService() {}
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
protected:
|
||||
nsInt2StrHashtable mErrorStringBundleURLMap;
|
||||
nsInt2StrHashtable mErrorStringBundleKeyMap;
|
||||
};
|
||||
|
||||
#endif // nsErrorService_h__
|
||||
@@ -1,349 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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
|
||||
* ActiveState Tool Corp..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark Hammond <MarkH@ActiveState.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsExceptionService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prthread.h"
|
||||
#include "prlock.h"
|
||||
static const PRUintn BAD_TLS_INDEX = (PRUintn) -1;
|
||||
|
||||
#define CHECK_SERVICE_USE_OK() if (!lock) return NS_ERROR_NOT_INITIALIZED
|
||||
#define CHECK_MANAGER_USE_OK() if (!mService || !nsExceptionService::lock) return NS_ERROR_NOT_INITIALIZED
|
||||
|
||||
// A key for our registered module providers hashtable
|
||||
class nsProviderKey : public nsHashKey {
|
||||
protected:
|
||||
PRUint32 mKey;
|
||||
public:
|
||||
nsProviderKey(PRUint32 key) : mKey(key) {}
|
||||
PRUint32 HashCode(void) const {
|
||||
return mKey;
|
||||
}
|
||||
PRBool Equals(const nsHashKey *aKey) const {
|
||||
return mKey == ((const nsProviderKey *) aKey)->mKey;
|
||||
}
|
||||
nsHashKey *Clone() const {
|
||||
return new nsProviderKey(mKey);
|
||||
}
|
||||
PRUint32 GetValue() { return mKey; }
|
||||
};
|
||||
|
||||
/** Exception Manager definition **/
|
||||
class nsExceptionManager : public nsIExceptionManager
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXCEPTIONMANAGER
|
||||
|
||||
nsExceptionManager(nsExceptionService *svc);
|
||||
virtual ~nsExceptionManager();
|
||||
/* additional members */
|
||||
nsCOMPtr<nsIException> mCurrentException;
|
||||
nsExceptionManager *mNextThread; // not ref-counted.
|
||||
nsExceptionService *mService; // not ref-counted
|
||||
#ifdef NS_DEBUG
|
||||
static PRInt32 totalInstances;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 nsExceptionManager::totalInstances = 0;
|
||||
#endif
|
||||
|
||||
// Note this object is single threaded - the service itself ensures
|
||||
// one per thread.
|
||||
// An exception if the destructor, which may be called on
|
||||
// the thread shutting down xpcom
|
||||
NS_IMPL_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
|
||||
|
||||
nsExceptionManager::nsExceptionManager(nsExceptionService *svc) :
|
||||
mNextThread(nsnull),
|
||||
mService(svc)
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
#ifdef NS_DEBUG
|
||||
PR_AtomicIncrement(&totalInstances);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsExceptionManager::~nsExceptionManager()
|
||||
{
|
||||
/* destructor code */
|
||||
#ifdef NS_DEBUG
|
||||
PR_AtomicDecrement(&totalInstances);
|
||||
#endif // NS_DEBUG
|
||||
}
|
||||
|
||||
/* void setCurrentException (in nsIException error); */
|
||||
NS_IMETHODIMP nsExceptionManager::SetCurrentException(nsIException *error)
|
||||
{
|
||||
CHECK_MANAGER_USE_OK();
|
||||
mCurrentException = error;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIException getCurrentException (); */
|
||||
NS_IMETHODIMP nsExceptionManager::GetCurrentException(nsIException **_retval)
|
||||
{
|
||||
CHECK_MANAGER_USE_OK();
|
||||
*_retval = mCurrentException;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
|
||||
NS_IMETHODIMP nsExceptionManager::GetExceptionFromProvider(nsresult rc, nsIException * defaultException, nsIException **_retval)
|
||||
{
|
||||
CHECK_MANAGER_USE_OK();
|
||||
// Just delegate back to the service with the provider map.
|
||||
return mService->GetExceptionFromProvider(rc, defaultException, _retval);
|
||||
}
|
||||
|
||||
/* The Exception Service */
|
||||
|
||||
PRUintn nsExceptionService::tlsIndex = BAD_TLS_INDEX;
|
||||
PRLock *nsExceptionService::lock = PR_FALSE;
|
||||
nsExceptionManager *nsExceptionService::firstThread = nsnull;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 nsExceptionService::totalInstances = 0;
|
||||
#endif
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsExceptionService, nsIExceptionService, nsIObserver)
|
||||
|
||||
nsExceptionService::nsExceptionService()
|
||||
: mProviders(4, PR_TRUE) /* small, thread-safe hashtable */
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
if (PR_AtomicIncrement(&totalInstances)!=1) {
|
||||
NS_ERROR("The nsExceptionService is a singleton!");
|
||||
}
|
||||
#endif
|
||||
/* member initializers and constructor code */
|
||||
if (tlsIndex == BAD_TLS_INDEX) {
|
||||
PRStatus status;
|
||||
status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct );
|
||||
NS_WARN_IF_FALSE(status==0, "ScriptErrorService could not allocate TLS storage.");
|
||||
}
|
||||
lock = PR_NewLock();
|
||||
NS_WARN_IF_FALSE(lock, "Error allocating ExceptionService lock");
|
||||
|
||||
// observe XPCOM shutdown.
|
||||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_WARN_IF_FALSE(observerService, "Could not get observer service!");
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
}
|
||||
|
||||
nsExceptionService::~nsExceptionService()
|
||||
{
|
||||
Shutdown();
|
||||
/* destructor code */
|
||||
#ifdef NS_DEBUG
|
||||
PR_AtomicDecrement(&totalInstances);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void nsExceptionService::ThreadDestruct( void *data )
|
||||
{
|
||||
if (!lock) {
|
||||
NS_WARNING("nsExceptionService ignoring thread destruction after shutdown");
|
||||
return;
|
||||
}
|
||||
DropThread( (nsExceptionManager *)data );
|
||||
}
|
||||
|
||||
|
||||
void nsExceptionService::Shutdown()
|
||||
{
|
||||
mProviders.Reset();
|
||||
if (lock) {
|
||||
DropAllThreads();
|
||||
PR_DestroyLock(lock);
|
||||
lock = nsnull;
|
||||
}
|
||||
PR_SetThreadPrivate(tlsIndex, nsnull);
|
||||
}
|
||||
|
||||
/* void setCurrentException (in nsIException error); */
|
||||
NS_IMETHODIMP nsExceptionService::SetCurrentException(nsIException *error)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
nsCOMPtr<nsIExceptionManager> sm;
|
||||
nsresult nr = GetCurrentExceptionManager(getter_AddRefs(sm));
|
||||
if (NS_FAILED(nr))
|
||||
return nr;
|
||||
return sm->SetCurrentException(error);
|
||||
}
|
||||
|
||||
/* nsIException getCurrentException (); */
|
||||
NS_IMETHODIMP nsExceptionService::GetCurrentException(nsIException **_retval)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
nsCOMPtr<nsIExceptionManager> sm;
|
||||
nsresult nr = GetCurrentExceptionManager(getter_AddRefs(sm));
|
||||
if (NS_FAILED(nr))
|
||||
return nr;
|
||||
return sm->GetCurrentException(_retval);
|
||||
}
|
||||
|
||||
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
|
||||
NS_IMETHODIMP nsExceptionService::GetExceptionFromProvider(nsresult rc,
|
||||
nsIException * defaultException, nsIException **_retval)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
return DoGetExceptionFromProvider(rc, defaultException, _retval);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIExceptionManager currentExceptionManager; */
|
||||
NS_IMETHODIMP nsExceptionService::GetCurrentExceptionManager(nsIExceptionManager * *aCurrentScriptManager)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
nsExceptionManager *mgr = (nsExceptionManager *)PR_GetThreadPrivate(tlsIndex);
|
||||
if (mgr == nsnull) {
|
||||
// Stick the new exception object in with no reference count.
|
||||
mgr = new nsExceptionManager(this);
|
||||
if (mgr == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
PR_SetThreadPrivate(tlsIndex, mgr);
|
||||
// The reference count is held in the thread-list
|
||||
AddThread(mgr);
|
||||
}
|
||||
*aCurrentScriptManager = mgr;
|
||||
NS_ADDREF(*aCurrentScriptManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void registerErrorProvider (in nsIExceptionProvider provider, in PRUint32 moduleCode); */
|
||||
NS_IMETHODIMP nsExceptionService::RegisterExceptionProvider(nsIExceptionProvider *provider, PRUint32 errorModule)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
|
||||
nsProviderKey key(errorModule);
|
||||
if (mProviders.Put(&key, provider)) {
|
||||
NS_WARNING("Registration of exception provider overwrote another provider with the same module code!");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void unregisterErrorProvider (in nsIExceptionProvider provider, in PRUint32 errorModule); */
|
||||
NS_IMETHODIMP nsExceptionService::UnregisterExceptionProvider(nsIExceptionProvider *provider, PRUint32 errorModule)
|
||||
{
|
||||
CHECK_SERVICE_USE_OK();
|
||||
nsProviderKey key(errorModule);
|
||||
if (!mProviders.Remove(&key)) {
|
||||
NS_WARNING("Attempt to unregister an unregistered exception provider!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIObserver
|
||||
NS_IMETHODIMP nsExceptionService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
Shutdown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExceptionService::DoGetExceptionFromProvider(nsresult errCode,
|
||||
nsIException * defaultException,
|
||||
nsIException **_exc)
|
||||
{
|
||||
// Check for an existing exception
|
||||
nsresult nr = GetCurrentException(_exc);
|
||||
if (NS_SUCCEEDED(nr) && *_exc) {
|
||||
(*_exc)->GetResult(&nr);
|
||||
// If it matches our result then use it
|
||||
if (nr == errCode)
|
||||
return NS_OK;
|
||||
NS_RELEASE(*_exc);
|
||||
}
|
||||
nsProviderKey key(NS_ERROR_GET_MODULE(errCode));
|
||||
nsCOMPtr<nsIExceptionProvider> provider =
|
||||
dont_AddRef((nsIExceptionProvider *)mProviders.Get(&key));
|
||||
|
||||
// No provider so we'll return the default exception
|
||||
if (!provider) {
|
||||
*_exc = defaultException;
|
||||
NS_IF_ADDREF(*_exc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return provider->GetException(errCode, defaultException, _exc);
|
||||
}
|
||||
|
||||
// thread management
|
||||
/*static*/ void nsExceptionService::AddThread(nsExceptionManager *thread)
|
||||
{
|
||||
PR_Lock(lock);
|
||||
thread->mNextThread = firstThread;
|
||||
firstThread = thread;
|
||||
NS_ADDREF(thread);
|
||||
PR_Unlock(lock);
|
||||
}
|
||||
|
||||
/*static*/ void nsExceptionService::DoDropThread(nsExceptionManager *thread)
|
||||
{
|
||||
nsExceptionManager **emp = &firstThread;
|
||||
while (*emp != thread) {
|
||||
NS_ABORT_IF_FALSE(*emp, "Could not find the thread to drop!");
|
||||
emp = &(*emp)->mNextThread;
|
||||
}
|
||||
*emp = thread->mNextThread;
|
||||
NS_RELEASE(thread);
|
||||
}
|
||||
|
||||
/*static*/ void nsExceptionService::DropThread(nsExceptionManager *thread)
|
||||
{
|
||||
PR_Lock(lock);
|
||||
DoDropThread(thread);
|
||||
PR_Unlock(lock);
|
||||
}
|
||||
|
||||
/*static*/ void nsExceptionService::DropAllThreads()
|
||||
{
|
||||
PR_Lock(lock);
|
||||
while (firstThread)
|
||||
DoDropThread(firstThread);
|
||||
PR_Unlock(lock);
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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
|
||||
* ActiveState Tool Corp..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark Hammond <MarkH@ActiveState.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsExceptionService_h__
|
||||
#define nsExceptionService_h__
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIException.h"
|
||||
#include "nsIExceptionService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
class nsExceptionManager;
|
||||
|
||||
/** Exception Service definition **/
|
||||
class nsExceptionService : public nsIExceptionService, public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXCEPTIONSERVICE
|
||||
NS_DECL_NSIEXCEPTIONMANAGER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsExceptionService();
|
||||
virtual ~nsExceptionService();
|
||||
|
||||
/* additional members */
|
||||
nsresult DoGetExceptionFromProvider(nsresult errCode,
|
||||
nsIException *defaultException,
|
||||
nsIException **_richError);
|
||||
void Shutdown();
|
||||
|
||||
|
||||
/* thread management and cleanup */
|
||||
static void AddThread(nsExceptionManager *);
|
||||
static void DropThread(nsExceptionManager *);
|
||||
static void DoDropThread(nsExceptionManager *thread);
|
||||
|
||||
static void DropAllThreads();
|
||||
static nsExceptionManager *firstThread;
|
||||
|
||||
nsSupportsHashtable mProviders;
|
||||
|
||||
/* single lock protects both providers hashtable
|
||||
and thread list */
|
||||
static PRLock* lock;
|
||||
|
||||
static PRUintn tlsIndex;
|
||||
static void PR_CALLBACK ThreadDestruct( void *data );
|
||||
#ifdef NS_DEBUG
|
||||
static PRInt32 totalInstances;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif // nsExceptionService_h__
|
||||
@@ -1,110 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
nsGarbageCollector.c
|
||||
*/
|
||||
|
||||
#ifdef GC_LEAK_DETECTOR
|
||||
|
||||
/* for FILE */
|
||||
#include <stdio.h>
|
||||
|
||||
/* NSPR stuff */
|
||||
#include "generic_threads.h"
|
||||
#include "prthread.h"
|
||||
#include "prlock.h"
|
||||
|
||||
/* Linux/Win32 export private NSPR files to include/private */
|
||||
#ifdef XP_MAC
|
||||
#include "pprthred.h"
|
||||
#else
|
||||
#include "private/pprthred.h"
|
||||
#endif
|
||||
|
||||
#include "nsLeakDetector.h"
|
||||
|
||||
extern FILE *GC_stdout, *GC_stderr;
|
||||
|
||||
extern void GC_gcollect(void);
|
||||
extern void GC_clear_roots(void);
|
||||
|
||||
static PRStatus PR_CALLBACK scanner(PRThread* t, void** baseAddr, PRUword count, void* closure)
|
||||
{
|
||||
char* begin = (char*)baseAddr;
|
||||
char* end = (char*)(baseAddr + count);
|
||||
GC_mark_range_proc marker = (GC_mark_range_proc) closure;
|
||||
marker(begin, end);
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static void mark_all_stacks(GC_mark_range_proc marker)
|
||||
{
|
||||
/* PR_ThreadScanStackPointers(PR_GetCurrentThread(), &scanner, marker); */
|
||||
PR_ScanStackPointers(&scanner, (void *)marker);
|
||||
}
|
||||
|
||||
static void locker(void* mutex)
|
||||
{
|
||||
PR_Lock(mutex);
|
||||
}
|
||||
|
||||
static void unlocker(void* mutex)
|
||||
{
|
||||
PR_Unlock(mutex);
|
||||
}
|
||||
|
||||
static void stopper(void* unused)
|
||||
{
|
||||
PR_SuspendAll();
|
||||
}
|
||||
|
||||
static void starter(void* unused)
|
||||
{
|
||||
PR_ResumeAll();
|
||||
}
|
||||
|
||||
nsresult NS_InitGarbageCollector()
|
||||
{
|
||||
PRLock* mutex;
|
||||
|
||||
/* redirect GC's stderr to catch startup leaks. */
|
||||
GC_stderr = fopen("StartupLeaks", "w");
|
||||
|
||||
mutex = PR_NewLock();
|
||||
if (mutex == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GC_generic_init_threads(&mark_all_stacks, mutex,
|
||||
&locker, &unlocker,
|
||||
&stopper, &starter);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_ShutdownGarbageCollector()
|
||||
{
|
||||
/* do anything you need to shut down the collector. */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif /* GC_LEAK_DETECTOR */
|
||||
@@ -1,56 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* XXX This file is obsolete. Use nsIMemory.idl or nsMemory.h instead.
|
||||
*/
|
||||
|
||||
#ifndef nsIAllocator_h___
|
||||
#define nsIAllocator_h___
|
||||
|
||||
#include "nsMemory.h"
|
||||
|
||||
#define nsIAllocator nsIMemory
|
||||
#define nsAllocator nsMemory
|
||||
#define GetGlobalAllocator GetGlobalMemoryService
|
||||
|
||||
#define NS_IALLOCATOR_IID NS_GET_IID(nsIMemory)
|
||||
#define NS_ALLOCATOR_CONTRACTID NS_MEMORY_CONTRACTID
|
||||
#define NS_ALLOCATOR_CLASSNAME NS_MEMORY_CLASSNAME
|
||||
#define NS_ALLOCATOR_CID NS_MEMORY_CID
|
||||
|
||||
#endif /* nsIAllocator_h___ */
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Used by the console service to notify listeners of new console messages.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIConsoleMessage.idl"
|
||||
|
||||
[scriptable, uuid(eaaf61d6-1dd1-11b2-bc6e-8fc96480f20d)]
|
||||
interface nsIConsoleListener : nsISupports
|
||||
{
|
||||
void observe(in nsIConsoleMessage aMessage);
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* This is intended as a base interface; implementations may want to
|
||||
* provide an object that can be qi'ed to provide more specific
|
||||
* message information.
|
||||
*/
|
||||
[scriptable, uuid(41bd8784-1dd2-11b2-9553-8606958fffe1)]
|
||||
interface nsIConsoleMessage : nsISupports
|
||||
{
|
||||
readonly attribute wstring message;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_CONSOLEMESSAGE_CID \
|
||||
{ 0x56c9d666, 0x1dd2, 0x11b2, { 0xb4, 0x3c, 0xa8, 0x4b, 0xf3, 0xb3, 0xec, 0xbb }}
|
||||
|
||||
#define NS_CONSOLEMESSAGE_CONTRACTID "@mozilla.org/consolemessage;1"
|
||||
%}
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIConsoleListener.idl"
|
||||
#include "nsIConsoleMessage.idl"
|
||||
|
||||
[scriptable, uuid(a647f184-1dd1-11b2-a9d1-8537b201161b)]
|
||||
interface nsIConsoleService : nsISupports
|
||||
{
|
||||
void logMessage(in nsIConsoleMessage message);
|
||||
|
||||
/**
|
||||
* Convenience method for logging simple messages.
|
||||
*/
|
||||
void logStringMessage(in wstring message);
|
||||
|
||||
/**
|
||||
* Get an array of all the messages logged so far. If no messages
|
||||
* are logged, this function will return a count of 0, but still
|
||||
* will allocate one word for messages, so as to show up as a
|
||||
* 0-length array when called from script.
|
||||
*/
|
||||
void getMessageArray([array, size_is(count)] out nsIConsoleMessage messages,
|
||||
out PRUint32 count);
|
||||
|
||||
/**
|
||||
* To guard against stack overflows from listeners that could log
|
||||
* messages (it's easy to do this inadvertently from listeners
|
||||
* implemented in JavaScript), we don't call any listeners when
|
||||
* another error is already being logged.
|
||||
*/
|
||||
void registerListener(in nsIConsoleListener listener);
|
||||
|
||||
/**
|
||||
* Each registered listener should also be unregistered.
|
||||
*/
|
||||
void unregisterListener(in nsIConsoleListener listener);
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
#define NS_CONSOLESERVICE_CLASSNAME "Console Service"
|
||||
|
||||
#define NS_CONSOLESERVICE_CID \
|
||||
{ 0x7e3ff85c, 0x1dd2, 0x11b2, { 0x8d, 0x4b, 0xeb, 0x45, 0x2c, 0xb0, 0xff, 0x40 }}
|
||||
|
||||
#define NS_CONSOLESERVICE_CONTRACTID "@mozilla.org/consoleservice;1"
|
||||
%}
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Bratell <bratell@lysator.liu.se>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsID.h"
|
||||
#include "prprf.h"
|
||||
#include "prmem.h"
|
||||
|
||||
static const char gIDFormat[] =
|
||||
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
|
||||
|
||||
static const char gIDFormat2[] =
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
|
||||
|
||||
|
||||
/**
|
||||
* Multiplies the_int_var with 16 (0x10) and adds the value of the
|
||||
* hexadecimal digit the_char. If it fails it returns PR_FALSE from
|
||||
* the function it's used in.
|
||||
*/
|
||||
|
||||
#define ADD_HEX_CHAR_TO_INT_OR_RETURN_FALSE(the_char, the_int_var) \
|
||||
the_int_var = (the_int_var << 4) + the_char; \
|
||||
if(the_char >= '0' && the_char <= '9') the_int_var -= '0'; \
|
||||
else if(the_char >= 'a' && the_char <= 'f') the_int_var -= 'a'-10; \
|
||||
else if(the_char >= 'A' && the_char <= 'F') the_int_var -= 'A'-10; \
|
||||
else return PR_FALSE
|
||||
|
||||
|
||||
/**
|
||||
* Parses number_of_chars characters from the char_pointer pointer and
|
||||
* puts the number in the dest_variable. The pointer is moved to point
|
||||
* at the first character after the parsed ones. If it fails it returns
|
||||
* PR_FALSE from the function the macro is used in.
|
||||
*/
|
||||
|
||||
#define PARSE_CHARS_TO_NUM(char_pointer, dest_variable, number_of_chars) \
|
||||
do { PRInt32 _i=number_of_chars; \
|
||||
dest_variable = 0; \
|
||||
while(_i) { \
|
||||
ADD_HEX_CHAR_TO_INT_OR_RETURN_FALSE(*char_pointer, dest_variable); \
|
||||
char_pointer++; \
|
||||
_i--; \
|
||||
} } while(0)
|
||||
|
||||
|
||||
/**
|
||||
* Parses a hyphen from the char_pointer string. If there is no hyphen there
|
||||
* the function returns PR_FALSE from the function it's used in. The
|
||||
* char_pointer is advanced one step.
|
||||
*/
|
||||
|
||||
#define PARSE_HYPHEN(char_pointer) if(*(char_pointer++) != '-') return PR_FALSE
|
||||
|
||||
/*
|
||||
* Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into
|
||||
* an nsID. It can also handle the old format without the { and }.
|
||||
*/
|
||||
|
||||
NS_COM PRBool nsID::Parse(const char *aIDStr)
|
||||
{
|
||||
/* Optimized for speed */
|
||||
if(!aIDStr) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool expectFormat1 = (aIDStr[0] == '{');
|
||||
if(expectFormat1) aIDStr++;
|
||||
|
||||
PARSE_CHARS_TO_NUM(aIDStr, m0, 8);
|
||||
PARSE_HYPHEN(aIDStr);
|
||||
PARSE_CHARS_TO_NUM(aIDStr, m1, 4);
|
||||
PARSE_HYPHEN(aIDStr);
|
||||
PARSE_CHARS_TO_NUM(aIDStr, m2, 4);
|
||||
PARSE_HYPHEN(aIDStr);
|
||||
int i;
|
||||
for(i=0; i<2; i++)
|
||||
PARSE_CHARS_TO_NUM(aIDStr, m3[i], 2);
|
||||
PARSE_HYPHEN(aIDStr);
|
||||
while(i < 8) {
|
||||
PARSE_CHARS_TO_NUM(aIDStr, m3[i], 2);
|
||||
i++;
|
||||
}
|
||||
|
||||
return expectFormat1 ? *aIDStr == '}' : PR_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an allocated string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||
* format. The string is allocated with PR_Malloc and should be freed by
|
||||
* the caller.
|
||||
*/
|
||||
|
||||
NS_COM char *nsID::ToString() const
|
||||
{
|
||||
char *res = (char*)PR_Malloc(39); // use PR_Malloc if this is to be freed with nsCRT::free
|
||||
|
||||
if (res != NULL) {
|
||||
PR_snprintf(res, 39, gIDFormat,
|
||||
m0, (PRUint32) m1, (PRUint32) m2,
|
||||
(PRUint32) m3[0], (PRUint32) m3[1], (PRUint32) m3[2],
|
||||
(PRUint32) m3[3], (PRUint32) m3[4], (PRUint32) m3[5],
|
||||
(PRUint32) m3[6], (PRUint32) m3[7]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsID_h__
|
||||
#define nsID_h__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifndef nscore_h___
|
||||
#include "nscore.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A "unique identifier". This is modeled after OSF DCE UUIDs.
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
struct nsID {
|
||||
/**
|
||||
* @name Indentifier values
|
||||
*/
|
||||
|
||||
//@{
|
||||
PRUint32 m0;
|
||||
PRUint16 m1;
|
||||
PRUint16 m2;
|
||||
PRUint8 m3[8];
|
||||
//@}
|
||||
|
||||
/**
|
||||
* @name Methods
|
||||
*/
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Equivalency method. Compares this nsID with another.
|
||||
* @return <b>PR_TRUE</b> if they are the same, <b>PR_FALSE</b> if not.
|
||||
*/
|
||||
|
||||
inline PRBool Equals(const nsID& other) const {
|
||||
#ifdef XP_UNIX
|
||||
return (PRBool)
|
||||
((((PRUint32*) &m0)[0] == ((PRUint32*) &other.m0)[0]) &&
|
||||
(((PRUint32*) &m0)[1] == ((PRUint32*) &other.m0)[1]) &&
|
||||
(((PRUint32*) &m0)[2] == ((PRUint32*) &other.m0)[2]) &&
|
||||
(((PRUint32*) &m0)[3] == ((PRUint32*) &other.m0)[3]));
|
||||
#else
|
||||
return (memcmp(this, &other, sizeof(*this)) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* nsID Parsing method. Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||
* string into an nsID
|
||||
*/
|
||||
NS_COM PRBool Parse(const char *aIDStr);
|
||||
|
||||
/**
|
||||
* nsID string encoder. Returns an allocated string in
|
||||
* {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format. Caller should free string.
|
||||
*/
|
||||
NS_COM char* ToString() const;
|
||||
//@}
|
||||
};
|
||||
|
||||
/*
|
||||
* Class IDs
|
||||
*/
|
||||
|
||||
typedef nsID nsCID;
|
||||
|
||||
// Define an CID
|
||||
#define NS_DEFINE_CID(_name, _cidspec) \
|
||||
const nsCID _name = _cidspec
|
||||
|
||||
#define REFNSCID const nsCID&
|
||||
|
||||
/**
|
||||
* An "interface id" which can be used to uniquely identify a given
|
||||
* interface.
|
||||
*/
|
||||
|
||||
typedef nsID nsIID;
|
||||
|
||||
/**
|
||||
* A macro shorthand for <tt>const nsIID&<tt>
|
||||
*/
|
||||
|
||||
#define REFNSIID const nsIID&
|
||||
|
||||
/**
|
||||
* Define an IID
|
||||
* obsolete - do not use this macro
|
||||
*/
|
||||
|
||||
#define NS_DEFINE_IID(_name, _iidspec) \
|
||||
const nsIID _name = _iidspec
|
||||
|
||||
/**
|
||||
* A macro to build the static const IID accessor method
|
||||
*/
|
||||
|
||||
#define NS_DEFINE_STATIC_IID_ACCESSOR(the_iid) \
|
||||
static const nsIID& GetIID() {static const nsIID iid = the_iid; return iid;}
|
||||
|
||||
/**
|
||||
* A macro to build the static const CID accessor method
|
||||
*/
|
||||
|
||||
#define NS_DEFINE_STATIC_CID_ACCESSOR(the_cid) \
|
||||
static const nsID& GetCID() {static const nsID cid = the_cid; return cid;}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* nsIErrorService: This is an interim service that allows nsresult codes to be mapped to
|
||||
* string bundles that can be used to look up error messages. String bundle keys can also
|
||||
* be mapped.
|
||||
*
|
||||
* This service will eventually get replaced by extending xpidl to allow errors to be defined.
|
||||
* (http://bugzilla.mozilla.org/show_bug.cgi?id=13423).
|
||||
*/
|
||||
[scriptable, uuid(e72f94b2-5f85-11d4-9877-00c04fa0cf4a)]
|
||||
interface nsIErrorService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Registers a string bundle URL for an error module. Error modules are obtained from
|
||||
* nsresult code with NS_ERROR_GET_MODULE.
|
||||
*/
|
||||
void registerErrorStringBundle(in short errorModule, in string stringBundleURL);
|
||||
|
||||
/**
|
||||
* Registers a string bundle URL for an error module.
|
||||
*/
|
||||
void unregisterErrorStringBundle(in short errorModule);
|
||||
|
||||
/**
|
||||
* Retrieves a string bundle URL for an error module.
|
||||
*/
|
||||
string getErrorStringBundle(in short errorModule);
|
||||
|
||||
/**
|
||||
* Registers a key in a string bundle for an nsresult error code. Only the code portion
|
||||
* of the nsresult is used (obtained with NS_ERROR_GET_CODE) in this registration. The
|
||||
* string bundle key is used to look up internationalized messages in the string bundle.
|
||||
*/
|
||||
void registerErrorStringBundleKey(in nsresult error, in string stringBundleKey);
|
||||
|
||||
/**
|
||||
* Unregisters a key in a string bundle for an nsresult error code.
|
||||
*/
|
||||
void unregisterErrorStringBundleKey(in nsresult error);
|
||||
|
||||
/**
|
||||
* Retrieves a key in a string bundle for an nsresult error code. If no key is registered
|
||||
* for the specified nsresult's code (obtained with NS_ERROR_GET_CODE), then the stringified
|
||||
* version of the nsresult code is returned.
|
||||
*/
|
||||
string getErrorStringBundleKey(in nsresult error);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
// The global nsIErrorService:
|
||||
#define NS_ERRORSERVICE_NAME "Error Service"
|
||||
#define NS_ERRORSERVICE_CONTRACTID "@mozilla.org/xpcom/error-service;1"
|
||||
#define NS_ERRORSERVICE_CID \
|
||||
{ /* 744afd5e-5f8c-11d4-9877-00c04fa0cf4a */ \
|
||||
0x744afd5e, \
|
||||
0x5f8c, \
|
||||
0x11d4, \
|
||||
{0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a} \
|
||||
}
|
||||
|
||||
%}
|
||||
@@ -1,101 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Interfaces for representing cross-language exceptions and stack traces.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIProgrammingLanguage.idl"
|
||||
|
||||
// XXX - most "string"s in this file should probably move to Unicode
|
||||
// so may as well use AStrings...
|
||||
|
||||
|
||||
[scriptable, uuid(91d82105-7c62-4f8b-9779-154277c0ee90)]
|
||||
interface nsIStackFrame : nsISupports
|
||||
{
|
||||
// see nsIProgrammingLanguage for list of language consts
|
||||
readonly attribute PRUint32 language;
|
||||
readonly attribute string languageName;
|
||||
readonly attribute string filename;
|
||||
readonly attribute string name;
|
||||
// Valid line numbers begin at '1'. '0' indicates unknown.
|
||||
readonly attribute PRInt32 lineNumber;
|
||||
readonly attribute string sourceLine;
|
||||
readonly attribute nsIStackFrame caller;
|
||||
|
||||
string toString();
|
||||
};
|
||||
|
||||
[scriptable, uuid(F3A8D3B4-C424-4edc-8BF6-8974C983BA78)]
|
||||
interface nsIException : nsISupports
|
||||
{
|
||||
// A custom message set by the thrower.
|
||||
readonly attribute string message;
|
||||
// The nsresult associated with this exception.
|
||||
readonly attribute nsresult result;
|
||||
// The name of the error code (ie, a string repr of |result|)
|
||||
readonly attribute string name;
|
||||
|
||||
// Filename location. This is the location that caused the
|
||||
// error, which may or may not be a source file location.
|
||||
// For example, standard language errors would generally have
|
||||
// the same location as their top stack entry. File
|
||||
// parsers may put the location of the file they were parsing,
|
||||
// etc.
|
||||
|
||||
// null indicates "no data"
|
||||
readonly attribute string filename;
|
||||
// Valid line numbers begin at '1'. '0' indicates unknown.
|
||||
readonly attribute PRUint32 lineNumber;
|
||||
// Valid column numbers begin at 0.
|
||||
// We don't have an unambiguous indicator for unknown.
|
||||
readonly attribute PRUint32 columnNumber;
|
||||
|
||||
// A stack trace, if available.
|
||||
readonly attribute nsIStackFrame location;
|
||||
// An inner exception that triggered this, if available.
|
||||
readonly attribute nsIException inner;
|
||||
|
||||
// Arbitary data for the implementation.
|
||||
readonly attribute nsISupports data;
|
||||
|
||||
// A generic formatter - make it suitable to print, etc.
|
||||
string toString();
|
||||
};
|
||||
@@ -1,97 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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
|
||||
* ActiveState Tool Corp..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark Hammond <MarkH@ActiveState.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIException.idl"
|
||||
|
||||
// An exception provider. These can turn special nsresult codes
|
||||
// into nsIExceptions
|
||||
|
||||
[scriptable, uuid(0577744c-c1d2-47f2-8bcc-ce7a9e5a88fc)]
|
||||
interface nsIExceptionProvider : nsISupports
|
||||
{
|
||||
/** Gets an nsIException or returns NULL if not possible. **/
|
||||
nsIException getException(in nsresult result, in nsIException defaultException);
|
||||
};
|
||||
|
||||
// A ScriptErrorManager for a single thread. These objects
|
||||
// are _not_ thread-safe. Use the ScriptErrorService
|
||||
// to get a script error manager for your current thread.
|
||||
[scriptable, uuid(efc9d00b-231c-4feb-852c-ac017266a415)]
|
||||
interface nsIExceptionManager : nsISupports
|
||||
{
|
||||
/** Sets (or clears with nsnull) the current error on the this thread. */
|
||||
void setCurrentException( in nsIException error);
|
||||
|
||||
/** Gets the current error for the current thread, or NULL if no error */
|
||||
nsIException getCurrentException();
|
||||
|
||||
/** Gets an exception from a registered exception provider..
|
||||
This has no effect on the "current exception" */
|
||||
nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException);
|
||||
};
|
||||
|
||||
|
||||
// The Exception Service. Allows you to get an set exceptions in a thread
|
||||
// safe manner, or to get an ExceptionManager for your specific thread.
|
||||
[scriptable, uuid(35A88F54-F267-4414-92A7-191F6454AB52)]
|
||||
interface nsIExceptionService : nsIExceptionManager
|
||||
{
|
||||
/** Obtains an exception manager for the current thread. */
|
||||
readonly attribute nsIExceptionManager currentExceptionManager;
|
||||
|
||||
/** Installs an "exception provider" which is capable of
|
||||
translating an nsresult into an exception. This enables
|
||||
error providers to return simple nsresults and only provide
|
||||
rich errors when specifically requested. It also has the
|
||||
advantage of allowing code like the DOM to handle all errors
|
||||
in a single function rather than at each XPCOM entry point.
|
||||
NOTE: This interface must be thread-safe - it will be called
|
||||
on whatever thread needs the error translation performed.*/
|
||||
void registerExceptionProvider( in nsIExceptionProvider provider, in PRUint32 moduleCode );
|
||||
void unregisterExceptionProvider( in nsIExceptionProvider provider, in PRUint32 moduleCode );
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
#define NS_EXCEPTIONSERVICE_CLASSNAME "Exception Service"
|
||||
// {35A88F54-F267-4414-92A7-191F6454AB52}
|
||||
#define NS_EXCEPTIONSERVICE_CID \
|
||||
{ 0x35a88f54, 0xf267, 0x4414, { 0x92, 0xa7, 0x19, 0x1f, 0x64, 0x54, 0xab, 0x52 } }
|
||||
#define NS_EXCEPTIONSERVICE_CONTRACTID "@mozilla.org/exceptionservice;1"
|
||||
%}
|
||||
@@ -1,41 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsIID_h
|
||||
#define __nsIID_h
|
||||
#include "nsID.h"
|
||||
#endif /* __nsIID_h */
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Travis Bogard <travis@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The nsIInterfaceRequestor interface defines a generic interface for
|
||||
* requesting interfaces that a given object might provide access to.
|
||||
* This is very similar to QueryInterface found in nsISupports.
|
||||
* The main difference is that interfaces returned from GetInterface()
|
||||
* are not required to provide a way back to the object implementing this
|
||||
* interface. The semantics of QI() dictate that given an interface A that
|
||||
* you QI() on to get to interface B, you must be able to QI on B to get back
|
||||
* to A. This interface however allows you to obtain an interface C from A
|
||||
* that may or most likely will not have the ability to get back to A.
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(033A1470-8B2A-11d3-AF88-00A024FFC08C)]
|
||||
interface nsIInterfaceRequestor : nsISupports
|
||||
{
|
||||
/**
|
||||
* Retrieves the specified interface pointer.
|
||||
*
|
||||
* @param uuid The IID of the interface being requested.
|
||||
* @param result [out] The interface pointer to be filled in if
|
||||
* the interface is accessible.
|
||||
* @return NS_OK - interface was successfully returned.
|
||||
* NS_NOINTERFACE - interface not accessible.
|
||||
* NS_ERROR* - method failure.
|
||||
*/
|
||||
void getInterface(in nsIIDRef uuid,
|
||||
[iid_is(uuid),retval] out nsQIResult result);
|
||||
};
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsICollection;
|
||||
|
||||
/**
|
||||
* Controls the leak detector.
|
||||
*/
|
||||
[scriptable, uuid(a2ec052c-1dd1-11b2-9c92-84be252fe47e)]
|
||||
interface nsILeakDetector : nsISupports {
|
||||
void dumpLeaks();
|
||||
void traceObject(in nsISupports object, in PRBool verbose);
|
||||
void traceCollection(in nsICollection objects, in PRBool verbose);
|
||||
void markObject(in nsISupports object, in PRBool marked);
|
||||
readonly attribute nsISupports services;
|
||||
};
|
||||
@@ -1,126 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
*
|
||||
* nsIMemory: interface to allocate and deallocate memory. Also provides
|
||||
* for notifications in low-memory situations.
|
||||
*
|
||||
* A client that wishes to be notified of low memory situations (for
|
||||
* example, because the client maintains a large memory cache that
|
||||
* could be released when memory is tight) should register with the
|
||||
* observer service (see nsIObserverService) using the topic
|
||||
* "memory-pressure". There are three specific types of notications
|
||||
* that can occur. These types will be passed as the |aData|
|
||||
* parameter of the of the "memory-pressure" notification:
|
||||
*
|
||||
* "low-memory"
|
||||
* This will be passed as the extra data when the pressure
|
||||
* observer is being asked to flush for low-memory conditions.
|
||||
*
|
||||
* "heap-minimize"
|
||||
* This will be passed as the extra data when the pressure
|
||||
* observer is being asked to flush because of a heap minimize
|
||||
* call.
|
||||
*
|
||||
* "alloc-failure"
|
||||
* This will be passed as the extra data when the pressure
|
||||
* observer has been asked to flush because a malloc() or
|
||||
* realloc() has failed.
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(59e7e77a-38e4-11d4-8cf5-0060b0fc14a3)]
|
||||
interface nsIMemory : nsISupports
|
||||
{
|
||||
/**
|
||||
* Allocates a block of memory of a particular size. If the memory
|
||||
* cannot be allocated (because of an out-of-memory condition), null
|
||||
* is returned.
|
||||
*
|
||||
* @param size - the size of the block to allocate
|
||||
* @result the block of memory
|
||||
*/
|
||||
[noscript, notxpcom] voidPtr alloc(in size_t size);
|
||||
|
||||
/**
|
||||
* Reallocates a block of memory to a new size.
|
||||
*
|
||||
* @param ptr - the block of memory to reallocate
|
||||
* @param size - the new size
|
||||
* @result the reallocated block of memory
|
||||
*
|
||||
* If ptr is null, this function behaves like malloc.
|
||||
* If s is the size of the block to which ptr points, the first
|
||||
* min(s, size) bytes of ptr's block are copied to the new block.
|
||||
* If the allocation succeeds, ptr is freed and a pointer to the
|
||||
* new block returned. If the allocation fails, ptr is not freed
|
||||
* and null is returned. The returned value may be the same as ptr.
|
||||
*/
|
||||
[noscript, notxpcom] voidPtr realloc(in voidPtr ptr,
|
||||
in size_t newSize);
|
||||
|
||||
/**
|
||||
* Frees a block of memory. Null is a permissible value, in which case
|
||||
* nothing happens.
|
||||
*
|
||||
* @param ptr - the block of memory to free
|
||||
*/
|
||||
[noscript, notxpcom] void free(in voidPtr ptr);
|
||||
|
||||
/**
|
||||
* Attempts to shrink the heap.
|
||||
* @param immediate - if true, heap minimization will occur
|
||||
* immediately if the call was made on the main thread. If
|
||||
* false, the flush will be scheduled to happen when the app is
|
||||
* idle.
|
||||
* @return NS_ERROR_FAILURE if 'immediate' is set an the call
|
||||
* was not on the application's main thread.
|
||||
*/
|
||||
void heapMinimize(in boolean immediate);
|
||||
|
||||
/**
|
||||
* This predicate can be used to determine if we're in a low-memory
|
||||
* situation (what constitutes low-memory is platform dependent). This
|
||||
* can be used to trigger the memory pressure observers.
|
||||
*/
|
||||
boolean isLowMemory();
|
||||
};
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; 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 Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* 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):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#ifdef XP_OS2 // OS2 has UNKNOWN problems :)
|
||||
#undef UNKNOWN
|
||||
#endif
|
||||
%}
|
||||
|
||||
/**
|
||||
* Enumeration of Programming Languages
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(ea604e90-40ba-11d5-90bb-0010a4e73d9a)]
|
||||
interface nsIProgrammingLanguage : nsISupports
|
||||
{
|
||||
/**
|
||||
* Identifiers for programming languages.
|
||||
*/
|
||||
const PRUint32 UNKNOWN = 0;
|
||||
const PRUint32 CPLUSPLUS = 1;
|
||||
const PRUint32 JAVASCRIPT = 2;
|
||||
const PRUint32 PYTHON = 3;
|
||||
const PRUint32 PERL = 4;
|
||||
const PRUint32 JAVA = 5;
|
||||
const PRUint32 ZX81_BASIC = 6; // it could happen :)
|
||||
const PRUint32 JAVASCRIPT2 = 7;
|
||||
// This list can grow indefinitely. Just don't ever change an existing item.
|
||||
|
||||
};
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* The mother of all xpcom interfaces.
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
/* In order to get both the right typelib and the right header we force
|
||||
* the 'real' output from xpidl to be commented out in the generated header
|
||||
* and includes a copy of the original nsISupports.h. This is all just to deal
|
||||
* with the Mac specific ": public __comobject" thing.
|
||||
*/
|
||||
|
||||
#include "nsrootidl.idl"
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* Start commenting out the C++ versions of the below in the output header
|
||||
*/
|
||||
#if 0
|
||||
%}
|
||||
|
||||
[scriptable, uuid(00000000-0000-0000-c000-000000000046)]
|
||||
interface nsISupports {
|
||||
void QueryInterface(in nsIIDRef uuid,
|
||||
[iid_is(uuid),retval] out nsQIResult result);
|
||||
[noscript, notxpcom] nsrefcnt AddRef();
|
||||
[noscript, notxpcom] nsrefcnt Release();
|
||||
};
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
*/
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
||||
%{C++
|
||||
#include "nsISupportsBase.h"
|
||||
|
||||
#ifndef MOZILLA_STRICT_API
|
||||
#include "nsISupportsUtils.h"
|
||||
#endif
|
||||
%}
|
||||
@@ -1,119 +0,0 @@
|
||||
/* ***** 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 XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 nsISupportsBase_h__
|
||||
#define nsISupportsBase_h__
|
||||
|
||||
#ifndef nscore_h___
|
||||
#include "nscore.h"
|
||||
#endif
|
||||
|
||||
#ifndef nsID_h__
|
||||
#include "nsID.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*@{*/
|
||||
/**
|
||||
* IID for the nsISupports interface
|
||||
* {00000000-0000-0000-c000-000000000046}
|
||||
*
|
||||
* To maintain binary compatibility with COM's nsIUnknown, we define the IID
|
||||
* of nsISupports to be the same as that of COM's nsIUnknown.
|
||||
*/
|
||||
#define NS_ISUPPORTS_IID \
|
||||
{ 0x00000000, 0x0000, 0x0000, \
|
||||
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
|
||||
|
||||
/**
|
||||
* Reference count values
|
||||
*
|
||||
* This is type of return value from Addref() and Release() in nsISupports.
|
||||
* nsIUnknown of COM returns a unsigned long from equivalent functions.
|
||||
* To maintain binary compatibility of nsISupports with nsIUnknown, we are
|
||||
* doing this ifdeffing.
|
||||
*/
|
||||
#if defined(XP_WIN) && PR_BYTES_PER_LONG == 4
|
||||
typedef unsigned long nsrefcnt;
|
||||
#else
|
||||
typedef PRUint32 nsrefcnt;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Basic component object model interface. Objects which implement
|
||||
* this interface support runtime interface discovery (QueryInterface)
|
||||
* and a reference counted memory model (AddRef/Release). This is
|
||||
* modelled after the win32 IUnknown API.
|
||||
*/
|
||||
class NS_NO_VTABLE nsISupports {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @name Methods
|
||||
*/
|
||||
|
||||
//@{
|
||||
/**
|
||||
* A run time mechanism for interface discovery.
|
||||
* @param aIID [in] A requested interface IID
|
||||
* @param aInstancePtr [out] A pointer to an interface pointer to
|
||||
* receive the result.
|
||||
* @return <b>NS_OK</b> if the interface is supported by the associated
|
||||
* instance, <b>NS_NOINTERFACE</b> if it is not.
|
||||
* <b>NS_ERROR_INVALID_POINTER</b> if <i>aInstancePtr</i> is <b>NULL</b>.
|
||||
*/
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
|
||||
/**
|
||||
* Increases the reference count for this interface.
|
||||
* The associated instance will not be deleted unless
|
||||
* the reference count is returned to zero.
|
||||
*
|
||||
* @return The resulting reference count.
|
||||
*/
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
|
||||
/**
|
||||
* Decreases the reference count for this interface.
|
||||
* Generally, if the reference count returns to zero,
|
||||
* the associated instance is deleted.
|
||||
*
|
||||
* @return The resulting reference count.
|
||||
*/
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
|
||||
//@}
|
||||
};
|
||||
/*@}*/
|
||||
#endif
|
||||
@@ -1,303 +0,0 @@
|
||||
/* ***** 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 XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 nsISupportsObsolete_h__
|
||||
#define nsISupportsObsolete_h__
|
||||
|
||||
#if defined(NS_MT_SUPPORTED)
|
||||
#include "prcmon.h"
|
||||
#endif /* NS_MT_SUPPORTED */
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define NS_INIT_REFCNT() NS_INIT_ISUPPORTS()
|
||||
|
||||
|
||||
#define NS_DECL_ISUPPORTS_EXPORTED \
|
||||
public: \
|
||||
NS_EXPORT NS_IMETHOD QueryInterface(REFNSIID aIID, \
|
||||
void** aInstancePtr); \
|
||||
NS_EXPORT NS_IMETHOD_(nsrefcnt) AddRef(void); \
|
||||
NS_EXPORT NS_IMETHOD_(nsrefcnt) Release(void); \
|
||||
protected: \
|
||||
nsrefcnt mRefCnt; \
|
||||
NS_DECL_OWNINGTHREAD \
|
||||
public:
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
/*
|
||||
* Adding this debug-only function as per bug #26803. If you are debugging
|
||||
* and this function returns wrong refcounts, fix the objects |AddRef()| and
|
||||
* |Release()| to do the right thing.
|
||||
*
|
||||
* Of course, this function is only available for debug builds.
|
||||
*/
|
||||
|
||||
inline
|
||||
nsrefcnt
|
||||
NS_DebugGetRefCount( nsISupports* obj )
|
||||
// Warning: don't apply this to an object whose refcount is
|
||||
// |0| or not yet initialized ... it may be destroyed.
|
||||
{
|
||||
nsrefcnt ref_count = 0;
|
||||
|
||||
if ( obj )
|
||||
{
|
||||
// |AddRef()| and |Release()| are supposed to return
|
||||
// the new refcount of the object
|
||||
obj->AddRef();
|
||||
ref_count = obj->Release();
|
||||
// Can't use |NS_[ADDREF|RELEASE]| since (a) they _don't_ return
|
||||
// the refcount, and (b) we don't want to log these guaranteed
|
||||
// balanced calls.
|
||||
|
||||
NS_ASSERTION(ref_count,
|
||||
"Oops! Calling |NS_DebugGetRefCount()| probably just "
|
||||
"destroyed this object.");
|
||||
}
|
||||
|
||||
return ref_count;
|
||||
}
|
||||
|
||||
#endif // NS_DEBUG
|
||||
|
||||
/**
|
||||
* Macro to free an array of pointers to nsISupports (or classes
|
||||
* derived from it). A convenience wrapper around
|
||||
* NS_FREE_XPCOM_POINTER_ARRAY.
|
||||
*
|
||||
* Note that if you know that none of your nsISupports pointers are
|
||||
* going to be 0, you can gain a bit of speed by calling
|
||||
* NS_FREE_XPCOM_POINTER_ARRAY directly and using NS_RELEASE as your
|
||||
* free function.
|
||||
*
|
||||
* @param size Number of elements in the array. If not a constant, this
|
||||
* should be a PRInt32. Note that this means this macro
|
||||
* will not work if size >= 2^31.
|
||||
* @param array The array to be freed.
|
||||
*/
|
||||
#define NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(size, array) \
|
||||
NS_FREE_XPCOM_POINTER_ARRAY((size), (array), NS_IF_RELEASE)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* use these functions to associate get/set methods with a
|
||||
C++ member variable
|
||||
*/
|
||||
|
||||
#define NS_METHOD_GETTER(_method, _type, _member) \
|
||||
_method(_type* aResult) \
|
||||
{\
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER; \
|
||||
*aResult = _member; \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define NS_METHOD_SETTER(_method, _type, _member) \
|
||||
_method(_type aResult) \
|
||||
{ \
|
||||
_member = aResult; \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
/*
|
||||
* special for strings to get/set char* strings
|
||||
* using PL_strdup and PR_FREEIF
|
||||
*/
|
||||
#define NS_METHOD_GETTER_STR(_method,_member) \
|
||||
_method(char* *aString)\
|
||||
{\
|
||||
if (!aString) return NS_ERROR_NULL_POINTER; \
|
||||
*aString = PL_strdup(_member); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define NS_METHOD_SETTER_STR(_method, _member) \
|
||||
_method(const char *aString)\
|
||||
{\
|
||||
PR_FREEIF(_member);\
|
||||
if (aString) _member = PL_strdup(aString); \
|
||||
else _member = nsnull;\
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
/* Getter/Setter macros.
|
||||
Usage:
|
||||
NS_IMPL_[CLASS_]GETTER[_<type>](method, [type,] member);
|
||||
NS_IMPL_[CLASS_]SETTER[_<type>](method, [type,] member);
|
||||
NS_IMPL_[CLASS_]GETSET[_<type>]([class, ]postfix, [type,] member);
|
||||
|
||||
where:
|
||||
CLASS_ - implementation is inside a class definition
|
||||
(otherwise the class name is needed)
|
||||
Do NOT use in publicly exported header files, because
|
||||
the implementation may be included many times over.
|
||||
Instead, use the non-CLASS_ version.
|
||||
_<type> - For more complex (STR, IFACE) data types
|
||||
(otherwise the simple data type is needed)
|
||||
method - name of the method, such as GetWidth or SetColor
|
||||
type - simple data type if required
|
||||
member - class member variable such as m_width or mColor
|
||||
class - the class name, such as Window or MyObject
|
||||
postfix - Method part after Get/Set such as "Width" for "GetWidth"
|
||||
|
||||
Example:
|
||||
class Window {
|
||||
public:
|
||||
NS_IMPL_CLASS_GETSET(Width, int, m_width);
|
||||
NS_IMPL_CLASS_GETTER_STR(GetColor, m_color);
|
||||
NS_IMETHOD SetColor(char *color);
|
||||
|
||||
private:
|
||||
int m_width; // read/write
|
||||
char *m_color; // readonly
|
||||
};
|
||||
|
||||
// defined outside of class
|
||||
NS_IMPL_SETTER_STR(Window::GetColor, m_color);
|
||||
|
||||
Questions/Comments to alecf@netscape.com
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Getter/Setter implementation within a class definition
|
||||
*/
|
||||
|
||||
/* simple data types */
|
||||
#define NS_IMPL_CLASS_GETTER(_method, _type, _member) \
|
||||
NS_IMETHOD NS_METHOD_GETTER(_method, _type, _member)
|
||||
|
||||
#define NS_IMPL_CLASS_SETTER(_method, _type, _member) \
|
||||
NS_IMETHOD NS_METHOD_SETTER(_method, _type, _member)
|
||||
|
||||
#define NS_IMPL_CLASS_GETSET(_postfix, _type, _member) \
|
||||
NS_IMPL_CLASS_GETTER(Get##_postfix, _type, _member) \
|
||||
NS_IMPL_CLASS_SETTER(Set##_postfix, _type, _member)
|
||||
|
||||
/* strings */
|
||||
#define NS_IMPL_CLASS_GETTER_STR(_method, _member) \
|
||||
NS_IMETHOD NS_METHOD_GETTER_STR(_method, _member)
|
||||
|
||||
#define NS_IMPL_CLASS_SETTER_STR(_method, _member) \
|
||||
NS_IMETHOD NS_METHOD_SETTER_STR(_method, _member)
|
||||
|
||||
#define NS_IMPL_CLASS_GETSET_STR(_postfix, _member) \
|
||||
NS_IMPL_CLASS_GETTER_STR(Get##_postfix, _member) \
|
||||
NS_IMPL_CLASS_SETTER_STR(Set##_postfix, _member)
|
||||
|
||||
/* Getter/Setter implementation outside of a class definition */
|
||||
|
||||
/* simple data types */
|
||||
#define NS_IMPL_GETTER(_method, _type, _member) \
|
||||
NS_IMETHODIMP NS_METHOD_GETTER(_method, _type, _member)
|
||||
|
||||
#define NS_IMPL_SETTER(_method, _type, _member) \
|
||||
NS_IMETHODIMP NS_METHOD_SETTER(_method, _type, _member)
|
||||
|
||||
#define NS_IMPL_GETSET(_class, _postfix, _type, _member) \
|
||||
NS_IMPL_GETTER(_class::Get##_postfix, _type, _member) \
|
||||
NS_IMPL_SETTER(_class::Set##_postfix, _type, _member)
|
||||
|
||||
/* strings */
|
||||
#define NS_IMPL_GETTER_STR(_method, _member) \
|
||||
NS_IMETHODIMP NS_METHOD_GETTER_STR(_method, _member)
|
||||
|
||||
#define NS_IMPL_SETTER_STR(_method, _member) \
|
||||
NS_IMETHODIMP NS_METHOD_SETTER_STR(_method, _member)
|
||||
|
||||
#define NS_IMPL_GETSET_STR(_class, _postfix, _member) \
|
||||
NS_IMPL_GETTER_STR(_class::Get##_postfix, _member) \
|
||||
NS_IMPL_SETTER_STR(_class::Set##_postfix, _member)
|
||||
|
||||
/**
|
||||
* IID for the nsIsThreadsafe interface
|
||||
* {88210890-47a6-11d2-bec3-00805f8a66dc}
|
||||
*
|
||||
* This interface is *only* used for debugging purposes to determine if
|
||||
* a given component is threadsafe.
|
||||
*/
|
||||
#define NS_ISTHREADSAFE_IID \
|
||||
{ 0x88210890, 0x47a6, 0x11d2, \
|
||||
{0xbe, 0xc3, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
|
||||
|
||||
|
||||
#if defined(NS_MT_SUPPORTED)
|
||||
|
||||
#define NS_LOCK_INSTANCE() \
|
||||
PR_CEnterMonitor((void*)this)
|
||||
#define NS_UNLOCK_INSTANCE() \
|
||||
PR_CExitMonitor((void*)this)
|
||||
|
||||
#else
|
||||
|
||||
#define NS_LOCK_INSTANCE()
|
||||
#define NS_UNLOCK_INSTANCE()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This implements query interface with two assumptions: First, the
|
||||
* class in question implements nsISupports and its own interface and
|
||||
* nothing else. Second, the implementation of the class's primary
|
||||
* inheritance chain leads to its own interface.
|
||||
*
|
||||
* @param _class The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
#if defined(NS_DEBUG)
|
||||
#define NS_VERIFY_THREADSAFE_INTERFACE(_iface) \
|
||||
if (NULL != (_iface)) { \
|
||||
nsISupports* tmp; \
|
||||
static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID); \
|
||||
NS_PRECONDITION((NS_OK == _iface->QueryInterface(kIsThreadsafeIID, \
|
||||
(void**)&tmp)), \
|
||||
"Interface is not threadsafe"); \
|
||||
}
|
||||
#else
|
||||
#define NS_VERIFY_THREADSAFE_INTERFACE(_iface)
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Shaver <shaver@mozilla.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* System information service.
|
||||
*
|
||||
* At present, a thin wrapper around PR_GetSystemInfo.
|
||||
*/
|
||||
|
||||
[scriptable,uuid(4189b420-1dd2-11b2-bff7-daaf5c1f7b10)]
|
||||
interface nsISystemInfo : nsISupports
|
||||
{
|
||||
/** The system hostname. */
|
||||
readonly attribute string hostname;
|
||||
|
||||
/** The operating system name. */
|
||||
readonly attribute string OSName;
|
||||
|
||||
/** The operating system version. */
|
||||
readonly attribute string OSVersion;
|
||||
|
||||
/** The processor architecture of the machine. */
|
||||
readonly attribute string architecture;
|
||||
};
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Scott Collins <scc@mozilla.org>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
/**
|
||||
* An instance of |nsIWeakReference| is a proxy object that cooperates with
|
||||
* its referent to give clients a non-owning, non-dangling reference. Clients
|
||||
* own the proxy, and should generally manage it with an |nsCOMPtr| (see the
|
||||
* type |nsWeakPtr| for a |typedef| name that stands out) as they would any
|
||||
* other XPCOM object. The |QueryReferent| member function provides a
|
||||
* (hopefully short-lived) owning reference on demand, through which clients
|
||||
* can get useful access to the referent, while it still exists.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @version 1.0
|
||||
* @see nsISupportsWeakReference
|
||||
* @see nsWeakReference
|
||||
* @see nsWeakPtr
|
||||
*/
|
||||
[scriptable, uuid(9188bc85-f92e-11d2-81ef-0060083a0bcf)]
|
||||
interface nsIWeakReference : nsISupports
|
||||
{
|
||||
/**
|
||||
* |QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces
|
||||
* an owning reference to the desired interface. It is designed to look and act exactly
|
||||
* like (a proxied) |QueryInterface|. Don't hold on to the produced interface permanently;
|
||||
* that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place.
|
||||
*/
|
||||
void QueryReferent( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* |nsISupportsWeakReference| is a factory interface which produces appropriate
|
||||
* instances of |nsIWeakReference|. Weak references in this scheme can only be
|
||||
* produced for objects that implement this interface.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @version 1.0
|
||||
* @see nsIWeakReference
|
||||
* @see nsSupportsWeakReference
|
||||
*/
|
||||
[scriptable, uuid(9188bc86-f92e-11d2-81ef-0060083a0bcf)]
|
||||
interface nsISupportsWeakReference : nsISupports
|
||||
{
|
||||
/**
|
||||
* |GetWeakReference| produces an appropriate instance of |nsIWeakReference|.
|
||||
* As with all good XPCOM `getters', you own the resulting interface and should
|
||||
* manage it with an |nsCOMPtr|.
|
||||
*
|
||||
* @see nsIWeakReference
|
||||
* @see nsWeakPtr
|
||||
* @see nsCOMPtr
|
||||
*/
|
||||
nsIWeakReference GetWeakReference();
|
||||
};
|
||||
|
||||
|
||||
%{C++
|
||||
#ifndef MOZILLA_STRICT_API
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#endif
|
||||
%}
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#if defined(GC_LEAK_DETECTOR)
|
||||
|
||||
#include "nsLeakDetector.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsILeakDetector.h"
|
||||
#include "nsICollection.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "gc.h"
|
||||
|
||||
extern "C" {
|
||||
extern FILE *GC_stdout, *GC_stderr;
|
||||
extern void GC_trace_object(GC_PTR object, int verbose);
|
||||
extern void GC_mark_object(GC_PTR object, GC_word mark);
|
||||
}
|
||||
|
||||
static nsresult nextLeakFile()
|
||||
{
|
||||
if (GC_stderr != NULL)
|
||||
fclose(GC_stderr);
|
||||
|
||||
// generate a time stamped report name.
|
||||
time_t timer;
|
||||
time(&timer);
|
||||
tm* now = localtime(&timer);
|
||||
|
||||
char reportName[256];
|
||||
sprintf(reportName, "Leaks%02d%02d%02d",
|
||||
now->tm_hour, now->tm_min, now->tm_sec);
|
||||
GC_stderr = fopen(reportName, "w");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static FILE* openTraceFile()
|
||||
{
|
||||
// generate a time stamped report name.
|
||||
time_t timer;
|
||||
time(&timer);
|
||||
tm* now = localtime(&timer);
|
||||
|
||||
char reportName[256];
|
||||
sprintf(reportName, "Trace%02d%02d%02d",
|
||||
now->tm_hour, now->tm_min, now->tm_sec);
|
||||
return fopen(reportName, "w");
|
||||
}
|
||||
|
||||
class nsLeakDetector : public nsILeakDetector {
|
||||
public:
|
||||
nsLeakDetector();
|
||||
virtual ~nsLeakDetector();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILEAKDETECTOR
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsLeakDetector, nsILeakDetector)
|
||||
|
||||
nsLeakDetector::nsLeakDetector() {
|
||||
}
|
||||
nsLeakDetector::~nsLeakDetector() {}
|
||||
|
||||
NS_METHOD nsLeakDetector::DumpLeaks()
|
||||
{
|
||||
GC_gcollect();
|
||||
|
||||
return nextLeakFile();
|
||||
}
|
||||
|
||||
NS_METHOD nsLeakDetector::TraceObject(nsISupports* object, PRBool verbose)
|
||||
{
|
||||
FILE* trace = openTraceFile();
|
||||
if (trace != NULL) {
|
||||
FILE* old_stderr = GC_stderr;
|
||||
GC_stderr = trace;
|
||||
GC_trace_object(object, (verbose ? 1 : 0));
|
||||
GC_stderr = old_stderr;
|
||||
fclose(trace);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD nsLeakDetector::TraceCollection(nsICollection* objects, PRBool verbose)
|
||||
{
|
||||
PRUint32 count;
|
||||
if (NS_FAILED(objects->Count(&count)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupports>* elements = new nsCOMPtr<nsISupports>[count];
|
||||
if (elements == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
objects->GetElementAt(i, getter_AddRefs(elements[i]));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
FILE* trace = openTraceFile();
|
||||
if (trace != NULL) {
|
||||
FILE* old_stderr = GC_stderr;
|
||||
GC_stderr = trace;
|
||||
GC_trace_object(elements, (verbose ? 1 : 0));
|
||||
GC_stderr = old_stderr;
|
||||
fclose(trace);
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
delete[] elements;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD nsLeakDetector::MarkObject(nsISupports* object, PRBool marked)
|
||||
{
|
||||
GC_mark_object(object, (marked ? 1 : 0));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsLeakDetector::GetServices(nsISupports* *result)
|
||||
{
|
||||
return NS_GetServiceManager((nsIServiceManager**)result);
|
||||
}
|
||||
|
||||
#define NS_CLEAKDETECTOR_CID_STR "bb1ba360-1dd1-11b2-b30e-aa2314429f54"
|
||||
#define NS_CLEAKDETECTOR_CID {0xbb1ba360, 0x1dd1, 0x11b2, {0xb3, 0x0e, 0xaa, 0x23, 0x14, 0x42, 0x9f, 0x54}}
|
||||
#define NS_CLEAKDETECTOR_CONTRACTID "@mozilla.org/xpcom/leakdetector;1"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLeakDetector)
|
||||
|
||||
static NS_DEFINE_CID(kCLeakDetectorCID, NS_CLEAKDETECTOR_CID);
|
||||
|
||||
nsresult NS_InitLeakDetector()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// open the first leak file.
|
||||
rv = nextLeakFile();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
static const nsModuleComponentInfo info = {
|
||||
"Leak Detector", kCLeakDetectorCID, NS_CLEAKDETECTOR_CONTRACTID, nsLeakDetectorConstructor
|
||||
};
|
||||
|
||||
// create a generic factory for the leak detector.
|
||||
nsCOMPtr<nsIGenericFactory> factory;
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(factory), &info);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// register this factory with the component manager.
|
||||
return nsComponentManager::RegisterFactory(info.mCID, info.mDescription, info.mContractID, factory, PR_TRUE);
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define SHUTDOWN_LEAKS_EARLY
|
||||
#undef SHUTDOWN_LEAKS_MEDIUM
|
||||
#undef SHUTDOWN_LEAKS_LATE
|
||||
#else
|
||||
#undef SHUTDOWN_LEAKS_EARLY
|
||||
#undef SHUTDOWN_LEAKS_MEDIUM
|
||||
#define SHUTDOWN_LEAKS_LATE
|
||||
#endif
|
||||
|
||||
class LeakDetectorFinalizer
|
||||
{
|
||||
public:
|
||||
~LeakDetectorFinalizer();
|
||||
};
|
||||
|
||||
#ifdef SHUTDOWN_LEAKS_LATE
|
||||
// do shutdown leaks when XPCOM library is unloaded
|
||||
LeakDetectorFinalizer gLeakDetectorFinalizer;
|
||||
#endif
|
||||
|
||||
LeakDetectorFinalizer::~LeakDetectorFinalizer()
|
||||
{
|
||||
GC_gcollect();
|
||||
|
||||
#if 0
|
||||
nextLeakFile();
|
||||
if (GC_stdout != NULL) {
|
||||
fprintf(GC_stdout, "ShutDown Leaks\n");
|
||||
GC_clear_roots();
|
||||
GC_gcollect();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult NS_ShutdownLeakDetector()
|
||||
{
|
||||
#if defined(SHUTDOWN_LEAKS_MEDIUM)
|
||||
// Make this the first atexit() called so it's before the atexit() crashes
|
||||
// see http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=23552
|
||||
static LeakDetectorFinalizer trick;
|
||||
#elif defined(SHUTDOWN_LEAKS_EARLY)
|
||||
// do shutdown leaks now
|
||||
LeakDetectorFinalizer trick;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif /* defined(GC_LEAK_DETECTOR) */
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsLeakDetector_h
|
||||
#define nsLeakDetector_h
|
||||
|
||||
#ifndef nsError_h
|
||||
#include "nsError.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
nsresult NS_InitGarbageCollector(void);
|
||||
nsresult NS_InitLeakDetector(void);
|
||||
nsresult NS_ShutdownLeakDetector(void);
|
||||
nsresult NS_ShutdownGarbageCollector(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* nsLeakDetector_h */
|
||||
@@ -1,544 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMemoryImpl.h"
|
||||
#include "prmem.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include <windows.h>
|
||||
#define NS_MEMORY_FLUSHER_THREAD
|
||||
#elif defined(XP_MAC)
|
||||
#include <MacMemory.h>
|
||||
#define NS_MEMORY_FLUSHER_THREAD
|
||||
#else
|
||||
// Need to implement the nsIMemory::IsLowMemory() predicate
|
||||
#undef NS_MEMORY_FLUSHER_THREAD
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if defined(XDEBUG_waterson)
|
||||
#define NS_TEST_MEMORY_FLUSHER
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A runnable that is used to periodically check the status
|
||||
* of the system, determine if too much memory is in use,
|
||||
* and if so, trigger a "memory flush".
|
||||
*/
|
||||
class MemoryFlusher : public nsIRunnable
|
||||
{
|
||||
protected:
|
||||
nsMemoryImpl* mMemoryImpl; // WEAK, it owns us.
|
||||
PRBool mRunning;
|
||||
PRIntervalTime mTimeout;
|
||||
PRLock* mLock;
|
||||
PRCondVar* mCVar;
|
||||
|
||||
MemoryFlusher(nsMemoryImpl* aMemoryImpl);
|
||||
virtual ~MemoryFlusher();
|
||||
|
||||
enum {
|
||||
kInitialTimeout = 60 /*seconds*/
|
||||
};
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a memory flusher.
|
||||
* @param aResult the memory flusher
|
||||
* @param aMemoryImpl the owning nsMemoryImpl object
|
||||
* @return NS_OK if the memory flusher was created successfully
|
||||
*/
|
||||
static nsresult
|
||||
Create(MemoryFlusher** aResult, nsMemoryImpl* aMemoryImpl);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
/**
|
||||
* Stop the memory flusher.
|
||||
*/
|
||||
nsresult Stop();
|
||||
};
|
||||
|
||||
|
||||
MemoryFlusher::MemoryFlusher(nsMemoryImpl* aMemoryImpl)
|
||||
: mMemoryImpl(aMemoryImpl),
|
||||
mRunning(PR_FALSE),
|
||||
mTimeout(PR_SecondsToInterval(kInitialTimeout)),
|
||||
mLock(nsnull),
|
||||
mCVar(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
MemoryFlusher::~MemoryFlusher()
|
||||
{
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
|
||||
if (mCVar)
|
||||
PR_DestroyCondVar(mCVar);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
MemoryFlusher::Create(MemoryFlusher** aResult, nsMemoryImpl* aMemoryImpl)
|
||||
{
|
||||
MemoryFlusher* result = new MemoryFlusher(aMemoryImpl);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
do {
|
||||
if ((result->mLock = PR_NewLock()) == nsnull)
|
||||
break;
|
||||
|
||||
if ((result->mCVar = PR_NewCondVar(result->mLock)) == nsnull)
|
||||
break;
|
||||
|
||||
NS_ADDREF(*aResult = result);
|
||||
return NS_OK;
|
||||
} while (0);
|
||||
|
||||
// Something bad happened if we get here...
|
||||
delete result;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(MemoryFlusher, nsIRunnable)
|
||||
|
||||
NS_IMETHODIMP
|
||||
MemoryFlusher::Run()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mRunning = PR_TRUE;
|
||||
|
||||
while (1) {
|
||||
PRStatus status;
|
||||
|
||||
{
|
||||
nsAutoLock l(mLock);
|
||||
if (! mRunning) {
|
||||
rv = NS_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
status = PR_WaitCondVar(mCVar, mTimeout);
|
||||
}
|
||||
|
||||
if (status != PR_SUCCESS) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! mRunning) {
|
||||
rv = NS_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
PRBool isLowMemory;
|
||||
rv = mMemoryImpl->IsLowMemory(&isLowMemory);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
#ifdef NS_TEST_MEMORY_FLUSHER
|
||||
// Fire the flusher *every* time
|
||||
isLowMemory = PR_TRUE;
|
||||
#endif
|
||||
|
||||
if (isLowMemory) {
|
||||
mMemoryImpl->FlushMemory(NS_LITERAL_STRING("low-memory").get(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
mRunning = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
MemoryFlusher::Stop()
|
||||
{
|
||||
if (mRunning) {
|
||||
nsAutoLock l(mLock);
|
||||
mRunning = PR_FALSE;
|
||||
PR_NotifyCondVar(mCVar);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsMemoryImpl, nsIMemory)
|
||||
|
||||
NS_METHOD
|
||||
nsMemoryImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
NS_ENSURE_PROPER_AGGREGATION(outer, aIID);
|
||||
|
||||
nsMemoryImpl* mm = new nsMemoryImpl();
|
||||
if (mm == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
do {
|
||||
rv = mm->QueryInterface(aIID, aInstancePtr);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mm->mFlushLock = PR_NewLock();
|
||||
if (! mm->mFlushLock)
|
||||
break;
|
||||
|
||||
rv = NS_OK;
|
||||
} while (0);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
delete mm;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsMemoryImpl::nsMemoryImpl()
|
||||
: mFlusher(nsnull),
|
||||
mFlushLock(nsnull),
|
||||
mIsFlushing(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsMemoryImpl::~nsMemoryImpl()
|
||||
{
|
||||
if (mFlushLock)
|
||||
PR_DestroyLock(mFlushLock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Define NS_OUT_OF_MEMORY_TESTER if you want to force memory failures
|
||||
|
||||
#ifdef DEBUG_xwarren
|
||||
#define NS_OUT_OF_MEMORY_TESTER
|
||||
#endif
|
||||
|
||||
#ifdef NS_OUT_OF_MEMORY_TESTER
|
||||
|
||||
// flush memory one in this number of times:
|
||||
#define NS_FLUSH_FREQUENCY 100000
|
||||
|
||||
// fail allocation one in this number of flushes:
|
||||
#define NS_FAIL_FREQUENCY 10
|
||||
|
||||
PRUint32 gFlushFreq = 0;
|
||||
PRUint32 gFailFreq = 0;
|
||||
|
||||
static void*
|
||||
mallocator(PRSize size, PRUint32& counter, PRUint32 max)
|
||||
{
|
||||
if (counter++ >= max) {
|
||||
counter = 0;
|
||||
NS_ASSERTION(0, "about to fail allocation... watch out");
|
||||
return nsnull;
|
||||
}
|
||||
return PR_Malloc(size);
|
||||
}
|
||||
|
||||
static void*
|
||||
reallocator(void* ptr, PRSize size, PRUint32& counter, PRUint32 max)
|
||||
{
|
||||
if (counter++ >= max) {
|
||||
counter = 0;
|
||||
NS_ASSERTION(0, "about to fail reallocation... watch out");
|
||||
return nsnull;
|
||||
}
|
||||
return PR_Realloc(ptr, size);
|
||||
}
|
||||
|
||||
#define MALLOC1(s) mallocator(s, gFlushFreq, NS_FLUSH_FREQUENCY)
|
||||
#define REALLOC1(p, s) reallocator(p, s, gFlushFreq, NS_FLUSH_FREQUENCY)
|
||||
|
||||
#else
|
||||
|
||||
#define MALLOC1(s) PR_Malloc(s)
|
||||
#define REALLOC1(p, s) PR_Realloc(p, s)
|
||||
|
||||
#endif // NS_OUT_OF_MEMORY_TESTER
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP_(void *)
|
||||
nsMemoryImpl::Alloc(PRSize size)
|
||||
{
|
||||
NS_ASSERTION(size, "nsMemoryImpl::Alloc of 0");
|
||||
void* result = MALLOC1(size);
|
||||
if (! result) {
|
||||
// Request an asynchronous flush
|
||||
FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void *)
|
||||
nsMemoryImpl::Realloc(void * ptr, PRSize size)
|
||||
{
|
||||
void* result = REALLOC1(ptr, size);
|
||||
if (! result) {
|
||||
// Request an asynchronous flush
|
||||
FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
nsMemoryImpl::Free(void * ptr)
|
||||
{
|
||||
PR_Free(ptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryImpl::HeapMinimize(PRBool aImmediate)
|
||||
{
|
||||
return FlushMemory(NS_LITERAL_STRING("heap-minimize").get(), aImmediate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryImpl::IsLowMemory(PRBool *result)
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
MEMORYSTATUS stat;
|
||||
GlobalMemoryStatus(&stat);
|
||||
*result = ((float)stat.dwAvailPageFile / stat.dwTotalPageFile) < 0.1;
|
||||
#elif defined(XP_MAC)
|
||||
|
||||
const long kReserveHeapFreeSpace = (256 * 1024);
|
||||
const long kReserveHeapContigSpace = (128 * 1024);
|
||||
|
||||
long totalSpace, contiguousSpace;
|
||||
// this call measures how much memory would be available if the OS
|
||||
// purged. Despite the name, it does not purge (that happens
|
||||
// automatically when heap space is low).
|
||||
::PurgeSpace(&totalSpace, &contiguousSpace);
|
||||
if (totalSpace < kReserveHeapFreeSpace || contiguousSpace < kReserveHeapContigSpace)
|
||||
{
|
||||
NS_WARNING("Found that heap mem is low");
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// see how much temp mem is available (since our allocators allocate 1Mb chunks
|
||||
// in temp mem. We don't use TempMaxMem() (to get contig space) here, because it
|
||||
// compacts the application heap, so can be slow.
|
||||
const long kReserveTempFreeSpace = (2 * 1024 * 1024); // 2Mb
|
||||
long totalTempSpace = ::TempFreeMem();
|
||||
if (totalTempSpace < kReserveTempFreeSpace)
|
||||
{
|
||||
NS_WARNING("Found that temp mem is low");
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*result = PR_FALSE;
|
||||
|
||||
#else
|
||||
*result = PR_FALSE;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryImpl::FlushMemory(const PRUnichar* aReason, PRBool aImmediate)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aImmediate) {
|
||||
// They've asked us to run the flusher *immediately*. We've
|
||||
// got to be on the UI main thread for us to be able to do
|
||||
// that...are we?
|
||||
PRBool isOnUIThread = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIThread> main;
|
||||
rv = nsIThread::GetMainThread(getter_AddRefs(main));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIThread> current;
|
||||
rv = nsIThread::GetCurrent(getter_AddRefs(current));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (current == main)
|
||||
isOnUIThread = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (! isOnUIThread) {
|
||||
NS_ERROR("can't synchronously flush memory: not on UI thread");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Are we already flushing?
|
||||
nsAutoLock l(mFlushLock);
|
||||
if (mIsFlushing)
|
||||
return NS_OK;
|
||||
|
||||
// Well, we are now!
|
||||
mIsFlushing = PR_TRUE;
|
||||
}
|
||||
|
||||
// Run the flushers immediately if we can; otherwise, proxy to the
|
||||
// UI thread an run 'em asynchronously.
|
||||
if (aImmediate) {
|
||||
rv = RunFlushers(this, aReason);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIEventQueueService> eqs = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (eqs) {
|
||||
nsCOMPtr<nsIEventQueue> eq;
|
||||
rv = eqs->GetThreadEventQueue(NS_UI_THREAD, getter_AddRefs(eq));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PL_InitEvent(&mFlushEvent.mEvent, this, HandleFlushEvent, DestroyFlushEvent);
|
||||
mFlushEvent.mReason = aReason;
|
||||
|
||||
rv = eq->PostEvent(NS_REINTERPRET_CAST(PLEvent*, &mFlushEvent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryImpl::RunFlushers(nsMemoryImpl* aSelf, const PRUnichar* aReason)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (os) {
|
||||
os->NotifyObservers(aSelf, "memory-pressure", aReason);
|
||||
}
|
||||
|
||||
{
|
||||
// Done flushing
|
||||
nsAutoLock l(aSelf->mFlushLock);
|
||||
aSelf->mIsFlushing = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void*
|
||||
nsMemoryImpl::HandleFlushEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsMemoryImpl* self = NS_STATIC_CAST(nsMemoryImpl*, PL_GetEventOwner(aEvent));
|
||||
FlushEvent* event = NS_REINTERPRET_CAST(FlushEvent*, aEvent);
|
||||
|
||||
RunFlushers(self, event->mReason);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsMemoryImpl::DestroyFlushEvent(PLEvent* aEvent)
|
||||
{
|
||||
// no-op, since mEvent is a member of nsMemoryImpl
|
||||
}
|
||||
|
||||
nsMemoryImpl* gMemory = nsnull;
|
||||
|
||||
static void
|
||||
EnsureGlobalMemoryService()
|
||||
{
|
||||
if (gMemory) return;
|
||||
nsresult rv = nsMemoryImpl::Create(nsnull, NS_GET_IID(nsIMemory), (void**)&gMemory);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMemoryImpl::Create failed");
|
||||
NS_ASSERTION(gMemory, "improper xpcom initialization");
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryImpl::Startup()
|
||||
{
|
||||
EnsureGlobalMemoryService();
|
||||
if (! gMemory)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef NS_MEMORY_FLUSHER_THREAD
|
||||
nsresult rv;
|
||||
|
||||
// Create and start a memory flusher thread
|
||||
rv = MemoryFlusher::Create(&gMemory->mFlusher, gMemory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NS_NewThread(getter_AddRefs(gMemory->mFlusherThread),
|
||||
gMemory->mFlusher,
|
||||
0, /* XXX use default stack size? */
|
||||
PR_JOINABLE_THREAD);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryImpl::Shutdown()
|
||||
{
|
||||
if (gMemory) {
|
||||
#ifdef NS_MEMORY_FLUSHER_THREAD
|
||||
if (gMemory->mFlusher) {
|
||||
// Stop the runnable...
|
||||
gMemory->mFlusher->Stop();
|
||||
NS_RELEASE(gMemory->mFlusher);
|
||||
|
||||
// ...and wait for the thread to exit
|
||||
if (gMemory->mFlusherThread)
|
||||
gMemory->mFlusherThread->Join();
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_RELEASE(gMemory);
|
||||
gMemory = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsMemoryImpl_h__
|
||||
#define nsMemoryImpl_h__
|
||||
|
||||
#include "nsMemory.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "plevent.h"
|
||||
|
||||
struct PRLock;
|
||||
class MemoryFlusher;
|
||||
|
||||
class nsMemoryImpl : public nsIMemory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMEMORY
|
||||
|
||||
nsMemoryImpl();
|
||||
virtual ~nsMemoryImpl();
|
||||
|
||||
nsresult FlushMemory(const PRUnichar* aReason, PRBool aImmediate);
|
||||
|
||||
// called from xpcom initialization/finalization:
|
||||
static nsresult Startup();
|
||||
static nsresult Shutdown();
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
protected:
|
||||
MemoryFlusher* mFlusher;
|
||||
nsCOMPtr<nsIThread> mFlusherThread;
|
||||
|
||||
PRLock* mFlushLock;
|
||||
PRBool mIsFlushing;
|
||||
|
||||
struct FlushEvent {
|
||||
PLEvent mEvent;
|
||||
const PRUnichar* mReason;
|
||||
};
|
||||
|
||||
FlushEvent mFlushEvent;
|
||||
|
||||
static nsresult RunFlushers(nsMemoryImpl* aSelf, const PRUnichar* aReason);
|
||||
|
||||
static void* PR_CALLBACK HandleFlushEvent(PLEvent* aEvent);
|
||||
static void PR_CALLBACK DestroyFlushEvent(PLEvent* aEvent);
|
||||
};
|
||||
|
||||
#endif // nsMemoryImpl_h__
|
||||
@@ -1,386 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsStackFrameWin.h code, released
|
||||
* December 20, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2003 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
#include "nsStackFrameUnix.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "nscore.h"
|
||||
|
||||
// On glibc 2.1, the Dl_info api defined in <dlfcn.h> is only exposed
|
||||
// if __USE_GNU is defined. I suppose its some kind of standards
|
||||
// adherence thing.
|
||||
//
|
||||
#if (__GLIBC_MINOR__ >= 1) && !defined(__USE_GNU)
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// This thing is exported by libiberty.a (-liberty)
|
||||
// Yes, this is a gcc only hack
|
||||
#if defined(MOZ_DEMANGLE_SYMBOLS)
|
||||
extern "C" char * cplus_demangle(const char *,int);
|
||||
#include <stdlib.h> // for free()
|
||||
#endif // MOZ_DEMANGLE_SYMBOLS
|
||||
|
||||
#if (defined(__linux__) || defined(__sun)) && defined(__GNUC__)
|
||||
void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
int aBufLen)
|
||||
{
|
||||
aBuffer[0] = '\0';
|
||||
|
||||
#if defined(MOZ_DEMANGLE_SYMBOLS)
|
||||
/* See demangle.h in the gcc source for the voodoo */
|
||||
char * demangled = cplus_demangle(aSymbol,3);
|
||||
|
||||
if (demangled)
|
||||
{
|
||||
strncpy(aBuffer,demangled,aBufLen);
|
||||
free(demangled);
|
||||
}
|
||||
#endif // MOZ_DEMANGLE_SYMBOLS
|
||||
}
|
||||
|
||||
#else
|
||||
void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
int aBufLen)
|
||||
{
|
||||
// lose
|
||||
aBuffer[0] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC)) // i386 or PPC Linux stackwalking code
|
||||
|
||||
#include <setjmp.h>
|
||||
//
|
||||
|
||||
void DumpStackToFile(FILE* aStream)
|
||||
{
|
||||
jmp_buf jb;
|
||||
setjmp(jb);
|
||||
|
||||
// Stack walking code courtesy Kipp's "leaky".
|
||||
|
||||
// Get the frame pointer out of the jmp_buf
|
||||
#if defined(__i386)
|
||||
unsigned long* bp = (unsigned long*) (jb[0].__jmpbuf[JB_BP]);
|
||||
#elif defined(PPC)
|
||||
unsigned long* bp = (unsigned long*) (jb[0].__jmpbuf[JB_GPR1]);
|
||||
#endif
|
||||
|
||||
int skip = 2;
|
||||
for (unsigned long *nextbp = (unsigned long*) *bp++, pc = *bp;
|
||||
pc >= 0x08000000 && pc < 0x7fffffff && nextbp > bp;
|
||||
bp = nextbp, nextbp = (unsigned long*) *bp++, pc = *bp) {
|
||||
if (--skip <= 0) {
|
||||
Dl_info info;
|
||||
int ok = dladdr((void*) pc, &info);
|
||||
if (!ok) {
|
||||
fprintf(aStream, "UNKNOWN %p\n", (void *)pc);
|
||||
continue;
|
||||
}
|
||||
|
||||
PRUint32 foff = (char*)pc - (char*)info.dli_fbase;
|
||||
|
||||
const char * symbol = info.dli_sname;
|
||||
int len;
|
||||
if (!symbol || !(len = strlen(symbol))) {
|
||||
fprintf(aStream, "UNKNOWN [%s +0x%08X]\n",
|
||||
info.dli_fname, foff);
|
||||
continue;
|
||||
}
|
||||
|
||||
char demangled[4096] = "\0";
|
||||
|
||||
DemangleSymbol(symbol, demangled, sizeof(demangled));
|
||||
|
||||
if (strlen(demangled)) {
|
||||
symbol = demangled;
|
||||
len = strlen(symbol);
|
||||
}
|
||||
|
||||
PRUint32 off = (char*)pc - (char*)info.dli_saddr;
|
||||
fprintf(aStream, "%s+0x%08X [%s +0x%08X]\n",
|
||||
symbol, off, info.dli_fname, foff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))
|
||||
|
||||
/*
|
||||
* Stack walking code for Solaris courtesy of Bart Smaalder's "memtrak".
|
||||
*/
|
||||
|
||||
#include <synch.h>
|
||||
#include <ucontext.h>
|
||||
#include <sys/frame.h>
|
||||
#include <sys/regset.h>
|
||||
#include <sys/stack.h>
|
||||
|
||||
static int load_address ( void * pc, void * arg, FILE * aStream );
|
||||
static int write_address_file ( void * pc );
|
||||
static struct bucket * newbucket ( void * pc );
|
||||
static struct frame * cs_getmyframeptr ( void );
|
||||
static void cs_walk_stack ( void * (*read_func)(char * address),
|
||||
struct frame * fp,
|
||||
int (*operate_func)(void *, void *),
|
||||
void * usrarg, FILE * aStream );
|
||||
static void cs_operate ( void (*operate_func)(void *, void *),
|
||||
void * usrarg, FILE * aStream );
|
||||
|
||||
#ifndef STACK_BIAS
|
||||
#define STACK_BIAS 0
|
||||
#endif /*STACK_BIAS*/
|
||||
|
||||
#define LOGSIZE 4096
|
||||
|
||||
/* type of demangling function */
|
||||
typedef int demf_t(const char *, char *, size_t);
|
||||
|
||||
static demf_t *demf;
|
||||
|
||||
static int initialized = 0;
|
||||
|
||||
#if defined(sparc) || defined(__sparc)
|
||||
#define FRAME_PTR_REGISTER REG_SP
|
||||
#endif
|
||||
|
||||
#if defined(i386) || defined(__i386)
|
||||
#define FRAME_PTR_REGISTER EBP
|
||||
#endif
|
||||
|
||||
struct bucket {
|
||||
void * pc;
|
||||
int index;
|
||||
struct bucket * next;
|
||||
};
|
||||
|
||||
struct mybuf {
|
||||
char * buffer;
|
||||
int chars_left;
|
||||
};
|
||||
|
||||
|
||||
static void myinit();
|
||||
|
||||
#pragma init (myinit)
|
||||
|
||||
static void
|
||||
myinit()
|
||||
{
|
||||
|
||||
if (! initialized) {
|
||||
#ifndef __GNUC__
|
||||
void *handle;
|
||||
const char *libdem = "libdemangle.so.1";
|
||||
|
||||
/* load libdemangle if we can and need to (only try this once) */
|
||||
if ((handle = dlopen(libdem, RTLD_LAZY)) != NULL) {
|
||||
demf = (demf_t *)dlsym(handle,
|
||||
"cplus_demangle"); /*lint !e611 */
|
||||
/*
|
||||
* lint override above is to prevent lint from
|
||||
* complaining about "suspicious cast".
|
||||
*/
|
||||
}
|
||||
#endif /*__GNUC__*/
|
||||
}
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
write_address_file(void * pc, FILE* aStream)
|
||||
{
|
||||
static struct bucket table[2048];
|
||||
static mutex_t lock;
|
||||
struct bucket * ptr;
|
||||
|
||||
unsigned int val = NS_PTR_TO_INT32(pc);
|
||||
|
||||
ptr = table + ((val >> 2)&2047);
|
||||
|
||||
mutex_lock(&lock);
|
||||
while (ptr->next) {
|
||||
if (ptr->next->pc == pc)
|
||||
break;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
if (ptr->next) {
|
||||
mutex_unlock(&lock);
|
||||
return (ptr->next->index);
|
||||
} else {
|
||||
char buffer[4096], dembuff[4096];
|
||||
Dl_info info;
|
||||
char *func, *lib;
|
||||
|
||||
ptr->next = newbucket(pc);
|
||||
mutex_unlock(&lock);
|
||||
|
||||
if (dladdr(pc, & info) == 0) {
|
||||
func = "??";
|
||||
lib = "??";
|
||||
} else {
|
||||
lib = (char *) info.dli_fname;
|
||||
func = (char *) info.dli_sname;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
DemangleSymbol(func, dembuff, sizeof(dembuff));
|
||||
if (strlen(dembuff)) {
|
||||
func = dembuff;
|
||||
}
|
||||
#else
|
||||
if (demf) {
|
||||
if (demf(func, dembuff, sizeof (dembuff)) == 0)
|
||||
func = dembuff;
|
||||
}
|
||||
#endif /*__GNUC__*/
|
||||
|
||||
fprintf(aStream, "%u %s:%s+0x%x\n",
|
||||
ptr->next->index,
|
||||
lib,
|
||||
func,
|
||||
(char *)pc - (char*)info.dli_saddr);
|
||||
|
||||
return (ptr->next->index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
load_address(void * pc, void * arg, FILE * aStream)
|
||||
{
|
||||
struct mybuf * buf = (struct mybuf *) arg;
|
||||
|
||||
char name[80];
|
||||
int len;
|
||||
|
||||
sprintf(name, " %u", write_address_file(pc, aStream));
|
||||
|
||||
len = strlen(name);
|
||||
|
||||
if (len >= buf->chars_left)
|
||||
return (1);
|
||||
|
||||
strcat(buf->buffer, name);
|
||||
|
||||
buf->chars_left -= len;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static struct bucket *
|
||||
newbucket(void * pc)
|
||||
{
|
||||
struct bucket * ptr = (struct bucket *) malloc(sizeof (*ptr));
|
||||
static int index; /* protected by lock in caller */
|
||||
|
||||
ptr->index = index++;
|
||||
ptr->next = NULL;
|
||||
ptr->pc = pc;
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
|
||||
static struct frame *
|
||||
csgetframeptr()
|
||||
{
|
||||
ucontext_t u;
|
||||
struct frame *fp;
|
||||
|
||||
(void) getcontext(&u);
|
||||
|
||||
fp = (struct frame *)
|
||||
((char *)u.uc_mcontext.gregs[FRAME_PTR_REGISTER] +
|
||||
STACK_BIAS);
|
||||
|
||||
/* make sure to return parents frame pointer.... */
|
||||
|
||||
return ((struct frame *)((ulong_t)fp->fr_savfp + STACK_BIAS));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cswalkstack(struct frame *fp, int (*operate_func)(void *, void *, FILE *),
|
||||
void *usrarg, FILE * aStream)
|
||||
{
|
||||
|
||||
while (fp != 0 && fp->fr_savpc != 0) {
|
||||
|
||||
if (operate_func((void *)fp->fr_savpc, usrarg, aStream) != 0)
|
||||
break;
|
||||
/*
|
||||
* watch out - libthread stacks look funny at the top
|
||||
* so they may not have their STACK_BIAS set
|
||||
*/
|
||||
|
||||
fp = (struct frame *)((ulong_t)fp->fr_savfp +
|
||||
(fp->fr_savfp?(ulong_t)STACK_BIAS:0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cs_operate(int (*operate_func)(void *, void *, FILE *), void * usrarg, FILE *aStream)
|
||||
{
|
||||
cswalkstack(csgetframeptr(), operate_func, usrarg, aStream);
|
||||
}
|
||||
|
||||
void DumpStackToFile(FILE* aStream)
|
||||
{
|
||||
char buffer[LOGSIZE];
|
||||
struct mybuf mybuf;
|
||||
|
||||
if (!initialized)
|
||||
myinit();
|
||||
|
||||
mybuf.chars_left = LOGSIZE - strlen(buffer)-1;
|
||||
mybuf.buffer = buffer;
|
||||
cs_operate(load_address, &mybuf, aStream);
|
||||
}
|
||||
#endif
|
||||
@@ -1,41 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsStackFrameWin.h code, released
|
||||
* December 20, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2003 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
#ifndef nsStackFrameUnix_h___
|
||||
#define nsStackFrameUnix_h___
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
void DumpStackToFile(FILE* out);
|
||||
|
||||
#endif
|
||||
@@ -1,346 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsStackFrameWin.h code, released
|
||||
* December 20, 2003.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2003 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Michael Judge, 20-December-2000
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "windows.h"
|
||||
#include "imagehlp.h"
|
||||
#include "stdio.h"
|
||||
#include "nsStackFrameWin.h"
|
||||
|
||||
// Define these as static pointers so that we can load the DLL on the
|
||||
// fly (and not introduce a link-time dependency on it). Tip o' the
|
||||
// hat to Matt Pietrick for this idea. See:
|
||||
//
|
||||
// http://msdn.microsoft.com/library/periodic/period97/F1/D3/S245C6.htm
|
||||
//
|
||||
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
SYMSETOPTIONSPROC _SymSetOptions;
|
||||
|
||||
SYMINITIALIZEPROC _SymInitialize;
|
||||
|
||||
SYMCLEANUPPROC _SymCleanup;
|
||||
|
||||
STACKWALKPROC _StackWalk;
|
||||
|
||||
SYMFUNCTIONTABLEACCESSPROC _SymFunctionTableAccess;
|
||||
|
||||
SYMGETMODULEBASEPROC _SymGetModuleBase;
|
||||
|
||||
SYMGETSYMFROMADDRPROC _SymGetSymFromAddr;
|
||||
|
||||
SYMLOADMODULE _SymLoadModule;
|
||||
|
||||
SYMUNDNAME _SymUnDName;
|
||||
|
||||
SYMGETMODULEINFO _SymGetModuleInfo;
|
||||
|
||||
ENUMLOADEDMODULES _EnumerateLoadedModules;
|
||||
|
||||
SYMGETLINEFROMADDRPROC _SymGetLineFromAddr;
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
EnsureImageHlpInitialized()
|
||||
{
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
|
||||
if (! gInitialized) {
|
||||
HMODULE module = ::LoadLibrary("IMAGEHLP.DLL");
|
||||
if (!module) return PR_FALSE;
|
||||
|
||||
_SymSetOptions = (SYMSETOPTIONSPROC) ::GetProcAddress(module, "SymSetOptions");
|
||||
if (!_SymSetOptions) return PR_FALSE;
|
||||
|
||||
_SymInitialize = (SYMINITIALIZEPROC) ::GetProcAddress(module, "SymInitialize");
|
||||
if (!_SymInitialize) return PR_FALSE;
|
||||
|
||||
_SymCleanup = (SYMCLEANUPPROC)GetProcAddress(module, "SymCleanup");
|
||||
if (!_SymCleanup) return PR_FALSE;
|
||||
|
||||
_StackWalk = (STACKWALKPROC)GetProcAddress(module, "StackWalk");
|
||||
if (!_StackWalk) return PR_FALSE;
|
||||
|
||||
_SymFunctionTableAccess = (SYMFUNCTIONTABLEACCESSPROC) GetProcAddress(module, "SymFunctionTableAccess");
|
||||
if (!_SymFunctionTableAccess) return PR_FALSE;
|
||||
|
||||
_SymGetModuleBase = (SYMGETMODULEBASEPROC)GetProcAddress(module, "SymGetModuleBase");
|
||||
if (!_SymGetModuleBase) return PR_FALSE;
|
||||
|
||||
_SymGetSymFromAddr = (SYMGETSYMFROMADDRPROC)GetProcAddress(module, "SymGetSymFromAddr");
|
||||
if (!_SymGetSymFromAddr) return PR_FALSE;
|
||||
|
||||
_SymLoadModule = (SYMLOADMODULE)GetProcAddress(module, "SymLoadModule");
|
||||
if (!_SymLoadModule) return PR_FALSE;
|
||||
|
||||
_SymUnDName = (SYMUNDNAME)GetProcAddress(module, "SymUnDName");
|
||||
if (!_SymUnDName) return PR_FALSE;
|
||||
|
||||
_SymGetModuleInfo = (SYMGETMODULEINFO)GetProcAddress(module, "SymGetModuleInfo");
|
||||
if (!_SymGetModuleInfo) return PR_FALSE;
|
||||
|
||||
_EnumerateLoadedModules = (ENUMLOADEDMODULES)GetProcAddress(module, "EnumerateLoadedModules");
|
||||
if (!_EnumerateLoadedModules) return PR_FALSE;
|
||||
|
||||
_SymGetLineFromAddr = (SYMGETLINEFROMADDRPROC)GetProcAddress(module, "SymGetLineFromAddr");
|
||||
if (!_SymGetLineFromAddr) return PR_FALSE;
|
||||
|
||||
gInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
return gInitialized;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback used by SymGetModuleInfoEspecial
|
||||
*/
|
||||
static BOOL CALLBACK callbackEspecial(LPSTR aModuleName, ULONG aModuleBase, ULONG aModuleSize, PVOID aUserContext)
|
||||
{
|
||||
BOOL retval = TRUE;
|
||||
DWORD addr = (DWORD)aUserContext;
|
||||
|
||||
/*
|
||||
* You'll want to control this if we are running on an
|
||||
* architecture where the addresses go the other direction.
|
||||
* Not sure this is even a realistic consideration.
|
||||
*/
|
||||
const BOOL addressIncreases = TRUE;
|
||||
|
||||
/*
|
||||
* If it falls in side the known range, load the symbols.
|
||||
*/
|
||||
if(addressIncreases
|
||||
? (addr >= aModuleBase && addr <= (aModuleBase + aModuleSize))
|
||||
: (addr <= aModuleBase && addr >= (aModuleBase - aModuleSize))
|
||||
)
|
||||
{
|
||||
BOOL loadRes = FALSE;
|
||||
HANDLE process = GetCurrentProcess();
|
||||
|
||||
loadRes = _SymLoadModule(process, NULL, aModuleName, NULL, aModuleBase, aModuleSize);
|
||||
PR_ASSERT(FALSE != loadRes);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* SymGetModuleInfoEspecial
|
||||
*
|
||||
* Attempt to determine the module information.
|
||||
* Bug 112196 says this DLL may not have been loaded at the time
|
||||
* SymInitialize was called, and thus the module information
|
||||
* and symbol information is not available.
|
||||
* This code rectifies that problem.
|
||||
*/
|
||||
BOOL SymGetModuleInfoEspecial(HANDLE aProcess, DWORD aAddr, PIMAGEHLP_MODULE aModuleInfo, PIMAGEHLP_LINE aLineInfo)
|
||||
{
|
||||
BOOL retval = FALSE;
|
||||
|
||||
/*
|
||||
* Init the vars if we have em.
|
||||
*/
|
||||
aModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE);
|
||||
if (nsnull != aLineInfo) {
|
||||
aLineInfo->SizeOfStruct = sizeof(IMAGEHLP_LINE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give it a go.
|
||||
* It may already be loaded.
|
||||
*/
|
||||
retval = _SymGetModuleInfo(aProcess, aAddr, aModuleInfo);
|
||||
|
||||
if (FALSE == retval) {
|
||||
BOOL enumRes = FALSE;
|
||||
|
||||
/*
|
||||
* Not loaded, here's the magic.
|
||||
* Go through all the modules.
|
||||
*/
|
||||
enumRes = _EnumerateLoadedModules(aProcess, callbackEspecial, (PVOID)aAddr);
|
||||
if(FALSE != enumRes)
|
||||
{
|
||||
/*
|
||||
* One final go.
|
||||
* If it fails, then well, we have other problems.
|
||||
*/
|
||||
retval = _SymGetModuleInfo(aProcess, aAddr, aModuleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we got module info, we may attempt line info as well.
|
||||
* We will not report failure if this does not work.
|
||||
*/
|
||||
if (FALSE != retval && nsnull != aLineInfo && nsnull != _SymGetLineFromAddr) {
|
||||
DWORD displacement = 0;
|
||||
BOOL lineRes = FALSE;
|
||||
|
||||
lineRes = _SymGetLineFromAddr(aProcess, aAddr, &displacement, aLineInfo);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
PRBool
|
||||
EnsureSymInitialized()
|
||||
{
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
|
||||
if (! gInitialized) {
|
||||
if (! EnsureImageHlpInitialized())
|
||||
return PR_FALSE;
|
||||
_SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
|
||||
gInitialized = _SymInitialize(GetCurrentProcess(), 0, TRUE);
|
||||
}
|
||||
return gInitialized;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Walk the stack, translating PC's found into strings and recording the
|
||||
* chain in aBuffer. For this to work properly, the dll's must be rebased
|
||||
* so that the address in the file agrees with the address in memory.
|
||||
* Otherwise StackWalk will return FALSE when it hits a frame in a dll's
|
||||
* whose in memory address doesn't match it's in-file address.
|
||||
*
|
||||
* Fortunately, there is a handy dandy routine in IMAGEHLP.DLL that does
|
||||
* the rebasing and accordingly I've made a tool to use it to rebase the
|
||||
* DLL's in one fell swoop (see xpcom/tools/windows/rebasedlls.cpp).
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
DumpStackToFile(FILE* aStream)
|
||||
{
|
||||
HANDLE myProcess = ::GetCurrentProcess();
|
||||
HANDLE myThread = ::GetCurrentThread();
|
||||
BOOL ok;
|
||||
|
||||
ok = EnsureSymInitialized();
|
||||
if (! ok)
|
||||
return;
|
||||
|
||||
// Get the context information for this thread. That way we will
|
||||
// know where our sp, fp, pc, etc. are and can fill in the
|
||||
// STACKFRAME with the initial values.
|
||||
CONTEXT context;
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
ok = GetThreadContext(myThread, &context);
|
||||
if (! ok)
|
||||
return;
|
||||
|
||||
// Setup initial stack frame to walk from
|
||||
STACKFRAME frame;
|
||||
memset(&frame, 0, sizeof(frame));
|
||||
frame.AddrPC.Offset = context.Eip;
|
||||
frame.AddrPC.Mode = AddrModeFlat;
|
||||
frame.AddrStack.Offset = context.Esp;
|
||||
frame.AddrStack.Mode = AddrModeFlat;
|
||||
frame.AddrFrame.Offset = context.Ebp;
|
||||
frame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
// Now walk the stack and map the pc's to symbol names
|
||||
int skip = 2;
|
||||
while (1) {
|
||||
ok = _StackWalk(IMAGE_FILE_MACHINE_I386,
|
||||
myProcess,
|
||||
myThread,
|
||||
&frame,
|
||||
&context,
|
||||
0, // read process memory routine
|
||||
_SymFunctionTableAccess, // function table access routine
|
||||
_SymGetModuleBase, // module base routine
|
||||
0); // translate address routine
|
||||
|
||||
if (!ok) {
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
fprintf(aStream, "### ERROR: WalkStack: %s", lpMsgBuf);
|
||||
fflush(aStream);
|
||||
LocalFree( lpMsgBuf );
|
||||
}
|
||||
if (!ok || frame.AddrPC.Offset == 0)
|
||||
break;
|
||||
|
||||
if (skip-- > 0)
|
||||
continue;
|
||||
|
||||
//
|
||||
// Attempt to load module info before we attempt to reolve the symbol.
|
||||
// This just makes sure we get good info if available.
|
||||
//
|
||||
IMAGEHLP_MODULE modInfo;
|
||||
modInfo.SizeOfStruct = sizeof(modInfo);
|
||||
BOOL modInfoRes = TRUE;
|
||||
modInfoRes = SymGetModuleInfoEspecial(myProcess, frame.AddrPC.Offset, &modInfo, nsnull);
|
||||
|
||||
char buf[sizeof(IMAGEHLP_SYMBOL) + 512];
|
||||
PIMAGEHLP_SYMBOL symbol = (PIMAGEHLP_SYMBOL) buf;
|
||||
symbol->SizeOfStruct = sizeof(buf);
|
||||
symbol->MaxNameLength = 512;
|
||||
|
||||
DWORD displacement;
|
||||
ok = _SymGetSymFromAddr(myProcess,
|
||||
frame.AddrPC.Offset,
|
||||
&displacement,
|
||||
symbol);
|
||||
|
||||
if (ok) {
|
||||
fprintf(aStream, "%s+0x%08X\n", symbol->Name, displacement);
|
||||
}
|
||||
else {
|
||||
fprintf(aStream, "0x%08X\n", frame.AddrPC.Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsStackFrameWin.h code, released
|
||||
* December 20, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Michael Judge, 20-December-2000
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
#ifndef nsStackFrameWin_h___
|
||||
#define nsStackFrameWin_h___
|
||||
|
||||
|
||||
#if defined(_WIN32) && defined(_M_IX86) // WIN32 x86 stack walking code
|
||||
#include "nspr.h"
|
||||
#include <windows.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
// Define these as static pointers so that we can load the DLL on the
|
||||
// fly (and not introduce a link-time dependency on it). Tip o' the
|
||||
// hat to Matt Pietrick for this idea. See:
|
||||
//
|
||||
// http://msdn.microsoft.com/library/periodic/period97/F1/D3/S245C6.htm
|
||||
//
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef DWORD (__stdcall *SYMSETOPTIONSPROC)(DWORD);
|
||||
extern SYMSETOPTIONSPROC _SymSetOptions;
|
||||
|
||||
typedef BOOL (__stdcall *SYMINITIALIZEPROC)(HANDLE, LPSTR, BOOL);
|
||||
extern SYMINITIALIZEPROC _SymInitialize;
|
||||
|
||||
typedef BOOL (__stdcall *SYMCLEANUPPROC)(HANDLE);
|
||||
extern SYMCLEANUPPROC _SymCleanup;
|
||||
|
||||
typedef BOOL (__stdcall *STACKWALKPROC)(DWORD,
|
||||
HANDLE,
|
||||
HANDLE,
|
||||
LPSTACKFRAME,
|
||||
LPVOID,
|
||||
PREAD_PROCESS_MEMORY_ROUTINE,
|
||||
PFUNCTION_TABLE_ACCESS_ROUTINE,
|
||||
PGET_MODULE_BASE_ROUTINE,
|
||||
PTRANSLATE_ADDRESS_ROUTINE);
|
||||
extern STACKWALKPROC _StackWalk;
|
||||
|
||||
typedef LPVOID (__stdcall *SYMFUNCTIONTABLEACCESSPROC)(HANDLE, DWORD);
|
||||
extern SYMFUNCTIONTABLEACCESSPROC _SymFunctionTableAccess;
|
||||
|
||||
typedef DWORD (__stdcall *SYMGETMODULEBASEPROC)(HANDLE, DWORD);
|
||||
extern SYMGETMODULEBASEPROC _SymGetModuleBase;
|
||||
|
||||
typedef BOOL (__stdcall *SYMGETSYMFROMADDRPROC)(HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL);
|
||||
extern SYMGETSYMFROMADDRPROC _SymGetSymFromAddr;
|
||||
|
||||
typedef DWORD ( __stdcall *SYMLOADMODULE)(HANDLE, HANDLE, PSTR, PSTR, DWORD, DWORD);
|
||||
extern SYMLOADMODULE _SymLoadModule;
|
||||
|
||||
typedef DWORD ( __stdcall *SYMUNDNAME)(PIMAGEHLP_SYMBOL, PSTR, DWORD);
|
||||
extern SYMUNDNAME _SymUnDName;
|
||||
|
||||
typedef DWORD ( __stdcall *SYMGETMODULEINFO)( HANDLE, DWORD, PIMAGEHLP_MODULE);
|
||||
extern SYMGETMODULEINFO _SymGetModuleInfo;
|
||||
|
||||
typedef BOOL ( __stdcall *ENUMLOADEDMODULES)( HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID);
|
||||
extern ENUMLOADEDMODULES _EnumerateLoadedModules;
|
||||
|
||||
typedef BOOL (__stdcall *SYMGETLINEFROMADDRPROC)(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE);
|
||||
extern SYMGETLINEFROMADDRPROC _SymGetLineFromAddr;
|
||||
|
||||
PRBool EnsureSymInitialized();
|
||||
|
||||
PRBool EnsureImageHlpInitialized();
|
||||
|
||||
/*
|
||||
* SymGetModuleInfoEspecial
|
||||
*
|
||||
* Attempt to determine the module information.
|
||||
* Bug 112196 says this DLL may not have been loaded at the time
|
||||
* SymInitialize was called, and thus the module information
|
||||
* and symbol information is not available.
|
||||
* This code rectifies that problem.
|
||||
* Line information is optional.
|
||||
*/
|
||||
BOOL SymGetModuleInfoEspecial(HANDLE aProcess, DWORD aAddr, PIMAGEHLP_MODULE aModuleInfo, PIMAGEHLP_LINE aLineInfo);
|
||||
|
||||
|
||||
void DumpStackToFile(FILE* out);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif //WIN32
|
||||
|
||||
#endif //nsStackFrameWin_h___
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Shaver <shaver@mozilla.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prsystem.h"
|
||||
#include "nsSystemInfo.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
nsSystemInfo::nsSystemInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsSystemInfo::~nsSystemInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSystemInfo, nsISystemInfo)
|
||||
|
||||
#define SYSINFO_GETTER(name, cmd) \
|
||||
NS_IMETHODIMP \
|
||||
nsSystemInfo::Get##name(char **_retval) \
|
||||
{ \
|
||||
NS_ENSURE_ARG_POINTER(_retval); \
|
||||
char *buf = (char *)nsMemory::Alloc(256); \
|
||||
if (!buf) \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
if (PR_GetSystemInfo((cmd), buf, 256) == PR_FAILURE) { \
|
||||
nsMemory::Free(buf); \
|
||||
return NS_ERROR_FAILURE; \
|
||||
} \
|
||||
*_retval = buf; \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
SYSINFO_GETTER(Hostname, PR_SI_HOSTNAME)
|
||||
SYSINFO_GETTER(OSName, PR_SI_SYSNAME)
|
||||
SYSINFO_GETTER(OSVersion, PR_SI_RELEASE)
|
||||
SYSINFO_GETTER(Architecture, PR_SI_ARCHITECTURE)
|
||||
|
||||
NS_METHOD
|
||||
nsSystemInfo::Create(nsISupports *outer, const nsIID &aIID, void **aInstancePtr)
|
||||
{
|
||||
nsresult rv;
|
||||
if (outer)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsSystemInfo *it = new nsSystemInfo();
|
||||
if (!it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = it->QueryInterface(aIID, aInstancePtr);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete it;
|
||||
*aInstancePtr = 0;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Shaver <shaver@mozilla.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISystemInfo.h"
|
||||
|
||||
#define NS_SYSTEMINFO_CID_STR "3c443856-1dd2-11b2-bfa1-83125c3f3887"
|
||||
|
||||
#define NS_SYSTEMINFO_CID \
|
||||
{0x3c443856, 0x1dd2, 0x11b2, \
|
||||
{ 0xbf, 0xa1, 0x83, 0x12, 0x5c, 0x3f, 0x38, 0x87 }}
|
||||
|
||||
#define NS_SYSTEMINFO_CLASSNAME "System Info Service"
|
||||
#define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/sysinfo;1"
|
||||
|
||||
class nsSystemInfo : public nsISystemInfo
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
NS_DECL_NSISYSTEMINFO
|
||||
|
||||
nsSystemInfo();
|
||||
virtual ~nsSystemInfo();
|
||||
static NS_METHOD Create(nsISupports *outer, const nsIID& aIID,
|
||||
void **aInstancePtr);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,216 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsTraceMalloc.c/bloatblame.c code, released
|
||||
* April 19, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brendan Eich, 14-April-2000
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
#ifndef nsTraceMalloc_h___
|
||||
#define nsTraceMalloc_h___
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* Magic "number" at start of a trace-malloc log file. Inspired by the PNG
|
||||
* magic string, which inspired XPCOM's typelib (.xpt) file magic. See the
|
||||
* NS_TraceMallocStartup comment (below) for magic number differences in log
|
||||
* file structure.
|
||||
*/
|
||||
#define NS_TRACE_MALLOC_MAGIC "XPCOM\nTMLog08\r\n\032"
|
||||
#define NS_TRACE_MALLOC_MAGIC_SIZE 16
|
||||
|
||||
/**
|
||||
* Trace-malloc stats, traced via the 'Z' event at the end of a log file.
|
||||
*/
|
||||
typedef struct nsTMStats {
|
||||
uint32 calltree_maxstack;
|
||||
uint32 calltree_maxdepth;
|
||||
uint32 calltree_parents;
|
||||
uint32 calltree_maxkids;
|
||||
uint32 calltree_kidhits;
|
||||
uint32 calltree_kidmisses;
|
||||
uint32 calltree_kidsteps;
|
||||
uint32 callsite_recurrences;
|
||||
uint32 backtrace_calls;
|
||||
uint32 backtrace_failures;
|
||||
uint32 btmalloc_failures;
|
||||
uint32 dladdr_failures;
|
||||
uint32 malloc_calls;
|
||||
uint32 malloc_failures;
|
||||
uint32 calloc_calls;
|
||||
uint32 calloc_failures;
|
||||
uint32 realloc_calls;
|
||||
uint32 realloc_failures;
|
||||
uint32 free_calls;
|
||||
uint32 null_free_calls;
|
||||
} nsTMStats;
|
||||
|
||||
#define NS_TMSTATS_STATIC_INITIALIZER {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
||||
|
||||
/**
|
||||
* Call NS_TraceMallocStartup with a valid file descriptor to enable logging
|
||||
* of compressed malloc traces, including callsite chains. Integers may be
|
||||
* unsigned serial numbers, sizes, or offsets, and require at most 32 bits.
|
||||
* They're encoded as follows:
|
||||
* 0-127 0xxxxxxx (binary, one byte)
|
||||
* 128-16383 10xxxxxx xxxxxxxx
|
||||
* 16384-0x1fffff 110xxxxx xxxxxxxx xxxxxxxx
|
||||
* 0x200000-0xfffffff 1110xxxx xxxxxxxx xxxxxxxx xxxxxxxx
|
||||
* 0x10000000-0xffffffff 11110000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
|
||||
* Strings are NUL-terminated ASCII.
|
||||
*
|
||||
* Event Operands (magic TMLog01)
|
||||
* 'L' library serial, shared object filename string
|
||||
* 'N' method serial, library serial, demangled name string
|
||||
* 'S' site serial, parent serial, method serial, calling pc offset
|
||||
* 'M' site serial, malloc size
|
||||
* 'C' site serial, calloc size
|
||||
* 'R' site serial, realloc oldsize, realloc size
|
||||
* 'F' site serial, free size
|
||||
*
|
||||
* Event Operands (magic TMLog02)
|
||||
* 'Z' serialized struct tmstats (20 unsigned integers),
|
||||
* maxkids parent callsite serial,
|
||||
* maxstack top callsite serial
|
||||
*
|
||||
* Event Operands (magic TMLog03)
|
||||
* 'T' seconds, microseconds, caption
|
||||
*
|
||||
* Event Operands (magic TMLog04)
|
||||
* 'R' site serial, realloc size, old site serial, realloc oldsize
|
||||
*
|
||||
* Event Operands (magic TMLog05)
|
||||
* 'M' site serial, address, malloc size
|
||||
* 'C' site serial, address, calloc size
|
||||
* 'R' site serial, address, realloc size, old site serial,
|
||||
* old address, old size
|
||||
* 'F' site serial, address, free size
|
||||
*
|
||||
* Event Operands (magic TMLog06)
|
||||
* 'M' site serial, interval, address, malloc size
|
||||
* 'C' site serial, interval, address, calloc size
|
||||
* 'R' site serial, interval, address, realloc size, old site serial,
|
||||
* old address, old size
|
||||
* 'F' site serial, interval, address, free size
|
||||
*
|
||||
* Event Operands (magic TMLog07)
|
||||
* no one documented their changes.
|
||||
* best of luck....
|
||||
*
|
||||
* Event Operands (magic TMLog08)
|
||||
* 'G' filename serial, source filename string.
|
||||
* 'N' method serial, library serial, source filename serial,
|
||||
* source file linenumber, demangled name string
|
||||
*
|
||||
* See tools/trace-malloc/bloatblame.c for an example log-file reader.
|
||||
*/
|
||||
#define TM_EVENT_LIBRARY 'L'
|
||||
#define TM_EVENT_FILENAME 'G'
|
||||
#define TM_EVENT_METHOD 'N'
|
||||
#define TM_EVENT_CALLSITE 'S'
|
||||
#define TM_EVENT_MALLOC 'M'
|
||||
#define TM_EVENT_CALLOC 'C'
|
||||
#define TM_EVENT_REALLOC 'R'
|
||||
#define TM_EVENT_FREE 'F'
|
||||
#define TM_EVENT_STATS 'Z'
|
||||
#define TM_EVENT_TIMESTAMP 'T'
|
||||
|
||||
PR_EXTERN(void) NS_TraceMallocStartup(int logfd);
|
||||
|
||||
/**
|
||||
* Initialize malloc tracing, using the ``standard'' startup arguments.
|
||||
*/
|
||||
PR_EXTERN(int) NS_TraceMallocStartupArgs(int argc, char* argv[]);
|
||||
|
||||
/**
|
||||
* Stop all malloc tracing, flushing any buffered events to the logfile.
|
||||
*/
|
||||
PR_EXTERN(void) NS_TraceMallocShutdown(void);
|
||||
|
||||
/**
|
||||
* Disable malloc tracing.
|
||||
*/
|
||||
PR_EXTERN(void) NS_TraceMallocDisable(void);
|
||||
|
||||
/**
|
||||
* Enable malloc tracing.
|
||||
*/
|
||||
PR_EXTERN(void) NS_TraceMallocEnable(void);
|
||||
|
||||
/**
|
||||
* Change the log file descriptor, flushing any buffered output to the old
|
||||
* fd, and writing NS_TRACE_MALLOC_MAGIC to the new file if it is zero length.
|
||||
* Return the old fd, so the caller can swap open fds. Return -2 on failure,
|
||||
* which means malloc failure.
|
||||
*/
|
||||
PR_EXTERN(int) NS_TraceMallocChangeLogFD(int fd);
|
||||
|
||||
/**
|
||||
* Close the file descriptor fd and forget any bookkeeping associated with it.
|
||||
* Do nothing if fd is -1.
|
||||
*/
|
||||
PR_EXTERN(void) NS_TraceMallocCloseLogFD(int fd);
|
||||
|
||||
/**
|
||||
* Emit a timestamp event with the given caption to the current log file.
|
||||
*/
|
||||
PR_EXTERN(void) NS_TraceMallocLogTimestamp(const char *caption);
|
||||
|
||||
/**
|
||||
* Walk the stack, dumping frames in standard form to ofp. If skip is 0,
|
||||
* exclude the frames for NS_TraceStack and anything it calls to do the walk.
|
||||
* If skip is less than 0, include -skip such frames. If skip is positive,
|
||||
* exclude that many frames leading to the call to NS_TraceStack.
|
||||
*/
|
||||
PR_EXTERN(void)
|
||||
NS_TraceStack(int skip, FILE *ofp);
|
||||
|
||||
/**
|
||||
* Dump a human-readable listing of current allocations and their compressed
|
||||
* stack backtraces to the file named by pathname. Beware this file may have
|
||||
* very long lines.
|
||||
*
|
||||
* Return -1 on error with errno set by the system, 0 on success.
|
||||
*/
|
||||
PR_EXTERN(int)
|
||||
NS_TraceMallocDumpAllocations(const char *pathname);
|
||||
|
||||
/**
|
||||
* Flush all logfile buffers.
|
||||
*/
|
||||
PR_EXTERN(void)
|
||||
NS_TraceMallocFlushLogfiles(void);
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* nsTraceMalloc_h___ */
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef NSTRACEMALLOCCALLBACKS_H
|
||||
#define NSTRACEMALLOCCALLBACKS_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
|
||||
PR_EXTERN(void) StartupHooker();/*implemented in TraceMalloc.cpp*/
|
||||
PR_EXTERN(void) ShutdownHooker();
|
||||
|
||||
PR_EXTERN(void) MallocCallback(void *aPtr, size_t aSize, PRUint32 start, PRUint32 end);/*implemented in nsTraceMalloc.c*/
|
||||
PR_EXTERN(void) CallocCallback(void *aPtr, size_t aCount, size_t aSize, PRUint32 start, PRUint32 end);
|
||||
PR_EXTERN(void) ReallocCallback(void *aPin, void* aPout, size_t aSize, PRUint32 start, PRUint32 end);
|
||||
PR_EXTERN(void) FreeCallback(void *aPtr, PRUint32 start, PRUint32 end);
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
|
||||
#endif //NSTRACEMALLOCCALLBACKS_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,269 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsTraceRefcnt_h___
|
||||
#define nsTraceRefcnt_h___
|
||||
|
||||
#include "nsCom.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class nsISupports;
|
||||
|
||||
// Normaly, the implementation of NS_LOG_ADDREF and NS_LOG_RELEASE
|
||||
// will use a stack crawl to determine who called Addref/Release on an
|
||||
// xpcom object. If your platform can't implement a stack crawling
|
||||
// function, then define this to symbol. When the symbol is defined
|
||||
// then the NS_LOG_ADDREF_CALL and NS_LOG_RELEASE_CALL will expand
|
||||
// differently.
|
||||
#undef NS_LOSING_ARCHITECTURE
|
||||
|
||||
// By default refcnt logging is not part of the build.
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
|
||||
#if (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
||||
// Make refcnt logging part of the build. This doesn't mean that
|
||||
// actual logging will occur (that requires a seperate enable; see
|
||||
// nsTraceRefcnt.h for more information).
|
||||
#define NS_BUILD_REFCNT_LOGGING 1
|
||||
#endif
|
||||
|
||||
// If NO_BUILD_REFCNT_LOGGING is defined then disable refcnt logging
|
||||
// in the build. This overrides FORCE_BUILD_REFCNT_LOGGING.
|
||||
#if defined(NO_BUILD_REFCNT_LOGGING)
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
#endif
|
||||
|
||||
// Disable refcnt logging if we are in xpcom glue
|
||||
// Bug #151072
|
||||
#if defined(XPCOM_GLUE)
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
#endif
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
|
||||
#define NS_LOG_ADDREF(_p, _rc, _type, _size) \
|
||||
nsTraceRefcnt::LogAddRef((_p), (_rc), (_type), (PRUint32) (_size))
|
||||
|
||||
#define NS_LOG_RELEASE(_p, _rc, _type) \
|
||||
nsTraceRefcnt::LogRelease((_p), (_rc), (_type))
|
||||
|
||||
#ifdef NS_LOSING_ARCHITECTURE
|
||||
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) \
|
||||
nsTraceRefcnt::LogAddRefCall((_p), (_rc), (_file), (_line))
|
||||
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) \
|
||||
nsTraceRefcnt::LogReleaseCall((_p), (_rc), (_file), (_line))
|
||||
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line) \
|
||||
nsTraceRefcnt::LogNewXPCOM((_p),(_type),(PRUint32)(_size),(_file),(_line))
|
||||
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line) \
|
||||
nsTraceRefcnt::LogDeleteXPCOM((_p),(_file),(_line))
|
||||
|
||||
#else
|
||||
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) _rc
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) _rc
|
||||
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line)
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line)
|
||||
|
||||
#endif
|
||||
|
||||
#define MOZ_DECL_CTOR_COUNTER(_type)
|
||||
|
||||
#define MOZ_COUNT_CTOR(_type) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsTraceRefcnt::LogCtor((void*)this, #_type, sizeof(*this)); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define MOZ_COUNT_DTOR(_type) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsTraceRefcnt::LogDtor((void*)this, #_type, sizeof(*this)); \
|
||||
PR_END_MACRO
|
||||
|
||||
#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR // from autoconf (XXX needs to be
|
||||
// set for non-autoconf platforms)
|
||||
|
||||
// nsCOMPtr.h allows these macros to be defined by clients
|
||||
// These logging functions require dynamic_cast<void *>, so we don't
|
||||
// define these macros if we don't have dynamic_cast.
|
||||
#define NSCAP_LOG_ASSIGNMENT(_c, _p) \
|
||||
if ((_p)) nsTraceRefcnt::LogAddCOMPtr((_c),NS_STATIC_CAST(nsISupports*,_p))
|
||||
|
||||
#define NSCAP_RELEASE(_c, _p); \
|
||||
if ((_p)) { \
|
||||
nsTraceRefcnt::LogReleaseCOMPtr((_c),NS_STATIC_CAST(nsISupports*,_p)); \
|
||||
NS_RELEASE(_p); \
|
||||
}
|
||||
|
||||
#endif /* HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR */
|
||||
|
||||
#else /* !NS_BUILD_REFCNT_LOGGING */
|
||||
|
||||
#define NS_LOG_ADDREF(_p, _rc, _type, _size)
|
||||
#define NS_LOG_RELEASE(_p, _rc, _type)
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line)
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line)
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) _rc
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) _rc
|
||||
#define MOZ_DECL_CTOR_COUNTER(_type)
|
||||
#define MOZ_COUNT_CTOR(_type)
|
||||
#define MOZ_COUNT_DTOR(_type)
|
||||
|
||||
#endif /* NS_BUILD_REFCNT_LOGGING */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
struct nsTraceRefcntStats {
|
||||
nsrefcnt mAddRefs;
|
||||
nsrefcnt mReleases;
|
||||
nsrefcnt mCreates;
|
||||
nsrefcnt mDestroys;
|
||||
double mRefsOutstandingTotal;
|
||||
double mRefsOutstandingSquared;
|
||||
double mObjsOutstandingTotal;
|
||||
double mObjsOutstandingSquared;
|
||||
};
|
||||
|
||||
// Function type used by GatherStatistics. For each type that data has
|
||||
// been gathered for, this function is called with the counts of the
|
||||
// various operations that have been logged. The function can return
|
||||
// PR_FALSE if the gathering should stop.
|
||||
//
|
||||
// aCurrentStats is the current value of the counters. aPrevStats is
|
||||
// the previous value of the counters which is established by the
|
||||
// nsTraceRefcnt::SnapshotStatistics call.
|
||||
typedef PRBool (PR_CALLBACK *nsTraceRefcntStatFunc)
|
||||
(const char* aTypeName,
|
||||
PRUint32 aInstanceSize,
|
||||
nsTraceRefcntStats* aCurrentStats,
|
||||
nsTraceRefcntStats* aPrevStats,
|
||||
void *aClosure);
|
||||
|
||||
/**
|
||||
* Note: The implementations for these methods are no-ops in a build
|
||||
* where NS_BUILD_REFCNT_LOGGING is disabled.
|
||||
*/
|
||||
class nsTraceRefcnt {
|
||||
public:
|
||||
static NS_COM void Startup();
|
||||
|
||||
static NS_COM void Shutdown();
|
||||
|
||||
static NS_COM void LogAddRef(void* aPtr,
|
||||
nsrefcnt aNewRefCnt,
|
||||
const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogRelease(void* aPtr,
|
||||
nsrefcnt aNewRefCnt,
|
||||
const char* aTypeName);
|
||||
|
||||
static NS_COM void LogNewXPCOM(void* aPtr,
|
||||
const char* aTypeName,
|
||||
PRUint32 aInstanceSize,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM void LogDeleteXPCOM(void* aPtr,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM nsrefcnt LogAddRefCall(void* aPtr,
|
||||
nsrefcnt aNewRefcnt,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM nsrefcnt LogReleaseCall(void* aPtr,
|
||||
nsrefcnt aNewRefcnt,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM void LogCtor(void* aPtr, const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogDtor(void* aPtr, const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogAddCOMPtr(void *aCOMPtr, nsISupports *aObject);
|
||||
|
||||
static NS_COM void LogReleaseCOMPtr(void *aCOMPtr, nsISupports *aObject);
|
||||
|
||||
enum StatisticsType {
|
||||
ALL_STATS,
|
||||
NEW_STATS
|
||||
};
|
||||
|
||||
static NS_COM nsresult DumpStatistics(StatisticsType type = ALL_STATS,
|
||||
FILE* out = 0);
|
||||
|
||||
static NS_COM void ResetStatistics(void);
|
||||
|
||||
static NS_COM void GatherStatistics(nsTraceRefcntStatFunc aFunc,
|
||||
void* aClosure);
|
||||
|
||||
static NS_COM void LoadLibrarySymbols(const char* aLibraryName,
|
||||
void* aLibrayHandle);
|
||||
|
||||
static NS_COM void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
int aBufLen);
|
||||
|
||||
static NS_COM void WalkTheStack(FILE* aStream);
|
||||
|
||||
static NS_COM void SetPrefServiceAvailability(PRBool avail);
|
||||
|
||||
/**
|
||||
* Tell nsTraceRefcnt whether refcounting, allocation, and destruction
|
||||
* activity is legal. This is used to trigger assertions for any such
|
||||
* activity that occurs because of static constructors or destructors.
|
||||
*/
|
||||
static NS_COM void SetActivityIsLegal(PRBool aLegal);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// And now for that utility that you've all been asking for...
|
||||
|
||||
extern "C" NS_COM void
|
||||
NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
|
||||
double *meanResult, double *stdDevResult);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif /* nsTraceRefcnt_h___ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,269 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsTraceRefcnt_h___
|
||||
#define nsTraceRefcnt_h___
|
||||
|
||||
#include "nsCom.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class nsISupports;
|
||||
|
||||
// Normaly, the implementation of NS_LOG_ADDREF and NS_LOG_RELEASE
|
||||
// will use a stack crawl to determine who called Addref/Release on an
|
||||
// xpcom object. If your platform can't implement a stack crawling
|
||||
// function, then define this to symbol. When the symbol is defined
|
||||
// then the NS_LOG_ADDREF_CALL and NS_LOG_RELEASE_CALL will expand
|
||||
// differently.
|
||||
#undef NS_LOSING_ARCHITECTURE
|
||||
|
||||
// By default refcnt logging is not part of the build.
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
|
||||
#if (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
||||
// Make refcnt logging part of the build. This doesn't mean that
|
||||
// actual logging will occur (that requires a seperate enable; see
|
||||
// nsTraceRefcnt.h for more information).
|
||||
#define NS_BUILD_REFCNT_LOGGING 1
|
||||
#endif
|
||||
|
||||
// If NO_BUILD_REFCNT_LOGGING is defined then disable refcnt logging
|
||||
// in the build. This overrides FORCE_BUILD_REFCNT_LOGGING.
|
||||
#if defined(NO_BUILD_REFCNT_LOGGING)
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
#endif
|
||||
|
||||
// Disable refcnt logging if we are in xpcom glue
|
||||
// Bug #151072
|
||||
#if defined(XPCOM_GLUE)
|
||||
#undef NS_BUILD_REFCNT_LOGGING
|
||||
#endif
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
|
||||
#define NS_LOG_ADDREF(_p, _rc, _type, _size) \
|
||||
nsTraceRefcnt::LogAddRef((_p), (_rc), (_type), (PRUint32) (_size))
|
||||
|
||||
#define NS_LOG_RELEASE(_p, _rc, _type) \
|
||||
nsTraceRefcnt::LogRelease((_p), (_rc), (_type))
|
||||
|
||||
#ifdef NS_LOSING_ARCHITECTURE
|
||||
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) \
|
||||
nsTraceRefcnt::LogAddRefCall((_p), (_rc), (_file), (_line))
|
||||
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) \
|
||||
nsTraceRefcnt::LogReleaseCall((_p), (_rc), (_file), (_line))
|
||||
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line) \
|
||||
nsTraceRefcnt::LogNewXPCOM((_p),(_type),(PRUint32)(_size),(_file),(_line))
|
||||
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line) \
|
||||
nsTraceRefcnt::LogDeleteXPCOM((_p),(_file),(_line))
|
||||
|
||||
#else
|
||||
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) _rc
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) _rc
|
||||
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line)
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line)
|
||||
|
||||
#endif
|
||||
|
||||
#define MOZ_DECL_CTOR_COUNTER(_type)
|
||||
|
||||
#define MOZ_COUNT_CTOR(_type) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsTraceRefcnt::LogCtor((void*)this, #_type, sizeof(*this)); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define MOZ_COUNT_DTOR(_type) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsTraceRefcnt::LogDtor((void*)this, #_type, sizeof(*this)); \
|
||||
PR_END_MACRO
|
||||
|
||||
#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR // from autoconf (XXX needs to be
|
||||
// set for non-autoconf platforms)
|
||||
|
||||
// nsCOMPtr.h allows these macros to be defined by clients
|
||||
// These logging functions require dynamic_cast<void *>, so we don't
|
||||
// define these macros if we don't have dynamic_cast.
|
||||
#define NSCAP_LOG_ASSIGNMENT(_c, _p) \
|
||||
if ((_p)) nsTraceRefcnt::LogAddCOMPtr((_c),NS_STATIC_CAST(nsISupports*,_p))
|
||||
|
||||
#define NSCAP_RELEASE(_c, _p); \
|
||||
if ((_p)) { \
|
||||
nsTraceRefcnt::LogReleaseCOMPtr((_c),NS_STATIC_CAST(nsISupports*,_p)); \
|
||||
NS_RELEASE(_p); \
|
||||
}
|
||||
|
||||
#endif /* HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR */
|
||||
|
||||
#else /* !NS_BUILD_REFCNT_LOGGING */
|
||||
|
||||
#define NS_LOG_ADDREF(_p, _rc, _type, _size)
|
||||
#define NS_LOG_RELEASE(_p, _rc, _type)
|
||||
#define NS_LOG_NEW_XPCOM(_p,_type,_size,_file,_line)
|
||||
#define NS_LOG_DELETE_XPCOM(_p,_file,_line)
|
||||
#define NS_LOG_ADDREF_CALL(_p,_rc,_file,_line) _rc
|
||||
#define NS_LOG_RELEASE_CALL(_p,_rc,_file,_line) _rc
|
||||
#define MOZ_DECL_CTOR_COUNTER(_type)
|
||||
#define MOZ_COUNT_CTOR(_type)
|
||||
#define MOZ_COUNT_DTOR(_type)
|
||||
|
||||
#endif /* NS_BUILD_REFCNT_LOGGING */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
struct nsTraceRefcntStats {
|
||||
nsrefcnt mAddRefs;
|
||||
nsrefcnt mReleases;
|
||||
nsrefcnt mCreates;
|
||||
nsrefcnt mDestroys;
|
||||
double mRefsOutstandingTotal;
|
||||
double mRefsOutstandingSquared;
|
||||
double mObjsOutstandingTotal;
|
||||
double mObjsOutstandingSquared;
|
||||
};
|
||||
|
||||
// Function type used by GatherStatistics. For each type that data has
|
||||
// been gathered for, this function is called with the counts of the
|
||||
// various operations that have been logged. The function can return
|
||||
// PR_FALSE if the gathering should stop.
|
||||
//
|
||||
// aCurrentStats is the current value of the counters. aPrevStats is
|
||||
// the previous value of the counters which is established by the
|
||||
// nsTraceRefcnt::SnapshotStatistics call.
|
||||
typedef PRBool (PR_CALLBACK *nsTraceRefcntStatFunc)
|
||||
(const char* aTypeName,
|
||||
PRUint32 aInstanceSize,
|
||||
nsTraceRefcntStats* aCurrentStats,
|
||||
nsTraceRefcntStats* aPrevStats,
|
||||
void *aClosure);
|
||||
|
||||
/**
|
||||
* Note: The implementations for these methods are no-ops in a build
|
||||
* where NS_BUILD_REFCNT_LOGGING is disabled.
|
||||
*/
|
||||
class nsTraceRefcnt {
|
||||
public:
|
||||
static NS_COM void Startup();
|
||||
|
||||
static NS_COM void Shutdown();
|
||||
|
||||
static NS_COM void LogAddRef(void* aPtr,
|
||||
nsrefcnt aNewRefCnt,
|
||||
const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogRelease(void* aPtr,
|
||||
nsrefcnt aNewRefCnt,
|
||||
const char* aTypeName);
|
||||
|
||||
static NS_COM void LogNewXPCOM(void* aPtr,
|
||||
const char* aTypeName,
|
||||
PRUint32 aInstanceSize,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM void LogDeleteXPCOM(void* aPtr,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM nsrefcnt LogAddRefCall(void* aPtr,
|
||||
nsrefcnt aNewRefcnt,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM nsrefcnt LogReleaseCall(void* aPtr,
|
||||
nsrefcnt aNewRefcnt,
|
||||
const char* aFile,
|
||||
int aLine);
|
||||
|
||||
static NS_COM void LogCtor(void* aPtr, const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogDtor(void* aPtr, const char* aTypeName,
|
||||
PRUint32 aInstanceSize);
|
||||
|
||||
static NS_COM void LogAddCOMPtr(void *aCOMPtr, nsISupports *aObject);
|
||||
|
||||
static NS_COM void LogReleaseCOMPtr(void *aCOMPtr, nsISupports *aObject);
|
||||
|
||||
enum StatisticsType {
|
||||
ALL_STATS,
|
||||
NEW_STATS
|
||||
};
|
||||
|
||||
static NS_COM nsresult DumpStatistics(StatisticsType type = ALL_STATS,
|
||||
FILE* out = 0);
|
||||
|
||||
static NS_COM void ResetStatistics(void);
|
||||
|
||||
static NS_COM void GatherStatistics(nsTraceRefcntStatFunc aFunc,
|
||||
void* aClosure);
|
||||
|
||||
static NS_COM void LoadLibrarySymbols(const char* aLibraryName,
|
||||
void* aLibrayHandle);
|
||||
|
||||
static NS_COM void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
int aBufLen);
|
||||
|
||||
static NS_COM void WalkTheStack(FILE* aStream);
|
||||
|
||||
static NS_COM void SetPrefServiceAvailability(PRBool avail);
|
||||
|
||||
/**
|
||||
* Tell nsTraceRefcnt whether refcounting, allocation, and destruction
|
||||
* activity is legal. This is used to trigger assertions for any such
|
||||
* activity that occurs because of static constructors or destructors.
|
||||
*/
|
||||
static NS_COM void SetActivityIsLegal(PRBool aLegal);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// And now for that utility that you've all been asking for...
|
||||
|
||||
extern "C" NS_COM void
|
||||
NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
|
||||
double *meanResult, double *stdDevResult);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif /* nsTraceRefcnt_h___ */
|
||||
@@ -1,294 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 nsTypeInfo.cpp code, released
|
||||
* November 27, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the MPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
/*
|
||||
typeinfo.cpp
|
||||
|
||||
Speculatively use RTTI on a random object. If it contains a pointer at offset 0
|
||||
that is in the current process' address space, and that so on, then attempt to
|
||||
use C++ RTTI's typeid operation to obtain the name of the type.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <typeinfo>
|
||||
#include <ctype.h>
|
||||
|
||||
extern "C" const char* nsGetTypeName(void* ptr);
|
||||
|
||||
class IUnknown {
|
||||
public:
|
||||
virtual long QueryInterface() = 0;
|
||||
virtual long AddRef() = 0;
|
||||
virtual long Release() = 0;
|
||||
};
|
||||
|
||||
#if defined(MACOS)
|
||||
|
||||
#include <Processes.h>
|
||||
|
||||
class AddressSpace {
|
||||
public:
|
||||
AddressSpace();
|
||||
Boolean contains(void* ptr);
|
||||
private:
|
||||
ProcessInfoRec mInfo;
|
||||
};
|
||||
|
||||
AddressSpace::AddressSpace()
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
mInfo.processInfoLength = sizeof(mInfo);
|
||||
::GetProcessInformation(&psn, &mInfo);
|
||||
}
|
||||
|
||||
Boolean AddressSpace::contains(void* ptr)
|
||||
{
|
||||
UInt32 start = UInt32(mInfo.processLocation);
|
||||
return (UInt32(ptr) >= start && UInt32(ptr) < (start + mInfo.processSize));
|
||||
}
|
||||
|
||||
const char* nsGetTypeName(void* ptr)
|
||||
{
|
||||
// construct only one of these per process.
|
||||
static AddressSpace space;
|
||||
|
||||
// sanity check the vtable pointer, before trying to use RTTI on the object.
|
||||
void** vt = *(void***)ptr;
|
||||
if (vt && !(unsigned(vt) & 0x3) && space.contains(vt) && space.contains(*vt)) {
|
||||
IUnknown* u = static_cast<IUnknown*>(ptr);
|
||||
const char* type = typeid(*u).name();
|
||||
// make sure it looks like a C++ identifier.
|
||||
if (type && (isalnum(type[0]) || type[0] == '_'))
|
||||
return type;
|
||||
}
|
||||
return "void*";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// New, more "portable" Linux code is below, but this might be a useful
|
||||
// model for other platforms, so keeping.
|
||||
//#if defined(linux)
|
||||
#if 0
|
||||
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
static jmp_buf context;
|
||||
|
||||
static void handler(int signum)
|
||||
{
|
||||
longjmp(context, signum);
|
||||
}
|
||||
|
||||
#define attempt() setjmp(context)
|
||||
|
||||
class Signaller {
|
||||
public:
|
||||
Signaller(int signum);
|
||||
~Signaller();
|
||||
|
||||
private:
|
||||
typedef void (*handler_t) (int signum);
|
||||
int mSignal;
|
||||
handler_t mOldHandler;
|
||||
};
|
||||
|
||||
Signaller::Signaller(int signum)
|
||||
: mSignal(signum), mOldHandler(signal(signum, &handler))
|
||||
{
|
||||
}
|
||||
|
||||
Signaller::~Signaller()
|
||||
{
|
||||
signal(mSignal, mOldHandler);
|
||||
}
|
||||
|
||||
// The following are pointers that bamboozle our otherwise feeble
|
||||
// attempts to "safely" collect type names.
|
||||
//
|
||||
// XXX this kind of sucks because it means that anyone trying to use
|
||||
// this without NSPR will get unresolved symbols when this library
|
||||
// loads. It's also not very extensible. Oh well: FIX ME!
|
||||
extern "C" {
|
||||
// from nsprpub/pr/src/io/priometh.c (libnspr4.so)
|
||||
extern void* _pr_faulty_methods;
|
||||
};
|
||||
|
||||
static inline int
|
||||
sanity_check_vtable_i386(void** vt)
|
||||
{
|
||||
// Now that we're "safe" inside the signal handler, we can
|
||||
// start poking around. If we're really an object with
|
||||
// RTTI, then the second entry in the vtable should point
|
||||
// to a function.
|
||||
//
|
||||
// Let's see if the second entry:
|
||||
//
|
||||
// 1) looks like a 4-byte aligned pointer
|
||||
//
|
||||
// 2) points to something that looks like the following
|
||||
// i386 instructions:
|
||||
//
|
||||
// 55 push %ebp
|
||||
// 89e5 mov %esp,%ebp
|
||||
// 53 push %ebx
|
||||
//
|
||||
// or
|
||||
//
|
||||
// 55 push %ebp
|
||||
// 89e5 mov %esp,%ebp
|
||||
// 56 push %esi
|
||||
//
|
||||
// (which is the standard function prologue generated
|
||||
// by egcs, plus a ``signature'' instruction that appears
|
||||
// in the typeid() function's implementation).
|
||||
unsigned char** fp1 = reinterpret_cast<unsigned char**>(vt) + 1;
|
||||
|
||||
// Does it look like an address?
|
||||
unsigned char* ip = *fp1;
|
||||
if ((unsigned(ip) & 3) != 0)
|
||||
return 0;
|
||||
|
||||
// Does it look like it refers to the standard prologue?
|
||||
static unsigned char prologue[] = { 0x55, 0x89, 0xE5 };
|
||||
for (unsigned i = 0; i < sizeof(prologue); ++i)
|
||||
if (*ip++ != prologue[i])
|
||||
return 0;
|
||||
|
||||
// Is the next instruction a `push %ebx' or `push %esi'?
|
||||
if (*ip == 0x53 || *ip == 0x56) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Nope. There's another variant that has a `sub' instruction,
|
||||
// followed by a `cmpl' and a `jne'. Check for that.
|
||||
if (ip[0] == 0x83 && ip[1] == 0xec // sub
|
||||
&& ip[3] == 0x83 && ip[4] == 0x3d // cmpl
|
||||
&& ip[10] == 0x75 // jne
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
sanity_check_vtable_ppc(void** vt)
|
||||
{
|
||||
// XXX write me!
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(__i386)
|
||||
# define SANITY_CHECK_VTABLE(vt) (sanity_check_vtable_i386(vt))
|
||||
#elif defined(PPC)
|
||||
# define SANITY_CHECK_VTABLE(vt) (sanity_check_vtable_ppc(vt))
|
||||
#else
|
||||
# define SANITY_CHECK_VTABLE(vt) (1)
|
||||
#endif
|
||||
|
||||
const char* nsGetTypeName(void* ptr)
|
||||
{
|
||||
// sanity check the vtable pointer, before trying to use RTTI on the object.
|
||||
void** vt = *(void***)ptr;
|
||||
if (vt && !(unsigned(vt) & 3) && (vt != &_pr_faulty_methods)) {
|
||||
Signaller s1(SIGSEGV);
|
||||
if (attempt() == 0) {
|
||||
if (SANITY_CHECK_VTABLE(vt)) {
|
||||
// Looks like a function: what the hell, let's call it.
|
||||
IUnknown* u = static_cast<IUnknown*>(ptr);
|
||||
const char* type = typeid(*u).name();
|
||||
// EGCS seems to prefix a length string.
|
||||
while (isdigit(*type)) ++type;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "void*";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(linux)
|
||||
|
||||
#if !defined(__USE_GNU)
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* nsGetTypeName(void* ptr)
|
||||
{
|
||||
#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
|
||||
const int expected_offset = 8;
|
||||
const char vtable_sym_start[] = "_ZTV";
|
||||
const int vtable_sym_start_length = sizeof(vtable_sym_start) - 1;
|
||||
#else
|
||||
const int expected_offset = 0;
|
||||
const char vtable_sym_start[] = "__vt_";
|
||||
const int vtable_sym_start_length = sizeof(vtable_sym_start) - 1;
|
||||
#endif
|
||||
void* vt = *(void**)ptr;
|
||||
Dl_info info;
|
||||
// If dladdr fails, if we're not at the expected offset in the vtable,
|
||||
// or if the symbol name isn't a vtable symbol name, return "void*".
|
||||
if ( !dladdr(vt, &info) ||
|
||||
((char*)info.dli_saddr) + expected_offset != vt ||
|
||||
!info.dli_sname ||
|
||||
strncmp(info.dli_sname, vtable_sym_start, vtable_sym_start_length))
|
||||
return "void*";
|
||||
|
||||
// skip the garbage at the beginning of things like
|
||||
// __vt_14nsRootBoxFrame (gcc 2.96) or _ZTV14nsRootBoxFrame (gcc 3.0)
|
||||
const char* rv = info.dli_sname + vtable_sym_start_length;
|
||||
while (*rv && isdigit(*rv))
|
||||
++rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN32
|
||||
const char* nsGetTypeName(void* ptr)
|
||||
{
|
||||
//TODO: COMPLETE THIS
|
||||
return "void*";
|
||||
}
|
||||
|
||||
#endif //XP_WIN32
|
||||
@@ -1,31 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott Collins <scc@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsWeakPtr_h__
|
||||
#define nsWeakPtr_h__
|
||||
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// typedef nsCOMPtr<nsIWeakReference> nsWeakPtr;
|
||||
|
||||
#endif
|
||||
@@ -1,438 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prlock.h"
|
||||
#include "nscore.h"
|
||||
#include "nsAutoLock.h"
|
||||
|
||||
#include "nsDebugHelpWin32.h"
|
||||
#include "nsTraceMallocCallbacks.h"
|
||||
|
||||
// XXX These are *very* quick hacks and need improvement!
|
||||
|
||||
static PRBool GetSymbolFromAddress(uint32 addr, char* outBuf)
|
||||
{
|
||||
PRBool ok;
|
||||
ok = dhwEnsureSymInitialized();
|
||||
if(!ok)
|
||||
return ok;
|
||||
|
||||
char buf[sizeof(IMAGEHLP_SYMBOL) + 512];
|
||||
PIMAGEHLP_SYMBOL symbol = (PIMAGEHLP_SYMBOL) buf;
|
||||
symbol->SizeOfStruct = sizeof(buf);
|
||||
symbol->MaxNameLength = 512;
|
||||
|
||||
DWORD displacement;
|
||||
|
||||
ok = dhwSymGetSymFromAddr(::GetCurrentProcess(),
|
||||
addr,
|
||||
&displacement,
|
||||
symbol);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
char buf2[512];
|
||||
sprintf(buf2, "%s+0x%08X", symbol->Name, displacement);
|
||||
strcat(outBuf, buf2);
|
||||
}
|
||||
else
|
||||
strcat(outBuf, "dunno");
|
||||
return ok;
|
||||
}
|
||||
|
||||
static PRBool GetModuleFromAddress(uint32 addr, char* outBuf)
|
||||
{
|
||||
PRBool ok;
|
||||
ok = dhwEnsureSymInitialized();
|
||||
if(!ok)
|
||||
return ok;
|
||||
|
||||
|
||||
IMAGEHLP_MODULE module;
|
||||
module.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
|
||||
|
||||
ok = dhwSymGetModuleInfo(::GetCurrentProcess(),
|
||||
addr,
|
||||
&module);
|
||||
|
||||
if(ok)
|
||||
strcat(outBuf, module.ModuleName);
|
||||
else
|
||||
strcat(outBuf, "dunno");
|
||||
return ok;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef VERBOSE
|
||||
#define SHOW(x_, buf_) \
|
||||
printf(#x_" = %#x... %s\n", x_, \
|
||||
(buf_[0] = 0, \
|
||||
GetModuleFromAddress((uint32)x_, buf_), \
|
||||
strcat(buf," :: "), \
|
||||
GetSymbolFromAddress((uint32)x_, buf_), \
|
||||
buf_));
|
||||
#else
|
||||
#define SHOW(x_, buf_)
|
||||
#endif //VERBOSE
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef VERBOSE
|
||||
// XXX This is a quick hack to show that x86 Win32 stack walking can be done
|
||||
// with this sort of loop following the bp.
|
||||
|
||||
void dumpStack()
|
||||
{
|
||||
uint32* bp_;
|
||||
uint32* bpdown;
|
||||
uint32 pc;
|
||||
|
||||
char buf[512];
|
||||
|
||||
_asm { mov bp_ , ebp }
|
||||
|
||||
/* Stack walking code adapted from Kipp's "leaky". */
|
||||
while (1) {
|
||||
bpdown = (uint32*) *bp_++;
|
||||
pc = *bp_;
|
||||
// These addresses are iffy...
|
||||
if (pc < 0x00400000 || pc > 0x7fffffff || bpdown < bp_)
|
||||
break;
|
||||
SHOW(pc, buf);
|
||||
bp_ = bpdown;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
char* _stdcall call2(void* v)
|
||||
{
|
||||
// dumpStack();
|
||||
// return 0;
|
||||
|
||||
return (char *)malloc(123);
|
||||
}
|
||||
|
||||
int call1(char c, int i, double d, ... )
|
||||
{
|
||||
free(call2(0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// shows how to use the dhw stuff to hook imported functions
|
||||
|
||||
|
||||
static BOOL g_lockOut = FALSE; //stop reentrancy
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_malloc, void*, __cdecl, MALLOC_, (size_t));
|
||||
|
||||
DHWImportHooker &getMallocHooker()
|
||||
{
|
||||
static DHWImportHooker gMallocHooker("MSVCRTD.dll", "malloc", (PROC) dhw_malloc);
|
||||
return gMallocHooker;
|
||||
}
|
||||
|
||||
void * __cdecl dhw_malloc( size_t size )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(MALLOC_, getMallocHooker())(size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* malloc called to get %d bytes. returned %#x\n", size, result);
|
||||
#endif
|
||||
MallocCallback(result, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_calloc, void*, __cdecl, CALLOC_, (size_t,size_t));
|
||||
|
||||
DHWImportHooker &getCallocHooker()
|
||||
{
|
||||
static DHWImportHooker gCallocHooker("MSVCRTD.dll", "calloc", (PROC) dhw_calloc);
|
||||
return gCallocHooker;
|
||||
}
|
||||
|
||||
void * __cdecl dhw_calloc( size_t count, size_t size )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(CALLOC_, getCallocHooker())(count,size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* calloc called to get %d many of %d bytes. returned %#x\n", count, size, result);
|
||||
#endif
|
||||
CallocCallback(result, count, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_free, void, __cdecl, FREE_, (void*));
|
||||
DHWImportHooker &getFreeHooker()
|
||||
{
|
||||
static DHWImportHooker gFreeHooker("MSVCRTD.dll", "free", (PROC) dhw_free);
|
||||
return gFreeHooker;
|
||||
}
|
||||
|
||||
void __cdecl dhw_free( void* p )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
DHW_ORIGINAL(FREE_, getFreeHooker())(p);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* free called for %#x\n", p);
|
||||
#endif
|
||||
FreeCallback(p, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
}
|
||||
|
||||
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_realloc, void*, __cdecl, REALLOC_, (void*, size_t));
|
||||
DHWImportHooker &getReallocHooker()
|
||||
{
|
||||
static DHWImportHooker gReallocHooker("MSVCRTD.dll", "realloc", (PROC) dhw_realloc);
|
||||
return gReallocHooker;
|
||||
}
|
||||
|
||||
void * __cdecl dhw_realloc(void * pin, size_t size)
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* pout = DHW_ORIGINAL(REALLOC_, getReallocHooker())(pin, size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return pout;
|
||||
g_lockOut = TRUE;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("* realloc called to resize to %d. old ptr: %#x. new ptr: %#x\n",
|
||||
size, pin, pout);
|
||||
#endif
|
||||
ReallocCallback(pin, pout, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
return pout;
|
||||
}
|
||||
|
||||
// Note the mangled name!
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_new, void*, __cdecl, NEW_, (size_t));
|
||||
DHWImportHooker &getNewHooker()
|
||||
{
|
||||
static DHWImportHooker gNewHooker("MSVCRTD.dll", "??2@YAPAXI@Z", (PROC) dhw_new);
|
||||
return gNewHooker;
|
||||
}
|
||||
|
||||
void * __cdecl dhw_new(size_t size)
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(NEW_, getNewHooker())(size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("* new called to get %d bytes. returned %#x\n", size, result);
|
||||
dumpStack();
|
||||
#endif
|
||||
MallocCallback(result, size, start, end);//do we need a different one for new?
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Note the mangled name!
|
||||
DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_delete, void, __cdecl, DELETE_, (void*));
|
||||
DHWImportHooker &getDeleteHooker()
|
||||
{
|
||||
static DHWImportHooker gDeleteHooker("MSVCRTD.dll", "??3@YAXPAX@Z", (PROC) dhw_delete);
|
||||
return gDeleteHooker;
|
||||
}
|
||||
|
||||
void __cdecl dhw_delete(void* p)
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
DHW_ORIGINAL(DELETE_, getDeleteHooker())(p);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* delete called for %#x\n", p);
|
||||
dumpStack();
|
||||
#endif
|
||||
FreeCallback(p, start, end);
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
// A demonstration of using the _CrtSetAllocHook based hooking.
|
||||
// This system sucks because you don't get to see the allocated pointer.
|
||||
#if 0
|
||||
class myAllocationSizePrinter : public DHWAllocationSizeDebugHook
|
||||
{
|
||||
public:
|
||||
PRBool AllocHook(size_t size)
|
||||
{
|
||||
alloc_calls++ ;
|
||||
total_mem += size;
|
||||
if(verbosity)
|
||||
{
|
||||
printf("alloc called to get %d bytes.\n", size);
|
||||
dumpStack();
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool ReallocHook(size_t size, size_t sizeOld)
|
||||
{
|
||||
realloc_calls++ ;
|
||||
total_mem += size;
|
||||
total_mem -= sizeOld;
|
||||
if(verbosity)
|
||||
{
|
||||
printf("realloc called to size to %d bytes. Old size: %d.\n",
|
||||
size, sizeOld);
|
||||
dumpStack();
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool FreeHook(size_t size)
|
||||
{
|
||||
free_calls++ ;
|
||||
total_mem -= size;
|
||||
if(verbosity)
|
||||
{
|
||||
printf("free called to release %d bytes.\n", size);
|
||||
dumpStack();
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
myAllocationSizePrinter(int v)
|
||||
: verbosity(v),
|
||||
alloc_calls(0),
|
||||
realloc_calls(0),
|
||||
free_calls(0),
|
||||
total_mem(0) {}
|
||||
virtual ~myAllocationSizePrinter(){}
|
||||
|
||||
void report()
|
||||
{
|
||||
printf("%d allocs, %d reallocs, %d frees, %d bytes leaked\n",
|
||||
alloc_calls, realloc_calls, free_calls, total_mem);
|
||||
}
|
||||
|
||||
private:
|
||||
void dumpStack()
|
||||
{
|
||||
if(verbosity == 2)
|
||||
::dumpStack();
|
||||
}
|
||||
|
||||
int verbosity;
|
||||
int alloc_calls;
|
||||
int realloc_calls;
|
||||
int free_calls;
|
||||
size_t total_mem;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*C Callbacks*/
|
||||
PR_IMPLEMENT(void)
|
||||
StartupHooker()
|
||||
{
|
||||
if (!dhwEnsureSymInitialized())
|
||||
return;
|
||||
|
||||
//run through get all hookers
|
||||
DHWImportHooker &loadlibraryW = DHWImportHooker::getLoadLibraryWHooker();
|
||||
DHWImportHooker &loadlibraryExW = DHWImportHooker::getLoadLibraryExWHooker();
|
||||
DHWImportHooker &loadlibraryA = DHWImportHooker::getLoadLibraryAHooker();
|
||||
DHWImportHooker &loadlibraryExA = DHWImportHooker::getLoadLibraryExAHooker();
|
||||
DHWImportHooker &mallochooker = getMallocHooker();
|
||||
DHWImportHooker &reallochooker = getReallocHooker();
|
||||
DHWImportHooker &callochooker = getCallocHooker();
|
||||
DHWImportHooker &freehooker = getFreeHooker();
|
||||
DHWImportHooker &newhooker = getNewHooker();
|
||||
DHWImportHooker &deletehooker = getDeleteHooker();
|
||||
printf("Startup Hooker\n");
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
ShutdownHooker()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
int main()
|
||||
{
|
||||
// A demonstration of using the (sucky) _CrtSetAllocHook based hooking.
|
||||
myAllocationSizePrinter ap(0);
|
||||
dhwSetAllocationSizeDebugHook(&ap);
|
||||
|
||||
// show that the ImportHooker is hooking calls from loaded dll
|
||||
DHW_DECLARE_FUN_TYPE(void, __stdcall, SOMECALL_, (void));
|
||||
HMODULE module = ::LoadLibrary("Other.dll");
|
||||
if(module) {
|
||||
SOMECALL_ _SomeCall = (SOMECALL_) GetProcAddress(module, "SomeCall");
|
||||
if(_SomeCall)
|
||||
_SomeCall();
|
||||
}
|
||||
|
||||
// show that the ImportHooker is hooking sneaky calls made from this dll.
|
||||
HMODULE module2 = ::LoadLibrary("MSVCRTD.dll");
|
||||
if(module2) {
|
||||
MALLOC_ _sneakyMalloc = (MALLOC_) GetProcAddress(module2, "malloc");
|
||||
if(_sneakyMalloc)
|
||||
{
|
||||
void* p = _sneakyMalloc(987);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
call1('x', 1, 1.0, "hi there", 2);
|
||||
|
||||
char* p = new char[10];
|
||||
delete p;
|
||||
|
||||
void* v = malloc(10);
|
||||
v = realloc(v, 15);
|
||||
v = realloc(v, 5);
|
||||
free(v);`
|
||||
|
||||
ap.report();
|
||||
dhwClearAllocationSizeDebugHook();
|
||||
return 0;
|
||||
}
|
||||
#endif //0
|
||||
|
||||
@@ -1,306 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nscore_h___
|
||||
#define nscore_h___
|
||||
|
||||
/**
|
||||
* Incorporate the core NSPR data types which XPCOM uses.
|
||||
*/
|
||||
#include "prtypes.h"
|
||||
|
||||
/* Core XPCOM declarations. */
|
||||
|
||||
/**
|
||||
* Macros defining the target platform...
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define NS_WIN32 1
|
||||
|
||||
#elif defined(__unix)
|
||||
#define NS_UNIX 1
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
#define NS_OS2 1
|
||||
#endif
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* Import/export defines */
|
||||
|
||||
#ifdef NS_WIN32
|
||||
|
||||
#define NS_IMPORT _declspec(dllimport)
|
||||
#define NS_IMPORT_(type) type _declspec(dllimport) __stdcall
|
||||
#define NS_EXPORT _declspec(dllexport)
|
||||
#define NS_EXPORT_(type) type _declspec(dllexport) __stdcall
|
||||
#define NS_IMETHOD_(type) virtual type __stdcall
|
||||
#define NS_IMETHODIMP_(type) type __stdcall
|
||||
#define NS_METHOD_(type) type __stdcall
|
||||
#define NS_CALLBACK_(_type, _name) _type (__stdcall * _name)
|
||||
|
||||
#elif defined(XP_MAC)
|
||||
|
||||
#define NS_IMPORT
|
||||
#define NS_IMPORT_(type) type
|
||||
#define NS_EXPORT __declspec(export)
|
||||
#define NS_EXPORT_(type) __declspec(export) type
|
||||
#define NS_IMETHOD_(type) virtual type
|
||||
#define NS_IMETHODIMP_(type) type
|
||||
#define NS_METHOD_(type) type
|
||||
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
|
||||
#define NS_IMPORT
|
||||
#define NS_IMPORT_(type) type
|
||||
#define NS_EXPORT
|
||||
#define NS_EXPORT_(type) type
|
||||
#define NS_IMETHOD_(type) virtual type
|
||||
#define NS_IMETHODIMP_(type) type
|
||||
#define NS_METHOD_(type) type
|
||||
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
||||
|
||||
#else
|
||||
|
||||
#define NS_IMPORT
|
||||
#define NS_IMPORT_(type) type
|
||||
#define NS_EXPORT
|
||||
#define NS_EXPORT_(type) type
|
||||
#define NS_IMETHOD_(type) virtual type
|
||||
#define NS_IMETHODIMP_(type) type
|
||||
#define NS_METHOD_(type) type
|
||||
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Generic API modifiers which return the standard XPCOM nsresult type
|
||||
*/
|
||||
#define NS_IMETHOD NS_IMETHOD_(nsresult)
|
||||
#define NS_IMETHODIMP NS_IMETHODIMP_(nsresult)
|
||||
#define NS_METHOD NS_METHOD_(nsresult)
|
||||
#define NS_CALLBACK(_name) NS_CALLBACK_(nsresult, _name)
|
||||
|
||||
/**
|
||||
* Import/Export macros for XPCOM APIs
|
||||
*/
|
||||
|
||||
#ifdef _IMPL_NS_COM
|
||||
#define NS_COM NS_EXPORT
|
||||
#elif _IMPL_NS_COM_OFF
|
||||
#define NS_COM
|
||||
#elif XPCOM_GLUE
|
||||
#define NS_COM
|
||||
#else
|
||||
#define NS_COM NS_IMPORT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NS_NO_VTABLE is emitted by xpidl in interface declarations whenever
|
||||
* xpidl can determine that the interface can't contain a constructor.
|
||||
* This results in some space savings and possible runtime savings -
|
||||
* see bug 49416. We undefine it first, as xpidl-generated headers
|
||||
* define it for IDL uses that don't include this file.
|
||||
*/
|
||||
#ifdef NS_NO_VTABLE
|
||||
#undef NS_NO_VTABLE
|
||||
#endif
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1100
|
||||
#define NS_NO_VTABLE __declspec(novtable)
|
||||
#else
|
||||
#define NS_NO_VTABLE
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Generic XPCOM result data type
|
||||
*/
|
||||
typedef PRUint32 nsresult;
|
||||
|
||||
/**
|
||||
* The preferred symbol for null.
|
||||
*/
|
||||
#define nsnull 0
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Casting macros for hiding C++ features from older compilers */
|
||||
|
||||
/*
|
||||
All our compiler support template specialization, but not all support the
|
||||
|template <>| notation. The compiler that don't understand this notation
|
||||
just omit it for specialization.
|
||||
|
||||
Need to add an autoconf test for this.
|
||||
*/
|
||||
|
||||
/* under Metrowerks (Mac), we don't have autoconf yet */
|
||||
#ifdef __MWERKS__
|
||||
#define HAVE_CPP_SPECIALIZATION
|
||||
#define HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
||||
|
||||
#define HAVE_CPP_ACCESS_CHANGING_USING
|
||||
#define HAVE_CPP_AMBIGUITY_RESOLVING_USING
|
||||
#define HAVE_CPP_EXPLICIT
|
||||
#define HAVE_CPP_TYPENAME
|
||||
#define HAVE_CPP_BOOL
|
||||
#define HAVE_CPP_NAMESPACE_STD
|
||||
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
||||
#define HAVE_CPP_2BYTE_WCHAR_T
|
||||
#endif
|
||||
|
||||
/* under VC++ (Windows), we don't have autoconf yet */
|
||||
#if defined(_MSC_VER) && (_MSC_VER>=1100)
|
||||
/* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */
|
||||
#define HAVE_CPP_SPECIALIZATION
|
||||
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
||||
#define HAVE_CPP_EXTERN_INSTANTIATION
|
||||
|
||||
#define HAVE_CPP_EXPLICIT
|
||||
#define HAVE_CPP_TYPENAME
|
||||
#define HAVE_CPP_ACCESS_CHANGING_USING
|
||||
|
||||
#if (_MSC_VER==1100)
|
||||
/* VC++5.0 has an internal compiler error (sometimes) without this */
|
||||
#undef HAVE_CPP_ACCESS_CHANGING_USING
|
||||
#endif
|
||||
|
||||
#define HAVE_CPP_NAMESPACE_STD
|
||||
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
||||
#define HAVE_CPP_2BYTE_WCHAR_T
|
||||
#endif
|
||||
|
||||
/* until we get an autoconf test for this, we'll assume it's on (since we're using it already) */
|
||||
#define HAVE_CPP_TYPENAME
|
||||
|
||||
/* waiting to find out if OS/2 VisualAge participates in autoconf */
|
||||
#if defined(XP_OS2_VACPP) || defined(AIX_XLC_364) || (defined(IRIX) && !defined(__GNUC__))
|
||||
#undef HAVE_CPP_TYPENAME
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __PRUNICHAR__
|
||||
#define __PRUNICHAR__
|
||||
/* For now, don't use wchar_t on Unix because it breaks the Netscape
|
||||
* commercial build. When this is fixed there will be no need for the
|
||||
* |NS_REINTERPRET_CAST| in nsLiteralString.h either.
|
||||
*/
|
||||
#if defined(HAVE_CPP_2BYTE_WCHAR_T) && (defined(NS_WIN32) || defined(XP_MAC))
|
||||
typedef wchar_t PRUnichar;
|
||||
#else
|
||||
typedef PRUint16 PRUnichar;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
If the compiler doesn't support |explicit|, we'll just make it go away, trusting
|
||||
that the builds under compilers that do have it will keep us on the straight and narrow.
|
||||
*/
|
||||
#ifndef HAVE_CPP_EXPLICIT
|
||||
#define explicit
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CPP_TYPENAME
|
||||
#define typename
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
||||
#define NS_SPECIALIZE_TEMPLATE template <>
|
||||
#else
|
||||
#define NS_SPECIALIZE_TEMPLATE
|
||||
#endif
|
||||
|
||||
/* unix and beos now determine this automatically */
|
||||
#if ! defined XP_UNIX && ! defined XP_BEOS && !defined(XP_OS2)
|
||||
#define HAVE_CPP_NEW_CASTS /* we'll be optimistic. */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CPP_NEW_CASTS)
|
||||
#define NS_STATIC_CAST(__type, __ptr) static_cast< __type >(__ptr)
|
||||
#define NS_CONST_CAST(__type, __ptr) const_cast< __type >(__ptr)
|
||||
|
||||
#define NS_REINTERPRET_POINTER_CAST(__type, __ptr) reinterpret_cast< __type >(__ptr)
|
||||
#define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) reinterpret_cast< __type >(__obj)
|
||||
#define NS_REINTERPRET_CAST(__type, __expr) reinterpret_cast< __type >(__expr)
|
||||
|
||||
#else
|
||||
#define NS_STATIC_CAST(__type, __ptr) ((__type)(__ptr))
|
||||
#define NS_CONST_CAST(__type, __ptr) ((__type)(__ptr))
|
||||
|
||||
#define NS_REINTERPRET_POINTER_CAST(__type, __ptr) ((__type)((void*)(__ptr)))
|
||||
#define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) ((__type)(__obj))
|
||||
|
||||
/* Note: the following is only appropriate for pointers. */
|
||||
#define NS_REINTERPRET_CAST(__type, __expr) NS_REINTERPRET_POINTER_CAST(__type, __expr)
|
||||
/*
|
||||
Why cast to a |void*| first? Well, when old-style casting from
|
||||
a pointer to a base to a pointer to a derived class, the cast will be
|
||||
ambiguous if the source pointer type appears multiple times in the
|
||||
destination, e.g.,
|
||||
|
||||
class Base {};
|
||||
class Derived : public Base, public Base {};
|
||||
|
||||
void foo( Base* b )
|
||||
{
|
||||
((Derived*)b)->some_derived_member ... // Error: Ambiguous, expand from which |Base|?
|
||||
}
|
||||
|
||||
an old-style cast (like |static_cast|) will change the pointer, but
|
||||
here, doesn't know how. The cast to |void*| prevents it from thinking
|
||||
it needs to expand the original pointer.
|
||||
|
||||
The cost is, |NS_REINTERPRET_CAST| is no longer appropriate for non-pointer
|
||||
conversions. Also, mis-applying |NS_REINTERPRET_CAST| to cast |this| to something
|
||||
will still expand the pointer to the outer object in standards complying compilers.
|
||||
*/
|
||||
|
||||
/*
|
||||
No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate
|
||||
the semantics. So if you want to dynamic_cast, then just use it
|
||||
"straight", no macro.
|
||||
*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use these macros to do 64bit safe pointer conversions.
|
||||
*/
|
||||
|
||||
#define NS_PTR_TO_INT32(x) ((char *)(x) - (char *)0)
|
||||
#define NS_INT32_TO_PTR(x) ((void *)((char *)0 + (x)))
|
||||
|
||||
#endif /* nscore_h___ */
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Root idl declarations to be used by all.
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
%{C++
|
||||
|
||||
#include "nscore.h"
|
||||
#include "prtime.h"
|
||||
|
||||
/*
|
||||
* Forward declarations for new string types
|
||||
*/
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
|
||||
/*
|
||||
* Start commenting out the C++ versions of the below in the output header
|
||||
*/
|
||||
#if 0
|
||||
%}
|
||||
|
||||
typedef boolean PRBool ;
|
||||
typedef octet PRUint8 ;
|
||||
typedef unsigned short PRUint16 ;
|
||||
typedef unsigned short PRUnichar;
|
||||
typedef unsigned long PRUint32 ;
|
||||
typedef unsigned long long PRUint64 ;
|
||||
typedef unsigned long long PRTime ;
|
||||
typedef short PRInt16 ;
|
||||
typedef long PRInt32 ;
|
||||
typedef long long PRInt64 ;
|
||||
|
||||
typedef unsigned long nsrefcnt ;
|
||||
typedef unsigned long nsresult ;
|
||||
|
||||
// XXX need this built into xpidl compiler so that it's really size_t or PRSize
|
||||
// and it's scriptable:
|
||||
typedef unsigned long size_t;
|
||||
|
||||
[ptr] native voidPtr(void);
|
||||
[ptr] native charPtr(char);
|
||||
[ptr] native unicharPtr(PRUnichar);
|
||||
|
||||
[ref, nsid] native nsIDRef(nsID);
|
||||
[ref, nsid] native nsIIDRef(nsIID);
|
||||
[ref, nsid] native nsCIDRef(nsCID);
|
||||
|
||||
[ptr, nsid] native nsIDPtr(nsID);
|
||||
[ptr, nsid] native nsIIDPtr(nsIID);
|
||||
[ptr, nsid] native nsCIDPtr(nsCID);
|
||||
|
||||
// NOTE: Be careful in using the following 3 types. The *Ref and *Ptr variants
|
||||
// are more commonly used (and better supported). Those variants require
|
||||
// nsMemory alloc'd copies when used as 'out' params while these types do not.
|
||||
// However, currently these types can not be used for 'in' params. And, methods
|
||||
// that use them as 'out' params *must* be declared [notxpcom] (with an explicit
|
||||
// return type of nsresult). This makes such methods implicitly not scriptable.
|
||||
// Use of these types in methods without a [notxpcom] declaration will cause
|
||||
// the xpidl compiler to raise an error.
|
||||
// See: http://bugzilla.mozilla.org/show_bug.cgi?id=93792
|
||||
|
||||
[nsid] native nsIID(nsIID);
|
||||
[nsid] native nsID(nsID);
|
||||
[nsid] native nsCID(nsCID);
|
||||
|
||||
[ptr] native nsQIResult(void);
|
||||
|
||||
[ref, domstring] native DOMString(ignored);
|
||||
[ref, domstring] native DOMStringRef(ignored);
|
||||
[ptr, domstring] native DOMStringPtr(ignored);
|
||||
|
||||
[ref, utf8string] native AUTF8String(ignored);
|
||||
[ref, utf8string] native AUTF8StringRef(ignored);
|
||||
[ptr, utf8string] native AUTF8StringPtr(ignored);
|
||||
|
||||
[ref, cstring] native ACString(ignored);
|
||||
[ref, cstring] native ACStringRef(ignored);
|
||||
[ptr, cstring] native ACStringPtr(ignored);
|
||||
|
||||
[ref, astring] native AString(ignored);
|
||||
[ref, astring] native AStringRef(ignored);
|
||||
[ptr, astring] native AStringPtr(ignored);
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
*/
|
||||
#endif
|
||||
%}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Header file of Pure API function declarations.
|
||||
*
|
||||
* Explicitly no copyright.
|
||||
* You may recompile and redistribute these definitions as required.
|
||||
*
|
||||
* Version 1.0
|
||||
*/
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PURE_H_VERSION 1
|
||||
|
||||
//////////////////////////////
|
||||
// API's Specific to Purify //
|
||||
//////////////////////////////
|
||||
|
||||
// TRUE when Purify is running.
|
||||
int __cdecl PurifyIsRunning(void) ;
|
||||
//
|
||||
// Print a string to the viewer.
|
||||
//
|
||||
int __cdecl PurePrintf(const char *fmt, ...) ;
|
||||
int __cdecl PurifyPrintf(const char *fmt, ...) ;
|
||||
//
|
||||
// Purify functions for leak and memory-in-use functionalty.
|
||||
//
|
||||
int __cdecl PurifyNewInuse(void) ;
|
||||
int __cdecl PurifyAllInuse(void) ;
|
||||
int __cdecl PurifyClearInuse(void) ;
|
||||
int __cdecl PurifyNewLeaks(void) ;
|
||||
int __cdecl PurifyAllLeaks(void) ;
|
||||
int __cdecl PurifyClearLeaks(void) ;
|
||||
//
|
||||
// Purify functions for handle leakage.
|
||||
//
|
||||
int __cdecl PurifyAllHandlesInuse(void) ;
|
||||
int __cdecl PurifyNewHandlesInuse(void) ;
|
||||
//
|
||||
// Functions that tell you about the state of memory.
|
||||
//
|
||||
int __cdecl PurifyDescribe(void *addr) ;
|
||||
int __cdecl PurifyWhatColors(void *addr, int size) ;
|
||||
//
|
||||
// Functions to test the state of memory. If the memory is not
|
||||
// accessable, an error is signaled just as if there were a memory
|
||||
// reference and the function returns false.
|
||||
//
|
||||
int __cdecl PurifyAssertIsReadable(const void *addr, int size) ;
|
||||
int __cdecl PurifyAssertIsWritable(const void *addr, int size) ;
|
||||
//
|
||||
// Functions to test the state of memory. If the memory is not
|
||||
// accessable, these functions return false. No error is signaled.
|
||||
//
|
||||
int __cdecl PurifyIsReadable(const void *addr, int size) ;
|
||||
int __cdecl PurifyIsWritable(const void *addr, int size) ;
|
||||
int __cdecl PurifyIsInitialized(const void *addr, int size) ;
|
||||
//
|
||||
// Functions to set the state of memory.
|
||||
//
|
||||
void __cdecl PurifyMarkAsInitialized(void *addr, int size) ;
|
||||
void __cdecl PurifyMarkAsUninitialized(void *addr, int size) ;
|
||||
//
|
||||
// Functions to do late detection of ABWs, FMWs, IPWs.
|
||||
//
|
||||
#define PURIFY_HEAP_CRT 0xfffffffe
|
||||
#define PURIFY_HEAP_ALL 0xfffffffd
|
||||
#define PURIFY_HEAP_BLOCKS_LIVE 0x80000000
|
||||
#define PURIFY_HEAP_BLOCKS_DEFERRED_FREE 0x40000000
|
||||
#define PURIFY_HEAP_BLOCKS_ALL (PURIFY_HEAP_BLOCKS_LIVE|PURIFY_HEAP_BLOCKS_DEFERRED_FREE)
|
||||
int __cdecl PurifyHeapValidate(unsigned int hHeap, unsigned int dwFlags, const void *addr) ;
|
||||
int __cdecl PurifySetLateDetectScanCounter(int counter);
|
||||
int __cdecl PurifySetLateDetectScanInterval(int seconds);
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// API's Specific to Quantify //
|
||||
////////////////////////////////
|
||||
|
||||
// TRUE when Quantify is running.
|
||||
int __cdecl QuantifyIsRunning(void) ;
|
||||
|
||||
//
|
||||
// Functions for controlling collection
|
||||
//
|
||||
int __cdecl QuantifyDisableRecordingData(void) ;
|
||||
int __cdecl QuantifyStartRecordingData(void) ;
|
||||
int __cdecl QuantifyStopRecordingData(void) ;
|
||||
int __cdecl QuantifyClearData(void) ;
|
||||
int __cdecl QuantifyIsRecordingData(void) ;
|
||||
|
||||
// Add a comment to the dataset
|
||||
int __cdecl QuantifyAddAnnotation(char *) ;
|
||||
|
||||
// Save the current data, creating a "checkpoint" dataset
|
||||
int __cdecl QuantifySaveData(void) ;
|
||||
|
||||
////////////////////////////////
|
||||
// API's Specific to Coverage //
|
||||
////////////////////////////////
|
||||
|
||||
// TRUE when Coverage is running.
|
||||
int __cdecl CoverageIsRunning(void) ;
|
||||
//
|
||||
// Functions for controlling collection
|
||||
//
|
||||
int __cdecl CoverageDisableRecordingData(void) ;
|
||||
int __cdecl CoverageStartRecordingData(void) ;
|
||||
int __cdecl CoverageStopRecordingData(void) ;
|
||||
int __cdecl CoverageClearData(void) ;
|
||||
int __cdecl CoverageIsRecordingData(void) ;
|
||||
// Add a comment to the dataset
|
||||
int __cdecl CoverageAddAnnotation(char *) ;
|
||||
|
||||
// Save the current data, creating a "checkpoint" dataset
|
||||
int __cdecl CoverageSaveData(void) ;
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// API's Specific to Purelock //
|
||||
////////////////////////////////
|
||||
|
||||
// TRUE when Purelock is running.
|
||||
int __cdecl PurelockIsRunning(void) ;
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Header file of Pure API function declarations.
|
||||
*
|
||||
* Explicitly no copyright.
|
||||
* You may recompile and redistribute these definitions as required.
|
||||
*
|
||||
* NOTE1: In some situations when compiling with MFC, you should
|
||||
* enable the setting 'Not using precompiled headers' in Visual C++
|
||||
* to avoid a compiler diagnostic.
|
||||
*
|
||||
* NOTE2: This file works through the use of deep magic. Calls to functions
|
||||
* in this file are replaced with calls into the OCI runtime system
|
||||
* when an instrumented version of this program is run.
|
||||
*
|
||||
* NOTE3: The static vars avoidGy_n (where n is a unique number) are used
|
||||
* to prevent optimizing the functions away when compiler option
|
||||
* /Gy is set. This is needed so that NOTE2 works properly.
|
||||
*/
|
||||
static int avoidGy_1;
|
||||
static int avoidGy_2;
|
||||
static int avoidGy_3;
|
||||
static int avoidGy_4;
|
||||
static int avoidGy_5;
|
||||
static int avoidGy_6;
|
||||
static int avoidGy_7;
|
||||
static int avoidGy_8;
|
||||
static int avoidGy_9;
|
||||
static int avoidGy_10;
|
||||
static int avoidGy_11;
|
||||
static int avoidGy_12;
|
||||
static int avoidGy_13;
|
||||
static int avoidGy_14;
|
||||
static int avoidGy_15;
|
||||
static int avoidGy_16;
|
||||
static int avoidGy_17;
|
||||
static int avoidGy_18;
|
||||
static int avoidGy_19;
|
||||
static int avoidGy_20;
|
||||
static int avoidGy_21;
|
||||
static int avoidGy_22;
|
||||
static int avoidGy_23;
|
||||
static int avoidGy_24;
|
||||
static int avoidGy_25;
|
||||
static int avoidGy_26;
|
||||
static int avoidGy_27;
|
||||
static int avoidGy_28;
|
||||
static int avoidGy_29;
|
||||
static int avoidGy_30;
|
||||
static int avoidGy_31;
|
||||
static int avoidGy_32;
|
||||
static int avoidGy_33;
|
||||
static int avoidGy_34;
|
||||
static int avoidGy_35;
|
||||
static int avoidGy_36;
|
||||
static int avoidGy_37;
|
||||
static int avoidGy_38;
|
||||
static int avoidGy_39;
|
||||
static int avoidGy_40;
|
||||
static int avoidGy_41;
|
||||
static int avoidGy_42;
|
||||
static int avoidGy_43;
|
||||
static int avoidGy_44;
|
||||
static int avoidGy_45;
|
||||
static int avoidGy_46;
|
||||
static int avoidGy_47;
|
||||
static int avoidGy_48;
|
||||
static int avoidGy_49;
|
||||
static int avoidGy_50;
|
||||
static int avoidGy_51;
|
||||
static int avoidGy_52;
|
||||
static int avoidGy_53;
|
||||
static int avoidGy_54;
|
||||
static int avoidGy_55;
|
||||
static int avoidGy_56;
|
||||
static int avoidGy_57;
|
||||
static int avoidGy_58;
|
||||
static int avoidGy_59;
|
||||
static int avoidGy_60;
|
||||
static int avoidGy_PL_01;
|
||||
__declspec(dllexport) int __cdecl PurePrintf(const char *fmt, ...) { avoidGy_1++; fmt; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyIsRunning(void) { avoidGy_2++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyPrintf(const char *fmt, ...) { avoidGy_3++; fmt; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyNewInuse(void) { avoidGy_4++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyAllInuse(void) { avoidGy_5++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyClearInuse(void) { avoidGy_6++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyNewLeaks(void) { avoidGy_7++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyAllLeaks(void) { avoidGy_8++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyClearLeaks(void) { avoidGy_9++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyAllHandlesInuse(void) { avoidGy_10++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyNewHandlesInuse(void) { avoidGy_11++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyDescribe(void *addr) { avoidGy_12++; addr; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyWhatColors(void *addr, int size) { avoidGy_13++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyAssertIsReadable(const void *addr, int size) { avoidGy_14++; addr; size; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifyAssertIsWritable(const void *addr, int size) { avoidGy_15++; addr; size; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifyIsReadable(const void *addr, int size) { avoidGy_16++; addr; size; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifyIsWritable(const void *addr, int size) { avoidGy_17++; addr; size; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifyIsInitialized(const void *addr, int size) { avoidGy_18++; addr; size; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifyRed(void *addr, int size) { avoidGy_19++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyGreen(void *addr, int size) { avoidGy_20++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyYellow(void *addr, int size) { avoidGy_21++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyBlue(void *addr, int size) { avoidGy_22++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyMarkAsInitialized(void *addr, int size) { avoidGy_23++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyMarkAsUninitialized(void *addr, int size) { avoidGy_24++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyMarkForTrap(void *addr, int size) { avoidGy_25++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyMarkForNoTrap(void *addr, int size) { avoidGy_26++; addr; size; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurifyHeapValidate(unsigned int hHeap, unsigned int dwFlags, const void *addr)
|
||||
{ avoidGy_27++; hHeap; dwFlags; addr; return 1; }
|
||||
__declspec(dllexport) int __cdecl PurifySetLateDetectScanCounter(int counter) { avoidGy_28++; counter; return 0; };
|
||||
__declspec(dllexport) int __cdecl PurifySetLateDetectScanInterval(int seconds) { avoidGy_29++; seconds; return 0; };
|
||||
__declspec(dllexport) int __cdecl CoverageIsRunning(void) { avoidGy_30++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageDisableRecordingData(void) { avoidGy_31++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageStartRecordingData(void) { avoidGy_32++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageStopRecordingData(void) { avoidGy_33++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageClearData(void) { avoidGy_34++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageIsRecordingData(void) { avoidGy_35++; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageAddAnnotation(char *str) { avoidGy_36++; str; return 0; }
|
||||
__declspec(dllexport) int __cdecl CoverageSaveData(void) { avoidGy_37++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyIsRunning(void) { avoidGy_42++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyDisableRecordingData(void) { avoidGy_43++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyStartRecordingData(void) { avoidGy_44++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyStopRecordingData(void) { avoidGy_45++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyClearData(void) { avoidGy_46++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyIsRecordingData(void) { avoidGy_47++; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifyAddAnnotation(char *str) { avoidGy_48++; str; return 0; }
|
||||
__declspec(dllexport) int __cdecl QuantifySaveData(void) { avoidGy_49++; return 0; }
|
||||
__declspec(dllexport) int __cdecl PurelockIsRunning(void) { avoidGy_PL_01++; return 0; }
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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):
|
||||
|
||||
16389=An unknown error has occurred (%1$S)
|
||||
@@ -1,2 +0,0 @@
|
||||
nsXPCOM.h
|
||||
nsXPCOMCID.h
|
||||
@@ -1,168 +0,0 @@
|
||||
#
|
||||
# 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 = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpcom
|
||||
LIBRARY_NAME = xpcom
|
||||
|
||||
ifdef _BUILD_BUNDLE
|
||||
IS_COMPONENT = 1
|
||||
DLL_SUFFIX = .bundle
|
||||
NO_DIST_INSTALL = 1
|
||||
NO_COMPONENT_LINK_MAP = 1
|
||||
endif
|
||||
|
||||
# Do not set EXPORT_LIBRARY as we do not want xpcom in the static libs list
|
||||
#EXPORT_LIBRARY = 1
|
||||
GRE_MODULE = 1
|
||||
|
||||
REQUIRES = libreg \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
# pull in MoreFiles for MacOSX
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
REQUIRES += macmorefiles
|
||||
endif
|
||||
|
||||
CPPSRCS = nsXPComInit.cpp
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS += dlldeps.cpp
|
||||
endif
|
||||
|
||||
ifdef XPCOM_USE_LEA
|
||||
CSRCS += malloc.c
|
||||
endif
|
||||
|
||||
ifdef GC_LEAK_DETECTOR
|
||||
EXTRA_DSO_LIBS = boehm
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomds_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomio_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomcomponents_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomthreads_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomproxy_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcombase_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xptcall.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xptinfo.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpt.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xptcmd.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)string_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)string_obsolete_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../glue \
|
||||
-I$(srcdir)/../base \
|
||||
-I$(srcdir)/../ds \
|
||||
-I$(srcdir)/../io \
|
||||
-I$(srcdir)/../components \
|
||||
-I$(srcdir)/../threads \
|
||||
-I$(srcdir)/../threads/_xpidlgen \
|
||||
-I$(srcdir)/../proxy/src \
|
||||
$(NULL)
|
||||
|
||||
SDK_HEADERS = \
|
||||
nsXPCOM.h \
|
||||
nsXPCOMCID.h \
|
||||
$(NULL)
|
||||
|
||||
SDK_BINARY = $(IMPORT_LIBRARY) $(SHARED_LIBRARY)
|
||||
|
||||
ifdef MOZ_DEMANGLE_SYMBOLS
|
||||
EXTRA_DSO_LDOPTS += -liberty
|
||||
endif
|
||||
|
||||
# pull in MoreFiles for MacOSX
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += $(DEPTH)/dist/lib/libmacmorefiles_s.a
|
||||
endif
|
||||
|
||||
# Turn off grep filter for .def files
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
XPCOM_SWITCH = 1
|
||||
endif
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
OS_LIBS += libconv.lib libuls.lib
|
||||
endif
|
||||
|
||||
# UNIX98 iconv support
|
||||
OS_LIBS += $(LIBICONV)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifndef DISABLE_DIST_GRE
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
GARBAGE += $(SHARED_LIBRARY:$(DLL_SUFFIX)=.bundle)
|
||||
ifndef _BUILD_BUNDLE
|
||||
libs:: $(SHARED_LIBRARY)
|
||||
$(MAKE) libs _BUILD_BUNDLE=1
|
||||
$(INSTALL) $(LIB_PREFIX)$(LIBRARY_NAME).bundle $(DIST)/gre
|
||||
$(INSTALL) $(LIB_PREFIX)$(LIBRARY_NAME).bundle $(DIST)/bin
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
DEFINES += \
|
||||
-D_IMPL_NS_COM \
|
||||
-DEXPORT_XPT_API \
|
||||
-DEXPORT_XPTC_API \
|
||||
-DEXPORT_XPTI_API
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
|
||||
|
||||
ifdef GC_LEAK_DETECTOR
|
||||
DEFINES += -DGC_LEAK_DETECTOR
|
||||
endif
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),BeOS)
|
||||
EXTRA_DSO_LDOPTS += -lbe
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
EXTRA_DSO_LDOPTS += shell32.lib ole32.lib
|
||||
ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
|
||||
EXTRA_DSO_LDOPTS += imagehlp.lib
|
||||
endif
|
||||
endif # WINNT
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Force references to all of the symbols that we want exported from
|
||||
// the dll that are located in the .lib files we link with
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsValueArray.h"
|
||||
#include "nsIAtom.h"
|
||||
//#include "nsIBuffer.h"
|
||||
//#include "nsIByteBufferInputStream.h"
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsRecyclingAllocator.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsObserver.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsString.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsProxyEventPrivate.h"
|
||||
#include "xpt_xdr.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsHashtableEnumerator.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsCWeakReference.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsStatistics.h"
|
||||
#include "nsIStorageStream.h"
|
||||
#include "nsLinebreakConverter.h"
|
||||
#include "nsIBinaryInputStream.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsStaticNameTable.h"
|
||||
#include "nsProcess.h"
|
||||
#include "nsSlidingString.h"
|
||||
#include "nsIInputStreamTee.h"
|
||||
#include "nsCheapSets.h"
|
||||
#include "nsSegmentedBuffer.h"
|
||||
#ifdef DEBUG
|
||||
#include "pure.h"
|
||||
#endif
|
||||
#include "pldhash.h"
|
||||
#include "nsVariant.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
extern NS_COM void TestSegmentedBuffer();
|
||||
#endif
|
||||
|
||||
void XXXNeverCalled()
|
||||
{
|
||||
nsTextFormatter::snprintf(nsnull,0,nsnull);
|
||||
nsTextFormatter::smprintf(nsnull, nsnull);
|
||||
nsTextFormatter::smprintf_free(nsnull);
|
||||
nsVoidArray();
|
||||
nsSmallVoidArray();
|
||||
nsStringHashSet();
|
||||
nsCStringHashSet();
|
||||
nsInt32HashSet();
|
||||
nsVoidHashSet();
|
||||
nsCheapStringSet();
|
||||
nsCheapInt32Set();
|
||||
nsValueArray(0);
|
||||
nsSupportsArray();
|
||||
NS_GetNumberOfAtoms();
|
||||
NS_NewPipe2(NULL, NULL, PR_FALSE, PR_FALSE, 0, 0, NULL);
|
||||
NS_NewInputStreamReadyEvent(NULL, NULL, NULL);
|
||||
NS_NewOutputStreamReadyEvent(NULL, NULL, NULL);
|
||||
NS_AsyncCopy(NULL, NULL, PR_TRUE, PR_TRUE, 0, 0, NULL);
|
||||
nsFixedSizeAllocator a;
|
||||
nsRecyclingAllocator recyclingAllocator(2);
|
||||
a.Init(0, 0, 0, 0, 0);
|
||||
a.Alloc(0);
|
||||
a.Free(0, 0);
|
||||
nsIThread::GetCurrent(NULL);
|
||||
nsDeque(NULL);
|
||||
NS_NewObserver(NULL, NULL);
|
||||
nsTraceRefcnt::DumpStatistics();
|
||||
NS_NewEmptyEnumerator(NULL);
|
||||
nsArrayEnumerator(NULL);
|
||||
NS_QuickSort(NULL, 0, 0, NULL, NULL);
|
||||
nsStatistics("dummy");
|
||||
nsString();
|
||||
nsProxyObject(NULL, 0, NULL);
|
||||
XPT_DoString(NULL, NULL, NULL);
|
||||
XPT_DoHeader(NULL, NULL, NULL);
|
||||
#ifdef DEBUG
|
||||
PurePrintf(0);
|
||||
#endif
|
||||
XPTC_InvokeByIndex(NULL, 0, 0, NULL);
|
||||
xptc_dummy();
|
||||
xptc_dummy2();
|
||||
XPTI_GetInterfaceInfoManager();
|
||||
NS_NewGenericFactory(NULL, NULL);
|
||||
NS_NewGenericModule(NULL, 0, NULL, NULL, NULL);
|
||||
NS_NewGenericModule2(NULL, NULL);
|
||||
NS_NewHashtableEnumerator(NULL, NULL, NULL, NULL);
|
||||
nsCWeakProxy(0, 0);
|
||||
nsCWeakReferent(0);
|
||||
NS_GetWeakReference(NULL);
|
||||
nsCOMPtr<nsISupports> dummyFoo(do_GetInterface(nsnull));
|
||||
nsSegmentedBuffer segx;
|
||||
segx.AppendNewSegment();
|
||||
#ifdef DEBUG
|
||||
TestSegmentedBuffer();
|
||||
#endif
|
||||
NS_NewSizeOfHandler(0);
|
||||
NS_NewStorageStream(0,0, nsnull);
|
||||
nsString foo;
|
||||
nsPrintfCString bar("");
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(foo,
|
||||
nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakContent);
|
||||
NS_NewLocalFile(nsString(), PR_FALSE, NULL);
|
||||
NS_NewNativeLocalFile(nsCString(), PR_FALSE, NULL);
|
||||
nsProcess();
|
||||
nsStaticCaseInsensitiveNameTable();
|
||||
nsAutoString str1;
|
||||
nsCAutoString str2;
|
||||
ToNewUnicode(str1);
|
||||
ToNewUnicode(str2);
|
||||
ToNewCString(str1);
|
||||
ToNewCString(str2);
|
||||
PL_DHashTableFinish(NULL);
|
||||
nsSlidingString sliding(NULL, NULL, NULL);
|
||||
NS_NewInputStreamTee(NULL, NULL, NULL);
|
||||
NS_NewArray(nsnull);
|
||||
nsCOMArray<nsISupports> dummyArray;
|
||||
NS_NewArray(nsnull, dummyArray);
|
||||
NS_NewArrayEnumerator(nsnull, dummyArray);
|
||||
nsVariant();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,196 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsXPCOM_h__
|
||||
#define nsXPCOM_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
|
||||
class nsIComponentManager;
|
||||
class nsIComponentRegistrar;
|
||||
class nsIServiceManager;
|
||||
class nsIFile;
|
||||
class nsILocalFile;
|
||||
class nsIDirectoryServiceProvider;
|
||||
class nsIMemory;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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 abinDirectory The directory containing the component
|
||||
* registry and runtime libraries;
|
||||
* or use <CODE>nsnull</CODE> to use the working
|
||||
* directory.
|
||||
*
|
||||
* @param aAppFileLocProvider 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.
|
||||
*
|
||||
* @see NS_NewLocalFile
|
||||
* @see nsILocalFile
|
||||
* @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.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
nsIFile* binDirectory,
|
||||
nsIDirectoryServiceProvider* appFileLocationProvider);
|
||||
/**
|
||||
* 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.
|
||||
* This will release servMgr. You may pass null.
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure during initialisation.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_ShutdownXPCOM(nsIServiceManager* servMgr);
|
||||
|
||||
|
||||
/**
|
||||
* Public Method to access to the service manager.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param result Interface pointer to the service manager
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure during initialisation.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_GetServiceManager(nsIServiceManager* *result);
|
||||
|
||||
/**
|
||||
* Public Method to access to the component manager.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param result Interface pointer to the service
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure during initialisation.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_GetComponentManager(nsIComponentManager* *result);
|
||||
|
||||
/**
|
||||
* Public Method to access to the component registration manager.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param result Interface pointer to the service
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure during initialisation.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_GetComponentRegistrar(nsIComponentRegistrar* *result);
|
||||
|
||||
/**
|
||||
* Public Method to access to the memory manager. See nsIMemory
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param result Interface pointer to the memory manager
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure during initialisation.
|
||||
*
|
||||
*/
|
||||
extern "C" NS_COM nsresult
|
||||
NS_GetMemoryManager(nsIMemory* *result);
|
||||
|
||||
/**
|
||||
* Public Method to create an instance of a nsILocalFile. This function
|
||||
* may be called prior to NS_InitXPCOM2.
|
||||
*
|
||||
* @status FROZEN
|
||||
*
|
||||
* @param filePath
|
||||
* A string which specifies a full file path to a
|
||||
* location. Relative paths will be treated as an
|
||||
* error (NS_ERROR_FILE_UNRECOGNIZED_PATH).
|
||||
* |NS_NewNativeLocalFile|'s path must be in the
|
||||
* filesystem charset.
|
||||
* @param followLinks
|
||||
* This attribute will determine if the nsLocalFile will auto
|
||||
* resolve symbolic links. By default, this value will be false
|
||||
* on all non unix systems. On unix, this attribute is effectively
|
||||
* a noop.
|
||||
* @param result Interface pointer to a new instance of an nsILocalFile
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure.
|
||||
*/
|
||||
|
||||
extern "C" NS_COM nsresult
|
||||
NS_NewLocalFile(const nsAString &path,
|
||||
PRBool followLinks,
|
||||
nsILocalFile* *result);
|
||||
|
||||
extern "C" NS_COM nsresult
|
||||
NS_NewNativeLocalFile(const nsACString &path,
|
||||
PRBool followLinks,
|
||||
nsILocalFile* *result);
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsXPCOMCID_h__
|
||||
#define nsXPCOMCID_h__
|
||||
|
||||
/**
|
||||
* XPCOM Directory Service Contract ID
|
||||
* The directory service provides ways to obtain file system locations. The
|
||||
* directory service is a singleton.
|
||||
*
|
||||
* This contract supports the nsIDirectoryService and the nsIProperties
|
||||
* interfaces.
|
||||
*
|
||||
*/
|
||||
#define NS_DIRECTORY_SERVICE_CONTRACTID "@mozilla.org/file/directory_service;1"
|
||||
|
||||
/**
|
||||
* XPCOM File
|
||||
* The file abstraction provides ways to obtain and access files and
|
||||
* directories located on the local system.
|
||||
*
|
||||
* This contract supports the nsIFile interface and the nsILocalFile interface.
|
||||
* This contract may also support platform specific interfaces such as
|
||||
* nsILocalFileMac on platforms where additional interfaces are required.
|
||||
*
|
||||
*/
|
||||
#define NS_LOCAL_FILE_CONTRACTID "@mozilla.org/file/local;1"
|
||||
|
||||
/**
|
||||
* XPCOM Category Manager Contract ID
|
||||
* The contract supports the nsICategoryManager interface. The
|
||||
* category manager is a singleton.
|
||||
*/
|
||||
#define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;1"
|
||||
|
||||
/**
|
||||
* XPCOM Properties Object Contract ID
|
||||
* Simple mapping object which supports the nsIProperties interface.
|
||||
*/
|
||||
#define NS_PROPERTIES_CONTRACTID "@mozilla.org/properties;1"
|
||||
|
||||
/**
|
||||
* XPCOM Array Object ContractID
|
||||
* Simple array implementation which supports the nsIArray and
|
||||
* nsIMutableArray interfaces.
|
||||
*/
|
||||
#define NS_ARRAY_CONTRACTID "@mozilla.org/array;1"
|
||||
|
||||
/**
|
||||
* The following are the CIDs and Contract IDs of the nsISupports wrappers for
|
||||
* primative types.
|
||||
*/
|
||||
#define NS_SUPPORTS_ID_CID \
|
||||
{ 0xacf8dc40, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_ID_CONTRACTID "@mozilla.org/supports-id;1"
|
||||
|
||||
#define NS_SUPPORTS_CSTRING_CID \
|
||||
{ 0xacf8dc41, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_CSTRING_CONTRACTID "@mozilla.org/supports-cstring;1"
|
||||
|
||||
#define NS_SUPPORTS_STRING_CID \
|
||||
{ 0xacf8dc42, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_STRING_CONTRACTID "@mozilla.org/supports-string;1"
|
||||
|
||||
#define NS_SUPPORTS_PRBOOL_CID \
|
||||
{ 0xacf8dc43, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRBOOL_CONTRACTID "@mozilla.org/supports-PRBool;1"
|
||||
|
||||
#define NS_SUPPORTS_PRUINT8_CID \
|
||||
{ 0xacf8dc44, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRUINT8_CONTRACTID "@mozilla.org/supports-PRUint8;1"
|
||||
|
||||
#define NS_SUPPORTS_PRUINT16_CID \
|
||||
{ 0xacf8dc46, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRUINT16_CONTRACTID "@mozilla.org/supports-PRUint16;1"
|
||||
|
||||
#define NS_SUPPORTS_PRUINT32_CID \
|
||||
{ 0xacf8dc47, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRUINT32_CONTRACTID "@mozilla.org/supports-PRUint32;1"
|
||||
|
||||
#define NS_SUPPORTS_PRUINT64_CID \
|
||||
{ 0xacf8dc48, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRUINT64_CONTRACTID "@mozilla.org/supports-PRUint64;1"
|
||||
|
||||
#define NS_SUPPORTS_PRTIME_CID \
|
||||
{ 0xacf8dc49, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRTIME_CONTRACTID "@mozilla.org/supports-PRTime;1"
|
||||
|
||||
#define NS_SUPPORTS_CHAR_CID \
|
||||
{ 0xacf8dc4a, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_CHAR_CONTRACTID "@mozilla.org/supports-char;1"
|
||||
|
||||
#define NS_SUPPORTS_PRINT16_CID \
|
||||
{ 0xacf8dc4b, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRINT16_CONTRACTID "@mozilla.org/supports-PRInt16;1"
|
||||
|
||||
#define NS_SUPPORTS_PRINT32_CID \
|
||||
{ 0xacf8dc4c, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRINT32_CONTRACTID "@mozilla.org/supports-PRInt32;1"
|
||||
|
||||
#define NS_SUPPORTS_PRINT64_CID \
|
||||
{ 0xacf8dc4d, 0x4a25, 0x11d3, \
|
||||
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
#define NS_SUPPORTS_PRINT64_CONTRACTID "@mozilla.org/supports-PRInt64;1"
|
||||
|
||||
#define NS_SUPPORTS_FLOAT_CID \
|
||||
{ 0xcbf86870, 0x4ac0, 0x11d3, \
|
||||
{ 0xba, 0xea, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
|
||||
#define NS_SUPPORTS_FLOAT_CONTRACTID "@mozilla.org/supports-float;1"
|
||||
|
||||
#define NS_SUPPORTS_DOUBLE_CID \
|
||||
{ 0xcbf86871, 0x4ac0, 0x11d3, \
|
||||
{ 0xba, 0xea, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
|
||||
#define NS_SUPPORTS_DOUBLE_CONTRACTID "@mozilla.org/supports-double;1"
|
||||
|
||||
#define NS_SUPPORTS_VOID_CID \
|
||||
{ 0xaf10f3e0, 0x568d, 0x11d3, \
|
||||
{ 0xba, 0xf8, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
|
||||
#define NS_SUPPORTS_VOID_CONTRACTID "@mozilla.org/supports-void;1"
|
||||
|
||||
#define NS_SUPPORTS_INTERFACE_POINTER_CID \
|
||||
{ 0xA99FEBBA, 0x1DD1, 0x11B2, \
|
||||
{ 0xA9, 0x43, 0xB0, 0x23, 0x34, 0xA6, 0xD0, 0x83 } }
|
||||
#define NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID "@mozilla.org/supports-interface-pointer;1"
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,169 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsXPComPrivate_h__
|
||||
#define nsXPComPrivate_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsXPCOM.h"
|
||||
/**
|
||||
* Private Method to register an exit routine. This method
|
||||
* allows you to setup a callback that will be called from
|
||||
* the NS_ShutdownXPCOM function after all services and
|
||||
* components have gone away.
|
||||
*
|
||||
* This API is for the exclusive use of the xpcom glue library.
|
||||
*
|
||||
* Note that these APIs are NOT threadsafe and must be called on the
|
||||
* main thread.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param exitRoutine pointer to user defined callback function
|
||||
* of type XPCOMExitRoutine.
|
||||
* @param priority higher priorities are called before lower
|
||||
* priorities.
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure.
|
||||
*
|
||||
*/
|
||||
typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
||||
|
||||
extern "C" NS_COM nsresult
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
||||
|
||||
extern "C" NS_COM nsresult
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
|
||||
|
||||
|
||||
// PUBLIC
|
||||
typedef nsresult (PR_CALLBACK *InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
|
||||
typedef nsresult (PR_CALLBACK *ShutdownFunc)(nsIServiceManager* servMgr);
|
||||
typedef nsresult (PR_CALLBACK *GetServiceManagerFunc)(nsIServiceManager* *result);
|
||||
typedef nsresult (PR_CALLBACK *GetComponentManagerFunc)(nsIComponentManager* *result);
|
||||
typedef nsresult (PR_CALLBACK *GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
|
||||
typedef nsresult (PR_CALLBACK *GetMemoryManagerFunc)(nsIMemory* *result);
|
||||
typedef nsresult (PR_CALLBACK *NewLocalFileFunc)(const nsAString &path, PRBool followLinks, nsILocalFile* *result);
|
||||
typedef nsresult (PR_CALLBACK *NewNativeLocalFileFunc)(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
|
||||
// PRIVATE
|
||||
typedef nsresult (PR_CALLBACK *RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
||||
typedef nsresult (PR_CALLBACK *UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
|
||||
|
||||
typedef struct XPCOMFunctions{
|
||||
PRUint32 version;
|
||||
PRUint32 size;
|
||||
|
||||
InitFunc init;
|
||||
ShutdownFunc shutdown;
|
||||
GetServiceManagerFunc getServiceManager;
|
||||
GetComponentManagerFunc getComponentManager;
|
||||
GetComponentRegistrarFunc getComponentRegistrar;
|
||||
GetMemoryManagerFunc getMemoryManager;
|
||||
NewLocalFileFunc newLocalFile;
|
||||
NewNativeLocalFileFunc newNativeLocalFile;
|
||||
|
||||
RegisterXPCOMExitRoutineFunc registerExitRoutine;
|
||||
UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
|
||||
} XPCOMFunctions;
|
||||
|
||||
typedef nsresult (PR_CALLBACK *GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
|
||||
extern "C" NS_COM nsresult
|
||||
NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
||||
|
||||
// think hard before changing this
|
||||
#define XPCOM_GLUE_VERSION 1
|
||||
|
||||
|
||||
/* XPCOM Specific Defines
|
||||
*
|
||||
* XPCOM_DLL - name of the loadable xpcom library on disk.
|
||||
* XPCOM_SEARCH_KEY - name of the environment variable that can be
|
||||
* modified to include additional search paths.
|
||||
* GRE_CONF_NAME - Name of the GRE Configuration file
|
||||
*/
|
||||
|
||||
#if defined(XP_WIN32) || defined(XP_OS2)
|
||||
|
||||
#define XPCOM_DLL "xpcom.dll"
|
||||
#define XPCOM_SEARCH_KEY "PATH"
|
||||
#define GRE_CONF_NAME "gre.config"
|
||||
#define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE\\"
|
||||
|
||||
#elif defined(XP_MAC)
|
||||
|
||||
#define XPCOM_SEARCH_KEY "PATH"
|
||||
#define GRE_CONF_NAME "gre.config"
|
||||
#define GRE_CONF_PATH ":Macintosh HD:gre.conf"
|
||||
#define XPCOM_DLL "xpcom.shlb"
|
||||
|
||||
#elif defined(XP_BEOS)
|
||||
|
||||
#define XPCOM_SEARCH_KEY "ADDON_PATH"
|
||||
#define GRE_CONF_NAME ".gre.config"
|
||||
#define GRE_CONF_PATH "/boot/home/config/settings/GRE/gre.conf"
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
|
||||
#else // Unix
|
||||
|
||||
// you have to love apple..
|
||||
#ifdef XP_MACOSX
|
||||
#define XPCOM_DLL "libxpcom.bundle"
|
||||
#define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
|
||||
#else
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
||||
#endif
|
||||
|
||||
#define GRE_CONF_NAME ".gre.config"
|
||||
#define GRE_CONF_PATH "/etc/gre.conf"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR ":"
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR "\\"
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR "/"
|
||||
#else
|
||||
#error need_to_define_your_file_path_separator_and_illegal_characters
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,853 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nscore.h"
|
||||
#include "prlink.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsObserverList.h"
|
||||
#include "nsObserver.h"
|
||||
#include "nsObserverService.h"
|
||||
#include "nsProperties.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsPersistentProperties.h"
|
||||
#include "nsScriptableInputStream.h"
|
||||
|
||||
#include "nsMemoryImpl.h"
|
||||
#include "nsErrorService.h"
|
||||
#include "nsArena.h"
|
||||
#include "nsByteBuffer.h"
|
||||
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsSupportsPrimitives.h"
|
||||
#include "nsConsoleService.h"
|
||||
#include "nsExceptionService.h"
|
||||
|
||||
#include "nsComponentManager.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsGenericFactory.h"
|
||||
|
||||
#include "nsEventQueueService.h"
|
||||
#include "nsEventQueue.h"
|
||||
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsProxyEventPrivate.h" // access to the impl of nsProxyObjectManager for the generic factory registration.
|
||||
|
||||
#include "xptinfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
|
||||
#include "nsTimerImpl.h"
|
||||
#include "TimerThread.h"
|
||||
|
||||
#include "nsThread.h"
|
||||
#include "nsProcess.h"
|
||||
|
||||
#include "nsEmptyEnumerator.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsLocalFile.h"
|
||||
#if defined(XP_UNIX) || defined(XP_OS2)
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#endif
|
||||
#include "nsDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsCategoryManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsMultiplexInputStream.h"
|
||||
|
||||
#include "nsFastLoadService.h"
|
||||
|
||||
#include "nsAtomService.h"
|
||||
#include "nsAtomTable.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsTimelineService.h"
|
||||
|
||||
#include "nsVariant.h"
|
||||
|
||||
#ifdef GC_LEAK_DETECTOR
|
||||
#include "nsLeakDetector.h"
|
||||
#endif
|
||||
#include "nsRecyclingAllocator.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
// Registry Factory creation function defined in nsRegistry.cpp
|
||||
// We hook into this function locally to create and register the registry
|
||||
// Since noone outside xpcom needs to know about this and nsRegistry.cpp
|
||||
// does not have a local include file, we are putting this definition
|
||||
// here rather than in nsIRegistry.h
|
||||
extern "C" NS_EXPORT nsresult NS_RegistryGetFactory(nsIFactory** aFactory);
|
||||
extern nsresult NS_CategoryManagerGetFactory( nsIFactory** );
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void _FreeAutoLockStatics();
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess);
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
// ds/nsISupportsPrimitives
|
||||
#define NS_SUPPORTS_ID_CLASSNAME "Supports ID"
|
||||
#define NS_SUPPORTS_CSTRING_CLASSNAME "Supports String"
|
||||
#define NS_SUPPORTS_STRING_CLASSNAME "Supports WString"
|
||||
#define NS_SUPPORTS_PRBOOL_CLASSNAME "Supports PRBool"
|
||||
#define NS_SUPPORTS_PRUINT8_CLASSNAME "Supports PRUint8"
|
||||
#define NS_SUPPORTS_PRUINT16_CLASSNAME "Supports PRUint16"
|
||||
#define NS_SUPPORTS_PRUINT32_CLASSNAME "Supports PRUint32"
|
||||
#define NS_SUPPORTS_PRUINT64_CLASSNAME "Supports PRUint64"
|
||||
#define NS_SUPPORTS_PRTIME_CLASSNAME "Supports PRTime"
|
||||
#define NS_SUPPORTS_CHAR_CLASSNAME "Supports Char"
|
||||
#define NS_SUPPORTS_PRINT16_CLASSNAME "Supports PRInt16"
|
||||
#define NS_SUPPORTS_PRINT32_CLASSNAME "Supports PRInt32"
|
||||
#define NS_SUPPORTS_PRINT64_CLASSNAME "Supports PRInt64"
|
||||
#define NS_SUPPORTS_FLOAT_CLASSNAME "Supports float"
|
||||
#define NS_SUPPORTS_DOUBLE_CLASSNAME "Supports double"
|
||||
#define NS_SUPPORTS_VOID_CLASSNAME "Supports void"
|
||||
#define NS_SUPPORTS_INTERFACE_POINTER_CLASSNAME "Supports interface pointer"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsIDImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsStringImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCStringImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRBoolImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint8Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint16Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint32Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint64Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRTimeImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCharImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt16Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt32Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt64Impl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloatImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDoubleImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsVoidImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointerImpl)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsArray);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConsoleService);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExceptionService);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerManager);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRecyclingAllocatorImpl);
|
||||
|
||||
#ifdef MOZ_TIMELINE
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimelineService);
|
||||
#endif
|
||||
|
||||
static NS_METHOD
|
||||
nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
||||
const nsIID& aIID,
|
||||
void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim(dont_AddRef(XPTI_GetInterfaceInfoManager()));
|
||||
if (!iim) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return iim->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
RegisterGenericFactory(nsIComponentManager* compMgr,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIGenericFactory* fact;
|
||||
rv = NS_NewGenericFactory(&fact, info);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// what I want to do here is QI for a Component Registration Manager. Since this
|
||||
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
|
||||
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(compMgr, &rv);
|
||||
if (registrar)
|
||||
rv = registrar->RegisterFactory(info->mCID,
|
||||
info->mDescription,
|
||||
info->mContractID,
|
||||
fact);
|
||||
NS_RELEASE(fact);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// in order to support the installer, we need
|
||||
// to be told out of band if we should cause
|
||||
// an autoregister. if a file exists named
|
||||
// ".autoreg" next to the application, this
|
||||
// will signal us to cause autoreg.
|
||||
static PRBool CheckAndRemoveUpdateFile()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIProperties> directoryService;
|
||||
nsDirectoryService::Create(nsnull,
|
||||
NS_GET_IID(nsIProperties),
|
||||
getter_AddRefs(directoryService));
|
||||
|
||||
if (!directoryService)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(file));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Getting NS_XPCOM_CURRENT_PROCESS_DIR failed");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
file->AppendNative(nsDependentCString(".autoreg"));
|
||||
|
||||
PRBool exists = PR_FALSE;
|
||||
file->Exists(&exists);
|
||||
if (!exists)
|
||||
return exists;
|
||||
|
||||
file->Remove(PR_FALSE);
|
||||
return exists;
|
||||
}
|
||||
|
||||
|
||||
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
|
||||
nsIProperties *gDirectoryService = NULL;
|
||||
PRBool gXPCOMShuttingDown = PR_FALSE;
|
||||
|
||||
// If XPCOM is unloaded, we need a way to ensure that all statics have been
|
||||
// reinitalized when reloading. Here we create a boolean which is initialized
|
||||
// to true. During shutdown, this boolean with set to false. When we startup,
|
||||
// this boolean will be checked and if the value is not true, startup will fail.
|
||||
static PRBool gXPCOMHasGlobalsBeenInitalized = PR_TRUE;
|
||||
|
||||
// For each class that wishes to support nsIClassInfo, add a line like this
|
||||
// NS_DECL_CLASSINFO(nsMyClass)
|
||||
|
||||
#define COMPONENT(NAME, Ctor) \
|
||||
{ NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor }
|
||||
|
||||
#define COMPONENT_CI(NAME, Ctor, Class) \
|
||||
{ NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor, \
|
||||
NULL, NULL, NULL, NS_CI_INTERFACE_GETTER_NAME(Class), NULL, \
|
||||
&NS_CLASSINFO_NAME(Class) }
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
// ugh
|
||||
#define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1"
|
||||
#define NS_MEMORY_CLASSNAME "Global Memory Service"
|
||||
COMPONENT(MEMORY, nsMemoryImpl::Create),
|
||||
#define NS_ERRORSERVICE_CLASSNAME NS_ERRORSERVICE_NAME
|
||||
COMPONENT(ERRORSERVICE, nsErrorService::Create),
|
||||
|
||||
COMPONENT(ARENA, ArenaImpl::Create),
|
||||
COMPONENT(BYTEBUFFER, ByteBufferImpl::Create),
|
||||
COMPONENT(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create),
|
||||
|
||||
#define NS_PROPERTIES_CLASSNAME "Properties"
|
||||
COMPONENT(PROPERTIES, nsProperties::Create),
|
||||
|
||||
#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */
|
||||
COMPONENT(PERSISTENTPROPERTIES, nsPersistentProperties::Create),
|
||||
|
||||
COMPONENT(SUPPORTSARRAY, nsSupportsArray::Create),
|
||||
COMPONENT(ARRAY, nsArrayConstructor),
|
||||
COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor),
|
||||
COMPONENT(EXCEPTIONSERVICE, nsExceptionServiceConstructor),
|
||||
COMPONENT(ATOMSERVICE, nsAtomServiceConstructor),
|
||||
#ifdef MOZ_TIMELINE
|
||||
COMPONENT(TIMELINESERVICE, nsTimelineServiceConstructor),
|
||||
#endif
|
||||
COMPONENT(OBSERVER, nsObserver::Create),
|
||||
COMPONENT(OBSERVERSERVICE, nsObserverService::Create),
|
||||
COMPONENT(GENERICFACTORY, nsGenericFactory::Create),
|
||||
COMPONENT(EVENTQUEUESERVICE, nsEventQueueServiceImpl::Create),
|
||||
COMPONENT(EVENTQUEUE, nsEventQueueImpl::Create),
|
||||
COMPONENT(THREAD, nsThread::Create),
|
||||
COMPONENT(THREADPOOL, nsThreadPool::Create),
|
||||
|
||||
#define NS_XPCOMPROXY_CID NS_PROXYEVENT_MANAGER_CID
|
||||
COMPONENT(XPCOMPROXY, nsProxyObjectManager::Create),
|
||||
|
||||
COMPONENT(TIMER, nsTimerImplConstructor),
|
||||
COMPONENT(TIMERMANAGER, nsTimerManagerConstructor),
|
||||
|
||||
#define COMPONENT_SUPPORTS(TYPE, Type) \
|
||||
COMPONENT(SUPPORTS_##TYPE, nsSupports##Type##ImplConstructor)
|
||||
|
||||
COMPONENT_SUPPORTS(ID, ID),
|
||||
COMPONENT_SUPPORTS(STRING, String),
|
||||
COMPONENT_SUPPORTS(CSTRING, CString),
|
||||
COMPONENT_SUPPORTS(PRBOOL, PRBool),
|
||||
COMPONENT_SUPPORTS(PRUINT8, PRUint8),
|
||||
COMPONENT_SUPPORTS(PRUINT16, PRUint16),
|
||||
COMPONENT_SUPPORTS(PRUINT32, PRUint32),
|
||||
COMPONENT_SUPPORTS(PRUINT64, PRUint64),
|
||||
COMPONENT_SUPPORTS(PRTIME, PRTime),
|
||||
COMPONENT_SUPPORTS(CHAR, Char),
|
||||
COMPONENT_SUPPORTS(PRINT16, PRInt16),
|
||||
COMPONENT_SUPPORTS(PRINT32, PRInt32),
|
||||
COMPONENT_SUPPORTS(PRINT64, PRInt64),
|
||||
COMPONENT_SUPPORTS(FLOAT, Float),
|
||||
COMPONENT_SUPPORTS(DOUBLE, Double),
|
||||
COMPONENT_SUPPORTS(VOID, Void),
|
||||
COMPONENT_SUPPORTS(INTERFACE_POINTER, InterfacePointer),
|
||||
|
||||
#undef COMPONENT_SUPPORTS
|
||||
#define NS_LOCAL_FILE_CLASSNAME "Local File Specification"
|
||||
COMPONENT(LOCAL_FILE, nsLocalFile::nsLocalFileConstructor),
|
||||
#define NS_DIRECTORY_SERVICE_CLASSNAME "nsIFile Directory Service"
|
||||
COMPONENT(DIRECTORY_SERVICE, nsDirectoryService::Create),
|
||||
COMPONENT(PROCESS, nsProcessConstructor),
|
||||
|
||||
COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor),
|
||||
COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor),
|
||||
|
||||
COMPONENT(FASTLOADSERVICE, nsFastLoadService::Create),
|
||||
COMPONENT(VARIANT, nsVariantConstructor),
|
||||
COMPONENT(INTERFACEINFOMANAGER_SERVICE, nsXPTIInterfaceInfoManagerGetSingleton),
|
||||
|
||||
COMPONENT(RECYCLINGALLOCATOR, nsRecyclingAllocatorImplConstructor),
|
||||
};
|
||||
|
||||
#undef COMPONENT
|
||||
|
||||
const int components_length = sizeof(components) / sizeof(components[0]);
|
||||
|
||||
// gMemory will be freed during shutdown.
|
||||
static nsIMemory* gMemory = nsnull;
|
||||
nsresult NS_COM NS_GetMemoryManager(nsIMemory* *result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!gMemory)
|
||||
{
|
||||
rv = nsMemoryImpl::Create(nsnull,
|
||||
NS_GET_IID(nsIMemory),
|
||||
(void**)&gMemory);
|
||||
}
|
||||
NS_IF_ADDREF(*result = gMemory);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
|
||||
nsIFile* binDirectory)
|
||||
{
|
||||
return NS_InitXPCOM2(result, binDirectory, nsnull);
|
||||
}
|
||||
|
||||
nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
nsIFile* binDirectory,
|
||||
nsIDirectoryServiceProvider* appFileLocationProvider)
|
||||
{
|
||||
|
||||
if (!gXPCOMHasGlobalsBeenInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// We are not shutting down
|
||||
gXPCOMShuttingDown = PR_FALSE;
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
nsTraceRefcnt::Startup();
|
||||
#endif
|
||||
|
||||
// Establish the main thread here.
|
||||
rv = nsIThread::SetMainThread();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Startup the memory manager
|
||||
rv = nsMemoryImpl::Startup();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_OS2)
|
||||
NS_StartupNativeCharsetUtils();
|
||||
#endif
|
||||
NS_StartupLocalFile();
|
||||
|
||||
StartupSpecialSystemDirectory();
|
||||
|
||||
// Start the directory service so that the component manager init can use it.
|
||||
rv = nsDirectoryService::Create(nsnull,
|
||||
NS_GET_IID(nsIProperties),
|
||||
(void**)&gDirectoryService);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDirectoryService> dirService = do_QueryInterface(gDirectoryService, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = dirService->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Create the Component/Service Manager
|
||||
nsComponentManagerImpl *compMgr = NULL;
|
||||
|
||||
if (nsComponentManagerImpl::gComponentManager == NULL)
|
||||
{
|
||||
compMgr = new nsComponentManagerImpl();
|
||||
if (compMgr == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(compMgr);
|
||||
|
||||
nsCOMPtr<nsIFile> xpcomLib;
|
||||
|
||||
PRBool value;
|
||||
if (binDirectory)
|
||||
{
|
||||
rv = binDirectory->IsDirectory(&value);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value) {
|
||||
gDirectoryService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, binDirectory);
|
||||
binDirectory->Clone(getter_AddRefs(xpcomLib));
|
||||
}
|
||||
}
|
||||
else {
|
||||
gDirectoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(xpcomLib));
|
||||
}
|
||||
|
||||
if (xpcomLib) {
|
||||
xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
|
||||
gDirectoryService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);
|
||||
}
|
||||
|
||||
if (appFileLocationProvider) {
|
||||
rv = dirService->RegisterProvider(appFileLocationProvider);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
rv = compMgr->Init();
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_RELEASE(compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsComponentManagerImpl::gComponentManager = compMgr;
|
||||
|
||||
if (result) {
|
||||
nsIServiceManager *serviceManager =
|
||||
NS_STATIC_CAST(nsIServiceManager*, compMgr);
|
||||
|
||||
NS_ADDREF(*result = serviceManager);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMemory> memory;
|
||||
NS_GetMemoryManager(getter_AddRefs(memory));
|
||||
// dougt - these calls will be moved into a new interface when nsIComponentManager is frozen.
|
||||
rv = compMgr->RegisterService(kMemoryCID, memory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef GC_LEAK_DETECTOR
|
||||
rv = NS_InitLeakDetector();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
// 2. Register the global services with the component manager so that
|
||||
// clients can create new objects.
|
||||
|
||||
// Registry
|
||||
nsIFactory *registryFactory = NULL;
|
||||
rv = NS_RegistryGetFactory(®istryFactory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||
|
||||
rv = compMgr->RegisterFactory(kRegistryCID,
|
||||
NS_REGISTRY_CLASSNAME,
|
||||
NS_REGISTRY_CONTRACTID,
|
||||
registryFactory, PR_TRUE);
|
||||
NS_RELEASE(registryFactory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Category Manager
|
||||
{
|
||||
nsCOMPtr<nsIFactory> categoryManagerFactory;
|
||||
if ( NS_FAILED(rv = NS_CategoryManagerGetFactory(getter_AddRefs(categoryManagerFactory))) )
|
||||
return rv;
|
||||
|
||||
NS_DEFINE_CID(kCategoryManagerCID, NS_CATEGORYMANAGER_CID);
|
||||
|
||||
rv = compMgr->RegisterFactory(kCategoryManagerCID,
|
||||
NS_CATEGORYMANAGER_CLASSNAME,
|
||||
NS_CATEGORYMANAGER_CONTRACTID,
|
||||
categoryManagerFactory,
|
||||
PR_TRUE);
|
||||
if ( NS_FAILED(rv) ) return rv;
|
||||
}
|
||||
|
||||
for (int i = 0; i < components_length; i++)
|
||||
RegisterGenericFactory(compMgr, &components[i]);
|
||||
|
||||
rv = nsComponentManagerImpl::gComponentManager->ReadPersistentRegistry();
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("No Persistent Registry Found.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( NS_FAILED(rv) || CheckAndRemoveUpdateFile()) {
|
||||
// if we find no persistent registry, we will try to autoregister
|
||||
// the default components directory.
|
||||
nsComponentManagerImpl::gComponentManager->AutoRegister(nsnull);
|
||||
|
||||
// If the application is using a GRE, then,
|
||||
// auto register components in the GRE directory as well.
|
||||
//
|
||||
// The application indicates that it's using an GRE by
|
||||
// returning a valid nsIFile when queried (via appFileLocProvider)
|
||||
// for the NS_GRE_DIR atom as shown below
|
||||
//
|
||||
|
||||
if ( appFileLocationProvider ) {
|
||||
nsCOMPtr<nsIFile> greDir;
|
||||
PRBool persistent = PR_TRUE;
|
||||
|
||||
appFileLocationProvider->GetFile(NS_GRE_COMPONENT_DIR, &persistent, getter_AddRefs(greDir));
|
||||
|
||||
if (greDir)
|
||||
{
|
||||
#ifdef DEBUG_dougt
|
||||
printf("start - Registering GRE components\n");
|
||||
#endif
|
||||
rv = nsComponentManagerImpl::gComponentManager->AutoRegister(greDir);
|
||||
|
||||
#ifdef DEBUG_dougt
|
||||
printf("end - Registering GRE components\n");
|
||||
#endif
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_ERROR("Could not AutoRegister GRE components");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pay the cost at startup time of starting this singleton.
|
||||
nsIInterfaceInfoManager* iim = XPTI_GetInterfaceInfoManager();
|
||||
NS_IF_RELEASE(iim);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> eventQService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));
|
||||
if ( NS_FAILED(rv) ) return rv;
|
||||
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
if ( NS_FAILED(rv) ) return rv;
|
||||
|
||||
// Notify observers of xpcom autoregistration start
|
||||
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_OBSERVER_ID,
|
||||
nsnull,
|
||||
NS_XPCOM_STARTUP_OBSERVER_ID);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
static nsVoidArray* gExitRoutines;
|
||||
|
||||
static void CallExitRoutines()
|
||||
{
|
||||
if (!gExitRoutines)
|
||||
return;
|
||||
|
||||
PRInt32 count = gExitRoutines->Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
XPCOMExitRoutine func = (XPCOMExitRoutine) gExitRoutines->ElementAt(i);
|
||||
func();
|
||||
}
|
||||
gExitRoutines->Clear();
|
||||
delete gExitRoutines;
|
||||
gExitRoutines = nsnull;
|
||||
}
|
||||
|
||||
nsresult NS_COM
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority)
|
||||
{
|
||||
// priority are not used right now. It will need to be implemented as more
|
||||
// classes are moved into the glue library --dougt
|
||||
if (!gExitRoutines) {
|
||||
gExitRoutines = new nsVoidArray();
|
||||
if (!gExitRoutines) {
|
||||
NS_WARNING("Failed to allocate gExitRoutines");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool okay = gExitRoutines->AppendElement((void*)exitRoutine);
|
||||
return okay ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult NS_COM
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
|
||||
{
|
||||
if (!gExitRoutines)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool okay = gExitRoutines->RemoveElement((void*)exitRoutine);
|
||||
return okay ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NS_ShutdownXPCOM()
|
||||
//
|
||||
// The shutdown sequence for xpcom would be
|
||||
//
|
||||
// - Release the Global Service Manager
|
||||
// - Release all service instances held by the global service manager
|
||||
// - Release the Global Service Manager itself
|
||||
// - Release the Component Manager
|
||||
// - Release all factories cached by the Component Manager
|
||||
// - Unload Libraries
|
||||
// - Release Contractid Cache held by Component Manager
|
||||
// - Release dll abstraction held by Component Manager
|
||||
// - Release the Registry held by Component Manager
|
||||
// - Finally, release the component manager itself
|
||||
//
|
||||
nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr)
|
||||
{
|
||||
|
||||
// Notify observers of xpcom shutting down
|
||||
nsresult rv = NS_OK;
|
||||
{
|
||||
// Block it so that the COMPtr will get deleted before we hit
|
||||
// servicemanager shutdown
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
rv = NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
(void) observerService->NotifyObservers(mgr,
|
||||
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// grab the event queue so that we can process events one last time before exiting
|
||||
nsCOMPtr <nsIEventQueue> currentQ;
|
||||
{
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
|
||||
if (eventQService) {
|
||||
eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(currentQ));
|
||||
}
|
||||
}
|
||||
// XPCOM is officially in shutdown mode NOW
|
||||
// Set this only after the observers have been notified as this
|
||||
// will cause servicemanager to become inaccessible.
|
||||
gXPCOMShuttingDown = PR_TRUE;
|
||||
|
||||
#ifdef DEBUG_dougt
|
||||
fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
|
||||
#endif
|
||||
// We may have AddRef'd for the caller of NS_InitXPCOM, so release it
|
||||
// here again:
|
||||
NS_IF_RELEASE(servMgr);
|
||||
|
||||
// Shutdown global servicemanager
|
||||
if (nsComponentManagerImpl::gComponentManager) {
|
||||
nsComponentManagerImpl::gComponentManager->FreeServices();
|
||||
}
|
||||
nsServiceManager::ShutdownGlobalServiceManager(nsnull);
|
||||
|
||||
if (currentQ) {
|
||||
currentQ->ProcessPendingEvents();
|
||||
currentQ = 0;
|
||||
}
|
||||
|
||||
nsProxyObjectManager::Shutdown();
|
||||
|
||||
// Release the directory service
|
||||
NS_IF_RELEASE(gDirectoryService);
|
||||
|
||||
// Shutdown nsLocalFile string conversion
|
||||
NS_ShutdownLocalFile();
|
||||
#ifdef XP_UNIX
|
||||
NS_ShutdownNativeCharsetUtils();
|
||||
#endif
|
||||
|
||||
// Shutdown the timer thread and all timers that might still be alive before
|
||||
// shutting down the component manager
|
||||
nsTimerImpl::Shutdown();
|
||||
|
||||
CallExitRoutines();
|
||||
|
||||
// Shutdown xpcom. This will release all loaders and cause others holding
|
||||
// a refcount to the component manager to release it.
|
||||
if (nsComponentManagerImpl::gComponentManager) {
|
||||
rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
|
||||
} else
|
||||
NS_WARNING("Component Manager was never created ...");
|
||||
|
||||
// Release our own singletons
|
||||
// Do this _after_ shutting down the component manager, because the
|
||||
// JS component loader will use XPConnect to call nsIModule::canUnload,
|
||||
// and that will spin up the InterfaceInfoManager again -- bad mojo
|
||||
XPTI_FreeInterfaceInfoManager();
|
||||
|
||||
// Finally, release the component manager last because it unloads the
|
||||
// libraries:
|
||||
if (nsComponentManagerImpl::gComponentManager) {
|
||||
nsrefcnt cnt;
|
||||
NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);
|
||||
NS_WARN_IF_FALSE(cnt == 0, "Component Manager being held past XPCOM shutdown.");
|
||||
}
|
||||
nsComponentManagerImpl::gComponentManager = nsnull;
|
||||
|
||||
#ifdef DEBUG
|
||||
_FreeAutoLockStatics();
|
||||
#endif
|
||||
|
||||
ShutdownSpecialSystemDirectory();
|
||||
|
||||
EmptyEnumeratorImpl::Shutdown();
|
||||
nsMemoryImpl::Shutdown();
|
||||
NS_IF_RELEASE(gMemory);
|
||||
|
||||
nsThread::Shutdown();
|
||||
NS_PurgeAtomTable();
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
nsTraceRefcnt::DumpStatistics();
|
||||
nsTraceRefcnt::ResetStatistics();
|
||||
nsTraceRefcnt::Shutdown();
|
||||
#endif
|
||||
|
||||
#ifdef GC_LEAK_DETECTOR
|
||||
// Shutdown the Leak detector.
|
||||
NS_ShutdownLeakDetector();
|
||||
#endif
|
||||
|
||||
gXPCOMHasGlobalsBeenInitalized = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_COM PR_CALLBACK
|
||||
NS_GetFrozenFunctions(XPCOMFunctions *functions, const char* libraryPath)
|
||||
{
|
||||
if (!functions)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (functions->version != XPCOM_GLUE_VERSION)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRLibrary *xpcomLib = nsnull;
|
||||
xpcomLib = PR_LoadLibrary(libraryPath);
|
||||
if (!xpcomLib)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
functions->init = (InitFunc) PR_FindSymbol(xpcomLib, "NS_InitXPCOM2");
|
||||
if (! functions->init) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->shutdown = (ShutdownFunc) PR_FindSymbol(xpcomLib, "NS_ShutdownXPCOM");
|
||||
if (! functions->shutdown) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->getServiceManager = (GetServiceManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetServiceManager");
|
||||
if (! functions->getServiceManager) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->getComponentManager = (GetComponentManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetComponentManager");
|
||||
if (! functions->getComponentManager) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->getComponentRegistrar = (GetComponentRegistrarFunc) PR_FindSymbol(xpcomLib, "NS_GetComponentRegistrar");
|
||||
if (! functions->getComponentRegistrar) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->getMemoryManager = (GetMemoryManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetMemoryManager");
|
||||
if (! functions->getMemoryManager) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->newLocalFile = (NewLocalFileFunc) PR_FindSymbol(xpcomLib, "NS_NewLocalFile");
|
||||
if (! functions->newLocalFile) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->newNativeLocalFile = (NewNativeLocalFileFunc)PR_FindSymbol(xpcomLib, "NS_NewNativeLocalFile");
|
||||
if (! functions->newNativeLocalFile) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->registerExitRoutine = (RegisterXPCOMExitRoutineFunc) PR_FindSymbol(xpcomLib, "NS_RegisterXPCOMExitRoutine");
|
||||
if (! functions->registerExitRoutine) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
functions->unregisterExitRoutine = (UnregisterXPCOMExitRoutineFunc) PR_FindSymbol(xpcomLib, "NS_UnregisterXPCOMExitRoutine");
|
||||
if (! functions->unregisterExitRoutine) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PR_UnloadLibrary(xpcomLib); // the library is refcnt'ed above by the caller.
|
||||
xpcomLib = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,252 +0,0 @@
|
||||
LIBRARY xpcom
|
||||
DESCRIPTION "xpcom library"
|
||||
|
||||
EXPORTS
|
||||
?Stub3@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub4@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub5@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub6@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub7@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub8@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub9@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub10@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub11@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub12@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub13@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub14@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub15@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub16@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub17@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub18@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub19@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub20@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub21@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub22@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub23@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub24@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub25@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub26@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub27@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub28@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub29@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub30@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub31@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub32@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub33@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub34@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub35@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub36@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub37@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub38@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub39@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub40@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub41@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub42@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub43@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub44@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub45@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub46@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub47@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub48@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub49@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub50@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub51@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub52@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub53@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub54@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub55@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub56@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub57@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub58@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub59@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub60@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub61@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub62@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub63@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub64@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub65@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub66@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub67@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub68@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub69@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub70@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub71@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub72@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub73@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub74@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub75@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub76@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub77@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub78@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub79@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub80@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub81@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub82@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub83@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub84@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub85@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub86@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub87@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub88@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub89@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub90@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub91@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub92@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub93@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub94@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub95@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub96@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub97@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub98@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub99@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub100@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub101@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub102@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub103@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub104@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub105@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub106@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub107@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub108@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub109@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub110@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub111@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub112@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub113@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub114@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub115@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub116@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub117@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub118@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub119@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub120@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub121@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub122@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub123@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub124@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub125@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub126@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub127@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub128@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub129@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub130@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub131@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub132@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub133@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub134@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub135@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub136@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub137@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub138@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub139@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub140@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub141@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub142@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub143@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub144@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub145@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub146@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub147@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub148@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub149@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub150@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub151@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub152@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub153@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub154@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub155@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub156@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub157@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub158@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub159@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub160@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub161@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub162@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub163@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub164@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub165@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub166@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub167@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub168@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub169@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub170@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub171@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub172@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub173@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub174@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub175@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub176@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub177@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub178@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub179@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub180@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub181@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub182@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub183@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub184@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub185@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub186@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub187@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub188@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub189@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub190@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub191@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub192@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub193@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub194@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub195@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub196@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub197@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub198@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub199@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub200@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub201@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub202@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub203@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub204@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub205@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub206@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub207@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub208@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub209@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub210@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub211@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub212@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub213@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub214@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub215@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub216@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub217@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub218@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub219@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub220@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub221@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub222@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub223@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub224@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub225@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub226@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub227@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub228@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub229@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub230@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub231@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub232@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub233@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub234@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub235@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub236@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub237@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub238@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub239@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub240@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub241@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub242@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub243@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub244@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub245@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub246@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub247@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub248@nsXPTCStubBase@@UAAIXZ
|
||||
?Stub249@nsXPTCStubBase@@UAAIXZ
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
nsIRegistryUtils.h
|
||||
nsXPComFactory.h
|
||||
nsComponentManagerUtils.h
|
||||
nsCategoryManagerUtils.h
|
||||
nsStaticComponent.h
|
||||
nsIServiceManagerObsolete.h
|
||||
nsIServiceManagerUtils.h
|
||||
nsComponentManagerObsolete.h
|
||||
nsIComponentManagerUtils.h
|
||||
nsObsoleteModuleLoading.h
|
||||
@@ -1,10 +0,0 @@
|
||||
nsICategoryManager.idl
|
||||
nsIClassInfo.idl
|
||||
nsIComponentLoader.idl
|
||||
nsIComponentLoaderManager.idl
|
||||
nsIComponentManager.idl
|
||||
nsIComponentManagerObsolete.idl
|
||||
nsIComponentRegistrar.idl
|
||||
nsIFactory.idl
|
||||
nsIRegistry.idl
|
||||
nsIServiceManager.idl
|
||||
@@ -1,98 +0,0 @@
|
||||
#
|
||||
# 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 = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpcom
|
||||
XPIDL_MODULE = xpcom_components
|
||||
LIBRARY_NAME = xpcomcomponents_s
|
||||
GRE_MODULE = 1
|
||||
|
||||
REQUIRES = libreg \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsCategoryManager.cpp \
|
||||
nsComponentManager.cpp \
|
||||
nsComponentManagerObsolete.cpp \
|
||||
nsNativeComponentLoader.cpp \
|
||||
nsRegistry.cpp \
|
||||
nsServiceManagerObsolete.cpp \
|
||||
xcDll.cpp \
|
||||
$(NULL)
|
||||
|
||||
# XXX not really right.
|
||||
ifdef MOZ_STATIC_COMPONENT_LIBS
|
||||
CPPSRCS += nsStaticComponentLoader.cpp
|
||||
DEFINES += -DENABLE_STATIC_COMPONENT_LOADER=1
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsCategoryManagerUtils.h \
|
||||
nsComponentManagerUtils.h \
|
||||
nsComponentManagerObsolete.h \
|
||||
nsIRegistryUtils.h \
|
||||
nsIServiceManagerUtils.h \
|
||||
nsIServiceManagerObsolete.h \
|
||||
nsXPComFactory.h \
|
||||
nsNativeComponentLoader.h \
|
||||
nsStaticComponent.h \
|
||||
nsObsoleteModuleLoading.h \
|
||||
xcDll.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIComponentLoader.idl \
|
||||
nsIComponentLoaderManager.idl \
|
||||
nsIComponentManagerObsolete.idl \
|
||||
nsIRegistry.idl \
|
||||
$(NULL)
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIClassInfo.idl \
|
||||
nsIComponentRegistrar.idl \
|
||||
nsIFactory.idl \
|
||||
nsIModule.idl \
|
||||
nsIServiceManager.idl \
|
||||
nsIComponentManager.idl \
|
||||
nsICategoryManager.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../base -I$(srcdir)/../thread -I$(srcdir)/../ds
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_COM -DEXPORT_XPTI_API
|
||||
|
||||
|
||||
@@ -1,513 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott Collins <scc@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsSupportsPrimitives.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsComponentManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsHashtableEnumerator.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
|
||||
|
||||
/*
|
||||
CategoryDatabase
|
||||
contains 0 or more 1-1 mappings of string to Category
|
||||
each Category contains 0 or more 1-1 mappings of string keys to string values
|
||||
|
||||
In other words, the CategoryDatabase is a tree, whose root is a hashtable.
|
||||
Internal nodes (or Categories) are hashtables.
|
||||
Leaf nodes are strings.
|
||||
*/
|
||||
|
||||
// this function is not public yet, hence it is externed here.
|
||||
extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result);
|
||||
|
||||
|
||||
static
|
||||
NS_IMETHODIMP
|
||||
ExtractKeyString( nsHashKey* key, void*, void*, nsISupports** _retval )
|
||||
/*
|
||||
...works with |nsHashtableEnumerator| to make the hash keys enumerable.
|
||||
*/
|
||||
{
|
||||
nsresult status = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupportsCString> obj = new nsSupportsCStringImpl();
|
||||
if ( obj ) {
|
||||
nsCStringKey* strkey = NS_STATIC_CAST(nsCStringKey*, key);
|
||||
status = obj->SetData(nsDependentCString(strkey->GetString(),
|
||||
strkey->GetStringLength()));
|
||||
}
|
||||
|
||||
*_retval = obj;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef nsCString LeafNode;
|
||||
|
||||
/*
|
||||
Our interior nodes are hashtables whose elements are |LeafNode|s,
|
||||
and we need a suitable destruction function to register with a
|
||||
given (interior node) hashtable for destroying its (|LeafNode|) elements.
|
||||
*/
|
||||
static
|
||||
PRBool
|
||||
Destroy_LeafNode( nsHashKey*, void* aElement, void* )
|
||||
{
|
||||
delete NS_STATIC_CAST(LeafNode*, aElement);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
class CategoryNode
|
||||
: public nsObjectHashtable
|
||||
{
|
||||
public:
|
||||
CategoryNode()
|
||||
: nsObjectHashtable((nsHashtableCloneElementFunc) 0, 0,
|
||||
(nsHashtableEnumFunc) Destroy_LeafNode, 0 )
|
||||
{
|
||||
// Nothing else to do here...
|
||||
}
|
||||
|
||||
LeafNode* find_leaf( const char* );
|
||||
};
|
||||
|
||||
LeafNode*
|
||||
CategoryNode::find_leaf( const char* aLeafName )
|
||||
{
|
||||
nsCStringKey leafNameKey(aLeafName);
|
||||
return NS_STATIC_CAST(LeafNode*, Get(&leafNameKey));
|
||||
}
|
||||
|
||||
/*
|
||||
We keep a hashtable of hashtables, therefore, we need a suitable
|
||||
destruction function to register with the outer table for destroying
|
||||
elements which are the inner tables.
|
||||
*/
|
||||
static
|
||||
PRBool
|
||||
Destroy_CategoryNode( nsHashKey*, void* aElement, void* )
|
||||
{
|
||||
delete NS_STATIC_CAST(CategoryNode*, aElement);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class nsCategoryManager
|
||||
: public nsICategoryManager,
|
||||
public nsObjectHashtable
|
||||
{
|
||||
private:
|
||||
friend class nsCategoryManagerFactory;
|
||||
nsCategoryManager();
|
||||
|
||||
public:
|
||||
virtual ~nsCategoryManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICATEGORYMANAGER
|
||||
|
||||
private:
|
||||
CategoryNode* find_category( const char* );
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCategoryManager, nsICategoryManager)
|
||||
|
||||
nsCategoryManager::nsCategoryManager()
|
||||
: nsObjectHashtable((nsHashtableCloneElementFunc) 0, 0,
|
||||
(nsHashtableEnumFunc) Destroy_CategoryNode, 0 )
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
nsCategoryManager::~nsCategoryManager()
|
||||
{
|
||||
}
|
||||
|
||||
CategoryNode*
|
||||
nsCategoryManager::find_category( const char* aCategoryName )
|
||||
{
|
||||
nsCStringKey categoryNameKey(aCategoryName);
|
||||
return NS_STATIC_CAST(CategoryNode*, Get(&categoryNameKey));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::GetCategoryEntry( const char *aCategoryName,
|
||||
const char *aEntryName,
|
||||
char **_retval )
|
||||
{
|
||||
NS_ASSERTION(aCategoryName, "aCategoryName is NULL!");
|
||||
NS_ASSERTION(aEntryName, "aEntryName is NULL!");
|
||||
NS_ASSERTION(_retval, "_retval is NULL!");
|
||||
|
||||
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
||||
CategoryNode* category = find_category(aCategoryName);
|
||||
if (category)
|
||||
{
|
||||
nsCStringKey entryKey(aEntryName);
|
||||
LeafNode* entry = NS_STATIC_CAST(LeafNode*, category->Get(&entryKey));
|
||||
if (entry)
|
||||
status = (*_retval = ToNewCString(*entry)) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
|
||||
const char *aEntryName,
|
||||
const char *aValue,
|
||||
PRBool aPersist,
|
||||
PRBool aReplace,
|
||||
char **_retval )
|
||||
{
|
||||
NS_ASSERTION(aCategoryName, "aCategoryName is NULL!");
|
||||
NS_ASSERTION(aEntryName, "aEntryName is NULL!");
|
||||
NS_ASSERTION(aValue, "aValue is NULL!");
|
||||
|
||||
|
||||
/*
|
||||
Note: if |_retval| is |NULL|, I won't bother returning a copy
|
||||
of the replaced value.
|
||||
*/
|
||||
|
||||
if ( _retval )
|
||||
*_retval = 0;
|
||||
|
||||
|
||||
// Before we can insert a new entry, we'll need to
|
||||
// find the |CategoryNode| to put it in...
|
||||
CategoryNode* category;
|
||||
if ( !(category = find_category(aCategoryName)) )
|
||||
{
|
||||
// That category doesn't exist yet; let's make it.
|
||||
category = new CategoryNode;
|
||||
nsCStringKey categoryNameKey(aCategoryName);
|
||||
Put(&categoryNameKey, category);
|
||||
}
|
||||
|
||||
// See if this entry is already in this category
|
||||
LeafNode* entry = category->find_leaf(aEntryName);
|
||||
|
||||
nsresult status = NS_OK;
|
||||
if ( entry )
|
||||
{
|
||||
// If this entry is in the category already,
|
||||
// then you better have said 'replace'!
|
||||
|
||||
if ( aReplace )
|
||||
{
|
||||
// return the value that we're replacing
|
||||
if ( _retval )
|
||||
*_retval = ToNewCString(*entry);
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_INVALID_ARG; // ...stops us from putting the value in
|
||||
}
|
||||
|
||||
// If you didn't say 'replace', and there was already an entry there,
|
||||
// then we can't put your value in (that's why we set |status|, above),
|
||||
// or make it persistent (see below)
|
||||
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
{ // it's OK to put a value in
|
||||
|
||||
// don't leak the entry we're replacing (if any)
|
||||
delete entry;
|
||||
|
||||
// now put in the new vaentrylue
|
||||
entry = new LeafNode(aValue);
|
||||
nsCStringKey entryNameKey(aEntryName);
|
||||
category->Put(&entryNameKey, entry);
|
||||
|
||||
nsCOMPtr<nsIComponentLoaderManager> mgr;
|
||||
NS_GetComponentLoaderManager(getter_AddRefs(mgr));
|
||||
if (mgr)
|
||||
mgr->FlushPersistentStore(PR_FALSE);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
|
||||
const char *aEntryName,
|
||||
PRBool aDontPersist)
|
||||
{
|
||||
|
||||
NS_ASSERTION(aCategoryName, "aCategoryName is NULL!");
|
||||
NS_ASSERTION(aEntryName, "aEntryName is NULL!");
|
||||
|
||||
/*
|
||||
Note: no errors are reported since failure to delete
|
||||
probably won't hurt you, and returning errors seriously
|
||||
inconveniences JS clients
|
||||
*/
|
||||
|
||||
CategoryNode* category = find_category(aCategoryName);
|
||||
if (category)
|
||||
{
|
||||
nsCStringKey entryKey(aEntryName);
|
||||
category->RemoveAndDelete(&entryKey);
|
||||
|
||||
nsCOMPtr<nsIComponentLoaderManager> mgr;
|
||||
NS_GetComponentLoaderManager(getter_AddRefs(mgr));
|
||||
if (mgr)
|
||||
mgr->FlushPersistentStore(PR_FALSE);
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::DeleteCategory( const char *aCategoryName )
|
||||
{
|
||||
NS_ASSERTION(aCategoryName, "aCategoryName is NULL!");
|
||||
|
||||
nsCOMPtr<nsIComponentLoaderManager> mgr;
|
||||
NS_GetComponentLoaderManager(getter_AddRefs(mgr));
|
||||
if (mgr)
|
||||
mgr->FlushPersistentStore(PR_FALSE);
|
||||
|
||||
// QUESTION: consider whether this should be an error
|
||||
nsCStringKey categoryKey(aCategoryName);
|
||||
return RemoveAndDelete(&categoryKey) ? NS_OK : NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
||||
nsISimpleEnumerator **_retval )
|
||||
{
|
||||
NS_ASSERTION(aCategoryName, "aCategoryName is NULL!");
|
||||
NS_ASSERTION(_retval, "_retval is NULL!");
|
||||
|
||||
*_retval = 0;
|
||||
|
||||
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
||||
CategoryNode* category = find_category(aCategoryName);
|
||||
if (category)
|
||||
{
|
||||
status = NS_NewHashtableEnumerator(category, ExtractKeyString, 0, _retval);
|
||||
}
|
||||
|
||||
// If you couldn't find the category, or had trouble creating an enumerator...
|
||||
if ( NS_FAILED(status) )
|
||||
{
|
||||
NS_IF_RELEASE(*_retval);
|
||||
status = NS_NewEmptyEnumerator(_retval);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::EnumerateCategories(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ASSERTION(_retval, "_retval is NULL!");
|
||||
*_retval = 0;
|
||||
|
||||
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
status = NS_NewHashtableEnumerator(this, ExtractKeyString, 0, _retval);
|
||||
|
||||
// If you couldn't find the category, or had trouble creating an
|
||||
// enumerator...
|
||||
if ( NS_FAILED(status) )
|
||||
{
|
||||
NS_IF_RELEASE(*_retval);
|
||||
status = NS_NewEmptyEnumerator(_retval);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
class nsCategoryManagerFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
nsCategoryManagerFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFACTORY
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCategoryManagerFactory, nsIFactory)
|
||||
|
||||
nsCategoryManagerFactory::nsCategoryManagerFactory()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManagerFactory::CreateInstance( nsISupports* aOuter, const nsIID& aIID, void** aResult )
|
||||
{
|
||||
// assert(aResult);
|
||||
|
||||
*aResult = 0;
|
||||
|
||||
nsresult status = NS_OK;
|
||||
if ( aOuter )
|
||||
status = NS_ERROR_NO_AGGREGATION;
|
||||
else
|
||||
{
|
||||
nsCategoryManager* raw_category_manager;
|
||||
nsCOMPtr<nsICategoryManager> new_category_manager = (raw_category_manager = new nsCategoryManager);
|
||||
if ( new_category_manager )
|
||||
status = new_category_manager->QueryInterface(aIID, aResult);
|
||||
else
|
||||
status = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManagerFactory::LockFactory( PRBool )
|
||||
{
|
||||
// Not implemented...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_CategoryManagerGetFactory( nsIFactory** aFactory )
|
||||
{
|
||||
// assert(aFactory);
|
||||
|
||||
nsresult status;
|
||||
|
||||
*aFactory = 0;
|
||||
nsIFactory* new_factory = NS_STATIC_CAST(nsIFactory*, new nsCategoryManagerFactory);
|
||||
if (new_factory)
|
||||
{
|
||||
*aFactory = new_factory;
|
||||
NS_ADDREF(*aFactory);
|
||||
status = NS_OK;
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CreateServicesFromCategory()
|
||||
*
|
||||
* Given a category, this convenience functions enumerates the category and
|
||||
* creates a service of every CID or ContractID registered under the category.
|
||||
* If observerTopic is non null and the service implements nsIObserver,
|
||||
* this will attempt to notify the observer with the origin, observerTopic string
|
||||
* as parameter.
|
||||
*/
|
||||
NS_EXPORT nsresult
|
||||
NS_CreateServicesFromCategory(const char *category,
|
||||
nsISupports *origin,
|
||||
const char *observerTopic)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
int nFailed = 0;
|
||||
nsCOMPtr<nsICategoryManager> categoryManager =
|
||||
do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
if (!categoryManager) return rv;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = categoryManager->EnumerateCategory(category,
|
||||
getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
||||
// From here on just skip any error we get.
|
||||
nsCOMPtr<nsISupportsCString> catEntry = do_QueryInterface(entry, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
nFailed++;
|
||||
continue;
|
||||
}
|
||||
nsCAutoString entryString;
|
||||
rv = catEntry->GetData(entryString);
|
||||
if (NS_FAILED(rv)) {
|
||||
nFailed++;
|
||||
continue;
|
||||
}
|
||||
nsXPIDLCString contractID;
|
||||
rv = categoryManager->GetCategoryEntry(category,entryString.get(), getter_Copies(contractID));
|
||||
if (NS_FAILED(rv)) {
|
||||
nFailed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> instance = do_GetService(contractID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
nFailed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (observerTopic) {
|
||||
// try an observer, if it implements it.
|
||||
nsCOMPtr<nsIObserver> observer = do_QueryInterface(instance, &rv);
|
||||
if (NS_SUCCEEDED(rv) && observer)
|
||||
observer->Observe(origin, observerTopic, NS_LITERAL_STRING("").get());
|
||||
}
|
||||
}
|
||||
return (nFailed ? NS_ERROR_FAILURE : NS_OK);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#define NS_CATEGORYMANAGER_CLASSNAME "Category Manager"
|
||||
|
||||
/* 16d222a6-1dd2-11b2-b693-f38b02c021b2 */
|
||||
#define NS_CATEGORYMANAGER_CID \
|
||||
{ 0x16d222a6, 0x1dd2, 0x11b2, \
|
||||
{0xb6, 0x93, 0xf3, 0x8b, 0x02, 0xc0, 0x21, 0xb2} }
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsCategoryManagerUtils_h__
|
||||
#define nsCategoryManagerUtils_h__
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
NS_COM nsresult
|
||||
NS_CreateServicesFromCategory(const char *category,
|
||||
nsISupports *origin,
|
||||
const char *observerTopic);
|
||||
|
||||
class NS_COM nsCreateInstanceFromCategory : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceFromCategory(const char *aCategory, const char *aEntry,
|
||||
nsISupports *aOuter, nsresult *aErrorPtr)
|
||||
: mCategory(aCategory),
|
||||
mEntry(aEntry),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do;
|
||||
}
|
||||
virtual nsresult operator()( const nsIID& aIID, void** aInstancePtr) const;
|
||||
virtual ~nsCreateInstanceFromCategory() {};
|
||||
|
||||
private:
|
||||
const char *mCategory; // Do not free. This char * is not owned.
|
||||
const char *mEntry; // Do not free. This char * is not owned.
|
||||
|
||||
nsISupports *mOuter;
|
||||
nsresult *mErrorPtr;
|
||||
|
||||
};
|
||||
|
||||
inline
|
||||
const nsCreateInstanceFromCategory
|
||||
do_CreateInstanceFromCategory( const char *aCategory, const char *aEntry,
|
||||
nsresult *aErrorPtr = 0)
|
||||
{
|
||||
return nsCreateInstanceFromCategory(aCategory, aEntry, 0, aErrorPtr);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceFromCategory
|
||||
do_CreateInstanceFromCategory( const char *aCategory, const char *aEntry,
|
||||
nsISupports *aOuter, nsresult *aErrorPtr = 0)
|
||||
{
|
||||
return nsCreateInstanceFromCategory(aCategory, aEntry, aOuter, aErrorPtr);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,356 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsComponentManager_h__
|
||||
#define nsComponentManager_h__
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
|
||||
#include "nsIComponentLoader.h"
|
||||
#include "nsNativeComponentLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIComponentManagerObsolete.h"
|
||||
#include "nsIComponentLoaderManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "pldhash.h"
|
||||
#include "prtime.h"
|
||||
#include "prmon.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIFile.h"
|
||||
#include "plarena.h"
|
||||
|
||||
class nsFactoryEntry;
|
||||
class nsDll;
|
||||
class nsIServiceManager;
|
||||
|
||||
|
||||
// Predefined loader types. Do not change the numbers.
|
||||
// NATIVE should be 0 as it is being used as the first array index.
|
||||
#define NS_COMPONENT_TYPE_NATIVE 0
|
||||
#define NS_COMPONENT_TYPE_FACTORY_ONLY -1
|
||||
// this define means that the factory entry only has a ContractID
|
||||
// to service mapping and has no cid mapping.
|
||||
#define NS_COMPONENT_TYPE_SERVICE_ONLY -2
|
||||
|
||||
extern const char XPCOM_LIB_PREFIX[];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Array of Loaders and their type strings
|
||||
struct nsLoaderdata {
|
||||
nsIComponentLoader *loader;
|
||||
const char *type;
|
||||
};
|
||||
|
||||
class nsComponentManagerImpl
|
||||
: public nsIComponentManager,
|
||||
public nsIServiceManager,
|
||||
public nsIComponentRegistrar,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIComponentLoaderManager,
|
||||
public nsIServiceManagerObsolete,
|
||||
public nsIComponentManagerObsolete
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// Since the nsIComponentManagerObsolete and nsIComponentManager share some of the
|
||||
// same interface function names, we have to manually define the functions here.
|
||||
// The only function that is in nsIComponentManagerObsolete and is in nsIComponentManager
|
||||
// is GetClassObjectContractID.
|
||||
//
|
||||
// nsIComponentManager function not in nsIComponentManagerObsolete:
|
||||
NS_IMETHOD GetClassObjectByContractID(const char *aContractID,
|
||||
const nsIID &aIID,
|
||||
void **_retval);
|
||||
|
||||
|
||||
NS_DECL_NSICOMPONENTMANAGEROBSOLETE
|
||||
|
||||
// Since the nsIComponentManagerObsolete and nsIComponentRegistrar share some of the
|
||||
// same interface function names, we have to manually define the functions here.
|
||||
// the only fuction that is shared is UnregisterFactory
|
||||
NS_IMETHOD AutoRegister(nsIFile *aSpec);
|
||||
NS_IMETHOD AutoUnregister(nsIFile *aSpec);
|
||||
NS_IMETHOD RegisterFactory(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFactory *aFactory);
|
||||
// NS_IMETHOD UnregisterFactory(const nsCID & aClass, nsIFactory *aFactory);
|
||||
NS_IMETHOD RegisterFactoryLocation(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFile *aFile, const char *loaderStr, const char *aType);
|
||||
NS_IMETHOD UnregisterFactoryLocation(const nsCID & aClass, nsIFile *aFile);
|
||||
NS_IMETHOD IsCIDRegistered(const nsCID & aClass, PRBool *_retval);
|
||||
NS_IMETHOD IsContractIDRegistered(const char *aClass, PRBool *_retval);
|
||||
NS_IMETHOD EnumerateCIDs(nsISimpleEnumerator **_retval);
|
||||
NS_IMETHOD EnumerateContractIDs(nsISimpleEnumerator **_retval);
|
||||
NS_IMETHOD CIDToContractID(const nsCID & aClass, char **_retval);
|
||||
NS_IMETHOD ContractIDToCID(const char *aContractID, nsCID * *_retval);
|
||||
|
||||
NS_DECL_NSISERVICEMANAGER
|
||||
NS_DECL_NSISERVICEMANAGEROBSOLETE
|
||||
NS_DECL_NSICOMPONENTLOADERMANAGER
|
||||
|
||||
// nsComponentManagerImpl methods:
|
||||
nsComponentManagerImpl();
|
||||
virtual ~nsComponentManagerImpl();
|
||||
|
||||
static nsComponentManagerImpl* gComponentManager;
|
||||
nsresult Init(void);
|
||||
|
||||
nsresult WritePersistentRegistry();
|
||||
nsresult ReadPersistentRegistry();
|
||||
private:
|
||||
nsresult WriteCategoryManagerToRegistry(PRFileDesc* fd);
|
||||
public:
|
||||
|
||||
nsresult Shutdown(void);
|
||||
|
||||
nsresult FreeServices();
|
||||
|
||||
friend class nsFactoryEntry;
|
||||
friend class nsServiceManager;
|
||||
|
||||
friend nsresult
|
||||
NS_GetService(const char *aContractID, const nsIID& aIID, PRBool aDontCreate, nsISupports** result);
|
||||
|
||||
protected:
|
||||
nsresult RegistryNameForLib(const char *aLibName, char **aRegistryName);
|
||||
nsresult RegisterComponentCommon(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
const char *aRegistryName,
|
||||
PRBool aReplace, PRBool aPersist,
|
||||
const char *aType);
|
||||
nsresult GetLoaderForType(int aType,
|
||||
nsIComponentLoader **aLoader);
|
||||
nsresult FindFactory(const char *contractID, nsIFactory **aFactory) ;
|
||||
nsresult LoadFactory(nsFactoryEntry *aEntry, nsIFactory **aFactory);
|
||||
|
||||
nsFactoryEntry *GetFactoryEntry(const char *aContractID);
|
||||
nsFactoryEntry *GetFactoryEntry(const nsCID &aClass);
|
||||
nsFactoryEntry *GetFactoryEntry(const nsCID &aClass, nsIDKey &cidKey);
|
||||
|
||||
nsresult SyncComponentsInDir(PRInt32 when, nsIFile *dirSpec);
|
||||
nsresult SelfRegisterDll(nsDll *dll);
|
||||
nsresult SelfUnregisterDll(nsDll *dll);
|
||||
nsresult HashContractID(const char *acontractID, nsFactoryEntry *fe_ptr);
|
||||
nsresult HashContractID(const char *acontractID, const nsCID &aClass, nsFactoryEntry **fe_ptr = NULL);
|
||||
nsresult HashContractID(const char *acontractID, const nsCID &aClass, nsIDKey &cidKey, nsFactoryEntry **fe_ptr = NULL);
|
||||
|
||||
void DeleteContractIDEntriesByCID(const nsCID* aClass, const char*registryName);
|
||||
void DeleteContractIDEntriesByCID(const nsCID* aClass, nsIFactory* factory);
|
||||
|
||||
nsresult UnloadLibraries(nsIServiceManager *servmgr, PRInt32 when);
|
||||
|
||||
// Convert a loader type string into an index into the loader data
|
||||
// array. Empty loader types are converted to NATIVE. Returns -1 if
|
||||
// loader type cannot be determined.
|
||||
int GetLoaderType(const char *typeStr);
|
||||
|
||||
// Add a loader type if not already known. Return the typeIndex
|
||||
// if the loader type is either added or already there; -1 if
|
||||
// there was an error
|
||||
int AddLoaderType(const char *typeStr);
|
||||
|
||||
private:
|
||||
nsresult AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec, PRBool fileIsCompDir=PR_TRUE);
|
||||
|
||||
protected:
|
||||
PLDHashTable mFactories;
|
||||
PLDHashTable mContractIDs;
|
||||
PRMonitor* mMon;
|
||||
|
||||
nsNativeComponentLoader *mNativeComponentLoader;
|
||||
nsIComponentLoader *mStaticComponentLoader;
|
||||
nsCOMPtr<nsIFile> mComponentsDir;
|
||||
PRInt32 mComponentsOffset;
|
||||
|
||||
// Shutdown
|
||||
#define NS_SHUTDOWN_NEVERHAPPENED 0
|
||||
#define NS_SHUTDOWN_INPROGRESS 1
|
||||
#define NS_SHUTDOWN_COMPLETE 2
|
||||
PRUint32 mShuttingDown;
|
||||
|
||||
nsLoaderdata *mLoaderData;
|
||||
int mNLoaderData;
|
||||
int mMaxNLoaderData;
|
||||
|
||||
PRBool mRegistryDirty;
|
||||
nsVoidArray mAutoRegEntries;
|
||||
nsCOMPtr<nsICategoryManager> mCategoryManager;
|
||||
|
||||
PLArenaPool mArena;
|
||||
};
|
||||
|
||||
|
||||
#define NS_MAX_FILENAME_LEN 1024
|
||||
|
||||
#define NS_ERROR_IS_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 24)
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
/* The default registry on the unix system is $HOME/.mozilla/registry per
|
||||
* vr_findGlobalRegName(). vr_findRegFile() will create the registry file
|
||||
* if it doesn't exist. But it wont create directories.
|
||||
*
|
||||
* Hence we need to create the directory if it doesn't exist already.
|
||||
*
|
||||
* Why create it here as opposed to the app ?
|
||||
* ------------------------------------------
|
||||
* The app cannot create the directory in main() as most of the registry
|
||||
* and initialization happens due to use of static variables.
|
||||
* And we dont want to be dependent on the order in which
|
||||
* these static stuff happen.
|
||||
*
|
||||
* Permission for the $HOME/.mozilla will be Read,Write,Execute
|
||||
* for user only. Nothing to group and others.
|
||||
*/
|
||||
#define NS_MOZILLA_DIR_NAME ".mozilla"
|
||||
#define NS_MOZILLA_DIR_PERMISSION 00700
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#ifdef XP_BEOS
|
||||
#define NS_MOZILLA_DIR_NAME "Mozilla"
|
||||
#define NS_MOZILLA_DIR_PERMISSION 00700
|
||||
#endif /* XP_BEOS */
|
||||
|
||||
/**
|
||||
* When using the registry we put a version number in it.
|
||||
* If the version number that is in the registry doesn't match
|
||||
* the following, we ignore the registry. This lets news versions
|
||||
* of the software deal with old formats of registry and not
|
||||
*
|
||||
* alpha0.20 : First time we did versioning
|
||||
* alpha0.30 : Changing autoreg to begin registration from ./components on unix
|
||||
* alpha0.40 : repository -> component manager
|
||||
* alpha0.50 : using nsIRegistry
|
||||
* alpha0.60 : xpcom 2.0 landing
|
||||
* alpha0.70 : using nsIFileSpec. PRTime -> PRUint32
|
||||
* alpha0.90 : using nsIComponentLoader, abs:/rel:/lib:, shaver-cleanup
|
||||
* alpha0.92 : restructured registry keys
|
||||
* alpha0.93 : changed component names to native strings instead of UTF8
|
||||
*/
|
||||
#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.93"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Class: nsFactoryEntry()
|
||||
*
|
||||
* There are two types of FactoryEntries.
|
||||
*
|
||||
* 1. {CID, dll} mapping.
|
||||
* Factory is a consequence of the dll. These can be either session
|
||||
* specific or persistent based on whether we write this
|
||||
* to the registry or not.
|
||||
*
|
||||
* 2. {CID, factory} mapping
|
||||
* These are strictly session specific and in memory only.
|
||||
*/
|
||||
|
||||
class nsFactoryEntry {
|
||||
public:
|
||||
nsFactoryEntry(const nsCID &aClass, const char *location, int aType);
|
||||
nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory);
|
||||
~nsFactoryEntry();
|
||||
|
||||
nsresult ReInit(const nsCID &aClass, const char *location, int aType);
|
||||
nsresult ReInit(const nsCID &aClass, nsIFactory *aFactory);
|
||||
|
||||
nsresult GetFactory(nsIFactory **aFactory,
|
||||
nsComponentManagerImpl * mgr) {
|
||||
if (factory) {
|
||||
*aFactory = factory.get();
|
||||
NS_ADDREF(*aFactory);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (typeIndex < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIComponentLoader> loader;
|
||||
rv = mgr->GetLoaderForType(typeIndex, getter_AddRefs(loader));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = loader->GetFactory(cid, location, mgr->mLoaderData[typeIndex].type, aFactory);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
factory = do_QueryInterface(*aFactory);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCID cid;
|
||||
char *location;
|
||||
nsCOMPtr<nsIFactory> factory;
|
||||
// This is an index into the mLoaderData array that holds the type string and the loader
|
||||
int typeIndex;
|
||||
nsCOMPtr<nsISupports> mServiceObject;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct nsFactoryTableEntry : public PLDHashEntryHdr {
|
||||
nsFactoryEntry *mFactoryEntry;
|
||||
};
|
||||
|
||||
struct nsContractIDTableEntry : public PLDHashEntryHdr {
|
||||
char *mContractID;
|
||||
nsFactoryEntry *mFactoryEntry;
|
||||
};
|
||||
class AutoRegEntry
|
||||
{
|
||||
public:
|
||||
AutoRegEntry(){};
|
||||
AutoRegEntry(const char* name, PRInt64* modDate);
|
||||
virtual ~AutoRegEntry();
|
||||
|
||||
char* GetName() {return mName;}
|
||||
PRInt64 GetDate() {return mModDate;}
|
||||
void SetDate(PRInt64 *date) { mModDate = *date;}
|
||||
PRBool Modified(PRInt64 *date);
|
||||
|
||||
private:
|
||||
char* mName;
|
||||
PRInt64 mModDate;
|
||||
};
|
||||
#endif // nsComponentManager_h__
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 XPCOM
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Global Static Component Manager Methods
|
||||
// (for when you need to link with xpcom)
|
||||
|
||||
#include "nsIComponentManagerObsolete.h"
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
|
||||
|
||||
nsresult
|
||||
nsComponentManager::Initialize(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->FindFactory(aClass, aFactory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::GetClassObject(const nsCID &aClass, const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->GetClassObject(aClass, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::ContractIDToClassID(const char *aContractID,
|
||||
nsCID *aClass)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->ContractIDToClassID(aContractID, aClass);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CLSIDToContractID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aContractID)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CLSIDToContractID(*aClass, aClassName, aContractID);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CreateInstance(aClass, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CreateInstance(const char *aContractID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CreateInstanceByContractID(aContractID, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterFactory(aClass, aClassName, aContractID,
|
||||
aFactory, aReplace);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
const char *aLibraryPersistentDescriptor,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterComponent(aClass, aClassName, aContractID,
|
||||
aLibraryPersistentDescriptor, aReplace, aPersist);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterComponentSpec(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
nsIFile *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterComponentSpec(aClass, aClassName, aContractID,
|
||||
aLibrary, aReplace, aPersist);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterComponentLib(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
const char *adllName,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterComponentLib(aClass, aClassName, aContractID,
|
||||
adllName, aReplace, aPersist);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterFactory(aClass, aFactory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterComponent(aClass, aLibrary);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterComponentSpec(const nsCID &aClass,
|
||||
nsIFile *aLibrarySpec)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterComponentSpec(aClass, aLibrarySpec);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::FreeLibraries(void)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->FreeLibraries();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::AutoRegister(PRInt32 when, nsIFile *directory)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->AutoRegister(when, directory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::AutoRegisterComponent(PRInt32 when,
|
||||
nsIFile *fullname)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->AutoRegisterComponent(when, fullname);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::AutoUnregisterComponent(PRInt32 when,
|
||||
nsIFile *fullname)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->AutoUnregisterComponent(when, fullname);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::IsRegistered(const nsCID &aClass,
|
||||
PRBool *aRegistered)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->IsRegistered(aClass, aRegistered);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::EnumerateCLSIDs(nsIEnumerator** aEnumerator)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->EnumerateCLSIDs(aEnumerator);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::EnumerateContractIDs(nsIEnumerator** aEnumerator)
|
||||
{
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->EnumerateContractIDs(aEnumerator);
|
||||
}
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 XPCOM
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsComponentManagerObsolete_h___
|
||||
#define nsComponentManagerObsolete_h___
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentManagerObsolete.h"
|
||||
|
||||
class nsIEnumerator;
|
||||
class nsIFactory;
|
||||
class nsIFile;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//
|
||||
// Functions, classes, interfaces and types in this file are
|
||||
// obsolete. Use at your own risk.
|
||||
// Please see nsIComponentManager.idl for the supported interface
|
||||
// to the component manager.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// God save me from this evilness. Below is a very bad
|
||||
// function. Its out var is really a nsIComponentManagerObsolete
|
||||
// but it has been cast to a nsIComponentManager.
|
||||
// The reason for such uglyness is that this function is require for
|
||||
// backward compatiblity of some plugins. This funciton will
|
||||
// be removed at some point.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_GetGlobalComponentManager(nsIComponentManager* *result);
|
||||
|
||||
|
||||
|
||||
|
||||
class NS_COM nsComponentManager {
|
||||
public:
|
||||
static nsresult Initialize(void);
|
||||
|
||||
// Finds a factory for a specific class ID
|
||||
static nsresult FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory);
|
||||
|
||||
// Get the singleton class object that implements the CID aClass
|
||||
static nsresult GetClassObject(const nsCID &aClass, const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Finds a class ID for a specific Program ID
|
||||
static nsresult ContractIDToClassID(const char *aContractID,
|
||||
nsCID *aClass);
|
||||
|
||||
// Finds a Program ID for a specific class ID
|
||||
// caller frees the result with delete[]
|
||||
static nsresult CLSIDToContractID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aContractID);
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
static nsresult CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Convenience routine, creates a class instance for a specific ContractID
|
||||
static nsresult CreateInstance(const char *aContractID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Manually registry a factory for a class
|
||||
static nsresult RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace);
|
||||
|
||||
// Manually register a dynamically loaded component.
|
||||
// The libraryPersistentDescriptor is what gets passed to the library
|
||||
// self register function from ComponentManager. The format of this string
|
||||
// is the same as nsIFile::GetPath()
|
||||
//
|
||||
// This function will go away in favour of RegisterComponentSpec. In fact,
|
||||
// it internally turns around and calls RegisterComponentSpec.
|
||||
static nsresult RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
const char *aLibraryPersistentDescriptor,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist);
|
||||
|
||||
// Register a component using its FileSpec as its identification
|
||||
// This is the more prevalent use.
|
||||
static nsresult RegisterComponentSpec(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
nsIFile *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist);
|
||||
|
||||
// Register a component using its dllName. This could be a dll name with
|
||||
// no path so that LD_LIBRARY_PATH on unix or PATH on win can load it. Or
|
||||
// this could be a code fragment name on the Mac.
|
||||
static nsresult RegisterComponentLib(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aContractID,
|
||||
const char *adllName,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist);
|
||||
|
||||
|
||||
// Manually unregister a factory for a class
|
||||
static nsresult UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
static nsresult UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
static nsresult UnregisterComponentSpec(const nsCID &aClass,
|
||||
nsIFile *aLibrarySpec);
|
||||
|
||||
// Unload dynamically loaded factories that are not in use
|
||||
static nsresult FreeLibraries(void);
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// DLL registration support
|
||||
|
||||
// If directory is NULL, then AutoRegister will try registering components
|
||||
// in the default components directory.
|
||||
static nsresult AutoRegister(PRInt32 when, nsIFile* directory);
|
||||
static nsresult AutoRegisterComponent(PRInt32 when, nsIFile *component);
|
||||
static nsresult AutoUnregisterComponent(PRInt32 when, nsIFile *component);
|
||||
|
||||
// Is the given CID currently registered?
|
||||
static nsresult IsRegistered(const nsCID &aClass,
|
||||
PRBool *aRegistered);
|
||||
|
||||
// Get an enumeration of all the CIDs
|
||||
static nsresult EnumerateCLSIDs(nsIEnumerator** aEmumerator);
|
||||
|
||||
// Get an enumeration of all the ContractIDs
|
||||
static nsresult EnumerateContractIDs(nsIEnumerator** aEmumerator);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,177 +0,0 @@
|
||||
/* -*- 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 "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsComponentManagerUtils_h__
|
||||
#define nsComponentManagerUtils_h__
|
||||
|
||||
/*
|
||||
* Do not include this file directly. Instead,
|
||||
* |#include "nsIComponentManager.h"|.
|
||||
*/
|
||||
|
||||
#ifndef nsCOMPtr_h__
|
||||
#include "nsCOMPtr.h"
|
||||
#endif
|
||||
|
||||
#ifndef nsComponentManagerObsolete_h___
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
#endif
|
||||
|
||||
#define NS_COMPONENTMANAGER_CID \
|
||||
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x91775d60, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr )
|
||||
: mCID(aCID),
|
||||
mOuter(aOuter),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const nsCID& mCID;
|
||||
nsISupports* mOuter;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
class NS_COM nsCreateInstanceByContractID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr )
|
||||
: mContractID(aContractID),
|
||||
mOuter(aOuter),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const char* mContractID;
|
||||
nsISupports* mOuter;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByCID
|
||||
do_CreateInstance( const nsCID& aCID, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByCID(aCID, 0, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByCID
|
||||
do_CreateInstance( const nsCID& aCID, nsISupports* aOuter, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByCID(aCID, aOuter, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByContractID
|
||||
do_CreateInstance( const char* aContractID, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByContractID(aContractID, 0, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByContractID
|
||||
do_CreateInstance( const char* aContractID, nsISupports* aOuter, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByContractID(aContractID, aOuter, error);
|
||||
}
|
||||
|
||||
// type-safe shortcuts for calling |CreateInstance|
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const nsCID &aClass,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const char *aContractID,
|
||||
nsISupports *aDelegate,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID,
|
||||
aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const char *aContractID,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
/* keys for registry use */
|
||||
extern const char xpcomKeyName[];
|
||||
extern const char xpcomComponentsKeyName[];
|
||||
extern const char lastModValueName[];
|
||||
extern const char fileSizeValueName[];
|
||||
extern const char nativeComponentType[];
|
||||
extern const char staticComponentType[];
|
||||
|
||||
#endif /* nsComponentManagerUtils_h__ */
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
|
||||
/*
|
||||
* nsICategoryManager
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3275b2cd-af6d-429a-80d7-f0c5120342ac)]
|
||||
interface nsICategoryManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the value for the given category's entry.
|
||||
* @param aCategory The name of the category ("protocol")
|
||||
* @param aEntry The entry you're looking for ("http")
|
||||
* @return The value.
|
||||
*/
|
||||
string getCategoryEntry(in string aCategory, in string aEntry);
|
||||
|
||||
/**
|
||||
* Add an entry to a category.
|
||||
* @param aCategory The name of the category ("protocol")
|
||||
* @param aEntry The entry to be added ("http")
|
||||
* @param aValue The value for the entry ("moz.httprulez.1")
|
||||
* @param aPersist Should we persist between invocations?
|
||||
* @param aReplace Should we replace an existing entry?
|
||||
* @return Previous entry, if any
|
||||
*/
|
||||
string addCategoryEntry(in string aCategory, in string aEntry,
|
||||
in string aValue, in boolean aPersist,
|
||||
in boolean aReplace);
|
||||
|
||||
/**
|
||||
* Delete an entry from the category.
|
||||
* @param aCategory The name of the category ("protocol")
|
||||
* @param aEntry The entry to be added ("http")
|
||||
* @param aPersist Delete entry from registry, if present?
|
||||
*/
|
||||
void deleteCategoryEntry(in string aCategory, in string aEntry,
|
||||
in boolean aPersist);
|
||||
|
||||
/**
|
||||
* Delete a category and all entries.
|
||||
* @param aCategory The category to be deleted.
|
||||
* @param aPersist Delete the category from the registry?
|
||||
*/
|
||||
void deleteCategory(in string aCategory);
|
||||
|
||||
/**
|
||||
* Enumerate the entries in a category.
|
||||
* @param aCategory The category to be enumerated.
|
||||
*/
|
||||
nsISimpleEnumerator enumerateCategory(in string aCategory);
|
||||
|
||||
/**
|
||||
* Enumerate the entries in a category.
|
||||
* @param aCategory The category to be enumerated.
|
||||
*/
|
||||
nsISimpleEnumerator enumerateCategories();
|
||||
};
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; 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 Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* 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):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIProgrammingLanguage.idl"
|
||||
|
||||
/**
|
||||
* Provides information about a specific implementation class
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(986c11d0-f340-11d4-9075-0010a4e73d9a)]
|
||||
interface nsIClassInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get an ordered list of the interface ids that instances of the class
|
||||
* promise to implement. Note that nsISupports is an implicit member
|
||||
* of any such list and need not be included.
|
||||
*
|
||||
* Should set *count = 0 and *array = null and return NS_OK if getting the
|
||||
* list is not supported.
|
||||
*/
|
||||
void getInterfaces(out PRUint32 count,
|
||||
[array, size_is(count), retval] out nsIIDPtr array);
|
||||
|
||||
/**
|
||||
* Get a language mapping specific helper object that may assist in using
|
||||
* objects of this class in a specific lanaguage. For instance, if asked
|
||||
* for the helper for nsIProgrammingLanguage::JAVASCRIPT this might return
|
||||
* an object that can be QI'd into the nsIXPCScriptable interface to assist
|
||||
* XPConnect in supplying JavaScript specific behavior to callers of the
|
||||
* instance object.
|
||||
*
|
||||
* see: nsIProgrammingLanguage.idl
|
||||
*
|
||||
* Should return null if no helper available for given language.
|
||||
*/
|
||||
nsISupports getHelperForLanguage(in PRUint32 language);
|
||||
|
||||
/**
|
||||
* A contract ID through which an instance of this class can be created
|
||||
* (or accessed as a service, if |flags & SINGLETON|), or null.
|
||||
*/
|
||||
readonly attribute string contractID;
|
||||
|
||||
/**
|
||||
* A human readable string naming the class, or null.
|
||||
*/
|
||||
readonly attribute string classDescription;
|
||||
|
||||
/**
|
||||
* A class ID through which an instance of this class can be created
|
||||
* (or accessed as a service, if |flags & SINGLETON|), or null.
|
||||
*/
|
||||
readonly attribute nsCIDPtr classID;
|
||||
|
||||
/**
|
||||
* Return language type from list in nsIProgrammingLanguage
|
||||
*/
|
||||
|
||||
readonly attribute PRUint32 implementationLanguage;
|
||||
|
||||
/**
|
||||
* Bitflags for 'flags' attribute.
|
||||
*/
|
||||
const PRUint32 SINGLETON = 1 << 0;
|
||||
const PRUint32 THREADSAFE = 1 << 1;
|
||||
const PRUint32 MAIN_THREAD_ONLY = 1 << 2;
|
||||
const PRUint32 DOM_OBJECT = 1 << 3;
|
||||
const PRUint32 PLUGIN_OBJECT = 1 << 4;
|
||||
const PRUint32 EAGER_CLASSINFO = 1 << 5;
|
||||
/**
|
||||
* 'flags' attribute bitflag: whether objects of this type implement
|
||||
* nsIContent.
|
||||
*/
|
||||
const PRUint32 CONTENT_NODE = 1 << 6;
|
||||
|
||||
// The high order bit is RESERVED for consumers of these flags.
|
||||
// No implementor of this interface should ever return flags
|
||||
// with this bit set.
|
||||
const PRUint32 RESERVED = 1 << 31;
|
||||
|
||||
|
||||
readonly attribute PRUint32 flags;
|
||||
|
||||
/**
|
||||
* Also a class ID through which an instance of this class can be created
|
||||
* (or accessed as a service, if |flags & SINGLETON|). If the class does
|
||||
* not have a CID, it should return NS_ERROR_NOT_AVAILABLE. This attribute
|
||||
* exists so C++ callers can avoid allocating and freeing a CID, as would
|
||||
* happen if they used classID.
|
||||
*/
|
||||
[notxpcom] readonly attribute nsCID classIDNoAlloc;
|
||||
|
||||
};
|
||||
@@ -1,89 +0,0 @@
|
||||
/* -*- 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 "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIFactory.idl"
|
||||
#include "nsIFile.idl"
|
||||
#include "nsIComponentManager.idl"
|
||||
|
||||
[object, uuid(c073cfc0-567c-11d3-aec1-0000f8e25c06)]
|
||||
interface nsIComponentLoader : nsISupports {
|
||||
|
||||
/**
|
||||
* Get the factory for a given component.
|
||||
*/
|
||||
nsIFactory getFactory(in nsIIDRef aCID, in string aLocation,
|
||||
in string aType);
|
||||
|
||||
/**
|
||||
* Initialize the loader.
|
||||
*
|
||||
* We use nsISupports here because nsIRegistry isn't IDLized yet.
|
||||
*/
|
||||
void init(in nsIComponentManager aCompMgr, in nsISupports aRegistry);
|
||||
|
||||
/**
|
||||
* Called when a component of the appropriate type is registered,
|
||||
* to give the component loader an opportunity to do things like
|
||||
* annotate the registry and such.
|
||||
*/
|
||||
void onRegister(in nsIIDRef aCID, in string aType,
|
||||
in string aClassName, in string aContractID,
|
||||
in string aLocation, in boolean aReplace,
|
||||
in boolean aPersist);
|
||||
|
||||
/**
|
||||
* When is AutoRegistration occuring?
|
||||
*/
|
||||
const long Startup = 0;
|
||||
const long Component = 1;
|
||||
const long Timer = 2;
|
||||
|
||||
/**
|
||||
* AutoRegister components in the given directory.
|
||||
*/
|
||||
void autoRegisterComponents(in long aWhen, in nsIFile aDirectory);
|
||||
|
||||
/**
|
||||
* AutoRegister the given component.
|
||||
*
|
||||
* Returns true if the component was registered, false if it couldn't
|
||||
* attempt to register the component (wrong type) and ``throws'' an
|
||||
* NS_FAILED code if there was an error during registration.
|
||||
*/
|
||||
boolean autoRegisterComponent(in long aWhen, in nsIFile aComponent);
|
||||
|
||||
/**
|
||||
* AutoUnregister the given component.
|
||||
* Returns true if the component was unregistered, false if it coudln't
|
||||
* attempt to unregister the component (not found, wrong type).
|
||||
*/
|
||||
boolean autoUnregisterComponent(in long aWhen, in nsIFile aComponent);
|
||||
|
||||
/**
|
||||
* Register any deferred (NS_ERROR_FACTORY_REGISTER_AGAIN) components.
|
||||
* Return registered-any-components?
|
||||
*/
|
||||
boolean registerDeferredComponents(in long aWhen);
|
||||
|
||||
/**
|
||||
* Unload all components that are willing.
|
||||
*/
|
||||
void unloadAll(in long aWhen);
|
||||
|
||||
};
|
||||
@@ -1,69 +0,0 @@
|
||||
/* ***** 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 XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
/**
|
||||
* The nsIComponentRegistrar interface.
|
||||
* @status EXPERIMENTAL
|
||||
*
|
||||
* USE AT YOUR OWN RISK
|
||||
* USE AT YOUR OWN RISK
|
||||
* USE AT YOUR OWN RISK
|
||||
* USE AT YOUR OWN RISK
|
||||
* USE AT YOUR OWN RISK
|
||||
* USE AT YOUR OWN RISK
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
[scriptable, uuid(fce83d37-a3c0-4e09-ad9f-6842a984dbdf)]
|
||||
interface nsIComponentLoaderManager : nsISupports
|
||||
{
|
||||
boolean hasFileChanged(in nsIFile file, in string loaderString, in PRInt64 modDate);
|
||||
void saveFileInfo(in nsIFile file, in string loaderString, in PRInt64 modDate);
|
||||
void removeFileInfo(in nsIFile file, in string loaderString);
|
||||
void flushPersistentStore(in boolean now);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* The nsIComponentManager interface.
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFactory;
|
||||
|
||||
[scriptable, uuid(a88e5a60-205a-4bb1-94e1-2628daf51eae)]
|
||||
interface nsIComponentManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* getClassObject
|
||||
*
|
||||
* Returns the factory object that can be used to create instances of
|
||||
* CID aClass
|
||||
*
|
||||
* @param aClass The classid of the factory that is being requested
|
||||
*/
|
||||
void getClassObject(in nsCIDRef aClass,
|
||||
in nsIIDRef aIID,
|
||||
[iid_is(aIID),retval] out nsQIResult result);
|
||||
|
||||
/**
|
||||
* getClassObjectByContractID
|
||||
*
|
||||
* Returns the factory object that can be used to create instances of
|
||||
* CID aClass
|
||||
*
|
||||
* @param aClass The classid of the factory that is being requested
|
||||
*/
|
||||
void getClassObjectByContractID(in string aContractID,
|
||||
in nsIIDRef aIID,
|
||||
[iid_is(aIID),retval] out nsQIResult result);
|
||||
|
||||
|
||||
/**
|
||||
* createInstance
|
||||
*
|
||||
* Create an instance of the CID aClass and return the interface aIID.
|
||||
*
|
||||
* @param aClass : ClassID of object instance requested
|
||||
* @param aDelegate : Used for aggregation
|
||||
* @param aIID : IID of interface requested
|
||||
*/
|
||||
void createInstance(in nsCIDRef aClass,
|
||||
in nsISupports aDelegate,
|
||||
in nsIIDRef aIID,
|
||||
[iid_is(aIID),retval] out nsQIResult result);
|
||||
|
||||
/**
|
||||
* createInstanceByContractID
|
||||
*
|
||||
* Create an instance of the CID that implements aContractID and return the
|
||||
* interface aIID.
|
||||
*
|
||||
* @param aContractID : aContractID of object instance requested
|
||||
* @param aDelegate : Used for aggregation
|
||||
* @param aIID : IID of interface requested
|
||||
*/
|
||||
void createInstanceByContractID(in string aContractID,
|
||||
in nsISupports aDelegate,
|
||||
in nsIIDRef aIID,
|
||||
[iid_is(aIID),retval] out nsQIResult result);
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
#ifndef MOZILLA_STRICT_API
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
#endif
|
||||
%} C++
|
||||
@@ -1,332 +0,0 @@
|
||||
/* -*- 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 "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIFactory.idl"
|
||||
|
||||
interface nsIFile;
|
||||
interface nsIEnumerator;
|
||||
|
||||
[scriptable, uuid(8458a740-d5dc-11d2-92fb-00e09805570f)]
|
||||
interface nsIComponentManagerObsolete : nsISupports
|
||||
{
|
||||
/**
|
||||
* findFactory
|
||||
*
|
||||
* Returns the factory object that can be used to create instances of
|
||||
* CID aClass
|
||||
*
|
||||
* @param aClass The classid of the factory that is being requested
|
||||
*/
|
||||
nsIFactory findFactory(in nsCIDRef aClass);
|
||||
|
||||
/**
|
||||
* getClassObject
|
||||
*
|
||||
* @param aClass : CID of the class whose class object is requested
|
||||
* @param aIID : IID of an interface that the class object is known to
|
||||
* to implement. nsISupports and nsIFactory are known to
|
||||
* be implemented by the class object.
|
||||
*/
|
||||
[noscript] voidPtr getClassObject(in nsCIDRef aClass, in nsIIDRef aIID);
|
||||
|
||||
/**
|
||||
* contractIDToClassID
|
||||
*
|
||||
* Get the ClassID for a given ContractID. Many ClassIDs may implement a
|
||||
* ContractID. In such a situation, this returns the preferred ClassID, which
|
||||
* happens to be the last registered ClassID.
|
||||
*
|
||||
* @param aContractID : Contractid for which ClassID is requested
|
||||
* @return aClass : ClassID return
|
||||
*/
|
||||
[notxpcom] nsresult contractIDToClassID(in string aContractID, out nsCID aClass);
|
||||
|
||||
/**
|
||||
* classIDToContractid
|
||||
*
|
||||
* Get the ContractID for a given ClassID. A ClassIDs may implement multiple
|
||||
* ContractIDs. This function return the last registered ContractID.
|
||||
*
|
||||
* @param aClass : ClassID for which ContractID is requested.
|
||||
* @return aClassName : returns class name asssociated with aClass
|
||||
* @return : ContractID last registered for aClass
|
||||
*/
|
||||
string CLSIDToContractID(in nsCIDRef aClass, out string aClassName);
|
||||
|
||||
/**
|
||||
* createInstance
|
||||
*
|
||||
* Create an instance of the CID aClass and return the interface aIID.
|
||||
*
|
||||
* @param aClass : ClassID of object instance requested
|
||||
* @param aDelegate : Used for aggregation
|
||||
* @param aIID : IID of interface requested
|
||||
*/
|
||||
[noscript] voidPtr createInstance(in nsCIDRef aClass,
|
||||
in nsISupports aDelegate,
|
||||
in nsIIDRef aIID);
|
||||
|
||||
/**
|
||||
* createInstanceByContractID
|
||||
*
|
||||
* Create an instance of the CID that implements aContractID and return the
|
||||
* interface aIID. This is a convenience function that effectively does
|
||||
* ContractIDToClassID() followed by CreateInstance().
|
||||
*
|
||||
* @param aContractID : aContractID of object instance requested
|
||||
* @param aDelegate : Used for aggregation
|
||||
* @param aIID : IID of interface requested
|
||||
*/
|
||||
[noscript] voidPtr createInstanceByContractID(in string aContractID,
|
||||
in nsISupports aDelegate,
|
||||
in nsIIDRef IID);
|
||||
/**
|
||||
* registryLocationForSpec
|
||||
*
|
||||
* Given a file specification, return the registry representation of
|
||||
* the filename. Files that are found relative to the components
|
||||
* directory will have a registry representation
|
||||
* "rel:<relative-native-path>" while filenames that are not, will have
|
||||
* "abs:<full-native-path>".
|
||||
*/
|
||||
string registryLocationForSpec(in nsIFile aSpec);
|
||||
|
||||
/**
|
||||
* specForRegistyLocation
|
||||
*
|
||||
* Create a file specification for the registry representation (rel:/abs:)
|
||||
* got via registryLocationForSpec.
|
||||
*/
|
||||
nsIFile specForRegistryLocation(in string aLocation);
|
||||
|
||||
/**
|
||||
* registerFactory
|
||||
*
|
||||
* Register a factory and ContractID associated with CID aClass
|
||||
*
|
||||
* @param aClass : CID of object
|
||||
* @param aClassName : Class Name of CID
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aFactory : Factory that will be registered for CID aClass
|
||||
* @param aReplace : Boolean that indicates whether to replace a previous
|
||||
* registration for the CID aClass.
|
||||
*/
|
||||
void registerFactory(in nsCIDRef aClass, in string aClassName,
|
||||
in string aContractID, in nsIFactory aFactory,
|
||||
in boolean aReplace);
|
||||
|
||||
/**
|
||||
* registerComponent
|
||||
*
|
||||
* Register a native dll module via its registry representation as returned
|
||||
* by registryLocationForSpec() as the container of CID implemenation
|
||||
* aClass and associate aContractID and aClassName to the CID aClass. Native
|
||||
* dll component type is assumed.
|
||||
*
|
||||
* @param aClass : CID implemenation contained in module
|
||||
* @param aClassName : Class name associated with CID aClass
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aLocation : Location of module (dll). Format of this is the
|
||||
* registry representation as returned by
|
||||
* registryLocationForSpec()
|
||||
* @param aReplace : Boolean that indicates whether to replace a previous
|
||||
* module registration for aClass.
|
||||
* @param aPersist : Remember this registration across sessions.
|
||||
*/
|
||||
void registerComponent(in nsCIDRef aClass, in string aClassName,
|
||||
in string aContractID, in string aLocation,
|
||||
in boolean aReplace, in boolean aPersist);
|
||||
|
||||
/**
|
||||
* registerComponentWithType
|
||||
*
|
||||
* Register a module's location via its registry representation
|
||||
* as returned by registryLocationForSpec() as the container of CID implemenation
|
||||
* aClass of type aType and associate aContractID and aClassName to the CID aClass.
|
||||
*
|
||||
* @param aClass : CID implemenation contained in module
|
||||
* @param aClassName : Class name associated with CID aClass
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aSpec : Filename spec for module's location.
|
||||
* @param aLocation : Location of module of type aType. Format of this string
|
||||
* is the registry representation as returned by
|
||||
* registryLocationForSpec()
|
||||
* @param aReplace : Boolean that indicates whether to replace a previous
|
||||
* loader registration for aClass.
|
||||
* @param aPersist : Remember this registration across sessions.
|
||||
* @param aType : Component Type of CID aClass.
|
||||
*/
|
||||
void registerComponentWithType(in nsCIDRef aClass, in string aClassName,
|
||||
in string aContractID, in nsIFile aSpec,
|
||||
in string aLocation, in boolean aReplace,
|
||||
in boolean aPersist, in string aType);
|
||||
|
||||
/**
|
||||
* registerComponentSpec
|
||||
*
|
||||
* Register a native dll module via its file specification as the container
|
||||
* of CID implemenation aClass and associate aContractID and aClassName to the
|
||||
* CID aClass. Native dll component type is assumed.
|
||||
*
|
||||
* @param aClass : CID implemenation contained in module
|
||||
* @param aClassName : Class name associated with CID aClass
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aLibrary : File specification Location of module (dll).
|
||||
* @param aReplace : Boolean that indicates whether to replace a previous
|
||||
* module registration for aClass.
|
||||
* @param aPersist : Remember this registration across sessions.
|
||||
*/
|
||||
void registerComponentSpec(in nsCIDRef aClass, in string aClassName,
|
||||
in string aContractID, in nsIFile aLibrary,
|
||||
in boolean aReplace, in boolean aPersist);
|
||||
|
||||
/**
|
||||
* registerComponentLib
|
||||
*
|
||||
* Register a native dll module via its dll name (not full path) as the
|
||||
* container of CID implemenation aClass and associate aContractID and aClassName
|
||||
* to the CID aClass. Native dll component type is assumed and the system
|
||||
* services will be used to load this dll.
|
||||
*
|
||||
* @param aClass : CID implemenation contained in module
|
||||
* @param aClassName : Class name associated with CID aClass
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aDllNameLocation : Dll name of module.
|
||||
* @param aReplace : Boolean that indicates whether to replace a previous
|
||||
* module registration for aClass.
|
||||
* @param aPersist : Remember this registration across sessions.
|
||||
*/
|
||||
void registerComponentLib(in nsCIDRef aClass, in string aClassName,
|
||||
in string aContractID, in string aDllName,
|
||||
in boolean aReplace, in boolean aPersist);
|
||||
|
||||
/**
|
||||
* unregisterFactory
|
||||
*
|
||||
* Unregister a factory associated with CID aClass.
|
||||
*
|
||||
* @param aClass : ClassID being unregistered
|
||||
* @param aFactory : Factory previously registered to create instances of
|
||||
* ClassID aClass.
|
||||
*/
|
||||
void unregisterFactory(in nsCIDRef aClass, in nsIFactory aFactory);
|
||||
|
||||
/**
|
||||
* unregisterComponent
|
||||
*
|
||||
* Disassociate module aLocation represented as registry location as returned
|
||||
* by registryLocationForSpec() as containing ClassID aClass.
|
||||
*
|
||||
* @param aClass : ClassID being unregistered
|
||||
* @param aLocation : Location of module. Format of this is the registry
|
||||
* representation as returned by registryLocationForSpec().
|
||||
* Components of any type will be unregistered.
|
||||
*/
|
||||
void unregisterComponent(in nsCIDRef aClass, in string aLocation);
|
||||
|
||||
/**
|
||||
* unregisterComponentSpec
|
||||
*
|
||||
* Disassociate module references by file specification aLibrarySpec as
|
||||
* containing ClassID aClass.
|
||||
*/
|
||||
void unregisterComponentSpec(in nsCIDRef aClass, in nsIFile aLibrarySpec);
|
||||
|
||||
/**
|
||||
* freeLibraries
|
||||
*
|
||||
* Enumerates all loaded modules and unloads unused modules.
|
||||
*/
|
||||
void freeLibraries();
|
||||
|
||||
/**
|
||||
* ID values for 'when'
|
||||
*/
|
||||
const long NS_Startup = 0;
|
||||
const long NS_Script = 1;
|
||||
const long NS_Timer = 2;
|
||||
const long NS_Shutdown = 3;
|
||||
|
||||
/**
|
||||
* autoRegister
|
||||
*
|
||||
* Enumerates directory looking for modules of all types and registers
|
||||
* modules who have changed (modtime or size) since the last time
|
||||
* autoRegister() was invoked.
|
||||
*
|
||||
* @param when : ID values of when the call is being made.
|
||||
* @param directory : Directory the will be enumerated.
|
||||
*/
|
||||
void autoRegister(in long when, in nsIFile directory);
|
||||
|
||||
/**
|
||||
* autoRegisterComponent
|
||||
*
|
||||
* Loads module using appropriate loader and gives it an opportunity to
|
||||
* register its CIDs if module's modtime or size changed since the last
|
||||
* time this was called.
|
||||
*
|
||||
* @param when : ID values of when the call is being made.
|
||||
* @param aFileLocation : File specification of module.
|
||||
*/
|
||||
void autoRegisterComponent(in long when, in nsIFile aFileLocation);
|
||||
|
||||
/**
|
||||
* autoUnregisterComponent
|
||||
*
|
||||
* Loads module using approriate loader and gives it an opportunity to
|
||||
* unregister its CIDs
|
||||
*/
|
||||
void autoUnregisterComponent(in long when, in nsIFile aFileLocation);
|
||||
|
||||
/**
|
||||
* isRegistered
|
||||
*
|
||||
* Returns true if a factory or module is registered for CID aClass.
|
||||
*
|
||||
* @param aClass : ClassID queried for registeration
|
||||
* @return : true if a factory or module is registered for CID aClass.
|
||||
* false otherwise.
|
||||
*/
|
||||
boolean isRegistered(in nsCIDRef aClass);
|
||||
|
||||
/**
|
||||
* enumerateCLSIDs
|
||||
*
|
||||
* Enumerate the list of all registered ClassIDs.
|
||||
*
|
||||
* @return : enumerator for ClassIDs.
|
||||
*/
|
||||
nsIEnumerator enumerateCLSIDs();
|
||||
|
||||
/**
|
||||
* enumerateContractIDs
|
||||
*
|
||||
* Enumerate the list of all registered ContractIDs.
|
||||
*
|
||||
* @return : enumerator for ContractIDs.
|
||||
*/
|
||||
nsIEnumerator enumerateContractIDs();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
/* include after the class def'n, because it needs to see it. */
|
||||
#include "nsComponentManagerUtils.h"
|
||||
%} C++
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 XPCOM
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIComponentManagerUtils_h__
|
||||
#define nsIComponentManagerUtils_h__
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,243 +0,0 @@
|
||||
/* ***** 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 XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
/**
|
||||
* The nsIComponentRegistrar interface.
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFile;
|
||||
interface nsIFactory;
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
[scriptable, uuid(2417cbfe-65ad-48a6-b4b6-eb84db174392)]
|
||||
interface nsIComponentRegistrar : nsISupports
|
||||
{
|
||||
/**
|
||||
* autoRegister
|
||||
*
|
||||
* Register a component file or all component files in a directory.
|
||||
*
|
||||
* Component files must have an associated loader and export the required
|
||||
* symbols which this loader defines. For example, if the given file is a
|
||||
* native library (which is built into XPCOM), it must export the symbol
|
||||
* "NSGetModule". Other loaders may have different semantics.
|
||||
*
|
||||
* This method may only be called from the main thread.
|
||||
*
|
||||
* @param aSpec : Filename spec for component file's location. If aSpec
|
||||
* is a directory, then every component file in the
|
||||
* directory will be registered.
|
||||
* If the aSpec is null, then the application component's
|
||||
* directory as defined by NS_XPCOM_COMPONENT_DIR will be
|
||||
* registered (see nsIDirectoryService.idl)
|
||||
*
|
||||
* @return NS_OK : Registration was successful.
|
||||
* NS_ERROR: Method failure.
|
||||
*/
|
||||
void autoRegister(in nsIFile aSpec);
|
||||
|
||||
/**
|
||||
* autoUnregister
|
||||
*
|
||||
* Unregister a component file or all component files in a directory.
|
||||
* This method may only be called from the main thread.
|
||||
*
|
||||
* @param aSpec : Filename spec for component file's location. If aSpec
|
||||
* is a directory, the every component file in the directory
|
||||
* will be registered.
|
||||
* If aSpec is null, then the application component's
|
||||
* directory as defined by NS_XPCOM_COMPONENT_DIR will be
|
||||
* registered. (see nsIDirectoryService.idl)
|
||||
*
|
||||
* @return NS_OK Unregistration was successful.
|
||||
* NS_ERROR* Method failure.
|
||||
*/
|
||||
void autoUnregister(in nsIFile aSpec);
|
||||
|
||||
|
||||
/**
|
||||
* registerFactory
|
||||
*
|
||||
* Register a factory with a given ContractID, CID and Class Name.
|
||||
*
|
||||
* @param aClass : CID of object
|
||||
* @param aClassName : Class Name of CID
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aFactory : Factory that will be registered for CID aClass
|
||||
*
|
||||
* @return NS_OK Registration was successful.
|
||||
* NS_ERROR* method failure.
|
||||
*/
|
||||
void registerFactory(in nsCIDRef aClass,
|
||||
in string aClassName,
|
||||
in string aContractID,
|
||||
in nsIFactory aFactory);
|
||||
|
||||
/**
|
||||
* unregisterFactory
|
||||
*
|
||||
* Unregister a factory associated with CID aClass.
|
||||
*
|
||||
* @param aClass : CID being unregistered
|
||||
* @param aFactory : Factory previously registered to create instances of
|
||||
* CID aClass.
|
||||
*
|
||||
* @return NS_OK Unregistration was successful.
|
||||
* NS_ERROR* Method failure.
|
||||
*/
|
||||
void unregisterFactory(in nsCIDRef aClass,
|
||||
in nsIFactory aFactory);
|
||||
|
||||
/**
|
||||
* registerFactoryLocation
|
||||
*
|
||||
* Register a factory with a given ContractID, CID and Class Name
|
||||
*
|
||||
* @param aClass : CID of object
|
||||
* @param aClassName : Class Name of CID
|
||||
* @param aContractID : ContractID associated with CID aClass
|
||||
* @param aFile : Component File. This file must have an associated
|
||||
* loader and export the required symbols which this
|
||||
* loader specifies.
|
||||
* @param aLoaderStr : Opaque loader specific string. This value is
|
||||
* passed into the nsIModule's registerSelf
|
||||
* callback and must be fowarded unmodified when
|
||||
* registering factories via their location.
|
||||
* @param aType : Component Type of CID aClass. This value is
|
||||
* passed into the nsIModule's registerSelf
|
||||
* callback and must be fowarded unmodified when
|
||||
* registering factories via their location.
|
||||
*
|
||||
* @return NS_OK Registration was successful.
|
||||
* NS_ERROR* Method failure.
|
||||
*/
|
||||
void registerFactoryLocation(in nsCIDRef aClass,
|
||||
in string aClassName,
|
||||
in string aContractID,
|
||||
in nsIFile aFile,
|
||||
in string aLoaderStr,
|
||||
in string aType);
|
||||
|
||||
/**
|
||||
* unregisterFactoryLocation
|
||||
*
|
||||
* Unregister a factory associated with CID aClass.
|
||||
*
|
||||
* @param aClass : CID being unregistered
|
||||
* @param aFile : Component File previously registered
|
||||
*
|
||||
* @return NS_OK Unregistration was successful.
|
||||
* NS_ERROR* Method failure.
|
||||
*/
|
||||
void unregisterFactoryLocation(in nsCIDRef aClass,
|
||||
in nsIFile aFile);
|
||||
|
||||
/**
|
||||
* isCIDRegistered
|
||||
*
|
||||
* Returns true if a factory is registered for the CID.
|
||||
*
|
||||
* @param aClass : CID queried for registeration
|
||||
* @return : true if a factory is registered for CID
|
||||
* false otherwise.
|
||||
*/
|
||||
boolean isCIDRegistered(in nsCIDRef aClass);
|
||||
|
||||
/**
|
||||
* isContractIDRegistered
|
||||
*
|
||||
* Returns true if a factory is registered for the contract id.
|
||||
*
|
||||
* @param aClass : contract id queried for registeration
|
||||
* @return : true if a factory is registered for contract id
|
||||
* false otherwise.
|
||||
*/
|
||||
boolean isContractIDRegistered(in string aContractID);
|
||||
|
||||
/**
|
||||
* enumerateCIDs
|
||||
*
|
||||
* Enumerate the list of all registered CIDs.
|
||||
*
|
||||
* @return : enumerator for CIDs. Elements of the enumeration can be QI'ed
|
||||
* for the nsISupportsID interface. From the nsISupportsID, you
|
||||
* can obtain the actual CID.
|
||||
*/
|
||||
nsISimpleEnumerator enumerateCIDs();
|
||||
|
||||
/**
|
||||
* enumerateContractIDs
|
||||
*
|
||||
* Enumerate the list of all registered ContractIDs.
|
||||
*
|
||||
* @return : enumerator for ContractIDs. Elements of the enumeration can be
|
||||
* QI'ed for the nsISupportsCString interface. From the
|
||||
* nsISupportsCString interface, you can obtain the actual
|
||||
* Contract ID string.
|
||||
*/
|
||||
nsISimpleEnumerator enumerateContractIDs();
|
||||
|
||||
/**
|
||||
* CIDToContractID
|
||||
*
|
||||
* Returns the Contract ID for a given CID, if one exists and is registered.
|
||||
*
|
||||
* @return : Contract ID.
|
||||
*/
|
||||
string CIDToContractID(in nsCIDRef aClass);
|
||||
|
||||
/**
|
||||
* contractIDToCID
|
||||
*
|
||||
* Returns the CID for a given Contract ID, if one exists and is registered.
|
||||
*
|
||||
* @return : Contract ID.
|
||||
*/
|
||||
nsCIDPtr contractIDToCID(in string aContractID);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user