本文整理汇总了C++中ExecState::vm方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::vm方法的具体用法?C++ ExecState::vm怎么用?C++ ExecState::vm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::vm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSSynchronousGarbageCollectForDebugging
void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx)
{
if (!ctx)
return;
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
exec->vm().heap.collectAllGarbage();
}
示例2: all
JSValue JSHTMLDocument::all(ExecState& state) const
{
// If "all" has been overwritten, return the overwritten value
JSValue v = getDirect(state.vm(), Identifier::fromString(&state, "all"));
if (v)
return v;
return toJS(&state, globalObject(), wrapped().all());
}
示例3: JSSynchronousGarbageCollectForDebugging
void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx)
{
if (!ctx)
return;
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
exec->vm().heap.collectAllGarbage();
}
示例4: verify
JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (state.argumentCount() < 4)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
ASSERT(scope.exception() || algorithm);
if (!algorithm)
return jsUndefined();
auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(&state, algorithm->identifier(), state.uncheckedArgument(0));
ASSERT(scope.exception() || parameters);
if (!parameters)
return jsUndefined();
RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
if (!key)
return throwTypeError(&state, scope);
if (!key->allows(CryptoKeyUsageVerify)) {
wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'verify'"));
setDOMException(&state, NOT_SUPPORTED_ERR);
return jsUndefined();
}
CryptoOperationData signature;
auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature);
ASSERT(scope.exception() || success);
if (!success)
return jsUndefined();
CryptoOperationData data;
success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data);
ASSERT(scope.exception() || success);
if (!success)
return jsUndefined();
RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
auto promise = wrapper->promise();
auto successCallback = [wrapper](bool result) mutable {
wrapper->resolve(result);
};
auto failureCallback = [wrapper]() mutable {
wrapper->reject(nullptr);
};
auto result = algorithm->verify(*parameters, *key, signature, data, WTFMove(successCallback), WTFMove(failureCallback));
if (result.hasException()) {
propagateException(state, scope, result.releaseException());
return { };
}
return promise;
}
示例5: JSObjectIsConstructor
bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object)
{
ExecState* exec = toJS(ctx);
VM& vm = exec->vm();
JSLockHolder locker(vm);
if (!object)
return false;
return toJS(object)->isConstructor(vm);
}
示例6: JSContextGetGroup
JSContextGroupRef JSContextGetGroup(JSContextRef ctx)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
return toRef(&exec->vm());
}
示例7: throwTypeError
template<> DictionaryImplName convertDictionary<DictionaryImplName>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
bool isNullOrUndefined = value.isUndefinedOrNull();
auto* object = isNullOrUndefined ? nullptr : value.getObject();
if (UNLIKELY(!isNullOrUndefined && !object)) {
throwTypeError(&state, throwScope);
return { };
}
DictionaryImplName result;
JSValue boolMemberValue;
if (isNullOrUndefined)
boolMemberValue = jsUndefined();
else {
boolMemberValue = object->get(&state, Identifier::fromString(&state, "boolMember"));
RETURN_IF_EXCEPTION(throwScope, { });
}
if (!boolMemberValue.isUndefined()) {
result.boolMember = convert<IDLBoolean>(state, boolMemberValue);
RETURN_IF_EXCEPTION(throwScope, { });
}
JSValue callbackMemberValue;
if (isNullOrUndefined)
callbackMemberValue = jsUndefined();
else {
callbackMemberValue = object->get(&state, Identifier::fromString(&state, "callbackMember"));
RETURN_IF_EXCEPTION(throwScope, { });
}
if (!callbackMemberValue.isUndefined()) {
result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(state, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()));
RETURN_IF_EXCEPTION(throwScope, { });
}
JSValue enumMemberValue;
if (isNullOrUndefined)
enumMemberValue = jsUndefined();
else {
enumMemberValue = object->get(&state, Identifier::fromString(&state, "enumMember"));
RETURN_IF_EXCEPTION(throwScope, { });
}
if (!enumMemberValue.isUndefined()) {
result.enumMember = convert<IDLEnumeration<TestStandaloneDictionary::EnumInStandaloneDictionaryFile>>(state, enumMemberValue);
RETURN_IF_EXCEPTION(throwScope, { });
}
JSValue stringMemberValue;
if (isNullOrUndefined)
stringMemberValue = jsUndefined();
else {
stringMemberValue = object->get(&state, Identifier::fromString(&state, "stringMember"));
RETURN_IF_EXCEPTION(throwScope, { });
}
if (!stringMemberValue.isUndefined()) {
result.stringMember = convert<IDLDOMString>(state, stringMemberValue);
RETURN_IF_EXCEPTION(throwScope, { });
}
return result;
}
示例8: JSSynchronousEdenCollectForDebugging
void JSSynchronousEdenCollectForDebugging(JSContextRef ctx)
{
if (!ctx)
return;
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
exec->vm().heap.collectSync(CollectionScope::Eden);
}
示例9: wrapKey
JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (state.argumentCount() < 4)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
auto keyFormat = cryptoKeyFormatFromJSValue(state, scope, state.uncheckedArgument(0));
RETURN_IF_EXCEPTION(scope, { });
RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(vm, state.uncheckedArgument(1));
if (!key)
return throwTypeError(&state, scope);
RefPtr<CryptoKey> wrappingKey = JSCryptoKey::toWrapped(vm, state.uncheckedArgument(2));
if (!key)
return throwTypeError(&state, scope);
if (!wrappingKey->allows(CryptoKeyUsageWrapKey)) {
wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'wrapKey'"));
throwNotSupportedError(state, scope);
return jsUndefined();
}
auto algorithm = createAlgorithmFromJSValue(state, scope, state.uncheckedArgument(3));
RETURN_IF_EXCEPTION(scope, { });
auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(state, scope, algorithm->identifier(), state.uncheckedArgument(3));
RETURN_IF_EXCEPTION(scope, { });
RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
auto promise = wrapper->promise();
auto exportSuccessCallback = [keyFormat, algorithm, parameters, wrappingKey, wrapper](const Vector<uint8_t>& exportedKeyData) mutable {
auto encryptSuccessCallback = [wrapper](const Vector<uint8_t>& encryptedData) mutable {
fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), encryptedData.data(), encryptedData.size());
};
auto encryptFailureCallback = [wrapper]() mutable {
wrapper->reject(); // FIXME: This should reject with an Exception.
};
auto result = algorithm->encryptForWrapKey(*parameters, *wrappingKey, std::make_pair(exportedKeyData.data(), exportedKeyData.size()), WTFMove(encryptSuccessCallback), WTFMove(encryptFailureCallback));
if (result.hasException()) {
// FIXME: Report failure details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
wrapper->reject(); // FIXME: This should reject with an Exception.
}
};
auto exportFailureCallback = [wrapper]() mutable {
wrapper->reject(); // FIXME: This should reject with an Exception.
};
WebCore::exportKey(state, keyFormat, *key, WTFMove(exportSuccessCallback), WTFMove(exportFailureCallback));
return promise;
}
示例10: MessageEvent
inline MessageEvent::MessageEvent(ExecState& state, const AtomicString& type, Init&& initializer, IsTrusted isTrusted)
: Event(type, initializer, isTrusted)
, m_dataType(DataTypeScriptValue)
, m_dataAsScriptValue(state.vm(), initializer.data)
, m_origin(initializer.origin)
, m_lastEventId(initializer.lastEventId)
, m_source(WTFMove(initializer.source))
, m_ports(WTFMove(initializer.ports))
{
}
示例11: JSSynchronousGarbageCollectForDebugging
void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx)
{
if (!ctx)
return;
ExecState* exec = toJS(ctx);
VM& vm = exec->vm();
JSLockHolder locker(vm);
vm.heap.collectNow(Sync, CollectionScope::Full);
}
示例12: JSReportExtraMemoryCost
void JSReportExtraMemoryCost(JSContextRef ctx, size_t size)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
exec->vm().heap.reportExtraMemoryCost(size);
}
示例13: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
VM& vm = exec->vm();
gcProtect(exec->vmEntryGlobalObject());
vm.ref();
return ctx;
}
示例14: JSObjectMakeFunctionWithCallback
JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
return toRef(JSCallbackFunction::create(exec->vm(), exec->lexicalGlobalObject(), callAsFunction, name ? name->string() : ASCIILiteral("anonymous")));
}
示例15: JSReportExtraMemoryCost
void JSReportExtraMemoryCost(JSContextRef ctx, size_t size)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
exec->vm().heap.reportExtraMemoryCost(size);
}