本文整理汇总了C++中ValueRef::asArrayLength方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueRef::asArrayLength方法的具体用法?C++ ValueRef::asArrayLength怎么用?C++ ValueRef::asArrayLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueRef
的用法示例。
在下文中一共展示了ValueRef::asArrayLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internalPut
// Section 8.12.5
void Object::internalPut(const StringRef name, const ValueRef value)
{
if (internalClass->engine->hasException)
return;
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return putIndexed(idx, value);
name->makeIdentifier();
uint member = internalClass->find(name.getPointer());
Property *pd = 0;
PropertyAttributes attrs;
if (member < UINT_MAX) {
pd = propertyAt(member);
attrs = internalClass->propertyData[member];
}
// clause 1
if (pd) {
if (attrs.isAccessor()) {
if (pd->setter())
goto cont;
goto reject;
} else if (!attrs.isWritable())
goto reject;
else if (isArrayObject() && name->equals(engine()->id_length)) {
bool ok;
uint l = value->asArrayLength(&ok);
if (!ok) {
engine()->currentContext()->throwRangeError(value);
return;
}
ok = setArrayLength(l);
if (!ok)
goto reject;
} else {
pd->value = *value;
}
return;
} else if (!prototype()) {
if (!extensible)
goto reject;
} else {
// clause 4
if ((pd = prototype()->__getPropertyDescriptor__(name, &attrs))) {
if (attrs.isAccessor()) {
if (!pd->setter())
goto reject;
} else if (!extensible || !attrs.isWritable()) {
goto reject;
}
} else if (!extensible) {
goto reject;
}
}
cont:
// Clause 5
if (pd && attrs.isAccessor()) {
assert(pd->setter() != 0);
Scope scope(engine());
ScopedCallData callData(scope, 1);
callData->args[0] = *value;
callData->thisObject = this;
pd->setter()->call(callData);
return;
}
insertMember(name, value);
return;
reject:
if (engine()->currentContext()->strictMode) {
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
engine()->currentContext()->throwTypeError(message);
}
}