Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / public / WrapperCallbacks.h
blob24f5aa7272682a5298020de12fcb067949902e99
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 js_WrapperCallbacks_h
8 #define js_WrapperCallbacks_h
10 #include "js/TypeDecls.h"
12 /**
13 * Callback used to ask the embedding for the cross compartment wrapper handler
14 * that implements the desired prolicy for this kind of object in the
15 * destination compartment. |obj| is the object to be wrapped. If |existing| is
16 * non-nullptr, it will point to an existing wrapper object that should be
17 * re-used if possible. |existing| is guaranteed to be a cross-compartment
18 * wrapper with a lazily-defined prototype and the correct global. It is
19 * guaranteed not to wrap a function.
21 using JSWrapObjectCallback = JSObject* (*)(JSContext*, JS::HandleObject,
22 JS::HandleObject);
24 /**
25 * Callback used by the wrap hook to ask the embedding to prepare an object
26 * for wrapping in a context. This might include unwrapping other wrappers
27 * or even finding a more suitable object for the new compartment. If |origObj|
28 * is non-null, then it is the original object we are going to swap into during
29 * a transplant.
31 using JSPreWrapCallback = void (*)(JSContext*, JS::HandleObject,
32 JS::HandleObject, JS::HandleObject,
33 JS::HandleObject, JS::MutableHandleObject);
35 struct JSWrapObjectCallbacks {
36 JSWrapObjectCallback wrap;
37 JSPreWrapCallback preWrap;
40 #endif // js_WrapperCallbacks_h