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 "JSSVGPoint.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "JSSVGMatrix.h"
34#include "JSSVGPoint.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 jsSVGPointPrototypeFunctionMatrixTransform(JSC::ExecState*);
50
51// Attributes
52
53JSC::EncodedJSValue jsSVGPointConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSSVGPointConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55JSC::EncodedJSValue jsSVGPointX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56bool setJSSVGPointX(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
57JSC::EncodedJSValue jsSVGPointY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58bool setJSSVGPointY(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
59
60class JSSVGPointPrototype : public JSC::JSNonFinalObject {
61public:
62 using Base = JSC::JSNonFinalObject;
63 static JSSVGPointPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
64 {
65 JSSVGPointPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGPointPrototype>(vm.heap)) JSSVGPointPrototype(vm, globalObject, structure);
66 ptr->finishCreation(vm);
67 return ptr;
68 }
69
70 DECLARE_INFO;
71 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
72 {
73 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
74 }
75
76private:
77 JSSVGPointPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
78 : JSC::JSNonFinalObject(vm, structure)
79 {
80 }
81
82 void finishCreation(JSC::VM&);
83};
84
85using JSSVGPointConstructor = JSDOMConstructorNotConstructable<JSSVGPoint>;
86
87template<> JSValue JSSVGPointConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
88{
89 UNUSED_PARAM(vm);
90 return globalObject.functionPrototype();
91}
92
93template<> void JSSVGPointConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
94{
95 putDirect(vm, vm.propertyNames->prototype, JSSVGPoint::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGPoint"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98}
99
100template<> const ClassInfo JSSVGPointConstructor::s_info = { "SVGPoint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGPointConstructor) };
101
102/* Hash table for prototype */
103
104static const HashTableValue JSSVGPointPrototypeTableValues[] =
105{
106 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGPointConstructor) } },
107 { "x", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGPointX) } },
108 { "y", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGPointY) } },
109 { "matrixTransform", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGPointPrototypeFunctionMatrixTransform), (intptr_t) (1) } },
110};
111
112const ClassInfo JSSVGPointPrototype::s_info = { "SVGPointPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGPointPrototype) };
113
114void JSSVGPointPrototype::finishCreation(VM& vm)
115{
116 Base::finishCreation(vm);
117 reifyStaticProperties(vm, JSSVGPoint::info(), JSSVGPointPrototypeTableValues, *this);
118}
119
120const ClassInfo JSSVGPoint::s_info = { "SVGPoint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGPoint) };
121
122JSSVGPoint::JSSVGPoint(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGPoint>&& impl)
123 : JSDOMWrapper<SVGPoint>(structure, globalObject, WTFMove(impl))
124{
125}
126
127void JSSVGPoint::finishCreation(VM& vm)
128{
129 Base::finishCreation(vm);
130 ASSERT(inherits(vm, info()));
131
132}
133
134JSObject* JSSVGPoint::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
135{
136 return JSSVGPointPrototype::create(vm, &globalObject, JSSVGPointPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
137}
138
139JSObject* JSSVGPoint::prototype(VM& vm, JSDOMGlobalObject& globalObject)
140{
141 return getDOMPrototype<JSSVGPoint>(vm, globalObject);
142}
143
144JSValue JSSVGPoint::getConstructor(VM& vm, const JSGlobalObject* globalObject)
145{
146 return getDOMConstructor<JSSVGPointConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
147}
148
149void JSSVGPoint::destroy(JSC::JSCell* cell)
150{
151 JSSVGPoint* thisObject = static_cast<JSSVGPoint*>(cell);
152 thisObject->JSSVGPoint::~JSSVGPoint();
153}
154
155template<> inline JSSVGPoint* IDLAttribute<JSSVGPoint>::cast(ExecState& state, EncodedJSValue thisValue)
156{
157 return jsDynamicCast<JSSVGPoint*>(state.vm(), JSValue::decode(thisValue));
158}
159
160template<> inline JSSVGPoint* IDLOperation<JSSVGPoint>::cast(ExecState& state)
161{
162 return jsDynamicCast<JSSVGPoint*>(state.vm(), state.thisValue());
163}
164
165EncodedJSValue jsSVGPointConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
166{
167 VM& vm = state->vm();
168 auto throwScope = DECLARE_THROW_SCOPE(vm);
169 auto* prototype = jsDynamicCast<JSSVGPointPrototype*>(vm, JSValue::decode(thisValue));
170 if (UNLIKELY(!prototype))
171 return throwVMTypeError(state, throwScope);
172 return JSValue::encode(JSSVGPoint::getConstructor(state->vm(), prototype->globalObject()));
173}
174
175bool setJSSVGPointConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
176{
177 VM& vm = state->vm();
178 auto throwScope = DECLARE_THROW_SCOPE(vm);
179 auto* prototype = jsDynamicCast<JSSVGPointPrototype*>(vm, JSValue::decode(thisValue));
180 if (UNLIKELY(!prototype)) {
181 throwVMTypeError(state, throwScope);
182 return false;
183 }
184 // Shadowing a built-in constructor
185 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
186}
187
188static inline JSValue jsSVGPointXGetter(ExecState& state, JSSVGPoint& thisObject, ThrowScope& throwScope)
189{
190 UNUSED_PARAM(throwScope);
191 UNUSED_PARAM(state);
192 auto& impl = thisObject.wrapped();
193 JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.x());
194 return result;
195}
196
197EncodedJSValue jsSVGPointX(ExecState* state, EncodedJSValue thisValue, PropertyName)
198{
199 return IDLAttribute<JSSVGPoint>::get<jsSVGPointXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x");
200}
201
202static inline bool setJSSVGPointXSetter(ExecState& state, JSSVGPoint& thisObject, JSValue value, ThrowScope& throwScope)
203{
204 UNUSED_PARAM(throwScope);
205 auto& impl = thisObject.wrapped();
206 auto nativeValue = convert<IDLUnrestrictedFloat>(state, value);
207 RETURN_IF_EXCEPTION(throwScope, false);
208 AttributeSetter::call(state, throwScope, [&] {
209 return impl.setX(WTFMove(nativeValue));
210 });
211 return true;
212}
213
214bool setJSSVGPointX(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
215{
216 return IDLAttribute<JSSVGPoint>::set<setJSSVGPointXSetter>(*state, thisValue, encodedValue, "x");
217}
218
219static inline JSValue jsSVGPointYGetter(ExecState& state, JSSVGPoint& thisObject, ThrowScope& throwScope)
220{
221 UNUSED_PARAM(throwScope);
222 UNUSED_PARAM(state);
223 auto& impl = thisObject.wrapped();
224 JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.y());
225 return result;
226}
227
228EncodedJSValue jsSVGPointY(ExecState* state, EncodedJSValue thisValue, PropertyName)
229{
230 return IDLAttribute<JSSVGPoint>::get<jsSVGPointYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y");
231}
232
233static inline bool setJSSVGPointYSetter(ExecState& state, JSSVGPoint& thisObject, JSValue value, ThrowScope& throwScope)
234{
235 UNUSED_PARAM(throwScope);
236 auto& impl = thisObject.wrapped();
237 auto nativeValue = convert<IDLUnrestrictedFloat>(state, value);
238 RETURN_IF_EXCEPTION(throwScope, false);
239 AttributeSetter::call(state, throwScope, [&] {
240 return impl.setY(WTFMove(nativeValue));
241 });
242 return true;
243}
244
245bool setJSSVGPointY(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
246{
247 return IDLAttribute<JSSVGPoint>::set<setJSSVGPointYSetter>(*state, thisValue, encodedValue, "y");
248}
249
250static inline JSC::EncodedJSValue jsSVGPointPrototypeFunctionMatrixTransformBody(JSC::ExecState* state, typename IDLOperation<JSSVGPoint>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
251{
252 UNUSED_PARAM(state);
253 UNUSED_PARAM(throwScope);
254 auto& impl = castedThis->wrapped();
255 if (UNLIKELY(state->argumentCount() < 1))
256 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
257 auto matrix = convert<IDLInterface<SVGMatrix>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "matrix", "SVGPoint", "matrixTransform", "SVGMatrix"); });
258 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
259 return JSValue::encode(toJSNewlyCreated<IDLInterface<SVGPoint>>(*state, *castedThis->globalObject(), impl.matrixTransform(*matrix)));
260}
261
262EncodedJSValue JSC_HOST_CALL jsSVGPointPrototypeFunctionMatrixTransform(ExecState* state)
263{
264 return IDLOperation<JSSVGPoint>::call<jsSVGPointPrototypeFunctionMatrixTransformBody>(*state, "matrixTransform");
265}
266
267void JSSVGPoint::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
268{
269 auto* thisObject = jsCast<JSSVGPoint*>(cell);
270 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
271 if (thisObject->scriptExecutionContext())
272 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
273 Base::heapSnapshot(cell, builder);
274}
275
276bool JSSVGPointOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
277{
278 UNUSED_PARAM(handle);
279 UNUSED_PARAM(visitor);
280 UNUSED_PARAM(reason);
281 return false;
282}
283
284void JSSVGPointOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
285{
286 auto* jsSVGPoint = static_cast<JSSVGPoint*>(handle.slot()->asCell());
287 auto& world = *static_cast<DOMWrapperWorld*>(context);
288 uncacheWrapper(world, &jsSVGPoint->wrapped(), jsSVGPoint);
289}
290
291JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGPoint>&& impl)
292{
293 return createWrapper<SVGPoint>(globalObject, WTFMove(impl));
294}
295
296JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGPoint& impl)
297{
298 return wrap(state, globalObject, impl);
299}
300
301SVGPoint* JSSVGPoint::toWrapped(JSC::VM& vm, JSC::JSValue value)
302{
303 if (auto* wrapper = jsDynamicCast<JSSVGPoint*>(vm, value))
304 return &wrapper->wrapped();
305 return nullptr;
306}
307
308}
309