2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:set ts=4 sw=4 et cindent: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsXPComPrivate_h__
|
|
|
|
#define nsXPComPrivate_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsXPCOM.h"
|
|
|
|
#include "nsXPCOMStrings.h"
|
2007-04-24 10:02:51 -07:00
|
|
|
#include "xptcall.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsStringContainer;
|
|
|
|
class nsCStringContainer;
|
|
|
|
class nsIComponentLoader;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* During this shutdown notification all threads which run XPCOM code must
|
|
|
|
* be joined.
|
|
|
|
*/
|
|
|
|
#define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* During this shutdown notification all module loaders must unload XPCOM
|
|
|
|
* modules.
|
|
|
|
*/
|
|
|
|
#define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
|
|
|
|
|
|
|
|
// PUBLIC
|
|
|
|
typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
|
|
|
|
typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr);
|
|
|
|
typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result);
|
|
|
|
typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result);
|
|
|
|
typedef nsresult (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
|
|
|
|
typedef nsresult (* GetMemoryManagerFunc)(nsIMemory* *result);
|
2012-06-05 19:08:30 -07:00
|
|
|
typedef nsresult (* NewLocalFileFunc)(const nsAString &path, bool followLinks, nsIFile* *result);
|
|
|
|
typedef nsresult (* NewNativeLocalFileFunc)(const nsACString &path, bool followLinks, nsIFile* *result);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef nsresult (* GetDebugFunc)(nsIDebug* *result);
|
|
|
|
typedef nsresult (* GetTraceRefcntFunc)(nsITraceRefcnt* *result);
|
|
|
|
|
|
|
|
typedef nsresult (* StringContainerInitFunc)(nsStringContainer&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* StringContainerInit2Func)(nsStringContainer&, const PRUnichar *, uint32_t, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef void (* StringContainerFinishFunc)(nsStringContainer&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint32_t (* StringGetDataFunc)(const nsAString&, const PRUnichar**, bool*);
|
|
|
|
typedef uint32_t (* StringGetMutableDataFunc)(nsAString&, uint32_t, PRUnichar**);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef PRUnichar* (* StringCloneDataFunc)(const nsAString&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* StringSetDataFunc)(nsAString&, const PRUnichar*, uint32_t);
|
|
|
|
typedef nsresult (* StringSetDataRangeFunc)(nsAString&, uint32_t, uint32_t, const PRUnichar*, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsresult (* StringCopyFunc)(nsAString &, const nsAString &);
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef void (* StringSetIsVoidFunc)(nsAString &, const bool);
|
|
|
|
typedef bool (* StringGetIsVoidFunc)(const nsAString &);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef nsresult (* CStringContainerInitFunc)(nsCStringContainer&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* CStringContainerInit2Func)(nsCStringContainer&, const char *, uint32_t, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef void (* CStringContainerFinishFunc)(nsCStringContainer&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint32_t (* CStringGetDataFunc)(const nsACString&, const char**, bool*);
|
|
|
|
typedef uint32_t (* CStringGetMutableDataFunc)(nsACString&, uint32_t, char**);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef char* (* CStringCloneDataFunc)(const nsACString&);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* CStringSetDataFunc)(nsACString&, const char*, uint32_t);
|
|
|
|
typedef nsresult (* CStringSetDataRangeFunc)(nsACString&, uint32_t, uint32_t, const char*, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsresult (* CStringCopyFunc)(nsACString &, const nsACString &);
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef void (* CStringSetIsVoidFunc)(nsACString &, const bool);
|
|
|
|
typedef bool (* CStringGetIsVoidFunc)(const nsACString &);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef nsresult (* CStringToUTF16)(const nsACString &, nsCStringEncoding, nsAString &);
|
|
|
|
typedef nsresult (* UTF16ToCString)(const nsAString &, nsCStringEncoding, nsACString &);
|
|
|
|
|
2012-08-09 00:10:11 -07:00
|
|
|
typedef void* (* AllocFunc)(size_t size);
|
|
|
|
typedef void* (* ReallocFunc)(void* ptr, size_t size);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef void (* FreeFunc)(void* ptr);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef void (* DebugBreakFunc)(uint32_t aSeverity,
|
2007-03-22 10:30:00 -07:00
|
|
|
const char *aStr, const char *aExpr,
|
2012-08-22 08:56:38 -07:00
|
|
|
const char *aFile, int32_t aLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef void (* xpcomVoidFunc)();
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef void (* LogAddRefFunc)(void*, nsrefcnt, const char*, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef void (* LogReleaseFunc)(void*, nsrefcnt, const char*);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef void (* LogCtorFunc)(void*, const char*, uint32_t);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef void (* LogCOMPtrFunc)(void*, nsISupports*);
|
|
|
|
|
2007-04-24 10:02:51 -07:00
|
|
|
typedef nsresult (* GetXPTCallStubFunc)(REFNSIID, nsIXPTCProxy*, nsISomeInterface**);
|
|
|
|
typedef void (* DestroyXPTCallStubFunc)(nsISomeInterface*);
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* InvokeByIndexFunc)(nsISupports*, uint32_t, uint32_t, nsXPTCVariant*);
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef bool (* CycleCollectorFunc)(nsISupports*);
|
2009-05-06 13:46:04 -07:00
|
|
|
typedef nsPurpleBufferEntry*
|
2012-08-24 09:50:06 -07:00
|
|
|
(* CycleCollectorSuspect2Func)(void*, nsCycleCollectionParticipant*);
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef bool (* CycleCollectorForget2Func)(nsPurpleBufferEntry*);
|
2007-04-24 10:02:51 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// PRIVATE AND DEPRECATED
|
|
|
|
typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, uint32_t priority);
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
|
|
|
|
|
|
|
|
typedef struct XPCOMFunctions{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t version;
|
|
|
|
uint32_t size;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
InitFunc init;
|
|
|
|
ShutdownFunc shutdown;
|
|
|
|
GetServiceManagerFunc getServiceManager;
|
|
|
|
GetComponentManagerFunc getComponentManager;
|
|
|
|
GetComponentRegistrarFunc getComponentRegistrar;
|
|
|
|
GetMemoryManagerFunc getMemoryManager;
|
|
|
|
NewLocalFileFunc newLocalFile;
|
|
|
|
NewNativeLocalFileFunc newNativeLocalFile;
|
|
|
|
|
|
|
|
RegisterXPCOMExitRoutineFunc registerExitRoutine;
|
|
|
|
UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
|
|
|
|
|
|
|
|
// Added for Mozilla 1.5
|
|
|
|
GetDebugFunc getDebug;
|
|
|
|
GetTraceRefcntFunc getTraceRefcnt;
|
|
|
|
|
|
|
|
// Added for Mozilla 1.7
|
|
|
|
StringContainerInitFunc stringContainerInit;
|
|
|
|
StringContainerFinishFunc stringContainerFinish;
|
|
|
|
StringGetDataFunc stringGetData;
|
|
|
|
StringSetDataFunc stringSetData;
|
|
|
|
StringSetDataRangeFunc stringSetDataRange;
|
|
|
|
StringCopyFunc stringCopy;
|
|
|
|
CStringContainerInitFunc cstringContainerInit;
|
|
|
|
CStringContainerFinishFunc cstringContainerFinish;
|
|
|
|
CStringGetDataFunc cstringGetData;
|
|
|
|
CStringSetDataFunc cstringSetData;
|
|
|
|
CStringSetDataRangeFunc cstringSetDataRange;
|
|
|
|
CStringCopyFunc cstringCopy;
|
|
|
|
CStringToUTF16 cstringToUTF16;
|
|
|
|
UTF16ToCString utf16ToCString;
|
|
|
|
StringCloneDataFunc stringCloneData;
|
|
|
|
CStringCloneDataFunc cstringCloneData;
|
|
|
|
|
|
|
|
// Added for Mozilla 1.8
|
|
|
|
AllocFunc allocFunc;
|
|
|
|
ReallocFunc reallocFunc;
|
|
|
|
FreeFunc freeFunc;
|
|
|
|
StringContainerInit2Func stringContainerInit2;
|
|
|
|
CStringContainerInit2Func cstringContainerInit2;
|
|
|
|
StringGetMutableDataFunc stringGetMutableData;
|
|
|
|
CStringGetMutableDataFunc cstringGetMutableData;
|
2010-06-10 11:11:11 -07:00
|
|
|
void* init3; // obsolete
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Added for Mozilla 1.9
|
|
|
|
DebugBreakFunc debugBreakFunc;
|
|
|
|
xpcomVoidFunc logInitFunc;
|
|
|
|
xpcomVoidFunc logTermFunc;
|
|
|
|
LogAddRefFunc logAddRefFunc;
|
|
|
|
LogReleaseFunc logReleaseFunc;
|
|
|
|
LogCtorFunc logCtorFunc;
|
|
|
|
LogCtorFunc logDtorFunc;
|
|
|
|
LogCOMPtrFunc logCOMPtrAddRefFunc;
|
|
|
|
LogCOMPtrFunc logCOMPtrReleaseFunc;
|
2007-04-24 10:02:51 -07:00
|
|
|
GetXPTCallStubFunc getXPTCallStubFunc;
|
|
|
|
DestroyXPTCallStubFunc destroyXPTCallStubFunc;
|
|
|
|
InvokeByIndexFunc invokeByIndexFunc;
|
2012-08-27 10:28:38 -07:00
|
|
|
CycleCollectorFunc cycleSuspectFunc; // obsolete: use cycleSuspect2Func
|
|
|
|
CycleCollectorFunc cycleForgetFunc; // obsolete: use cycleForget2Func
|
2007-08-17 20:48:16 -07:00
|
|
|
StringSetIsVoidFunc stringSetIsVoid;
|
|
|
|
StringGetIsVoidFunc stringGetIsVoid;
|
|
|
|
CStringSetIsVoidFunc cstringSetIsVoid;
|
|
|
|
CStringGetIsVoidFunc cstringGetIsVoid;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-20 13:04:39 -07:00
|
|
|
// Added for Mozilla 1.9.1
|
2009-05-06 13:46:04 -07:00
|
|
|
CycleCollectorSuspect2Func cycleSuspect2Func;
|
|
|
|
CycleCollectorForget2Func cycleForget2Func;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
} XPCOMFunctions;
|
|
|
|
|
2008-10-10 08:04:34 -07:00
|
|
|
typedef nsresult (*GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
|
2007-03-22 10:30:00 -07:00
|
|
|
XPCOM_API(nsresult)
|
|
|
|
NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
|
|
|
|
2009-06-16 12:36:44 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown XPCOM. You must call this method after you are finished
|
|
|
|
* using xpcom.
|
|
|
|
*
|
|
|
|
* @param servMgr The service manager which was returned by NS_InitXPCOM.
|
|
|
|
* This will release servMgr. You may pass null.
|
|
|
|
*
|
|
|
|
* @return NS_OK for success;
|
|
|
|
* other error codes indicate a failure during shutdown
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
ShutdownXPCOM(nsIServiceManager* servMgr);
|
|
|
|
|
2010-02-03 14:17:09 -08:00
|
|
|
/**
|
|
|
|
* C++ namespaced version of NS_LogTerm.
|
|
|
|
*/
|
|
|
|
void LogTerm();
|
|
|
|
|
2009-06-16 12:36:44 -07:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// think hard before changing this
|
|
|
|
#define XPCOM_GLUE_VERSION 1
|
|
|
|
|
|
|
|
|
|
|
|
/* XPCOM Specific Defines
|
|
|
|
*
|
|
|
|
* XPCOM_DLL - name of the loadable xpcom library on disk.
|
|
|
|
* XUL_DLL - name of the loadable XUL 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
|
|
|
|
*/
|
|
|
|
|
2011-05-01 11:59:24 -07:00
|
|
|
#if defined(XP_WIN32) || defined(XP_OS2)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define XPCOM_SEARCH_KEY "PATH"
|
|
|
|
#define GRE_CONF_NAME "gre.config"
|
2008-12-03 05:41:12 -08:00
|
|
|
#define GRE_WIN_REG_LOC L"Software\\mozilla.org\\GRE"
|
2007-03-22 10:30:00 -07:00
|
|
|
#define XPCOM_DLL "xpcom.dll"
|
2008-12-03 05:41:12 -08:00
|
|
|
#define LXPCOM_DLL L"xpcom.dll"
|
2007-03-22 10:30:00 -07:00
|
|
|
#define XUL_DLL "xul.dll"
|
2008-12-03 05:41:12 -08:00
|
|
|
#define LXUL_DLL L"xul.dll"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#else // Unix
|
2008-10-20 20:55:57 -07:00
|
|
|
#include <limits.h> // for PATH_MAX
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-08 01:33:56 -08:00
|
|
|
#define XPCOM_DLL "libxpcom" MOZ_DLL_SUFFIX
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// you have to love apple..
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
|
|
|
|
#define GRE_FRAMEWORK_NAME "XUL.framework"
|
|
|
|
#define XUL_DLL "XUL"
|
|
|
|
#else
|
|
|
|
#define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
2011-11-08 01:33:56 -08:00
|
|
|
#define XUL_DLL "libxul" MOZ_DLL_SUFFIX
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GRE_CONF_NAME ".gre.config"
|
|
|
|
#define GRE_CONF_PATH "/etc/gre.conf"
|
|
|
|
#define GRE_CONF_DIR "/etc/gre.d"
|
|
|
|
#define GRE_USER_CONF_DIR ".gre.d"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
|
|
|
#define XPCOM_FILE_PATH_SEPARATOR "\\"
|
|
|
|
#define XPCOM_ENV_PATH_SEPARATOR ";"
|
Bug 627277 - Remove (broken) BeOS support. r=biesi,dwitte,gavin,joe,jorendorff,josh,khuey,mfinkle,neil,Pike,roc,shaver,smontagu,taras
2011-02-19 11:10:24 -08:00
|
|
|
#elif defined(XP_UNIX)
|
2007-03-22 10:30:00 -07:00
|
|
|
#define XPCOM_FILE_PATH_SEPARATOR "/"
|
|
|
|
#define XPCOM_ENV_PATH_SEPARATOR ":"
|
|
|
|
#else
|
|
|
|
#error need_to_define_your_file_path_separator_and_illegal_characters
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AIX
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAXPATHLEN
|
|
|
|
#ifdef PATH_MAX
|
|
|
|
#define MAXPATHLEN PATH_MAX
|
|
|
|
#elif defined(_MAX_PATH)
|
|
|
|
#define MAXPATHLEN _MAX_PATH
|
|
|
|
#elif defined(CCHMAXPATH)
|
|
|
|
#define MAXPATHLEN CCHMAXPATH
|
|
|
|
#else
|
|
|
|
#define MAXPATHLEN 1024
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
extern bool gXPCOMShuttingDown;
|
2010-04-02 11:38:25 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace services {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears service cache, sets gXPCOMShuttingDown
|
|
|
|
*/
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
} // namespace services
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|