utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 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 "JSTestPromiseRejectionEvent.h" |
| 23 | |
weinig@apple.com | 5a46ef0 | 2017-08-09 01:01:44 +0000 | [diff] [blame] | 24 | #include "DOMPromiseProxy.h" |
weinig@apple.com | 96c96d9 | 2017-05-25 17:39:57 +0000 | [diff] [blame] | 25 | #include "JSDOMAttribute.h" |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 26 | #include "JSDOMBinding.h" |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 27 | #include "JSDOMConstructor.h" |
commit-queue@webkit.org | e196714 | 2017-06-15 17:49:50 +0000 | [diff] [blame] | 28 | #include "JSDOMConvertAny.h" |
| 29 | #include "JSDOMConvertBoolean.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertPromise.h" |
| 32 | #include "JSDOMConvertStrings.h" |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 33 | #include "JSDOMExceptionHandling.h" |
weinig@apple.com | 5a46ef0 | 2017-08-09 01:01:44 +0000 | [diff] [blame] | 34 | #include "JSDOMGlobalObject.h" |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 35 | #include "JSDOMWrapperCache.h" |
don.olmstead@sony.com | aa7e1648 | 2018-02-03 00:57:02 +0000 | [diff] [blame] | 36 | #include <JavaScriptCore/JSCInlines.h> |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 37 | #include <wtf/GetPtr.h> |
mark.lam@apple.com | bde8a73 | 2018-01-27 00:43:27 +0000 | [diff] [blame] | 38 | #include <wtf/PointerPreparations.h> |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 39 | |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 40 | |
| 41 | namespace WebCore { |
keith_miller@apple.com | ce64b73 | 2017-10-17 07:10:58 +0000 | [diff] [blame] | 42 | using namespace JSC; |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 43 | |
| 44 | template<> TestPromiseRejectionEvent::Init convertDictionary<TestPromiseRejectionEvent::Init>(ExecState& state, JSValue value) |
| 45 | { |
| 46 | VM& vm = state.vm(); |
| 47 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 48 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 49 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 50 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 51 | throwTypeError(&state, throwScope); |
| 52 | return { }; |
| 53 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 54 | TestPromiseRejectionEvent::Init result; |
cdumez@apple.com | 8cd0d31 | 2018-02-01 23:33:19 +0000 | [diff] [blame] | 55 | JSValue bubblesValue; |
| 56 | if (isNullOrUndefined) |
| 57 | bubblesValue = jsUndefined(); |
| 58 | else { |
| 59 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles")); |
| 60 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 61 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 62 | if (!bubblesValue.isUndefined()) { |
| 63 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
| 64 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 65 | } else |
| 66 | result.bubbles = false; |
cdumez@apple.com | 8cd0d31 | 2018-02-01 23:33:19 +0000 | [diff] [blame] | 67 | JSValue cancelableValue; |
| 68 | if (isNullOrUndefined) |
| 69 | cancelableValue = jsUndefined(); |
| 70 | else { |
| 71 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable")); |
| 72 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 73 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 74 | if (!cancelableValue.isUndefined()) { |
| 75 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
| 76 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 77 | } else |
| 78 | result.cancelable = false; |
cdumez@apple.com | 8cd0d31 | 2018-02-01 23:33:19 +0000 | [diff] [blame] | 79 | JSValue composedValue; |
| 80 | if (isNullOrUndefined) |
| 81 | composedValue = jsUndefined(); |
| 82 | else { |
| 83 | composedValue = object->get(&state, Identifier::fromString(&state, "composed")); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 86 | if (!composedValue.isUndefined()) { |
| 87 | result.composed = convert<IDLBoolean>(state, composedValue); |
| 88 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 89 | } else |
| 90 | result.composed = false; |
cdumez@apple.com | 8cd0d31 | 2018-02-01 23:33:19 +0000 | [diff] [blame] | 91 | JSValue promiseValue; |
| 92 | if (isNullOrUndefined) |
| 93 | promiseValue = jsUndefined(); |
| 94 | else { |
| 95 | promiseValue = object->get(&state, Identifier::fromString(&state, "promise")); |
| 96 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 97 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 98 | if (!promiseValue.isUndefined()) { |
| 99 | result.promise = convert<IDLPromise<IDLAny>>(state, promiseValue); |
| 100 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 101 | } else { |
| 102 | throwRequiredMemberTypeError(state, throwScope, "promise", "TestPromiseRejectionEventInit", "Promise"); |
| 103 | return { }; |
| 104 | } |
cdumez@apple.com | 8cd0d31 | 2018-02-01 23:33:19 +0000 | [diff] [blame] | 105 | JSValue reasonValue; |
| 106 | if (isNullOrUndefined) |
| 107 | reasonValue = jsUndefined(); |
| 108 | else { |
| 109 | reasonValue = object->get(&state, Identifier::fromString(&state, "reason")); |
| 110 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 111 | } |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 112 | if (!reasonValue.isUndefined()) { |
| 113 | result.reason = convert<IDLAny>(state, reasonValue); |
| 114 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 115 | } else |
| 116 | result.reason = jsUndefined(); |
| 117 | return result; |
| 118 | } |
| 119 | |
| 120 | // Attributes |
| 121 | |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 122 | JSC::EncodedJSValue jsTestPromiseRejectionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 123 | bool setJSTestPromiseRejectionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 124 | JSC::EncodedJSValue jsTestPromiseRejectionEventPromise(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 125 | JSC::EncodedJSValue jsTestPromiseRejectionEventReason(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 126 | |
| 127 | class JSTestPromiseRejectionEventPrototype : public JSC::JSNonFinalObject { |
| 128 | public: |
| 129 | using Base = JSC::JSNonFinalObject; |
| 130 | static JSTestPromiseRejectionEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 131 | { |
| 132 | JSTestPromiseRejectionEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestPromiseRejectionEventPrototype>(vm.heap)) JSTestPromiseRejectionEventPrototype(vm, globalObject, structure); |
| 133 | ptr->finishCreation(vm); |
| 134 | return ptr; |
| 135 | } |
| 136 | |
| 137 | DECLARE_INFO; |
| 138 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 139 | { |
| 140 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 141 | } |
| 142 | |
| 143 | private: |
| 144 | JSTestPromiseRejectionEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 145 | : JSC::JSNonFinalObject(vm, structure) |
| 146 | { |
| 147 | } |
| 148 | |
| 149 | void finishCreation(JSC::VM&); |
| 150 | }; |
| 151 | |
| 152 | using JSTestPromiseRejectionEventConstructor = JSDOMConstructor<JSTestPromiseRejectionEvent>; |
| 153 | |
| 154 | template<> EncodedJSValue JSC_HOST_CALL JSTestPromiseRejectionEventConstructor::construct(ExecState* state) |
| 155 | { |
| 156 | VM& vm = state->vm(); |
| 157 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 158 | UNUSED_PARAM(throwScope); |
| 159 | auto* castedThis = jsCast<JSTestPromiseRejectionEventConstructor*>(state->jsCallee()); |
| 160 | ASSERT(castedThis); |
| 161 | if (UNLIKELY(state->argumentCount() < 2)) |
| 162 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 163 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 164 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 165 | auto eventInitDict = convert<IDLDictionary<TestPromiseRejectionEvent::Init>>(*state, state->uncheckedArgument(1)); |
| 166 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 167 | auto object = TestPromiseRejectionEvent::create(*state, WTFMove(type), WTFMove(eventInitDict)); |
| 168 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 169 | return JSValue::encode(toJSNewlyCreated<IDLInterface<TestPromiseRejectionEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 170 | } |
| 171 | |
| 172 | template<> JSValue JSTestPromiseRejectionEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 173 | { |
| 174 | return JSEvent::getConstructor(vm, &globalObject); |
| 175 | } |
| 176 | |
| 177 | template<> void JSTestPromiseRejectionEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 178 | { |
achristensen@apple.com | 5c6da6e | 2017-09-25 22:37:03 +0000 | [diff] [blame] | 179 | putDirect(vm, vm.propertyNames->prototype, JSTestPromiseRejectionEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame^] | 180 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestPromiseRejectionEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
achristensen@apple.com | 5c6da6e | 2017-09-25 22:37:03 +0000 | [diff] [blame] | 181 | putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 182 | } |
| 183 | |
utatane.tea@gmail.com | a5544f1 | 2017-05-19 09:23:20 +0000 | [diff] [blame] | 184 | template<> const ClassInfo JSTestPromiseRejectionEventConstructor::s_info = { "TestPromiseRejectionEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEventConstructor) }; |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 185 | |
| 186 | /* Hash table for prototype */ |
| 187 | |
| 188 | static const HashTableValue JSTestPromiseRejectionEventPrototypeTableValues[] = |
| 189 | { |
achristensen@apple.com | 5c6da6e | 2017-09-25 22:37:03 +0000 | [diff] [blame] | 190 | { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestPromiseRejectionEventConstructor) } }, |
| 191 | { "promise", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventPromise), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 192 | { "reason", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventReason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
utatane.tea@gmail.com | a5544f1 | 2017-05-19 09:23:20 +0000 | [diff] [blame] | 195 | const ClassInfo JSTestPromiseRejectionEventPrototype::s_info = { "TestPromiseRejectionEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEventPrototype) }; |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 196 | |
| 197 | void JSTestPromiseRejectionEventPrototype::finishCreation(VM& vm) |
| 198 | { |
| 199 | Base::finishCreation(vm); |
utatane.tea@gmail.com | f496c6b | 2017-07-27 12:35:49 +0000 | [diff] [blame] | 200 | reifyStaticProperties(vm, JSTestPromiseRejectionEvent::info(), JSTestPromiseRejectionEventPrototypeTableValues, *this); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 201 | } |
| 202 | |
utatane.tea@gmail.com | a5544f1 | 2017-05-19 09:23:20 +0000 | [diff] [blame] | 203 | const ClassInfo JSTestPromiseRejectionEvent::s_info = { "TestPromiseRejectionEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEvent) }; |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 204 | |
| 205 | JSTestPromiseRejectionEvent::JSTestPromiseRejectionEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestPromiseRejectionEvent>&& impl) |
| 206 | : JSEvent(structure, globalObject, WTFMove(impl)) |
| 207 | { |
| 208 | } |
| 209 | |
| 210 | void JSTestPromiseRejectionEvent::finishCreation(VM& vm) |
| 211 | { |
| 212 | Base::finishCreation(vm); |
| 213 | ASSERT(inherits(vm, info())); |
| 214 | |
| 215 | } |
| 216 | |
| 217 | JSObject* JSTestPromiseRejectionEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 218 | { |
| 219 | return JSTestPromiseRejectionEventPrototype::create(vm, &globalObject, JSTestPromiseRejectionEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
| 220 | } |
| 221 | |
| 222 | JSObject* JSTestPromiseRejectionEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 223 | { |
| 224 | return getDOMPrototype<JSTestPromiseRejectionEvent>(vm, globalObject); |
| 225 | } |
| 226 | |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 227 | JSValue JSTestPromiseRejectionEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 228 | { |
| 229 | return getDOMConstructor<JSTestPromiseRejectionEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 230 | } |
| 231 | |
weinig@apple.com | 96c96d9 | 2017-05-25 17:39:57 +0000 | [diff] [blame] | 232 | template<> inline JSTestPromiseRejectionEvent* IDLAttribute<JSTestPromiseRejectionEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 233 | { |
utatane.tea@gmail.com | 5ec91b7 | 2018-03-08 18:38:09 +0000 | [diff] [blame] | 234 | return jsDynamicCast<JSTestPromiseRejectionEvent*>(state.vm(), JSValue::decode(thisValue)); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 235 | } |
| 236 | |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 237 | EncodedJSValue jsTestPromiseRejectionEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 238 | { |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 239 | VM& vm = state->vm(); |
| 240 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
utatane.tea@gmail.com | 5ec91b7 | 2018-03-08 18:38:09 +0000 | [diff] [blame] | 241 | auto* prototype = jsDynamicCast<JSTestPromiseRejectionEventPrototype*>(vm, JSValue::decode(thisValue)); |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 242 | if (UNLIKELY(!prototype)) |
| 243 | return throwVMTypeError(state, throwScope); |
| 244 | return JSValue::encode(JSTestPromiseRejectionEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 245 | } |
| 246 | |
| 247 | bool setJSTestPromiseRejectionEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 248 | { |
| 249 | VM& vm = state->vm(); |
| 250 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
utatane.tea@gmail.com | 5ec91b7 | 2018-03-08 18:38:09 +0000 | [diff] [blame] | 251 | auto* prototype = jsDynamicCast<JSTestPromiseRejectionEventPrototype*>(vm, JSValue::decode(thisValue)); |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 252 | if (UNLIKELY(!prototype)) { |
| 253 | throwVMTypeError(state, throwScope); |
| 254 | return false; |
| 255 | } |
| 256 | // Shadowing a built-in constructor |
mark.lam@apple.com | 23e9624 | 2017-09-09 16:21:45 +0000 | [diff] [blame] | 257 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static inline JSValue jsTestPromiseRejectionEventPromiseGetter(ExecState& state, JSTestPromiseRejectionEvent& thisObject, ThrowScope& throwScope) |
| 261 | { |
| 262 | UNUSED_PARAM(throwScope); |
| 263 | UNUSED_PARAM(state); |
| 264 | auto& impl = thisObject.wrapped(); |
weinig@apple.com | 72d0cb9 | 2017-09-25 19:16:14 +0000 | [diff] [blame] | 265 | JSValue result = toJS<IDLPromise<IDLAny>>(state, *thisObject.globalObject(), throwScope, impl.promise()); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 266 | return result; |
| 267 | } |
| 268 | |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 269 | EncodedJSValue jsTestPromiseRejectionEventPromise(ExecState* state, EncodedJSValue thisValue, PropertyName) |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 270 | { |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 271 | return IDLAttribute<JSTestPromiseRejectionEvent>::get<jsTestPromiseRejectionEventPromiseGetter, CastedThisErrorBehavior::RejectPromise>(*state, thisValue, "promise"); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | static inline JSValue jsTestPromiseRejectionEventReasonGetter(ExecState& state, JSTestPromiseRejectionEvent& thisObject, ThrowScope& throwScope) |
| 275 | { |
| 276 | UNUSED_PARAM(throwScope); |
| 277 | UNUSED_PARAM(state); |
| 278 | auto& impl = thisObject.wrapped(); |
weinig@apple.com | 72d0cb9 | 2017-09-25 19:16:14 +0000 | [diff] [blame] | 279 | JSValue result = toJS<IDLAny>(state, throwScope, impl.reason()); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 280 | return result; |
| 281 | } |
| 282 | |
commit-queue@webkit.org | 036616a | 2017-05-26 21:33:15 +0000 | [diff] [blame] | 283 | EncodedJSValue jsTestPromiseRejectionEventReason(ExecState* state, EncodedJSValue thisValue, PropertyName) |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 284 | { |
utatane.tea@gmail.com | f496c6b | 2017-07-27 12:35:49 +0000 | [diff] [blame] | 285 | return IDLAttribute<JSTestPromiseRejectionEvent>::get<jsTestPromiseRejectionEventReasonGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "reason"); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | #if ENABLE(BINDING_INTEGRITY) |
| 289 | #if PLATFORM(WIN) |
| 290 | #pragma warning(disable: 4483) |
| 291 | extern "C" { extern void (*const __identifier("??_7TestPromiseRejectionEvent@WebCore@@6B@")[])(); } |
| 292 | #else |
| 293 | extern "C" { extern void* _ZTVN7WebCore25TestPromiseRejectionEventE[]; } |
| 294 | #endif |
| 295 | #endif |
| 296 | |
| 297 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestPromiseRejectionEvent>&& impl) |
| 298 | { |
| 299 | |
| 300 | #if ENABLE(BINDING_INTEGRITY) |
mark.lam@apple.com | 92c4bb1 | 2018-04-03 20:22:08 +0000 | [diff] [blame] | 301 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 302 | #if PLATFORM(WIN) |
mark.lam@apple.com | bde8a73 | 2018-01-27 00:43:27 +0000 | [diff] [blame] | 303 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestPromiseRejectionEvent@WebCore@@6B@")); |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 304 | #else |
mark.lam@apple.com | bde8a73 | 2018-01-27 00:43:27 +0000 | [diff] [blame] | 305 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore25TestPromiseRejectionEventE[2]); |
commit-queue@webkit.org | 1f0f62d | 2017-06-30 15:45:59 +0000 | [diff] [blame] | 306 | #endif |
| 307 | |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 308 | // If this fails TestPromiseRejectionEvent does not have a vtable, so you need to add the |
| 309 | // ImplementationLacksVTable attribute to the interface definition |
commit-queue@webkit.org | 1f0f62d | 2017-06-30 15:45:59 +0000 | [diff] [blame] | 310 | static_assert(std::is_polymorphic<TestPromiseRejectionEvent>::value, "TestPromiseRejectionEvent is not polymorphic"); |
| 311 | |
utatane.tea@gmail.com | 73e7e9f | 2017-05-09 12:17:21 +0000 | [diff] [blame] | 312 | // If you hit this assertion you either have a use after free bug, or |
| 313 | // TestPromiseRejectionEvent has subclasses. If TestPromiseRejectionEvent has subclasses that get passed |
| 314 | // to toJS() we currently require TestPromiseRejectionEvent you to opt out of binding hardening |
| 315 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 316 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 317 | #endif |
| 318 | return createWrapper<TestPromiseRejectionEvent>(globalObject, WTFMove(impl)); |
| 319 | } |
| 320 | |
| 321 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestPromiseRejectionEvent& impl) |
| 322 | { |
| 323 | return wrap(state, globalObject, impl); |
| 324 | } |
| 325 | |
| 326 | |
| 327 | } |