本文整理汇总了C++中kjs::Value::toBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::toBoolean方法的具体用法?C++ Value::toBoolean怎么用?C++ Value::toBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::Value
的用法示例。
在下文中一共展示了Value::toBoolean方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setActive
void KstBindTimeInterpretation::setActive(KJS::ExecState *exec, const KJS::Value& value) {
if (!_d) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return;
}
if (value.type() != KJS::BooleanType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return;
}
KstWriteLocker wl(_d->_d);
bool isIt;
KstAxisInterpretation interp;
KstAxisDisplay disp;
if (_d->_xAxis) {
_d->_d->getXAxisInterpretation(isIt, interp, disp);
_d->_d->setXAxisInterpretation(value.toBoolean(exec), interp, disp);
} else {
_d->_d->getYAxisInterpretation(isIt, interp, disp);
_d->_d->setYAxisInterpretation(value.toBoolean(exec), interp, disp);
}
_d->_d->setDirty();
KstApp::inst()->paintAll(KstPainter::P_PAINT);
}
示例2: startElement
bool SaxHandler::startElement( const QString &ns, const QString &ln, const QString &qn,
const QXmlAttributes &attrs )
{
if ( !jshandler.isValid() ) {
error = ErrorNoHandler;
return false;
}
KJS::Identifier funName("startElement");
if ( !jshandler.hasProperty(exec, funName) )
return QXmlDefaultHandler::startElement( ns, ln, qn, attrs );
KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
if ( !fun.implementsCall() ) {
error = ErrorNotCallable;
return false;
}
KJS::List args;
args.append( KJS::String(ns) );
args.append( KJS::String(ln) );
args.append( KJS::String(qn) );
// TODO: XmlAttributes not yet supported
KJS::Value ret = fun.call( exec, jshandler, args );
return ret.toBoolean( exec );
}
示例3: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
{
Type type = value.type();
if (type == StringType) {
UString ustring = value.toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
NPN_InitializeVariantWithStringCopy (result, &string );
}
else if (type == NumberType) {
NPN_InitializeVariantWithDouble (result, value.toNumber(exec));
}
else if (type == BooleanType) {
NPN_InitializeVariantWithBool (result, value.toBoolean(exec));
}
else if (type == UnspecifiedType) {
NPN_InitializeVariantAsUndefined(result);
}
else if (type == NullType) {
NPN_InitializeVariantAsNull(result);
}
else if (type == ObjectType) {
KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
NPN_InitializeVariantWithObject (result, instance->getObject());
}
else {
KJS::Interpreter *originInterpreter = exec->interpreter();
const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
KJS::Interpreter *interpreter = 0;
if (originInterpreter->isGlobalObject(value)) {
interpreter = originInterpreter->interpreterForGlobalObject (value.imp());
}
if (!interpreter)
interpreter = originInterpreter;
const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0);
newExecutionContext->setInterpreter (interpreter);
executionContext = newExecutionContext;
}
NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue (exec, Instance::CLanguage, value.toObject(exec), originExecutionContext, executionContext);
NPN_InitializeVariantWithObject (result, obj);
_NPN_ReleaseObject (obj);
}
}
else
NPN_InitializeVariantAsUndefined(result);
}
示例4: setAverage
void KstBindPowerSpectrum::setAverage(KJS::ExecState *exec, const KJS::Value& value) {
if (value.type() != KJS::BooleanType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return;
}
KstPSDPtr d = makePSD(_d);
if (d) {
KstWriteLocker wl(d);
d->setAverage(value.toBoolean(exec));
}
}
示例5: endDocument
bool SaxHandler::endDocument()
{
if ( !jshandler.isValid() ) {
error = ErrorNoHandler;
return false;
}
KJS::Identifier funName("endDocument");
if ( !jshandler.hasProperty(exec, funName) )
return QXmlDefaultHandler::endDocument();
KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
if ( !fun.implementsCall() ) {
error = ErrorNotCallable;
return false;
}
KJS::Value ret = fun.call( exec, jshandler, KJS::List() );
return ret.toBoolean( exec );
}
示例6: characters
bool SaxHandler::characters( const QString &chars )
{
if ( !jshandler.isValid() ) {
error = ErrorNoHandler;
return false;
}
KJS::Identifier funName("characters");
if ( !jshandler.hasProperty(exec, funName) )
return QXmlDefaultHandler::characters( chars );
KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
if ( !fun.implementsCall() ) {
error = ErrorNotCallable;
return false;
}
KJS::List args;
args.append( KJS::String(chars) );
KJS::Value ret = fun.call( exec, jshandler, args );
return ret.toBoolean( exec );
}