| 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 "JSVRDisplay.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertCallbacks.h" |
| 29 | #include "JSDOMConvertDictionary.h" |
| 30 | #include "JSDOMConvertEnumeration.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertNullable.h" |
| 33 | #include "JSDOMConvertNumbers.h" |
| 34 | #include "JSDOMConvertSequences.h" |
| 35 | #include "JSDOMConvertStrings.h" |
| 36 | #include "JSDOMExceptionHandling.h" |
| 37 | #include "JSDOMGlobalObject.h" |
| 38 | #include "JSDOMOperation.h" |
| 39 | #include "JSDOMOperationReturningPromise.h" |
| 40 | #include "JSDOMWrapperCache.h" |
| 41 | #include "JSRequestAnimationFrameCallback.h" |
| 42 | #include "JSVRDisplayCapabilities.h" |
| 43 | #include "JSVREye.h" |
| 44 | #include "JSVREyeParameters.h" |
| 45 | #include "JSVRFrameData.h" |
| 46 | #include "JSVRLayerInit.h" |
| 47 | #include "JSVRPose.h" |
| 48 | #include "JSVRStageParameters.h" |
| 49 | #include "ScriptExecutionContext.h" |
| 50 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 51 | #include <JavaScriptCore/JSArray.h> |
| 52 | #include <JavaScriptCore/JSCInlines.h> |
| 53 | #include <wtf/GetPtr.h> |
| 54 | #include <wtf/PointerPreparations.h> |
| 55 | #include <wtf/URL.h> |
| 56 | |
| 57 | |
| 58 | namespace WebCore { |
| 59 | using namespace JSC; |
| 60 | |
| 61 | // Functions |
| 62 | |
| 63 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetEyeParameters(JSC::ExecState*); |
| 64 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetFrameData(JSC::ExecState*); |
| 65 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetPose(JSC::ExecState*); |
| 66 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionResetPose(JSC::ExecState*); |
| 67 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionRequestAnimationFrame(JSC::ExecState*); |
| 68 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionCancelAnimationFrame(JSC::ExecState*); |
| 69 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionRequestPresent(JSC::ExecState*); |
| 70 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionExitPresent(JSC::ExecState*); |
| 71 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetLayers(JSC::ExecState*); |
| 72 | JSC::EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionSubmitFrame(JSC::ExecState*); |
| 73 | |
| 74 | // Attributes |
| 75 | |
| 76 | JSC::EncodedJSValue jsVRDisplayConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 77 | bool setJSVRDisplayConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 78 | JSC::EncodedJSValue jsVRDisplayIsConnected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 79 | JSC::EncodedJSValue jsVRDisplayIsPresenting(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 80 | JSC::EncodedJSValue jsVRDisplayCapabilities(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 81 | JSC::EncodedJSValue jsVRDisplayStageParameters(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 82 | JSC::EncodedJSValue jsVRDisplayDisplayId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 83 | JSC::EncodedJSValue jsVRDisplayDisplayName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 84 | JSC::EncodedJSValue jsVRDisplayDepthNear(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 85 | bool setJSVRDisplayDepthNear(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 86 | JSC::EncodedJSValue jsVRDisplayDepthFar(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 87 | bool setJSVRDisplayDepthFar(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 88 | |
| 89 | class JSVRDisplayPrototype : public JSC::JSNonFinalObject { |
| 90 | public: |
| 91 | using Base = JSC::JSNonFinalObject; |
| 92 | static JSVRDisplayPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 93 | { |
| 94 | JSVRDisplayPrototype* ptr = new (NotNull, JSC::allocateCell<JSVRDisplayPrototype>(vm.heap)) JSVRDisplayPrototype(vm, globalObject, structure); |
| 95 | ptr->finishCreation(vm); |
| 96 | return ptr; |
| 97 | } |
| 98 | |
| 99 | DECLARE_INFO; |
| 100 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 101 | { |
| 102 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | JSVRDisplayPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 107 | : JSC::JSNonFinalObject(vm, structure) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | void finishCreation(JSC::VM&); |
| 112 | }; |
| 113 | |
| 114 | using JSVRDisplayConstructor = JSDOMConstructorNotConstructable<JSVRDisplay>; |
| 115 | |
| 116 | template<> JSValue JSVRDisplayConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 117 | { |
| 118 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 119 | } |
| 120 | |
| 121 | template<> void JSVRDisplayConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 122 | { |
| 123 | putDirect(vm, vm.propertyNames->prototype, JSVRDisplay::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 124 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("VRDisplay"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 125 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 126 | } |
| 127 | |
| 128 | template<> const ClassInfo JSVRDisplayConstructor::s_info = { "VRDisplay" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVRDisplayConstructor) }; |
| 129 | |
| 130 | /* Hash table for prototype */ |
| 131 | |
| 132 | static const HashTableValue JSVRDisplayPrototypeTableValues[] = |
| 133 | { |
| 134 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVRDisplayConstructor) } }, |
| 135 | { "isConnected" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayIsConnected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 136 | { "isPresenting" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayIsPresenting), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 137 | { "capabilities" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayCapabilities), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 138 | { "stageParameters" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayStageParameters), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 139 | { "displayId" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayDisplayId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 140 | { "displayName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayDisplayName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 141 | { "depthNear" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayDepthNear), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVRDisplayDepthNear) } }, |
| 142 | { "depthFar" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVRDisplayDepthFar), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVRDisplayDepthFar) } }, |
| 143 | { "getEyeParameters" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionGetEyeParameters), (intptr_t) (1) } }, |
| 144 | { "getFrameData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionGetFrameData), (intptr_t) (1) } }, |
| 145 | { "getPose" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionGetPose), (intptr_t) (0) } }, |
| 146 | { "resetPose" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionResetPose), (intptr_t) (0) } }, |
| 147 | { "requestAnimationFrame" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionRequestAnimationFrame), (intptr_t) (1) } }, |
| 148 | { "cancelAnimationFrame" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionCancelAnimationFrame), (intptr_t) (1) } }, |
| 149 | { "requestPresent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionRequestPresent), (intptr_t) (1) } }, |
| 150 | { "exitPresent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionExitPresent), (intptr_t) (0) } }, |
| 151 | { "getLayers" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionGetLayers), (intptr_t) (0) } }, |
| 152 | { "submitFrame" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsVRDisplayPrototypeFunctionSubmitFrame), (intptr_t) (0) } }, |
| 153 | }; |
| 154 | |
| 155 | const ClassInfo JSVRDisplayPrototype::s_info = { "VRDisplayPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVRDisplayPrototype) }; |
| 156 | |
| 157 | void JSVRDisplayPrototype::finishCreation(VM& vm) |
| 158 | { |
| 159 | Base::finishCreation(vm); |
| 160 | reifyStaticProperties(vm, JSVRDisplay::info(), JSVRDisplayPrototypeTableValues, *this); |
| 161 | } |
| 162 | |
| 163 | const ClassInfo JSVRDisplay::s_info = { "VRDisplay" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVRDisplay) }; |
| 164 | |
| 165 | JSVRDisplay::JSVRDisplay(Structure* structure, JSDOMGlobalObject& globalObject, Ref<VRDisplay>&& impl) |
| 166 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 167 | { |
| 168 | } |
| 169 | |
| 170 | void JSVRDisplay::finishCreation(VM& vm) |
| 171 | { |
| 172 | Base::finishCreation(vm); |
| 173 | ASSERT(inherits(vm, info())); |
| 174 | |
| 175 | } |
| 176 | |
| 177 | JSObject* JSVRDisplay::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 178 | { |
| 179 | return JSVRDisplayPrototype::create(vm, &globalObject, JSVRDisplayPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 180 | } |
| 181 | |
| 182 | JSObject* JSVRDisplay::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 183 | { |
| 184 | return getDOMPrototype<JSVRDisplay>(vm, globalObject); |
| 185 | } |
| 186 | |
| 187 | JSValue JSVRDisplay::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 188 | { |
| 189 | return getDOMConstructor<JSVRDisplayConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 190 | } |
| 191 | |
| 192 | template<> inline JSVRDisplay* IDLAttribute<JSVRDisplay>::cast(ExecState& state, EncodedJSValue thisValue) |
| 193 | { |
| 194 | return jsDynamicCast<JSVRDisplay*>(state.vm(), JSValue::decode(thisValue)); |
| 195 | } |
| 196 | |
| 197 | template<> inline JSVRDisplay* IDLOperation<JSVRDisplay>::cast(ExecState& state) |
| 198 | { |
| 199 | return jsDynamicCast<JSVRDisplay*>(state.vm(), state.thisValue()); |
| 200 | } |
| 201 | |
| 202 | EncodedJSValue jsVRDisplayConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 203 | { |
| 204 | VM& vm = state->vm(); |
| 205 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 206 | auto* prototype = jsDynamicCast<JSVRDisplayPrototype*>(vm, JSValue::decode(thisValue)); |
| 207 | if (UNLIKELY(!prototype)) |
| 208 | return throwVMTypeError(state, throwScope); |
| 209 | return JSValue::encode(JSVRDisplay::getConstructor(state->vm(), prototype->globalObject())); |
| 210 | } |
| 211 | |
| 212 | bool setJSVRDisplayConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 213 | { |
| 214 | VM& vm = state->vm(); |
| 215 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 216 | auto* prototype = jsDynamicCast<JSVRDisplayPrototype*>(vm, JSValue::decode(thisValue)); |
| 217 | if (UNLIKELY(!prototype)) { |
| 218 | throwVMTypeError(state, throwScope); |
| 219 | return false; |
| 220 | } |
| 221 | // Shadowing a built-in constructor |
| 222 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 223 | } |
| 224 | |
| 225 | static inline JSValue jsVRDisplayIsConnectedGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 226 | { |
| 227 | UNUSED_PARAM(throwScope); |
| 228 | UNUSED_PARAM(state); |
| 229 | auto& impl = thisObject.wrapped(); |
| 230 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isConnected()); |
| 231 | return result; |
| 232 | } |
| 233 | |
| 234 | EncodedJSValue jsVRDisplayIsConnected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 235 | { |
| 236 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayIsConnectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isConnected" ); |
| 237 | } |
| 238 | |
| 239 | static inline JSValue jsVRDisplayIsPresentingGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 240 | { |
| 241 | UNUSED_PARAM(throwScope); |
| 242 | UNUSED_PARAM(state); |
| 243 | auto& impl = thisObject.wrapped(); |
| 244 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isPresenting()); |
| 245 | return result; |
| 246 | } |
| 247 | |
| 248 | EncodedJSValue jsVRDisplayIsPresenting(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 249 | { |
| 250 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayIsPresentingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isPresenting" ); |
| 251 | } |
| 252 | |
| 253 | static inline JSValue jsVRDisplayCapabilitiesGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 254 | { |
| 255 | UNUSED_PARAM(throwScope); |
| 256 | UNUSED_PARAM(state); |
| 257 | auto& impl = thisObject.wrapped(); |
| 258 | JSValue result = toJS<IDLInterface<VRDisplayCapabilities>>(state, *thisObject.globalObject(), throwScope, impl.capabilities()); |
| 259 | return result; |
| 260 | } |
| 261 | |
| 262 | EncodedJSValue jsVRDisplayCapabilities(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 263 | { |
| 264 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayCapabilitiesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "capabilities" ); |
| 265 | } |
| 266 | |
| 267 | static inline JSValue jsVRDisplayStageParametersGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 268 | { |
| 269 | UNUSED_PARAM(throwScope); |
| 270 | UNUSED_PARAM(state); |
| 271 | auto& impl = thisObject.wrapped(); |
| 272 | JSValue result = toJS<IDLNullable<IDLInterface<VRStageParameters>>>(state, *thisObject.globalObject(), throwScope, impl.stageParameters()); |
| 273 | return result; |
| 274 | } |
| 275 | |
| 276 | EncodedJSValue jsVRDisplayStageParameters(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 277 | { |
| 278 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayStageParametersGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "stageParameters" ); |
| 279 | } |
| 280 | |
| 281 | static inline JSValue jsVRDisplayDisplayIdGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 282 | { |
| 283 | UNUSED_PARAM(throwScope); |
| 284 | UNUSED_PARAM(state); |
| 285 | auto& impl = thisObject.wrapped(); |
| 286 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.displayId()); |
| 287 | return result; |
| 288 | } |
| 289 | |
| 290 | EncodedJSValue jsVRDisplayDisplayId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 291 | { |
| 292 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayDisplayIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "displayId" ); |
| 293 | } |
| 294 | |
| 295 | static inline JSValue jsVRDisplayDisplayNameGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 296 | { |
| 297 | UNUSED_PARAM(throwScope); |
| 298 | UNUSED_PARAM(state); |
| 299 | auto& impl = thisObject.wrapped(); |
| 300 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.displayName()); |
| 301 | return result; |
| 302 | } |
| 303 | |
| 304 | EncodedJSValue jsVRDisplayDisplayName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 305 | { |
| 306 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayDisplayNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "displayName" ); |
| 307 | } |
| 308 | |
| 309 | static inline JSValue jsVRDisplayDepthNearGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 310 | { |
| 311 | UNUSED_PARAM(throwScope); |
| 312 | UNUSED_PARAM(state); |
| 313 | auto& impl = thisObject.wrapped(); |
| 314 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.depthNear()); |
| 315 | return result; |
| 316 | } |
| 317 | |
| 318 | EncodedJSValue jsVRDisplayDepthNear(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 319 | { |
| 320 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayDepthNearGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "depthNear" ); |
| 321 | } |
| 322 | |
| 323 | static inline bool setJSVRDisplayDepthNearSetter(ExecState& state, JSVRDisplay& thisObject, JSValue value, ThrowScope& throwScope) |
| 324 | { |
| 325 | UNUSED_PARAM(throwScope); |
| 326 | auto& impl = thisObject.wrapped(); |
| 327 | auto nativeValue = convert<IDLDouble>(state, value); |
| 328 | RETURN_IF_EXCEPTION(throwScope, false); |
| 329 | AttributeSetter::call(state, throwScope, [&] { |
| 330 | return impl.setDepthNear(WTFMove(nativeValue)); |
| 331 | }); |
| 332 | return true; |
| 333 | } |
| 334 | |
| 335 | bool setJSVRDisplayDepthNear(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 336 | { |
| 337 | return IDLAttribute<JSVRDisplay>::set<setJSVRDisplayDepthNearSetter>(*state, thisValue, encodedValue, "depthNear" ); |
| 338 | } |
| 339 | |
| 340 | static inline JSValue jsVRDisplayDepthFarGetter(ExecState& state, JSVRDisplay& thisObject, ThrowScope& throwScope) |
| 341 | { |
| 342 | UNUSED_PARAM(throwScope); |
| 343 | UNUSED_PARAM(state); |
| 344 | auto& impl = thisObject.wrapped(); |
| 345 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.depthFar()); |
| 346 | return result; |
| 347 | } |
| 348 | |
| 349 | EncodedJSValue jsVRDisplayDepthFar(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 350 | { |
| 351 | return IDLAttribute<JSVRDisplay>::get<jsVRDisplayDepthFarGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "depthFar" ); |
| 352 | } |
| 353 | |
| 354 | static inline bool setJSVRDisplayDepthFarSetter(ExecState& state, JSVRDisplay& thisObject, JSValue value, ThrowScope& throwScope) |
| 355 | { |
| 356 | UNUSED_PARAM(throwScope); |
| 357 | auto& impl = thisObject.wrapped(); |
| 358 | auto nativeValue = convert<IDLDouble>(state, value); |
| 359 | RETURN_IF_EXCEPTION(throwScope, false); |
| 360 | AttributeSetter::call(state, throwScope, [&] { |
| 361 | return impl.setDepthFar(WTFMove(nativeValue)); |
| 362 | }); |
| 363 | return true; |
| 364 | } |
| 365 | |
| 366 | bool setJSVRDisplayDepthFar(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 367 | { |
| 368 | return IDLAttribute<JSVRDisplay>::set<setJSVRDisplayDepthFarSetter>(*state, thisValue, encodedValue, "depthFar" ); |
| 369 | } |
| 370 | |
| 371 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionGetEyeParametersBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 372 | { |
| 373 | UNUSED_PARAM(state); |
| 374 | UNUSED_PARAM(throwScope); |
| 375 | auto& impl = castedThis->wrapped(); |
| 376 | if (UNLIKELY(state->argumentCount() < 1)) |
| 377 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 378 | auto whichEye = convert<IDLEnumeration<VREye>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 0, "whichEye" , "VRDisplay" , "getEyeParameters" , expectedEnumerationValues<VREye>()); }); |
| 379 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 380 | return JSValue::encode(toJS<IDLInterface<VREyeParameters>>(*state, *castedThis->globalObject(), impl.getEyeParameters(WTFMove(whichEye)))); |
| 381 | } |
| 382 | |
| 383 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetEyeParameters(ExecState* state) |
| 384 | { |
| 385 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionGetEyeParametersBody>(*state, "getEyeParameters" ); |
| 386 | } |
| 387 | |
| 388 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionGetFrameDataBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 389 | { |
| 390 | UNUSED_PARAM(state); |
| 391 | UNUSED_PARAM(throwScope); |
| 392 | auto& impl = castedThis->wrapped(); |
| 393 | if (UNLIKELY(state->argumentCount() < 1)) |
| 394 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 395 | auto frameData = convert<IDLInterface<VRFrameData>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "frameData" , "VRDisplay" , "getFrameData" , "VRFrameData" ); }); |
| 396 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 397 | return JSValue::encode(toJS<IDLBoolean>(impl.getFrameData(*frameData))); |
| 398 | } |
| 399 | |
| 400 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetFrameData(ExecState* state) |
| 401 | { |
| 402 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionGetFrameDataBody>(*state, "getFrameData" ); |
| 403 | } |
| 404 | |
| 405 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionGetPoseBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 406 | { |
| 407 | UNUSED_PARAM(state); |
| 408 | UNUSED_PARAM(throwScope); |
| 409 | auto& impl = castedThis->wrapped(); |
| 410 | return JSValue::encode(toJSNewlyCreated<IDLInterface<VRPose>>(*state, *castedThis->globalObject(), impl.getPose())); |
| 411 | } |
| 412 | |
| 413 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetPose(ExecState* state) |
| 414 | { |
| 415 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionGetPoseBody>(*state, "getPose" ); |
| 416 | } |
| 417 | |
| 418 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionResetPoseBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 419 | { |
| 420 | UNUSED_PARAM(state); |
| 421 | UNUSED_PARAM(throwScope); |
| 422 | auto& impl = castedThis->wrapped(); |
| 423 | impl.resetPose(); |
| 424 | return JSValue::encode(jsUndefined()); |
| 425 | } |
| 426 | |
| 427 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionResetPose(ExecState* state) |
| 428 | { |
| 429 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionResetPoseBody>(*state, "resetPose" ); |
| 430 | } |
| 431 | |
| 432 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionRequestAnimationFrameBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 433 | { |
| 434 | UNUSED_PARAM(state); |
| 435 | UNUSED_PARAM(throwScope); |
| 436 | auto& impl = castedThis->wrapped(); |
| 437 | if (UNLIKELY(state->argumentCount() < 1)) |
| 438 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 439 | auto callback = convert<IDLCallbackFunction<JSRequestAnimationFrameCallback>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback" , "VRDisplay" , "requestAnimationFrame" ); }); |
| 440 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 441 | return JSValue::encode(toJS<IDLLong>(impl.requestAnimationFrame(callback.releaseNonNull()))); |
| 442 | } |
| 443 | |
| 444 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionRequestAnimationFrame(ExecState* state) |
| 445 | { |
| 446 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionRequestAnimationFrameBody>(*state, "requestAnimationFrame" ); |
| 447 | } |
| 448 | |
| 449 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionCancelAnimationFrameBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 450 | { |
| 451 | UNUSED_PARAM(state); |
| 452 | UNUSED_PARAM(throwScope); |
| 453 | auto& impl = castedThis->wrapped(); |
| 454 | if (UNLIKELY(state->argumentCount() < 1)) |
| 455 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 456 | auto handle = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 457 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 458 | impl.cancelAnimationFrame(WTFMove(handle)); |
| 459 | return JSValue::encode(jsUndefined()); |
| 460 | } |
| 461 | |
| 462 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionCancelAnimationFrame(ExecState* state) |
| 463 | { |
| 464 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionCancelAnimationFrameBody>(*state, "cancelAnimationFrame" ); |
| 465 | } |
| 466 | |
| 467 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionRequestPresentBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSVRDisplay>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 468 | { |
| 469 | UNUSED_PARAM(state); |
| 470 | UNUSED_PARAM(throwScope); |
| 471 | auto& impl = castedThis->wrapped(); |
| 472 | if (UNLIKELY(state->argumentCount() < 1)) |
| 473 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 474 | auto layers = convert<IDLSequence<IDLDictionary<VRLayerInit>>>(*state, state->uncheckedArgument(0)); |
| 475 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 476 | impl.requestPresent(WTFMove(layers), WTFMove(promise)); |
| 477 | return JSValue::encode(jsUndefined()); |
| 478 | } |
| 479 | |
| 480 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionRequestPresent(ExecState* state) |
| 481 | { |
| 482 | return IDLOperationReturningPromise<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionRequestPresentBody, PromiseExecutionScope::WindowOnly>(*state, "requestPresent" ); |
| 483 | } |
| 484 | |
| 485 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionExitPresentBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSVRDisplay>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 486 | { |
| 487 | UNUSED_PARAM(state); |
| 488 | UNUSED_PARAM(throwScope); |
| 489 | auto& impl = castedThis->wrapped(); |
| 490 | impl.exitPresent(WTFMove(promise)); |
| 491 | return JSValue::encode(jsUndefined()); |
| 492 | } |
| 493 | |
| 494 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionExitPresent(ExecState* state) |
| 495 | { |
| 496 | return IDLOperationReturningPromise<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionExitPresentBody, PromiseExecutionScope::WindowOnly>(*state, "exitPresent" ); |
| 497 | } |
| 498 | |
| 499 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionGetLayersBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 500 | { |
| 501 | UNUSED_PARAM(state); |
| 502 | UNUSED_PARAM(throwScope); |
| 503 | auto& impl = castedThis->wrapped(); |
| 504 | return JSValue::encode(toJS<IDLSequence<IDLDictionary<VRLayerInit>>>(*state, *castedThis->globalObject(), impl.getLayers())); |
| 505 | } |
| 506 | |
| 507 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionGetLayers(ExecState* state) |
| 508 | { |
| 509 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionGetLayersBody>(*state, "getLayers" ); |
| 510 | } |
| 511 | |
| 512 | static inline JSC::EncodedJSValue jsVRDisplayPrototypeFunctionSubmitFrameBody(JSC::ExecState* state, typename IDLOperation<JSVRDisplay>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 513 | { |
| 514 | UNUSED_PARAM(state); |
| 515 | UNUSED_PARAM(throwScope); |
| 516 | auto& impl = castedThis->wrapped(); |
| 517 | impl.submitFrame(); |
| 518 | return JSValue::encode(jsUndefined()); |
| 519 | } |
| 520 | |
| 521 | EncodedJSValue JSC_HOST_CALL jsVRDisplayPrototypeFunctionSubmitFrame(ExecState* state) |
| 522 | { |
| 523 | return IDLOperation<JSVRDisplay>::call<jsVRDisplayPrototypeFunctionSubmitFrameBody>(*state, "submitFrame" ); |
| 524 | } |
| 525 | |
| 526 | void JSVRDisplay::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 527 | { |
| 528 | auto* thisObject = jsCast<JSVRDisplay*>(cell); |
| 529 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 530 | if (thisObject->scriptExecutionContext()) |
| 531 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 532 | Base::heapSnapshot(cell, builder); |
| 533 | } |
| 534 | |
| 535 | #if ENABLE(BINDING_INTEGRITY) |
| 536 | #if PLATFORM(WIN) |
| 537 | #pragma warning(disable: 4483) |
| 538 | extern "C" { extern void (*const __identifier("??_7VRDisplay@WebCore@@6B@" )[])(); } |
| 539 | #else |
| 540 | extern "C" { extern void* _ZTVN7WebCore9VRDisplayE[]; } |
| 541 | #endif |
| 542 | #endif |
| 543 | |
| 544 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<VRDisplay>&& impl) |
| 545 | { |
| 546 | |
| 547 | #if ENABLE(BINDING_INTEGRITY) |
| 548 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 549 | #if PLATFORM(WIN) |
| 550 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7VRDisplay@WebCore@@6B@" )); |
| 551 | #else |
| 552 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore9VRDisplayE[2]); |
| 553 | #endif |
| 554 | |
| 555 | // If this fails VRDisplay does not have a vtable, so you need to add the |
| 556 | // ImplementationLacksVTable attribute to the interface definition |
| 557 | static_assert(std::is_polymorphic<VRDisplay>::value, "VRDisplay is not polymorphic" ); |
| 558 | |
| 559 | // If you hit this assertion you either have a use after free bug, or |
| 560 | // VRDisplay has subclasses. If VRDisplay has subclasses that get passed |
| 561 | // to toJS() we currently require VRDisplay you to opt out of binding hardening |
| 562 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 563 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 564 | #endif |
| 565 | return createWrapper<VRDisplay>(globalObject, WTFMove(impl)); |
| 566 | } |
| 567 | |
| 568 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, VRDisplay& impl) |
| 569 | { |
| 570 | return wrap(state, globalObject, impl); |
| 571 | } |
| 572 | |
| 573 | VRDisplay* JSVRDisplay::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 574 | { |
| 575 | if (auto* wrapper = jsDynamicCast<JSVRDisplay*>(vm, value)) |
| 576 | return &wrapper->wrapped(); |
| 577 | return nullptr; |
| 578 | } |
| 579 | |
| 580 | } |
| 581 | |