| 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 | |
| 45 | namespace WebCore { |
| 46 | using namespace JSC; |
| 47 | |
| 48 | // Functions |
| 49 | |
| 50 | JSC::EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionIterateNext(JSC::ExecState*); |
| 51 | JSC::EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionSnapshotItem(JSC::ExecState*); |
| 52 | |
| 53 | // Attributes |
| 54 | |
| 55 | JSC::EncodedJSValue jsXPathResultConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 56 | bool setJSXPathResultConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 57 | JSC::EncodedJSValue jsXPathResultResultType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 58 | JSC::EncodedJSValue jsXPathResultNumberValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | JSC::EncodedJSValue jsXPathResultStringValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | JSC::EncodedJSValue jsXPathResultBooleanValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsXPathResultSingleNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsXPathResultInvalidIteratorState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | JSC::EncodedJSValue jsXPathResultSnapshotLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | |
| 65 | class JSXPathResultPrototype : public JSC::JSNonFinalObject { |
| 66 | public: |
| 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 | |
| 81 | private: |
| 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 | |
| 90 | using JSXPathResultConstructor = JSDOMConstructorNotConstructable<JSXPathResult>; |
| 91 | |
| 92 | /* Hash table for constructor */ |
| 93 | |
| 94 | static 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 | |
| 108 | static_assert(XPathResult::ANY_TYPE == 0, "ANY_TYPE in XPathResult does not match value from IDL" ); |
| 109 | static_assert(XPathResult::NUMBER_TYPE == 1, "NUMBER_TYPE in XPathResult does not match value from IDL" ); |
| 110 | static_assert(XPathResult::STRING_TYPE == 2, "STRING_TYPE in XPathResult does not match value from IDL" ); |
| 111 | static_assert(XPathResult::BOOLEAN_TYPE == 3, "BOOLEAN_TYPE in XPathResult does not match value from IDL" ); |
| 112 | static_assert(XPathResult::UNORDERED_NODE_ITERATOR_TYPE == 4, "UNORDERED_NODE_ITERATOR_TYPE in XPathResult does not match value from IDL" ); |
| 113 | static_assert(XPathResult::ORDERED_NODE_ITERATOR_TYPE == 5, "ORDERED_NODE_ITERATOR_TYPE in XPathResult does not match value from IDL" ); |
| 114 | static_assert(XPathResult::UNORDERED_NODE_SNAPSHOT_TYPE == 6, "UNORDERED_NODE_SNAPSHOT_TYPE in XPathResult does not match value from IDL" ); |
| 115 | static_assert(XPathResult::ORDERED_NODE_SNAPSHOT_TYPE == 7, "ORDERED_NODE_SNAPSHOT_TYPE in XPathResult does not match value from IDL" ); |
| 116 | static_assert(XPathResult::ANY_UNORDERED_NODE_TYPE == 8, "ANY_UNORDERED_NODE_TYPE in XPathResult does not match value from IDL" ); |
| 117 | static_assert(XPathResult::FIRST_ORDERED_NODE_TYPE == 9, "FIRST_ORDERED_NODE_TYPE in XPathResult does not match value from IDL" ); |
| 118 | |
| 119 | template<> JSValue JSXPathResultConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 120 | { |
| 121 | UNUSED_PARAM(vm); |
| 122 | return globalObject.functionPrototype(); |
| 123 | } |
| 124 | |
| 125 | template<> 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 | |
| 133 | template<> const ClassInfo JSXPathResultConstructor::s_info = { "XPathResult" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResultConstructor) }; |
| 134 | |
| 135 | /* Hash table for prototype */ |
| 136 | |
| 137 | static 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 | |
| 161 | const ClassInfo JSXPathResultPrototype::s_info = { "XPathResultPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResultPrototype) }; |
| 162 | |
| 163 | void JSXPathResultPrototype::finishCreation(VM& vm) |
| 164 | { |
| 165 | Base::finishCreation(vm); |
| 166 | reifyStaticProperties(vm, JSXPathResult::info(), JSXPathResultPrototypeTableValues, *this); |
| 167 | } |
| 168 | |
| 169 | const ClassInfo JSXPathResult::s_info = { "XPathResult" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathResult) }; |
| 170 | |
| 171 | JSXPathResult::JSXPathResult(Structure* structure, JSDOMGlobalObject& globalObject, Ref<XPathResult>&& impl) |
| 172 | : JSDOMWrapper<XPathResult>(structure, globalObject, WTFMove(impl)) |
| 173 | { |
| 174 | } |
| 175 | |
| 176 | void JSXPathResult::finishCreation(VM& vm) |
| 177 | { |
| 178 | Base::finishCreation(vm); |
| 179 | ASSERT(inherits(vm, info())); |
| 180 | |
| 181 | } |
| 182 | |
| 183 | JSObject* JSXPathResult::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 184 | { |
| 185 | return JSXPathResultPrototype::create(vm, &globalObject, JSXPathResultPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 186 | } |
| 187 | |
| 188 | JSObject* JSXPathResult::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 189 | { |
| 190 | return getDOMPrototype<JSXPathResult>(vm, globalObject); |
| 191 | } |
| 192 | |
| 193 | JSValue JSXPathResult::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 194 | { |
| 195 | return getDOMConstructor<JSXPathResultConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 196 | } |
| 197 | |
| 198 | void JSXPathResult::destroy(JSC::JSCell* cell) |
| 199 | { |
| 200 | JSXPathResult* thisObject = static_cast<JSXPathResult*>(cell); |
| 201 | thisObject->JSXPathResult::~JSXPathResult(); |
| 202 | } |
| 203 | |
| 204 | template<> inline JSXPathResult* IDLAttribute<JSXPathResult>::cast(ExecState& state, EncodedJSValue thisValue) |
| 205 | { |
| 206 | return jsDynamicCast<JSXPathResult*>(state.vm(), JSValue::decode(thisValue)); |
| 207 | } |
| 208 | |
| 209 | template<> inline JSXPathResult* IDLOperation<JSXPathResult>::cast(ExecState& state) |
| 210 | { |
| 211 | return jsDynamicCast<JSXPathResult*>(state.vm(), state.thisValue()); |
| 212 | } |
| 213 | |
| 214 | EncodedJSValue 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 | |
| 224 | bool 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 | |
| 237 | static 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 | |
| 246 | EncodedJSValue jsXPathResultResultType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 247 | { |
| 248 | return IDLAttribute<JSXPathResult>::get<jsXPathResultResultTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "resultType" ); |
| 249 | } |
| 250 | |
| 251 | static 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 | |
| 260 | EncodedJSValue jsXPathResultNumberValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 261 | { |
| 262 | return IDLAttribute<JSXPathResult>::get<jsXPathResultNumberValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "numberValue" ); |
| 263 | } |
| 264 | |
| 265 | static 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 | |
| 274 | EncodedJSValue jsXPathResultStringValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 275 | { |
| 276 | return IDLAttribute<JSXPathResult>::get<jsXPathResultStringValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "stringValue" ); |
| 277 | } |
| 278 | |
| 279 | static 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 | |
| 288 | EncodedJSValue jsXPathResultBooleanValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 289 | { |
| 290 | return IDLAttribute<JSXPathResult>::get<jsXPathResultBooleanValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "booleanValue" ); |
| 291 | } |
| 292 | |
| 293 | static 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 | |
| 302 | EncodedJSValue jsXPathResultSingleNodeValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 303 | { |
| 304 | return IDLAttribute<JSXPathResult>::get<jsXPathResultSingleNodeValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "singleNodeValue" ); |
| 305 | } |
| 306 | |
| 307 | static 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 | |
| 316 | EncodedJSValue jsXPathResultInvalidIteratorState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 317 | { |
| 318 | return IDLAttribute<JSXPathResult>::get<jsXPathResultInvalidIteratorStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "invalidIteratorState" ); |
| 319 | } |
| 320 | |
| 321 | static 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 | |
| 330 | EncodedJSValue jsXPathResultSnapshotLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 331 | { |
| 332 | return IDLAttribute<JSXPathResult>::get<jsXPathResultSnapshotLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "snapshotLength" ); |
| 333 | } |
| 334 | |
| 335 | static 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 | |
| 343 | EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionIterateNext(ExecState* state) |
| 344 | { |
| 345 | return IDLOperation<JSXPathResult>::call<jsXPathResultPrototypeFunctionIterateNextBody>(*state, "iterateNext" ); |
| 346 | } |
| 347 | |
| 348 | static 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 | |
| 358 | EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionSnapshotItem(ExecState* state) |
| 359 | { |
| 360 | return IDLOperation<JSXPathResult>::call<jsXPathResultPrototypeFunctionSnapshotItemBody>(*state, "snapshotItem" ); |
| 361 | } |
| 362 | |
| 363 | void 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 | |
| 371 | void 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 | |
| 379 | void 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 | |
| 388 | bool 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 | |
| 396 | void 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 | |
| 403 | JSC::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 | |
| 413 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, XPathResult& impl) |
| 414 | { |
| 415 | return wrap(state, globalObject, impl); |
| 416 | } |
| 417 | |
| 418 | XPathResult* 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 | |