本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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);
}
示例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());
}
示例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));
}
示例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());
}
示例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);
}
示例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();
}
示例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);
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}