本文整理汇总了C++中QScriptValueImpl::isUndefined方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::isUndefined方法的具体用法?C++ QScriptValueImpl::isUndefined怎么用?C++ QScriptValueImpl::isUndefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::isUndefined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_apply
QScriptValueImpl Function::method_apply(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
if (! context->thisObject().isFunction()) {
return context->throwError(QScriptContext::TypeError,
QLatin1String("Function.prototype.apply"));
}
QScriptValueImpl thisObject = context->argument(0).toObject();
if (! (thisObject.isValid () && thisObject.isObject()))
thisObject = eng->globalObject();
QScriptValueImplList args;
QScriptValueImpl undefined = eng->undefinedValue();
QScriptValueImpl arg = context->argument(1);
if (Ecma::Array::Instance *arr = eng->arrayConstructor->get(arg)) {
QScript::Array actuals = arr->value;
for (quint32 i = 0; i < actuals.count(); ++i) {
QScriptValueImpl a = actuals.at(i);
if (! a.isValid())
args << undefined;
else
args << a;
}
} else if (arg.classInfo() == eng->m_class_arguments) {
QScript::ArgumentsObjectData *arguments;
arguments = static_cast<QScript::ArgumentsObjectData*> (arg.objectData());
QScriptObject *activation = arguments->activation.objectValue();
for (uint i = 0; i < arguments->length; ++i)
args << activation->m_objects[i];
} else if (!(arg.isUndefined() || arg.isNull())) {
return context->throwError(QScriptContext::TypeError,
QLatin1String("Function.prototype.apply: second argument is not an array"));
}
return context->thisObject().call(thisObject, args);
}
示例3: 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
}