1/*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
3 * Copyright (c) 2017 Canon Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
29// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
30
31#include "config.h"
32#include "ReadableStreamBYOBReaderBuiltins.h"
33
34#if ENABLE(STREAMS_API)
35
36#include "WebCoreJSClientData.h"
37#include <JavaScriptCore/HeapInlines.h>
38#include <JavaScriptCore/IdentifierInlines.h>
39#include <JavaScriptCore/Intrinsic.h>
40#include <JavaScriptCore/JSCJSValueInlines.h>
41#include <JavaScriptCore/JSCellInlines.h>
42#include <JavaScriptCore/StructureInlines.h>
43#include <JavaScriptCore/VM.h>
44
45namespace WebCore {
46
47const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
48const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength = 574;
49static const JSC::Intrinsic s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
50const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode =
51 "(function (stream)\n" \
52 "{\n" \
53 " \"use strict\";\n" \
54 "\n" \
55 " if (!@isReadableStream(stream))\n" \
56 " @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableStream\");\n" \
57 " if (!@isReadableByteStreamController(@getByIdDirectPrivate(stream, \"readableStreamController\")))\n" \
58 " @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableByteStreamController\");\n" \
59 " if (@isReadableStreamLocked(stream))\n" \
60 " @throwTypeError(\"ReadableStream is locked\");\n" \
61 "\n" \
62 " @readableStreamReaderGenericInitialize(this, stream);\n" \
63 " @putByIdDirectPrivate(this, \"readIntoRequests\", []);\n" \
64 "\n" \
65 " return this;\n" \
66 "})\n" \
67;
68
69const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
70const int s_readableStreamBYOBReaderCancelCodeLength = 410;
71static const JSC::Intrinsic s_readableStreamBYOBReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
72const char* const s_readableStreamBYOBReaderCancelCode =
73 "(function (reason)\n" \
74 "{\n" \
75 " \"use strict\";\n" \
76 "\n" \
77 " if (!@isReadableStreamBYOBReader(this))\n" \
78 " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"cancel\"));\n" \
79 "\n" \
80 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
81 " return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
82 "\n" \
83 " return @readableStreamReaderGenericCancel(this, reason);\n" \
84 "})\n" \
85;
86
87const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
88const int s_readableStreamBYOBReaderReadCodeLength = 762;
89static const JSC::Intrinsic s_readableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic;
90const char* const s_readableStreamBYOBReaderReadCode =
91 "(function (view)\n" \
92 "{\n" \
93 " \"use strict\";\n" \
94 "\n" \
95 " if (!@isReadableStreamBYOBReader(this))\n" \
96 " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"read\"));\n" \
97 "\n" \
98 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
99 " return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
100 "\n" \
101 " if (!@isObject(view))\n" \
102 " return @Promise.@reject(@makeTypeError(\"Provided view is not an object\"));\n" \
103 "\n" \
104 " if (!@ArrayBuffer.@isView(view))\n" \
105 " return @Promise.@reject(@makeTypeError(\"Provided view is not an ArrayBufferView\"));\n" \
106 "\n" \
107 " if (view.byteLength === 0)\n" \
108 " return @Promise.@reject(@makeTypeError(\"Provided view cannot have a 0 byteLength\"));\n" \
109 "\n" \
110 " return @readableStreamBYOBReaderRead(this, view);\n" \
111 "})\n" \
112;
113
114const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
115const int s_readableStreamBYOBReaderReleaseLockCodeLength = 440;
116static const JSC::Intrinsic s_readableStreamBYOBReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
117const char* const s_readableStreamBYOBReaderReleaseLockCode =
118 "(function ()\n" \
119 "{\n" \
120 " \"use strict\";\n" \
121 "\n" \
122 " if (!@isReadableStreamBYOBReader(this))\n" \
123 " throw @makeThisTypeError(\"ReadableStreamBYOBReader\", \"releaseLock\");\n" \
124 "\n" \
125 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
126 " return;\n" \
127 "\n" \
128 " if (@getByIdDirectPrivate(this, \"readIntoRequests\").length)\n" \
129 " @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
130 "\n" \
131 " @readableStreamReaderGenericRelease(this);\n" \
132 "})\n" \
133;
134
135const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
136const int s_readableStreamBYOBReaderClosedCodeLength = 251;
137static const JSC::Intrinsic s_readableStreamBYOBReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
138const char* const s_readableStreamBYOBReaderClosedCode =
139 "(function ()\n" \
140 "{\n" \
141 " \"use strict\";\n" \
142 "\n" \
143 " if (!@isReadableStreamBYOBReader(this))\n" \
144 " return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamBYOBReader\", \"closed\"));\n" \
145 "\n" \
146 " return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
147 "})\n" \
148;
149
150
151#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
152JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
153{\
154 JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
155 return clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \
156}
157WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
158#undef DEFINE_BUILTIN_GENERATOR
159
160
161} // namespace WebCore
162
163#endif // ENABLE(STREAMS_API)
164