本文整理汇总了C++中jsc::JSValue::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toString方法的具体用法?C++ JSValue::toString怎么用?C++ JSValue::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsc::JSValue
的用法示例。
在下文中一共展示了JSValue::toString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asURL
String DragData::asURL(String* /*title*/) const
{
JSC::JSLock lock(false);
bool success;
JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::URI_LIST_TYPE, success);
if (success && data.isString())
return String(ustringToString(data.toString(m_platformDragData->execState())));
return String();
}
示例2: RunScript
wxString wxWebFrame::RunScript(const wxString& javascript)
{
wxString returnValue = wxEmptyString;
if (m_impl->frame) {
JSC::JSValue result = m_impl->frame->loader()->executeScript(javascript, true).jsValue();
if (result)
returnValue = wxString(result.toString(m_impl->frame->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8);
}
return returnValue;
}
示例3: create
PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value)
{
if (value.isNull())
return IDBKey::create();
if (value.isInt32())
return IDBKey::create(value.toInt32(exec));
if (value.isString())
return IDBKey::create(ustringToString(value.toString(exec)));
// FIXME: Implement dates.
return 0;
}
示例4: throwError
static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec, JSC::JSObject *callee,
JSC::JSValue thisValue, const JSC::ArgList &args)
{
QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
thisValue = engine->toUsableValue(thisValue);
if (!thisValue.inherits(&QScriptObject::info))
return throwError(exec, JSC::TypeError, "This object is not a QVariant");
QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(thisValue))->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::Variant))
return throwError(exec, JSC::TypeError, "This object is not a QVariant");
const QVariant &v = static_cast<QVariantDelegate*>(delegate)->value();
JSC::UString result;
JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args);
if (value.isObject()) {
result = v.toString();
if (result.isEmpty() && !v.canConvert(QVariant::String))
result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(v.typeName()));
} else {
result = value.toString(exec);
}
return JSC::jsString(exec, result);
}
示例5: 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;
}
示例6: asPlainText
String DragData::asPlainText() const
{
JSC::JSLock lock(false);
bool success;
JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::TEXT_TYPE, success);
if (success && data.isString())
return String(ustringToString(data.toString(m_platformDragData->execState())));
Vector<String> filenames;
asFilenames(filenames);
if (!filenames.isEmpty()) {
String result;
for (unsigned int i=0; i<filenames.size(); i++)
result.append(filenames[i] + "\n");
return result;
}
String url(asURL(NULL));
if (!url.isEmpty())
return url;
return String();
}
示例7: asFilenames
void DragData::asFilenames(Vector<String>& result) const
{
bool success;
JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::FILE_LIST_TYPE, success);
JSC::ExecState *exec = m_platformDragData->execState();
if (success && data.isObject()) {
JSC::JSObject* filenameArray = data.toObject(exec);
uint32_t length = filenameArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec);
for (uint32_t i=0; i<length; i++) {
JSC::JSValue fileValue = filenameArray->get(exec, i);
if (fileValue.isObject()) {
JSC::JSObject* file = fileValue.toObject(exec);
JSC::JSValue pathValue = file->get(exec, JSC::Identifier(exec, "nativePath"));
if (pathValue.isString()) {
String path = ustringToString(pathValue.toString(exec));
result.append(path);
}
}
}
}
if (exec->hadException())
exec->clearException();
}