1 | /* |
2 | * Copyright (c) 2015 Canon Inc. |
3 | * Copyright (c) 2015 Igalia |
4 | * Copyright (c) 2016 Apple Inc. All rights reserved. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
19 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | * THE POSSIBILITY OF SUCH DAMAGE. |
26 | * |
27 | */ |
28 | |
29 | // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for |
30 | // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py |
31 | |
32 | #pragma once |
33 | |
34 | #if ENABLE(STREAMS_API) |
35 | |
36 | #include <JavaScriptCore/BuiltinUtils.h> |
37 | #include <JavaScriptCore/Identifier.h> |
38 | #include <JavaScriptCore/JSFunction.h> |
39 | #include <JavaScriptCore/UnlinkedFunctionExecutable.h> |
40 | |
41 | namespace JSC { |
42 | class FunctionExecutable; |
43 | } |
44 | |
45 | namespace WebCore { |
46 | |
47 | /* WritableStream */ |
48 | extern const char* const s_writableStreamInitializeWritableStreamCode; |
49 | extern const int s_writableStreamInitializeWritableStreamCodeLength; |
50 | extern const JSC::ConstructAbility s_writableStreamInitializeWritableStreamCodeConstructAbility; |
51 | extern const char* const s_writableStreamAbortCode; |
52 | extern const int s_writableStreamAbortCodeLength; |
53 | extern const JSC::ConstructAbility s_writableStreamAbortCodeConstructAbility; |
54 | extern const char* const s_writableStreamCloseCode; |
55 | extern const int s_writableStreamCloseCodeLength; |
56 | extern const JSC::ConstructAbility s_writableStreamCloseCodeConstructAbility; |
57 | extern const char* const s_writableStreamWriteCode; |
58 | extern const int s_writableStreamWriteCodeLength; |
59 | extern const JSC::ConstructAbility s_writableStreamWriteCodeConstructAbility; |
60 | extern const char* const s_writableStreamClosedCode; |
61 | extern const int s_writableStreamClosedCodeLength; |
62 | extern const JSC::ConstructAbility s_writableStreamClosedCodeConstructAbility; |
63 | extern const char* const s_writableStreamReadyCode; |
64 | extern const int s_writableStreamReadyCodeLength; |
65 | extern const JSC::ConstructAbility s_writableStreamReadyCodeConstructAbility; |
66 | extern const char* const s_writableStreamStateCode; |
67 | extern const int s_writableStreamStateCodeLength; |
68 | extern const JSC::ConstructAbility s_writableStreamStateCodeConstructAbility; |
69 | |
70 | #define WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_DATA(macro) \ |
71 | macro(initializeWritableStream, writableStreamInitializeWritableStream, 2) \ |
72 | macro(abort, writableStreamAbort, 1) \ |
73 | macro(close, writableStreamClose, 0) \ |
74 | macro(write, writableStreamWrite, 1) \ |
75 | macro(closed, writableStreamClosed, 0) \ |
76 | macro(ready, writableStreamReady, 0) \ |
77 | macro(state, writableStreamState, 0) \ |
78 | |
79 | #define WEBCORE_BUILTIN_WRITABLESTREAM_INITIALIZEWRITABLESTREAM 1 |
80 | #define WEBCORE_BUILTIN_WRITABLESTREAM_ABORT 1 |
81 | #define WEBCORE_BUILTIN_WRITABLESTREAM_CLOSE 1 |
82 | #define WEBCORE_BUILTIN_WRITABLESTREAM_WRITE 1 |
83 | #define WEBCORE_BUILTIN_WRITABLESTREAM_CLOSED 1 |
84 | #define WEBCORE_BUILTIN_WRITABLESTREAM_READY 1 |
85 | #define WEBCORE_BUILTIN_WRITABLESTREAM_STATE 1 |
86 | |
87 | #define WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(macro) \ |
88 | macro(writableStreamInitializeWritableStreamCode, initializeWritableStream, static_cast<const char*>(nullptr), s_writableStreamInitializeWritableStreamCodeLength) \ |
89 | macro(writableStreamAbortCode, abort, static_cast<const char*>(nullptr), s_writableStreamAbortCodeLength) \ |
90 | macro(writableStreamCloseCode, close, static_cast<const char*>(nullptr), s_writableStreamCloseCodeLength) \ |
91 | macro(writableStreamWriteCode, write, static_cast<const char*>(nullptr), s_writableStreamWriteCodeLength) \ |
92 | macro(writableStreamClosedCode, closed, "get closed", s_writableStreamClosedCodeLength) \ |
93 | macro(writableStreamReadyCode, ready, "get ready", s_writableStreamReadyCodeLength) \ |
94 | macro(writableStreamStateCode, state, "get state", s_writableStreamStateCodeLength) \ |
95 | |
96 | #define WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \ |
97 | macro(abort) \ |
98 | macro(close) \ |
99 | macro(closed) \ |
100 | macro(initializeWritableStream) \ |
101 | macro(ready) \ |
102 | macro(state) \ |
103 | macro(write) \ |
104 | |
105 | #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
106 | JSC::FunctionExecutable* codeName##Generator(JSC::VM&); |
107 | |
108 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) |
109 | #undef DECLARE_BUILTIN_GENERATOR |
110 | |
111 | class WritableStreamBuiltinsWrapper : private JSC::WeakHandleOwner { |
112 | public: |
113 | explicit WritableStreamBuiltinsWrapper(JSC::VM* vm) |
114 | : m_vm(*vm) |
115 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) |
116 | #define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) |
117 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) |
118 | #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS |
119 | { |
120 | } |
121 | |
122 | #define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
123 | JSC::UnlinkedFunctionExecutable* name##Executable(); \ |
124 | const JSC::SourceCode& name##Source() const { return m_##name##Source; } |
125 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) |
126 | #undef EXPOSE_BUILTIN_EXECUTABLES |
127 | |
128 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) |
129 | |
130 | void exportNames(); |
131 | |
132 | private: |
133 | JSC::VM& m_vm; |
134 | |
135 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) |
136 | |
137 | #define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \ |
138 | JSC::SourceCode m_##name##Source;\ |
139 | JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable; |
140 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) |
141 | #undef DECLARE_BUILTIN_SOURCE_MEMBERS |
142 | |
143 | }; |
144 | |
145 | #define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
146 | inline JSC::UnlinkedFunctionExecutable* WritableStreamBuiltinsWrapper::name##Executable() \ |
147 | {\ |
148 | if (!m_##name##Executable) {\ |
149 | JSC::Identifier executableName = functionName##PublicName();\ |
150 | if (overriddenName)\ |
151 | executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\ |
152 | m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\ |
153 | }\ |
154 | return m_##name##Executable.get();\ |
155 | } |
156 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) |
157 | #undef DEFINE_BUILTIN_EXECUTABLES |
158 | |
159 | inline void WritableStreamBuiltinsWrapper::exportNames() |
160 | { |
161 | #define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); |
162 | WEBCORE_FOREACH_WRITABLESTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) |
163 | #undef EXPORT_FUNCTION_NAME |
164 | } |
165 | |
166 | } // namespace WebCore |
167 | |
168 | #endif // ENABLE(STREAMS_API) |
169 | |