本文整理汇总了C++中ExecState::argument方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::argument方法的具体用法?C++ ExecState::argument怎么用?C++ ExecState::argument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::argument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
// Custom functions
JSValue JSXMLHttpRequest::open(ExecState& state)
{
if (state.argumentCount() < 2)
return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
const URL& url = wrapped().scriptExecutionContext()->completeURL(state.uncheckedArgument(1).toString(&state)->value(&state));
String method = state.uncheckedArgument(0).toString(&state)->value(&state);
ExceptionCode ec = 0;
if (state.argumentCount() >= 3) {
bool async = state.uncheckedArgument(2).toBoolean(&state);
if (!state.argument(3).isUndefined()) {
String user = valueToStringWithNullCheck(&state, state.uncheckedArgument(3));
if (!state.argument(4).isUndefined()) {
String password = valueToStringWithNullCheck(&state, state.uncheckedArgument(4));
wrapped().open(method, url, async, user, password, ec);
} else
wrapped().open(method, url, async, user, ec);
} else
wrapped().open(method, url, async, ec);
} else
wrapped().open(method, url, ec);
setDOMException(&state, ec);
return jsUndefined();
}
示例2: setParameter
JSValue JSXSLTProcessor::setParameter(ExecState& state)
{
if (state.argument(1).isUndefinedOrNull() || state.argument(2).isUndefinedOrNull())
return jsUndefined(); // Throw exception?
String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
String value = state.uncheckedArgument(2).toString(&state)->value(&state);
wrapped().setParameter(namespaceURI, localName, value);
return jsUndefined();
}
示例3: setSelectionRange
JSValue JSHTMLInputElement::setSelectionRange(ExecState& state)
{
HTMLInputElement& input = wrapped();
if (!input.canHaveSelection())
return throwTypeError(&state);
int start = state.argument(0).toInt32(&state);
int end = state.argument(1).toInt32(&state);
String direction = state.argument(2).toString(&state)->value(&state);
input.setSelectionRange(start, end, direction);
return jsUndefined();
}
示例4: send
JSValue JSXMLHttpRequest::send(ExecState& state)
{
InspectorInstrumentation::willSendXMLHttpRequest(wrapped().scriptExecutionContext(), wrapped().url());
ExceptionCode ec = 0;
JSValue val = state.argument(0);
if (val.isUndefinedOrNull())
wrapped().send(ec);
else if (val.inherits(JSDocument::info()))
wrapped().send(JSDocument::toWrapped(val), ec);
else if (val.inherits(JSBlob::info()))
wrapped().send(JSBlob::toWrapped(val), ec);
else if (val.inherits(JSDOMFormData::info()))
wrapped().send(JSDOMFormData::toWrapped(val), ec);
else if (val.inherits(JSArrayBuffer::info()))
wrapped().send(toArrayBuffer(val), ec);
else if (val.inherits(JSArrayBufferView::info())) {
RefPtr<ArrayBufferView> view = toArrayBufferView(val);
wrapped().send(view.get(), ec);
} else
wrapped().send(val.toString(&state)->value(&state), ec);
// FIXME: This should probably use ShadowChicken so that we get the right frame even when it did
// a tail call.
// https://bugs.webkit.org/show_bug.cgi?id=155688
SendFunctor functor;
state.iterate(functor);
wrapped().setLastSendLineAndColumnNumber(functor.line(), functor.column());
wrapped().setLastSendURL(functor.url());
setDOMException(&state, ec);
return jsUndefined();
}
示例5: documentWrite
static inline void documentWrite(ExecState& state, JSHTMLDocument* thisDocument, NewlineRequirement addNewline)
{
HTMLDocument* document = &thisDocument->wrapped();
// DOM only specifies single string argument, but browsers allow multiple or no arguments.
size_t size = state.argumentCount();
String firstString = state.argument(0).toString(&state)->value(&state);
SegmentedString segmentedString = firstString;
if (size != 1) {
if (!size)
segmentedString.clear();
else {
for (size_t i = 1; i < size; ++i) {
String subsequentString = state.uncheckedArgument(i).toString(&state)->value(&state);
segmentedString.append(SegmentedString(subsequentString));
}
}
}
if (addNewline)
segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));
Document* activeDocument = findCallingDocument(state);
document->write(segmentedString, activeDocument);
}
示例6: exportKey
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));
CryptoKeyFormat keyFormat;
auto success = cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat);
ASSERT(scope.exception() || success);
if (!success)
return jsUndefined();
RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(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(nullptr);
};
WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
RETURN_IF_EXCEPTION(scope, JSValue());
return promise;
}
示例7: showContextMenu
JSValue JSInspectorFrontendHost::showContextMenu(ExecState& state)
{
#if ENABLE(CONTEXT_MENUS)
if (state.argumentCount() < 2)
return jsUndefined();
Event* event = JSEvent::toWrapped(state.argument(0));
JSArray* array = asArray(state.argument(1));
ContextMenu menu;
populateContextMenuItems(&state, array, menu);
wrapped().showContextMenu(event, menu.items());
#else
UNUSED_PARAM(state);
#endif
return jsUndefined();
}
示例8: initDeviceMotionEvent
JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState& state)
{
const String type = state.argument(0).toString(&state)->value(&state);
bool bubbles = state.argument(1).toBoolean(&state);
bool cancelable = state.argument(2).toBoolean(&state);
// If any of the parameters are null or undefined, mark them as not provided.
// Otherwise, use the standard JavaScript conversion.
RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(state.argument(3), state);
if (state.hadException())
return jsUndefined();
RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(state.argument(4), state);
if (state.hadException())
return jsUndefined();
RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(state.argument(5), state);
if (state.hadException())
return jsUndefined();
bool intervalProvided = !state.argument(6).isUndefinedOrNull();
double interval = state.argument(6).toNumber(&state);
RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
return jsUndefined();
}
示例9: open
JSValue JSDOMWindow::open(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
String urlString = convert<IDLNullable<IDLUSVString>>(state, state.argument(0));
RETURN_IF_EXCEPTION(scope, JSValue());
JSValue targetValue = state.argument(1);
AtomicString target = targetValue.isUndefinedOrNull() ? AtomicString("_blank", AtomicString::ConstructFromLiteral) : targetValue.toString(&state)->toAtomicString(&state);
RETURN_IF_EXCEPTION(scope, JSValue());
String windowFeaturesString = convert<IDLNullable<IDLDOMString>>(state, state.argument(2));
RETURN_IF_EXCEPTION(scope, JSValue());
RefPtr<DOMWindow> openedWindow = wrapped().open(urlString, target, windowFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state));
if (!openedWindow)
return jsNull();
return toJS(&state, openedWindow.get());
}
示例10: dialogCreated
inline void DialogHandler::dialogCreated(DOMWindow* dialog)
{
m_frame = dialog->frame();
// FIXME: This looks like a leak between the normal world and an isolated
// world if dialogArguments comes from an isolated world.
JSDOMWindow* globalObject = toJSDOMWindow(m_frame.get(), normalWorld(m_exec->globalData()));
if (JSValue dialogArguments = m_exec->argument(1))
globalObject->putDirect(m_exec->globalData(), Identifier(m_exec, "dialogArguments"), dialogArguments);
}
示例11: removeParameter
JSValue JSXSLTProcessor::removeParameter(ExecState& state)
{
if (state.argument(1).isUndefinedOrNull())
return jsUndefined();
String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
wrapped().removeParameter(namespaceURI, localName);
return jsUndefined();
}
示例12: setInterval
JSValue JSWorkerGlobalScope::setInterval(ExecState& state)
{
std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
if (state.hadException())
return jsUndefined();
if (!action)
return jsNumber(0);
int delay = state.argument(1).toInt32(&state);
return jsNumber(wrapped().setInterval(WTFMove(action), delay));
}
示例13: generateKey
JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (state.argumentCount() < 1)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
ASSERT(scope.exception() || algorithm);
if (!algorithm)
return jsUndefined();
auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
ASSERT(scope.exception() || parameters);
if (!parameters)
return jsUndefined();
bool extractable = false;
if (state.argumentCount() >= 2) {
extractable = state.uncheckedArgument(1).toBoolean(&state);
RETURN_IF_EXCEPTION(scope, JSValue());
}
CryptoKeyUsageBitmap keyUsages = 0;
if (state.argumentCount() >= 3) {
auto success = cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages);
ASSERT(scope.exception() || success);
if (!success)
return jsUndefined();
}
RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
auto promise = wrapper->promise();
auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
ASSERT(key || keyPair);
ASSERT(!key || !keyPair);
if (key)
wrapper->resolve(key);
else
wrapper->resolve(keyPair);
};
auto failureCallback = [wrapper]() mutable {
wrapper->reject(nullptr);
};
auto result = algorithm->generateKey(*parameters, extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback), *scriptExecutionContextFromExecState(&state));
if (result.hasException()) {
propagateException(state, scope, result.releaseException());
return { };
}
return promise;
}
示例14: if
RefPtr<ReadableJSStream> ReadableJSStream::create(ExecState& state, ScriptExecutionContext& scriptExecutionContext)
{
// FIXME: We should consider reducing the binding code herei (using Dictionary/regular binding constructor and/or improving the IDL generator).
JSObject* jsSource;
JSValue value = state.argument(0);
if (value.isObject())
jsSource = value.getObject();
else if (!value.isUndefined()) {
throwVMError(&state, createTypeError(&state, ASCIILiteral("First argument, if any, should be an object")));
return nullptr;
} else
jsSource = JSFinalObject::create(state.vm(), JSFinalObject::createStructure(state.vm(), state.callee()->globalObject(), jsNull(), 1));
double highWaterMark = 1;
JSFunction* sizeFunction = nullptr;
value = state.argument(1);
if (value.isObject()) {
JSObject& strategyObject = *value.getObject();
highWaterMark = normalizeHighWaterMark(state, strategyObject);
if (state.hadException())
return nullptr;
if (!(sizeFunction = jsDynamicCast<JSFunction*>(getPropertyFromObject(state, strategyObject, "size")))) {
if (!state.hadException())
throwVMError(&state, createTypeError(&state, ASCIILiteral("size parameter should be a function")));
return nullptr;
}
} else if (!value.isUndefined()) {
throwVMError(&state, createTypeError(&state, ASCIILiteral("Second argument, if any, should be an object")));
return nullptr;
}
RefPtr<ReadableJSStream> readableStream = adoptRef(*new ReadableJSStream(scriptExecutionContext, state, jsSource, highWaterMark, sizeFunction));
readableStream->doStart(state);
if (state.hadException())
return nullptr;
return readableStream;
}
示例15: showModalDialog
JSValue JSDOMWindow::showModalDialog(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (UNLIKELY(state.argumentCount() < 1))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
String urlString = convert<IDLNullable<IDLDOMString>>(state, state.argument(0));
RETURN_IF_EXCEPTION(scope, JSValue());
String dialogFeaturesString = convert<IDLNullable<IDLDOMString>>(state, state.argument(2));
RETURN_IF_EXCEPTION(scope, JSValue());
DialogHandler handler(state);
wrapped().showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state), [&handler](DOMWindow& dialog) {
handler.dialogCreated(dialog);
});
return handler.returnValue();
}