| 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 | |
| 23 | #if ENABLE(STREAMS_API) |
| 24 | |
| 25 | #include "JSReadableStreamDefaultReader.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMBuiltinConstructor.h" |
| 30 | #include "JSDOMExceptionHandling.h" |
| 31 | #include "JSDOMOperation.h" |
| 32 | #include "JSDOMWrapperCache.h" |
| 33 | #include "ReadableStreamDefaultReaderBuiltins.h" |
| 34 | #include <JavaScriptCore/FunctionPrototype.h> |
| 35 | #include <JavaScriptCore/JSCInlines.h> |
| 36 | #include <wtf/GetPtr.h> |
| 37 | #include <wtf/PointerPreparations.h> |
| 38 | |
| 39 | |
| 40 | namespace WebCore { |
| 41 | using namespace JSC; |
| 42 | |
| 43 | // Functions |
| 44 | |
| 45 | |
| 46 | // Attributes |
| 47 | |
| 48 | JSC::EncodedJSValue jsReadableStreamDefaultReaderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 49 | bool setJSReadableStreamDefaultReaderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 50 | |
| 51 | class JSReadableStreamDefaultReaderPrototype : public JSC::JSNonFinalObject { |
| 52 | public: |
| 53 | using Base = JSC::JSNonFinalObject; |
| 54 | static JSReadableStreamDefaultReaderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 55 | { |
| 56 | JSReadableStreamDefaultReaderPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultReaderPrototype>(vm.heap)) JSReadableStreamDefaultReaderPrototype(vm, globalObject, structure); |
| 57 | ptr->finishCreation(vm); |
| 58 | return ptr; |
| 59 | } |
| 60 | |
| 61 | DECLARE_INFO; |
| 62 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 63 | { |
| 64 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 65 | } |
| 66 | |
| 67 | private: |
| 68 | JSReadableStreamDefaultReaderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 69 | : JSC::JSNonFinalObject(vm, structure) |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | void finishCreation(JSC::VM&); |
| 74 | }; |
| 75 | |
| 76 | using JSReadableStreamDefaultReaderConstructor = JSDOMBuiltinConstructor<JSReadableStreamDefaultReader>; |
| 77 | |
| 78 | template<> JSValue JSReadableStreamDefaultReaderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 79 | { |
| 80 | UNUSED_PARAM(vm); |
| 81 | return globalObject.functionPrototype(); |
| 82 | } |
| 83 | |
| 84 | template<> void JSReadableStreamDefaultReaderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 85 | { |
| 86 | putDirect(vm, vm.propertyNames->prototype, JSReadableStreamDefaultReader::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 87 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ReadableStreamDefaultReader"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 88 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 89 | } |
| 90 | |
| 91 | template<> FunctionExecutable* JSReadableStreamDefaultReaderConstructor::initializeExecutable(VM& vm) |
| 92 | { |
| 93 | return readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeGenerator(vm); |
| 94 | } |
| 95 | |
| 96 | template<> const ClassInfo JSReadableStreamDefaultReaderConstructor::s_info = { "ReadableStreamDefaultReader" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReaderConstructor) }; |
| 97 | |
| 98 | /* Hash table for prototype */ |
| 99 | |
| 100 | static const HashTableValue JSReadableStreamDefaultReaderPrototypeTableValues[] = |
| 101 | { |
| 102 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamDefaultReaderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSReadableStreamDefaultReaderConstructor) } }, |
| 103 | { "closed" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderClosedCodeGenerator), (intptr_t) (0) } }, |
| 104 | { "read" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderReadCodeGenerator), (intptr_t) (0) } }, |
| 105 | { "cancel" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderCancelCodeGenerator), (intptr_t) (0) } }, |
| 106 | { "releaseLock" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderReleaseLockCodeGenerator), (intptr_t) (0) } }, |
| 107 | }; |
| 108 | |
| 109 | const ClassInfo JSReadableStreamDefaultReaderPrototype::s_info = { "ReadableStreamDefaultReaderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReaderPrototype) }; |
| 110 | |
| 111 | void JSReadableStreamDefaultReaderPrototype::finishCreation(VM& vm) |
| 112 | { |
| 113 | Base::finishCreation(vm); |
| 114 | reifyStaticProperties(vm, JSReadableStreamDefaultReader::info(), JSReadableStreamDefaultReaderPrototypeTableValues, *this); |
| 115 | } |
| 116 | |
| 117 | const ClassInfo JSReadableStreamDefaultReader::s_info = { "ReadableStreamDefaultReader" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReader) }; |
| 118 | |
| 119 | JSReadableStreamDefaultReader::JSReadableStreamDefaultReader(Structure* structure, JSDOMGlobalObject& globalObject) |
| 120 | : JSDOMObject(structure, globalObject) { } |
| 121 | |
| 122 | void JSReadableStreamDefaultReader::finishCreation(VM& vm) |
| 123 | { |
| 124 | Base::finishCreation(vm); |
| 125 | ASSERT(inherits(vm, info())); |
| 126 | |
| 127 | } |
| 128 | |
| 129 | JSObject* JSReadableStreamDefaultReader::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 130 | { |
| 131 | return JSReadableStreamDefaultReaderPrototype::create(vm, &globalObject, JSReadableStreamDefaultReaderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 132 | } |
| 133 | |
| 134 | JSObject* JSReadableStreamDefaultReader::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 135 | { |
| 136 | return getDOMPrototype<JSReadableStreamDefaultReader>(vm, globalObject); |
| 137 | } |
| 138 | |
| 139 | JSValue JSReadableStreamDefaultReader::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 140 | { |
| 141 | return getDOMConstructor<JSReadableStreamDefaultReaderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 142 | } |
| 143 | |
| 144 | void JSReadableStreamDefaultReader::destroy(JSC::JSCell* cell) |
| 145 | { |
| 146 | JSReadableStreamDefaultReader* thisObject = static_cast<JSReadableStreamDefaultReader*>(cell); |
| 147 | thisObject->JSReadableStreamDefaultReader::~JSReadableStreamDefaultReader(); |
| 148 | } |
| 149 | |
| 150 | template<> inline JSReadableStreamDefaultReader* IDLAttribute<JSReadableStreamDefaultReader>::cast(ExecState& state, EncodedJSValue thisValue) |
| 151 | { |
| 152 | return jsDynamicCast<JSReadableStreamDefaultReader*>(state.vm(), JSValue::decode(thisValue)); |
| 153 | } |
| 154 | |
| 155 | template<> inline JSReadableStreamDefaultReader* IDLOperation<JSReadableStreamDefaultReader>::cast(ExecState& state) |
| 156 | { |
| 157 | return jsDynamicCast<JSReadableStreamDefaultReader*>(state.vm(), state.thisValue()); |
| 158 | } |
| 159 | |
| 160 | EncodedJSValue jsReadableStreamDefaultReaderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 161 | { |
| 162 | VM& vm = state->vm(); |
| 163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 164 | auto* prototype = jsDynamicCast<JSReadableStreamDefaultReaderPrototype*>(vm, JSValue::decode(thisValue)); |
| 165 | if (UNLIKELY(!prototype)) |
| 166 | return throwVMTypeError(state, throwScope); |
| 167 | return JSValue::encode(JSReadableStreamDefaultReader::getConstructor(state->vm(), prototype->globalObject())); |
| 168 | } |
| 169 | |
| 170 | bool setJSReadableStreamDefaultReaderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 171 | { |
| 172 | VM& vm = state->vm(); |
| 173 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 174 | auto* prototype = jsDynamicCast<JSReadableStreamDefaultReaderPrototype*>(vm, JSValue::decode(thisValue)); |
| 175 | if (UNLIKELY(!prototype)) { |
| 176 | throwVMTypeError(state, throwScope); |
| 177 | return false; |
| 178 | } |
| 179 | // Shadowing a built-in constructor |
| 180 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 181 | } |
| 182 | |
| 183 | |
| 184 | } |
| 185 | |
| 186 | #endif // ENABLE(STREAMS_API) |
| 187 | |