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