/usr/include/thunderbird/mozilla/ModuleUtils.h is in thunderbird-dev 1:38.6.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#ifndef mozilla_GenericModule_h
#define mozilla_GenericModule_h
#include "mozilla/Attributes.h"
#include "mozilla/Module.h"
#define NS_GENERIC_FACTORY_CONSTRUCTOR(_InstanceClass) \
static nsresult \
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
void **aResult) \
{ \
nsresult rv; \
\
_InstanceClass * inst; \
\
*aResult = nullptr; \
if (nullptr != aOuter) { \
rv = NS_ERROR_NO_AGGREGATION; \
return rv; \
} \
\
inst = new _InstanceClass(); \
if (nullptr == inst) { \
rv = NS_ERROR_OUT_OF_MEMORY; \
return rv; \
} \
NS_ADDREF(inst); \
rv = inst->QueryInterface(aIID, aResult); \
NS_RELEASE(inst); \
\
return rv; \
}
#define NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(_InstanceClass, _InitMethod) \
static nsresult \
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
void **aResult) \
{ \
nsresult rv; \
\
_InstanceClass * inst; \
\
*aResult = nullptr; \
if (nullptr != aOuter) { \
rv = NS_ERROR_NO_AGGREGATION; \
return rv; \
} \
\
inst = new _InstanceClass(); \
if (nullptr == inst) { \
rv = NS_ERROR_OUT_OF_MEMORY; \
return rv; \
} \
NS_ADDREF(inst); \
rv = inst->_InitMethod(); \
if(NS_SUCCEEDED(rv)) { \
rv = inst->QueryInterface(aIID, aResult); \
} \
NS_RELEASE(inst); \
\
return rv; \
}
// 'Constructor' that uses an existing getter function that gets a singleton.
// NOTE: assumes that getter does an AddRef - so additional AddRef is not done.
#define NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(_InstanceClass, _GetterProc) \
static nsresult \
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
void **aResult) \
{ \
nsresult rv; \
\
_InstanceClass * inst; \
\
*aResult = nullptr; \
if (nullptr != aOuter) { \
rv = NS_ERROR_NO_AGGREGATION; \
return rv; \
} \
\
inst = already_AddRefed<_InstanceClass>(_GetterProc()).take(); \
if (nullptr == inst) { \
rv = NS_ERROR_OUT_OF_MEMORY; \
return rv; \
} \
/* NS_ADDREF(inst); */ \
rv = inst->QueryInterface(aIID, aResult); \
NS_RELEASE(inst); \
\
return rv; \
}
#ifndef MOZILLA_INTERNAL_API
#include "nsIModule.h"
#include "nsISupportsUtils.h"
namespace mozilla {
class GenericModule final : public nsIModule
{
~GenericModule() {}
public:
explicit GenericModule(const mozilla::Module* aData) : mData(aData) {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIMODULE
private:
const mozilla::Module* mData;
};
} // namespace mozilla
#define NS_IMPL_MOZILLA192_NSGETMODULE(module) \
extern "C" NS_EXPORT nsresult \
NSGetModule(nsIComponentManager* aCompMgr, \
nsIFile* aLocation, \
nsIModule** aResult) \
{ \
*aResult = new mozilla::GenericModule(module); \
NS_ADDREF(*aResult); \
return NS_OK; \
}
#endif
#endif // mozilla_GenericModule_h
|