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#pragma once
32
33#if ENABLE(WEB_RTC)
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/* RTCPeerConnectionInternals */
47extern const char* const s_rtcPeerConnectionInternalsEnqueueOperationCode;
48extern const int s_rtcPeerConnectionInternalsEnqueueOperationCodeLength;
49extern const JSC::ConstructAbility s_rtcPeerConnectionInternalsEnqueueOperationCodeConstructAbility;
50extern const char* const s_rtcPeerConnectionInternalsObjectOverloadCode;
51extern const int s_rtcPeerConnectionInternalsObjectOverloadCodeLength;
52extern const JSC::ConstructAbility s_rtcPeerConnectionInternalsObjectOverloadCodeConstructAbility;
53extern const char* const s_rtcPeerConnectionInternalsIsRTCPeerConnectionCode;
54extern const int s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeLength;
55extern const JSC::ConstructAbility s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeConstructAbility;
56
57#define WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_DATA(macro) \
58 macro(enqueueOperation, rtcPeerConnectionInternalsEnqueueOperation, 2) \
59 macro(objectOverload, rtcPeerConnectionInternalsObjectOverload, 4) \
60 macro(isRTCPeerConnection, rtcPeerConnectionInternalsIsRTCPeerConnection, 1) \
61
62#define WEBCORE_BUILTIN_RTCPEERCONNECTIONINTERNALS_ENQUEUEOPERATION 1
63#define WEBCORE_BUILTIN_RTCPEERCONNECTIONINTERNALS_OBJECTOVERLOAD 1
64#define WEBCORE_BUILTIN_RTCPEERCONNECTIONINTERNALS_ISRTCPEERCONNECTION 1
65
66#define WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(macro) \
67 macro(rtcPeerConnectionInternalsEnqueueOperationCode, enqueueOperation, static_cast<const char*>(nullptr), s_rtcPeerConnectionInternalsEnqueueOperationCodeLength) \
68 macro(rtcPeerConnectionInternalsObjectOverloadCode, objectOverload, static_cast<const char*>(nullptr), s_rtcPeerConnectionInternalsObjectOverloadCodeLength) \
69 macro(rtcPeerConnectionInternalsIsRTCPeerConnectionCode, isRTCPeerConnection, static_cast<const char*>(nullptr), s_rtcPeerConnectionInternalsIsRTCPeerConnectionCodeLength) \
70
71#define WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
72 macro(enqueueOperation) \
73 macro(isRTCPeerConnection) \
74 macro(objectOverload) \
75
76#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
77 JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
78
79WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
80#undef DECLARE_BUILTIN_GENERATOR
81
82class RTCPeerConnectionInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
83public:
84 explicit RTCPeerConnectionInternalsBuiltinsWrapper(JSC::VM* vm)
85 : m_vm(*vm)
86 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
87#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
88 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
89#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
90 {
91 }
92
93#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
94 JSC::UnlinkedFunctionExecutable* name##Executable(); \
95 const JSC::SourceCode& name##Source() const { return m_##name##Source; }
96 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
97#undef EXPOSE_BUILTIN_EXECUTABLES
98
99 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
100
101 void exportNames();
102
103private:
104 JSC::VM& m_vm;
105
106 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
107
108#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
109 JSC::SourceCode m_##name##Source;\
110 JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
111 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
112#undef DECLARE_BUILTIN_SOURCE_MEMBERS
113
114};
115
116#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
117inline JSC::UnlinkedFunctionExecutable* RTCPeerConnectionInternalsBuiltinsWrapper::name##Executable() \
118{\
119 if (!m_##name##Executable) {\
120 JSC::Identifier executableName = functionName##PublicName();\
121 if (overriddenName)\
122 executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
123 m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
124 }\
125 return m_##name##Executable.get();\
126}
127WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
128#undef DEFINE_BUILTIN_EXECUTABLES
129
130inline void RTCPeerConnectionInternalsBuiltinsWrapper::exportNames()
131{
132#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
133 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
134#undef EXPORT_FUNCTION_NAME
135}
136
137class RTCPeerConnectionInternalsBuiltinFunctions {
138public:
139 explicit RTCPeerConnectionInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
140
141 void init(JSC::JSGlobalObject&);
142 void visit(JSC::SlotVisitor&);
143
144public:
145 JSC::VM& m_vm;
146
147#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
148 JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
149 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
150#undef DECLARE_BUILTIN_SOURCE_MEMBERS
151};
152
153inline void RTCPeerConnectionInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
154{
155#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
156 m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
157 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
158#undef EXPORT_FUNCTION
159}
160
161inline void RTCPeerConnectionInternalsBuiltinFunctions::visit(JSC::SlotVisitor& visitor)
162{
163#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
164 WEBCORE_FOREACH_RTCPEERCONNECTIONINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
165#undef VISIT_FUNCTION
166}
167
168
169} // namespace WebCore
170
171#endif // ENABLE(WEB_RTC)
172