Source code

Revision control

Other Tools

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 proxy_Proxy_h
8
#define proxy_Proxy_h
9
10
#include "NamespaceImports.h"
11
12
#include "js/Class.h"
13
14
namespace js {
15
16
class GlobalObject;
17
18
/*
19
* Dispatch point for handlers that executes the appropriate C++ or scripted
20
* traps.
21
*
22
* Important: All proxy methods need either (a) an AutoEnterPolicy in their
23
* Proxy::foo entry point below or (b) an override in SecurityWrapper. See bug
24
* 945826 comment 0.
25
*/
26
class Proxy {
27
public:
28
/* Standard internal methods. */
29
static bool getOwnPropertyDescriptor(
30
JSContext* cx, HandleObject proxy, HandleId id,
31
MutableHandle<JS::PropertyDescriptor> desc);
32
static bool defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
33
Handle<JS::PropertyDescriptor> desc,
34
ObjectOpResult& result);
35
static bool ownPropertyKeys(JSContext* cx, HandleObject proxy,
36
MutableHandleIdVector props);
37
static bool delete_(JSContext* cx, HandleObject proxy, HandleId id,
38
ObjectOpResult& result);
39
static bool enumerate(JSContext* cx, HandleObject proxy,
40
MutableHandleIdVector props);
41
static bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible);
42
static bool preventExtensions(JSContext* cx, HandleObject proxy,
43
ObjectOpResult& result);
44
static bool getPrototype(JSContext* cx, HandleObject proxy,
45
MutableHandleObject protop);
46
static bool setPrototype(JSContext* cx, HandleObject proxy,
47
HandleObject proto, ObjectOpResult& result);
48
static bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy,
49
bool* isOrdinary,
50
MutableHandleObject protop);
51
static bool setImmutablePrototype(JSContext* cx, HandleObject proxy,
52
bool* succeeded);
53
static bool has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp);
54
static bool get(JSContext* cx, HandleObject proxy, HandleValue receiver,
55
HandleId id, MutableHandleValue vp);
56
static bool getInternal(JSContext* cx, HandleObject proxy,
57
HandleValue receiver, HandleId id,
58
MutableHandleValue vp);
59
static bool set(JSContext* cx, HandleObject proxy, HandleId id, HandleValue v,
60
HandleValue receiver, ObjectOpResult& result);
61
static bool setInternal(JSContext* cx, HandleObject proxy, HandleId id,
62
HandleValue v, HandleValue receiver,
63
ObjectOpResult& result);
64
static bool call(JSContext* cx, HandleObject proxy, const CallArgs& args);
65
static bool construct(JSContext* cx, HandleObject proxy,
66
const CallArgs& args);
67
68
/* SpiderMonkey extensions. */
69
static bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp);
70
static bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy,
71
MutableHandleIdVector props);
72
static bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
73
const CallArgs& args);
74
static bool hasInstance(JSContext* cx, HandleObject proxy,
75
MutableHandleValue v, bool* bp);
76
static bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls);
77
static bool isArray(JSContext* cx, HandleObject proxy,
78
JS::IsArrayAnswer* answer);
79
static const char* className(JSContext* cx, HandleObject proxy);
80
static JSString* fun_toString(JSContext* cx, HandleObject proxy,
81
bool isToSource);
82
static RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy);
83
static bool boxedValue_unbox(JSContext* cx, HandleObject proxy,
84
MutableHandleValue vp);
85
86
static bool getElements(JSContext* cx, HandleObject obj, uint32_t begin,
87
uint32_t end, ElementAdder* adder);
88
89
static void trace(JSTracer* trc, JSObject* obj);
90
};
91
92
size_t proxy_ObjectMoved(JSObject* obj, JSObject* old);
93
94
// These functions are used by JIT code
95
96
bool ProxyHas(JSContext* cx, HandleObject proxy, HandleValue idVal,
97
MutableHandleValue result);
98
99
bool ProxyHasOwn(JSContext* cx, HandleObject proxy, HandleValue idVal,
100
MutableHandleValue result);
101
102
bool ProxyGetProperty(JSContext* cx, HandleObject proxy, HandleId id,
103
MutableHandleValue vp);
104
105
bool ProxyGetPropertyByValue(JSContext* cx, HandleObject proxy,
106
HandleValue idVal, MutableHandleValue vp);
107
108
bool ProxySetProperty(JSContext* cx, HandleObject proxy, HandleId id,
109
HandleValue val, bool strict);
110
111
bool ProxySetPropertyByValue(JSContext* cx, HandleObject proxy,
112
HandleValue idVal, HandleValue val, bool strict);
113
114
extern JSObject* InitProxyClass(JSContext* cx, Handle<GlobalObject*> global);
115
116
} /* namespace js */
117
118
#endif /* proxy_Proxy_h */