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/. */
7 #ifndef builtin_WrappedFunctionObject_h
8 #define builtin_WrappedFunctionObject_h
11 #include "vm/NativeObject.h"
15 // Implementing Wrapped Function Exotic Objects from the ShadowRealms proposal
16 // https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects
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
{
22 static const JSClass class_
;
24 enum { WrappedTargetFunctionSlot
, SlotCount
};
26 JSObject
* getTargetFunction() const {
27 return &getFixedSlot(WrappedTargetFunctionSlot
).toObject();
30 void setTargetFunction(JSObject
& obj
) {
31 setFixedSlot(WrappedTargetFunctionSlot
, ObjectValue(obj
));
35 bool WrappedFunctionCreate(JSContext
* cx
, Realm
* callerRealm
,
36 Handle
<JSObject
*> target
, MutableHandle
<Value
> res
);
38 bool GetWrappedValue(JSContext
* cx
, Realm
* callerRealm
, Handle
<Value
> value
,
39 MutableHandle
<Value
> res
);