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


C++ ScriptValue::v8Value方法代码示例

本文整理汇总了C++中ScriptValue::v8Value方法的典型用法代码示例。如果您正苦于以下问题:C++ ScriptValue::v8Value方法的具体用法?C++ ScriptValue::v8Value怎么用?C++ ScriptValue::v8Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptValue的用法示例。


在下文中一共展示了ScriptValue::v8Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isReadableStream

bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState,
                                                ScriptValue value) {
  ASSERT(!value.isEmpty());

  if (!value.isObject())
    return false;

  v8::Local<v8::Value> args[] = {value.v8Value()};
  return V8ScriptRunner::callExtraOrCrash(scriptState, "IsReadableStream", args)
      ->ToBoolean()
      ->Value();
}
开发者ID:mirror,项目名称:chromium,代码行数:12,代码来源:ReadableStreamOperations.cpp

示例2:

ScriptCustomElementDefinitionBuilder::ScriptCustomElementDefinitionBuilder(
    ScriptState* scriptState,
    CustomElementRegistry* registry,
    const ScriptValue& constructor,
    ExceptionState& exceptionState)
    : m_prev(s_stack),
      m_scriptState(scriptState),
      m_registry(registry),
      m_constructorValue(constructor.v8Value()),
      m_exceptionState(exceptionState) {
  s_stack = this;
}
开发者ID:mirror,项目名称:chromium,代码行数:12,代码来源:ScriptCustomElementDefinitionBuilder.cpp

示例3: dictionary

v8::Handle<v8::Value> WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Handle<v8::Value> options, WebExceptionCode& ec)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    Document* document = unwrap<Document>();
    Dictionary dictionary(options, isolate);
    TrackExceptionState exceptionState;
    ScriptValue constructor = document->registerElement(ScriptState::current(isolate), name, dictionary, exceptionState, CustomElement::EmbedderNames);
    ec = exceptionState.code();
    if (exceptionState.hadException())
        return v8::Handle<v8::Value>();
    return constructor.v8Value();
}
开发者ID:pozdnyakov,项目名称:blink-crosswalk-1,代码行数:12,代码来源:WebDocument.cpp

示例4: ScriptValue

ScriptPromise::ScriptPromise(const ScriptValue& value)
{
    if (value.hasNoValue())
        return;
    v8::Local<v8::Value> v8Value(value.v8Value());
    v8::Isolate* isolate = value.isolate();
    if (V8PromiseCustom::isPromise(v8Value, isolate)) {
        m_promise = value;
        return;
    }
    m_promise = ScriptValue(V8PromiseCustom::toPromise(v8Value, isolate), isolate);
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例5: exceptionState

void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
    ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate());
    ScriptValue text = xmlHttpRequest->responseText(exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    if (text.hasNoValue()) {
        v8SetReturnValueString(info, emptyString(), info.GetIsolate());
        return;
    }
    v8SetReturnValue(info, text.v8Value());
}
开发者ID:kublaj,项目名称:blink,代码行数:13,代码来源:V8XMLHttpRequestCustom.cpp

示例6: createReadableStream

ScriptValue ReadableStreamOperations::createReadableStream(
    ScriptState* scriptState,
    UnderlyingSourceBase* underlyingSource,
    ScriptValue strategy) {
  ScriptState::Scope scope(scriptState);

  v8::Local<v8::Value> jsUnderlyingSource = toV8(underlyingSource, scriptState);
  v8::Local<v8::Value> jsStrategy = strategy.v8Value();
  v8::Local<v8::Value> args[] = {jsUnderlyingSource, jsStrategy};
  return ScriptValue(
      scriptState,
      V8ScriptRunner::callExtraOrCrash(
          scriptState, "createReadableStreamWithExternalController", args));
}
开发者ID:mirror,项目名称:chromium,代码行数:14,代码来源:ReadableStreamOperations.cpp

示例7: UnderlyingSourceBase

BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, ScriptValue stream)
    : UnderlyingSourceBase(scriptState),
      m_scriptState(scriptState),
      m_madeFromReadableStream(true) {
  DCHECK(ReadableStreamOperations::isReadableStream(scriptState, stream));
  v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
  DCHECK(!bodyValue.IsEmpty());
  DCHECK(bodyValue->IsObject());
  v8::Local<v8::Object> body = bodyValue.As<v8::Object>();

  V8HiddenValue::setHiddenValue(
      scriptState, body,
      V8HiddenValue::internalBodyStream(scriptState->isolate()),
      stream.v8Value());
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例8: assertPrimaryKeyValidOrInjectable

void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, PassRefPtr<SharedBuffer> buffer, const Vector<blink::WebBlobInfo>* blobInfo, IDBKey* key, const IDBKeyPath& keyPath)
{
    ScriptState::Scope scope(scriptState);
    v8::Isolate* isolate = scriptState->isolate();
    ScriptValue keyValue = idbKeyToScriptValue(scriptState, key);
    ScriptValue scriptValue(scriptState, deserializeIDBValueBuffer(isolate, buffer.get(), blobInfo));

    // This assertion is about already persisted data, so allow experimental types.
    const bool allowExperimentalTypes = true;
    IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue, keyPath, allowExperimentalTypes);
    ASSERT(!expectedKey || expectedKey->isEqual(key));

    bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptValue.v8Value(), keyPath);
    ASSERT_UNUSED(injected, injected);
}
开发者ID:exploring,项目名称:blink-crosswalk,代码行数:15,代码来源:IDBBindingUtilities.cpp

示例9:

v8::Local<v8::Value> WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Local<v8::Value> options, WebExceptionCode& ec)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    Document* document = unwrap<Document>();
    TrackExceptionState exceptionState;
    ElementRegistrationOptions registrationOptions;
    V8ElementRegistrationOptions::toImpl(isolate, options, registrationOptions, exceptionState);
    if (exceptionState.hadException())
        return v8::Local<v8::Value>();
    ScriptValue constructor = document->registerElement(ScriptState::current(isolate), name, registrationOptions, exceptionState, CustomElement::EmbedderNames);
    ec = exceptionState.code();
    if (exceptionState.hadException())
        return v8::Local<v8::Value>();
    return constructor.v8Value();
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:15,代码来源:WebDocument.cpp

示例10: handleScope

static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& value, const String& keyPath, v8::Isolate* isolate)
{
    Vector<String> keyPathElements;
    IDBKeyPathParseError error;
    IDBParseKeyPath(keyPath, keyPathElements, error);
    ASSERT(error == IDBKeyPathParseErrorNone);
    ASSERT(isolate->InContext());

    v8::HandleScope handleScope(isolate);
    v8::Handle<v8::Value> v8Value(value.v8Value());
    v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size(), isolate));
    if (v8Key.IsEmpty())
        return 0;
    return createIDBKeyFromValue(v8Key, isolate);
}
开发者ID:Metrological,项目名称:chromium,代码行数:15,代码来源:IDBBindingUtilities.cpp

示例11: scope

void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg)
{
    if (!canInvokeCallback())
        return;

    if (!m_scriptState->contextIsValid())
        return;

    ScriptState::Scope scope(m_scriptState.get());
    v8::Local<v8::Value> thisHandle = thisValue.v8Value();
    v8::Local<v8::Value> stringArgHandle = v8String(m_scriptState->isolate(), stringArg);
    v8::Local<v8::Value> argv[] = { stringArgHandle };

    V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), thisHandle, 1, argv, m_scriptState->isolate());
}
开发者ID:ollie314,项目名称:chromium,代码行数:15,代码来源:V8TestCallbackInterface.cpp

示例12: canInjectIDBKeyIntoScriptValue

