本文整理汇总了C++中QScriptValueImpl::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::setProperty方法的具体用法?C++ QScriptValueImpl::setProperty怎么用?C++ QScriptValueImpl::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::setProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method_exec
QScriptValueImpl RegExp::method_exec(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo) {
return throwThisObjectTypeError(
context, QLatin1String("RegExp.prototype.exec"));
}
Instance *rx_data = Instance::get(self, classInfo);
Q_ASSERT(rx_data != 0);
QString S = context->argument(0).toString();
int length = S.length();
QScriptValueImpl lastIndex = self.property(QLatin1String("lastIndex"));
int i = lastIndex.isValid() ? int (lastIndex.toInteger()) : 0;
bool global = self.property(QLatin1String("global")).toBoolean();
if (! global)
i = 0;
if (i < 0 || i >= length)
return (eng->nullValue());
#ifndef QT_NO_REGEXP
int index = rx_data->value.indexIn(S, i);
if (index == -1)
#endif // QT_NO_REGEXP
return eng->nullValue();
#ifndef QT_NO_REGEXP
int e = index + rx_data->value.matchedLength();
if (global)
self.setProperty(QLatin1String("lastIndex"), QScriptValueImpl(e));
QScript::Array elts(eng);
QStringList capturedTexts = rx_data->value.capturedTexts();
for (int i = 0; i < capturedTexts.count(); ++i)
elts.assign(i, QScriptValueImpl(eng, capturedTexts.at(i)));
QScriptValueImpl r = eng->newArray(elts);
r.setProperty(QLatin1String("index"), QScriptValueImpl(index));
r.setProperty(QLatin1String("input"), QScriptValueImpl(eng, S));
return r;
#endif // QT_NO_REGEXP
}
示例2: addFunction
void Core::addFunction(QScriptValueImpl &object, const QString &name,
QScriptInternalFunctionSignature fun, int length,
const QScriptValue::PropertyFlags flags)
{
QScriptValueImpl val = engine()->createFunction(fun, length, m_classInfo, name);
object.setProperty(name, val, flags);
}
示例3: addFunction
void Math::addFunction(QScriptValueImpl &object, const QString &name,
QScriptInternalFunctionSignature fun, int length,
const QScriptValue::PropertyFlags flags)
{
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(object.engine());
QScriptValueImpl val = eng_p->createFunction(fun, length, object.classInfo(), name);
object.setProperty(name, val, flags);
}
示例4: newErrorPrototype
void Error::newErrorPrototype(QScriptValueImpl *result, const QScriptValueImpl &proto,
QScriptValueImpl &ztor, const QString &name)
{
newError(result, proto);
result->setProperty(QLatin1String("name"), QScriptValueImpl(engine(), name));
result->setProperty(QLatin1String("constructor"), ztor,
QScriptValue::Undeletable
| QScriptValue::SkipInEnumeration);
ztor.setProperty(QLatin1String("prototype"), *result,
QScriptValue::Undeletable
| QScriptValue::ReadOnly
| QScriptValue::SkipInEnumeration);
}