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 "JSXPathExpression.h"
23
24#include "JSDOMBinding.h"
25#include "JSDOMConstructorNotConstructable.h"
26#include "JSDOMConvertInterface.h"
27#include "JSDOMConvertNullable.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "JSNode.h"
34#include "JSXPathResult.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/FunctionPrototype.h>
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.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// Functions
48
49JSC::EncodedJSValue JSC_HOST_CALL jsXPathExpressionPrototypeFunctionEvaluate(JSC::ExecState*);
50
51// Attributes
52
53JSC::EncodedJSValue jsXPathExpressionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSXPathExpressionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55
56class JSXPathExpressionPrototype : public JSC::JSNonFinalObject {
57public:
58 using Base = JSC::JSNonFinalObject;
59 static JSXPathExpressionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
60 {
61 JSXPathExpressionPrototype* ptr = new (NotNull, JSC::allocateCell<JSXPathExpressionPrototype>(vm.heap)) JSXPathExpressionPrototype(vm, globalObject, structure);
62 ptr->finishCreation(vm);
63 return ptr;
64 }
65
66 DECLARE_INFO;
67 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
68 {
69 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
70 }
71
72private:
73 JSXPathExpressionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
74 : JSC::JSNonFinalObject(vm, structure)
75 {
76 }
77
78 void finishCreation(JSC::VM&);
79};
80
81using JSXPathExpressionConstructor = JSDOMConstructorNotConstructable<JSXPathExpression>;
82
83template<> JSValue JSXPathExpressionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
84{
85 UNUSED_PARAM(vm);
86 return globalObject.functionPrototype();
87}
88
89template<> void JSXPathExpressionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
90{
91 putDirect(vm, vm.propertyNames->prototype, JSXPathExpression::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("XPathExpression"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94}
95
96template<> const ClassInfo JSXPathExpressionConstructor::s_info = { "XPathExpression", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathExpressionConstructor) };
97
98/* Hash table for prototype */
99
100static const HashTableValue JSXPathExpressionPrototypeTableValues[] =
101{
102 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathExpressionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSXPathExpressionConstructor) } },
103 { "evaluate", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsXPathExpressionPrototypeFunctionEvaluate), (intptr_t) (0) } },
104};
105
106const ClassInfo JSXPathExpressionPrototype::s_info = { "XPathExpressionPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathExpressionPrototype) };
107
108void JSXPathExpressionPrototype::finishCreation(VM& vm)
109{
110 Base::finishCreation(vm);
111 reifyStaticProperties(vm, JSXPathExpression::info(), JSXPathExpressionPrototypeTableValues, *this);
112}
113
114const ClassInfo JSXPathExpression::s_info = { "XPathExpression", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXPathExpression) };
115
116JSXPathExpression::JSXPathExpression(Structure* structure, JSDOMGlobalObject& globalObject, Ref<XPathExpression>&& impl)
117 : JSDOMWrapper<XPathExpression>(structure, globalObject, WTFMove(impl))
118{
119}
120
121void JSXPathExpression::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 ASSERT(inherits(vm, info()));
125
126}
127
128JSObject* JSXPathExpression::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
129{
130 return JSXPathExpressionPrototype::create(vm, &globalObject, JSXPathExpressionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
131}
132
133JSObject* JSXPathExpression::prototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return getDOMPrototype<JSXPathExpression>(vm, globalObject);
136}
137
138JSValue JSXPathExpression::getConstructor(VM& vm, const JSGlobalObject* globalObject)
139{
140 return getDOMConstructor<JSXPathExpressionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
141}
142
143void JSXPathExpression::destroy(JSC::JSCell* cell)
144{
145 JSXPathExpression* thisObject = static_cast<JSXPathExpression*>(cell);
146 thisObject->JSXPathExpression::~JSXPathExpression();
147}
148
149template<> inline JSXPathExpression* IDLOperation<JSXPathExpression>::cast(ExecState& state)
150{
151 return jsDynamicCast<JSXPathExpression*>(state.vm(), state.thisValue());
152}
153
154EncodedJSValue jsXPathExpressionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
155{
156 VM& vm = state->vm();
157 auto throwScope = DECLARE_THROW_SCOPE(vm);
158 auto* prototype = jsDynamicCast<JSXPathExpressionPrototype*>(vm, JSValue::decode(thisValue));
159 if (UNLIKELY(!prototype))
160 return throwVMTypeError(state, throwScope);
161 return JSValue::encode(JSXPathExpression::getConstructor(state->vm(), prototype->globalObject()));
162}
163
164bool setJSXPathExpressionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
165{
166 VM& vm = state->vm();
167 auto throwScope = DECLARE_THROW_SCOPE(vm);
168 auto* prototype = jsDynamicCast<JSXPathExpressionPrototype*>(vm, JSValue::decode(thisValue));
169 if (UNLIKELY(!prototype)) {
170 throwVMTypeError(state, throwScope);
171 return false;
172 }
173 // Shadowing a built-in constructor
174 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
175}
176
177static inline JSC::EncodedJSValue jsXPathExpressionPrototypeFunctionEvaluateBody(JSC::ExecState* state, typename IDLOperation<JSXPathExpression>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
178{
179 UNUSED_PARAM(state);
180 UNUSED_PARAM(throwScope);
181 auto& impl = castedThis->wrapped();
182 auto contextNode = convert<IDLNullable<IDLInterface<Node>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "contextNode", "XPathExpression", "evaluate", "Node"); });
183 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
184 auto type = convert<IDLUnsignedShort>(*state, state->argument(1));
185 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
186 auto inResult = convert<IDLNullable<IDLInterface<XPathResult>>>(*state, state->argument(2), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 2, "inResult", "XPathExpression", "evaluate", "XPathResult"); });
187 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
188 return JSValue::encode(toJS<IDLInterface<XPathResult>>(*state, *castedThis->globalObject(), throwScope, impl.evaluate(WTFMove(contextNode), WTFMove(type), WTFMove(inResult))));
189}
190
191EncodedJSValue JSC_HOST_CALL jsXPathExpressionPrototypeFunctionEvaluate(ExecState* state)
192{
193 return IDLOperation<JSXPathExpression>::call<jsXPathExpressionPrototypeFunctionEvaluateBody>(*state, "evaluate");
194}
195
196void JSXPathExpression::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
197{
198 auto* thisObject = jsCast<JSXPathExpression*>(cell);
199 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
200 if (thisObject->scriptExecutionContext())
201 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
202 Base::heapSnapshot(cell, builder);
203}
204
205bool JSXPathExpressionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
206{
207 UNUSED_PARAM(handle);
208 UNUSED_PARAM(visitor);
209 UNUSED_PARAM(reason);
210 return false;
211}
212
213void JSXPathExpressionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
214{
215 auto* jsXPathExpression = static_cast<JSXPathExpression*>(handle.slot()->asCell());
216 auto& world = *static_cast<DOMWrapperWorld*>(context);
217 uncacheWrapper(world, &jsXPathExpression->wrapped(), jsXPathExpression);
218}
219
220JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<XPathExpression>&& impl)
221{
222 // If you hit this failure the interface definition has the ImplementationLacksVTable
223 // attribute. You should remove that attribute. If the class has subclasses
224 // that may be passed through this toJS() function you should use the SkipVTableValidation
225 // attribute to XPathExpression.
226 static_assert(!std::is_polymorphic<XPathExpression>::value, "XPathExpression is polymorphic but the IDL claims it is not");
227 return createWrapper<XPathExpression>(globalObject, WTFMove(impl));
228}
229
230JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, XPathExpression& impl)
231{
232 return wrap(state, globalObject, impl);
233}
234
235XPathExpression* JSXPathExpression::toWrapped(JSC::VM& vm, JSC::JSValue value)
236{
237 if (auto* wrapper = jsDynamicCast<JSXPathExpression*>(vm, value))
238 return &wrapper->wrapped();
239 return nullptr;
240}
241
242}
243