1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22#include "JSAbortController.h"
23
24#include "JSAbortSignal.h"
25#include "JSDOMAttribute.h"
26#include "JSDOMBinding.h"
27#include "JSDOMConstructor.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "ScriptExecutionContext.h"
34#include <JavaScriptCore/FunctionPrototype.h>
35#include <JavaScriptCore/HeapSnapshotBuilder.h>
36#include <JavaScriptCore/JSCInlines.h>
37#include <wtf/GetPtr.h>
38#include <wtf/PointerPreparations.h>
39#include <wtf/URL.h>
40
41
42namespace WebCore {
43using namespace JSC;
44
45// Functions
46
47JSC::EncodedJSValue JSC_HOST_CALL jsAbortControllerPrototypeFunctionAbort(JSC::ExecState*);
48
49// Attributes
50
51JSC::EncodedJSValue jsAbortControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSAbortControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53JSC::EncodedJSValue jsAbortControllerSignal(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54
55class JSAbortControllerPrototype : public JSC::JSNonFinalObject {
56public:
57 using Base = JSC::JSNonFinalObject;
58 static JSAbortControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
59 {
60 JSAbortControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSAbortControllerPrototype>(vm.heap)) JSAbortControllerPrototype(vm, globalObject, structure);
61 ptr->finishCreation(vm);
62 return ptr;
63 }
64
65 DECLARE_INFO;
66 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
67 {
68 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
69 }
70
71private:
72 JSAbortControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
73 : JSC::JSNonFinalObject(vm, structure)
74 {
75 }
76
77 void finishCreation(JSC::VM&);
78};
79
80using JSAbortControllerConstructor = JSDOMConstructor<JSAbortController>;
81
82template<> EncodedJSValue JSC_HOST_CALL JSAbortControllerConstructor::construct(ExecState* state)
83{
84 VM& vm = state->vm();
85 auto throwScope = DECLARE_THROW_SCOPE(vm);
86 UNUSED_PARAM(throwScope);
87 auto* castedThis = jsCast<JSAbortControllerConstructor*>(state->jsCallee());
88 ASSERT(castedThis);
89 auto* context = castedThis->scriptExecutionContext();
90 if (UNLIKELY(!context))
91 return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "AbortController");
92 auto object = AbortController::create(*context);
93 return JSValue::encode(toJSNewlyCreated<IDLInterface<AbortController>>(*state, *castedThis->globalObject(), WTFMove(object)));
94}
95
96template<> JSValue JSAbortControllerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
97{
98 UNUSED_PARAM(vm);
99 return globalObject.functionPrototype();
100}
101
102template<> void JSAbortControllerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
103{
104 putDirect(vm, vm.propertyNames->prototype, JSAbortController::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
105 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AbortController"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
106 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
107}
108
109template<> const ClassInfo JSAbortControllerConstructor::s_info = { "AbortController", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortControllerConstructor) };
110
111/* Hash table for prototype */
112
113static const HashTableValue JSAbortControllerPrototypeTableValues[] =
114{
115 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAbortControllerConstructor) } },
116 { "signal", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortControllerSignal), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
117 { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAbortControllerPrototypeFunctionAbort), (intptr_t) (0) } },
118};
119
120const ClassInfo JSAbortControllerPrototype::s_info = { "AbortControllerPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortControllerPrototype) };
121
122void JSAbortControllerPrototype::finishCreation(VM& vm)
123{
124 Base::finishCreation(vm);
125 reifyStaticProperties(vm, JSAbortController::info(), JSAbortControllerPrototypeTableValues, *this);
126}
127
128const ClassInfo JSAbortController::s_info = { "AbortController", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortController) };
129
130JSAbortController::JSAbortController(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AbortController>&& impl)
131 : JSDOMWrapper<AbortController>(structure, globalObject, WTFMove(impl))
132{
133}
134
135void JSAbortController::finishCreation(VM& vm)
136{
137 Base::finishCreation(vm);
138 ASSERT(inherits(vm, info()));
139
140}
141
142JSObject* JSAbortController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
143{
144 return JSAbortControllerPrototype::create(vm, &globalObject, JSAbortControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
145}
146
147JSObject* JSAbortController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
148{
149 return getDOMPrototype<JSAbortController>(vm, globalObject);
150}
151
152JSValue JSAbortController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
153{
154 return getDOMConstructor<JSAbortControllerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
155}
156
157void JSAbortController::destroy(JSC::JSCell* cell)
158{
159 JSAbortController* thisObject = static_cast<JSAbortController*>(cell);
160 thisObject->JSAbortController::~JSAbortController();
161}
162
163template<> inline JSAbortController* IDLAttribute<JSAbortController>::cast(ExecState& state, EncodedJSValue thisValue)
164{
165 return jsDynamicCast<JSAbortController*>(state.vm(), JSValue::decode(thisValue));
166}
167
168template<> inline JSAbortController* IDLOperation<JSAbortController>::cast(ExecState& state)
169{
170 return jsDynamicCast<JSAbortController*>(state.vm(), state.thisValue());
171}
172
173EncodedJSValue jsAbortControllerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
174{
175 VM& vm = state->vm();
176 auto throwScope = DECLARE_THROW_SCOPE(vm);
177 auto* prototype = jsDynamicCast<JSAbortControllerPrototype*>(vm, JSValue::decode(thisValue));
178 if (UNLIKELY(!prototype))
179 return throwVMTypeError(state, throwScope);
180 return JSValue::encode(JSAbortController::getConstructor(state->vm(), prototype->globalObject()));
181}
182
183bool setJSAbortControllerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
184{
185 VM& vm = state->vm();
186 auto throwScope = DECLARE_THROW_SCOPE(vm);
187 auto* prototype = jsDynamicCast<JSAbortControllerPrototype*>(vm, JSValue::decode(thisValue));
188 if (UNLIKELY(!prototype)) {
189 throwVMTypeError(state, throwScope);
190 return false;
191 }
192 // Shadowing a built-in constructor
193 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
194}
195
196static inline JSValue jsAbortControllerSignalGetter(ExecState& state, JSAbortController& thisObject, ThrowScope& throwScope)
197{
198 UNUSED_PARAM(throwScope);
199 UNUSED_PARAM(state);
200 auto& impl = thisObject.wrapped();
201 JSValue result = toJS<IDLInterface<AbortSignal>>(state, *thisObject.globalObject(), throwScope, impl.signal());
202 return result;
203}
204
205EncodedJSValue jsAbortControllerSignal(ExecState* state, EncodedJSValue thisValue, PropertyName)
206{
207 return IDLAttribute<JSAbortController>::get<jsAbortControllerSignalGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "signal");
208}
209
210static inline JSC::EncodedJSValue jsAbortControllerPrototypeFunctionAbortBody(JSC::ExecState* state, typename IDLOperation<JSAbortController>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
211{
212 UNUSED_PARAM(state);
213 UNUSED_PARAM(throwScope);
214 auto& impl = castedThis->wrapped();
215 impl.abort();
216 return JSValue::encode(jsUndefined());
217}
218
219EncodedJSValue JSC_HOST_CALL jsAbortControllerPrototypeFunctionAbort(ExecState* state)
220{
221 return IDLOperation<JSAbortController>::call<jsAbortControllerPrototypeFunctionAbortBody>(*state, "abort");
222}
223
224void JSAbortController::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
225{
226 auto* thisObject = jsCast<JSAbortController*>(cell);
227 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
228 if (thisObject->scriptExecutionContext())
229 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
230 Base::heapSnapshot(cell, builder);
231}
232
233bool JSAbortControllerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
234{
235 UNUSED_PARAM(handle);
236 UNUSED_PARAM(visitor);
237 UNUSED_PARAM(reason);
238 return false;
239}
240
241void JSAbortControllerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
242{
243 auto* jsAbortController = static_cast<JSAbortController*>(handle.slot()->asCell());
244 auto& world = *static_cast<DOMWrapperWorld*>(context);
245 uncacheWrapper(world, &jsAbortController->wrapped(), jsAbortController);
246}
247
248JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<AbortController>&& impl)
249{
250 // If you hit this failure the interface definition has the ImplementationLacksVTable
251 // attribute. You should remove that attribute. If the class has subclasses
252 // that may be passed through this toJS() function you should use the SkipVTableValidation
253 // attribute to AbortController.
254 static_assert(!std::is_polymorphic<AbortController>::value, "AbortController is polymorphic but the IDL claims it is not");
255 return createWrapper<AbortController>(globalObject, WTFMove(impl));
256}
257
258JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, AbortController& impl)
259{
260 return wrap(state, globalObject, impl);
261}
262
263AbortController* JSAbortController::toWrapped(JSC::VM& vm, JSC::JSValue value)
264{
265 if (auto* wrapper = jsDynamicCast<JSAbortController*>(vm, value))
266 return &wrapper->wrapped();
267 return nullptr;
268}
269
270}
271