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 "JSRadioNodeList.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertStrings.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMWrapperCache.h"
32#include "JSHTMLElement.h"
33#include "JSNode.h"
34#include "Node.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <JavaScriptCore/PropertyNameArray.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43
44namespace WebCore {
45using namespace JSC;
46
47// Attributes
48
49JSC::EncodedJSValue jsRadioNodeListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSRadioNodeListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsRadioNodeListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSRadioNodeListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54class JSRadioNodeListPrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSRadioNodeListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSRadioNodeListPrototype* ptr = new (NotNull, JSC::allocateCell<JSRadioNodeListPrototype>(vm.heap)) JSRadioNodeListPrototype(vm, globalObject, structure);
60 ptr->finishCreation(vm);
61 return ptr;
62 }
63
64 DECLARE_INFO;
65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66 {
67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68 }
69
70private:
71 JSRadioNodeListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSRadioNodeListConstructor = JSDOMConstructorNotConstructable<JSRadioNodeList>;
80
81template<> JSValue JSRadioNodeListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 return JSNodeList::getConstructor(vm, &globalObject);
84}
85
86template<> void JSRadioNodeListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
87{
88 putDirect(vm, vm.propertyNames->prototype, JSRadioNodeList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RadioNodeList"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91}
92
93template<> const ClassInfo JSRadioNodeListConstructor::s_info = { "RadioNodeList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRadioNodeListConstructor) };
94
95/* Hash table for prototype */
96
97static const HashTableValue JSRadioNodeListPrototypeTableValues[] =
98{
99 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRadioNodeListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRadioNodeListConstructor) } },
100 { "value", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRadioNodeListValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRadioNodeListValue) } },
101};
102
103const ClassInfo JSRadioNodeListPrototype::s_info = { "RadioNodeListPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRadioNodeListPrototype) };
104
105void JSRadioNodeListPrototype::finishCreation(VM& vm)
106{
107 Base::finishCreation(vm);
108 reifyStaticProperties(vm, JSRadioNodeList::info(), JSRadioNodeListPrototypeTableValues, *this);
109}
110
111const ClassInfo JSRadioNodeList::s_info = { "RadioNodeList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRadioNodeList) };
112
113JSRadioNodeList::JSRadioNodeList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RadioNodeList>&& impl)
114 : JSNodeList(structure, globalObject, WTFMove(impl))
115{
116}
117
118void JSRadioNodeList::finishCreation(VM& vm)
119{
120 Base::finishCreation(vm);
121 ASSERT(inherits(vm, info()));
122
123}
124
125JSObject* JSRadioNodeList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
126{
127 return JSRadioNodeListPrototype::create(vm, &globalObject, JSRadioNodeListPrototype::createStructure(vm, &globalObject, JSNodeList::prototype(vm, globalObject)));
128}
129
130JSObject* JSRadioNodeList::prototype(VM& vm, JSDOMGlobalObject& globalObject)
131{
132 return getDOMPrototype<JSRadioNodeList>(vm, globalObject);
133}
134
135JSValue JSRadioNodeList::getConstructor(VM& vm, const JSGlobalObject* globalObject)
136{
137 return getDOMConstructor<JSRadioNodeListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
138}
139
140bool JSRadioNodeList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
141{
142 auto* thisObject = jsCast<JSRadioNodeList*>(object);
143 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
144 if (auto index = parseIndex(propertyName)) {
145 if (index.value() < thisObject->wrapped().length()) {
146 auto value = toJS<IDLInterface<HTMLElement>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value()));
147 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
148 return true;
149 }
150 }
151 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
152}
153
154bool JSRadioNodeList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
155{
156 auto* thisObject = jsCast<JSRadioNodeList*>(object);
157 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
158 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
159 if (index < thisObject->wrapped().length()) {
160 auto value = toJS<IDLInterface<HTMLElement>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index));
161 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
162 return true;
163 }
164 }
165 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
166}
167
168void JSRadioNodeList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
169{
170 auto* thisObject = jsCast<JSRadioNodeList*>(object);
171 ASSERT_GC_OBJECT_INHERITS(object, info());
172 for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
173 propertyNames.add(Identifier::from(state, i));
174 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
175}
176
177template<> inline JSRadioNodeList* IDLAttribute<JSRadioNodeList>::cast(ExecState& state, EncodedJSValue thisValue)
178{
179 return jsDynamicCast<JSRadioNodeList*>(state.vm(), JSValue::decode(thisValue));
180}
181
182EncodedJSValue jsRadioNodeListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
183{
184 VM& vm = state->vm();
185 auto throwScope = DECLARE_THROW_SCOPE(vm);
186 auto* prototype = jsDynamicCast<JSRadioNodeListPrototype*>(vm, JSValue::decode(thisValue));
187 if (UNLIKELY(!prototype))
188 return throwVMTypeError(state, throwScope);
189 return JSValue::encode(JSRadioNodeList::getConstructor(state->vm(), prototype->globalObject()));
190}
191
192bool setJSRadioNodeListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
193{
194 VM& vm = state->vm();
195 auto throwScope = DECLARE_THROW_SCOPE(vm);
196 auto* prototype = jsDynamicCast<JSRadioNodeListPrototype*>(vm, JSValue::decode(thisValue));
197 if (UNLIKELY(!prototype)) {
198 throwVMTypeError(state, throwScope);
199 return false;
200 }
201 // Shadowing a built-in constructor
202 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
203}
204
205static inline JSValue jsRadioNodeListValueGetter(ExecState& state, JSRadioNodeList& thisObject, ThrowScope& throwScope)
206{
207 UNUSED_PARAM(throwScope);
208 UNUSED_PARAM(state);
209 auto& impl = thisObject.wrapped();
210 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.value());
211 return result;
212}
213
214EncodedJSValue jsRadioNodeListValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
215{
216 return IDLAttribute<JSRadioNodeList>::get<jsRadioNodeListValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value");
217}
218
219static inline bool setJSRadioNodeListValueSetter(ExecState& state, JSRadioNodeList& thisObject, JSValue value, ThrowScope& throwScope)
220{
221 UNUSED_PARAM(throwScope);
222 auto& impl = thisObject.wrapped();
223 auto nativeValue = convert<IDLDOMString>(state, value);
224 RETURN_IF_EXCEPTION(throwScope, false);
225 AttributeSetter::call(state, throwScope, [&] {
226 return impl.setValue(WTFMove(nativeValue));
227 });
228 return true;
229}
230
231bool setJSRadioNodeListValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
232{
233 return IDLAttribute<JSRadioNodeList>::set<setJSRadioNodeListValueSetter>(*state, thisValue, encodedValue, "value");
234}
235
236void JSRadioNodeList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
237{
238 auto* thisObject = jsCast<JSRadioNodeList*>(cell);
239 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
240 if (thisObject->scriptExecutionContext())
241 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
242 Base::heapSnapshot(cell, builder);
243}
244
245#if ENABLE(BINDING_INTEGRITY)
246#if PLATFORM(WIN)
247#pragma warning(disable: 4483)
248extern "C" { extern void (*const __identifier("??_7RadioNodeList@WebCore@@6B@")[])(); }
249#else
250extern "C" { extern void* _ZTVN7WebCore13RadioNodeListE[]; }
251#endif
252#endif
253
254JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RadioNodeList>&& impl)
255{
256
257#if ENABLE(BINDING_INTEGRITY)
258 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
259#if PLATFORM(WIN)
260 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RadioNodeList@WebCore@@6B@"));
261#else
262 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13RadioNodeListE[2]);
263#endif
264
265 // If this fails RadioNodeList does not have a vtable, so you need to add the
266 // ImplementationLacksVTable attribute to the interface definition
267 static_assert(std::is_polymorphic<RadioNodeList>::value, "RadioNodeList is not polymorphic");
268
269 // If you hit this assertion you either have a use after free bug, or
270 // RadioNodeList has subclasses. If RadioNodeList has subclasses that get passed
271 // to toJS() we currently require RadioNodeList you to opt out of binding hardening
272 // by adding the SkipVTableValidation attribute to the interface IDL definition
273 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
274#endif
275 return createWrapper<RadioNodeList>(globalObject, WTFMove(impl));
276}
277
278JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RadioNodeList& impl)
279{
280 return wrap(state, globalObject, impl);
281}
282
283
284}
285