本文整理汇总了C++中QScriptValueImpl::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::property方法的具体用法?C++ QScriptValueImpl::property怎么用?C++ QScriptValueImpl::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::property方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backtrace
QStringList Error::backtrace(const QScriptValueImpl &error)
{
QStringList result;
QScriptValueImpl stack = error.property(QLatin1String("stack"));
int frameCount = stack.property(QLatin1String("length")).toInt32();
for (int i = 0; i < frameCount; ++i) {
QScriptValueImpl o = stack.property(i);
QScriptValueImpl frame = o.property(QLatin1String("frame"));
QString s;
QString functionName = o.property(QLatin1String("functionName")).toString();
if (functionName.isEmpty()) {
if (i == frameCount-1)
s += QLatin1String("<global>");
else
s += QLatin1String("<anonymous>");
} else {
s += functionName;
}
s += QLatin1Char('(');
QScriptValueImpl arguments = frame.property(QLatin1String("arguments"));
if (arguments.isObject()) {
int argCount = arguments.property(QLatin1String("length")).toInt32();
for (int j = 0; j < argCount; ++j) {
if (j > 0)
s += QLatin1Char(',');
s += arguments.property(j).toString();
}
}
s += QLatin1String(")@") + o.property(QLatin1String("fileName")).toString()
+ QLatin1Char(':') + o.property(QLatin1String("lineNumber")).toString();
result.append(s);
}
return result;
}
示例2: 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
}
示例3: method_connect
QScriptValueImpl Function::method_connect(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
Q_UNUSED(classInfo);
#ifndef QT_NO_QOBJECT
if (context->argumentCount() == 0) {
return context->throwError(
QLatin1String("Function.prototype.connect: no arguments given"));
}
QScriptValueImpl self = context->thisObject();
QScriptFunction *fun = self.toFunction();
if ((fun == 0) || (fun->type() != QScriptFunction::Qt)) {
return context->throwError(
QScriptContext::TypeError,
QLatin1String("Function.prototype.connect: this object is not a signal"));
}
QtFunction *qtSignal = static_cast<QtFunction*>(fun);
const QMetaObject *meta = qtSignal->metaObject();
if (!meta) {
return context->throwError(
QScriptContext::TypeError,
QString::fromLatin1("Function.prototype.connect: cannot connect to deleted QObject"));
}
QMetaMethod sig = meta->method(qtSignal->initialIndex());
if (sig.methodType() != QMetaMethod::Signal) {
return context->throwError(QScriptContext::TypeError,
QString::fromLatin1("Function.prototype.connect: %0::%1 is not a signal")
.arg(QLatin1String(qtSignal->metaObject()->className()))
.arg(QLatin1String(sig.signature())));
}
QScriptValueImpl receiver;
QScriptValueImpl slot;
QScriptValueImpl arg0 = context->argument(0);
if (context->argumentCount() < 2) {
receiver = QScriptValueImpl();
slot = arg0;
} else {
receiver = arg0;
QScriptValueImpl arg1 = context->argument(1);
if (arg1.isFunction())
slot = arg1;
else
slot = receiver.property(arg1.toString(), QScriptValue::ResolvePrototype);
}
if (!slot.isFunction()) {
return context->throwError(
QScriptContext::TypeError,
QLatin1String("Function.prototype.connect: target is not a function"));
}
bool ok = eng->scriptConnect(self, receiver, slot);
if (!ok) {
return context->throwError(
QString::fromLatin1("Function.prototype.connect: failed to connect to %0::%1")
.arg(QLatin1String(qtSignal->metaObject()->className()))
.arg(QLatin1String(sig.signature())));
}
return eng->undefinedValue();
#else
Q_UNUSED(eng);
Q_UNUSED(classInfo);
return context->throwError(QScriptContext::TypeError,
QLatin1String("Function.prototype.connect"));
#endif // QT_NO_QOBJECT
}