LCOV - code coverage report
Current view: top level - js/src/proxy - DeadObjectProxy.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 6 66.7 %
Date: 2017-07-14 16:53:18 Functions: 5 12 41.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       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
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef proxy_DeadObjectProxy_h
       8             : #define proxy_DeadObjectProxy_h
       9             : 
      10             : #include "js/Proxy.h"
      11             : 
      12             : namespace js {
      13             : 
      14             : class ProxyObject;
      15             : 
      16             : enum DeadProxyIsCallableIsConstructorOption
      17             : {
      18             :     DeadProxyNotCallableNotConstructor,
      19             :     DeadProxyNotCallableIsConstructor,
      20             :     DeadProxyIsCallableNotConstructor,
      21             :     DeadProxyIsCallableIsConstructor
      22             : };
      23             : 
      24             : template <DeadProxyIsCallableIsConstructorOption CC>
      25             : class DeadObjectProxy : public BaseProxyHandler
      26             : {
      27             :   public:
      28             :     explicit constexpr DeadObjectProxy()
      29             :       : BaseProxyHandler(&family)
      30             :     { }
      31             : 
      32             :     /* Standard internal methods. */
      33             :     virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
      34             :                                           MutableHandle<PropertyDescriptor> desc) const override;
      35             :     virtual bool defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
      36             :                                 Handle<PropertyDescriptor> desc,
      37             :                                 ObjectOpResult& result) const override;
      38             :     virtual bool ownPropertyKeys(JSContext* cx, HandleObject wrapper,
      39             :                                  AutoIdVector& props) const override;
      40             :     virtual bool delete_(JSContext* cx, HandleObject wrapper, HandleId id,
      41             :                          ObjectOpResult& result) const override;
      42             :     virtual bool getPrototype(JSContext* cx, HandleObject proxy,
      43             :                               MutableHandleObject protop) const override;
      44             :     virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
      45             :                                         MutableHandleObject protop) const override;
      46             :     virtual bool preventExtensions(JSContext* cx, HandleObject proxy,
      47             :                                    ObjectOpResult& result) const override;
      48             :     virtual bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const override;
      49             :     virtual bool call(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
      50             :     virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
      51             : 
      52             :     /* SpiderMonkey extensions. */
      53             :     // BaseProxyHandler::getPropertyDescriptor will throw by calling getOwnPropertyDescriptor.
      54             :     // BaseProxyHandler::enumerate will throw by calling ownKeys.
      55             :     virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
      56             :                             const CallArgs& args) const override;
      57             :     virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
      58             :                              bool* bp) const override;
      59             :     virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override;
      60             :     virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const override;
      61             :     virtual const char* className(JSContext* cx, HandleObject proxy) const override;
      62             :     virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const override;
      63             :     virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
      64             : 
      65          10 :     virtual bool isCallable(JSObject* obj) const override {
      66          10 :         return CC == DeadProxyIsCallableIsConstructor || CC == DeadProxyIsCallableNotConstructor;
      67             :     }
      68           0 :     virtual bool isConstructor(JSObject* obj) const override {
      69           0 :         return CC == DeadProxyIsCallableIsConstructor || CC == DeadProxyNotCallableIsConstructor;
      70             :     }
      71             : 
      72      104954 :     static const DeadObjectProxy* singleton() {
      73             :         static DeadObjectProxy singleton;
      74      104954 :         return &singleton;
      75             :     }
      76             : 
      77             :     static const char family;
      78             : };
      79             : 
      80             : bool
      81             : IsDeadProxyObject(JSObject* obj);
      82             : 
      83             : const BaseProxyHandler*
      84             : SelectDeadProxyHandler(ProxyObject* obj);
      85             : 
      86             : JSObject*
      87             : NewDeadProxyObject(JSContext* cx, JSObject* origObj = nullptr);
      88             : 
      89             : } /* namespace js */
      90             : 
      91             : #endif /* proxy_DeadObjectProxy_h */

Generated by: LCOV version 1.13