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 "JSBeforeUnloadEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertStrings.h"
28#include "JSDOMExceptionHandling.h"
29#include "JSDOMWrapperCache.h"
30#include "ScriptExecutionContext.h"
31#include <JavaScriptCore/HeapSnapshotBuilder.h>
32#include <JavaScriptCore/JSCInlines.h>
33#include <wtf/GetPtr.h>
34#include <wtf/PointerPreparations.h>
35#include <wtf/URL.h>
36
37
38namespace WebCore {
39using namespace JSC;
40
41// Attributes
42
43JSC::EncodedJSValue jsBeforeUnloadEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
44bool setJSBeforeUnloadEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
45JSC::EncodedJSValue jsBeforeUnloadEventReturnValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46bool setJSBeforeUnloadEventReturnValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47
48class JSBeforeUnloadEventPrototype : public JSC::JSNonFinalObject {
49public:
50 using Base = JSC::JSNonFinalObject;
51 static JSBeforeUnloadEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
52 {
53 JSBeforeUnloadEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSBeforeUnloadEventPrototype>(vm.heap)) JSBeforeUnloadEventPrototype(vm, globalObject, structure);
54 ptr->finishCreation(vm);
55 return ptr;
56 }
57
58 DECLARE_INFO;
59 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
60 {
61 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
62 }
63
64private:
65 JSBeforeUnloadEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
66 : JSC::JSNonFinalObject(vm, structure)
67 {
68 }
69
70 void finishCreation(JSC::VM&);
71};
72
73using JSBeforeUnloadEventConstructor = JSDOMConstructorNotConstructable<JSBeforeUnloadEvent>;
74
75template<> JSValue JSBeforeUnloadEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
76{
77 return JSEvent::getConstructor(vm, &globalObject);
78}
79
80template<> void JSBeforeUnloadEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
81{
82 putDirect(vm, vm.propertyNames->prototype, JSBeforeUnloadEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
83 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("BeforeUnloadEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
84 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
85}
86
87template<> const ClassInfo JSBeforeUnloadEventConstructor::s_info = { "BeforeUnloadEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBeforeUnloadEventConstructor) };
88
89/* Hash table for prototype */
90
91static const HashTableValue JSBeforeUnloadEventPrototypeTableValues[] =
92{
93 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBeforeUnloadEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBeforeUnloadEventConstructor) } },
94 { "returnValue", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBeforeUnloadEventReturnValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBeforeUnloadEventReturnValue) } },
95};
96
97const ClassInfo JSBeforeUnloadEventPrototype::s_info = { "BeforeUnloadEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBeforeUnloadEventPrototype) };
98
99void JSBeforeUnloadEventPrototype::finishCreation(VM& vm)
100{
101 Base::finishCreation(vm);
102 reifyStaticProperties(vm, JSBeforeUnloadEvent::info(), JSBeforeUnloadEventPrototypeTableValues, *this);
103}
104
105const ClassInfo JSBeforeUnloadEvent::s_info = { "BeforeUnloadEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBeforeUnloadEvent) };
106
107JSBeforeUnloadEvent::JSBeforeUnloadEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BeforeUnloadEvent>&& impl)
108 : JSEvent(structure, globalObject, WTFMove(impl))
109{
110}
111
112void JSBeforeUnloadEvent::finishCreation(VM& vm)
113{
114 Base::finishCreation(vm);
115 ASSERT(inherits(vm, info()));
116
117}
118
119JSObject* JSBeforeUnloadEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
120{
121 return JSBeforeUnloadEventPrototype::create(vm, &globalObject, JSBeforeUnloadEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
122}
123
124JSObject* JSBeforeUnloadEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
125{
126 return getDOMPrototype<JSBeforeUnloadEvent>(vm, globalObject);
127}
128
129JSValue JSBeforeUnloadEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
130{
131 return getDOMConstructor<JSBeforeUnloadEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
132}
133
134template<> inline JSBeforeUnloadEvent* IDLAttribute<JSBeforeUnloadEvent>::cast(ExecState& state, EncodedJSValue thisValue)
135{
136 return jsDynamicCast<JSBeforeUnloadEvent*>(state.vm(), JSValue::decode(thisValue));
137}
138
139EncodedJSValue jsBeforeUnloadEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
140{
141 VM& vm = state->vm();
142 auto throwScope = DECLARE_THROW_SCOPE(vm);
143 auto* prototype = jsDynamicCast<JSBeforeUnloadEventPrototype*>(vm, JSValue::decode(thisValue));
144 if (UNLIKELY(!prototype))
145 return throwVMTypeError(state, throwScope);
146 return JSValue::encode(JSBeforeUnloadEvent::getConstructor(state->vm(), prototype->globalObject()));
147}
148
149bool setJSBeforeUnloadEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
150{
151 VM& vm = state->vm();
152 auto throwScope = DECLARE_THROW_SCOPE(vm);
153 auto* prototype = jsDynamicCast<JSBeforeUnloadEventPrototype*>(vm, JSValue::decode(thisValue));
154 if (UNLIKELY(!prototype)) {
155 throwVMTypeError(state, throwScope);
156 return false;
157 }
158 // Shadowing a built-in constructor
159 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
160}
161
162static inline JSValue jsBeforeUnloadEventReturnValueGetter(ExecState& state, JSBeforeUnloadEvent& thisObject, ThrowScope& throwScope)
163{
164 UNUSED_PARAM(throwScope);
165 UNUSED_PARAM(state);
166 auto& impl = thisObject.wrapped();
167 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.returnValue());
168 return result;
169}
170
171EncodedJSValue jsBeforeUnloadEventReturnValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
172{
173 return IDLAttribute<JSBeforeUnloadEvent>::get<jsBeforeUnloadEventReturnValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "returnValue");
174}
175
176static inline bool setJSBeforeUnloadEventReturnValueSetter(ExecState& state, JSBeforeUnloadEvent& thisObject, JSValue value, ThrowScope& throwScope)
177{
178 UNUSED_PARAM(throwScope);
179 auto& impl = thisObject.wrapped();
180 auto nativeValue = convert<IDLDOMString>(state, value);
181 RETURN_IF_EXCEPTION(throwScope, false);
182 AttributeSetter::call(state, throwScope, [&] {
183 return impl.setReturnValue(WTFMove(nativeValue));
184 });
185 return true;
186}
187
188bool setJSBeforeUnloadEventReturnValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
189{
190 return IDLAttribute<JSBeforeUnloadEvent>::set<setJSBeforeUnloadEventReturnValueSetter>(*state, thisValue, encodedValue, "returnValue");
191}
192
193void JSBeforeUnloadEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
194{
195 auto* thisObject = jsCast<JSBeforeUnloadEvent*>(cell);
196 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
197 if (thisObject->scriptExecutionContext())
198 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
199 Base::heapSnapshot(cell, builder);
200}
201
202
203}
204