| 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(WEBGL) |
| 24 | |
| 25 | #include "JSWebGLContextEvent.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertBoolean.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.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 | |
| 43 | namespace WebCore { |
| 44 | using namespace JSC; |
| 45 | |
| 46 | template<> WebGLContextEvent::Init convertDictionary<WebGLContextEvent::Init>(ExecState& state, JSValue value) |
| 47 | { |
| 48 | VM& vm = state.vm(); |
| 49 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 50 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 51 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 52 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 53 | throwTypeError(&state, throwScope); |
| 54 | return { }; |
| 55 | } |
| 56 | WebGLContextEvent::Init result; |
| 57 | JSValue bubblesValue; |
| 58 | if (isNullOrUndefined) |
| 59 | bubblesValue = jsUndefined(); |
| 60 | else { |
| 61 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
| 62 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 63 | } |
| 64 | if (!bubblesValue.isUndefined()) { |
| 65 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
| 66 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 67 | } else |
| 68 | result.bubbles = false; |
| 69 | JSValue cancelableValue; |
| 70 | if (isNullOrUndefined) |
| 71 | cancelableValue = jsUndefined(); |
| 72 | else { |
| 73 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
| 74 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 75 | } |
| 76 | if (!cancelableValue.isUndefined()) { |
| 77 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
| 78 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 79 | } else |
| 80 | result.cancelable = false; |
| 81 | JSValue composedValue; |
| 82 | if (isNullOrUndefined) |
| 83 | composedValue = jsUndefined(); |
| 84 | else { |
| 85 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
| 86 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 87 | } |
| 88 | if (!composedValue.isUndefined()) { |
| 89 | result.composed = convert<IDLBoolean>(state, composedValue); |
| 90 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 91 | } else |
| 92 | result.composed = false; |
| 93 | JSValue statusMessageValue; |
| 94 | if (isNullOrUndefined) |
| 95 | statusMessageValue = jsUndefined(); |
| 96 | else { |
| 97 | statusMessageValue = object->get(&state, Identifier::fromString(&state, "statusMessage" )); |
| 98 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 99 | } |
| 100 | if (!statusMessageValue.isUndefined()) { |
| 101 | result.statusMessage = convert<IDLDOMString>(state, statusMessageValue); |
| 102 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 103 | } else |
| 104 | result.statusMessage = emptyString(); |
| 105 | return result; |
| 106 | } |
| 107 | |
| 108 | // Attributes |
| 109 | |
| 110 | JSC::EncodedJSValue jsWebGLContextEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 111 | bool setJSWebGLContextEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 112 | JSC::EncodedJSValue jsWebGLContextEventStatusMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 113 | |
| 114 | class JSWebGLContextEventPrototype : public JSC::JSNonFinalObject { |
| 115 | public: |
| 116 | using Base = JSC::JSNonFinalObject; |
| 117 | static JSWebGLContextEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 118 | { |
| 119 | JSWebGLContextEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGLContextEventPrototype>(vm.heap)) JSWebGLContextEventPrototype(vm, globalObject, structure); |
| 120 | ptr->finishCreation(vm); |
| 121 | return ptr; |
| 122 | } |
| 123 | |
| 124 | DECLARE_INFO; |
| 125 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 126 | { |
| 127 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 128 | } |
| 129 | |
| 130 | private: |
| 131 | JSWebGLContextEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 132 | : JSC::JSNonFinalObject(vm, structure) |
| 133 | { |
| 134 | } |
| 135 | |
| 136 | void finishCreation(JSC::VM&); |
| 137 | }; |
| 138 | |
| 139 | using JSWebGLContextEventConstructor = JSDOMConstructor<JSWebGLContextEvent>; |
| 140 | |
| 141 | template<> EncodedJSValue JSC_HOST_CALL JSWebGLContextEventConstructor::construct(ExecState* state) |
| 142 | { |
| 143 | VM& vm = state->vm(); |
| 144 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 145 | UNUSED_PARAM(throwScope); |
| 146 | auto* castedThis = jsCast<JSWebGLContextEventConstructor*>(state->jsCallee()); |
| 147 | ASSERT(castedThis); |
| 148 | if (UNLIKELY(state->argumentCount() < 1)) |
| 149 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 150 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 151 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 152 | auto eventInit = convert<IDLDictionary<WebGLContextEvent::Init>>(*state, state->argument(1)); |
| 153 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 154 | auto object = WebGLContextEvent::create(WTFMove(type), WTFMove(eventInit)); |
| 155 | return JSValue::encode(toJSNewlyCreated<IDLInterface<WebGLContextEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 156 | } |
| 157 | |
| 158 | template<> JSValue JSWebGLContextEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 159 | { |
| 160 | return JSEvent::getConstructor(vm, &globalObject); |
| 161 | } |
| 162 | |
| 163 | template<> void JSWebGLContextEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 164 | { |
| 165 | putDirect(vm, vm.propertyNames->prototype, JSWebGLContextEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 166 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WebGLContextEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 167 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 168 | } |
| 169 | |
| 170 | template<> const ClassInfo JSWebGLContextEventConstructor::s_info = { "WebGLContextEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLContextEventConstructor) }; |
| 171 | |
| 172 | /* Hash table for prototype */ |
| 173 | |
| 174 | static const HashTableValue JSWebGLContextEventPrototypeTableValues[] = |
| 175 | { |
| 176 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGLContextEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGLContextEventConstructor) } }, |
| 177 | { "statusMessage" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGLContextEventStatusMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 178 | }; |
| 179 | |
| 180 | const ClassInfo JSWebGLContextEventPrototype::s_info = { "WebGLContextEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLContextEventPrototype) }; |
| 181 | |
| 182 | void JSWebGLContextEventPrototype::finishCreation(VM& vm) |
| 183 | { |
| 184 | Base::finishCreation(vm); |
| 185 | reifyStaticProperties(vm, JSWebGLContextEvent::info(), JSWebGLContextEventPrototypeTableValues, *this); |
| 186 | } |
| 187 | |
| 188 | const ClassInfo JSWebGLContextEvent::s_info = { "WebGLContextEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLContextEvent) }; |
| 189 | |
| 190 | JSWebGLContextEvent::JSWebGLContextEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGLContextEvent>&& impl) |
| 191 | : JSEvent(structure, globalObject, WTFMove(impl)) |
| 192 | { |
| 193 | } |
| 194 | |
| 195 | void JSWebGLContextEvent::finishCreation(VM& vm) |
| 196 | { |
| 197 | Base::finishCreation(vm); |
| 198 | ASSERT(inherits(vm, info())); |
| 199 | |
| 200 | } |
| 201 | |
| 202 | JSObject* JSWebGLContextEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 203 | { |
| 204 | return JSWebGLContextEventPrototype::create(vm, &globalObject, JSWebGLContextEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
| 205 | } |
| 206 | |
| 207 | JSObject* JSWebGLContextEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 208 | { |
| 209 | return getDOMPrototype<JSWebGLContextEvent>(vm, globalObject); |
| 210 | } |
| 211 | |
| 212 | JSValue JSWebGLContextEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 213 | { |
| 214 | return getDOMConstructor<JSWebGLContextEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 215 | } |
| 216 | |
| 217 | template<> inline JSWebGLContextEvent* IDLAttribute<JSWebGLContextEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
| 218 | { |
| 219 | return jsDynamicCast<JSWebGLContextEvent*>(state.vm(), JSValue::decode(thisValue)); |
| 220 | } |
| 221 | |
| 222 | EncodedJSValue jsWebGLContextEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 223 | { |
| 224 | VM& vm = state->vm(); |
| 225 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 226 | auto* prototype = jsDynamicCast<JSWebGLContextEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 227 | if (UNLIKELY(!prototype)) |
| 228 | return throwVMTypeError(state, throwScope); |
| 229 | return JSValue::encode(JSWebGLContextEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 230 | } |
| 231 | |
| 232 | bool setJSWebGLContextEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 233 | { |
| 234 | VM& vm = state->vm(); |
| 235 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 236 | auto* prototype = jsDynamicCast<JSWebGLContextEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 237 | if (UNLIKELY(!prototype)) { |
| 238 | throwVMTypeError(state, throwScope); |
| 239 | return false; |
| 240 | } |
| 241 | // Shadowing a built-in constructor |
| 242 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 243 | } |
| 244 | |
| 245 | static inline JSValue jsWebGLContextEventStatusMessageGetter(ExecState& state, JSWebGLContextEvent& thisObject, ThrowScope& throwScope) |
| 246 | { |
| 247 | UNUSED_PARAM(throwScope); |
| 248 | UNUSED_PARAM(state); |
| 249 | auto& impl = thisObject.wrapped(); |
| 250 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.statusMessage()); |
| 251 | return result; |
| 252 | } |
| 253 | |
| 254 | EncodedJSValue jsWebGLContextEventStatusMessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 255 | { |
| 256 | return IDLAttribute<JSWebGLContextEvent>::get<jsWebGLContextEventStatusMessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "statusMessage" ); |
| 257 | } |
| 258 | |
| 259 | void JSWebGLContextEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 260 | { |
| 261 | auto* thisObject = jsCast<JSWebGLContextEvent*>(cell); |
| 262 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 263 | if (thisObject->scriptExecutionContext()) |
| 264 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 265 | Base::heapSnapshot(cell, builder); |
| 266 | } |
| 267 | |
| 268 | #if ENABLE(BINDING_INTEGRITY) |
| 269 | #if PLATFORM(WIN) |
| 270 | #pragma warning(disable: 4483) |
| 271 | extern "C" { extern void (*const __identifier("??_7WebGLContextEvent@WebCore@@6B@" )[])(); } |
| 272 | #else |
| 273 | extern "C" { extern void* _ZTVN7WebCore17WebGLContextEventE[]; } |
| 274 | #endif |
| 275 | #endif |
| 276 | |
| 277 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLContextEvent>&& impl) |
| 278 | { |
| 279 | |
| 280 | #if ENABLE(BINDING_INTEGRITY) |
| 281 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 282 | #if PLATFORM(WIN) |
| 283 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGLContextEvent@WebCore@@6B@" )); |
| 284 | #else |
| 285 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17WebGLContextEventE[2]); |
| 286 | #endif |
| 287 | |
| 288 | // If this fails WebGLContextEvent does not have a vtable, so you need to add the |
| 289 | // ImplementationLacksVTable attribute to the interface definition |
| 290 | static_assert(std::is_polymorphic<WebGLContextEvent>::value, "WebGLContextEvent is not polymorphic" ); |
| 291 | |
| 292 | // If you hit this assertion you either have a use after free bug, or |
| 293 | // WebGLContextEvent has subclasses. If WebGLContextEvent has subclasses that get passed |
| 294 | // to toJS() we currently require WebGLContextEvent you to opt out of binding hardening |
| 295 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 296 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 297 | #endif |
| 298 | return createWrapper<WebGLContextEvent>(globalObject, WTFMove(impl)); |
| 299 | } |
| 300 | |
| 301 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGLContextEvent& impl) |
| 302 | { |
| 303 | return wrap(state, globalObject, impl); |
| 304 | } |
| 305 | |
| 306 | |
| 307 | } |
| 308 | |
| 309 | #endif // ENABLE(WEBGL) |
| 310 | |