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 "JSDOMException.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructor.h" |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMConvertNumbers.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMExceptionHandling.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 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | // Attributes |
45 | |
46 | JSC::EncodedJSValue jsDOMExceptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
47 | bool setJSDOMExceptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
48 | JSC::EncodedJSValue jsDOMExceptionCode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
49 | JSC::EncodedJSValue jsDOMExceptionName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | JSC::EncodedJSValue jsDOMExceptionMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | |
52 | class JSDOMExceptionPrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSDOMExceptionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSDOMExceptionPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMExceptionPrototype>(vm.heap)) JSDOMExceptionPrototype(vm, globalObject, structure); |
58 | ptr->finishCreation(vm); |
59 | return ptr; |
60 | } |
61 | |
62 | DECLARE_INFO; |
63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
64 | { |
65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
66 | } |
67 | |
68 | private: |
69 | JSDOMExceptionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
70 | : JSC::JSNonFinalObject(vm, structure) |
71 | { |
72 | } |
73 | |
74 | void finishCreation(JSC::VM&); |
75 | }; |
76 | |
77 | using JSDOMExceptionConstructor = JSDOMConstructor<JSDOMException>; |
78 | |
79 | /* Hash table for constructor */ |
80 | |
81 | static const HashTableValue JSDOMExceptionConstructorTableValues[] = |
82 | { |
83 | { "INDEX_SIZE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
84 | { "DOMSTRING_SIZE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
85 | { "HIERARCHY_REQUEST_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
86 | { "WRONG_DOCUMENT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
87 | { "INVALID_CHARACTER_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
88 | { "NO_DATA_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
89 | { "NO_MODIFICATION_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
90 | { "NOT_FOUND_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
91 | { "NOT_SUPPORTED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
92 | { "INUSE_ATTRIBUTE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
93 | { "INVALID_STATE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
94 | { "SYNTAX_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
95 | { "INVALID_MODIFICATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, |
96 | { "NAMESPACE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, |
97 | { "INVALID_ACCESS_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, |
98 | { "VALIDATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
99 | { "TYPE_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, |
100 | { "SECURITY_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, |
101 | { "NETWORK_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, |
102 | { "ABORT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, |
103 | { "URL_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, |
104 | { "QUOTA_EXCEEDED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, |
105 | { "TIMEOUT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, |
106 | { "INVALID_NODE_TYPE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, |
107 | { "DATA_CLONE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, |
108 | }; |
109 | |
110 | template<> EncodedJSValue JSC_HOST_CALL JSDOMExceptionConstructor::construct(ExecState* state) |
111 | { |
112 | VM& vm = state->vm(); |
113 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
114 | UNUSED_PARAM(throwScope); |
115 | auto* castedThis = jsCast<JSDOMExceptionConstructor*>(state->jsCallee()); |
116 | ASSERT(castedThis); |
117 | auto message = state->argument(0).isUndefined() ? emptyString() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
118 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
119 | auto name = state->argument(1).isUndefined() ? "Error"_s : convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
120 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
121 | auto object = DOMException::create(WTFMove(message), WTFMove(name)); |
122 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMException>>(*state, *castedThis->globalObject(), WTFMove(object))); |
123 | } |
124 | |
125 | template<> JSValue JSDOMExceptionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
126 | { |
127 | UNUSED_PARAM(vm); |
128 | return globalObject.functionPrototype(); |
129 | } |
130 | |
131 | template<> void JSDOMExceptionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
132 | { |
133 | putDirect(vm, vm.propertyNames->prototype, JSDOMException::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
134 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DOMException"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
135 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
136 | reifyStaticProperties(vm, JSDOMException::info(), JSDOMExceptionConstructorTableValues, *this); |
137 | } |
138 | |
139 | template<> const ClassInfo JSDOMExceptionConstructor::s_info = { "DOMException" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMExceptionConstructor) }; |
140 | |
141 | /* Hash table for prototype */ |
142 | |
143 | static const HashTableValue JSDOMExceptionPrototypeTableValues[] = |
144 | { |
145 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMExceptionConstructor) } }, |
146 | { "code" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
147 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
148 | { "message" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
149 | { "INDEX_SIZE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
150 | { "DOMSTRING_SIZE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
151 | { "HIERARCHY_REQUEST_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
152 | { "WRONG_DOCUMENT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
153 | { "INVALID_CHARACTER_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
154 | { "NO_DATA_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
155 | { "NO_MODIFICATION_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
156 | { "NOT_FOUND_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
157 | { "NOT_SUPPORTED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
158 | { "INUSE_ATTRIBUTE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
159 | { "INVALID_STATE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
160 | { "SYNTAX_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
161 | { "INVALID_MODIFICATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, |
162 | { "NAMESPACE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, |
163 | { "INVALID_ACCESS_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, |
164 | { "VALIDATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
165 | { "TYPE_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, |
166 | { "SECURITY_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, |
167 | { "NETWORK_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, |
168 | { "ABORT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, |
169 | { "URL_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, |
170 | { "QUOTA_EXCEEDED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, |
171 | { "TIMEOUT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, |
172 | { "INVALID_NODE_TYPE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, |
173 | { "DATA_CLONE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, |
174 | }; |
175 | |
176 | const ClassInfo JSDOMExceptionPrototype::s_info = { "DOMExceptionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMExceptionPrototype) }; |
177 | |
178 | void JSDOMExceptionPrototype::finishCreation(VM& vm) |
179 | { |
180 | Base::finishCreation(vm); |
181 | reifyStaticProperties(vm, JSDOMException::info(), JSDOMExceptionPrototypeTableValues, *this); |
182 | } |
183 | |
184 | const ClassInfo JSDOMException::s_info = { "DOMException" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMException) }; |
185 | |
186 | JSDOMException::JSDOMException(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMException>&& impl) |
187 | : JSDOMWrapper<DOMException>(structure, globalObject, WTFMove(impl)) |
188 | { |
189 | } |
190 | |
191 | void JSDOMException::finishCreation(VM& vm) |
192 | { |
193 | Base::finishCreation(vm); |
194 | ASSERT(inherits(vm, info())); |
195 | |
196 | } |
197 | |
198 | JSObject* JSDOMException::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
199 | { |
200 | return JSDOMExceptionPrototype::create(vm, &globalObject, JSDOMExceptionPrototype::createStructure(vm, &globalObject, globalObject.errorPrototype())); |
201 | } |
202 | |
203 | JSObject* JSDOMException::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
204 | { |
205 | return getDOMPrototype<JSDOMException>(vm, globalObject); |
206 | } |
207 | |
208 | JSValue JSDOMException::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
209 | { |
210 | return getDOMConstructor<JSDOMExceptionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
211 | } |
212 | |
213 | void JSDOMException::destroy(JSC::JSCell* cell) |
214 | { |
215 | JSDOMException* thisObject = static_cast<JSDOMException*>(cell); |
216 | thisObject->JSDOMException::~JSDOMException(); |
217 | } |
218 | |
219 | template<> inline JSDOMException* IDLAttribute<JSDOMException>::cast(ExecState& state, EncodedJSValue thisValue) |
220 | { |
221 | return jsDynamicCast<JSDOMException*>(state.vm(), JSValue::decode(thisValue)); |
222 | } |
223 | |
224 | EncodedJSValue jsDOMExceptionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
225 | { |
226 | VM& vm = state->vm(); |
227 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
228 | auto* prototype = jsDynamicCast<JSDOMExceptionPrototype*>(vm, JSValue::decode(thisValue)); |
229 | if (UNLIKELY(!prototype)) |
230 | return throwVMTypeError(state, throwScope); |
231 | return JSValue::encode(JSDOMException::getConstructor(state->vm(), prototype->globalObject())); |
232 | } |
233 | |
234 | bool setJSDOMExceptionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
235 | { |
236 | VM& vm = state->vm(); |
237 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
238 | auto* prototype = jsDynamicCast<JSDOMExceptionPrototype*>(vm, JSValue::decode(thisValue)); |
239 | if (UNLIKELY(!prototype)) { |
240 | throwVMTypeError(state, throwScope); |
241 | return false; |
242 | } |
243 | // Shadowing a built-in constructor |
244 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
245 | } |
246 | |
247 | static inline JSValue jsDOMExceptionCodeGetter(ExecState& state, JSDOMException& thisObject, ThrowScope& throwScope) |
248 | { |
249 | UNUSED_PARAM(throwScope); |
250 | UNUSED_PARAM(state); |
251 | auto& impl = thisObject.wrapped(); |
252 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.legacyCode()); |
253 | return result; |
254 | } |
255 | |
256 | EncodedJSValue jsDOMExceptionCode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSDOMException>::get<jsDOMExceptionCodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "code" ); |
259 | } |
260 | |
261 | static inline JSValue jsDOMExceptionNameGetter(ExecState& state, JSDOMException& thisObject, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | UNUSED_PARAM(state); |
265 | auto& impl = thisObject.wrapped(); |
266 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name()); |
267 | return result; |
268 | } |
269 | |
270 | EncodedJSValue jsDOMExceptionName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
271 | { |
272 | return IDLAttribute<JSDOMException>::get<jsDOMExceptionNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
273 | } |
274 | |
275 | static inline JSValue jsDOMExceptionMessageGetter(ExecState& state, JSDOMException& thisObject, ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(throwScope); |
278 | UNUSED_PARAM(state); |
279 | auto& impl = thisObject.wrapped(); |
280 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.message()); |
281 | return result; |
282 | } |
283 | |
284 | EncodedJSValue jsDOMExceptionMessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
285 | { |
286 | return IDLAttribute<JSDOMException>::get<jsDOMExceptionMessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "message" ); |
287 | } |
288 | |
289 | void JSDOMException::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
290 | { |
291 | auto* thisObject = jsCast<JSDOMException*>(cell); |
292 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
293 | if (thisObject->scriptExecutionContext()) |
294 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
295 | Base::heapSnapshot(cell, builder); |
296 | } |
297 | |
298 | bool JSDOMExceptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
299 | { |
300 | UNUSED_PARAM(handle); |
301 | UNUSED_PARAM(visitor); |
302 | UNUSED_PARAM(reason); |
303 | return false; |
304 | } |
305 | |
306 | void JSDOMExceptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
307 | { |
308 | auto* jsDOMException = static_cast<JSDOMException*>(handle.slot()->asCell()); |
309 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
310 | uncacheWrapper(world, &jsDOMException->wrapped(), jsDOMException); |
311 | } |
312 | |
313 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMException>&& impl) |
314 | { |
315 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
316 | // attribute. You should remove that attribute. If the class has subclasses |
317 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
318 | // attribute to DOMException. |
319 | static_assert(!std::is_polymorphic<DOMException>::value, "DOMException is polymorphic but the IDL claims it is not" ); |
320 | return createWrapper<DOMException>(globalObject, WTFMove(impl)); |
321 | } |
322 | |
323 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMException& impl) |
324 | { |
325 | return wrap(state, globalObject, impl); |
326 | } |
327 | |
328 | DOMException* JSDOMException::toWrapped(JSC::VM& vm, JSC::JSValue value) |
329 | { |
330 | if (auto* wrapper = jsDynamicCast<JSDOMException*>(vm, value)) |
331 | return &wrapper->wrapped(); |
332 | return nullptr; |
333 | } |
334 | |
335 | } |
336 | |