LCOV - code coverage report
Current view: top level - js/src/proxy - ScriptedProxyHandler.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 3 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.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             :  * 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_ScriptedProxyHandler_h
       8             : #define proxy_ScriptedProxyHandler_h
       9             : 
      10             : #include "js/Proxy.h"
      11             : 
      12             : namespace js {
      13             : 
      14             : /* Derived class for all scripted proxy handlers. */
      15             : class ScriptedProxyHandler : public BaseProxyHandler
      16             : {
      17             :   public:
      18             :     constexpr ScriptedProxyHandler()
      19             :       : BaseProxyHandler(&family)
      20             :     { }
      21             : 
      22             :     /* Standard internal methods. */
      23             :     virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
      24             :                                           MutableHandle<PropertyDescriptor> desc) const override;
      25             :     virtual bool defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
      26             :                                 Handle<PropertyDescriptor> desc,
      27             :                                 ObjectOpResult& result) const override;
      28             :     virtual bool ownPropertyKeys(JSContext* cx, HandleObject proxy,
      29             :                                  AutoIdVector& props) const override;
      30             :     virtual bool delete_(JSContext* cx, HandleObject proxy, HandleId id,
      31             :                          ObjectOpResult& result) const override;
      32             : 
      33             :     virtual bool getPrototype(JSContext* cx, HandleObject proxy,
      34             :                               MutableHandleObject protop) const override;
      35             :     virtual bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto,
      36             :                               ObjectOpResult& result) const override;
      37             :     /* Non-standard, but needed to correctly implement OrdinaryGetPrototypeOf. */
      38             :     virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
      39             :                                        MutableHandleObject protop) const override;
      40             :     /* Non-standard, but needed to handle revoked proxies. */
      41             :     virtual bool setImmutablePrototype(JSContext* cx, HandleObject proxy,
      42             :                                        bool* succeeded) const override;
      43             : 
      44             :     virtual bool preventExtensions(JSContext* cx, HandleObject proxy,
      45             :                                    ObjectOpResult& result) const override;
      46             :     virtual bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const override;
      47             : 
      48             :     virtual bool has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const override;
      49             :     virtual bool get(JSContext* cx, HandleObject proxy, HandleValue receiver, HandleId id,
      50             :                      MutableHandleValue vp) const override;
      51             :     virtual bool set(JSContext* cx, HandleObject proxy, HandleId id, HandleValue v,
      52             :                      HandleValue receiver, ObjectOpResult& result) const override;
      53             :     virtual bool call(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
      54             :     virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
      55             : 
      56             :     /* SpiderMonkey extensions. */
      57           0 :     virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const override {
      58           0 :         return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
      59             :     }
      60             : 
      61             :     // A scripted proxy should not be treated as generic in most contexts.
      62             :     virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
      63             :                             const CallArgs& args) const override;
      64             :     virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
      65             :                              bool* bp) const override;
      66             :     virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override;
      67             :     virtual bool isArray(JSContext* cx, HandleObject proxy,
      68             :                          JS::IsArrayAnswer* answer) const override;
      69             :     virtual const char* className(JSContext* cx, HandleObject proxy) const override;
      70             :     virtual JSString* fun_toString(JSContext* cx, HandleObject proxy,
      71             :                                    unsigned indent) const override;
      72             :     virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
      73             :     virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy,
      74             :                                   MutableHandleValue vp) const override;
      75             : 
      76             :     virtual bool isCallable(JSObject* obj) const override;
      77             :     virtual bool isConstructor(JSObject* obj) const override;
      78             : 
      79           0 :     virtual bool isScripted() const override { return true; }
      80             : 
      81             :     static const char family;
      82             :     static const ScriptedProxyHandler singleton;
      83             : 
      84             :     // The "proxy extra" slot index in which the handler is stored. Revocable proxies need to set
      85             :     // this at revocation time.
      86             :     static const int HANDLER_EXTRA = 0;
      87             :     static const int IS_CALLCONSTRUCT_EXTRA = 1;
      88             :     // Bitmasks for the "call/construct" slot
      89             :     static const int IS_CALLABLE    = 1 << 0;
      90             :     static const int IS_CONSTRUCTOR = 1 << 1;
      91             :     // The "function extended" slot index in which the revocation object is stored. Per spec, this
      92             :     // is to be cleared during the first revocation.
      93             :     static const int REVOKE_SLOT = 0;
      94             : 
      95             :     static JSObject* handlerObject(const JSObject* proxy);
      96             : };
      97             : 
      98             : bool
      99             : proxy(JSContext* cx, unsigned argc, Value* vp);
     100             : 
     101             : bool
     102             : proxy_revocable(JSContext* cx, unsigned argc, Value* vp);
     103             : 
     104             : } /* namespace js */
     105             : 
     106             : #endif /* proxy_ScriptedProxyHandler_h */

Generated by: LCOV version 1.13