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