ReadableStreamDefaultController.cpp [plain text]
#include "config.h"
#include "ReadableStreamDefaultController.h"
#if ENABLE(STREAMS_API)
#include "WebCoreJSClientData.h"
#include <JavaScriptCore/CatchScope.h>
#include <JavaScriptCore/HeapInlines.h>
#include <JavaScriptCore/IdentifierInlines.h>
#include <JavaScriptCore/JSObjectInlines.h>
namespace WebCore {
static inline JSC::JSValue readableStreamCallFunction(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList& arguments)
{
JSC::CallData callData;
auto callType = JSC::getCallData(lexicalGlobalObject.vm(), jsFunction, callData);
return call(&lexicalGlobalObject, jsFunction, callType, callData, thisValue, arguments);
}
JSC::JSValue ReadableStreamDefaultController::invoke(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& object, const char* propertyName, JSC::JSValue parameter)
{
JSC::VM& vm = lexicalGlobalObject.vm();
JSC::JSLockHolder lock(vm);
auto scope = DECLARE_THROW_SCOPE(vm);
auto function = object.get(&lexicalGlobalObject, JSC::Identifier::fromString(vm, propertyName));
RETURN_IF_EXCEPTION(scope, JSC::JSValue());
if (!function.isFunction(vm)) {
if (!function.isUndefined())
throwTypeError(&lexicalGlobalObject, scope, "ReadableStream trying to call a property that is not callable"_s);
return JSC::jsUndefined();
}
JSC::MarkedArgumentBuffer arguments;
arguments.append(parameter);
ASSERT(!arguments.hasOverflowed());
return readableStreamCallFunction(lexicalGlobalObject, function, &object, arguments);
}
}
#endif // ENABLE(STREAMS_API)