本文整理汇总了C++中HandleObject::isStrictArguments方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleObject::isStrictArguments方法的具体用法?C++ HandleObject::isStrictArguments怎么用?C++ HandleObject::isStrictArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HandleObject
的用法示例。
在下文中一共展示了HandleObject::isStrictArguments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: value
static JSBool
StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHandleValue vp)
{
if (!obj->isStrictArguments())
return true;
unsigned attrs;
if (!baseops::GetAttributes(cx, obj, id, &attrs))
return false;
JS_ASSERT(!(attrs & JSPROP_READONLY));
attrs &= (JSPROP_ENUMERATE | JSPROP_PERMANENT); /* only valid attributes */
Rooted<StrictArgumentsObject*> argsobj(cx, &obj->asStrictArguments());
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj->initialLength()) {
argsobj->setElement(arg, vp);
return true;
}
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length));
}
/*
* For simplicity we use delete/define to replace the property with one
* backed by the default Object getter and setter. Note that we rely on
* args_delProperty to clear the corresponding reserved slot so the GC can
* collect its value.
*/
RootedValue value(cx);
return baseops::DeleteGeneric(cx, argsobj, id, &value, strict) &&
baseops::DefineGeneric(cx, argsobj, id, vp, NULL, NULL, attrs);
}
示例2: value
static JSBool
StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp)
{
if (!obj->isStrictArguments())
return true;
Rooted<StrictArgumentsObject*> argsobj(cx, &obj->asStrictArguments());
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj->initialLength()) {
argsobj->setElement(arg, *vp);
return true;
}
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom));
}
/*
* For simplicity we use delete/set to replace the property with one
* backed by the default Object getter and setter. Note that we rely on
* args_delProperty to clear the corresponding reserved slot so the GC can
* collect its value.
*/
RootedValue value(cx);
return baseops::DeleteGeneric(cx, argsobj, id, value.address(), strict) &&
baseops::SetPropertyHelper(cx, argsobj, id, 0, vp, strict);
}
示例3: unsigned
static JSBool
StrictArgGetter(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
{
if (!obj->isStrictArguments())
return true;
StrictArgumentsObject &argsobj = obj->asStrictArguments();
if (JSID_IS_INT(id)) {
/*
* arg can exceed the number of arguments if a script changed the
* prototype to point to another Arguments object with a bigger argc.
*/
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg))
vp.set(argsobj.element(arg));
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length));
if (!argsobj.hasOverriddenLength())
vp.setInt32(argsobj.initialLength());
}
return true;
}