| 1 | /* | 
|---|
| 2 | * Copyright (c) 2016 Apple Inc. All rights reserved. | 
|---|
| 3 | * Copyright (c) 2016 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 "ReadableByteStreamControllerBuiltins.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 |  | 
|---|
| 45 | namespace WebCore { | 
|---|
| 46 |  | 
|---|
| 47 | const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 48 | const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 366; | 
|---|
| 49 | static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 50 | const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = | 
|---|
| 51 | "(function (stream, underlyingByteSource, highWaterMark)\n"\ | 
|---|
| 52 | "{\n"\ | 
|---|
| 53 | "    \"use strict\";\n"\ | 
|---|
| 54 | "\n"\ | 
|---|
| 55 | "    if (arguments.length !== 4 && arguments[3] !== @isReadableStream)\n"\ | 
|---|
| 56 | "        @throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");\n"\ | 
|---|
| 57 | "\n"\ | 
|---|
| 58 | "    return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);\n"\ | 
|---|
| 59 | "})\n"\ | 
|---|
| 60 | ; | 
|---|
| 61 |  | 
|---|
| 62 | const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 63 | const int s_readableByteStreamControllerEnqueueCodeLength = 739; | 
|---|
| 64 | static const JSC::Intrinsic s_readableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 65 | const char* const s_readableByteStreamControllerEnqueueCode = | 
|---|
| 66 | "(function (chunk)\n"\ | 
|---|
| 67 | "{\n"\ | 
|---|
| 68 | "    \"use strict\";\n"\ | 
|---|
| 69 | "\n"\ | 
|---|
| 70 | "    if (!@isReadableByteStreamController(this))\n"\ | 
|---|
| 71 | "        throw @makeThisTypeError(\"ReadableByteStreamController\", \"enqueue\");\n"\ | 
|---|
| 72 | "\n"\ | 
|---|
| 73 | "    if (@getByIdDirectPrivate(this, \"closeRequested\"))\n"\ | 
|---|
| 74 | "        @throwTypeError(\"ReadableByteStreamController is requested to close\");\n"\ | 
|---|
| 75 | "\n"\ | 
|---|
| 76 | "    if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n"\ | 
|---|
| 77 | "        @throwTypeError(\"ReadableStream is not readable\");\n"\ | 
|---|
| 78 | "\n"\ | 
|---|
| 79 | "    if (!@isObject(chunk))\n"\ | 
|---|
| 80 | "        @throwTypeError(\"Provided chunk is not an object\");\n"\ | 
|---|
| 81 | "\n"\ | 
|---|
| 82 | "    if (!@ArrayBuffer.@isView(chunk))\n"\ | 
|---|
| 83 | "        @throwTypeError(\"Provided chunk is not an ArrayBuffer view\");\n"\ | 
|---|
| 84 | "\n"\ | 
|---|
| 85 | "    return @readableByteStreamControllerEnqueue(this, chunk);\n"\ | 
|---|
| 86 | "})\n"\ | 
|---|
| 87 | ; | 
|---|
| 88 |  | 
|---|
| 89 | const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 90 | const int s_readableByteStreamControllerErrorCodeLength = 396; | 
|---|
| 91 | static const JSC::Intrinsic s_readableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 92 | const char* const s_readableByteStreamControllerErrorCode = | 
|---|
| 93 | "(function (error)\n"\ | 
|---|
| 94 | "{\n"\ | 
|---|
| 95 | "    \"use strict\";\n"\ | 
|---|
| 96 | "\n"\ | 
|---|
| 97 | "    if (!@isReadableByteStreamController(this))\n"\ | 
|---|
| 98 | "        throw @makeThisTypeError(\"ReadableByteStreamController\", \"error\");\n"\ | 
|---|
| 99 | "\n"\ | 
|---|
| 100 | "    if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n"\ | 
|---|
| 101 | "        @throwTypeError(\"ReadableStream is not readable\");\n"\ | 
|---|
| 102 | "\n"\ | 
|---|
| 103 | "    @readableByteStreamControllerError(this, error);\n"\ | 
|---|
| 104 | "})\n"\ | 
|---|
| 105 | ; | 
|---|
| 106 |  | 
|---|
| 107 | const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 108 | const int s_readableByteStreamControllerCloseCodeLength = 501; | 
|---|
| 109 | static const JSC::Intrinsic s_readableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 110 | const char* const s_readableByteStreamControllerCloseCode = | 
|---|
| 111 | "(function ()\n"\ | 
|---|
| 112 | "{\n"\ | 
|---|
| 113 | "    \"use strict\";\n"\ | 
|---|
| 114 | "\n"\ | 
|---|
| 115 | "    if (!@isReadableByteStreamController(this))\n"\ | 
|---|
| 116 | "        throw @makeThisTypeError(\"ReadableByteStreamController\", \"close\");\n"\ | 
|---|
| 117 | "\n"\ | 
|---|
| 118 | "    if (@getByIdDirectPrivate(this, \"closeRequested\"))\n"\ | 
|---|
| 119 | "        @throwTypeError(\"Close has already been requested\");\n"\ | 
|---|
| 120 | "\n"\ | 
|---|
| 121 | "    if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n"\ | 
|---|
| 122 | "        @throwTypeError(\"ReadableStream is not readable\");\n"\ | 
|---|
| 123 | "\n"\ | 
|---|
| 124 | "    @readableByteStreamControllerClose(this);\n"\ | 
|---|
| 125 | "})\n"\ | 
|---|
| 126 | ; | 
|---|
| 127 |  | 
|---|
| 128 | const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 129 | const int s_readableByteStreamControllerByobRequestCodeLength = 759; | 
|---|
| 130 | static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 131 | const char* const s_readableByteStreamControllerByobRequestCode = | 
|---|
| 132 | "(function ()\n"\ | 
|---|
| 133 | "{\n"\ | 
|---|
| 134 | "    \"use strict\";\n"\ | 
|---|
| 135 | "\n"\ | 
|---|
| 136 | "    if (!@isReadableByteStreamController(this))\n"\ | 
|---|
| 137 | "        throw @makeGetterTypeError(\"ReadableByteStreamController\", \"byobRequest\");\n"\ | 
|---|
| 138 | "\n"\ | 
|---|
| 139 | "    if (@getByIdDirectPrivate(this, \"byobRequest\") === @undefined && @getByIdDirectPrivate(this, \"pendingPullIntos\").length) {\n"\ | 
|---|
| 140 | "        const firstDescriptor = @getByIdDirectPrivate(this, \"pendingPullIntos\")[0];\n"\ | 
|---|
| 141 | "        const view = new @Uint8Array(firstDescriptor.buffer,\n"\ | 
|---|
| 142 | "            firstDescriptor.byteOffset + firstDescriptor.bytesFilled,\n"\ | 
|---|
| 143 | "            firstDescriptor.byteLength - firstDescriptor.bytesFilled);\n"\ | 
|---|
| 144 | "        @putByIdDirectPrivate(this, \"byobRequest\", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));\n"\ | 
|---|
| 145 | "    }\n"\ | 
|---|
| 146 | "\n"\ | 
|---|
| 147 | "    return @getByIdDirectPrivate(this, \"byobRequest\");\n"\ | 
|---|
| 148 | "})\n"\ | 
|---|
| 149 | ; | 
|---|
| 150 |  | 
|---|
| 151 | const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; | 
|---|
| 152 | const int s_readableByteStreamControllerDesiredSizeCodeLength = 231; | 
|---|
| 153 | static const JSC::Intrinsic s_readableByteStreamControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; | 
|---|
| 154 | const char* const s_readableByteStreamControllerDesiredSizeCode = | 
|---|
| 155 | "(function ()\n"\ | 
|---|
| 156 | "{\n"\ | 
|---|
| 157 | "    \"use strict\";\n"\ | 
|---|
| 158 | "\n"\ | 
|---|
| 159 | "    if (!@isReadableByteStreamController(this))\n"\ | 
|---|
| 160 | "        throw @makeGetterTypeError(\"ReadableByteStreamController\", \"desiredSize\");\n"\ | 
|---|
| 161 | "\n"\ | 
|---|
| 162 | "    return @readableByteStreamControllerGetDesiredSize(this);\n"\ | 
|---|
| 163 | "})\n"\ | 
|---|
| 164 | ; | 
|---|
| 165 |  | 
|---|
| 166 |  | 
|---|
| 167 | #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ | 
|---|
| 168 | JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ | 
|---|
| 169 | {\ | 
|---|
| 170 | JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \ | 
|---|
| 171 | return clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \ | 
|---|
| 172 | } | 
|---|
| 173 | WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) | 
|---|
| 174 | #undef DEFINE_BUILTIN_GENERATOR | 
|---|
| 175 |  | 
|---|
| 176 |  | 
|---|
| 177 | } // namespace WebCore | 
|---|
| 178 |  | 
|---|
| 179 | #endif // ENABLE(STREAMS_API) | 
|---|
| 180 |  | 
|---|