Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set ts=8 sts=4 et sw=4 tw=99: */
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 AddonWrapper_h
8 : #define AddonWrapper_h
9 :
10 : #include "mozilla/Attributes.h"
11 :
12 : #include "nsID.h"
13 :
14 : #include "jswrapper.h"
15 :
16 : namespace xpc {
17 :
18 : bool
19 : InterposeProperty(JSContext* cx, JS::HandleObject target, const nsIID* iid, JS::HandleId id,
20 : JS::MutableHandle<JS::PropertyDescriptor> descriptor);
21 :
22 : bool
23 : InterposeCall(JSContext* cx, JS::HandleObject wrapper,
24 : const JS::CallArgs& args, bool& done);
25 :
26 : template<typename Base>
27 : class AddonWrapper : public Base {
28 : public:
29 0 : explicit constexpr AddonWrapper(unsigned flags) : Base(flags) { }
30 :
31 : virtual bool getOwnPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> wrapper,
32 : JS::Handle<jsid> id,
33 : JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
34 : virtual bool defineProperty(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
35 : JS::Handle<JS::PropertyDescriptor> desc,
36 : JS::ObjectOpResult& result) const override;
37 : virtual bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
38 : JS::ObjectOpResult& result) const override;
39 : virtual bool get(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JS::Value> receiver,
40 : JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
41 : virtual bool set(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id, JS::HandleValue v,
42 : JS::HandleValue receiver, JS::ObjectOpResult& result) const override;
43 : virtual bool call(JSContext* cx, JS::Handle<JSObject*> wrapper,
44 : const JS::CallArgs& args) const override;
45 :
46 : virtual bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> wrapper,
47 : JS::Handle<jsid> id,
48 : JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
49 :
50 : static const AddonWrapper singleton;
51 : };
52 :
53 : } // namespace xpc
54 :
55 : #endif // AddonWrapper_h
|