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 "JSXMLHttpRequestProgressEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertNumbers.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 jsXMLHttpRequestProgressEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
44bool setJSXMLHttpRequestProgressEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
45JSC::EncodedJSValue jsXMLHttpRequestProgressEventPosition(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46JSC::EncodedJSValue jsXMLHttpRequestProgressEventTotalSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47
48class JSXMLHttpRequestProgressEventPrototype : public JSC::JSNonFinalObject {
49public:
50 using Base = JSC::JSNonFinalObject;
51 static JSXMLHttpRequestProgressEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
52 {
53 JSXMLHttpRequestProgressEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSXMLHttpRequestProgressEventPrototype>(vm.heap)) JSXMLHttpRequestProgressEventPrototype(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 JSXMLHttpRequestProgressEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
66 : JSC::JSNonFinalObject(vm, structure)
67 {
68 }
69
70 void finishCreation(JSC::VM&);
71};
72
73using JSXMLHttpRequestProgressEventConstructor = JSDOMConstructorNotConstructable<JSXMLHttpRequestProgressEvent>;
74
75template<> JSValue JSXMLHttpRequestProgressEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
76{
77 return JSProgressEvent::getConstructor(vm, &globalObject);
78}
79
80template<> void JSXMLHttpRequestProgressEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
81{
82 putDirect(vm, vm.propertyNames->prototype, JSXMLHttpRequestProgressEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
83 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("XMLHttpRequestProgressEvent"_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 JSXMLHttpRequestProgressEventConstructor::s_info = { "XMLHttpRequestProgressEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestProgressEventConstructor) };
88
89/* Hash table for prototype */
90
91static const HashTableValue JSXMLHttpRequestProgressEventPrototypeTableValues[] =
92{
93 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestProgressEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSXMLHttpRequestProgressEventConstructor) } },
94 { "position", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestProgressEventPosition), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
95 { "totalSize", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestProgressEventTotalSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
96};
97
98const ClassInfo JSXMLHttpRequestProgressEventPrototype::s_info = { "XMLHttpRequestProgressEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestProgressEventPrototype) };
99
100void JSXMLHttpRequestProgressEventPrototype::finishCreation(VM& vm)
101{
102 Base::finishCreation(vm);
103 reifyStaticProperties(vm, JSXMLHttpRequestProgressEvent::info(), JSXMLHttpRequestProgressEventPrototypeTableValues, *this);
104}
105
106const ClassInfo JSXMLHttpRequestProgressEvent::s_info = { "XMLHttpRequestProgressEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestProgressEvent) };
107
108JSXMLHttpRequestProgressEvent::JSXMLHttpRequestProgressEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<XMLHttpRequestProgressEvent>&& impl)
109 : JSProgressEvent(structure, globalObject, WTFMove(impl))
110{
111}
112
113void JSXMLHttpRequestProgressEvent::finishCreation(VM& vm)
114{
115 Base::finishCreation(vm);
116 ASSERT(inherits(vm, info()));
117
118}
119
120JSObject* JSXMLHttpRequestProgressEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
121{
122 return JSXMLHttpRequestProgressEventPrototype::create(vm, &globalObject, JSXMLHttpRequestProgressEventPrototype::createStructure(vm, &globalObject, JSProgressEvent::prototype(vm, globalObject)));
123}
124
125JSObject* JSXMLHttpRequestProgressEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
126{
127 return getDOMPrototype<JSXMLHttpRequestProgressEvent>(vm, globalObject);
128}
129
130JSValue JSXMLHttpRequestProgressEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
131{
132 return getDOMConstructor<JSXMLHttpRequestProgressEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
133}
134
135template<> inline JSXMLHttpRequestProgressEvent* IDLAttribute<JSXMLHttpRequestProgressEvent>::cast(ExecState& state, EncodedJSValue thisValue)
136{
137 return jsDynamicCast<JSXMLHttpRequestProgressEvent*>(state.vm(), JSValue::decode(thisValue));
138}
139
140EncodedJSValue jsXMLHttpRequestProgressEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
141{
142 VM& vm = state->vm();
143 auto throwScope = DECLARE_THROW_SCOPE(vm);
144 auto* prototype = jsDynamicCast<JSXMLHttpRequestProgressEventPrototype*>(vm, JSValue::decode(thisValue));
145 if (UNLIKELY(!prototype))
146 return throwVMTypeError(state, throwScope);
147 return JSValue::encode(JSXMLHttpRequestProgressEvent::getConstructor(state->vm(), prototype->globalObject()));
148}
149
150bool setJSXMLHttpRequestProgressEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
151{
152 VM& vm = state->vm();
153 auto throwScope = DECLARE_THROW_SCOPE(vm);
154 auto* prototype = jsDynamicCast<JSXMLHttpRequestProgressEventPrototype*>(vm, JSValue::decode(thisValue));
155 if (UNLIKELY(!prototype)) {
156 throwVMTypeError(state, throwScope);
157 return false;
158 }
159 // Shadowing a built-in constructor
160 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
161}
162
163static inline JSValue jsXMLHttpRequestProgressEventPositionGetter(ExecState& state, JSXMLHttpRequestProgressEvent& thisObject, ThrowScope& throwScope)
164{
165 UNUSED_PARAM(throwScope);
166 UNUSED_PARAM(state);
167 auto& impl = thisObject.wrapped();
168 JSValue result = toJS<IDLUnsignedLongLong>(state, throwScope, impl.position());
169 return result;
170}
171
172EncodedJSValue jsXMLHttpRequestProgressEventPosition(ExecState* state, EncodedJSValue thisValue, PropertyName)
173{
174 return IDLAttribute<JSXMLHttpRequestProgressEvent>::get<jsXMLHttpRequestProgressEventPositionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "position");
175}
176
177static inline JSValue jsXMLHttpRequestProgressEventTotalSizeGetter(ExecState& state, JSXMLHttpRequestProgressEvent& thisObject, ThrowScope& throwScope)
178{
179 UNUSED_PARAM(throwScope);
180 UNUSED_PARAM(state);
181 auto& impl = thisObject.wrapped();
182 JSValue result = toJS<IDLUnsignedLongLong>(state, throwScope, impl.totalSize());
183 return result;
184}
185
186EncodedJSValue jsXMLHttpRequestProgressEventTotalSize(ExecState* state, EncodedJSValue thisValue, PropertyName)
187{
188 return IDLAttribute<JSXMLHttpRequestProgressEvent>::get<jsXMLHttpRequestProgressEventTotalSizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "totalSize");
189}
190
191void JSXMLHttpRequestProgressEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
192{
193 auto* thisObject = jsCast<JSXMLHttpRequestProgressEvent*>(cell);
194 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
195 if (thisObject->scriptExecutionContext())
196 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
197 Base::heapSnapshot(cell, builder);
198}
199
200
201}
202