|
|
|
Lines 385-400
ProxyHandler::finalize(JSFreeOp *fop, JS
|
Link Here
|
|---|
|
| 385 |
{ |
385 |
{ |
| 386 |
} |
386 |
} |
| 387 |
|
387 |
|
| 388 |
void |
388 |
void |
| 389 |
ProxyHandler::trace(JSTracer *trc, JSObject *proxy) |
389 |
ProxyHandler::trace(JSTracer *trc, JSObject *proxy) |
| 390 |
{ |
390 |
{ |
| 391 |
} |
391 |
} |
| 392 |
|
392 |
|
|
|
393 |
AbstractProxyHandler::AbstractProxyHandler(void *family) : ProxyHandler(family) |
| 394 |
{ |
| 395 |
} |
| 396 |
|
| 397 |
bool |
| 398 |
AbstractProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy, |
| 399 |
jsid id, bool set, |
| 400 |
PropertyDescriptor *desc) |
| 401 |
{ |
| 402 |
return JS_GetPropertyDescriptorById(cx, GetProxyTargetObject(proxy), id, |
| 403 |
JSRESOLVE_QUALIFIED, desc); |
| 404 |
} |
| 405 |
|
| 406 |
static bool |
| 407 |
GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, unsigned flags, |
| 408 |
JSPropertyDescriptor *desc) |
| 409 |
{ |
| 410 |
// If obj is a proxy, we can do better than just guessing. This is |
| 411 |
// important for certain types of wrappers that wrap other wrappers. |
| 412 |
if (obj->isProxy()) |
| 413 |
return Proxy::getOwnPropertyDescriptor(cx, obj, id, |
| 414 |
flags & JSRESOLVE_ASSIGNING, |
| 415 |
desc); |
| 416 |
|
| 417 |
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc)) |
| 418 |
return false; |
| 419 |
if (desc->obj != obj) |
| 420 |
desc->obj = NULL; |
| 421 |
return true; |
| 422 |
} |
| 423 |
|
| 424 |
bool |
| 425 |
AbstractProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, |
| 426 |
jsid id, bool set, |
| 427 |
PropertyDescriptor *desc) |
| 428 |
{ |
| 429 |
return GetOwnPropertyDescriptor(cx, GetProxyTargetObject(proxy), id, |
| 430 |
JSRESOLVE_QUALIFIED, desc); |
| 431 |
} |
| 432 |
|
| 433 |
bool |
| 434 |
AbstractProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id, |
| 435 |
PropertyDescriptor *desc) |
| 436 |
{ |
| 437 |
return JS_DefinePropertyById(cx, GetProxyTargetObject(proxy), id, |
| 438 |
desc->value, desc->getter, desc->setter, |
| 439 |
desc->attrs); |
| 440 |
} |
| 441 |
|
| 442 |
bool |
| 443 |
AbstractProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy, |
| 444 |
AutoIdVector &props) |
| 445 |
{ |
| 446 |
return GetPropertyNames(cx, GetProxyTargetObject(proxy), |
| 447 |
JSITER_OWNONLY | JSITER_HIDDEN, &props); |
| 448 |
} |
| 449 |
|
| 450 |
bool |
| 451 |
AbstractProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) |
| 452 |
{ |
| 453 |
Value v; |
| 454 |
if (!JS_DeletePropertyById2(cx, GetProxyTargetObject(proxy), id, &v)) |
| 455 |
return false; |
| 456 |
JSBool b; |
| 457 |
if (!JS_ValueToBoolean(cx, v, &b)) |
| 458 |
return false; |
| 459 |
*bp = !!b; |
| 460 |
return true; |
| 461 |
} |
| 462 |
|
| 463 |
bool |
| 464 |
AbstractProxyHandler::enumerate(JSContext *cx, JSObject *proxy, |
| 465 |
AutoIdVector &props) |
| 466 |
{ |
| 467 |
return GetPropertyNames(cx, GetProxyTargetObject(proxy), 0, &props); |
| 468 |
} |
| 469 |
|
| 393 |
static bool |
470 |
static bool |
| 394 |
GetTrap(JSContext *cx, JSObject *handler, JSAtom *atom, Value *fvalp) |
471 |
GetTrap(JSContext *cx, JSObject *handler, JSAtom *atom, Value *fvalp) |
| 395 |
{ |
472 |
{ |
| 396 |
JS_CHECK_RECURSION(cx, return false); |
473 |
JS_CHECK_RECURSION(cx, return false); |
| 397 |
|
474 |
|
| 398 |
return handler->getGeneric(cx, ATOM_TO_JSID(atom), fvalp); |
475 |
return handler->getGeneric(cx, ATOM_TO_JSID(atom), fvalp); |
| 399 |
} |
476 |
} |
| 400 |
|
477 |
|