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 __FilteringWrapper_h__
8 #define __FilteringWrapper_h__
10 #include "XrayWrapper.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/Maybe.h"
13 #include "js/CallNonGenericMethod.h"
14 #include "js/Wrapper.h"
18 template <typename Base
, typename Policy
>
19 class FilteringWrapper
: public Base
{
21 constexpr explicit FilteringWrapper(unsigned flags
) : Base(flags
) {}
23 virtual bool enter(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
24 JS::Handle
<jsid
> id
, js::Wrapper::Action act
,
25 bool mayThrow
, bool* bp
) const override
;
27 virtual bool getOwnPropertyDescriptor(
28 JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
, JS::Handle
<jsid
> id
,
29 JS::MutableHandle
<mozilla::Maybe
<JS::PropertyDescriptor
>> desc
)
31 virtual bool ownPropertyKeys(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
32 JS::MutableHandleIdVector props
) const override
;
34 virtual bool getOwnEnumerablePropertyKeys(
35 JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
36 JS::MutableHandleIdVector props
) const override
;
37 virtual bool enumerate(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
38 JS::MutableHandleIdVector props
) const override
;
40 virtual bool call(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
41 const JS::CallArgs
& args
) const override
;
42 virtual bool construct(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
43 const JS::CallArgs
& args
) const override
;
45 virtual bool nativeCall(JSContext
* cx
, JS::IsAcceptableThis test
,
47 const JS::CallArgs
& args
) const override
;
49 virtual bool getPrototype(JSContext
* cx
, JS::HandleObject wrapper
,
50 JS::MutableHandleObject protop
) const override
;
52 static const FilteringWrapper singleton
;
57 #endif /* __FilteringWrapper_h__ */