michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set ts=4 sw=4 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsXPComPrivate_h__ michael@0: #define nsXPComPrivate_h__ michael@0: michael@0: #include "nscore.h" michael@0: #include "nsXPCOM.h" michael@0: #include "nsXPCOMStrings.h" michael@0: #include "xptcall.h" michael@0: michael@0: class nsStringContainer; michael@0: class nsCStringContainer; michael@0: class nsIComponentLoader; michael@0: class nsPurpleBufferEntry; michael@0: michael@0: /** michael@0: * During this shutdown notification all threads which run XPCOM code must michael@0: * be joined. michael@0: */ michael@0: #define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads" michael@0: michael@0: /** michael@0: * During this shutdown notification all module loaders must unload XPCOM michael@0: * modules. michael@0: */ michael@0: #define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders" michael@0: michael@0: // PUBLIC michael@0: typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider); michael@0: typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr); michael@0: typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result); michael@0: typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result); michael@0: typedef nsresult (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result); michael@0: typedef nsresult (* GetMemoryManagerFunc)(nsIMemory* *result); michael@0: typedef nsresult (* NewLocalFileFunc)(const nsAString &path, bool followLinks, nsIFile* *result); michael@0: typedef nsresult (* NewNativeLocalFileFunc)(const nsACString &path, bool followLinks, nsIFile* *result); michael@0: michael@0: typedef nsresult (* GetDebugFunc)(nsIDebug* *result); michael@0: michael@0: typedef nsresult (* StringContainerInitFunc)(nsStringContainer&); michael@0: typedef nsresult (* StringContainerInit2Func)(nsStringContainer&, const char16_t *, uint32_t, uint32_t); michael@0: typedef void (* StringContainerFinishFunc)(nsStringContainer&); michael@0: typedef uint32_t (* StringGetDataFunc)(const nsAString&, const char16_t**, bool*); michael@0: typedef uint32_t (* StringGetMutableDataFunc)(nsAString&, uint32_t, char16_t**); michael@0: typedef char16_t* (* StringCloneDataFunc)(const nsAString&); michael@0: typedef nsresult (* StringSetDataFunc)(nsAString&, const char16_t*, uint32_t); michael@0: typedef nsresult (* StringSetDataRangeFunc)(nsAString&, uint32_t, uint32_t, const char16_t*, uint32_t); michael@0: typedef nsresult (* StringCopyFunc)(nsAString &, const nsAString &); michael@0: typedef void (* StringSetIsVoidFunc)(nsAString &, const bool); michael@0: typedef bool (* StringGetIsVoidFunc)(const nsAString &); michael@0: michael@0: typedef nsresult (* CStringContainerInitFunc)(nsCStringContainer&); michael@0: typedef nsresult (* CStringContainerInit2Func)(nsCStringContainer&, const char *, uint32_t, uint32_t); michael@0: typedef void (* CStringContainerFinishFunc)(nsCStringContainer&); michael@0: typedef uint32_t (* CStringGetDataFunc)(const nsACString&, const char**, bool*); michael@0: typedef uint32_t (* CStringGetMutableDataFunc)(nsACString&, uint32_t, char**); michael@0: typedef char* (* CStringCloneDataFunc)(const nsACString&); michael@0: typedef nsresult (* CStringSetDataFunc)(nsACString&, const char*, uint32_t); michael@0: typedef nsresult (* CStringSetDataRangeFunc)(nsACString&, uint32_t, uint32_t, const char*, uint32_t); michael@0: typedef nsresult (* CStringCopyFunc)(nsACString &, const nsACString &); michael@0: typedef void (* CStringSetIsVoidFunc)(nsACString &, const bool); michael@0: typedef bool (* CStringGetIsVoidFunc)(const nsACString &); michael@0: michael@0: typedef nsresult (* CStringToUTF16)(const nsACString &, nsCStringEncoding, nsAString &); michael@0: typedef nsresult (* UTF16ToCString)(const nsAString &, nsCStringEncoding, nsACString &); michael@0: michael@0: typedef void* (* AllocFunc)(size_t size); michael@0: typedef void* (* ReallocFunc)(void* ptr, size_t size); michael@0: typedef void (* FreeFunc)(void* ptr); michael@0: michael@0: typedef void (* DebugBreakFunc)(uint32_t aSeverity, michael@0: const char *aStr, const char *aExpr, michael@0: const char *aFile, int32_t aLine); michael@0: michael@0: typedef void (* xpcomVoidFunc)(); michael@0: typedef void (* LogAddRefFunc)(void*, nsrefcnt, const char*, uint32_t); michael@0: typedef void (* LogReleaseFunc)(void*, nsrefcnt, const char*); michael@0: typedef void (* LogCtorFunc)(void*, const char*, uint32_t); michael@0: typedef void (* LogCOMPtrFunc)(void*, nsISupports*); michael@0: michael@0: typedef nsresult (* GetXPTCallStubFunc)(REFNSIID, nsIXPTCProxy*, nsISomeInterface**); michael@0: typedef void (* DestroyXPTCallStubFunc)(nsISomeInterface*); michael@0: typedef nsresult (* InvokeByIndexFunc)(nsISupports*, uint32_t, uint32_t, nsXPTCVariant*); michael@0: typedef bool (* CycleCollectorFunc)(nsISupports*); michael@0: typedef nsPurpleBufferEntry* michael@0: (* CycleCollectorSuspect2Func)(void*, nsCycleCollectionParticipant*); michael@0: typedef bool (* CycleCollectorForget2Func)(nsPurpleBufferEntry*); michael@0: typedef void (* CycleCollectorSuspect3Func)(void*, nsCycleCollectionParticipant*,nsCycleCollectingAutoRefCnt*,bool*); michael@0: // PRIVATE AND DEPRECATED michael@0: typedef NS_CALLBACK(XPCOMExitRoutine)(void); michael@0: michael@0: typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, uint32_t priority); michael@0: typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine); michael@0: michael@0: typedef struct XPCOMFunctions{ michael@0: uint32_t version; michael@0: uint32_t size; michael@0: michael@0: InitFunc init; michael@0: ShutdownFunc shutdown; michael@0: GetServiceManagerFunc getServiceManager; michael@0: GetComponentManagerFunc getComponentManager; michael@0: GetComponentRegistrarFunc getComponentRegistrar; michael@0: GetMemoryManagerFunc getMemoryManager; michael@0: NewLocalFileFunc newLocalFile; michael@0: NewNativeLocalFileFunc newNativeLocalFile; michael@0: michael@0: RegisterXPCOMExitRoutineFunc registerExitRoutine; michael@0: UnregisterXPCOMExitRoutineFunc unregisterExitRoutine; michael@0: michael@0: // Added for Mozilla 1.5 michael@0: GetDebugFunc getDebug; michael@0: void* getTraceRefcnt; michael@0: michael@0: // Added for Mozilla 1.7 michael@0: StringContainerInitFunc stringContainerInit; michael@0: StringContainerFinishFunc stringContainerFinish; michael@0: StringGetDataFunc stringGetData; michael@0: StringSetDataFunc stringSetData; michael@0: StringSetDataRangeFunc stringSetDataRange; michael@0: StringCopyFunc stringCopy; michael@0: CStringContainerInitFunc cstringContainerInit; michael@0: CStringContainerFinishFunc cstringContainerFinish; michael@0: CStringGetDataFunc cstringGetData; michael@0: CStringSetDataFunc cstringSetData; michael@0: CStringSetDataRangeFunc cstringSetDataRange; michael@0: CStringCopyFunc cstringCopy; michael@0: CStringToUTF16 cstringToUTF16; michael@0: UTF16ToCString utf16ToCString; michael@0: StringCloneDataFunc stringCloneData; michael@0: CStringCloneDataFunc cstringCloneData; michael@0: michael@0: // Added for Mozilla 1.8 michael@0: AllocFunc allocFunc; michael@0: ReallocFunc reallocFunc; michael@0: FreeFunc freeFunc; michael@0: StringContainerInit2Func stringContainerInit2; michael@0: CStringContainerInit2Func cstringContainerInit2; michael@0: StringGetMutableDataFunc stringGetMutableData; michael@0: CStringGetMutableDataFunc cstringGetMutableData; michael@0: void* init3; // obsolete michael@0: michael@0: // Added for Mozilla 1.9 michael@0: DebugBreakFunc debugBreakFunc; michael@0: xpcomVoidFunc logInitFunc; michael@0: xpcomVoidFunc logTermFunc; michael@0: LogAddRefFunc logAddRefFunc; michael@0: LogReleaseFunc logReleaseFunc; michael@0: LogCtorFunc logCtorFunc; michael@0: LogCtorFunc logDtorFunc; michael@0: LogCOMPtrFunc logCOMPtrAddRefFunc; michael@0: LogCOMPtrFunc logCOMPtrReleaseFunc; michael@0: GetXPTCallStubFunc getXPTCallStubFunc; michael@0: DestroyXPTCallStubFunc destroyXPTCallStubFunc; michael@0: InvokeByIndexFunc invokeByIndexFunc; michael@0: CycleCollectorFunc cycleSuspectFunc; // obsolete: use cycleSuspect3Func michael@0: CycleCollectorFunc cycleForgetFunc; // obsolete michael@0: StringSetIsVoidFunc stringSetIsVoid; michael@0: StringGetIsVoidFunc stringGetIsVoid; michael@0: CStringSetIsVoidFunc cstringSetIsVoid; michael@0: CStringGetIsVoidFunc cstringGetIsVoid; michael@0: michael@0: // Added for Mozilla 1.9.1 michael@0: CycleCollectorSuspect2Func cycleSuspect2Func; // obsolete: use cycleSuspect3Func michael@0: CycleCollectorForget2Func cycleForget2Func; // obsolete michael@0: michael@0: CycleCollectorSuspect3Func cycleSuspect3Func; michael@0: michael@0: } XPCOMFunctions; michael@0: michael@0: typedef nsresult (*GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath); michael@0: XPCOM_API(nsresult) michael@0: NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath); michael@0: michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * Shutdown XPCOM. You must call this method after you are finished michael@0: * using xpcom. michael@0: * michael@0: * @param servMgr The service manager which was returned by NS_InitXPCOM. michael@0: * This will release servMgr. You may pass null. michael@0: * michael@0: * @return NS_OK for success; michael@0: * other error codes indicate a failure during shutdown michael@0: * michael@0: */ michael@0: nsresult michael@0: ShutdownXPCOM(nsIServiceManager* servMgr); michael@0: michael@0: void SetICUMemoryFunctions(); michael@0: michael@0: /** michael@0: * C++ namespaced version of NS_LogTerm. michael@0: */ michael@0: void LogTerm(); michael@0: michael@0: } // namespace mozilla michael@0: michael@0: michael@0: // think hard before changing this michael@0: #define XPCOM_GLUE_VERSION 1 michael@0: michael@0: michael@0: /* XPCOM Specific Defines michael@0: * michael@0: * XPCOM_DLL - name of the loadable xpcom library on disk. michael@0: * XUL_DLL - name of the loadable XUL library on disk michael@0: * XPCOM_SEARCH_KEY - name of the environment variable that can be michael@0: * modified to include additional search paths. michael@0: * GRE_CONF_NAME - Name of the GRE Configuration file michael@0: */ michael@0: michael@0: #if defined(XP_WIN32) michael@0: michael@0: #define XPCOM_SEARCH_KEY "PATH" michael@0: #define GRE_CONF_NAME "gre.config" michael@0: #define GRE_WIN_REG_LOC L"Software\\mozilla.org\\GRE" michael@0: #define XPCOM_DLL XUL_DLL michael@0: #define LXPCOM_DLL LXUL_DLL michael@0: #define XUL_DLL "xul.dll" michael@0: #define LXUL_DLL L"xul.dll" michael@0: michael@0: #else // Unix michael@0: #include // for PATH_MAX michael@0: michael@0: #define XPCOM_DLL XUL_DLL michael@0: michael@0: // you have to love apple.. michael@0: #ifdef XP_MACOSX michael@0: #define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH" michael@0: #define GRE_FRAMEWORK_NAME "XUL.framework" michael@0: #define XUL_DLL "XUL" michael@0: #else michael@0: #define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH" michael@0: #define XUL_DLL "libxul" MOZ_DLL_SUFFIX michael@0: #endif michael@0: michael@0: #define GRE_CONF_NAME ".gre.config" michael@0: #define GRE_CONF_PATH "/etc/gre.conf" michael@0: #define GRE_CONF_DIR "/etc/gre.d" michael@0: #define GRE_USER_CONF_DIR ".gre.d" michael@0: #endif michael@0: michael@0: #if defined(XP_WIN) michael@0: #define XPCOM_FILE_PATH_SEPARATOR "\\" michael@0: #define XPCOM_ENV_PATH_SEPARATOR ";" michael@0: #elif defined(XP_UNIX) michael@0: #define XPCOM_FILE_PATH_SEPARATOR "/" michael@0: #define XPCOM_ENV_PATH_SEPARATOR ":" michael@0: #else michael@0: #error need_to_define_your_file_path_separator_and_illegal_characters michael@0: #endif michael@0: michael@0: #ifdef AIX michael@0: #include michael@0: #endif michael@0: michael@0: #ifndef MAXPATHLEN michael@0: #ifdef PATH_MAX michael@0: #define MAXPATHLEN PATH_MAX michael@0: #elif defined(_MAX_PATH) michael@0: #define MAXPATHLEN _MAX_PATH michael@0: #elif defined(CCHMAXPATH) michael@0: #define MAXPATHLEN CCHMAXPATH michael@0: #else michael@0: #define MAXPATHLEN 1024 michael@0: #endif michael@0: #endif michael@0: michael@0: extern bool gXPCOMShuttingDown; michael@0: extern bool gXPCOMThreadsShutDown; michael@0: michael@0: namespace mozilla { michael@0: namespace services { michael@0: michael@0: /** michael@0: * Clears service cache, sets gXPCOMShuttingDown michael@0: */ michael@0: void Shutdown(); michael@0: michael@0: } // namespace services michael@0: } // namespace mozilla michael@0: michael@0: #endif