LCOV - code coverage report
Current view: top level - xpcom/reflect/xptinfo - xptiTypelibGuts.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 25 27 92.6 %
Date: 2017-07-14 16:53:18 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /* Implementation of xptiTypelibGuts. */
       7             : 
       8             : #include "xptiprivate.h"
       9             : #include "mozilla/XPTInterfaceInfoManager.h"
      10             : 
      11             : using namespace mozilla;
      12             : 
      13             : // Ensure through static analysis that xptiTypelibGuts won't have a vtable.
      14             : template <class T>
      15             : class MOZ_NEEDS_NO_VTABLE_TYPE CheckNoVTable
      16             : {
      17             : };
      18             : CheckNoVTable<xptiTypelibGuts> gChecker;
      19             : 
      20             : // static
      21             : xptiTypelibGuts*
      22         522 : xptiTypelibGuts::Create(XPTHeader* aHeader)
      23             : {
      24         522 :     NS_ASSERTION(aHeader, "bad param");
      25             :     size_t n = sizeof(xptiTypelibGuts) +
      26         522 :                sizeof(xptiInterfaceEntry*) * (aHeader->num_interfaces - 1);
      27         522 :     void* place = XPT_CALLOC8(gXPTIStructArena, n);
      28         522 :     if (!place)
      29           0 :         return nullptr;
      30         522 :     return new(place) xptiTypelibGuts(aHeader);
      31             : }
      32             : 
      33             : xptiInterfaceEntry*
      34        6037 : xptiTypelibGuts::GetEntryAt(uint16_t i)
      35             : {
      36             :     static const nsID zeroIID =
      37             :         { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } };
      38             : 
      39        6037 :     NS_ASSERTION(mHeader, "bad state");
      40        6037 :     NS_ASSERTION(i < GetEntryCount(), "bad index");
      41             : 
      42        6037 :     xptiInterfaceEntry* r = mEntryArray[i];
      43        6037 :     if (r)
      44        5766 :         return r;
      45             : 
      46         271 :     XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i;
      47             : 
      48             :     XPTInterfaceInfoManager::xptiWorkingSet& set =
      49         271 :         XPTInterfaceInfoManager::GetSingleton()->mWorkingSet;
      50             : 
      51             :     {
      52         542 :         ReentrantMonitorAutoEnter monitor(set.mTableReentrantMonitor);
      53         271 :         if (iface->iid.Equals(zeroIID))
      54         271 :             r = set.mNameTable.Get(iface->name);
      55             :         else
      56           0 :             r = set.mIIDTable.Get(iface->iid);
      57             :     }
      58             : 
      59         271 :     if (r)
      60         205 :         SetEntryAt(i, r);
      61             : 
      62         271 :     return r;
      63             : }
      64             : 
      65             : const char*
      66          66 : xptiTypelibGuts::GetEntryNameAt(uint16_t i)
      67             : {
      68          66 :     NS_ASSERTION(mHeader, "bad state");
      69          66 :     NS_ASSERTION(i < GetEntryCount(), "bad index");
      70             : 
      71          66 :     XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i;
      72             : 
      73          66 :     return iface->name;
      74             : }

Generated by: LCOV version 1.13