tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WrappedFunctionObject.h (1431B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef builtin_WrappedFunctionObject_h
      8 #define builtin_WrappedFunctionObject_h
      9 
     10 #include "js/Value.h"
     11 #include "vm/NativeObject.h"
     12 
     13 namespace js {
     14 
     15 // Implementing Wrapped Function Exotic Objects from the ShadowRealms proposal
     16 // https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects
     17 //
     18 // These are produced as callables are passed across ShadowRealm boundaries,
     19 // preventing functions from piercing the shadow realm barrier.
     20 class WrappedFunctionObject : public NativeObject {
     21 public:
     22  static const JSClass class_;
     23 
     24  enum { WrappedTargetFunctionSlot, SlotCount };
     25 
     26  JSObject* getTargetFunction() const {
     27    return &getFixedSlot(WrappedTargetFunctionSlot).toObject();
     28  }
     29 
     30  void setTargetFunction(JSObject& obj) {
     31    setFixedSlot(WrappedTargetFunctionSlot, ObjectValue(obj));
     32  }
     33 };
     34 
     35 bool WrappedFunctionCreate(JSContext* cx, Realm* callerRealm,
     36                           Handle<JSObject*> target, MutableHandle<Value> res);
     37 
     38 bool GetWrappedValue(JSContext* cx, Realm* callerRealm, Handle<Value> value,
     39                     MutableHandle<Value> res);
     40 
     41 }  // namespace js
     42 
     43 #endif