1/*
2 * Copyright (c) 2015 Canon Inc.
3 * Copyright (c) 2016 Apple Inc. All rights reserved.
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 "ReadableStreamDefaultReaderBuiltins.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_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
48const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength = 382;
49static const JSC::Intrinsic s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
50const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode =
51 "(function (stream)\n" \
52 "{\n" \
53 " \"use strict\";\n" \
54 "\n" \
55 " if (!@isReadableStream(stream))\n" \
56 " @throwTypeError(\"ReadableStreamDefaultReader needs a ReadableStream\");\n" \
57 " if (@isReadableStreamLocked(stream))\n" \
58 " @throwTypeError(\"ReadableStream is locked\");\n" \
59 "\n" \
60 " @readableStreamReaderGenericInitialize(this, stream);\n" \
61 " @putByIdDirectPrivate(this, \"readRequests\", []);\n" \
62 "\n" \
63 " return this;\n" \
64 "})\n" \
65;
66
67const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
68const int s_readableStreamDefaultReaderCancelCodeLength = 416;
69static const JSC::Intrinsic s_readableStreamDefaultReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
70const char* const s_readableStreamDefaultReaderCancelCode =
71 "(function (reason)\n" \
72 "{\n" \
73 " \"use strict\";\n" \
74 "\n" \
75 " if (!@isReadableStreamDefaultReader(this))\n" \
76 " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"cancel\"));\n" \
77 "\n" \
78 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
79 " return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
80 "\n" \
81 " return @readableStreamReaderGenericCancel(this, reason);\n" \
82 "})\n" \
83;
84
85const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
86const int s_readableStreamDefaultReaderReadCodeLength = 395;
87static const JSC::Intrinsic s_readableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic;
88const char* const s_readableStreamDefaultReaderReadCode =
89 "(function ()\n" \
90 "{\n" \
91 " \"use strict\";\n" \
92 "\n" \
93 " if (!@isReadableStreamDefaultReader(this))\n" \
94 " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"read\"));\n" \
95 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
96 " return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
97 "\n" \
98 " return @readableStreamDefaultReaderRead(this);\n" \
99 "})\n" \
100;
101
102const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
103const int s_readableStreamDefaultReaderReleaseLockCodeLength = 442;
104static const JSC::Intrinsic s_readableStreamDefaultReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
105const char* const s_readableStreamDefaultReaderReleaseLockCode =
106 "(function ()\n" \
107 "{\n" \
108 " \"use strict\";\n" \
109 "\n" \
110 " if (!@isReadableStreamDefaultReader(this))\n" \
111 " throw @makeThisTypeError(\"ReadableStreamDefaultReader\", \"releaseLock\");\n" \
112 "\n" \
113 " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
114 " return;\n" \
115 "\n" \
116 " if (@getByIdDirectPrivate(this, \"readRequests\").length)\n" \
117 " @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
118 "\n" \
119 " @readableStreamReaderGenericRelease(this);\n" \
120 "})\n" \
121;
122
123const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
124const int s_readableStreamDefaultReaderClosedCodeLength = 257;
125static const JSC::Intrinsic s_readableStreamDefaultReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
126const char* const s_readableStreamDefaultReaderClosedCode =
127 "(function ()\n" \
128 "{\n" \
129 " \"use strict\";\n" \
130 "\n" \
131 " if (!@isReadableStreamDefaultReader(this))\n" \
132 " return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamDefaultReader\", \"closed\"));\n" \
133 "\n" \
134 " return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
135 "})\n" \
136;
137
138
139#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
140JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
141{\
142 JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
143 return clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \
144}
145WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
146#undef DEFINE_BUILTIN_GENERATOR
147
148
149} // namespace WebCore
150
151#endif // ENABLE(STREAMS_API)
152