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 "JSSVGLength.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertNumbers.h" |
28 | #include "JSDOMConvertStrings.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMOperation.h" |
31 | #include "JSDOMWrapperCache.h" |
32 | #include "ScriptExecutionContext.h" |
33 | #include <JavaScriptCore/FunctionPrototype.h> |
34 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
35 | #include <JavaScriptCore/JSCInlines.h> |
36 | #include <wtf/GetPtr.h> |
37 | #include <wtf/PointerPreparations.h> |
38 | #include <wtf/URL.h> |
39 | |
40 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | // Functions |
45 | |
46 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits(JSC::ExecState*); |
47 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits(JSC::ExecState*); |
48 | |
49 | // Attributes |
50 | |
51 | JSC::EncodedJSValue jsSVGLengthConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
52 | bool setJSSVGLengthConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
53 | JSC::EncodedJSValue jsSVGLengthUnitType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | JSC::EncodedJSValue jsSVGLengthValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
55 | bool setJSSVGLengthValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
56 | JSC::EncodedJSValue jsSVGLengthValueInSpecifiedUnits(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | bool setJSSVGLengthValueInSpecifiedUnits(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
58 | JSC::EncodedJSValue jsSVGLengthValueAsString(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | bool setJSSVGLengthValueAsString(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
60 | |
61 | class JSSVGLengthPrototype : public JSC::JSNonFinalObject { |
62 | public: |
63 | using Base = JSC::JSNonFinalObject; |
64 | static JSSVGLengthPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
65 | { |
66 | JSSVGLengthPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGLengthPrototype>(vm.heap)) JSSVGLengthPrototype(vm, globalObject, structure); |
67 | ptr->finishCreation(vm); |
68 | return ptr; |
69 | } |
70 | |
71 | DECLARE_INFO; |
72 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
73 | { |
74 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
75 | } |
76 | |
77 | private: |
78 | JSSVGLengthPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
79 | : JSC::JSNonFinalObject(vm, structure) |
80 | { |
81 | } |
82 | |
83 | void finishCreation(JSC::VM&); |
84 | }; |
85 | |
86 | using JSSVGLengthConstructor = JSDOMConstructorNotConstructable<JSSVGLength>; |
87 | |
88 | /* Hash table for constructor */ |
89 | |
90 | static const HashTableValue JSSVGLengthConstructorTableValues[] = |
91 | { |
92 | { "SVG_LENGTHTYPE_UNKNOWN" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
93 | { "SVG_LENGTHTYPE_NUMBER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
94 | { "SVG_LENGTHTYPE_PERCENTAGE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
95 | { "SVG_LENGTHTYPE_EMS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
96 | { "SVG_LENGTHTYPE_EXS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
97 | { "SVG_LENGTHTYPE_PX" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
98 | { "SVG_LENGTHTYPE_CM" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
99 | { "SVG_LENGTHTYPE_MM" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
100 | { "SVG_LENGTHTYPE_IN" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
101 | { "SVG_LENGTHTYPE_PT" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
102 | { "SVG_LENGTHTYPE_PC" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
103 | }; |
104 | |
105 | static_assert(SVGLength::SVG_LENGTHTYPE_UNKNOWN == 0, "SVG_LENGTHTYPE_UNKNOWN in SVGLength does not match value from IDL" ); |
106 | static_assert(SVGLength::SVG_LENGTHTYPE_NUMBER == 1, "SVG_LENGTHTYPE_NUMBER in SVGLength does not match value from IDL" ); |
107 | static_assert(SVGLength::SVG_LENGTHTYPE_PERCENTAGE == 2, "SVG_LENGTHTYPE_PERCENTAGE in SVGLength does not match value from IDL" ); |
108 | static_assert(SVGLength::SVG_LENGTHTYPE_EMS == 3, "SVG_LENGTHTYPE_EMS in SVGLength does not match value from IDL" ); |
109 | static_assert(SVGLength::SVG_LENGTHTYPE_EXS == 4, "SVG_LENGTHTYPE_EXS in SVGLength does not match value from IDL" ); |
110 | static_assert(SVGLength::SVG_LENGTHTYPE_PX == 5, "SVG_LENGTHTYPE_PX in SVGLength does not match value from IDL" ); |
111 | static_assert(SVGLength::SVG_LENGTHTYPE_CM == 6, "SVG_LENGTHTYPE_CM in SVGLength does not match value from IDL" ); |
112 | static_assert(SVGLength::SVG_LENGTHTYPE_MM == 7, "SVG_LENGTHTYPE_MM in SVGLength does not match value from IDL" ); |
113 | static_assert(SVGLength::SVG_LENGTHTYPE_IN == 8, "SVG_LENGTHTYPE_IN in SVGLength does not match value from IDL" ); |
114 | static_assert(SVGLength::SVG_LENGTHTYPE_PT == 9, "SVG_LENGTHTYPE_PT in SVGLength does not match value from IDL" ); |
115 | static_assert(SVGLength::SVG_LENGTHTYPE_PC == 10, "SVG_LENGTHTYPE_PC in SVGLength does not match value from IDL" ); |
116 | |
117 | template<> JSValue JSSVGLengthConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
118 | { |
119 | UNUSED_PARAM(vm); |
120 | return globalObject.functionPrototype(); |
121 | } |
122 | |
123 | template<> void JSSVGLengthConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
124 | { |
125 | putDirect(vm, vm.propertyNames->prototype, JSSVGLength::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
126 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGLength"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
127 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
128 | reifyStaticProperties(vm, JSSVGLength::info(), JSSVGLengthConstructorTableValues, *this); |
129 | } |
130 | |
131 | template<> const ClassInfo JSSVGLengthConstructor::s_info = { "SVGLength" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLengthConstructor) }; |
132 | |
133 | /* Hash table for prototype */ |
134 | |
135 | static const HashTableValue JSSVGLengthPrototypeTableValues[] = |
136 | { |
137 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthConstructor) } }, |
138 | { "unitType" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthUnitType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
139 | { "value" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValue) } }, |
140 | { "valueInSpecifiedUnits" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValueInSpecifiedUnits), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValueInSpecifiedUnits) } }, |
141 | { "valueAsString" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValueAsString), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValueAsString) } }, |
142 | { "newValueSpecifiedUnits" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits), (intptr_t) (2) } }, |
143 | { "convertToSpecifiedUnits" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits), (intptr_t) (1) } }, |
144 | { "SVG_LENGTHTYPE_UNKNOWN" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
145 | { "SVG_LENGTHTYPE_NUMBER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
146 | { "SVG_LENGTHTYPE_PERCENTAGE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
147 | { "SVG_LENGTHTYPE_EMS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
148 | { "SVG_LENGTHTYPE_EXS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
149 | { "SVG_LENGTHTYPE_PX" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
150 | { "SVG_LENGTHTYPE_CM" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
151 | { "SVG_LENGTHTYPE_MM" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
152 | { "SVG_LENGTHTYPE_IN" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
153 | { "SVG_LENGTHTYPE_PT" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
154 | { "SVG_LENGTHTYPE_PC" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
155 | }; |
156 | |
157 | const ClassInfo JSSVGLengthPrototype::s_info = { "SVGLengthPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLengthPrototype) }; |
158 | |
159 | void JSSVGLengthPrototype::finishCreation(VM& vm) |
160 | { |
161 | Base::finishCreation(vm); |
162 | reifyStaticProperties(vm, JSSVGLength::info(), JSSVGLengthPrototypeTableValues, *this); |
163 | } |
164 | |
165 | const ClassInfo JSSVGLength::s_info = { "SVGLength" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLength) }; |
166 | |
167 | JSSVGLength::JSSVGLength(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGLength>&& impl) |
168 | : JSDOMWrapper<SVGLength>(structure, globalObject, WTFMove(impl)) |
169 | { |
170 | } |
171 | |
172 | void JSSVGLength::finishCreation(VM& vm) |
173 | { |
174 | Base::finishCreation(vm); |
175 | ASSERT(inherits(vm, info())); |
176 | |
177 | } |
178 | |
179 | JSObject* JSSVGLength::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
180 | { |
181 | return JSSVGLengthPrototype::create(vm, &globalObject, JSSVGLengthPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
182 | } |
183 | |
184 | JSObject* JSSVGLength::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
185 | { |
186 | return getDOMPrototype<JSSVGLength>(vm, globalObject); |
187 | } |
188 | |
189 | JSValue JSSVGLength::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
190 | { |
191 | return getDOMConstructor<JSSVGLengthConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
192 | } |
193 | |
194 | void JSSVGLength::destroy(JSC::JSCell* cell) |
195 | { |
196 | JSSVGLength* thisObject = static_cast<JSSVGLength*>(cell); |
197 | thisObject->JSSVGLength::~JSSVGLength(); |
198 | } |
199 | |
200 | template<> inline JSSVGLength* IDLAttribute<JSSVGLength>::cast(ExecState& state, EncodedJSValue thisValue) |
201 | { |
202 | return jsDynamicCast<JSSVGLength*>(state.vm(), JSValue::decode(thisValue)); |
203 | } |
204 | |
205 | template<> inline JSSVGLength* IDLOperation<JSSVGLength>::cast(ExecState& state) |
206 | { |
207 | return jsDynamicCast<JSSVGLength*>(state.vm(), state.thisValue()); |
208 | } |
209 | |
210 | EncodedJSValue jsSVGLengthConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
211 | { |
212 | VM& vm = state->vm(); |
213 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
214 | auto* prototype = jsDynamicCast<JSSVGLengthPrototype*>(vm, JSValue::decode(thisValue)); |
215 | if (UNLIKELY(!prototype)) |
216 | return throwVMTypeError(state, throwScope); |
217 | return JSValue::encode(JSSVGLength::getConstructor(state->vm(), prototype->globalObject())); |
218 | } |
219 | |
220 | bool setJSSVGLengthConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
221 | { |
222 | VM& vm = state->vm(); |
223 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
224 | auto* prototype = jsDynamicCast<JSSVGLengthPrototype*>(vm, JSValue::decode(thisValue)); |
225 | if (UNLIKELY(!prototype)) { |
226 | throwVMTypeError(state, throwScope); |
227 | return false; |
228 | } |
229 | // Shadowing a built-in constructor |
230 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
231 | } |
232 | |
233 | static inline JSValue jsSVGLengthUnitTypeGetter(ExecState& state, JSSVGLength& thisObject, ThrowScope& throwScope) |
234 | { |
235 | UNUSED_PARAM(throwScope); |
236 | UNUSED_PARAM(state); |
237 | auto& impl = thisObject.wrapped(); |
238 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.unitType()); |
239 | return result; |
240 | } |
241 | |
242 | EncodedJSValue jsSVGLengthUnitType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
243 | { |
244 | return IDLAttribute<JSSVGLength>::get<jsSVGLengthUnitTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "unitType" ); |
245 | } |
246 | |
247 | static inline JSValue jsSVGLengthValueGetter(ExecState& state, JSSVGLength& thisObject, ThrowScope& throwScope) |
248 | { |
249 | UNUSED_PARAM(throwScope); |
250 | UNUSED_PARAM(state); |
251 | auto& impl = thisObject.wrapped(); |
252 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.valueForBindings()); |
253 | return result; |
254 | } |
255 | |
256 | EncodedJSValue jsSVGLengthValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSSVGLength>::get<jsSVGLengthValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value" ); |
259 | } |
260 | |
261 | static inline bool setJSSVGLengthValueSetter(ExecState& state, JSSVGLength& thisObject, JSValue value, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | auto& impl = thisObject.wrapped(); |
265 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
266 | RETURN_IF_EXCEPTION(throwScope, false); |
267 | AttributeSetter::call(state, throwScope, [&] { |
268 | return impl.setValueForBindings(WTFMove(nativeValue)); |
269 | }); |
270 | return true; |
271 | } |
272 | |
273 | bool setJSSVGLengthValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
274 | { |
275 | return IDLAttribute<JSSVGLength>::set<setJSSVGLengthValueSetter>(*state, thisValue, encodedValue, "value" ); |
276 | } |
277 | |
278 | static inline JSValue jsSVGLengthValueInSpecifiedUnitsGetter(ExecState& state, JSSVGLength& thisObject, ThrowScope& throwScope) |
279 | { |
280 | UNUSED_PARAM(throwScope); |
281 | UNUSED_PARAM(state); |
282 | auto& impl = thisObject.wrapped(); |
283 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.valueInSpecifiedUnits()); |
284 | return result; |
285 | } |
286 | |
287 | EncodedJSValue jsSVGLengthValueInSpecifiedUnits(ExecState* state, EncodedJSValue thisValue, PropertyName) |
288 | { |
289 | return IDLAttribute<JSSVGLength>::get<jsSVGLengthValueInSpecifiedUnitsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "valueInSpecifiedUnits" ); |
290 | } |
291 | |
292 | static inline bool setJSSVGLengthValueInSpecifiedUnitsSetter(ExecState& state, JSSVGLength& thisObject, JSValue value, ThrowScope& throwScope) |
293 | { |
294 | UNUSED_PARAM(throwScope); |
295 | auto& impl = thisObject.wrapped(); |
296 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
297 | RETURN_IF_EXCEPTION(throwScope, false); |
298 | AttributeSetter::call(state, throwScope, [&] { |
299 | return impl.setValueInSpecifiedUnits(WTFMove(nativeValue)); |
300 | }); |
301 | return true; |
302 | } |
303 | |
304 | bool setJSSVGLengthValueInSpecifiedUnits(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
305 | { |
306 | return IDLAttribute<JSSVGLength>::set<setJSSVGLengthValueInSpecifiedUnitsSetter>(*state, thisValue, encodedValue, "valueInSpecifiedUnits" ); |
307 | } |
308 | |
309 | static inline JSValue jsSVGLengthValueAsStringGetter(ExecState& state, JSSVGLength& thisObject, ThrowScope& throwScope) |
310 | { |
311 | UNUSED_PARAM(throwScope); |
312 | UNUSED_PARAM(state); |
313 | auto& impl = thisObject.wrapped(); |
314 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.valueAsString()); |
315 | return result; |
316 | } |
317 | |
318 | EncodedJSValue jsSVGLengthValueAsString(ExecState* state, EncodedJSValue thisValue, PropertyName) |
319 | { |
320 | return IDLAttribute<JSSVGLength>::get<jsSVGLengthValueAsStringGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "valueAsString" ); |
321 | } |
322 | |
323 | static inline bool setJSSVGLengthValueAsStringSetter(ExecState& state, JSSVGLength& thisObject, JSValue value, ThrowScope& throwScope) |
324 | { |
325 | UNUSED_PARAM(throwScope); |
326 | auto& impl = thisObject.wrapped(); |
327 | auto nativeValue = convert<IDLDOMString>(state, value); |
328 | RETURN_IF_EXCEPTION(throwScope, false); |
329 | AttributeSetter::call(state, throwScope, [&] { |
330 | return impl.setValueAsString(WTFMove(nativeValue)); |
331 | }); |
332 | return true; |
333 | } |
334 | |
335 | bool setJSSVGLengthValueAsString(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
336 | { |
337 | return IDLAttribute<JSSVGLength>::set<setJSSVGLengthValueAsStringSetter>(*state, thisValue, encodedValue, "valueAsString" ); |
338 | } |
339 | |
340 | static inline JSC::EncodedJSValue jsSVGLengthPrototypeFunctionNewValueSpecifiedUnitsBody(JSC::ExecState* state, typename IDLOperation<JSSVGLength>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
341 | { |
342 | UNUSED_PARAM(state); |
343 | UNUSED_PARAM(throwScope); |
344 | auto& impl = castedThis->wrapped(); |
345 | if (UNLIKELY(state->argumentCount() < 2)) |
346 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
347 | auto unitType = convert<IDLUnsignedShort>(*state, state->uncheckedArgument(0)); |
348 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
349 | auto valueInSpecifiedUnits = convert<IDLUnrestrictedFloat>(*state, state->uncheckedArgument(1)); |
350 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
351 | propagateException(*state, throwScope, impl.newValueSpecifiedUnits(WTFMove(unitType), WTFMove(valueInSpecifiedUnits))); |
352 | return JSValue::encode(jsUndefined()); |
353 | } |
354 | |
355 | EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits(ExecState* state) |
356 | { |
357 | return IDLOperation<JSSVGLength>::call<jsSVGLengthPrototypeFunctionNewValueSpecifiedUnitsBody>(*state, "newValueSpecifiedUnits" ); |
358 | } |
359 | |
360 | static inline JSC::EncodedJSValue jsSVGLengthPrototypeFunctionConvertToSpecifiedUnitsBody(JSC::ExecState* state, typename IDLOperation<JSSVGLength>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
361 | { |
362 | UNUSED_PARAM(state); |
363 | UNUSED_PARAM(throwScope); |
364 | auto& impl = castedThis->wrapped(); |
365 | if (UNLIKELY(state->argumentCount() < 1)) |
366 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
367 | auto unitType = convert<IDLUnsignedShort>(*state, state->uncheckedArgument(0)); |
368 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
369 | propagateException(*state, throwScope, impl.convertToSpecifiedUnits(WTFMove(unitType))); |
370 | return JSValue::encode(jsUndefined()); |
371 | } |
372 | |
373 | EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits(ExecState* state) |
374 | { |
375 | return IDLOperation<JSSVGLength>::call<jsSVGLengthPrototypeFunctionConvertToSpecifiedUnitsBody>(*state, "convertToSpecifiedUnits" ); |
376 | } |
377 | |
378 | void JSSVGLength::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
379 | { |
380 | auto* thisObject = jsCast<JSSVGLength*>(cell); |
381 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
382 | if (thisObject->scriptExecutionContext()) |
383 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
384 | Base::heapSnapshot(cell, builder); |
385 | } |
386 | |
387 | bool JSSVGLengthOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
388 | { |
389 | UNUSED_PARAM(handle); |
390 | UNUSED_PARAM(visitor); |
391 | UNUSED_PARAM(reason); |
392 | return false; |
393 | } |
394 | |
395 | void JSSVGLengthOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
396 | { |
397 | auto* jsSVGLength = static_cast<JSSVGLength*>(handle.slot()->asCell()); |
398 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
399 | uncacheWrapper(world, &jsSVGLength->wrapped(), jsSVGLength); |
400 | } |
401 | |
402 | #if ENABLE(BINDING_INTEGRITY) |
403 | #if PLATFORM(WIN) |
404 | #pragma warning(disable: 4483) |
405 | extern "C" { extern void (*const __identifier("??_7SVGLength@WebCore@@6B@" )[])(); } |
406 | #else |
407 | extern "C" { extern void* _ZTVN7WebCore9SVGLengthE[]; } |
408 | #endif |
409 | #endif |
410 | |
411 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGLength>&& impl) |
412 | { |
413 | |
414 | #if ENABLE(BINDING_INTEGRITY) |
415 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
416 | #if PLATFORM(WIN) |
417 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SVGLength@WebCore@@6B@" )); |
418 | #else |
419 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore9SVGLengthE[2]); |
420 | #endif |
421 | |
422 | // If this fails SVGLength does not have a vtable, so you need to add the |
423 | // ImplementationLacksVTable attribute to the interface definition |
424 | static_assert(std::is_polymorphic<SVGLength>::value, "SVGLength is not polymorphic" ); |
425 | |
426 | // If you hit this assertion you either have a use after free bug, or |
427 | // SVGLength has subclasses. If SVGLength has subclasses that get passed |
428 | // to toJS() we currently require SVGLength you to opt out of binding hardening |
429 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
430 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
431 | #endif |
432 | return createWrapper<SVGLength>(globalObject, WTFMove(impl)); |
433 | } |
434 | |
435 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGLength& impl) |
436 | { |
437 | return wrap(state, globalObject, impl); |
438 | } |
439 | |
440 | SVGLength* JSSVGLength::toWrapped(JSC::VM& vm, JSC::JSValue value) |
441 | { |
442 | if (auto* wrapper = jsDynamicCast<JSSVGLength*>(vm, value)) |
443 | return &wrapper->wrapped(); |
444 | return nullptr; |
445 | } |
446 | |
447 | } |
448 | |