| 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 js_WrapperCallbacks_h |
| 8 |
#define js_WrapperCallbacks_h |
| 9 |
|
| 10 |
#include "js/TypeDecls.h" |
| 11 |
|
| 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. |
| 20 |
*/ |
| 21 |
using JSWrapObjectCallback = JSObject* (*)(JSContext*, JS::HandleObject, |
| 22 |
JS::HandleObject); |
| 23 |
|
| 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. |
| 30 |
*/ |
| 31 |
using JSPreWrapCallback = void (*)(JSContext*, JS::HandleObject, |
| 32 |
JS::HandleObject, JS::HandleObject, |
| 33 |
JS::HandleObject, JS::MutableHandleObject); |
| 34 |
|
| 35 |
struct JSWrapObjectCallbacks { |
| 36 |
JSWrapObjectCallback wrap; |
| 37 |
JSPreWrapCallback preWrap; |
| 38 |
}; |
| 39 |
|
| 40 |
#endif // js_WrapperCallbacks_h |