|
|
|
Lines 1038-1053
class ScriptedDirectProxyHandler : publi
|
Link Here
|
|---|
|
| 1038 |
virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, |
1038 |
virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, |
| 1039 |
Value *vp) MOZ_OVERRIDE; |
1039 |
Value *vp) MOZ_OVERRIDE; |
| 1040 |
virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, |
1040 |
virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, |
| 1041 |
Value *vp) MOZ_OVERRIDE; |
1041 |
Value *vp) MOZ_OVERRIDE; |
| 1042 |
virtual bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE; |
1042 |
virtual bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE; |
| 1043 |
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) MOZ_OVERRIDE; |
1043 |
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) MOZ_OVERRIDE; |
| 1044 |
|
1044 |
|
| 1045 |
virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp) MOZ_OVERRIDE; |
1045 |
virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp) MOZ_OVERRIDE; |
|
|
1046 |
virtual bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, |
| 1047 |
Value *rval) MOZ_OVERRIDE; |
| 1046 |
|
1048 |
|
| 1047 |
static ScriptedDirectProxyHandler singleton; |
1049 |
static ScriptedDirectProxyHandler singleton; |
| 1048 |
}; |
1050 |
}; |
| 1049 |
|
1051 |
|
| 1050 |
static int sScriptedDirectProxyHandlerFamily = 0; |
1052 |
static int sScriptedDirectProxyHandlerFamily = 0; |
| 1051 |
|
1053 |
|
| 1052 |
// Aux.2 FromGenericPropertyDescriptor(Desc) |
1054 |
// Aux.2 FromGenericPropertyDescriptor(Desc) |
| 1053 |
static bool |
1055 |
static bool |
|
Lines 2140-2155
ScriptedDirectProxyHandler::call(JSConte
|
Link Here
|
|---|
|
| 2140 |
ObjectValue(*target), |
2142 |
ObjectValue(*target), |
| 2141 |
vp[1], |
2143 |
vp[1], |
| 2142 |
ObjectValue(*args) |
2144 |
ObjectValue(*args) |
| 2143 |
}; |
2145 |
}; |
| 2144 |
RootedValue thisValue(cx, ObjectValue(*handler)); |
2146 |
RootedValue thisValue(cx, ObjectValue(*handler)); |
| 2145 |
return Invoke(cx, thisValue, trap, 3, argv, vp); |
2147 |
return Invoke(cx, thisValue, trap, 3, argv, vp); |
| 2146 |
} |
2148 |
} |
| 2147 |
|
2149 |
|
|
|
2150 |
bool |
| 2151 |
ScriptedDirectProxyHandler::construct(JSContext *cx, JSObject *proxy_, unsigned argc, Value *argv, |
| 2152 |
Value *rval) |
| 2153 |
{ |
| 2154 |
RootedObject proxy(cx, proxy_); |
| 2155 |
|
| 2156 |
// step 1 |
| 2157 |
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy)); |
| 2158 |
|
| 2159 |
// step 2 |
| 2160 |
RootedObject target(cx, GetProxyTargetObject(proxy)); |
| 2161 |
|
| 2162 |
// step 3 |
| 2163 |
RootedObject args(cx, NewDenseCopiedArray(cx, argc, argv)); |
| 2164 |
if (!args) |
| 2165 |
return false; |
| 2166 |
|
| 2167 |
// step 4 |
| 2168 |
RootedValue trap(cx); |
| 2169 |
if (!handler->getProperty(cx, ATOM(construct), &trap)) |
| 2170 |
return false; |
| 2171 |
|
| 2172 |
// step 5 |
| 2173 |
if (trap.isUndefined()) |
| 2174 |
return DirectProxyHandler::construct(cx, proxy_, argc, argv, rval); |
| 2175 |
|
| 2176 |
// step 6 |
| 2177 |
Value constructArgv[] = { |
| 2178 |
ObjectValue(*target), |
| 2179 |
ObjectValue(*args) |
| 2180 |
}; |
| 2181 |
RootedValue thisValue(cx, ObjectValue(*handler)); |
| 2182 |
return Invoke(cx, thisValue, trap, 2, constructArgv, rval); |
| 2183 |
} |
| 2184 |
|
| 2148 |
ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; |
2185 |
ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; |
| 2149 |
|
2186 |
|
| 2150 |
#define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall) \ |
2187 |
#define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall) \ |
| 2151 |
JS_BEGIN_MACRO \ |
2188 |
JS_BEGIN_MACRO \ |
| 2152 |
JSObject *proto; \ |
2189 |
JSObject *proto; \ |
| 2153 |
if (!handler->getPrototypeOf(cx, proxy, &proto)) \ |
2190 |
if (!handler->getPrototypeOf(cx, proxy, &proto)) \ |
| 2154 |
return false; \ |
2191 |
return false; \ |
| 2155 |
if (!proto) \ |
2192 |
if (!proto) \ |