当前位置: 首页>>代码示例>>C++>>正文


C++ JSValue::toString方法代码示例

本文整理汇总了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();
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:9,代码来源:DragDataApollo.cpp

示例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;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:10,代码来源:WebFrame.cpp

示例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;
}
开发者ID:1833183060,项目名称:wke,代码行数:11,代码来源:IDBBindingUtilities.cpp

示例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);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:22,代码来源:qscriptvariant.cpp

示例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;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:38,代码来源:WebFrame.cpp

示例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();
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:23,代码来源:DragDataApollo.cpp

示例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();
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:23,代码来源:DragDataApollo.cpp


注:本文中的jsc::JSValue::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。