xpcom/build/FrozenFunctions.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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.
    19  */
    20 XPCOM_API(nsresult)
    21 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, uint32_t priority);
    23 XPCOM_API(nsresult)
    24 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
    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,
    97 };
    99 EXPORT_XPCOM_API(nsresult)
   100 NS_GetFrozenFunctions(XPCOMFunctions *functions, const char* /* libraryPath */)
   101 {
   102     if (!functions)
   103         return NS_ERROR_OUT_OF_MEMORY;
   105     if (functions->version != XPCOM_GLUE_VERSION)
   106         return NS_ERROR_FAILURE;
   108     uint32_t size = functions->size;
   109     if (size > sizeof(XPCOMFunctions))
   110         size = sizeof(XPCOMFunctions);
   112     size -= offsetof(XPCOMFunctions, init);
   114     memcpy(&functions->init, &kFrozenFunctions.init, size);
   116     return NS_OK;
   117 }
   119 /*
   120  * Stubs for nsXPCOMPrivate.h
   121  */
   123 EXPORT_XPCOM_API(nsresult)
   124 NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, uint32_t priority)
   125 {
   126   return NS_OK;
   127 }
   129 EXPORT_XPCOM_API(nsresult)
   130 NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
   131 {
   132   return NS_OK;
   133 }

mercurial