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 "JSSVGNumber.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 jsSVGNumberConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
45 | bool setJSSVGNumberConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
46 | JSC::EncodedJSValue jsSVGNumberValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
47 | bool setJSSVGNumberValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
48 | |
49 | class JSSVGNumberPrototype : public JSC::JSNonFinalObject { |
50 | public: |
51 | using Base = JSC::JSNonFinalObject; |
52 | static JSSVGNumberPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
53 | { |
54 | JSSVGNumberPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGNumberPrototype>(vm.heap)) JSSVGNumberPrototype(vm, globalObject, structure); |
55 | ptr->finishCreation(vm); |
56 | return ptr; |
57 | } |
58 | |
59 | DECLARE_INFO; |
60 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
61 | { |
62 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
63 | } |
64 | |
65 | private: |
66 | JSSVGNumberPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
67 | : JSC::JSNonFinalObject(vm, structure) |
68 | { |
69 | } |
70 | |
71 | void finishCreation(JSC::VM&); |
72 | }; |
73 | |
74 | using JSSVGNumberConstructor = JSDOMConstructorNotConstructable<JSSVGNumber>; |
75 | |
76 | template<> JSValue JSSVGNumberConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
77 | { |
78 | UNUSED_PARAM(vm); |
79 | return globalObject.functionPrototype(); |
80 | } |
81 | |
82 | template<> void JSSVGNumberConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
83 | { |
84 | putDirect(vm, vm.propertyNames->prototype, JSSVGNumber::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
85 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGNumber"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
86 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
87 | } |
88 | |
89 | template<> const ClassInfo JSSVGNumberConstructor::s_info = { "SVGNumber" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGNumberConstructor) }; |
90 | |
91 | /* Hash table for prototype */ |
92 | |
93 | static const HashTableValue JSSVGNumberPrototypeTableValues[] = |
94 | { |
95 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGNumberConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGNumberConstructor) } }, |
96 | { "value" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGNumberValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGNumberValue) } }, |
97 | }; |
98 | |
99 | const ClassInfo JSSVGNumberPrototype::s_info = { "SVGNumberPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGNumberPrototype) }; |
100 | |
101 | void JSSVGNumberPrototype::finishCreation(VM& vm) |
102 | { |
103 | Base::finishCreation(vm); |
104 | reifyStaticProperties(vm, JSSVGNumber::info(), JSSVGNumberPrototypeTableValues, *this); |
105 | } |
106 | |
107 | const ClassInfo JSSVGNumber::s_info = { "SVGNumber" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGNumber) }; |
108 | |
109 | JSSVGNumber::JSSVGNumber(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGNumber>&& impl) |
110 | : JSDOMWrapper<SVGNumber>(structure, globalObject, WTFMove(impl)) |
111 | { |
112 | } |
113 | |
114 | void JSSVGNumber::finishCreation(VM& vm) |
115 | { |
116 | Base::finishCreation(vm); |
117 | ASSERT(inherits(vm, info())); |
118 | |
119 | } |
120 | |
121 | JSObject* JSSVGNumber::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
122 | { |
123 | return JSSVGNumberPrototype::create(vm, &globalObject, JSSVGNumberPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
124 | } |
125 | |
126 | JSObject* JSSVGNumber::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
127 | { |
128 | return getDOMPrototype<JSSVGNumber>(vm, globalObject); |
129 | } |
130 | |
131 | JSValue JSSVGNumber::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
132 | { |
133 | return getDOMConstructor<JSSVGNumberConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
134 | } |
135 | |
136 | void JSSVGNumber::destroy(JSC::JSCell* cell) |
137 | { |
138 | JSSVGNumber* thisObject = static_cast<JSSVGNumber*>(cell); |
139 | thisObject->JSSVGNumber::~JSSVGNumber(); |
140 | } |
141 | |
142 | template<> inline JSSVGNumber* IDLAttribute<JSSVGNumber>::cast(ExecState& state, EncodedJSValue thisValue) |
143 | { |
144 | return jsDynamicCast<JSSVGNumber*>(state.vm(), JSValue::decode(thisValue)); |
145 | } |
146 | |
147 | EncodedJSValue jsSVGNumberConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
148 | { |
149 | VM& vm = state->vm(); |
150 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
151 | auto* prototype = jsDynamicCast<JSSVGNumberPrototype*>(vm, JSValue::decode(thisValue)); |
152 | if (UNLIKELY(!prototype)) |
153 | return throwVMTypeError(state, throwScope); |
154 | return JSValue::encode(JSSVGNumber::getConstructor(state->vm(), prototype->globalObject())); |
155 | } |
156 | |
157 | bool setJSSVGNumberConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
158 | { |
159 | VM& vm = state->vm(); |
160 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
161 | auto* prototype = jsDynamicCast<JSSVGNumberPrototype*>(vm, JSValue::decode(thisValue)); |
162 | if (UNLIKELY(!prototype)) { |
163 | throwVMTypeError(state, throwScope); |
164 | return false; |
165 | } |
166 | // Shadowing a built-in constructor |
167 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
168 | } |
169 | |
170 | static inline JSValue jsSVGNumberValueGetter(ExecState& state, JSSVGNumber& thisObject, ThrowScope& throwScope) |
171 | { |
172 | UNUSED_PARAM(throwScope); |
173 | UNUSED_PARAM(state); |
174 | auto& impl = thisObject.wrapped(); |
175 | JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.valueForBindings()); |
176 | return result; |
177 | } |
178 | |
179 | EncodedJSValue jsSVGNumberValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
180 | { |
181 | return IDLAttribute<JSSVGNumber>::get<jsSVGNumberValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value" ); |
182 | } |
183 | |
184 | static inline bool setJSSVGNumberValueSetter(ExecState& state, JSSVGNumber& thisObject, JSValue value, ThrowScope& throwScope) |
185 | { |
186 | UNUSED_PARAM(throwScope); |
187 | auto& impl = thisObject.wrapped(); |
188 | auto nativeValue = convert<IDLUnrestrictedFloat>(state, value); |
189 | RETURN_IF_EXCEPTION(throwScope, false); |
190 | AttributeSetter::call(state, throwScope, [&] { |
191 | return impl.setValueForBindings(WTFMove(nativeValue)); |
192 | }); |
193 | return true; |
194 | } |
195 | |
196 | bool setJSSVGNumberValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
197 | { |
198 | return IDLAttribute<JSSVGNumber>::set<setJSSVGNumberValueSetter>(*state, thisValue, encodedValue, "value" ); |
199 | } |
200 | |
201 | void JSSVGNumber::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
202 | { |
203 | auto* thisObject = jsCast<JSSVGNumber*>(cell); |
204 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
205 | if (thisObject->scriptExecutionContext()) |
206 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
207 | Base::heapSnapshot(cell, builder); |
208 | } |
209 | |
210 | bool JSSVGNumberOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
211 | { |
212 | UNUSED_PARAM(handle); |
213 | UNUSED_PARAM(visitor); |
214 | UNUSED_PARAM(reason); |
215 | return false; |
216 | } |
217 | |
218 | void JSSVGNumberOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
219 | { |
220 | auto* jsSVGNumber = static_cast<JSSVGNumber*>(handle.slot()->asCell()); |
221 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
222 | uncacheWrapper(world, &jsSVGNumber->wrapped(), jsSVGNumber); |
223 | } |
224 | |
225 | #if ENABLE(BINDING_INTEGRITY) |
226 | #if PLATFORM(WIN) |
227 | #pragma warning(disable: 4483) |
228 | extern "C" { extern void (*const __identifier("??_7SVGNumber@WebCore@@6B@" )[])(); } |
229 | #else |
230 | extern "C" { extern void* _ZTVN7WebCore9SVGNumberE[]; } |
231 | #endif |
232 | #endif |
233 | |
234 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGNumber>&& impl) |
235 | { |
236 | |
237 | #if ENABLE(BINDING_INTEGRITY) |
238 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
239 | #if PLATFORM(WIN) |
240 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SVGNumber@WebCore@@6B@" )); |
241 | #else |
242 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore9SVGNumberE[2]); |
243 | #endif |
244 | |
245 | // If this fails SVGNumber does not have a vtable, so you need to add the |
246 | // ImplementationLacksVTable attribute to the interface definition |
247 | static_assert(std::is_polymorphic<SVGNumber>::value, "SVGNumber is not polymorphic" ); |
248 | |
249 | // If you hit this assertion you either have a use after free bug, or |
250 | // SVGNumber has subclasses. If SVGNumber has subclasses that get passed |
251 | // to toJS() we currently require SVGNumber you to opt out of binding hardening |
252 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
253 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
254 | #endif |
255 | return createWrapper<SVGNumber>(globalObject, WTFMove(impl)); |
256 | } |
257 | |
258 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGNumber& impl) |
259 | { |
260 | return wrap(state, globalObject, impl); |
261 | } |
262 | |
263 | SVGNumber* JSSVGNumber::toWrapped(JSC::VM& vm, JSC::JSValue value) |
264 | { |
265 | if (auto* wrapper = jsDynamicCast<JSSVGNumber*>(vm, value)) |
266 | return &wrapper->wrapped(); |
267 | return nullptr; |
268 | } |
269 | |
270 | } |
271 | |