LCOV - code coverage report
Current view: top level - dom/bindings - RootedRefPtr.h (source / functions) Hit Total Coverage
Test: output.info Lines: 5 9 55.6 %
Date: 2017-07-14 16:53:18 Functions: 6 40 15.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : /**
       8             :  * An implementation of Rooted for RefPtr<T>.  This works by assuming that T has
       9             :  * a Trace() method defined on it which will trace whatever things inside the T
      10             :  * instance need tracing.
      11             :  *
      12             :  * This implementation has one serious drawback: operator= doesn't work right
      13             :  * because it's declared on Rooted directly and expects the type Rooted is
      14             :  * templated over.
      15             :  */
      16             : 
      17             : #ifndef mozilla_RootedRefPtr_h__
      18             : #define mozilla_RootedRefPtr_h__
      19             : 
      20             : #include "mozilla/RefPtr.h"
      21             : #include "js/GCPolicyAPI.h"
      22             : #include "js/RootingAPI.h"
      23             : 
      24             : namespace JS {
      25             : template<typename T>
      26             : struct GCPolicy<RefPtr<T>>
      27             : {
      28         194 :   static RefPtr<T> initial() {
      29         194 :     return RefPtr<T>();
      30             :   }
      31             : 
      32           0 :   static void trace(JSTracer* trc, RefPtr<T>* tp, const char* name)
      33             :   {
      34           0 :     if (*tp) {
      35           0 :       (*tp)->Trace(trc);
      36             :     }
      37           0 :   }
      38             : };
      39             : } // namespace JS
      40             : 
      41             : namespace js {
      42             : template<typename T, typename Wrapper>
      43         194 : struct WrappedPtrOperations<RefPtr<T>, Wrapper>
      44             : {
      45         194 :   operator T*() const
      46             :   {
      47         194 :     return static_cast<const Wrapper*>(this)->get();
      48             :   }
      49             : };
      50             : } // namespace js
      51             : 
      52             : #endif /* mozilla_RootedRefPtr_h__ */

Generated by: LCOV version 1.13