本文整理汇总了C++中RETURN_IF_EXCEPTION函数的典型用法代码示例。如果您正苦于以下问题:C++ RETURN_IF_EXCEPTION函数的具体用法?C++ RETURN_IF_EXCEPTION怎么用?C++ RETURN_IF_EXCEPTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RETURN_IF_EXCEPTION函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: moduleLoaderPrototypeParseModule
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeParseModule(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto* jsSourceCode = jsDynamicCast<JSSourceCode*>(vm, exec->argument(1));
if (!jsSourceCode)
return throwVMTypeError(exec, scope);
SourceCode sourceCode = jsSourceCode->sourceCode();
CodeProfiling profile(sourceCode);
ParserError error;
std::unique_ptr<ModuleProgramNode> moduleProgramNode = parse<ModuleProgramNode>(
&vm, sourceCode, Identifier(), JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::Strict, JSParserScriptMode::Module, SourceParseMode::ModuleAnalyzeMode, SuperBinding::NotNeeded, error);
if (error.isValid()) {
throwVMError(exec, scope, error.toErrorObject(exec->lexicalGlobalObject(), sourceCode));
return JSValue::encode(jsUndefined());
}
ASSERT(moduleProgramNode);
ModuleAnalyzer moduleAnalyzer(exec, moduleKey, sourceCode, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables());
RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSModuleRecord* moduleRecord = moduleAnalyzer.analyze(*moduleProgramNode);
return JSValue::encode(moduleRecord);
}
开发者ID:caiolima,项目名称:webkit,代码行数:32,代码来源:ModuleLoaderPrototype.cpp
示例2: constructWeakSet
static EncodedJSValue JSC_HOST_CALL constructWeakSet(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSGlobalObject* globalObject = asInternalFunction(exec->jsCallee())->globalObject();
Structure* weakSetStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakSetStructure());
RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSWeakSet* weakSet = JSWeakSet::create(exec, weakSetStructure);
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(weakSet);
JSValue adderFunction = weakSet->JSObject::get(exec, vm.propertyNames->add);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
if (adderFunctionCallType == CallType::None)
return JSValue::encode(throwTypeError(exec, scope));
scope.release();
forEachInIterable(exec, iterable, [&](VM&, ExecState* exec, JSValue nextValue) {
MarkedArgumentBuffer arguments;
arguments.append(nextValue);
call(exec, adderFunction, adderFunctionCallType, adderFunctionCallData, weakSet, arguments);
});
return JSValue::encode(weakSet);
}
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:30,代码来源:WeakSetConstructor.cpp
示例3: iteratorForIterable
JSValue iteratorForIterable(ExecState* state, JSValue iterable)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue iteratorFunction = iterable.get(state, state->propertyNames().iteratorSymbol);
RETURN_IF_EXCEPTION(scope, JSValue());
CallData iteratorFunctionCallData;
CallType iteratorFunctionCallType = getCallData(iteratorFunction, iteratorFunctionCallData);
if (iteratorFunctionCallType == CallType::None) {
throwTypeError(state, scope);
return JSValue();
}
ArgList iteratorFunctionArguments;
JSValue iterator = call(state, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
RETURN_IF_EXCEPTION(scope, JSValue());
if (!iterator.isObject()) {
throwTypeError(state, scope);
return JSValue();
}
return iterator;
}
开发者ID:caiolima,项目名称:webkit,代码行数:26,代码来源:IteratorOperations.cpp
示例4: iteratorForIterable
IterationRecord iteratorForIterable(ExecState* state, JSValue iterable)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue iteratorFunction = iterable.get(state, vm.propertyNames->iteratorSymbol);
RETURN_IF_EXCEPTION(scope, { });
CallData iteratorFunctionCallData;
CallType iteratorFunctionCallType = getCallData(vm, iteratorFunction, iteratorFunctionCallData);
if (iteratorFunctionCallType == CallType::None) {
throwTypeError(state, scope);
return { };
}
ArgList iteratorFunctionArguments;
JSValue iterator = call(state, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
RETURN_IF_EXCEPTION(scope, { });
if (!iterator.isObject()) {
throwTypeError(state, scope);
return { };
}
JSValue nextMethod = iterator.getObject()->get(state, vm.propertyNames->next);
RETURN_IF_EXCEPTION(scope, { });
return { iterator, nextMethod };
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:29,代码来源:IteratorOperations.cpp
示例5: getJSListenerFunctions
static JSArray* getJSListenerFunctions(ExecState& state, Document* document, const EventListenerInfo& listenerInfo)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* result = constructEmptyArray(&state, nullptr);
RETURN_IF_EXCEPTION(scope, nullptr);
size_t handlersCount = listenerInfo.eventListenerVector.size();
for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
const JSEventListener* jsListener = JSEventListener::cast(&listenerInfo.eventListenerVector[i]->callback());
if (!jsListener) {
ASSERT_NOT_REACHED();
continue;
}
// Hide listeners from other contexts.
if (&jsListener->isolatedWorld() != ¤tWorld(&state))
continue;
JSObject* function = jsListener->jsFunction(document);
if (!function)
continue;
JSObject* listenerEntry = constructEmptyObject(&state);
listenerEntry->putDirect(vm, Identifier::fromString(&state, "listener"), function);
listenerEntry->putDirect(vm, Identifier::fromString(&state, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i]->useCapture()));
result->putDirectIndex(&state, outputIndex++, JSValue(listenerEntry));
RETURN_IF_EXCEPTION(scope, nullptr);
}
return result;
}
开发者ID:eocanha,项目名称:webkit,代码行数:30,代码来源:JSCommandLineAPIHostCustom.cpp
示例6: DECLARE_THROW_SCOPE
// Based on ErrorPrototype's errorProtoFuncToString(), but is modified to
// have no observable side effects to the user (i.e. does not call proxies,
// and getters).
String ErrorInstance::sanitizedToString(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue nameValue;
auto namePropertName = vm.propertyNames->name;
PropertySlot nameSlot(this, PropertySlot::InternalMethodType::VMInquiry);
JSValue currentObj = this;
unsigned prototypeDepth = 0;
// We only check the current object and its prototype (2 levels) because normal
// Error objects may have a name property, and if not, its prototype should have
// a name property for the type of error e.g. "SyntaxError".
while (currentObj.isCell() && prototypeDepth++ < 2) {
JSObject* obj = jsCast<JSObject*>(currentObj);
if (JSObject::getOwnPropertySlot(obj, exec, namePropertName, nameSlot) && nameSlot.isValue()) {
nameValue = nameSlot.getValue(exec, namePropertName);
break;
}
currentObj = obj->getPrototypeDirect();
}
ASSERT(!scope.exception());
String nameString;
if (!nameValue)
nameString = ASCIILiteral("Error");
else {
nameString = nameValue.toWTFString(exec);
RETURN_IF_EXCEPTION(scope, String());
}
JSValue messageValue;
auto messagePropertName = vm.propertyNames->message;
PropertySlot messageSlot(this, PropertySlot::InternalMethodType::VMInquiry);
if (JSObject::getOwnPropertySlot(this, exec, messagePropertName, messageSlot) && messageSlot.isValue())
messageValue = messageSlot.getValue(exec, messagePropertName);
ASSERT(!scope.exception());
String messageString;
if (!messageValue)
messageString = String();
else {
messageString = messageValue.toWTFString(exec);
RETURN_IF_EXCEPTION(scope, String());
}
if (!nameString.length())
return messageString;
if (!messageString.length())
return nameString;
StringBuilder builder;
builder.append(nameString);
builder.appendLiteral(": ");
builder.append(messageString);
return builder.toString();
}
开发者ID:eocanha,项目名称:webkit,代码行数:63,代码来源:ErrorInstance.cpp
示例7: IntlCollatorFuncCompare
static EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* state)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// 10.3.4 Collator Compare Functions (ECMA-402 2.0)
// 1. Let collator be the this value.
// 2. Assert: Type(collator) is Object and collator has an [[initializedCollator]] internal slot whose value is true.
IntlCollator* collator = jsCast<IntlCollator*>(state->thisValue());
// 3. If x is not provided, let x be undefined.
// 4. If y is not provided, let y be undefined.
// 5. Let X be ToString(x).
JSString* x = state->argument(0).toString(state);
// 6. ReturnIfAbrupt(X).
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 7. Let Y be ToString(y).
JSString* y = state->argument(1).toString(state);
// 8. ReturnIfAbrupt(Y).
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 9. Return CompareStrings(collator, X, Y).
auto xViewWithString = x->viewWithUnderlyingString(*state);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto yViewWithString = y->viewWithUnderlyingString(*state);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
scope.release();
return JSValue::encode(collator->compareStrings(*state, xViewWithString.view, yViewWithString.view));
}
开发者ID:ollie314,项目名称:webkit,代码行数:29,代码来源:IntlCollatorPrototype.cpp
示例8: webAssemblyModuleImports
EncodedJSValue JSC_HOST_CALL webAssemblyModuleImports(ExecState* exec)
{
VM& vm = exec->vm();
auto* globalObject = exec->lexicalGlobalObject();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->argument(0));
if (!module)
return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Module.imports called with non WebAssembly.Module argument"_s)));
JSArray* result = constructEmptyArray(exec, nullptr, globalObject);
RETURN_IF_EXCEPTION(throwScope, { });
const auto& imports = module->moduleInformation().imports;
if (imports.size()) {
Identifier module = Identifier::fromString(exec, "module");
Identifier name = Identifier::fromString(exec, "name");
Identifier kind = Identifier::fromString(exec, "kind");
for (const Wasm::Import& imp : imports) {
JSObject* obj = constructEmptyObject(exec);
RETURN_IF_EXCEPTION(throwScope, { });
obj->putDirect(vm, module, jsString(exec, String::fromUTF8(imp.module)));
obj->putDirect(vm, name, jsString(exec, String::fromUTF8(imp.field)));
obj->putDirect(vm, kind, jsString(exec, String(makeString(imp.kind))));
result->push(exec, obj);
RETURN_IF_EXCEPTION(throwScope, { });
}
}
return JSValue::encode(result);
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:31,代码来源:WebAssemblyModuleConstructor.cpp
示例9: callHTMLAllCollection
// HTMLAllCollections are strange objects, they support both get and call.
static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (exec->argumentCount() < 1)
return JSValue::encode(jsUndefined());
// Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
JSHTMLAllCollection* jsCollection = jsCast<JSHTMLAllCollection*>(exec->callee());
HTMLAllCollection& collection = jsCollection->wrapped();
// Also, do we need the TypeError test here ?
if (exec->argumentCount() == 1) {
// Support for document.all(<index>) etc.
String string = exec->argument(0).toString(exec)->value(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (Optional<uint32_t> index = parseIndex(*string.impl()))
return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection.item(index.value())));
// Support for document.images('<name>') etc.
return JSValue::encode(namedItems(*exec, jsCollection, Identifier::fromString(exec, string)));
}
// The second arg, if set, is the index of the item we want
String string = exec->argument(0).toString(exec)->value(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (Optional<uint32_t> index = parseIndex(*exec->argument(1).toWTFString(exec).impl())) {
if (auto* item = collection.namedItemWithIndex(string, index.value()))
return JSValue::encode(toJS(exec, jsCollection->globalObject(), *item));
}
return JSValue::encode(jsUndefined());
}
开发者ID:ollie314,项目名称:webkit,代码行数:36,代码来源:JSHTMLAllCollectionCustom.cpp
示例10: constructArrayBuffer
static EncodedJSValue JSC_HOST_CALL constructArrayBuffer(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArrayBufferConstructor* constructor =
jsCast<JSArrayBufferConstructor*>(exec->jsCallee());
unsigned length;
if (exec->argumentCount()) {
length = exec->uncheckedArgument(0).toIndex(exec, "length");
RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else {
// Although the documentation doesn't say so, it is in fact correct to say
// "new ArrayBuffer()". The result is the same as allocating an array buffer
// with a zero length.
length = 0;
}
auto buffer = ArrayBuffer::tryCreate(length, 1);
if (!buffer)
return JSValue::encode(throwOutOfMemoryError(exec, scope));
if (constructor->sharingMode() == ArrayBufferSharingMode::Shared)
buffer->makeShared();
ASSERT(constructor->sharingMode() == buffer->sharingMode());
Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure(constructor->sharingMode()));
RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSArrayBuffer* result = JSArrayBuffer::create(vm, arrayBufferStructure, WTFMove(buffer));
return JSValue::encode(result);
}
开发者ID:caiolima,项目名称:webkit,代码行数:34,代码来源:JSArrayBufferConstructor.cpp
示例11: webAssemblyModuleCustomSections
EncodedJSValue JSC_HOST_CALL webAssemblyModuleCustomSections(ExecState* exec)
{
VM& vm = exec->vm();
auto* globalObject = exec->lexicalGlobalObject();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->argument(0));
if (!module)
return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Module.customSections called with non WebAssembly.Module argument"_s)));
const String sectionNameString = exec->argument(1).getString(exec);
RETURN_IF_EXCEPTION(throwScope, { });
JSArray* result = constructEmptyArray(exec, nullptr, globalObject);
RETURN_IF_EXCEPTION(throwScope, { });
const auto& customSections = module->moduleInformation().customSections;
for (const Wasm::CustomSection& section : customSections) {
if (String::fromUTF8(section.name) == sectionNameString) {
auto buffer = ArrayBuffer::tryCreate(section.payload.data(), section.payload.size());
if (!buffer)
return JSValue::encode(throwException(exec, throwScope, createOutOfMemoryError(exec)));
result->push(exec, JSArrayBuffer::create(vm, globalObject->arrayBufferStructure(ArrayBufferSharingMode::Default), WTFMove(buffer)));
RETURN_IF_EXCEPTION(throwScope, { });
}
}
return JSValue::encode(result);
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:30,代码来源:WebAssemblyModuleConstructor.cpp
示例12: DECLARE_THROW_SCOPE
JSValue JSWebKitSubtleCrypto::exportKey(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (state.argumentCount() < 2)
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<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
auto promise = wrapper->promise();
auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
};
auto failureCallback = [wrapper]() mutable {
wrapper->reject(); // FIXME: This should reject with an Exception.
};
WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
RETURN_IF_EXCEPTION(scope, JSValue());
return promise;
}
开发者ID:caiolima,项目名称:webkit,代码行数:29,代码来源:JSWebKitSubtleCryptoCustom.cpp
示例13: DECLARE_THROW_SCOPE
JSValue Database::toJS(ExecState* exec) const
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* result = constructEmptyObject(exec);
JSArray* bytecodes = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_bytecodes.size(); ++i)
bytecodes->putDirectIndex(exec, i, m_bytecodes[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().bytecodes, bytecodes);
JSArray* compilations = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_compilations.size(); ++i)
compilations->putDirectIndex(exec, i, m_compilations[i]->toJS(exec));
result->putDirect(vm, exec->propertyNames().compilations, compilations);
JSArray* events = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_events.size(); ++i)
events->putDirectIndex(exec, i, m_events[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().events, events);
return result;
}
开发者ID:ollie314,项目名称:webkit,代码行数:26,代码来源:ProfilerDatabase.cpp
示例14: webAssemblyTableProtoFuncSet
static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState* exec)
{
VM& vm = exec->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSWebAssemblyTable* table = getTable(exec, vm, exec->thisValue());
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue value = exec->argument(1);
WebAssemblyFunction* wasmFunction;
WebAssemblyWrapperFunction* wasmWrapperFunction;
if (!value.isNull() && !isWebAssemblyHostFunction(vm, value, wasmFunction, wasmWrapperFunction))
return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Table.prototype.set expects the second argument to be null or an instance of WebAssembly.Function"_s)));
uint32_t index = toNonWrappingUint32(exec, exec->argument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (index >= table->length())
return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, "WebAssembly.Table.prototype.set expects an integer less than the length of the table"_s)));
if (value.isNull())
table->clearFunction(index);
else {
ASSERT(value.isObject() && isWebAssemblyHostFunction(vm, jsCast<JSObject*>(value), wasmFunction, wasmWrapperFunction));
ASSERT(!!wasmFunction || !!wasmWrapperFunction);
if (wasmFunction)
table->setFunction(vm, index, wasmFunction);
else
table->setFunction(vm, index, wasmWrapperFunction);
}
return JSValue::encode(jsUndefined());
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:33,代码来源:WebAssemblyTablePrototype.cpp
示例15: errorProtoFuncToString
// ECMA-262 5.1, 15.11.4.4
EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// 1. Let O be the this value.
JSValue thisValue = exec->thisValue();
// 2. If Type(O) is not Object, throw a TypeError exception.
if (!thisValue.isObject())
return throwVMTypeError(exec, scope);
JSObject* thisObj = asObject(thisValue);
// Guard against recursion!
StringRecursionChecker checker(exec, thisObj);
ASSERT(!scope.exception() || checker.earlyReturnValue());
if (JSValue earlyReturnValue = checker.earlyReturnValue())
return JSValue::encode(earlyReturnValue);
// 3. Let name be the result of calling the [[Get]] internal method of O with argument "name".
JSValue name = thisObj->get(exec, exec->propertyNames().name);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 4. If name is undefined, then let name be "Error"; else let name be ToString(name).
String nameString;
if (name.isUndefined())
nameString = ASCIILiteral("Error");
else {
nameString = name.toWTFString(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 5. Let msg be the result of calling the [[Get]] internal method of O with argument "message".
JSValue message = thisObj->get(exec, exec->propertyNames().message);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// (sic)
// 6. If msg is undefined, then let msg be the empty String; else let msg be ToString(msg).
// 7. If msg is undefined, then let msg be the empty String; else let msg be ToString(msg).
String messageString;
if (message.isUndefined())
messageString = String();
else {
messageString = message.toWTFString(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 8. If name is the empty String, return msg.
if (!nameString.length())
return JSValue::encode(message.isString() ? message : jsString(exec, messageString));
// 9. If msg is the empty String, return name.
if (!messageString.length())
return JSValue::encode(name.isString() ? name : jsString(exec, nameString));
// 10. Return the result of concatenating name, ":", a single space character, and msg.
scope.release();
return JSValue::encode(jsMakeNontrivialString(exec, nameString, ": ", messageString));
}
开发者ID:caiolima,项目名称:webkit,代码行数:60,代码来源:ErrorPrototype.cpp
示例16: importKey
static void importKey(ExecState& state, CryptoKeyFormat keyFormat, CryptoOperationData data, RefPtr<CryptoAlgorithm> algorithm, RefPtr<CryptoAlgorithmParametersDeprecated> parameters, bool extractable, CryptoKeyUsageBitmap keyUsages, CryptoAlgorithm::KeyCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
std::unique_ptr<CryptoKeySerialization> keySerialization;
switch (keyFormat) {
case CryptoKeyFormat::Raw:
keySerialization = CryptoKeySerializationRaw::create(data);
break;
case CryptoKeyFormat::JWK: {
String jwkString = String::fromUTF8(data.first, data.second);
if (jwkString.isNull()) {
throwTypeError(&state, scope, ASCIILiteral("JWK JSON serialization is not valid UTF-8"));
return;
}
keySerialization = std::make_unique<JSCryptoKeySerializationJWK>(&state, jwkString);
RETURN_IF_EXCEPTION(scope, void());
break;
}
default:
throwTypeError(&state, scope, ASCIILiteral("Unsupported key format for import"));
return;
}
ASSERT(keySerialization);
std::optional<CryptoAlgorithmPair> reconciledResult = keySerialization->reconcileAlgorithm(algorithm.get(), parameters.get());
if (!reconciledResult) {
if (!scope.exception())
throwTypeError(&state, scope, ASCIILiteral("Algorithm specified in key is not compatible with one passed to importKey as argument"));
return;
}
RETURN_IF_EXCEPTION(scope, void());
algorithm = reconciledResult->algorithm;
parameters = reconciledResult->parameters;
if (!algorithm) {
throwTypeError(&state, scope, ASCIILiteral("Neither key nor function argument has crypto algorithm specified"));
return;
}
ASSERT(parameters);
keySerialization->reconcileExtractable(extractable);
RETURN_IF_EXCEPTION(scope, void());
keySerialization->reconcileUsages(keyUsages);
RETURN_IF_EXCEPTION(scope, void());
auto keyData = keySerialization->keyData();
RETURN_IF_EXCEPTION(scope, void());
propagateException(state, scope, algorithm->importKey(*parameters, *keyData, extractable, keyUsages, WTFMove(callback), WTFMove(failureCallback)));
}
开发者ID:caiolima,项目名称:webkit,代码行数:54,代码来源:JSWebKitSubtleCryptoCustom.cpp
示例17: DECLARE_THROW_SCOPE
JSArray* JSBoundFunction::boundArgsCopy(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* result = constructEmptyArray(exec, nullptr, globalObject());
RETURN_IF_EXCEPTION(scope, nullptr);
for (unsigned i = 0; i < m_boundArgs->length(); ++i) {
result->push(exec, m_boundArgs->getIndexQuickly(i));
RETURN_IF_EXCEPTION(scope, nullptr);
}
return result;
}
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:12,代码来源:JSBoundFunction.cpp
示例18: symbolConstructorFor
EncodedJSValue JSC_HOST_CALL symbolConstructorFor(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSString* stringKey = exec->argument(0).toString(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
String string = stringKey->value(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(Symbol::create(exec->vm(), exec->vm().symbolRegistry().symbolForKey(string)));
}
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:12,代码来源:SymbolConstructor.cpp
示例19: DECLARE_THROW_SCOPE
JSValue OSRExitSite::toJS(ExecState* exec) const
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* result = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, { });
for (unsigned i = 0; i < m_codeAddresses.size(); ++i) {
result->putDirectIndex(exec, i, jsString(exec, toString(RawPointer(m_codeAddresses[i]))));
RETURN_IF_EXCEPTION(scope, { });
}
return result;
}
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:12,代码来源:ProfilerOSRExitSite.cpp
示例20: iteratorStep
JSValue iteratorStep(ExecState* exec, IterationRecord iterationRecord)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue result = iteratorNext(exec, iterationRecord);
RETURN_IF_EXCEPTION(scope, JSValue());
bool done = iteratorComplete(exec, result);
RETURN_IF_EXCEPTION(scope, JSValue());
if (done)
return jsBoolean(false);
return result;
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:13,代码来源:IteratorOperations.cpp
注:本文中的RETURN_IF_EXCEPTION函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论