1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set ts=4 sw=4 et cindent: */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsXPComPrivate_h__
40 #define nsXPComPrivate_h__
44 #include "nsXPCOMStrings.h"
47 class nsStringContainer
;
48 class nsCStringContainer
;
49 class nsIComponentLoader
;
52 * During this shutdown notification all threads which run XPCOM code must
55 #define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
58 * During this shutdown notification all module loaders must unload XPCOM
61 #define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
64 typedef nsresult (* InitFunc
)(nsIServiceManager
* *result
, nsIFile
* binDirectory
, nsIDirectoryServiceProvider
* appFileLocationProvider
);
65 typedef nsresult (* Init3Func
)(nsIServiceManager
* *result
, nsIFile
* binDirectory
, nsIDirectoryServiceProvider
* appFileLocationProvider
, nsStaticModuleInfo
const *staticComponents
, PRUint32 componentCount
);
66 typedef nsresult (* ShutdownFunc
)(nsIServiceManager
* servMgr
);
67 typedef nsresult (* GetServiceManagerFunc
)(nsIServiceManager
* *result
);
68 typedef nsresult (* GetComponentManagerFunc
)(nsIComponentManager
* *result
);
69 typedef nsresult (* GetComponentRegistrarFunc
)(nsIComponentRegistrar
* *result
);
70 typedef nsresult (* GetMemoryManagerFunc
)(nsIMemory
* *result
);
71 typedef nsresult (* NewLocalFileFunc
)(const nsAString
&path
, PRBool followLinks
, nsILocalFile
* *result
);
72 typedef nsresult (* NewNativeLocalFileFunc
)(const nsACString
&path
, PRBool followLinks
, nsILocalFile
* *result
);
74 typedef nsresult (* GetDebugFunc
)(nsIDebug
* *result
);
75 typedef nsresult (* GetTraceRefcntFunc
)(nsITraceRefcnt
* *result
);
77 typedef nsresult (* StringContainerInitFunc
)(nsStringContainer
&);
78 typedef nsresult (* StringContainerInit2Func
)(nsStringContainer
&, const PRUnichar
*, PRUint32
, PRUint32
);
79 typedef void (* StringContainerFinishFunc
)(nsStringContainer
&);
80 typedef PRUint32 (* StringGetDataFunc
)(const nsAString
&, const PRUnichar
**, PRBool
*);
81 typedef PRUint32 (* StringGetMutableDataFunc
)(nsAString
&, PRUint32
, PRUnichar
**);
82 typedef PRUnichar
* (* StringCloneDataFunc
)(const nsAString
&);
83 typedef nsresult (* StringSetDataFunc
)(nsAString
&, const PRUnichar
*, PRUint32
);
84 typedef nsresult (* StringSetDataRangeFunc
)(nsAString
&, PRUint32
, PRUint32
, const PRUnichar
*, PRUint32
);
85 typedef nsresult (* StringCopyFunc
)(nsAString
&, const nsAString
&);
86 typedef void (* StringSetIsVoidFunc
)(nsAString
&, const PRBool
);
87 typedef PRBool (* StringGetIsVoidFunc
)(const nsAString
&);
89 typedef nsresult (* CStringContainerInitFunc
)(nsCStringContainer
&);
90 typedef nsresult (* CStringContainerInit2Func
)(nsCStringContainer
&, const char *, PRUint32
, PRUint32
);
91 typedef void (* CStringContainerFinishFunc
)(nsCStringContainer
&);
92 typedef PRUint32 (* CStringGetDataFunc
)(const nsACString
&, const char**, PRBool
*);
93 typedef PRUint32 (* CStringGetMutableDataFunc
)(nsACString
&, PRUint32
, char**);
94 typedef char* (* CStringCloneDataFunc
)(const nsACString
&);
95 typedef nsresult (* CStringSetDataFunc
)(nsACString
&, const char*, PRUint32
);
96 typedef nsresult (* CStringSetDataRangeFunc
)(nsACString
&, PRUint32
, PRUint32
, const char*, PRUint32
);
97 typedef nsresult (* CStringCopyFunc
)(nsACString
&, const nsACString
&);
98 typedef void (* CStringSetIsVoidFunc
)(nsACString
&, const PRBool
);
99 typedef PRBool (* CStringGetIsVoidFunc
)(const nsACString
&);
101 typedef nsresult (* CStringToUTF16
)(const nsACString
&, nsCStringEncoding
, nsAString
&);
102 typedef nsresult (* UTF16ToCString
)(const nsAString
&, nsCStringEncoding
, nsACString
&);
104 typedef void* (* AllocFunc
)(PRSize size
);
105 typedef void* (* ReallocFunc
)(void* ptr
, PRSize size
);
106 typedef void (* FreeFunc
)(void* ptr
);
108 typedef void (* DebugBreakFunc
)(PRUint32 aSeverity
,
109 const char *aStr
, const char *aExpr
,
110 const char *aFile
, PRInt32 aLine
);
112 typedef void (* xpcomVoidFunc
)();
113 typedef void (* LogAddRefFunc
)(void*, nsrefcnt
, const char*, PRUint32
);
114 typedef void (* LogReleaseFunc
)(void*, nsrefcnt
, const char*);
115 typedef void (* LogCtorFunc
)(void*, const char*, PRUint32
);
116 typedef void (* LogCOMPtrFunc
)(void*, nsISupports
*);
118 typedef nsresult (* GetXPTCallStubFunc
)(REFNSIID
, nsIXPTCProxy
*, nsISomeInterface
**);
119 typedef void (* DestroyXPTCallStubFunc
)(nsISomeInterface
*);
120 typedef nsresult (* InvokeByIndexFunc
)(nsISupports
*, PRUint32
, PRUint32
, nsXPTCVariant
*);
121 typedef PRBool (* CycleCollectorFunc
)(nsISupports
*);
123 // PRIVATE AND DEPRECATED
124 typedef NS_CALLBACK(XPCOMExitRoutine
)(void);
126 typedef nsresult (* RegisterXPCOMExitRoutineFunc
)(XPCOMExitRoutine exitRoutine
, PRUint32 priority
);
127 typedef nsresult (* UnregisterXPCOMExitRoutineFunc
)(XPCOMExitRoutine exitRoutine
);
129 typedef struct XPCOMFunctions
{
134 ShutdownFunc shutdown
;
135 GetServiceManagerFunc getServiceManager
;
136 GetComponentManagerFunc getComponentManager
;
137 GetComponentRegistrarFunc getComponentRegistrar
;
138 GetMemoryManagerFunc getMemoryManager
;
139 NewLocalFileFunc newLocalFile
;
140 NewNativeLocalFileFunc newNativeLocalFile
;
142 RegisterXPCOMExitRoutineFunc registerExitRoutine
;
143 UnregisterXPCOMExitRoutineFunc unregisterExitRoutine
;
145 // Added for Mozilla 1.5
146 GetDebugFunc getDebug
;
147 GetTraceRefcntFunc getTraceRefcnt
;
149 // Added for Mozilla 1.7
150 StringContainerInitFunc stringContainerInit
;
151 StringContainerFinishFunc stringContainerFinish
;
152 StringGetDataFunc stringGetData
;
153 StringSetDataFunc stringSetData
;
154 StringSetDataRangeFunc stringSetDataRange
;
155 StringCopyFunc stringCopy
;
156 CStringContainerInitFunc cstringContainerInit
;
157 CStringContainerFinishFunc cstringContainerFinish
;
158 CStringGetDataFunc cstringGetData
;
159 CStringSetDataFunc cstringSetData
;
160 CStringSetDataRangeFunc cstringSetDataRange
;
161 CStringCopyFunc cstringCopy
;
162 CStringToUTF16 cstringToUTF16
;
163 UTF16ToCString utf16ToCString
;
164 StringCloneDataFunc stringCloneData
;
165 CStringCloneDataFunc cstringCloneData
;
167 // Added for Mozilla 1.8
169 ReallocFunc reallocFunc
;
171 StringContainerInit2Func stringContainerInit2
;
172 CStringContainerInit2Func cstringContainerInit2
;
173 StringGetMutableDataFunc stringGetMutableData
;
174 CStringGetMutableDataFunc cstringGetMutableData
;
177 // Added for Mozilla 1.9
178 DebugBreakFunc debugBreakFunc
;
179 xpcomVoidFunc logInitFunc
;
180 xpcomVoidFunc logTermFunc
;
181 LogAddRefFunc logAddRefFunc
;
182 LogReleaseFunc logReleaseFunc
;
183 LogCtorFunc logCtorFunc
;
184 LogCtorFunc logDtorFunc
;
185 LogCOMPtrFunc logCOMPtrAddRefFunc
;
186 LogCOMPtrFunc logCOMPtrReleaseFunc
;
187 GetXPTCallStubFunc getXPTCallStubFunc
;
188 DestroyXPTCallStubFunc destroyXPTCallStubFunc
;
189 InvokeByIndexFunc invokeByIndexFunc
;
190 CycleCollectorFunc cycleSuspectFunc
;
191 CycleCollectorFunc cycleForgetFunc
;
192 StringSetIsVoidFunc stringSetIsVoid
;
193 StringGetIsVoidFunc stringGetIsVoid
;
194 CStringSetIsVoidFunc cstringSetIsVoid
;
195 CStringGetIsVoidFunc cstringGetIsVoid
;
199 typedef nsresult (PR_CALLBACK
*GetFrozenFunctionsFunc
)(XPCOMFunctions
*entryPoints
, const char* libraryPath
);
201 NS_GetFrozenFunctions(XPCOMFunctions
*entryPoints
, const char* libraryPath
);
203 // think hard before changing this
204 #define XPCOM_GLUE_VERSION 1
207 /* XPCOM Specific Defines
209 * XPCOM_DLL - name of the loadable xpcom library on disk.
210 * XUL_DLL - name of the loadable XUL library on disk
211 * XPCOM_SEARCH_KEY - name of the environment variable that can be
212 * modified to include additional search paths.
213 * GRE_CONF_NAME - Name of the GRE Configuration file
216 #if defined(XP_WIN32) || defined(XP_OS2) || defined(WINCE)
218 #define XPCOM_SEARCH_KEY "PATH"
219 #define GRE_CONF_NAME "gre.config"
220 #define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE"
221 #define XPCOM_DLL "xpcom.dll"
222 #define XUL_DLL "xul.dll"
224 #elif defined(XP_BEOS)
226 #define XPCOM_SEARCH_KEY "ADDON_PATH"
227 #define GRE_CONF_NAME "gre.config"
228 #define GRE_CONF_PATH "gre.conf"
229 #define GRE_CONF_DIR "gre.d"
230 #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
231 #define XUL_DLL "libxul"MOZ_DLL_SUFFIX
235 #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
237 // you have to love apple..
239 #define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
240 #define GRE_FRAMEWORK_NAME "XUL.framework"
241 #define XUL_DLL "XUL"
243 #define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
244 #define XUL_DLL "libxul"MOZ_DLL_SUFFIX
247 #define GRE_CONF_NAME ".gre.config"
248 #define GRE_CONF_PATH "/etc/gre.conf"
249 #define GRE_CONF_DIR "/etc/gre.d"
250 #define GRE_USER_CONF_DIR ".gre.d"
253 #if defined(XP_WIN) || defined(XP_OS2)
254 #define XPCOM_FILE_PATH_SEPARATOR "\\"
255 #define XPCOM_ENV_PATH_SEPARATOR ";"
256 #elif defined(XP_UNIX) || defined(XP_BEOS)
257 #define XPCOM_FILE_PATH_SEPARATOR "/"
258 #define XPCOM_ENV_PATH_SEPARATOR ":"
260 #error need_to_define_your_file_path_separator_and_illegal_characters
264 #include <sys/param.h>
269 #define MAXPATHLEN PATH_MAX
270 #elif defined(_MAX_PATH)
271 #define MAXPATHLEN _MAX_PATH
272 #elif defined(CCHMAXPATH)
273 #define MAXPATHLEN CCHMAXPATH
275 #define MAXPATHLEN 1024