| 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 "JSXMLHttpRequestUpload.h" |
| 23 | |
| 24 | #include "JSDOMBinding.h" |
| 25 | #include "JSDOMConstructorNotConstructable.h" |
| 26 | #include "JSDOMExceptionHandling.h" |
| 27 | #include "JSDOMWrapperCache.h" |
| 28 | #include "ScriptExecutionContext.h" |
| 29 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 30 | #include <JavaScriptCore/JSCInlines.h> |
| 31 | #include <wtf/GetPtr.h> |
| 32 | #include <wtf/PointerPreparations.h> |
| 33 | #include <wtf/URL.h> |
| 34 | |
| 35 | |
| 36 | namespace WebCore { |
| 37 | using namespace JSC; |
| 38 | |
| 39 | // Attributes |
| 40 | |
| 41 | JSC::EncodedJSValue jsXMLHttpRequestUploadConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 42 | bool setJSXMLHttpRequestUploadConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 43 | |
| 44 | class JSXMLHttpRequestUploadPrototype : public JSC::JSNonFinalObject { |
| 45 | public: |
| 46 | using Base = JSC::JSNonFinalObject; |
| 47 | static JSXMLHttpRequestUploadPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 48 | { |
| 49 | JSXMLHttpRequestUploadPrototype* ptr = new (NotNull, JSC::allocateCell<JSXMLHttpRequestUploadPrototype>(vm.heap)) JSXMLHttpRequestUploadPrototype(vm, globalObject, structure); |
| 50 | ptr->finishCreation(vm); |
| 51 | return ptr; |
| 52 | } |
| 53 | |
| 54 | DECLARE_INFO; |
| 55 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 56 | { |
| 57 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 58 | } |
| 59 | |
| 60 | private: |
| 61 | JSXMLHttpRequestUploadPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 62 | : JSC::JSNonFinalObject(vm, structure) |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | void finishCreation(JSC::VM&); |
| 67 | }; |
| 68 | |
| 69 | using JSXMLHttpRequestUploadConstructor = JSDOMConstructorNotConstructable<JSXMLHttpRequestUpload>; |
| 70 | |
| 71 | template<> JSValue JSXMLHttpRequestUploadConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 72 | { |
| 73 | return JSXMLHttpRequestEventTarget::getConstructor(vm, &globalObject); |
| 74 | } |
| 75 | |
| 76 | template<> void JSXMLHttpRequestUploadConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 77 | { |
| 78 | putDirect(vm, vm.propertyNames->prototype, JSXMLHttpRequestUpload::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 79 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("XMLHttpRequestUpload"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 80 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 81 | } |
| 82 | |
| 83 | template<> const ClassInfo JSXMLHttpRequestUploadConstructor::s_info = { "XMLHttpRequestUpload" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestUploadConstructor) }; |
| 84 | |
| 85 | /* Hash table for prototype */ |
| 86 | |
| 87 | static const HashTableValue JSXMLHttpRequestUploadPrototypeTableValues[] = |
| 88 | { |
| 89 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestUploadConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSXMLHttpRequestUploadConstructor) } }, |
| 90 | }; |
| 91 | |
| 92 | const ClassInfo JSXMLHttpRequestUploadPrototype::s_info = { "XMLHttpRequestUploadPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestUploadPrototype) }; |
| 93 | |
| 94 | void JSXMLHttpRequestUploadPrototype::finishCreation(VM& vm) |
| 95 | { |
| 96 | Base::finishCreation(vm); |
| 97 | reifyStaticProperties(vm, JSXMLHttpRequestUpload::info(), JSXMLHttpRequestUploadPrototypeTableValues, *this); |
| 98 | } |
| 99 | |
| 100 | const ClassInfo JSXMLHttpRequestUpload::s_info = { "XMLHttpRequestUpload" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSXMLHttpRequestUpload) }; |
| 101 | |
| 102 | JSXMLHttpRequestUpload::JSXMLHttpRequestUpload(Structure* structure, JSDOMGlobalObject& globalObject, Ref<XMLHttpRequestUpload>&& impl) |
| 103 | : JSXMLHttpRequestEventTarget(structure, globalObject, WTFMove(impl)) |
| 104 | { |
| 105 | } |
| 106 | |
| 107 | void JSXMLHttpRequestUpload::finishCreation(VM& vm) |
| 108 | { |
| 109 | Base::finishCreation(vm); |
| 110 | ASSERT(inherits(vm, info())); |
| 111 | |
| 112 | } |
| 113 | |
| 114 | JSObject* JSXMLHttpRequestUpload::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 115 | { |
| 116 | return JSXMLHttpRequestUploadPrototype::create(vm, &globalObject, JSXMLHttpRequestUploadPrototype::createStructure(vm, &globalObject, JSXMLHttpRequestEventTarget::prototype(vm, globalObject))); |
| 117 | } |
| 118 | |
| 119 | JSObject* JSXMLHttpRequestUpload::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 120 | { |
| 121 | return getDOMPrototype<JSXMLHttpRequestUpload>(vm, globalObject); |
| 122 | } |
| 123 | |
| 124 | JSValue JSXMLHttpRequestUpload::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 125 | { |
| 126 | return getDOMConstructor<JSXMLHttpRequestUploadConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 127 | } |
| 128 | |
| 129 | EncodedJSValue jsXMLHttpRequestUploadConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 130 | { |
| 131 | VM& vm = state->vm(); |
| 132 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 133 | auto* prototype = jsDynamicCast<JSXMLHttpRequestUploadPrototype*>(vm, JSValue::decode(thisValue)); |
| 134 | if (UNLIKELY(!prototype)) |
| 135 | return throwVMTypeError(state, throwScope); |
| 136 | return JSValue::encode(JSXMLHttpRequestUpload::getConstructor(state->vm(), prototype->globalObject())); |
| 137 | } |
| 138 | |
| 139 | bool setJSXMLHttpRequestUploadConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 140 | { |
| 141 | VM& vm = state->vm(); |
| 142 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 143 | auto* prototype = jsDynamicCast<JSXMLHttpRequestUploadPrototype*>(vm, JSValue::decode(thisValue)); |
| 144 | if (UNLIKELY(!prototype)) { |
| 145 | throwVMTypeError(state, throwScope); |
| 146 | return false; |
| 147 | } |
| 148 | // Shadowing a built-in constructor |
| 149 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 150 | } |
| 151 | |
| 152 | void JSXMLHttpRequestUpload::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 153 | { |
| 154 | auto* thisObject = jsCast<JSXMLHttpRequestUpload*>(cell); |
| 155 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 156 | if (thisObject->scriptExecutionContext()) |
| 157 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 158 | Base::heapSnapshot(cell, builder); |
| 159 | } |
| 160 | |
| 161 | bool JSXMLHttpRequestUploadOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 162 | { |
| 163 | auto* jsXMLHttpRequestUpload = jsCast<JSXMLHttpRequestUpload*>(handle.slot()->asCell()); |
| 164 | if (jsXMLHttpRequestUpload->wrapped().isFiringEventListeners()) { |
| 165 | if (UNLIKELY(reason)) |
| 166 | *reason = "EventTarget firing event listeners" ; |
| 167 | return true; |
| 168 | } |
| 169 | XMLHttpRequestUpload* root = &jsXMLHttpRequestUpload->wrapped(); |
| 170 | if (UNLIKELY(reason)) |
| 171 | *reason = "Reachable from XMLHttpRequestUpload" ; |
| 172 | return visitor.containsOpaqueRoot(root); |
| 173 | } |
| 174 | |
| 175 | void JSXMLHttpRequestUploadOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 176 | { |
| 177 | auto* jsXMLHttpRequestUpload = static_cast<JSXMLHttpRequestUpload*>(handle.slot()->asCell()); |
| 178 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 179 | uncacheWrapper(world, &jsXMLHttpRequestUpload->wrapped(), jsXMLHttpRequestUpload); |
| 180 | } |
| 181 | |
| 182 | #if ENABLE(BINDING_INTEGRITY) |
| 183 | #if PLATFORM(WIN) |
| 184 | #pragma warning(disable: 4483) |
| 185 | extern "C" { extern void (*const __identifier("??_7XMLHttpRequestUpload@WebCore@@6B@" )[])(); } |
| 186 | #else |
| 187 | extern "C" { extern void* _ZTVN7WebCore20XMLHttpRequestUploadE[]; } |
| 188 | #endif |
| 189 | #endif |
| 190 | |
| 191 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<XMLHttpRequestUpload>&& impl) |
| 192 | { |
| 193 | |
| 194 | #if ENABLE(BINDING_INTEGRITY) |
| 195 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 196 | #if PLATFORM(WIN) |
| 197 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7XMLHttpRequestUpload@WebCore@@6B@" )); |
| 198 | #else |
| 199 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20XMLHttpRequestUploadE[2]); |
| 200 | #endif |
| 201 | |
| 202 | // If this fails XMLHttpRequestUpload does not have a vtable, so you need to add the |
| 203 | // ImplementationLacksVTable attribute to the interface definition |
| 204 | static_assert(std::is_polymorphic<XMLHttpRequestUpload>::value, "XMLHttpRequestUpload is not polymorphic" ); |
| 205 | |
| 206 | // If you hit this assertion you either have a use after free bug, or |
| 207 | // XMLHttpRequestUpload has subclasses. If XMLHttpRequestUpload has subclasses that get passed |
| 208 | // to toJS() we currently require XMLHttpRequestUpload you to opt out of binding hardening |
| 209 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 210 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 211 | #endif |
| 212 | return createWrapper<XMLHttpRequestUpload>(globalObject, WTFMove(impl)); |
| 213 | } |
| 214 | |
| 215 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, XMLHttpRequestUpload& impl) |
| 216 | { |
| 217 | return wrap(state, globalObject, impl); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | } |
| 222 | |