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 "JSXPathResult.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNumbers.h"
30#include "JSDOMConvertStrings.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMGlobalObject.h"
33#include "JSDOMOperation.h"
34#include "JSDOMWrapperCache.h"
35#include "JSNode.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/FunctionPrototype.h>
38#include <JavaScriptCore/HeapSnapshotBuilder.h>
39#include <JavaScriptCore/JSCInlines.h>
40#include <wtf/GetPtr.h>
41#include <wtf/PointerPreparations.h>
42#include <wtf/URL.h>
43
44
45namespace WebCore {
46using namespace JSC;
47
48// Functions
49
50JSC::EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionIterateNext(JSC::ExecState*);
51JSC::EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionSnapshotItem(JSC::ExecState*);
52
53// Attributes
54
55JSC::EncodedJSValue jsXPathResultConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56bool setJSXPathResultConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
57JSC::EncodedJSValue jsXPathResultResultType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58JSC::EncodedJSValue jsXPathResultNumberValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59JSC::EncodedJSValue jsXPathResultStringValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60JSC::EncodedJSValue jsXPathResultBooleanValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
61JSC::EncodedJSValue jsXPathResultSingleNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62JSC::EncodedJSValue jsXPathResultInvalidIteratorState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
63JSC::EncodedJSValue jsXPathResultSnapshotLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
64
65class JSXPathResultPrototype : public JSC::JSNonFinalObject {
66public:
67 using Base = JSC::JSNonFinalObject;
68 static JSXPathResultPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
69 {
70 JSXPathResultPrototype* ptr = new (NotNull, JSC::allocateCell<JSXPathResultPrototype>(vm.heap)) JSXPathResultPrototype(vm, globalObject, structure);
71 ptr->finishCreation(vm);
72 return ptr;
73 }
74
75 DECLARE_INFO;
76 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
77 {
78 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
79 }
80
81private:
82 JSXPathResultPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
83 : JSC::JSNonFinalObject(vm, structure)
84 {
85 }
86
87 void finishCreation(JSC::VM&);
88};
89
90using JSXPathResultConstructor = JSDOMConstructorNotConstructable<JSXPathResult>;
91
92/* Hash table for constructor */
93
94static const HashTableValue JSXPathResultConstructorTableValues[] =
95{
96 { "ANY_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
97 { "NUMBER_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
98 { "STRING_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
99 { "BOOLEAN_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
100 { "UNORDERED_NODE_ITERATOR_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
101 { "ORDERED_NODE_ITERATOR_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
102 { "UNORDERED_NODE_SNAPSHOT_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
103 { "ORDERED_NODE_SNAPSHOT_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
104 { "ANY_UNORDERED_NODE_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
105 { "FIRST_ORDERED_NODE_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
106};
107
108static_assert(XPathResult::ANY_TYPE == 0, "ANY_TYPE in XPathResult does not match value from IDL");
109static_assert(XPathResult::NUMBER_TYPE == 1, "NUMBER_TYPE in XPathResult does not match value from IDL");
110static_assert(XPathResult::STRING_TYPE == 2, "STRING_TYPE in XPathResult does not match value from IDL");
111static_assert(XPathResult::BOOLEAN_TYPE == 3, "BOOLEAN_TYPE in XPathResult does not match value from IDL");
112static_assert(XPathResult::UNORDERED_NODE_ITERATOR_TYPE == 4, "UNORDERED_NODE_ITERATOR_TYPE in XPathResult does not match value from IDL");
113static_assert(XPathResult::ORDERED_NODE_ITERATOR_TYPE == 5, "ORDERED_NODE_ITERATOR_TYPE in XPathResult does not match value from IDL");
114static_assert(XPathResult::UNORDERED_NODE_SNAPSHOT_TYPE == 6, "UNORDERED_NODE_SNAPSHOT_TYPE in XPathResult does not match value from IDL");
115static_assert(XPathResult::ORDERED_NODE_SNAPSHOT_TYPE == 7, "ORDERED_NODE_SNAPSHOT_TYPE in XPathResult does not match value from IDL");
116static_assert(XPathResult::ANY_UNORDERED_NODE_TYPE == 8, "ANY_UNORDERED_NODE_TYPE in XPathResult does not match value from IDL");
117static_assert(XPathResult::FIRST_ORDERED_NODE_TYPE == 9, "FIRST_ORDERED_NODE_TYPE in XPathResult does not match value from IDL");
118
119template<> JSValue JSXPathResultConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
120{
121 UNUSED_PARAM(vm);
122 return globalObject.functionPrototype();
123}
124
125template<> void JSXPathResultConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
126{
127 putDirect(vm, vm.propertyNames->prototype, JSXPathResult::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
128 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("XPathResult"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
129 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
130 reifyStaticProperties(vm, JSXPathResult::info(), JSXPathResultConstructorTableValues, *this);
131}
132
133template<> const ClassInfo JSXPathResultConstructor::s_info = { "XPathResult", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResultConstructor) };
134
135/* Hash table for prototype */
136
137static const HashTableValue JSXPathResultPrototypeTableValues[] =
138{
139 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSXPathResultConstructor) } },
140 { "resultType", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultResultType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
141 { "numberValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultNumberValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
142 { "stringValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultStringValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
143 { "booleanValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultBooleanValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
144 { "singleNodeValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultSingleNodeValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
145 { "invalidIteratorState", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultInvalidIteratorState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
146 { "snapshotLength", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathResultSnapshotLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
147 { "iterateNext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsXPathResultPrototypeFunctionIterateNext), (intptr_t) (0) } },
148 { "snapshotItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsXPathResultPrototypeFunctionSnapshotItem), (intptr_t) (0) } },
149 { "ANY_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
150 { "NUMBER_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
151 { "STRING_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
152 { "BOOLEAN_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
153 { "UNORDERED_NODE_ITERATOR_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
154 { "ORDERED_NODE_ITERATOR_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
155 { "UNORDERED_NODE_SNAPSHOT_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
156 { "ORDERED_NODE_SNAPSHOT_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
157 { "ANY_UNORDERED_NODE_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
158 { "FIRST_ORDERED_NODE_TYPE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
159};
160
161const ClassInfo JSXPathResultPrototype::s_info = { "XPathResultPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResultPrototype) };
162
163void JSXPathResultPrototype::finishCreation(VM& vm)
164{
165 Base::finishCreation(vm);
166 reifyStaticProperties(vm, JSXPathResult::info(), JSXPathResultPrototypeTableValues, *this);
167}
168
169const ClassInfo JSXPathResult::s_info = { "XPathResult", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResult) };
170
171JSXPathResult::JSXPathResult(Structure* structure, JSDOMGlobalObject& globalObject, Ref<XPathResult>&& impl)
172 : JSDOMWrapper<XPathResult>(structure, globalObject, WTFMove(impl))
173{
174}
175
176void JSXPathResult::finishCreation(VM& vm)
177{
178 Base::finishCreation(vm);
179 ASSERT(inherits(vm, info()));
180
181}
182
183JSObject* JSXPathResult::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
184{
185 return JSXPathResultPrototype::create(vm, &globalObject, JSXPathResultPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
186}
187
188JSObject* JSXPathResult::prototype(VM& vm, JSDOMGlobalObject& globalObject)
189{
190 return getDOMPrototype<JSXPathResult>(vm, globalObject);
191}
192
193JSValue JSXPathResult::getConstructor(VM& vm, const JSGlobalObject* globalObject)
194{
195 return getDOMConstructor<JSXPathResultConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
196}
197
198void JSXPathResult::destroy(JSC::JSCell* cell)
199{
200 JSXPathResult* thisObject = static_cast<JSXPathResult*>(cell);
201 thisObject->JSXPathResult::~JSXPathResult();
202}
203
204template<> inline JSXPathResult* IDLAttribute<JSXPathResult>::cast(ExecState& state, EncodedJSValue thisValue)
205{
206 return jsDynamicCast<JSXPathResult*>(state.vm(), JSValue::decode(thisValue));
207}
208
209template<> inline JSXPathResult* IDLOperation<JSXPathResult>::cast(ExecState& state)
210{
211 return jsDynamicCast<JSXPathResult*>(state.vm(), state.thisValue());
212}
213
214EncodedJSValue jsXPathResultConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
215{
216 VM& vm = state->vm();
217 auto throwScope = DECLARE_THROW_SCOPE(vm);
218 auto* prototype = jsDynamicCast<JSXPathResultPrototype*>(vm, JSValue::decode(thisValue));
219 if (UNLIKELY(!prototype))
220 return throwVMTypeError(state, throwScope);
221 return JSValue::encode(JSXPathResult::getConstructor(state->vm(), prototype->globalObject()));
222}
223
224bool setJSXPathResultConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
225{
226 VM& vm = state->vm();
227 auto throwScope = DECLARE_THROW_SCOPE(vm);
228 auto* prototype = jsDynamicCast<JSXPathResultPrototype*>(vm, JSValue::decode(thisValue));
229 if (UNLIKELY(!prototype)) {
230 throwVMTypeError(state, throwScope);
231 return false;
232 }
233 // Shadowing a built-in constructor
234 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
235}
236
237static inline JSValue jsXPathResultResultTypeGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
238{
239 UNUSED_PARAM(throwScope);
240 UNUSED_PARAM(state);
241 auto& impl = thisObject.wrapped();
242 JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.resultType());
243 return result;
244}
245
246EncodedJSValue jsXPathResultResultType(ExecState* state, EncodedJSValue thisValue, PropertyName)
247{
248 return IDLAttribute<JSXPathResult>::get<jsXPathResultResultTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "resultType");
249}
250
251static inline JSValue jsXPathResultNumberValueGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
252{
253 UNUSED_PARAM(throwScope);
254 UNUSED_PARAM(state);
255 auto& impl = thisObject.wrapped();
256 JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.numberValue());
257 return result;
258}
259
260EncodedJSValue jsXPathResultNumberValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
261{
262 return IDLAttribute<JSXPathResult>::get<jsXPathResultNumberValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "numberValue");
263}
264
265static inline JSValue jsXPathResultStringValueGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
266{
267 UNUSED_PARAM(throwScope);
268 UNUSED_PARAM(state);
269 auto& impl = thisObject.wrapped();
270 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.stringValue());
271 return result;
272}
273
274EncodedJSValue jsXPathResultStringValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
275{
276 return IDLAttribute<JSXPathResult>::get<jsXPathResultStringValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "stringValue");
277}
278
279static inline JSValue jsXPathResultBooleanValueGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
280{
281 UNUSED_PARAM(throwScope);
282 UNUSED_PARAM(state);
283 auto& impl = thisObject.wrapped();
284 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.booleanValue());
285 return result;
286}
287
288EncodedJSValue jsXPathResultBooleanValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
289{
290 return IDLAttribute<JSXPathResult>::get<jsXPathResultBooleanValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "booleanValue");
291}
292
293static inline JSValue jsXPathResultSingleNodeValueGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
294{
295 UNUSED_PARAM(throwScope);
296 UNUSED_PARAM(state);
297 auto& impl = thisObject.wrapped();
298 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.singleNodeValue());
299 return result;
300}
301
302EncodedJSValue jsXPathResultSingleNodeValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
303{
304 return IDLAttribute<JSXPathResult>::get<jsXPathResultSingleNodeValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "singleNodeValue");
305}
306
307static inline JSValue jsXPathResultInvalidIteratorStateGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
308{
309 UNUSED_PARAM(throwScope);
310 UNUSED_PARAM(state);
311 auto& impl = thisObject.wrapped();
312 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.invalidIteratorState());
313 return result;
314}
315
316EncodedJSValue jsXPathResultInvalidIteratorState(ExecState* state, EncodedJSValue thisValue, PropertyName)
317{
318 return IDLAttribute<JSXPathResult>::get<jsXPathResultInvalidIteratorStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "invalidIteratorState");
319}
320
321static inline JSValue jsXPathResultSnapshotLengthGetter(ExecState& state, JSXPathResult& thisObject, ThrowScope& throwScope)
322{
323 UNUSED_PARAM(throwScope);
324 UNUSED_PARAM(state);
325 auto& impl = thisObject.wrapped();
326 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.snapshotLength());
327 return result;
328}
329
330EncodedJSValue jsXPathResultSnapshotLength(ExecState* state, EncodedJSValue thisValue, PropertyName)
331{
332 return IDLAttribute<JSXPathResult>::get<jsXPathResultSnapshotLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "snapshotLength");
333}
334
335static inline JSC::EncodedJSValue jsXPathResultPrototypeFunctionIterateNextBody(JSC::ExecState* state, typename IDLOperation<JSXPathResult>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
336{
337 UNUSED_PARAM(state);
338 UNUSED_PARAM(throwScope);
339 auto& impl = castedThis->wrapped();
340 return JSValue::encode(toJS<IDLInterface<Node>>(*state, *castedThis->globalObject(), throwScope, impl.iterateNext()));
341}
342
343EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionIterateNext(ExecState* state)
344{
345 return IDLOperation<JSXPathResult>::call<jsXPathResultPrototypeFunctionIterateNextBody>(*state, "iterateNext");
346}
347
348static inline JSC::EncodedJSValue jsXPathResultPrototypeFunctionSnapshotItemBody(JSC::ExecState* state, typename IDLOperation<JSXPathResult>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
349{
350 UNUSED_PARAM(state);
351 UNUSED_PARAM(throwScope);
352 auto& impl = castedThis->wrapped();
353 auto index = convert<IDLUnsignedLong>(*state, state->argument(0));
354 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
355 return JSValue::encode(toJS<IDLInterface<Node>>(*state, *castedThis->globalObject(), throwScope, impl.snapshotItem(WTFMove(index))));
356}
357
358EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionSnapshotItem(ExecState* state)
359{
360 return IDLOperation<JSXPathResult>::call<jsXPathResultPrototypeFunctionSnapshotItemBody>(*state, "snapshotItem");
361}
362
363void JSXPathResult::visitChildren(JSCell* cell, SlotVisitor& visitor)
364{
365 auto* thisObject = jsCast<JSXPathResult*>(cell);
366 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
367 Base::visitChildren(thisObject, visitor);
368 thisObject->visitAdditionalChildren(visitor);
369}
370
371void JSXPathResult::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor)
372{
373 auto* thisObject = jsCast<JSXPathResult*>(cell);
374 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
375 Base::visitOutputConstraints(thisObject, visitor);
376 thisObject->visitAdditionalChildren(visitor);
377}
378
379void JSXPathResult::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
380{
381 auto* thisObject = jsCast<JSXPathResult*>(cell);
382 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
383 if (thisObject->scriptExecutionContext())
384 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
385 Base::heapSnapshot(cell, builder);
386}
387
388bool JSXPathResultOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
389{
390 UNUSED_PARAM(handle);
391 UNUSED_PARAM(visitor);
392 UNUSED_PARAM(reason);
393 return false;
394}
395
396void JSXPathResultOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
397{
398 auto* jsXPathResult = static_cast<JSXPathResult*>(handle.slot()->asCell());
399 auto& world = *static_cast<DOMWrapperWorld*>(context);
400 uncacheWrapper(world, &jsXPathResult->wrapped(), jsXPathResult);
401}
402
403JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<XPathResult>&& impl)
404{
405 // If you hit this failure the interface definition has the ImplementationLacksVTable
406 // attribute. You should remove that attribute. If the class has subclasses
407 // that may be passed through this toJS() function you should use the SkipVTableValidation
408 // attribute to XPathResult.
409 static_assert(!std::is_polymorphic<XPathResult>::value, "XPathResult is polymorphic but the IDL claims it is not");
410 return createWrapper<XPathResult>(globalObject, WTFMove(impl));
411}
412
413JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, XPathResult& impl)
414{
415 return wrap(state, globalObject, impl);
416}
417
418XPathResult* JSXPathResult::toWrapped(JSC::VM& vm, JSC::JSValue value)
419{
420 if (auto* wrapper = jsDynamicCast<JSXPathResult*>(vm, value))
421 return &wrapper->wrapped();
422 return nullptr;
423}
424
425}
426