1/*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
3 * Copyright (c) 2017 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#pragma once
32
33#if ENABLE(STREAMS_API)
34
35#include <JavaScriptCore/BuiltinUtils.h>
36#include <JavaScriptCore/Identifier.h>
37#include <JavaScriptCore/JSFunction.h>
38#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
39
40namespace JSC {
41class FunctionExecutable;
42}
43
44namespace WebCore {
45
46/* ReadableStreamBYOBRequest */
47extern const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode;
48extern const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength;
49extern const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility;
50extern const char* const s_readableStreamBYOBRequestRespondCode;
51extern const int s_readableStreamBYOBRequestRespondCodeLength;
52extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility;
53extern const char* const s_readableStreamBYOBRequestRespondWithNewViewCode;
54extern const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength;
55extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility;
56extern const char* const s_readableStreamBYOBRequestViewCode;
57extern const int s_readableStreamBYOBRequestViewCodeLength;
58extern const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility;
59
60#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_DATA(macro) \
61 macro(initializeReadableStreamBYOBRequest, readableStreamBYOBRequestInitializeReadableStreamBYOBRequest, 2) \
62 macro(respond, readableStreamBYOBRequestRespond, 1) \
63 macro(respondWithNewView, readableStreamBYOBRequestRespondWithNewView, 1) \
64 macro(view, readableStreamBYOBRequestView, 0) \
65
66#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_INITIALIZEREADABLESTREAMBYOBREQUEST 1
67#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPOND 1
68#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPONDWITHNEWVIEW 1
69#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_VIEW 1
70
71#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(macro) \
72 macro(readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode, initializeReadableStreamBYOBRequest, static_cast<const char*>(nullptr), s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength) \
73 macro(readableStreamBYOBRequestRespondCode, respond, static_cast<const char*>(nullptr), s_readableStreamBYOBRequestRespondCodeLength) \
74 macro(readableStreamBYOBRequestRespondWithNewViewCode, respondWithNewView, static_cast<const char*>(nullptr), s_readableStreamBYOBRequestRespondWithNewViewCodeLength) \
75 macro(readableStreamBYOBRequestViewCode, view, "get view", s_readableStreamBYOBRequestViewCodeLength) \
76
77#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(macro) \
78 macro(initializeReadableStreamBYOBRequest) \
79 macro(respond) \
80 macro(respondWithNewView) \
81 macro(view) \
82
83#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
84 JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
85
86WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
87#undef DECLARE_BUILTIN_GENERATOR
88
89class ReadableStreamBYOBRequestBuiltinsWrapper : private JSC::WeakHandleOwner {
90public:
91 explicit ReadableStreamBYOBRequestBuiltinsWrapper(JSC::VM* vm)
92 : m_vm(*vm)
93 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
94#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
95 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
96#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
97 {
98 }
99
100#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
101 JSC::UnlinkedFunctionExecutable* name##Executable(); \
102 const JSC::SourceCode& name##Source() const { return m_##name##Source; }
103 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
104#undef EXPOSE_BUILTIN_EXECUTABLES
105
106 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
107
108 void exportNames();
109
110private:
111 JSC::VM& m_vm;
112
113 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
114
115#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
116 JSC::SourceCode m_##name##Source;\
117 JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
118 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
119#undef DECLARE_BUILTIN_SOURCE_MEMBERS
120
121};
122
123#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
124inline JSC::UnlinkedFunctionExecutable* ReadableStreamBYOBRequestBuiltinsWrapper::name##Executable() \
125{\
126 if (!m_##name##Executable) {\
127 JSC::Identifier executableName = functionName##PublicName();\
128 if (overriddenName)\
129 executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
130 m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
131 }\
132 return m_##name##Executable.get();\
133}
134WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
135#undef DEFINE_BUILTIN_EXECUTABLES
136
137inline void ReadableStreamBYOBRequestBuiltinsWrapper::exportNames()
138{
139#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
140 WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
141#undef EXPORT_FUNCTION_NAME
142}
143
144} // namespace WebCore
145
146#endif // ENABLE(STREAMS_API)
147