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