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 "JSNodeIterator.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertCallbacks.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertNullable.h"
31#include "JSDOMConvertNumbers.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMOperation.h"
35#include "JSDOMWrapperCache.h"
36#include "JSNode.h"
37#include "JSNodeFilter.h"
38#include "ScriptExecutionContext.h"
39#include <JavaScriptCore/FunctionPrototype.h>
40#include <JavaScriptCore/HeapSnapshotBuilder.h>
41#include <JavaScriptCore/JSCInlines.h>
42#include <wtf/GetPtr.h>
43#include <wtf/PointerPreparations.h>
44#include <wtf/URL.h>
45
46
47namespace WebCore {
48using namespace JSC;
49
50// Functions
51
52JSC::EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionNextNode(JSC::ExecState*);
53JSC::EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionPreviousNode(JSC::ExecState*);
54JSC::EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(JSC::ExecState*);
55
56// Attributes
57
58JSC::EncodedJSValue jsNodeIteratorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59bool setJSNodeIteratorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60JSC::EncodedJSValue jsNodeIteratorRoot(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
61JSC::EncodedJSValue jsNodeIteratorReferenceNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62JSC::EncodedJSValue jsNodeIteratorPointerBeforeReferenceNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
63JSC::EncodedJSValue jsNodeIteratorWhatToShow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
64JSC::EncodedJSValue jsNodeIteratorFilter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
65
66class JSNodeIteratorPrototype : public JSC::JSNonFinalObject {
67public:
68 using Base = JSC::JSNonFinalObject;
69 static JSNodeIteratorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
70 {
71 JSNodeIteratorPrototype* ptr = new (NotNull, JSC::allocateCell<JSNodeIteratorPrototype>(vm.heap)) JSNodeIteratorPrototype(vm, globalObject, structure);
72 ptr->finishCreation(vm);
73 return ptr;
74 }
75
76 DECLARE_INFO;
77 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
78 {
79 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
80 }
81
82private:
83 JSNodeIteratorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
84 : JSC::JSNonFinalObject(vm, structure)
85 {
86 }
87
88 void finishCreation(JSC::VM&);
89};
90
91using JSNodeIteratorConstructor = JSDOMConstructorNotConstructable<JSNodeIterator>;
92
93template<> JSValue JSNodeIteratorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
94{
95 UNUSED_PARAM(vm);
96 return globalObject.functionPrototype();
97}
98
99template<> void JSNodeIteratorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
100{
101 putDirect(vm, vm.propertyNames->prototype, JSNodeIterator::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
102 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("NodeIterator"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
103 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
104}
105
106template<> const ClassInfo JSNodeIteratorConstructor::s_info = { "NodeIterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeIteratorConstructor) };
107
108/* Hash table for prototype */
109
110static const HashTableValue JSNodeIteratorPrototypeTableValues[] =
111{
112 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeIteratorConstructor) } },
113 { "root", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorRoot), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
114 { "referenceNode", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorReferenceNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
115 { "pointerBeforeReferenceNode", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorPointerBeforeReferenceNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
116 { "whatToShow", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorWhatToShow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
117 { "filter", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorFilter), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
118 { "nextNode", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodeIteratorPrototypeFunctionNextNode), (intptr_t) (0) } },
119 { "previousNode", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodeIteratorPrototypeFunctionPreviousNode), (intptr_t) (0) } },
120 { "detach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodeIteratorPrototypeFunctionDetach), (intptr_t) (0) } },
121};
122
123const ClassInfo JSNodeIteratorPrototype::s_info = { "NodeIteratorPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeIteratorPrototype) };
124
125void JSNodeIteratorPrototype::finishCreation(VM& vm)
126{
127 Base::finishCreation(vm);
128 reifyStaticProperties(vm, JSNodeIterator::info(), JSNodeIteratorPrototypeTableValues, *this);
129}
130
131const ClassInfo JSNodeIterator::s_info = { "NodeIterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeIterator) };
132
133JSNodeIterator::JSNodeIterator(Structure* structure, JSDOMGlobalObject& globalObject, Ref<NodeIterator>&& impl)
134 : JSDOMWrapper<NodeIterator>(structure, globalObject, WTFMove(impl))
135{
136}
137
138void JSNodeIterator::finishCreation(VM& vm)
139{
140 Base::finishCreation(vm);
141 ASSERT(inherits(vm, info()));
142
143}
144
145JSObject* JSNodeIterator::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
146{
147 return JSNodeIteratorPrototype::create(vm, &globalObject, JSNodeIteratorPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
148}
149
150JSObject* JSNodeIterator::prototype(VM& vm, JSDOMGlobalObject& globalObject)
151{
152 return getDOMPrototype<JSNodeIterator>(vm, globalObject);
153}
154
155JSValue JSNodeIterator::getConstructor(VM& vm, const JSGlobalObject* globalObject)
156{
157 return getDOMConstructor<JSNodeIteratorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
158}
159
160void JSNodeIterator::destroy(JSC::JSCell* cell)
161{
162 JSNodeIterator* thisObject = static_cast<JSNodeIterator*>(cell);
163 thisObject->JSNodeIterator::~JSNodeIterator();
164}
165
166template<> inline JSNodeIterator* IDLAttribute<JSNodeIterator>::cast(ExecState& state, EncodedJSValue thisValue)
167{
168 return jsDynamicCast<JSNodeIterator*>(state.vm(), JSValue::decode(thisValue));
169}
170
171template<> inline JSNodeIterator* IDLOperation<JSNodeIterator>::cast(ExecState& state)
172{
173 return jsDynamicCast<JSNodeIterator*>(state.vm(), state.thisValue());
174}
175
176EncodedJSValue jsNodeIteratorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
177{
178 VM& vm = state->vm();
179 auto throwScope = DECLARE_THROW_SCOPE(vm);
180 auto* prototype = jsDynamicCast<JSNodeIteratorPrototype*>(vm, JSValue::decode(thisValue));
181 if (UNLIKELY(!prototype))
182 return throwVMTypeError(state, throwScope);
183 return JSValue::encode(JSNodeIterator::getConstructor(state->vm(), prototype->globalObject()));
184}
185
186bool setJSNodeIteratorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
187{
188 VM& vm = state->vm();
189 auto throwScope = DECLARE_THROW_SCOPE(vm);
190 auto* prototype = jsDynamicCast<JSNodeIteratorPrototype*>(vm, JSValue::decode(thisValue));
191 if (UNLIKELY(!prototype)) {
192 throwVMTypeError(state, throwScope);
193 return false;
194 }
195 // Shadowing a built-in constructor
196 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
197}
198
199static inline JSValue jsNodeIteratorRootGetter(ExecState& state, JSNodeIterator& thisObject, ThrowScope& throwScope)
200{
201 UNUSED_PARAM(throwScope);
202 UNUSED_PARAM(state);
203 auto& impl = thisObject.wrapped();
204 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.root());
205 return result;
206}
207
208EncodedJSValue jsNodeIteratorRoot(ExecState* state, EncodedJSValue thisValue, PropertyName)
209{
210 return IDLAttribute<JSNodeIterator>::get<jsNodeIteratorRootGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "root");
211}
212
213static inline JSValue jsNodeIteratorReferenceNodeGetter(ExecState& state, JSNodeIterator& thisObject, ThrowScope& throwScope)
214{
215 UNUSED_PARAM(throwScope);
216 UNUSED_PARAM(state);
217 auto& impl = thisObject.wrapped();
218 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.referenceNode());
219 return result;
220}
221
222EncodedJSValue jsNodeIteratorReferenceNode(ExecState* state, EncodedJSValue thisValue, PropertyName)
223{
224 return IDLAttribute<JSNodeIterator>::get<jsNodeIteratorReferenceNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "referenceNode");
225}
226
227static inline JSValue jsNodeIteratorPointerBeforeReferenceNodeGetter(ExecState& state, JSNodeIterator& thisObject, ThrowScope& throwScope)
228{
229 UNUSED_PARAM(throwScope);
230 UNUSED_PARAM(state);
231 auto& impl = thisObject.wrapped();
232 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.pointerBeforeReferenceNode());
233 return result;
234}
235
236EncodedJSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* state, EncodedJSValue thisValue, PropertyName)
237{
238 return IDLAttribute<JSNodeIterator>::get<jsNodeIteratorPointerBeforeReferenceNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pointerBeforeReferenceNode");
239}
240
241static inline JSValue jsNodeIteratorWhatToShowGetter(ExecState& state, JSNodeIterator& thisObject, ThrowScope& throwScope)
242{
243 UNUSED_PARAM(throwScope);
244 UNUSED_PARAM(state);
245 auto& impl = thisObject.wrapped();
246 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.whatToShow());
247 return result;
248}
249
250EncodedJSValue jsNodeIteratorWhatToShow(ExecState* state, EncodedJSValue thisValue, PropertyName)
251{
252 return IDLAttribute<JSNodeIterator>::get<jsNodeIteratorWhatToShowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "whatToShow");
253}
254
255static inline JSValue jsNodeIteratorFilterGetter(ExecState& state, JSNodeIterator& thisObject, ThrowScope& throwScope)
256{
257 UNUSED_PARAM(throwScope);
258 UNUSED_PARAM(state);
259 auto& impl = thisObject.wrapped();
260 JSValue result = toJS<IDLNullable<IDLCallbackInterface<JSNodeFilter>>>(state, *thisObject.globalObject(), throwScope, impl.filter());
261 return result;
262}
263
264EncodedJSValue jsNodeIteratorFilter(ExecState* state, EncodedJSValue thisValue, PropertyName)
265{
266 return IDLAttribute<JSNodeIterator>::get<jsNodeIteratorFilterGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "filter");
267}
268
269static inline JSC::EncodedJSValue jsNodeIteratorPrototypeFunctionNextNodeBody(JSC::ExecState* state, typename IDLOperation<JSNodeIterator>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
270{
271 UNUSED_PARAM(state);
272 UNUSED_PARAM(throwScope);
273 auto& impl = castedThis->wrapped();
274 return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.nextNode()));
275}
276
277EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionNextNode(ExecState* state)
278{
279 return IDLOperation<JSNodeIterator>::call<jsNodeIteratorPrototypeFunctionNextNodeBody>(*state, "nextNode");
280}
281
282static inline JSC::EncodedJSValue jsNodeIteratorPrototypeFunctionPreviousNodeBody(JSC::ExecState* state, typename IDLOperation<JSNodeIterator>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
283{
284 UNUSED_PARAM(state);
285 UNUSED_PARAM(throwScope);
286 auto& impl = castedThis->wrapped();
287 return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.previousNode()));
288}
289
290EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionPreviousNode(ExecState* state)
291{
292 return IDLOperation<JSNodeIterator>::call<jsNodeIteratorPrototypeFunctionPreviousNodeBody>(*state, "previousNode");
293}
294
295static inline JSC::EncodedJSValue jsNodeIteratorPrototypeFunctionDetachBody(JSC::ExecState* state, typename IDLOperation<JSNodeIterator>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
296{
297 UNUSED_PARAM(state);
298 UNUSED_PARAM(throwScope);
299 auto& impl = castedThis->wrapped();
300 impl.detach();
301 return JSValue::encode(jsUndefined());
302}
303
304EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(ExecState* state)
305{
306 return IDLOperation<JSNodeIterator>::call<jsNodeIteratorPrototypeFunctionDetachBody>(*state, "detach");
307}
308
309void JSNodeIterator::visitChildren(JSCell* cell, SlotVisitor& visitor)
310{
311 auto* thisObject = jsCast<JSNodeIterator*>(cell);
312 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
313 Base::visitChildren(thisObject, visitor);
314 thisObject->visitAdditionalChildren(visitor);
315}
316
317void JSNodeIterator::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor)
318{
319 auto* thisObject = jsCast<JSNodeIterator*>(cell);
320 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
321 Base::visitOutputConstraints(thisObject, visitor);
322 thisObject->visitAdditionalChildren(visitor);
323}
324
325void JSNodeIterator::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
326{
327 auto* thisObject = jsCast<JSNodeIterator*>(cell);
328 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
329 if (thisObject->scriptExecutionContext())
330 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
331 Base::heapSnapshot(cell, builder);
332}
333
334bool JSNodeIteratorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
335{
336 UNUSED_PARAM(handle);
337 UNUSED_PARAM(visitor);
338 UNUSED_PARAM(reason);
339 return false;
340}
341
342void JSNodeIteratorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
343{
344 auto* jsNodeIterator = static_cast<JSNodeIterator*>(handle.slot()->asCell());
345 auto& world = *static_cast<DOMWrapperWorld*>(context);
346 uncacheWrapper(world, &jsNodeIterator->wrapped(), jsNodeIterator);
347}
348
349JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<NodeIterator>&& impl)
350{
351 // If you hit this failure the interface definition has the ImplementationLacksVTable
352 // attribute. You should remove that attribute. If the class has subclasses
353 // that may be passed through this toJS() function you should use the SkipVTableValidation
354 // attribute to NodeIterator.
355 static_assert(!std::is_polymorphic<NodeIterator>::value, "NodeIterator is polymorphic but the IDL claims it is not");
356 return createWrapper<NodeIterator>(globalObject, WTFMove(impl));
357}
358
359JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, NodeIterator& impl)
360{
361 return wrap(state, globalObject, impl);
362}
363
364NodeIterator* JSNodeIterator::toWrapped(JSC::VM& vm, JSC::JSValue value)
365{
366 if (auto* wrapper = jsDynamicCast<JSNodeIterator*>(vm, value))
367 return &wrapper->wrapped();
368 return nullptr;
369}
370
371}
372