diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /xpcom/reflect/xptinfo/xptiTypelibGuts.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'xpcom/reflect/xptinfo/xptiTypelibGuts.cpp')
-rw-r--r-- | xpcom/reflect/xptinfo/xptiTypelibGuts.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/xpcom/reflect/xptinfo/xptiTypelibGuts.cpp b/xpcom/reflect/xptinfo/xptiTypelibGuts.cpp new file mode 100644 index 000000000..e2965d0b1 --- /dev/null +++ b/xpcom/reflect/xptinfo/xptiTypelibGuts.cpp @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 8; 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/. */ + +/* Implementation of xptiTypelibGuts. */ + +#include "xptiprivate.h" +#include "mozilla/XPTInterfaceInfoManager.h" + +using namespace mozilla; + +// Ensure through static analysis that xptiTypelibGuts won't have a vtable. +template <class T> +class MOZ_NEEDS_NO_VTABLE_TYPE CheckNoVTable +{ +}; +CheckNoVTable<xptiTypelibGuts> gChecker; + +// static +xptiTypelibGuts* +xptiTypelibGuts::Create(XPTHeader* aHeader) +{ + NS_ASSERTION(aHeader, "bad param"); + size_t n = sizeof(xptiTypelibGuts) + + sizeof(xptiInterfaceEntry*) * (aHeader->num_interfaces - 1); + void* place = XPT_CALLOC8(gXPTIStructArena, n); + if (!place) + return nullptr; + return new(place) xptiTypelibGuts(aHeader); +} + +xptiInterfaceEntry* +xptiTypelibGuts::GetEntryAt(uint16_t i) +{ + static const nsID zeroIID = + { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }; + + NS_ASSERTION(mHeader, "bad state"); + NS_ASSERTION(i < GetEntryCount(), "bad index"); + + xptiInterfaceEntry* r = mEntryArray[i]; + if (r) + return r; + + XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i; + + XPTInterfaceInfoManager::xptiWorkingSet& set = + XPTInterfaceInfoManager::GetSingleton()->mWorkingSet; + + { + ReentrantMonitorAutoEnter monitor(set.mTableReentrantMonitor); + if (iface->iid.Equals(zeroIID)) + r = set.mNameTable.Get(iface->name); + else + r = set.mIIDTable.Get(iface->iid); + } + + if (r) + SetEntryAt(i, r); + + return r; +} + +const char* +xptiTypelibGuts::GetEntryNameAt(uint16_t i) +{ + NS_ASSERTION(mHeader, "bad state"); + NS_ASSERTION(i < GetEntryCount(), "bad index"); + + XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i; + + return iface->name; +} |