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 "JSWebKitPoint.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMWrapperCache.h"
31#include "ScriptExecutionContext.h"
32#include <JavaScriptCore/FunctionPrototype.h>
33#include <JavaScriptCore/HeapSnapshotBuilder.h>
34#include <JavaScriptCore/JSCInlines.h>
35#include <wtf/GetPtr.h>
36#include <wtf/PointerPreparations.h>
37#include <wtf/URL.h>
38
39
40namespace WebCore {
41using namespace JSC;
42
43// Attributes
44
45JSC::EncodedJSValue jsWebKitPointConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46bool setJSWebKitPointConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47JSC::EncodedJSValue jsWebKitPointX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSWebKitPointX(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsWebKitPointY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSWebKitPointY(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51
52class JSWebKitPointPrototype : public JSC::JSNonFinalObject {
53public:
54 using Base = JSC::JSNonFinalObject;
55 static JSWebKitPointPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
56 {
57 JSWebKitPointPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebKitPointPrototype>(vm.heap)) JSWebKitPointPrototype(vm, globalObject, structure);
58 ptr->finishCreation(vm);
59 return ptr;
60 }
61
62 DECLARE_INFO;
63 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
64 {
65 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
66 }
67
68private:
69 JSWebKitPointPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
70 : JSC::JSNonFinalObject(vm, structure)
71 {
72 }
73
74 void finishCreation(JSC::VM&);
75};
76
77using JSWebKitPointConstructor = JSDOMConstructor<JSWebKitPoint>;
78
79template<> EncodedJSValue JSC_HOST_CALL JSWebKitPointConstructor::construct(ExecState* state)
80{
81 VM& vm = state->vm();
82 auto throwScope = DECLARE_THROW_SCOPE(vm);
83 UNUSED_PARAM(throwScope);
84 auto* castedThis = jsCast<JSWebKitPointConstructor*>(state->jsCallee());
85 ASSERT(castedThis);
86 auto x = state->argument(0).isUndefined() ? 0 : convert<IDLUnrestrictedFloat>(*state, state->uncheckedArgument(0));
87 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
88 auto y = state->argument(1).isUndefined() ? 0 : convert<IDLUnrestrictedFloat>(*state, state->uncheckedArgument(1));
89 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
90 auto object = WebKitPoint::create(WTFMove(x), WTFMove(y));
91 return JSValue::encode(toJSNewlyCreated<IDLInterface<WebKitPoint>>(*state, *castedThis->globalObject(), WTFMove(object)));
92}
93
94template<> JSValue JSWebKitPointConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
95{
96 UNUSED_PARAM(vm);
97 return globalObject.functionPrototype();
98}
99
100template<> void JSWebKitPointConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
101{
102 putDirect(vm, vm.propertyNames->prototype, JSWebKitPoint::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
103 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WebKitPoint"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
104 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
105}
106
107template<> const ClassInfo JSWebKitPointConstructor::s_info = { "WebKitPoint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitPointConstructor) };
108
109/* Hash table for prototype */
110
111static const HashTableValue JSWebKitPointPrototypeTableValues[] =
112{
113 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitPointConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebKitPointConstructor) } },
114 { "x", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitPointX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebKitPointX) } },
115 { "y", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitPointY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebKitPointY) } },
116};
117
118const ClassInfo JSWebKitPointPrototype::s_info = { "WebKitPointPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitPointPrototype) };
119
120void JSWebKitPointPrototype::finishCreation(VM& vm)
121{
122 Base::finishCreation(vm);
123 reifyStaticProperties(vm, JSWebKitPoint::info(), JSWebKitPointPrototypeTableValues, *this);
124}
125
126const ClassInfo JSWebKitPoint::s_info = { "WebKitPoint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitPoint) };
127
128JSWebKitPoint::JSWebKitPoint(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebKitPoint>&& impl)
129 : JSDOMWrapper<WebKitPoint>(structure, globalObject, WTFMove(impl))
130{
131}
132
133void JSWebKitPoint::finishCreation(VM& vm)
134{
135 Base::finishCreation(vm);
136 ASSERT(inherits(vm, info()));
137
138}
139
140JSObject* JSWebKitPoint::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
141{
142 return JSWebKitPointPrototype::create(vm, &globalObject, JSWebKitPointPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
143}
144
145JSObject* JSWebKitPoint::prototype(VM& vm, JSDOMGlobalObject& globalObject)
146{
147 return getDOMPrototype<JSWebKitPoint>(vm, globalObject);
148}
149
150JSValue JSWebKitPoint::getConstructor(VM& vm, const JSGlobalObject* globalObject)
151{
152 return getDOMConstructor<JSWebKitPointConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
153}
154
155void JSWebKitPoint::destroy(JSC::JSCell* cell)
156{
157 JSWebKitPoint* thisObject = static_cast<JSWebKitPoint*>(cell);
158 thisObject->JSWebKitPoint::~JSWebKitPoint();
159}
160
161template<> inline JSWebKitPoint* IDLAttribute<JSWebKitPoint>::cast(ExecState& state, EncodedJSValue thisValue)
162{
163 return jsDynamicCast<JSWebKitPoint*>(state.vm(), JSValue::decode(thisValue));
164}
165
166EncodedJSValue jsWebKitPointConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSWebKitPointPrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype))
172 return throwVMTypeError(state, throwScope);
173 return JSValue::encode(JSWebKitPoint::getConstructor(state->vm(), prototype->globalObject()));
174}
175
176bool setJSWebKitPointConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
177{
178 VM& vm = state->vm();
179 auto throwScope = DECLARE_THROW_SCOPE(vm);
180 auto* prototype = jsDynamicCast<JSWebKitPointPrototype*>(vm, JSValue::decode(thisValue));
181 if (UNLIKELY(!prototype)) {
182 throwVMTypeError(state, throwScope);
183 return false;
184 }
185 // Shadowing a built-in constructor
186 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
187}
188
189static inline JSValue jsWebKitPointXGetter(ExecState& state, JSWebKitPoint& thisObject, ThrowScope& throwScope)
190{
191 UNUSED_PARAM(throwScope);
192 UNUSED_PARAM(state);
193 auto& impl = thisObject.wrapped();
194 JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.x());
195 return result;
196}
197
198EncodedJSValue jsWebKitPointX(ExecState* state, EncodedJSValue thisValue, PropertyName)
199{
200 return IDLAttribute<JSWebKitPoint>::get<jsWebKitPointXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x");
201}
202
203static inline bool setJSWebKitPointXSetter(ExecState& state, JSWebKitPoint& thisObject, JSValue value, ThrowScope& throwScope)
204{
205 UNUSED_PARAM(throwScope);
206 auto& impl = thisObject.wrapped();
207 auto nativeValue = convert<IDLUnrestrictedFloat>(state, value);
208 RETURN_IF_EXCEPTION(throwScope, false);
209 AttributeSetter::call(state, throwScope, [&] {
210 return impl.setX(WTFMove(nativeValue));
211 });
212 return true;
213}
214
215bool setJSWebKitPointX(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
216{
217 return IDLAttribute<JSWebKitPoint>::set<setJSWebKitPointXSetter>(*state, thisValue, encodedValue, "x");
218}
219
220static inline JSValue jsWebKitPointYGetter(ExecState& state, JSWebKitPoint& thisObject, ThrowScope& throwScope)
221{
222 UNUSED_PARAM(throwScope);
223 UNUSED_PARAM(state);
224 auto& impl = thisObject.wrapped();
225 JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.y());
226 return result;
227}
228
229EncodedJSValue jsWebKitPointY(ExecState* state, EncodedJSValue thisValue, PropertyName)
230{
231 return IDLAttribute<JSWebKitPoint>::get<jsWebKitPointYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y");
232}
233
234static inline bool setJSWebKitPointYSetter(ExecState& state, JSWebKitPoint& thisObject, JSValue value, ThrowScope& throwScope)
235{
236 UNUSED_PARAM(throwScope);
237 auto& impl = thisObject.wrapped();
238 auto nativeValue = convert<IDLUnrestrictedFloat>(state, value);
239 RETURN_IF_EXCEPTION(throwScope, false);
240 AttributeSetter::call(state, throwScope, [&] {
241 return impl.setY(WTFMove(nativeValue));
242 });
243 return true;
244}
245
246bool setJSWebKitPointY(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
247{
248 return IDLAttribute<JSWebKitPoint>::set<setJSWebKitPointYSetter>(*state, thisValue, encodedValue, "y");
249}
250
251void JSWebKitPoint::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
252{
253 auto* thisObject = jsCast<JSWebKitPoint*>(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
260bool JSWebKitPointOwner::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
268void JSWebKitPointOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
269{
270 auto* jsWebKitPoint = static_cast<JSWebKitPoint*>(handle.slot()->asCell());
271 auto& world = *static_cast<DOMWrapperWorld*>(context);
272 uncacheWrapper(world, &jsWebKitPoint->wrapped(), jsWebKitPoint);
273}
274
275JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebKitPoint>&& 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 WebKitPoint.
281 static_assert(!std::is_polymorphic<WebKitPoint>::value, "WebKitPoint is polymorphic but the IDL claims it is not");
282 return createWrapper<WebKitPoint>(globalObject, WTFMove(impl));
283}
284
285JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebKitPoint& impl)
286{
287 return wrap(state, globalObject, impl);
288}
289
290WebKitPoint* JSWebKitPoint::toWrapped(JSC::VM& vm, JSC::JSValue value)
291{
292 if (auto* wrapper = jsDynamicCast<JSWebKitPoint*>(vm, value))
293 return &wrapper->wrapped();
294 return nullptr;
295}
296
297}
298