本文整理汇总了C++中jsc::JSValue::isBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::isBoolean方法的具体用法?C++ JSValue::isBoolean怎么用?C++ JSValue::isBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsc::JSValue
的用法示例。
在下文中一共展示了JSValue::isBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSValueGetType
JSType JSValueGetType(JSContextRef, JSValueRef value)
{
JSC::JSValue* jsValue = toJS(value);
if (jsValue->isUndefined())
return kJSTypeUndefined;
if (jsValue->isNull())
return kJSTypeNull;
if (jsValue->isBoolean())
return kJSTypeBoolean;
if (jsValue->isNumber())
return kJSTypeNumber;
if (jsValue->isString())
return kJSTypeString;
ASSERT(jsValue->isObject());
return kJSTypeObject;
}
示例2: JSValueGetType
JSType JSValueGetType(JSContextRef ctx, JSValueRef value)
{
JSC::ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSC::JSLock lock(exec);
JSC::JSValue jsValue = toJS(exec, value);
if (jsValue.isUndefined())
return kJSTypeUndefined;
if (jsValue.isNull())
return kJSTypeNull;
if (jsValue.isBoolean())
return kJSTypeBoolean;
if (jsValue.isNumber())
return kJSTypeNumber;
if (jsValue.isString())
return kJSTypeString;
ASSERT(jsValue.isObject());
return kJSTypeObject;
}
示例3: stringByEvaluatingJavaScriptInScriptWorld
bool WebFrame::stringByEvaluatingJavaScriptInScriptWorld(WebScriptWorld* world, void* jsGlobalObject, const char* script, const char** evaluationResult)
{
if (!world || !jsGlobalObject || !evaluationResult)
return false;
*evaluationResult = 0;
Frame* coreFrame = core(this);
JSObjectRef globalObjectRef = reinterpret_cast<JSObjectRef>(jsGlobalObject);
String string = String(script);
// Start off with some guess at a frame and a global object, we'll try to do better...!
JSDOMWindow* anyWorldGlobalObject = coreFrame->script()->globalObject(mainThreadNormalWorld());
// The global object is probably a shell object? - if so, we know how to use this!
JSC::JSObject* globalObjectObj = toJS(globalObjectRef);
if (!strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell"))
anyWorldGlobalObject = static_cast<JSDOMWindowShell*>(globalObjectObj)->window();
// Get the frame from the global object we've settled on.
Frame* frame = anyWorldGlobalObject->impl()->frame();
ASSERT(frame->document());
JSC::JSValue result = frame->script()->executeScriptInWorld(world->world(), string, true).jsValue();
if (!frame) // In case the script removed our frame from the page.
return true;
// This bizarre set of rules matches behavior from WebKit for Safari 2.0.
// If you don't like it, use -[WebScriptObject evaluateWebScript:] or
// JSEvaluateScript instead, since they have less surprising semantics.
if (!result || !result.isBoolean() && !result.isString() && !result.isNumber())
return true;
JSC::JSLock lock(JSC::SilenceAssertionsOnly);
String resultString = ustringToString(result.toString(anyWorldGlobalObject->globalExec()));
*evaluationResult = strdup(resultString.utf8().data());
return true;
}