| 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 "JSSQLTransaction.h" | 
| 23 |  | 
| 24 | #include "JSDOMBinding.h" | 
| 25 | #include "JSDOMConstructorNotConstructable.h" | 
| 26 | #include "JSDOMConvertCallbacks.h" | 
| 27 | #include "JSDOMConvertNullable.h" | 
| 28 | #include "JSDOMConvertNumbers.h" | 
| 29 | #include "JSDOMConvertSequences.h" | 
| 30 | #include "JSDOMConvertStrings.h" | 
| 31 | #include "JSDOMConvertUnion.h" | 
| 32 | #include "JSDOMExceptionHandling.h" | 
| 33 | #include "JSDOMGlobalObject.h" | 
| 34 | #include "JSDOMOperation.h" | 
| 35 | #include "JSDOMWrapperCache.h" | 
| 36 | #include "JSSQLStatementCallback.h" | 
| 37 | #include "JSSQLStatementErrorCallback.h" | 
| 38 | #include "ScriptExecutionContext.h" | 
| 39 | #include <JavaScriptCore/FunctionPrototype.h> | 
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> | 
| 41 | #include <JavaScriptCore/JSArray.h> | 
| 42 | #include <JavaScriptCore/JSCInlines.h> | 
| 43 | #include <wtf/GetPtr.h> | 
| 44 | #include <wtf/PointerPreparations.h> | 
| 45 | #include <wtf/URL.h> | 
| 46 | #include <wtf/Variant.h> | 
| 47 |  | 
| 48 |  | 
| 49 | namespace WebCore { | 
| 50 | using namespace JSC; | 
| 51 |  | 
| 52 | // Functions | 
| 53 |  | 
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsSQLTransactionPrototypeFunctionExecuteSql(JSC::ExecState*); | 
| 55 |  | 
| 56 | // Attributes | 
| 57 |  | 
| 58 | JSC::EncodedJSValue jsSQLTransactionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); | 
| 59 | bool setJSSQLTransactionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); | 
| 60 |  | 
| 61 | class JSSQLTransactionPrototype : public JSC::JSNonFinalObject { | 
| 62 | public: | 
| 63 |     using Base = JSC::JSNonFinalObject; | 
| 64 |     static JSSQLTransactionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) | 
| 65 |     { | 
| 66 |         JSSQLTransactionPrototype* ptr = new (NotNull, JSC::allocateCell<JSSQLTransactionPrototype>(vm.heap)) JSSQLTransactionPrototype(vm, globalObject, structure); | 
| 67 |         ptr->finishCreation(vm); | 
| 68 |         return ptr; | 
| 69 |     } | 
| 70 |  | 
| 71 |     DECLARE_INFO; | 
| 72 |     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) | 
| 73 |     { | 
| 74 |         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); | 
| 75 |     } | 
| 76 |  | 
| 77 | private: | 
| 78 |     JSSQLTransactionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) | 
| 79 |         : JSC::JSNonFinalObject(vm, structure) | 
| 80 |     { | 
| 81 |     } | 
| 82 |  | 
| 83 |     void finishCreation(JSC::VM&); | 
| 84 | }; | 
| 85 |  | 
| 86 | using JSSQLTransactionConstructor = JSDOMConstructorNotConstructable<JSSQLTransaction>; | 
| 87 |  | 
| 88 | template<> JSValue JSSQLTransactionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) | 
| 89 | { | 
| 90 |     UNUSED_PARAM(vm); | 
| 91 |     return globalObject.functionPrototype(); | 
| 92 | } | 
| 93 |  | 
| 94 | template<> void JSSQLTransactionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) | 
| 95 | { | 
| 96 |     putDirect(vm, vm.propertyNames->prototype, JSSQLTransaction::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); | 
| 97 |     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SQLTransaction"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); | 
| 98 |     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); | 
| 99 | } | 
| 100 |  | 
| 101 | template<> const ClassInfo JSSQLTransactionConstructor::s_info = { "SQLTransaction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLTransactionConstructor) }; | 
| 102 |  | 
| 103 | /* Hash table for prototype */ | 
| 104 |  | 
| 105 | static const HashTableValue JSSQLTransactionPrototypeTableValues[] = | 
| 106 | { | 
| 107 |     { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSQLTransactionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSQLTransactionConstructor) } }, | 
| 108 |     { "executeSql" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSQLTransactionPrototypeFunctionExecuteSql), (intptr_t) (1) } }, | 
| 109 | }; | 
| 110 |  | 
| 111 | const ClassInfo JSSQLTransactionPrototype::s_info = { "SQLTransactionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLTransactionPrototype) }; | 
| 112 |  | 
| 113 | void JSSQLTransactionPrototype::finishCreation(VM& vm) | 
| 114 | { | 
| 115 |     Base::finishCreation(vm); | 
| 116 |     reifyStaticProperties(vm, JSSQLTransaction::info(), JSSQLTransactionPrototypeTableValues, *this); | 
| 117 | } | 
| 118 |  | 
| 119 | const ClassInfo JSSQLTransaction::s_info = { "SQLTransaction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLTransaction) }; | 
| 120 |  | 
| 121 | JSSQLTransaction::JSSQLTransaction(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SQLTransaction>&& impl) | 
| 122 |     : JSDOMWrapper<SQLTransaction>(structure, globalObject, WTFMove(impl)) | 
| 123 | { | 
| 124 | } | 
| 125 |  | 
| 126 | void JSSQLTransaction::finishCreation(VM& vm) | 
| 127 | { | 
| 128 |     Base::finishCreation(vm); | 
| 129 |     ASSERT(inherits(vm, info())); | 
| 130 |  | 
| 131 | } | 
| 132 |  | 
| 133 | JSObject* JSSQLTransaction::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) | 
| 134 | { | 
| 135 |     return JSSQLTransactionPrototype::create(vm, &globalObject, JSSQLTransactionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); | 
| 136 | } | 
| 137 |  | 
| 138 | JSObject* JSSQLTransaction::prototype(VM& vm, JSDOMGlobalObject& globalObject) | 
| 139 | { | 
| 140 |     return getDOMPrototype<JSSQLTransaction>(vm, globalObject); | 
| 141 | } | 
| 142 |  | 
| 143 | JSValue JSSQLTransaction::getConstructor(VM& vm, const JSGlobalObject* globalObject) | 
| 144 | { | 
| 145 |     return getDOMConstructor<JSSQLTransactionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); | 
| 146 | } | 
| 147 |  | 
| 148 | void JSSQLTransaction::destroy(JSC::JSCell* cell) | 
| 149 | { | 
| 150 |     JSSQLTransaction* thisObject = static_cast<JSSQLTransaction*>(cell); | 
| 151 |     thisObject->JSSQLTransaction::~JSSQLTransaction(); | 
| 152 | } | 
| 153 |  | 
| 154 | template<> inline JSSQLTransaction* IDLOperation<JSSQLTransaction>::cast(ExecState& state) | 
| 155 | { | 
| 156 |     return jsDynamicCast<JSSQLTransaction*>(state.vm(), state.thisValue()); | 
| 157 | } | 
| 158 |  | 
| 159 | EncodedJSValue jsSQLTransactionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) | 
| 160 | { | 
| 161 |     VM& vm = state->vm(); | 
| 162 |     auto throwScope = DECLARE_THROW_SCOPE(vm); | 
| 163 |     auto* prototype = jsDynamicCast<JSSQLTransactionPrototype*>(vm, JSValue::decode(thisValue)); | 
| 164 |     if (UNLIKELY(!prototype)) | 
| 165 |         return throwVMTypeError(state, throwScope); | 
| 166 |     return JSValue::encode(JSSQLTransaction::getConstructor(state->vm(), prototype->globalObject())); | 
| 167 | } | 
| 168 |  | 
| 169 | bool setJSSQLTransactionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) | 
| 170 | { | 
| 171 |     VM& vm = state->vm(); | 
| 172 |     auto throwScope = DECLARE_THROW_SCOPE(vm); | 
| 173 |     auto* prototype = jsDynamicCast<JSSQLTransactionPrototype*>(vm, JSValue::decode(thisValue)); | 
| 174 |     if (UNLIKELY(!prototype)) { | 
| 175 |         throwVMTypeError(state, throwScope); | 
| 176 |         return false; | 
| 177 |     } | 
| 178 |     // Shadowing a built-in constructor | 
| 179 |     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); | 
| 180 | } | 
| 181 |  | 
| 182 | static inline JSC::EncodedJSValue jsSQLTransactionPrototypeFunctionExecuteSqlBody(JSC::ExecState* state, typename IDLOperation<JSSQLTransaction>::ClassParameter castedThis, JSC::ThrowScope& throwScope) | 
| 183 | { | 
| 184 |     UNUSED_PARAM(state); | 
| 185 |     UNUSED_PARAM(throwScope); | 
| 186 |     auto& impl = castedThis->wrapped(); | 
| 187 |     if (UNLIKELY(state->argumentCount() < 1)) | 
| 188 |         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); | 
| 189 |     auto sqlStatement = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); | 
| 190 |     RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | 
| 191 |     auto arguments = state->argument(1).isUndefined() ? Converter<IDLNullable<IDLSequence<IDLUnion<IDLNull, IDLDOMString, IDLUnrestrictedDouble>>>>::ReturnType{ } : convert<IDLNullable<IDLSequence<IDLUnion<IDLNull, IDLDOMString, IDLUnrestrictedDouble>>>>(*state, state->uncheckedArgument(1)); | 
| 192 |     RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | 
| 193 |     auto callback = convert<IDLNullable<IDLCallbackFunction<JSSQLStatementCallback>>>(*state, state->argument(2), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 2, "callback" , "SQLTransaction" , "executeSql" ); }); | 
| 194 |     RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | 
| 195 |     auto errorCallback = convert<IDLNullable<IDLCallbackFunction<JSSQLStatementErrorCallback>>>(*state, state->argument(3), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 3, "errorCallback" , "SQLTransaction" , "executeSql" ); }); | 
| 196 |     RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | 
| 197 |     propagateException(*state, throwScope, impl.executeSql(WTFMove(sqlStatement), WTFMove(arguments), WTFMove(callback), WTFMove(errorCallback))); | 
| 198 |     return JSValue::encode(jsUndefined()); | 
| 199 | } | 
| 200 |  | 
| 201 | EncodedJSValue JSC_HOST_CALL jsSQLTransactionPrototypeFunctionExecuteSql(ExecState* state) | 
| 202 | { | 
| 203 |     return IDLOperation<JSSQLTransaction>::call<jsSQLTransactionPrototypeFunctionExecuteSqlBody>(*state, "executeSql" ); | 
| 204 | } | 
| 205 |  | 
| 206 | void JSSQLTransaction::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) | 
| 207 | { | 
| 208 |     auto* thisObject = jsCast<JSSQLTransaction*>(cell); | 
| 209 |     builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); | 
| 210 |     if (thisObject->scriptExecutionContext()) | 
| 211 |         builder.setLabelForCell(cell, "url "  + thisObject->scriptExecutionContext()->url().string()); | 
| 212 |     Base::heapSnapshot(cell, builder); | 
| 213 | } | 
| 214 |  | 
| 215 | bool JSSQLTransactionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) | 
| 216 | { | 
| 217 |     UNUSED_PARAM(handle); | 
| 218 |     UNUSED_PARAM(visitor); | 
| 219 |     UNUSED_PARAM(reason); | 
| 220 |     return false; | 
| 221 | } | 
| 222 |  | 
| 223 | void JSSQLTransactionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) | 
| 224 | { | 
| 225 |     auto* jsSQLTransaction = static_cast<JSSQLTransaction*>(handle.slot()->asCell()); | 
| 226 |     auto& world = *static_cast<DOMWrapperWorld*>(context); | 
| 227 |     uncacheWrapper(world, &jsSQLTransaction->wrapped(), jsSQLTransaction); | 
| 228 | } | 
| 229 |  | 
| 230 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SQLTransaction>&& impl) | 
| 231 | { | 
| 232 |     return createWrapper<SQLTransaction>(globalObject, WTFMove(impl)); | 
| 233 | } | 
| 234 |  | 
| 235 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SQLTransaction& impl) | 
| 236 | { | 
| 237 |     return wrap(state, globalObject, impl); | 
| 238 | } | 
| 239 |  | 
| 240 | SQLTransaction* JSSQLTransaction::toWrapped(JSC::VM& vm, JSC::JSValue value) | 
| 241 | { | 
| 242 |     if (auto* wrapper = jsDynamicCast<JSSQLTransaction*>(vm, value)) | 
| 243 |         return &wrapper->wrapped(); | 
| 244 |     return nullptr; | 
| 245 | } | 
| 246 |  | 
| 247 | } | 
| 248 |  |