blob: 97b8c3470292285fe64c3f2b72845cf8208f65a5 [file] [log] [blame]
/*
* Copyright (c) 2016 Apple Inc. All rights reserved.
* Copyright (c) 2016 Canon Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
#include "config.h"
#include "FetchResponseBuiltins.h"
#if ENABLE(FETCH_API)
#include "WebCoreJSClientData.h"
#include <heap/HeapInlines.h>
#include <runtime/Executable.h>
#include <runtime/Intrinsic.h>
#include <runtime/JSCJSValueInlines.h>
#include <runtime/JSCellInlines.h>
#include <runtime/StructureInlines.h>
#include <runtime/VM.h>
namespace WebCore {
const JSC::ConstructAbility s_fetchResponseInitializeFetchResponseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseInitializeFetchResponseCodeLength = 1015;
static const JSC::Intrinsic s_fetchResponseInitializeFetchResponseCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseInitializeFetchResponseCode =
"(function (body, init)\n" \
"{\n" \
" \"use strict\";\n" \
" if (init === @undefined)\n" \
" init = { };\n" \
" else if (!@isObject(init))\n" \
" throw new @TypeError(\"Response init must be an object\");\n" \
" let status = (init.status !== @undefined) ? @toNumber(init.status) : 200;\n" \
" if (status < 200 || status > 599)\n" \
" throw new @RangeError(\"Status must be between 200 and 599\");\n" \
" let statusText = (init.statusText !== @undefined) ? init.statusText : \"OK\";\n" \
" this.@setStatus(status, statusText);\n" \
" if (init.headers !== @undefined)\n" \
" @fillFetchHeaders(this.headers, init.headers);\n" \
" if (body !== @undefined && body !== null) {\n" \
" if (status == 101 || status == 204 || status == 205 || status == 304)\n" \
" throw new @TypeError(\"Response cannot have a body with the given status\");\n" \
" let isBodyReadableStream = (@isObject(body) && !!body.@readableStreamController);\n" \
" if (isBodyReadableStream)\n" \
" this.@body = body;\n" \
" this.@initializeWith(body);\n" \
" }\n" \
" return this;\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseBodyUsedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseBodyUsedCodeLength = 247;
static const JSC::Intrinsic s_fetchResponseBodyUsedCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseBodyUsedCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" throw @makeGetterTypeError(\"Response\", \"bodyUsed\");\n" \
" if (this.@body)\n" \
" return @isReadableStreamDisturbed(this.@body);\n" \
" return @Response.prototype.@isDisturbed.@call(this);\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseBodyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseBodyCodeLength = 513;
static const JSC::Intrinsic s_fetchResponseBodyCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseBodyCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" throw @makeGetterTypeError(\"Response\", \"body\");\n" \
" if (!this.@body) {\n" \
" if (@Response.prototype.@isDisturbed.@call(this)) {\n" \
" this.@body = new @ReadableStream();\n" \
" new @ReadableStreamDefaultReader(this.@body);\n" \
" } else {\n" \
" var source = @Response.prototype.@createReadableStreamSource.@call(this);\n" \
" this.@body = source ? new @ReadableStream(source) : null;\n" \
" }\n" \
" }\n" \
" return this.@body;\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseCloneCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseCloneCodeLength = 794;
static const JSC::Intrinsic s_fetchResponseCloneCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseCloneCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" throw @makeThisTypeError(\"Response\", \"clone\");\n" \
" if (@Response.prototype.@isDisturbed.@call(this) || (this.@body && @isReadableStreamLocked(this.@body)))\n" \
" throw new @TypeError(\"Cannot clone a disturbed Response\");\n" \
" var cloned = @Response.prototype.@cloneForJS.@call(this);\n" \
" if (@Response.prototype.@isLoading.@call(this) && !this.@body) {\n" \
" var source = @Response.prototype.@createReadableStreamSource.@call(this);\n" \
" @assert(!!source);\n" \
" this.@body = new @ReadableStream(source);\n" \
" }\n" \
" if (this.@body) {\n" \
" var teedReadableStreams = @teeReadableStream(this.@body, true);\n" \
" this.@body = teedReadableStreams[0];\n" \
" cloned.@body = teedReadableStreams[1];\n" \
" }\n" \
" return cloned;\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseArrayBufferCodeLength = 336;
static const JSC::Intrinsic s_fetchResponseArrayBufferCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseArrayBufferCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" return @Promise.@reject(@makeThisTypeError(\"Response\", \"arrayBuffer\"));\n" \
" const arrayBufferConsumerType = 1;\n" \
" if (!this.@body)\n" \
" return @Response.prototype.@consume.@call(this, arrayBufferConsumerType);\n" \
" return @consumeStream(this, arrayBufferConsumerType);\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseBlobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseBlobCodeLength = 308;
static const JSC::Intrinsic s_fetchResponseBlobCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseBlobCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" return @Promise.@reject(@makeThisTypeError(\"Response\", \"blob\"));\n" \
" const blobConsumerType = 2;\n" \
" if (!this.@body)\n" \
" return @Response.prototype.@consume.@call(this, blobConsumerType);\n" \
" return @consumeStream(this, blobConsumerType);\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseFormDataCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseFormDataCodeLength = 181;
static const JSC::Intrinsic s_fetchResponseFormDataCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseFormDataCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" return @Promise.@reject(@makeThisTypeError(\"Response\", \"formData\"));\n" \
" return @Promise.@reject(\"Not implemented\");\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseJsonCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseJsonCodeLength = 308;
static const JSC::Intrinsic s_fetchResponseJsonCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseJsonCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" return @Promise.@reject(@makeThisTypeError(\"Response\", \"json\"));\n" \
" const jsonConsumerType = 3;\n" \
" if (!this.@body)\n" \
" return @Response.prototype.@consume.@call(this, jsonConsumerType);\n" \
" return @consumeStream(this, jsonConsumerType);\n" \
"})\n" \
;
const JSC::ConstructAbility s_fetchResponseTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_fetchResponseTextCodeLength = 308;
static const JSC::Intrinsic s_fetchResponseTextCodeIntrinsic = JSC::NoIntrinsic;
const char* s_fetchResponseTextCode =
"(function ()\n" \
"{\n" \
" if (!(this instanceof @Response))\n" \
" return @Promise.@reject(@makeThisTypeError(\"Response\", \"text\"));\n" \
" const textConsumerType = 4;\n" \
" if (!this.@body)\n" \
" return @Response.prototype.@consume.@call(this, textConsumerType);\n" \
" return @consumeStream(this, textConsumerType);\n" \
"})\n" \
;
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
{\
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
return clientData->builtinFunctions().fetchResponseBuiltins().codeName##Executable()->link(vm, clientData->builtinFunctions().fetchResponseBuiltins().codeName##Source(), Nullopt, s_##codeName##Intrinsic); \
}
WEBCORE_FOREACH_FETCHRESPONSE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
#undef DEFINE_BUILTIN_GENERATOR
} // namespace WebCore
#endif // ENABLE(FETCH_API)