| 1 | /* |
| 2 | * Copyright (c) 2015, 2016 Ericsson AB. All rights reserved. |
| 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 "RTCPeerConnectionInternalsBuiltins.h" |
| 33 | |
| 34 | #if ENABLE(WEB_RTC) |
| 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_rtcPeerConnectionInternalsEnqueueOperationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
| 48 | const int s_rtcPeerConnectionInternalsEnqueueOperationCodeLength = 511; |
| 49 | static const JSC::Intrinsic s_rtcPeerConnectionInternalsEnqueueOperationCodeIntrinsic = JSC::NoIntrinsic; |
| 50 | const char* const s_rtcPeerConnectionInternalsEnqueueOperationCode = |
| 51 | "(function (peerConnection, operation)\n" \ |
| 52 | "{\n" \ |
| 53 | " \"use strict\";\n" \ |
| 54 | "\n" \ |
| 55 | " const operations = @getByIdDirectPrivate(peerConnection, \"operations\");\n" \ |
| 56 | "\n" \ |
| 57 | " function runNext() {\n" \ |
| 58 | " operations.@shift();\n" \ |
| 59 | " if (operations.length)\n" \ |
| 60 | " operations[0]();\n" \ |
| 61 | " };\n" \ |
| 62 | "\n" \ |
| 63 | " return new @Promise(function (resolve, reject) {\n" \ |
| 64 | " operations.@push(function() {\n" \ |
| 65 | " operation().@then(resolve, reject).@then(runNext, runNext);\n" \ |
| 66 | " });\n" \ |
| 67 | "\n" \ |
| 68 | " if (operations.length === 1)\n" \ |
| 69 | " operations[0]();\n" \ |
| 70 | " });\n" \ |
| 71 | "})\n" \ |
| 72 | ; |
| 73 | |
| 74 | const JSC::ConstructAbility s_rtcPeerConnectionInternalsObjectOverloadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
| 75 | const int s_rtcPeerConnectionInternalsObjectOverloadCodeLength = 813; |
| 76 | static const JSC::Intrinsic s_rtcPeerConnectionInternalsObjectOverloadCodeIntrinsic = JSC::NoIntrinsic; |
| 77 | const char* const s_rtcPeerConnectionInternalsObjectOverloadCode = |
| 78 | "(function (objectArg, functionName, objectInfo, promiseMode)\n" \ |
| 79 | "{\n" \ |
| 80 | " \"use strict\";\n" \ |
| 81 | "\n" \ |
| 82 | " let objectArgOk = false;\n" \ |
| 83 | "\n" \ |
| 84 | " const hasMatchingType = objectArg instanceof objectInfo.constructor;\n" \ |
| 85 | " if (hasMatchingType)\n" \ |
| 86 | " objectArgOk = true;\n" \ |
| 87 | " else if (objectArg == null && objectInfo.defaultsToNull) {\n" \ |
| 88 | " objectArgOk = true;\n" \ |
| 89 | " objectArg = null;\n" \ |
| 90 | " } else if (objectInfo.maybeDictionary) {\n" \ |
| 91 | " try {\n" \ |
| 92 | " objectArg = new objectInfo.constructor(objectArg);\n" \ |
| 93 | " objectArgOk = true;\n" \ |
| 94 | " } catch (e) {\n" \ |
| 95 | " objectArgOk = false;\n" \ |
| 96 | " }\n" \ |
| 97 | " }\n" \ |
| 98 | "\n" \ |
| 99 | " if (!objectArgOk)\n" \ |
| 100 | " return @Promise.@reject(@makeTypeError(`Argument 1 ('${objectInfo.argName}') to RTCPeerConnection.${functionName} must be an instance of ${objectInfo.argType}`));\n" \ |
| 101 | "\n" \ |
| 102 | " return promiseMode(objectArg);\n" \ |
| 103 | "})\n" \ |
| 104 | ; |
| 105 | |
| 106 | const JSC::ConstructAbility s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
| 107 | const int s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeLength = 134; |
| 108 | static const JSC::Intrinsic s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeIntrinsic = JSC::NoIntrinsic; |
| 109 | const char* const s_rtcPeerConnectionInternalsIsRTCPeerConnectionCode = |
| 110 | "(function (connection)\n" \ |
| 111 | "{\n" \ |
| 112 | " \"use strict\";\n" \ |
| 113 | "\n" \ |
| 114 | " return @isObject(connection) && !!@getByIdDirectPrivate(connection, \"operations\");\n" \ |
| 115 | "})\n" \ |
| 116 | ; |
| 117 | |
| 118 | |
| 119 | #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
| 120 | JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ |
| 121 | {\ |
| 122 | JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \ |
| 123 | return clientData->builtinFunctions().rtcPeerConnectionInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().rtcPeerConnectionInternalsBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \ |
| 124 | } |
| 125 | WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) |
| 126 | #undef DEFINE_BUILTIN_GENERATOR |
| 127 | |
| 128 | |
| 129 | } // namespace WebCore |
| 130 | |
| 131 | #endif // ENABLE(WEB_RTC) |
| 132 | |