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
23#if ENABLE(GEOLOCATION)
24
25#include "JSCoordinates.h"
26
27#include "Document.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConvertNullable.h"
31#include "JSDOMConvertNumbers.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMWrapperCache.h"
34#include "ScriptExecutionContext.h"
35#include "Settings.h"
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <wtf/GetPtr.h>
39#include <wtf/PointerPreparations.h>
40#include <wtf/URL.h>
41
42
43namespace WebCore {
44using namespace JSC;
45
46// Attributes
47
48JSC::EncodedJSValue jsCoordinatesLatitude(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49JSC::EncodedJSValue jsCoordinatesLongitude(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50JSC::EncodedJSValue jsCoordinatesAltitude(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsCoordinatesAccuracy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsCoordinatesAltitudeAccuracy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsCoordinatesHeading(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54JSC::EncodedJSValue jsCoordinatesSpeed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55JSC::EncodedJSValue jsCoordinatesFloorLevel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56
57class JSCoordinatesPrototype : public JSC::JSNonFinalObject {
58public:
59 using Base = JSC::JSNonFinalObject;
60 static JSCoordinatesPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
61 {
62 JSCoordinatesPrototype* ptr = new (NotNull, JSC::allocateCell<JSCoordinatesPrototype>(vm.heap)) JSCoordinatesPrototype(vm, globalObject, structure);
63 ptr->finishCreation(vm);
64 return ptr;
65 }
66
67 DECLARE_INFO;
68 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
69 {
70 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
71 }
72
73private:
74 JSCoordinatesPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
75 : JSC::JSNonFinalObject(vm, structure)
76 {
77 }
78
79 void finishCreation(JSC::VM&);
80};
81
82/* Hash table for prototype */
83
84static const HashTableValue JSCoordinatesPrototypeTableValues[] =
85{
86 { "latitude", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesLatitude), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
87 { "longitude", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesLongitude), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
88 { "altitude", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesAltitude), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
89 { "accuracy", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesAccuracy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
90 { "altitudeAccuracy", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesAltitudeAccuracy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
91 { "heading", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesHeading), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
92 { "speed", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesSpeed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
93 { "floorLevel", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCoordinatesFloorLevel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
94};
95
96const ClassInfo JSCoordinatesPrototype::s_info = { "CoordinatesPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCoordinatesPrototype) };
97
98void JSCoordinatesPrototype::finishCreation(VM& vm)
99{
100 Base::finishCreation(vm);
101 reifyStaticProperties(vm, JSCoordinates::info(), JSCoordinatesPrototypeTableValues, *this);
102 bool hasDisabledRuntimeProperties = false;
103 if (!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().geolocationFloorLevelEnabled()) {
104 hasDisabledRuntimeProperties = true;
105 auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("floorLevel"), strlen("floorLevel"));
106 VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
107 JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
108 }
109 if (hasDisabledRuntimeProperties && structure()->isDictionary())
110 flattenDictionaryObject(vm);
111}
112
113const ClassInfo JSCoordinates::s_info = { "Coordinates", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCoordinates) };
114
115JSCoordinates::JSCoordinates(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Coordinates>&& impl)
116 : JSDOMWrapper<Coordinates>(structure, globalObject, WTFMove(impl))
117{
118}
119
120void JSCoordinates::finishCreation(VM& vm)
121{
122 Base::finishCreation(vm);
123 ASSERT(inherits(vm, info()));
124
125}
126
127JSObject* JSCoordinates::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
128{
129 return JSCoordinatesPrototype::create(vm, &globalObject, JSCoordinatesPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
130}
131
132JSObject* JSCoordinates::prototype(VM& vm, JSDOMGlobalObject& globalObject)
133{
134 return getDOMPrototype<JSCoordinates>(vm, globalObject);
135}
136
137void JSCoordinates::destroy(JSC::JSCell* cell)
138{
139 JSCoordinates* thisObject = static_cast<JSCoordinates*>(cell);
140 thisObject->JSCoordinates::~JSCoordinates();
141}
142
143template<> inline JSCoordinates* IDLAttribute<JSCoordinates>::cast(ExecState& state, EncodedJSValue thisValue)
144{
145 return jsDynamicCast<JSCoordinates*>(state.vm(), JSValue::decode(thisValue));
146}
147
148static inline JSValue jsCoordinatesLatitudeGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
149{
150 UNUSED_PARAM(throwScope);
151 UNUSED_PARAM(state);
152 auto& impl = thisObject.wrapped();
153 JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.latitude());
154 return result;
155}
156
157EncodedJSValue jsCoordinatesLatitude(ExecState* state, EncodedJSValue thisValue, PropertyName)
158{
159 return IDLAttribute<JSCoordinates>::get<jsCoordinatesLatitudeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "latitude");
160}
161
162static inline JSValue jsCoordinatesLongitudeGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
163{
164 UNUSED_PARAM(throwScope);
165 UNUSED_PARAM(state);
166 auto& impl = thisObject.wrapped();
167 JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.longitude());
168 return result;
169}
170
171EncodedJSValue jsCoordinatesLongitude(ExecState* state, EncodedJSValue thisValue, PropertyName)
172{
173 return IDLAttribute<JSCoordinates>::get<jsCoordinatesLongitudeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "longitude");
174}
175
176static inline JSValue jsCoordinatesAltitudeGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
177{
178 UNUSED_PARAM(throwScope);
179 UNUSED_PARAM(state);
180 auto& impl = thisObject.wrapped();
181 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(state, throwScope, impl.altitude());
182 return result;
183}
184
185EncodedJSValue jsCoordinatesAltitude(ExecState* state, EncodedJSValue thisValue, PropertyName)
186{
187 return IDLAttribute<JSCoordinates>::get<jsCoordinatesAltitudeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "altitude");
188}
189
190static inline JSValue jsCoordinatesAccuracyGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
191{
192 UNUSED_PARAM(throwScope);
193 UNUSED_PARAM(state);
194 auto& impl = thisObject.wrapped();
195 JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.accuracy());
196 return result;
197}
198
199EncodedJSValue jsCoordinatesAccuracy(ExecState* state, EncodedJSValue thisValue, PropertyName)
200{
201 return IDLAttribute<JSCoordinates>::get<jsCoordinatesAccuracyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "accuracy");
202}
203
204static inline JSValue jsCoordinatesAltitudeAccuracyGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
205{
206 UNUSED_PARAM(throwScope);
207 UNUSED_PARAM(state);
208 auto& impl = thisObject.wrapped();
209 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(state, throwScope, impl.altitudeAccuracy());
210 return result;
211}
212
213EncodedJSValue jsCoordinatesAltitudeAccuracy(ExecState* state, EncodedJSValue thisValue, PropertyName)
214{
215 return IDLAttribute<JSCoordinates>::get<jsCoordinatesAltitudeAccuracyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "altitudeAccuracy");
216}
217
218static inline JSValue jsCoordinatesHeadingGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
219{
220 UNUSED_PARAM(throwScope);
221 UNUSED_PARAM(state);
222 auto& impl = thisObject.wrapped();
223 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(state, throwScope, impl.heading());
224 return result;
225}
226
227EncodedJSValue jsCoordinatesHeading(ExecState* state, EncodedJSValue thisValue, PropertyName)
228{
229 return IDLAttribute<JSCoordinates>::get<jsCoordinatesHeadingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "heading");
230}
231
232static inline JSValue jsCoordinatesSpeedGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
233{
234 UNUSED_PARAM(throwScope);
235 UNUSED_PARAM(state);
236 auto& impl = thisObject.wrapped();
237 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(state, throwScope, impl.speed());
238 return result;
239}
240
241EncodedJSValue jsCoordinatesSpeed(ExecState* state, EncodedJSValue thisValue, PropertyName)
242{
243 return IDLAttribute<JSCoordinates>::get<jsCoordinatesSpeedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "speed");
244}
245
246static inline JSValue jsCoordinatesFloorLevelGetter(ExecState& state, JSCoordinates& thisObject, ThrowScope& throwScope)
247{
248 UNUSED_PARAM(throwScope);
249 UNUSED_PARAM(state);
250 auto& impl = thisObject.wrapped();
251 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(state, throwScope, impl.floorLevel());
252 return result;
253}
254
255EncodedJSValue jsCoordinatesFloorLevel(ExecState* state, EncodedJSValue thisValue, PropertyName)
256{
257 return IDLAttribute<JSCoordinates>::get<jsCoordinatesFloorLevelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "floorLevel");
258}
259
260void JSCoordinates::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
261{
262 auto* thisObject = jsCast<JSCoordinates*>(cell);
263 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
264 if (thisObject->scriptExecutionContext())
265 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
266 Base::heapSnapshot(cell, builder);
267}
268
269bool JSCoordinatesOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
270{
271 UNUSED_PARAM(handle);
272 UNUSED_PARAM(visitor);
273 UNUSED_PARAM(reason);
274 return false;
275}
276
277void JSCoordinatesOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
278{
279 auto* jsCoordinates = static_cast<JSCoordinates*>(handle.slot()->asCell());
280 auto& world = *static_cast<DOMWrapperWorld*>(context);
281 uncacheWrapper(world, &jsCoordinates->wrapped(), jsCoordinates);
282}
283
284JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Coordinates>&& impl)
285{
286 // If you hit this failure the interface definition has the ImplementationLacksVTable
287 // attribute. You should remove that attribute. If the class has subclasses
288 // that may be passed through this toJS() function you should use the SkipVTableValidation
289 // attribute to Coordinates.
290 static_assert(!std::is_polymorphic<Coordinates>::value, "Coordinates is polymorphic but the IDL claims it is not");
291 return createWrapper<Coordinates>(globalObject, WTFMove(impl));
292}
293
294JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Coordinates& impl)
295{
296 return wrap(state, globalObject, impl);
297}
298
299Coordinates* JSCoordinates::toWrapped(JSC::VM& vm, JSC::JSValue value)
300{
301 if (auto* wrapper = jsDynamicCast<JSCoordinates*>(vm, value))
302 return &wrapper->wrapped();
303 return nullptr;
304}
305
306}
307
308#endif // ENABLE(GEOLOCATION)
309