本文整理汇总了C++中JSValue::isTrue方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::isTrue方法的具体用法?C++ JSValue::isTrue怎么用?C++ JSValue::isTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::isTrue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpImmediate
void dumpImmediate(JSValue value)
{
if (value.isNull())
write(NullTag);
else if (value.isUndefined())
write(UndefinedTag);
else if (value.isNumber()) {
if (value.isInt32()) {
if (!value.asInt32())
write(ZeroTag);
else if (value.asInt32() == 1)
write(OneTag);
else {
write(IntTag);
write(static_cast<uint32_t>(value.asInt32()));
}
} else {
write(DoubleTag);
write(value.asDouble());
}
} else if (value.isBoolean()) {
if (value.isTrue())
write(TrueTag);
else
write(FalseTag);
}
}
示例2: handleEvent
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
if (!event->hasInterface(eventNames().interfaceForErrorEvent))
return JSEventListener::handleEvent(scriptExecutionContext, event);
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
JSLock lock(SilenceAssertionsOnly);
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->methodTable()->getCallData(jsFunction, callData);
if (callType != CallTypeNone) {
RefPtr<JSErrorHandler> protectedctor(this);
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
MarkedArgumentBuffer args;
args.append(jsString(exec, errorEvent->message()));
args.append(jsString(exec, errorEvent->filename()));
args.append(jsNumber(errorEvent->lineno()));
JSGlobalData& globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(globalData, globalData.dynamicGlobalObject ? globalData.dynamicGlobalObject : globalObject);
JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec);
globalData.timeoutChecker.start();
JSValue returnValue = scriptExecutionContext->isDocument()
? JSMainThreadExecState::call(exec, jsFunction, callType, callData, thisValue, args)
: JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData.timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
if (exec->hadException())
reportCurrentException(exec);
else {
if (returnValue.isTrue())
event->preventDefault();
}
}
}
示例3: handleEvent
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
if (!is<ErrorEvent>(*event))
return JSEventListener::handleEvent(scriptExecutionContext, event);
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
ErrorEvent& errorEvent = downcast<ErrorEvent>(*event);
JSLockHolder lock(scriptExecutionContext->vm());
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->methodTable()->getCallData(jsFunction, callData);
if (callType != CallTypeNone) {
Ref<JSErrorHandler> protectedctor(*this);
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
MarkedArgumentBuffer args;
args.append(jsStringWithCache(exec, errorEvent.message()));
args.append(jsStringWithCache(exec, errorEvent.filename()));
args.append(jsNumber(errorEvent.lineno()));
args.append(jsNumber(errorEvent.colno()));
VM& vm = globalObject->vm();
VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
NakedPtr<Exception> exception;
JSValue returnValue = scriptExecutionContext->isDocument()
? JSMainThreadExecState::call(exec, jsFunction, callType, callData, globalObject, args, exception)
: JSC::call(exec, jsFunction, callType, callData, globalObject, args, exception);
globalObject->setCurrentEvent(savedEvent);
if (exception)
reportException(exec, exception);
else {
if (returnValue.isTrue())
event->preventDefault();
}
}
}