本文整理汇总了C++中QScriptValueImpl::internalValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::internalValue方法的具体用法?C++ QScriptValueImpl::internalValue怎么用?C++ QScriptValueImpl::internalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::internalValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method_toString
QScriptValueImpl Number::method_toString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo)
return context->throwError(QScriptContext::TypeError,
QLatin1String("Number.prototype.toString"));
QScriptValueImpl arg = context->argument(0);
if (!arg.isUndefined()) {
int radix = arg.toInt32();
if (radix < 2 || radix > 36)
return context->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
if (radix != 10) {
QString str;
qsreal num = self.internalValue().toInteger();
do {
char c = (char)::fmod(num, radix);
if (c < 10)
c += '0';
else
c = c - 10 + 'a';
str.prepend(QLatin1Char(c));
num = ::floor(num / radix);
} while (num != 0);
return QScriptValueImpl(eng, str);
}
}
QString str = self.internalValue().toString();
return (QScriptValueImpl(eng, str));
}
示例2: method_valueOf
QScriptValueImpl Number::method_valueOf(QScriptContextPrivate *context, QScriptEnginePrivate *, QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo)
return context->throwError(QScriptContext::TypeError,
QLatin1String("Number.prototype.valueOf"));
return (self.internalValue());
}
示例3: method_toLocaleString
QScriptValueImpl Number::method_toLocaleString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo)
return context->throwError(QScriptContext::TypeError,
QLatin1String("Number.prototype.toLocaleString"));
QString str = self.internalValue().toString();
return (QScriptValueImpl(eng, str));
}
示例4: method_toString
QScriptValueImpl Boolean::method_toString(QScriptContextPrivate *context,
QScriptEnginePrivate *eng,
QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo)
return context->throwError(QScriptContext::TypeError,
QLatin1String("Boolean.prototype.toString"));
const QScript::IdTable *t = eng->idTable();
bool v = self.internalValue().toBoolean();
QScriptValueImpl result;
eng->newNameId(&result, v ? t->id_true : t->id_false);
return result;
}
示例5: method_toPrecision
QScriptValueImpl Number::method_toPrecision(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
QScriptValueImpl self = context->thisObject();
if (self.classInfo() != classInfo)
return context->throwError(QScriptContext::TypeError,
QLatin1String("Number.prototype.toPrecision"));
qsreal fdigits = 0;
if (context->argumentCount() > 0)
fdigits = context->argument(0).toInteger();
qsreal v = self.internalValue().toNumber();
return (QScriptValueImpl(eng, QString::number(v, 'g', int (fdigits))));
}