2015-04-09 20:25:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-20 17:56:41 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsXPCOM.h"
|
|
|
|
#include "nsXPCOMPrivate.h"
|
|
|
|
#include "nsXPCOMStrings.h"
|
|
|
|
#include "xptcall.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private Method to register an exit routine. This method
|
2014-08-13 22:45:37 +04:00
|
|
|
* used to allow you to setup a callback that will be called from
|
|
|
|
* the NS_ShutdownXPCOM function after all services and
|
2013-03-20 17:56:41 +04:00
|
|
|
* components have gone away. It was fatally flawed in that the component
|
|
|
|
* DLL could be released before the exit function was called; it is now a
|
|
|
|
* stub implementation that does nothing.
|
|
|
|
*/
|
|
|
|
XPCOM_API(nsresult)
|
2014-08-13 22:45:37 +04:00
|
|
|
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority);
|
2013-03-20 17:56:41 +04:00
|
|
|
|
|
|
|
XPCOM_API(nsresult)
|
2014-08-13 22:45:37 +04:00
|
|
|
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine);
|
2013-03-20 17:56:41 +04:00
|
|
|
|
|
|
|
static const XPCOMFunctions kFrozenFunctions = {
|
2014-08-13 22:45:37 +04:00
|
|
|
XPCOM_GLUE_VERSION,
|
|
|
|
sizeof(XPCOMFunctions),
|
|
|
|
&NS_InitXPCOM2,
|
|
|
|
&NS_ShutdownXPCOM,
|
|
|
|
&NS_GetServiceManager,
|
|
|
|
&NS_GetComponentManager,
|
|
|
|
&NS_GetComponentRegistrar,
|
|
|
|
&NS_GetMemoryManager,
|
|
|
|
&NS_NewLocalFile,
|
|
|
|
&NS_NewNativeLocalFile,
|
|
|
|
&NS_RegisterXPCOMExitRoutine,
|
|
|
|
&NS_UnregisterXPCOMExitRoutine,
|
|
|
|
|
|
|
|
// these functions were added post 1.4
|
|
|
|
&NS_GetDebug,
|
|
|
|
nullptr,
|
|
|
|
|
|
|
|
// these functions were added post 1.6
|
|
|
|
&NS_StringContainerInit,
|
|
|
|
&NS_StringContainerFinish,
|
|
|
|
&NS_StringGetData,
|
|
|
|
&NS_StringSetData,
|
|
|
|
&NS_StringSetDataRange,
|
|
|
|
&NS_StringCopy,
|
|
|
|
&NS_CStringContainerInit,
|
|
|
|
&NS_CStringContainerFinish,
|
|
|
|
&NS_CStringGetData,
|
|
|
|
&NS_CStringSetData,
|
|
|
|
&NS_CStringSetDataRange,
|
|
|
|
&NS_CStringCopy,
|
|
|
|
&NS_CStringToUTF16,
|
|
|
|
&NS_UTF16ToCString,
|
|
|
|
&NS_StringCloneData,
|
|
|
|
&NS_CStringCloneData,
|
|
|
|
|
|
|
|
// these functions were added post 1.7 (post Firefox 1.0)
|
2015-04-01 08:29:55 +03:00
|
|
|
&moz_xmalloc,
|
|
|
|
&moz_xrealloc,
|
|
|
|
&free,
|
2014-08-13 22:45:37 +04:00
|
|
|
&NS_StringContainerInit2,
|
|
|
|
&NS_CStringContainerInit2,
|
|
|
|
&NS_StringGetMutableData,
|
|
|
|
&NS_CStringGetMutableData,
|
|
|
|
nullptr,
|
|
|
|
|
|
|
|
// these functions were added post 1.8
|
|
|
|
&NS_DebugBreak,
|
|
|
|
&NS_LogInit,
|
|
|
|
&NS_LogTerm,
|
|
|
|
&NS_LogAddRef,
|
|
|
|
&NS_LogRelease,
|
|
|
|
&NS_LogCtor,
|
|
|
|
&NS_LogDtor,
|
|
|
|
&NS_LogCOMPtrAddRef,
|
|
|
|
&NS_LogCOMPtrRelease,
|
|
|
|
&NS_GetXPTCallStub,
|
|
|
|
&NS_DestroyXPTCallStub,
|
|
|
|
&NS_InvokeByIndex,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&NS_StringSetIsVoid,
|
|
|
|
&NS_StringGetIsVoid,
|
|
|
|
&NS_CStringSetIsVoid,
|
|
|
|
&NS_CStringGetIsVoid,
|
|
|
|
|
|
|
|
// these functions were added post 1.9, but then made obsolete
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
|
|
|
|
&NS_CycleCollectorSuspect3,
|
2013-03-20 17:56:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 22:45:37 +04:00
|
|
|
NS_GetFrozenFunctions(XPCOMFunctions* aFunctions, const char* /* aLibraryPath */)
|
2013-03-20 17:56:41 +04:00
|
|
|
{
|
2014-08-13 22:45:37 +04:00
|
|
|
if (!aFunctions) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2013-03-20 17:56:41 +04:00
|
|
|
|
2014-08-13 22:45:37 +04:00
|
|
|
if (aFunctions->version != XPCOM_GLUE_VERSION) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2013-03-20 17:56:41 +04:00
|
|
|
|
2014-08-13 22:45:37 +04:00
|
|
|
uint32_t size = aFunctions->size;
|
|
|
|
if (size > sizeof(XPCOMFunctions)) {
|
|
|
|
size = sizeof(XPCOMFunctions);
|
|
|
|
}
|
2013-03-20 17:56:41 +04:00
|
|
|
|
2014-08-13 22:45:37 +04:00
|
|
|
size -= offsetof(XPCOMFunctions, init);
|
2013-03-20 17:56:41 +04:00
|
|
|
|
2014-08-13 22:45:37 +04:00
|
|
|
memcpy(&aFunctions->init, &kFrozenFunctions.init, size);
|
2013-03-20 17:56:41 +04:00
|
|
|
|
2014-08-13 22:45:37 +04:00
|
|
|
return NS_OK;
|
2013-03-20 17:56:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stubs for nsXPCOMPrivate.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 22:45:37 +04:00
|
|
|
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority)
|
2013-03-20 17:56:41 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 22:45:37 +04:00
|
|
|
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine)
|
2013-03-20 17:56:41 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|