1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsXPCOMPrivate.h"
7 #include "nsXPCOMStrings.h"
13 * Private Method to register an exit routine. This method
14 * used to allow you to setup a callback that will be called from
15 * the NS_ShutdownXPCOM function after all services and
16 * components have gone away. It was fatally flawed in that the component
17 * DLL could be released before the exit function was called; it is now a
18 * stub implementation that does nothing.
21 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine
, uint32_t aPriority
);
24 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine
);
26 static const XPCOMFunctions kFrozenFunctions
= {
28 sizeof(XPCOMFunctions
),
31 &NS_GetServiceManager
,
32 &NS_GetComponentManager
,
33 &NS_GetComponentRegistrar
,
36 &NS_NewNativeLocalFile
,
37 &NS_RegisterXPCOMExitRoutine
,
38 &NS_UnregisterXPCOMExitRoutine
,
40 // these functions were added post 1.4
44 // these functions were added post 1.6
45 &NS_StringContainerInit
,
46 &NS_StringContainerFinish
,
49 &NS_StringSetDataRange
,
51 &NS_CStringContainerInit
,
52 &NS_CStringContainerFinish
,
55 &NS_CStringSetDataRange
,
62 // these functions were added post 1.7 (post Firefox 1.0)
66 &NS_StringContainerInit2
,
67 &NS_CStringContainerInit2
,
68 &NS_StringGetMutableData
,
69 &NS_CStringGetMutableData
,
72 // these functions were added post 1.8
83 &NS_DestroyXPTCallStub
,
92 // these functions were added post 1.9, but then made obsolete
96 &NS_CycleCollectorSuspect3
,
99 EXPORT_XPCOM_API(nsresult
)
100 NS_GetFrozenFunctions(XPCOMFunctions
* aFunctions
, const char* /* aLibraryPath */)
103 return NS_ERROR_OUT_OF_MEMORY
;
106 if (aFunctions
->version
!= XPCOM_GLUE_VERSION
) {
107 return NS_ERROR_FAILURE
;
110 uint32_t size
= aFunctions
->size
;
111 if (size
> sizeof(XPCOMFunctions
)) {
112 size
= sizeof(XPCOMFunctions
);
115 size
-= offsetof(XPCOMFunctions
, init
);
117 memcpy(&aFunctions
->init
, &kFrozenFunctions
.init
, size
);
123 * Stubs for nsXPCOMPrivate.h
126 EXPORT_XPCOM_API(nsresult
)
127 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine
, uint32_t aPriority
)
132 EXPORT_XPCOM_API(nsresult
)
133 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine
)