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 "JSSVGRect.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertNumbers.h" |
28 | #include "JSDOMExceptionHandling.h" |
29 | #include "JSDOMWrapperCache.h" |
30 | #include "ScriptExecutionContext.h" |
31 | #include <JavaScriptCore/FunctionPrototype.h> |
32 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
33 | #include <JavaScriptCore/JSCInlines.h> |
34 | #include <wtf/GetPtr.h> |
35 | #include <wtf/PointerPreparations.h> |
36 | #include <wtf/URL.h> |
37 | |
38 | |
39 | namespace WebCore { |
40 | using namespace JSC; |
41 | |
42 | // Attributes |
43 | |
44 | JSC::EncodedJSValue jsSVGRectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
45 | bool setJSSVGRectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
46 | JSC::EncodedJSValue jsSVGRectX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
47 | bool setJSSVGRectX(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
48 | JSC::EncodedJSValue jsSVGRectY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
49 | bool setJSSVGRectY(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
50 | JSC::EncodedJSValue jsSVGRectWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | bool setJSSVGRectWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
52 | JSC::EncodedJSValue jsSVGRectHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
53 | bool setJSSVGRectHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
54 | |
55 | class JSSVGRectPrototype : public JSC::JSNonFinalObject { |
56 | public: |
57 | using Base = JSC::JSNonFinalObject; |
58 | static JSSVGRectPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
59 | { |
60 | JSSVGRectPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGRectPrototype>(vm.heap)) JSSVGRectPrototype(vm, globalObject, structure); |
61 | ptr->finishCreation(vm); |
62 | return ptr; |
63 | } |
64 | |
65 | DECLARE_INFO; |
66 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
67 | { |
68 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
69 | } |
70 | |
71 | private: |
72 | JSSVGRectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
73 | : JSC::JSNonFinalObject(vm, structure) |
74 | { |
75 | } |
76 | |
77 | void finishCreation(JSC::VM&); |
78 | }; |
79 | |
80 | using JSSVGRectConstructor = JSDOMConstructorNotConstructable<JSSVGRect>; |
81 | |
82 | template<> JSValue JSSVGRectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
83 | { |
84 | UNUSED_PARAM(vm); |
85 | return globalObject.functionPrototype(); |
86 | } |
87 | |
88 | template<> void JSSVGRectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
89 | { |
90 | putDirect(vm, vm.propertyNames->prototype, JSSVGRect::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
91 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGRect"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
92 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
93 | } |
94 | |
95 | template<> const ClassInfo JSSVGRectConstructor::s_info = { "SVGRect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGRectConstructor) }; |
96 | |
97 | /* Hash table for prototype */ |
98 | |
99 | static const HashTableValue JSSVGRectPrototypeTableValues[] = |
100 | { |
101 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGRectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGRectConstructor) } }, |
102 | { "x" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGRectX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGRectX) } }, |
103 | { "y" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGRectY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGRectY) } }, |
104 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGRectWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGRectWidth) } }, |
105 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGRectHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGRectHeight) } }, |
106 | }; |
107 | |
108 | const ClassInfo JSSVGRectPrototype::s_info = { "SVGRectPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGRectPrototype) }; |
109 | |
110 | void JSSVGRectPrototype::finishCreation(VM& vm) |
111 | { |
112 | Base::finishCreation(vm); |
113 | reifyStaticProperties(vm, JSSVGRect::info(), JSSVGRectPrototypeTableValues, *this); |
114 | } |
115 | |
116 | const ClassInfo JSSVGRect::s_info = { "SVGRect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGRect) }; |
117 | |
118 | JSSVGRect::JSSVGRect(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGRect>&& impl) |
119 | : JSDOMWrapper<SVGRect>(structure, globalObject, WTFMove(impl)) |
120 | { |
121 | } |
122 | |
123 | void JSSVGRect::finishCreation(VM& vm) |
124 | { |
125 | Base::finishCreation(vm); |
126 | ASSERT(inherits(vm, info())); |
127 | |
128 | } |
129 | |
130 | JSObject* JSSVGRect::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
131 | { |
132 | return JSSVGRectPrototype::create(vm, &globalObject, JSSVGRectPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
133 | } |
134 | |
135 | JSObject* JSSVGRect::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return getDOMPrototype<JSSVGRect>(vm, globalObject); |
138 | } |
139 | |
140 | JSValue JSSVGRect::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
141 | { |
142 | return getDOMConstructor<JSSVGRectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
143 | } |
144 | |
145 | void JSSVGRect::destroy(JSC::JSCell* cell) |
146 | { |
147 | JSSVGRect* thisObject = static_cast<JSSVGRect*>(cell); |
148 | thisObject->JSSVGRect::~JSSVGRect(); |
149 | } |
150 | |
151 | template<> inline JSSVGRect* IDLAttribute<JSSVGRect>::cast(ExecState& state, EncodedJSValue thisValue) |
152 | { |
153 | return jsDynamicCast<JSSVGRect*>(state.vm(), JSValue::decode(thisValue)); |
154 | } |
155 | |
156 | EncodedJSValue jsSVGRectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
157 | { |
158 | VM& vm = state->vm(); |
159 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
160 | auto* prototype = jsDynamicCast<JSSVGRectPrototype*>(vm, JSValue::decode(thisValue)); |
161 | if (UNLIKELY(!prototype)) |
162 | return throwVMTypeError(state, throwScope); |
163 | return JSValue::encode(JSSVGRect::getConstructor(state->vm(), prototype->globalObject())); |
164 | } |
165 | |
166 | bool setJSSVGRectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
167 | { |
168 | VM& vm = state->vm(); |
169 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
170 | auto* prototype = jsDynamicCast<JSSVGRectPrototype*>(vm, JSValue::decode(thisValue)); |
171 | if (UNLIKELY(!prototype)) { |
172 | throwVMTypeError(state, throwScope); |
173 | return false; |
174 | } |
175 | // Shadowing a built-in constructor |
176 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
177 | } |
178 | |
179 | static inline JSValue jsSVGRectXGetter(ExecState& state, JSSVGRect& thisObject, ThrowScope& throwScope) |
180 | { |
181 | UNUSED_PARAM(throwScope); |
182 | UNUSED_PARAM(state); |
183 | auto& impl = thisObject.wrapped(); |
184 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.x()); |
185 | return result; |
186 | } |
187 | |
188 | EncodedJSValue jsSVGRectX(ExecState* state, EncodedJSValue thisValue, PropertyName) |
189 | { |
190 | return IDLAttribute<JSSVGRect>::get<jsSVGRectXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x" ); |
191 | } |
192 | |
193 | static inline bool setJSSVGRectXSetter(ExecState& state, JSSVGRect& thisObject, JSValue value, ThrowScope& throwScope) |
194 | { |
195 | UNUSED_PARAM(throwScope); |
196 | auto& impl = thisObject.wrapped(); |
197 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
198 | RETURN_IF_EXCEPTION(throwScope, false); |
199 | AttributeSetter::call(state, throwScope, [&] { |
200 | return impl.setX(WTFMove(nativeValue)); |
201 | }); |
202 | return true; |
203 | } |
204 | |
205 | bool setJSSVGRectX(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
206 | { |
207 | return IDLAttribute<JSSVGRect>::set<setJSSVGRectXSetter>(*state, thisValue, encodedValue, "x" ); |
208 | } |
209 | |
210 | static inline JSValue jsSVGRectYGetter(ExecState& state, JSSVGRect& thisObject, ThrowScope& throwScope) |
211 | { |
212 | UNUSED_PARAM(throwScope); |
213 | UNUSED_PARAM(state); |
214 | auto& impl = thisObject.wrapped(); |
215 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.y()); |
216 | return result; |
217 | } |
218 | |
219 | EncodedJSValue jsSVGRectY(ExecState* state, EncodedJSValue thisValue, PropertyName) |
220 | { |
221 | return IDLAttribute<JSSVGRect>::get<jsSVGRectYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y" ); |
222 | } |
223 | |
224 | static inline bool setJSSVGRectYSetter(ExecState& state, JSSVGRect& thisObject, JSValue value, ThrowScope& throwScope) |
225 | { |
226 | UNUSED_PARAM(throwScope); |
227 | auto& impl = thisObject.wrapped(); |
228 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
229 | RETURN_IF_EXCEPTION(throwScope, false); |
230 | AttributeSetter::call(state, throwScope, [&] { |
231 | return impl.setY(WTFMove(nativeValue)); |
232 | }); |
233 | return true; |
234 | } |
235 | |
236 | bool setJSSVGRectY(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
237 | { |
238 | return IDLAttribute<JSSVGRect>::set<setJSSVGRectYSetter>(*state, thisValue, encodedValue, "y" ); |
239 | } |
240 | |
241 | static inline JSValue jsSVGRectWidthGetter(ExecState& state, JSSVGRect& thisObject, ThrowScope& throwScope) |
242 | { |
243 | UNUSED_PARAM(throwScope); |
244 | UNUSED_PARAM(state); |
245 | auto& impl = thisObject.wrapped(); |
246 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.width()); |
247 | return result; |
248 | } |
249 | |
250 | EncodedJSValue jsSVGRectWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
251 | { |
252 | return IDLAttribute<JSSVGRect>::get<jsSVGRectWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
253 | } |
254 | |
255 | static inline bool setJSSVGRectWidthSetter(ExecState& state, JSSVGRect& thisObject, JSValue value, ThrowScope& throwScope) |
256 | { |
257 | UNUSED_PARAM(throwScope); |
258 | auto& impl = thisObject.wrapped(); |
259 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
260 | RETURN_IF_EXCEPTION(throwScope, false); |
261 | AttributeSetter::call(state, throwScope, [&] { |
262 | return impl.setWidth(WTFMove(nativeValue)); |
263 | }); |
264 | return true; |
265 | } |
266 | |
267 | bool setJSSVGRectWidth(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
268 | { |
269 | return IDLAttribute<JSSVGRect>::set<setJSSVGRectWidthSetter>(*state, thisValue, encodedValue, "width" ); |
270 | } |
271 | |
272 | static inline JSValue jsSVGRectHeightGetter(ExecState& state, JSSVGRect& thisObject, ThrowScope& throwScope) |
273 | { |
274 | UNUSED_PARAM(throwScope); |
275 | UNUSED_PARAM(state); |
276 | auto& impl = thisObject.wrapped(); |
277 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.height()); |
278 | return result; |
279 | } |
280 | |
281 | EncodedJSValue jsSVGRectHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
282 | { |
283 | return IDLAttribute<JSSVGRect>::get<jsSVGRectHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
284 | } |
285 | |
286 | static inline bool setJSSVGRectHeightSetter(ExecState& state, JSSVGRect& thisObject, JSValue value, ThrowScope& throwScope) |
287 | { |
288 | UNUSED_PARAM(throwScope); |
289 | auto& impl = thisObject.wrapped(); |
290 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
291 | RETURN_IF_EXCEPTION(throwScope, false); |
292 | AttributeSetter::call(state, throwScope, [&] { |
293 | return impl.setHeight(WTFMove(nativeValue)); |
294 | }); |
295 | return true; |
296 | } |
297 | |
298 | bool setJSSVGRectHeight(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
299 | { |
300 | return IDLAttribute<JSSVGRect>::set<setJSSVGRectHeightSetter>(*state, thisValue, encodedValue, "height" ); |
301 | } |
302 | |
303 | void JSSVGRect::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
304 | { |
305 | auto* thisObject = jsCast<JSSVGRect*>(cell); |
306 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
307 | if (thisObject->scriptExecutionContext()) |
308 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
309 | Base::heapSnapshot(cell, builder); |
310 | } |
311 | |
312 | bool JSSVGRectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
313 | { |
314 | UNUSED_PARAM(handle); |
315 | UNUSED_PARAM(visitor); |
316 | UNUSED_PARAM(reason); |
317 | return false; |
318 | } |
319 | |
320 | void JSSVGRectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
321 | { |
322 | auto* jsSVGRect = static_cast<JSSVGRect*>(handle.slot()->asCell()); |
323 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
324 | uncacheWrapper(world, &jsSVGRect->wrapped(), jsSVGRect); |
325 | } |
326 | |
327 | #if ENABLE(BINDING_INTEGRITY) |
328 | #if PLATFORM(WIN) |
329 | #pragma warning(disable: 4483) |
330 | extern "C" { extern void (*const __identifier("??_7SVGRect@WebCore@@6B@" )[])(); } |
331 | #else |
332 | extern "C" { extern void* _ZTVN7WebCore7SVGRectE[]; } |
333 | #endif |
334 | #endif |
335 | |
336 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGRect>&& impl) |
337 | { |
338 | |
339 | #if ENABLE(BINDING_INTEGRITY) |
340 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
341 | #if PLATFORM(WIN) |
342 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SVGRect@WebCore@@6B@" )); |
343 | #else |
344 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore7SVGRectE[2]); |
345 | #endif |
346 | |
347 | // If this fails SVGRect does not have a vtable, so you need to add the |
348 | // ImplementationLacksVTable attribute to the interface definition |
349 | static_assert(std::is_polymorphic<SVGRect>::value, "SVGRect is not polymorphic" ); |
350 | |
351 | // If you hit this assertion you either have a use after free bug, or |
352 | // SVGRect has subclasses. If SVGRect has subclasses that get passed |
353 | // to toJS() we currently require SVGRect you to opt out of binding hardening |
354 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
355 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
356 | #endif |
357 | return createWrapper<SVGRect>(globalObject, WTFMove(impl)); |
358 | } |
359 | |
360 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGRect& impl) |
361 | { |
362 | return wrap(state, globalObject, impl); |
363 | } |
364 | |
365 | SVGRect* JSSVGRect::toWrapped(JSC::VM& vm, JSC::JSValue value) |
366 | { |
367 | if (auto* wrapper = jsDynamicCast<JSSVGRect*>(vm, value)) |
368 | return &wrapper->wrapped(); |
369 | return nullptr; |
370 | } |
371 | |
372 | } |
373 | |