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 "JSGeoposition.h"
26
27#include "JSCoordinates.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConvertInterface.h"
31#include "JSDOMConvertNumbers.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMWrapperCache.h"
35#include "ScriptExecutionContext.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 jsGeopositionCoords(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49JSC::EncodedJSValue jsGeopositionTimestamp(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50
51class JSGeopositionPrototype : public JSC::JSNonFinalObject {
52public:
53 using Base = JSC::JSNonFinalObject;
54 static JSGeopositionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
55 {
56 JSGeopositionPrototype* ptr = new (NotNull, JSC::allocateCell<JSGeopositionPrototype>(vm.heap)) JSGeopositionPrototype(vm, globalObject, structure);
57 ptr->finishCreation(vm);
58 return ptr;
59 }
60
61 DECLARE_INFO;
62 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63 {
64 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65 }
66
67private:
68 JSGeopositionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69 : JSC::JSNonFinalObject(vm, structure)
70 {
71 }
72
73 void finishCreation(JSC::VM&);
74};
75
76/* Hash table for prototype */
77
78static const HashTableValue JSGeopositionPrototypeTableValues[] =
79{
80 { "coords", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsGeopositionCoords), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
81 { "timestamp", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsGeopositionTimestamp), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
82};
83
84const ClassInfo JSGeopositionPrototype::s_info = { "GeopositionPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGeopositionPrototype) };
85
86void JSGeopositionPrototype::finishCreation(VM& vm)
87{
88 Base::finishCreation(vm);
89 reifyStaticProperties(vm, JSGeoposition::info(), JSGeopositionPrototypeTableValues, *this);
90}
91
92const ClassInfo JSGeoposition::s_info = { "Geoposition", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGeoposition) };
93
94JSGeoposition::JSGeoposition(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Geoposition>&& impl)
95 : JSDOMWrapper<Geoposition>(structure, globalObject, WTFMove(impl))
96{
97}
98
99void JSGeoposition::finishCreation(VM& vm)
100{
101 Base::finishCreation(vm);
102 ASSERT(inherits(vm, info()));
103
104}
105
106JSObject* JSGeoposition::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
107{
108 return JSGeopositionPrototype::create(vm, &globalObject, JSGeopositionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
109}
110
111JSObject* JSGeoposition::prototype(VM& vm, JSDOMGlobalObject& globalObject)
112{
113 return getDOMPrototype<JSGeoposition>(vm, globalObject);
114}
115
116void JSGeoposition::destroy(JSC::JSCell* cell)
117{
118 JSGeoposition* thisObject = static_cast<JSGeoposition*>(cell);
119 thisObject->JSGeoposition::~JSGeoposition();
120}
121
122template<> inline JSGeoposition* IDLAttribute<JSGeoposition>::cast(ExecState& state, EncodedJSValue thisValue)
123{
124 return jsDynamicCast<JSGeoposition*>(state.vm(), JSValue::decode(thisValue));
125}
126
127static inline JSValue jsGeopositionCoordsGetter(ExecState& state, JSGeoposition& thisObject, ThrowScope& throwScope)
128{
129 UNUSED_PARAM(throwScope);
130 UNUSED_PARAM(state);
131 auto& impl = thisObject.wrapped();
132 JSValue result = toJS<IDLInterface<Coordinates>>(state, *thisObject.globalObject(), throwScope, impl.coords());
133 return result;
134}
135
136EncodedJSValue jsGeopositionCoords(ExecState* state, EncodedJSValue thisValue, PropertyName)
137{
138 return IDLAttribute<JSGeoposition>::get<jsGeopositionCoordsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "coords");
139}
140
141static inline JSValue jsGeopositionTimestampGetter(ExecState& state, JSGeoposition& thisObject, ThrowScope& throwScope)
142{
143 UNUSED_PARAM(throwScope);
144 UNUSED_PARAM(state);
145 auto& impl = thisObject.wrapped();
146 JSValue result = toJS<IDLUnsignedLongLong>(state, throwScope, impl.timestamp());
147 return result;
148}
149
150EncodedJSValue jsGeopositionTimestamp(ExecState* state, EncodedJSValue thisValue, PropertyName)
151{
152 return IDLAttribute<JSGeoposition>::get<jsGeopositionTimestampGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "timestamp");
153}
154
155void JSGeoposition::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
156{
157 auto* thisObject = jsCast<JSGeoposition*>(cell);
158 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
159 if (thisObject->scriptExecutionContext())
160 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
161 Base::heapSnapshot(cell, builder);
162}
163
164bool JSGeopositionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
165{
166 UNUSED_PARAM(handle);
167 UNUSED_PARAM(visitor);
168 UNUSED_PARAM(reason);
169 return false;
170}
171
172void JSGeopositionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
173{
174 auto* jsGeoposition = static_cast<JSGeoposition*>(handle.slot()->asCell());
175 auto& world = *static_cast<DOMWrapperWorld*>(context);
176 uncacheWrapper(world, &jsGeoposition->wrapped(), jsGeoposition);
177}
178
179JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Geoposition>&& impl)
180{
181 // If you hit this failure the interface definition has the ImplementationLacksVTable
182 // attribute. You should remove that attribute. If the class has subclasses
183 // that may be passed through this toJS() function you should use the SkipVTableValidation
184 // attribute to Geoposition.
185 static_assert(!std::is_polymorphic<Geoposition>::value, "Geoposition is polymorphic but the IDL claims it is not");
186 return createWrapper<Geoposition>(globalObject, WTFMove(impl));
187}
188
189JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Geoposition& impl)
190{
191 return wrap(state, globalObject, impl);
192}
193
194Geoposition* JSGeoposition::toWrapped(JSC::VM& vm, JSC::JSValue value)
195{
196 if (auto* wrapper = jsDynamicCast<JSGeoposition*>(vm, value))
197 return &wrapper->wrapped();
198 return nullptr;
199}
200
201}
202
203#endif // ENABLE(GEOLOCATION)
204