| 1 | /* |
| 2 | * Copyright (c) 2016 Apple Inc. All rights reserved. |
| 3 | * Copyright (c) 2017 Apple 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 | #pragma once |
| 32 | |
| 33 | #include <JavaScriptCore/BuiltinUtils.h> |
| 34 | #include <JavaScriptCore/Identifier.h> |
| 35 | #include <JavaScriptCore/JSFunction.h> |
| 36 | #include <JavaScriptCore/UnlinkedFunctionExecutable.h> |
| 37 | |
| 38 | namespace JSC { |
| 39 | class FunctionExecutable; |
| 40 | } |
| 41 | |
| 42 | namespace WebCore { |
| 43 | |
| 44 | /* JSDOMBindingInternals */ |
| 45 | extern const char* const s_jsDOMBindingInternalsMapLikeForEachCode; |
| 46 | extern const int s_jsDOMBindingInternalsMapLikeForEachCodeLength; |
| 47 | extern const JSC::ConstructAbility s_jsDOMBindingInternalsMapLikeForEachCodeConstructAbility; |
| 48 | |
| 49 | #define WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_DATA(macro) \ |
| 50 | macro(mapLikeForEach, jsDOMBindingInternalsMapLikeForEach, 1) \ |
| 51 | |
| 52 | #define WEBCORE_BUILTIN_JSDOMBINDINGINTERNALS_MAPLIKEFOREACH 1 |
| 53 | |
| 54 | #define WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(macro) \ |
| 55 | macro(jsDOMBindingInternalsMapLikeForEachCode, mapLikeForEach, static_cast<const char*>(nullptr), s_jsDOMBindingInternalsMapLikeForEachCodeLength) \ |
| 56 | |
| 57 | #define WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ |
| 58 | macro(mapLikeForEach) \ |
| 59 | |
| 60 | #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
| 61 | JSC::FunctionExecutable* codeName##Generator(JSC::VM&); |
| 62 | |
| 63 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) |
| 64 | #undef DECLARE_BUILTIN_GENERATOR |
| 65 | |
| 66 | class JSDOMBindingInternalsBuiltinsWrapper : private JSC::WeakHandleOwner { |
| 67 | public: |
| 68 | explicit JSDOMBindingInternalsBuiltinsWrapper(JSC::VM* vm) |
| 69 | : m_vm(*vm) |
| 70 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) |
| 71 | #define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) |
| 72 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) |
| 73 | #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | #define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
| 78 | JSC::UnlinkedFunctionExecutable* name##Executable(); \ |
| 79 | const JSC::SourceCode& name##Source() const { return m_##name##Source; } |
| 80 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) |
| 81 | #undef EXPOSE_BUILTIN_EXECUTABLES |
| 82 | |
| 83 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) |
| 84 | |
| 85 | void exportNames(); |
| 86 | |
| 87 | private: |
| 88 | JSC::VM& m_vm; |
| 89 | |
| 90 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) |
| 91 | |
| 92 | #define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \ |
| 93 | JSC::SourceCode m_##name##Source;\ |
| 94 | JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable; |
| 95 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) |
| 96 | #undef DECLARE_BUILTIN_SOURCE_MEMBERS |
| 97 | |
| 98 | }; |
| 99 | |
| 100 | #define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
| 101 | inline JSC::UnlinkedFunctionExecutable* JSDOMBindingInternalsBuiltinsWrapper::name##Executable() \ |
| 102 | {\ |
| 103 | if (!m_##name##Executable) {\ |
| 104 | JSC::Identifier executableName = functionName##PublicName();\ |
| 105 | if (overriddenName)\ |
| 106 | executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\ |
| 107 | m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\ |
| 108 | }\ |
| 109 | return m_##name##Executable.get();\ |
| 110 | } |
| 111 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) |
| 112 | #undef DEFINE_BUILTIN_EXECUTABLES |
| 113 | |
| 114 | inline void JSDOMBindingInternalsBuiltinsWrapper::exportNames() |
| 115 | { |
| 116 | #define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); |
| 117 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) |
| 118 | #undef EXPORT_FUNCTION_NAME |
| 119 | } |
| 120 | |
| 121 | class JSDOMBindingInternalsBuiltinFunctions { |
| 122 | public: |
| 123 | explicit JSDOMBindingInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { } |
| 124 | |
| 125 | void init(JSC::JSGlobalObject&); |
| 126 | void visit(JSC::SlotVisitor&); |
| 127 | |
| 128 | public: |
| 129 | JSC::VM& m_vm; |
| 130 | |
| 131 | #define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \ |
| 132 | JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function; |
| 133 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS) |
| 134 | #undef DECLARE_BUILTIN_SOURCE_MEMBERS |
| 135 | }; |
| 136 | |
| 137 | inline void JSDOMBindingInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject) |
| 138 | { |
| 139 | #define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\ |
| 140 | m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject)); |
| 141 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION) |
| 142 | #undef EXPORT_FUNCTION |
| 143 | } |
| 144 | |
| 145 | inline void JSDOMBindingInternalsBuiltinFunctions::visit(JSC::SlotVisitor& visitor) |
| 146 | { |
| 147 | #define VISIT_FUNCTION(name) visitor.append(m_##name##Function); |
| 148 | WEBCORE_FOREACH_JSDOMBINDINGINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION) |
| 149 | #undef VISIT_FUNCTION |
| 150 | } |
| 151 | |
| 152 | |
| 153 | } // namespace WebCore |
| 154 | |