本文整理汇总了C++中QScriptEnginePrivate::idTable方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEnginePrivate::idTable方法的具体用法?C++ QScriptEnginePrivate::idTable怎么用?C++ QScriptEnginePrivate::idTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEnginePrivate
的用法示例。
在下文中一共展示了QScriptEnginePrivate::idTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasInstance
bool QScriptValueImpl::hasInstance(const QScriptValueImpl &value) const
{
Q_ASSERT(isObject());
if (QScriptClassData *odata = classInfo()->data()) {
if (odata->implementsHasInstance(*this))
return odata->hasInstance(*this, value);
}
if (!isFunction())
return false;
// [[HasInstance] for function objects
if (!value.isObject())
return false;
QScriptEnginePrivate *eng = engine();
QScriptValueImpl proto = property(eng->idTable()->id_prototype);
if (!proto.isObject()) {
QScriptContextPrivate *ctx = eng->currentContext();
ctx->throwTypeError(QLatin1String("instanceof: 'prototype' property is not an object"));
return false;
}
QScriptObject *target = proto.m_object_value;
QScriptValueImpl v = value;
while (true) {
v = v.prototype();
if (!v.isObject())
break;
if (target == v.m_object_value)
return true;
}
return false;
}
示例2: get
bool FunctionClassData::get(const QScriptValueImpl &object, const Member &member,
QScriptValueImpl *result)
{
if (object.classInfo() != classInfo())
return false;
QScriptEnginePrivate *eng = QScriptEnginePrivate::get(object.engine());
if (! member.isNativeProperty())
return false;
if (member.nameId() == eng->idTable()->id_length) {
eng->newNumber(result, object.toFunction()->length);
return true;
} else if (member.nameId() == eng->idTable()->id_arguments) {
eng->newNull(result);
return true;
}
return false;
}
示例3: resolve
bool FunctionClassData::resolve(const QScriptValueImpl &object,
QScriptNameIdImpl *nameId,
QScript::Member *member, QScriptValueImpl *base)
{
if (object.classInfo() != classInfo())
return false;
QScriptEnginePrivate *eng = QScriptEnginePrivate::get(object.engine());
if ((nameId == eng->idTable()->id_length)
|| (nameId == eng->idTable()->id_arguments)) {
member->native(nameId, /*id=*/ 0,
QScriptValue::Undeletable
| QScriptValue::ReadOnly
| QScriptValue::SkipInEnumeration);
*base = object;
return true;
}
return false;
}