1/*
2 * Copyright (c) 2015 Canon Inc.
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#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/* CountQueuingStrategy */
47extern const char* const s_countQueuingStrategySizeCode;
48extern const int s_countQueuingStrategySizeCodeLength;
49extern const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility;
50extern const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode;
51extern const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength;
52extern const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility;
53
54#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_DATA(macro) \
55 macro(size, countQueuingStrategySize, 0) \
56 macro(initializeCountQueuingStrategy, countQueuingStrategyInitializeCountQueuingStrategy, 1) \
57
58#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_SIZE 1
59#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_INITIALIZECOUNTQUEUINGSTRATEGY 1
60
61#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(macro) \
62 macro(countQueuingStrategySizeCode, size, static_cast<const char*>(nullptr), s_countQueuingStrategySizeCodeLength) \
63 macro(countQueuingStrategyInitializeCountQueuingStrategyCode, initializeCountQueuingStrategy, static_cast<const char*>(nullptr), s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength) \
64
65#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(macro) \
66 macro(initializeCountQueuingStrategy) \
67 macro(size) \
68
69#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
70 JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
71
72WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
73#undef DECLARE_BUILTIN_GENERATOR
74
75class CountQueuingStrategyBuiltinsWrapper : private JSC::WeakHandleOwner {
76public:
77 explicit CountQueuingStrategyBuiltinsWrapper(JSC::VM* vm)
78 : m_vm(*vm)
79 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
80#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
81 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
82#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
83 {
84 }
85
86#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
87 JSC::UnlinkedFunctionExecutable* name##Executable(); \
88 const JSC::SourceCode& name##Source() const { return m_##name##Source; }
89 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
90#undef EXPOSE_BUILTIN_EXECUTABLES
91
92 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
93
94 void exportNames();
95
96private:
97 JSC::VM& m_vm;
98
99 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
100
101#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
102 JSC::SourceCode m_##name##Source;\
103 JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
104 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
105#undef DECLARE_BUILTIN_SOURCE_MEMBERS
106
107};
108
109#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
110inline JSC::UnlinkedFunctionExecutable* CountQueuingStrategyBuiltinsWrapper::name##Executable() \
111{\
112 if (!m_##name##Executable) {\
113 JSC::Identifier executableName = functionName##PublicName();\
114 if (overriddenName)\
115 executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
116 m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
117 }\
118 return m_##name##Executable.get();\
119}
120WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
121#undef DEFINE_BUILTIN_EXECUTABLES
122
123inline void CountQueuingStrategyBuiltinsWrapper::exportNames()
124{
125#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
126 WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
127#undef EXPORT_FUNCTION_NAME
128}
129
130} // namespace WebCore
131
132#endif // ENABLE(STREAMS_API)
133