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