本文整理汇总了C++中js::HandleObject::lastProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleObject::lastProperty方法的具体用法?C++ HandleObject::lastProperty怎么用?C++ HandleObject::lastProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::HandleObject
的用法示例。
在下文中一共展示了HandleObject::lastProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: props
JS_GetPropertyDescArray(JSContext *cx, JS::HandleObject obj, JSPropertyDescArray *pda)
{
assertSameCompartment(cx, obj);
uint32_t i = 0;
JSPropertyDesc *pd = nullptr;
if (obj->is<DebugScopeObject>()) {
AutoIdVector props(cx);
if (!Proxy::enumerate(cx, obj, props))
return false;
pd = cx->pod_calloc<JSPropertyDesc>(props.length());
if (!pd)
return false;
for (i = 0; i < props.length(); ++i) {
pd[i].id = JSVAL_NULL;
pd[i].value = JSVAL_NULL;
if (!AddValueRoot(cx, &pd[i].id, nullptr))
goto bad;
pd[i].id = IdToValue(props[i]);
if (!AddValueRoot(cx, &pd[i].value, nullptr))
goto bad;
if (!Proxy::get(cx, obj, obj, props.handleAt(i), MutableHandleValue::fromMarkedLocation(&pd[i].value)))
goto bad;
}
pda->length = props.length();
pda->array = pd;
return true;
}
const Class *clasp;
clasp = obj->getClass();
if (!obj->isNative() || (clasp->flags & JSCLASS_NEW_ENUMERATE)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
JSMSG_CANT_DESCRIBE_PROPS, clasp->name);
return false;
}
if (!clasp->enumerate(cx, obj))
return false;
/* Return an empty pda early if obj has no own properties. */
if (obj->nativeEmpty()) {
pda->length = 0;
pda->array = nullptr;
return true;
}
pd = cx->pod_malloc<JSPropertyDesc>(obj->propertyCount());
if (!pd)
return false;
{
Shape::Range<CanGC> r(cx, obj->lastProperty());
RootedShape shape(cx);
for (; !r.empty(); r.popFront()) {
pd[i].id = JSVAL_NULL;
pd[i].value = JSVAL_NULL;
pd[i].alias = JSVAL_NULL;
if (!AddValueRoot(cx, &pd[i].id, nullptr))
goto bad;
if (!AddValueRoot(cx, &pd[i].value, nullptr))
goto bad;
shape = const_cast<Shape *>(&r.front());
if (!GetPropertyDesc(cx, obj, shape, &pd[i]))
goto bad;
if ((pd[i].flags & JSPD_ALIAS) && !AddValueRoot(cx, &pd[i].alias, nullptr))
goto bad;
if (++i == obj->propertyCount())
break;
}
}
pda->length = i;
pda->array = pd;
return true;
bad:
pda->length = i + 1;
pda->array = pd;
JS_PutPropertyDescArray(cx, pda);
return false;
}