bool canInjectIDBKeyIntoScriptValue(DOMRequestState* state, const ScriptValue& scriptValue, const IDBKeyPath& keyPath)
{
    IDB_TRACE("canInjectIDBKeyIntoScriptValue");
    ASSERT(keyPath.type() == IDBKeyPath::StringType);
    Vector<String> keyPathElements;
    IDBKeyPathParseError error;
    IDBParseKeyPath(keyPath.string(), keyPathElements, error);
    ASSERT(error == IDBKeyPathParseErrorNone);

    if (!keyPathElements.size())
        return false;

    v8::Handle<v8::Value> v8Value(scriptValue.v8Value());
    return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1, state->context()->GetIsolate());
}
开发者ID:Metrological,项目名称:chromium,代码行数:15,代码来源:IDBBindingUtilities.cpp

示例13: getReader

ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState,
                                                ScriptValue stream,
                                                ExceptionState& es) {
  ASSERT(isReadableStream(scriptState, stream));

  v8::TryCatch block(scriptState->isolate());
  v8::Local<v8::Value> args[] = {stream.v8Value()};
  ScriptValue result(
      scriptState,
      V8ScriptRunner::callExtra(scriptState,
                                "AcquireReadableStreamDefaultReader", args));
  if (block.HasCaught())
    es.rethrowV8Exception(block.Exception());
  return result;
}
开发者ID:mirror,项目名称:chromium,代码行数:15,代码来源:ReadableStreamOperations.cpp

示例14: responseWasResolved

void AcceptConnectionObserver::responseWasResolved(const ScriptValue& value)
{
    ASSERT(executionContext());
    if (!m_resolver) {
        // TODO(mek): Get rid of this block when observer is only used for
        // service port connect events.
        if (!value.v8Value()->IsTrue()) {
            responseWasRejected();
            return;
        }
        ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleCrossOriginConnectEvent(m_eventID, true);
        m_state = Done;
        return;
    }

    ScriptState* scriptState = m_resolver->scriptState();
    ExceptionState exceptionState(ExceptionState::UnknownContext, nullptr, nullptr, scriptState->context()->Global(), scriptState->isolate());
    ServicePortConnectResponse response = ScriptValue::to<ServicePortConnectResponse>(scriptState->isolate(), value, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.reject(m_resolver.get());
        m_resolver = nullptr;
        responseWasRejected();
        return;
    }
    if (!response.hasAccept() || !response.accept()) {
        responseWasRejected();
        return;
    }
    WebServicePort webPort;
    webPort.targetUrl = m_targetURL;
    if (response.hasName())
        webPort.name = response.name();
    if (response.hasData()) {
        webPort.data = SerializedScriptValueFactory::instance().create(scriptState->isolate(), response.data(), nullptr, exceptionState)->toWireString();
        if (exceptionState.hadException()) {
            exceptionState.reject(m_resolver.get());
            m_resolver = nullptr;
            responseWasRejected();
            return;
        }
    }
    webPort.id = m_portID;
    ServicePort* port = ServicePort::create(m_collection, webPort);
    m_collection->addPort(port);
    m_resolver->resolve(port);
    m_callbacks->onSuccess(&webPort);
    m_state = Done;
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:48,代码来源:AcceptConnectionObserver.cpp

示例15: assertPrimaryKeyValidOrInjectable

void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey> prpKey, const IDBKeyPath& keyPath)
{
    RefPtr<IDBKey> key(prpKey);

    DOMRequestState::Scope scope(*state);
    v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();

    ScriptValue keyValue = idbKeyToScriptValue(state, key);
    ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), isolate);

    RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(state, scriptValue, keyPath);
    ASSERT(!expectedKey || expectedKey->isEqual(key.get()));

    bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Value(), keyPath, isolate);
    ASSERT_UNUSED(injected, injected);
}
开发者ID:Metrological,项目名称:chromium,代码行数:16,代码来源:IDBBindingUtilities.cpp


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