本文整理汇总了C++中QScriptValueImpl::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::toString方法的具体用法?C++ QScriptValueImpl::toString怎么用?C++ QScriptValueImpl::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::toString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method_propertyIsEnumerable
QScriptValueImpl Object::method_propertyIsEnumerable(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
bool result = false;
if (context->thisObject().isObject() && (context->argumentCount() > 0)) {
QScriptValueImpl arg = context->argument(0);
QScriptNameIdImpl *id = 0;
if (arg.isString())
id = arg.stringValue();
if (! id || ! id->unique) {
QString str = arg.toString();
id = eng->nameId(str);
}
QScript::Member member;
QScriptValueImpl base;
QScriptValueImpl self = context->thisObject();
if (self.resolve(id, &member, &base, QScriptValue::ResolveLocal, QScript::Read)) {
result = ! member.dontEnum();
if (result) {
QScriptValueImpl tmp;
base.get(member, &tmp);
result = tmp.isValid();
}
}
}
return (QScriptValueImpl(result));
}
示例2: method_hasOwnProperty
QScriptValueImpl Object::method_hasOwnProperty(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
bool result = false;
if (context->thisObject().isObject() && (context->argumentCount() > 0)) {
QScriptValueImpl arg = context->argument(0);
QScriptNameIdImpl *id = 0;
if (arg.isString())
id = arg.stringValue();
if (! id || ! id->unique) {
QString str = arg.toString();
id = eng->nameId(str);
}
QScript::Member member;
QScriptValueImpl base;
QScriptValueImpl self = context->thisObject();
if (self.resolve(id, &member, &base, QScriptValue::ResolveLocal, QScript::Read))
result = true;
}
return (QScriptValueImpl(result));
}
示例3: method_toString
QScriptValueImpl Error::method_toString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
QScriptValueImpl name = context->thisObject().property(QLatin1String("name"),
QScriptValue::ResolvePrototype);
QScriptValueImpl message = context->thisObject().property(QLatin1String("message"),
QScriptValue::ResolvePrototype);
QString result = QLatin1String("");
if (name.isValid())
result = name.toString();
if (message.isValid()) {
QString str = message.toString();
if (!str.isEmpty()) {
if (!result.isEmpty())
result += QLatin1String(": ");
result += str;
}
}
return (QScriptValueImpl(eng, result));
}
示例4: method_toString
QScriptValueImpl Variant::method_toString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
if (Instance *instance = Instance::get(context->thisObject(), classInfo)) {
QString result;
QScriptValueImpl value = method_valueOf(context, eng, classInfo);
if (value.isObject()) {
result = instance->value.toString();
if (result.isEmpty()) {
result = QString::fromLatin1("QVariant(%0)")
.arg(QLatin1String(instance->value.typeName()));
}
} else {
result = value.toString();
}
return QScriptValueImpl(eng, result);
}
return context->throwError(QScriptContext::TypeError,
QLatin1String("QVariant.prototype.toString"));
}
示例5: execute
void RegExp::execute(QScriptContextPrivate *context)
{
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
engine()->notifyFunctionEntry(context);
#endif
QString P;
int F;
QScriptValueImpl pattern = context->argument(0);
QScriptValueImpl flags = context->argument(1);
if (!context->isCalledAsConstructor()) {
if ((pattern.classInfo() == classInfo()) && flags.isUndefined()) {
context->m_result = pattern;
goto Lout;
}
}
if (pattern.classInfo() == classInfo()) {
if (!flags.isUndefined()) {
context->throwTypeError(QString::fromLatin1("cannot specify flags when creating a copy of a RegExp"));
goto Lout;
}
Instance *data = Instance::get(pattern, classInfo());
#ifndef QT_NO_REGEXP
P = data->value.pattern();
#else
P = data->pattern;
#endif
F = data->flags;
} else {
if (!pattern.isUndefined())
P = pattern.toString();
F = 0;
if (!flags.isUndefined()) {
QString flagsStr = flags.toString();
for (int i = 0; i < flagsStr.length(); ++i) {
int bitflag = flagFromChar(flagsStr.at(i));
if (bitflag == 0) {
context->throwError(
QScriptContext::SyntaxError,
QString::fromUtf8("invalid regular expression flag '%0'")
.arg(flagsStr.at(i)));
goto Lout;
}
F |= bitflag;
}
}
}
if (context->isCalledAsConstructor()) {
QScriptValueImpl &object = context->m_thisObject;
object.setClassInfo(classInfo());
object.setPrototype(publicPrototype);
#ifndef QT_NO_REGEXP
initRegExp(&object, toRegExp(P, F), F);
#else
initRegExp(&object, P, F);
#endif
} else {
newRegExp(&context->m_result, P, F);
}
Lout: ;
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
engine()->notifyFunctionExit(context);
#endif
}