Fix typo in 9b54bd30006c008b4a951331b273613d5bac3abf
[pm.git] / xpcom / build / FrozenFunctions.cpp
blobe7a358e3b14b3234bbb72258997163f8d61abed7
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/. */
5 #include "nsXPCOM.h"
6 #include "nsXPCOMPrivate.h"
7 #include "nsXPCOMStrings.h"
8 #include "xptcall.h"
10 #include <string.h>
12 /**
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.
20 XPCOM_API(nsresult)
21 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority);
23 XPCOM_API(nsresult)
24 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine);
26 static const XPCOMFunctions kFrozenFunctions = {
27 XPCOM_GLUE_VERSION,
28 sizeof(XPCOMFunctions),
29 &NS_InitXPCOM2,
30 &NS_ShutdownXPCOM,
31 &NS_GetServiceManager,
32 &NS_GetComponentManager,
33 &NS_GetComponentRegistrar,
34 &NS_GetMemoryManager,
35 &NS_NewLocalFile,
36 &NS_NewNativeLocalFile,
37 &NS_RegisterXPCOMExitRoutine,
38 &NS_UnregisterXPCOMExitRoutine,
40 // these functions were added post 1.4
41 &NS_GetDebug,
42 nullptr,
44 // these functions were added post 1.6
45 &NS_StringContainerInit,
46 &NS_StringContainerFinish,
47 &NS_StringGetData,
48 &NS_StringSetData,
49 &NS_StringSetDataRange,
50 &NS_StringCopy,
51 &NS_CStringContainerInit,
52 &NS_CStringContainerFinish,
53 &NS_CStringGetData,
54 &NS_CStringSetData,
55 &NS_CStringSetDataRange,
56 &NS_CStringCopy,
57 &NS_CStringToUTF16,
58 &NS_UTF16ToCString,
59 &NS_StringCloneData,
60 &NS_CStringCloneData,
62 // these functions were added post 1.7 (post Firefox 1.0)
63 &NS_Alloc,
64 &NS_Realloc,
65 &NS_Free,
66 &NS_StringContainerInit2,
67 &NS_CStringContainerInit2,
68 &NS_StringGetMutableData,
69 &NS_CStringGetMutableData,
70 nullptr,
72 // these functions were added post 1.8
73 &NS_DebugBreak,
74 &NS_LogInit,
75 &NS_LogTerm,
76 &NS_LogAddRef,
77 &NS_LogRelease,
78 &NS_LogCtor,
79 &NS_LogDtor,
80 &NS_LogCOMPtrAddRef,
81 &NS_LogCOMPtrRelease,
82 &NS_GetXPTCallStub,
83 &NS_DestroyXPTCallStub,
84 &NS_InvokeByIndex,
85 nullptr,
86 nullptr,
87 &NS_StringSetIsVoid,
88 &NS_StringGetIsVoid,
89 &NS_CStringSetIsVoid,
90 &NS_CStringGetIsVoid,
92 // these functions were added post 1.9, but then made obsolete
93 nullptr,
94 nullptr,
96 &NS_CycleCollectorSuspect3,
99 EXPORT_XPCOM_API(nsresult)
100 NS_GetFrozenFunctions(XPCOMFunctions* aFunctions, const char* /* aLibraryPath */)
102 if (!aFunctions) {
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);
119 return NS_OK;
123 * Stubs for nsXPCOMPrivate.h
126 EXPORT_XPCOM_API(nsresult)
127 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority)
129 return NS_OK;
132 EXPORT_XPCOM_API(nsresult)
133 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine)
135 return NS_OK;