2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "JSreadonly.h"
24 #include "JSDOMBinding.h"
25 #include "JSDOMConstructor.h"
26 #include <runtime/FunctionPrototype.h>
27 #include <wtf/GetPtr.h>
35 JSC::EncodedJSValue jsreadonlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
36 bool setJSreadonlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
38 class JSreadonlyPrototype : public JSC::JSNonFinalObject {
40 using Base = JSC::JSNonFinalObject;
41 static JSreadonlyPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
43 JSreadonlyPrototype* ptr = new (NotNull, JSC::allocateCell<JSreadonlyPrototype>(vm.heap)) JSreadonlyPrototype(vm, globalObject, structure);
44 ptr->finishCreation(vm);
49 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
51 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
55 JSreadonlyPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
56 : JSC::JSNonFinalObject(vm, structure)
60 void finishCreation(JSC::VM&);
63 using JSreadonlyConstructor = JSDOMConstructorNotConstructable<JSreadonly>;
65 template<> JSValue JSreadonlyConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
68 return globalObject.functionPrototype();
71 template<> void JSreadonlyConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
73 putDirect(vm, vm.propertyNames->prototype, JSreadonly::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
74 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("readonly"))), ReadOnly | DontEnum);
75 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
78 template<> const ClassInfo JSreadonlyConstructor::s_info = { "readonly", &Base::s_info, 0, CREATE_METHOD_TABLE(JSreadonlyConstructor) };
80 /* Hash table for prototype */
82 static const HashTableValue JSreadonlyPrototypeTableValues[] =
84 { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsreadonlyConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSreadonlyConstructor) } },
87 const ClassInfo JSreadonlyPrototype::s_info = { "readonlyPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSreadonlyPrototype) };
89 void JSreadonlyPrototype::finishCreation(VM& vm)
91 Base::finishCreation(vm);
92 reifyStaticProperties(vm, JSreadonlyPrototypeTableValues, *this);
95 const ClassInfo JSreadonly::s_info = { "readonly", &Base::s_info, 0, CREATE_METHOD_TABLE(JSreadonly) };
97 JSreadonly::JSreadonly(Structure* structure, JSDOMGlobalObject& globalObject, Ref<readonly>&& impl)
98 : JSDOMWrapper<readonly>(structure, globalObject, WTFMove(impl))
102 JSObject* JSreadonly::createPrototype(VM& vm, JSGlobalObject* globalObject)
104 return JSreadonlyPrototype::create(vm, globalObject, JSreadonlyPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
107 JSObject* JSreadonly::prototype(VM& vm, JSGlobalObject* globalObject)
109 return getDOMPrototype<JSreadonly>(vm, globalObject);
112 void JSreadonly::destroy(JSC::JSCell* cell)
114 JSreadonly* thisObject = static_cast<JSreadonly*>(cell);
115 thisObject->JSreadonly::~JSreadonly();
118 EncodedJSValue jsreadonlyConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
120 VM& vm = state->vm();
121 auto throwScope = DECLARE_THROW_SCOPE(vm);
122 JSreadonlyPrototype* domObject = jsDynamicCast<JSreadonlyPrototype*>(JSValue::decode(thisValue));
123 if (UNLIKELY(!domObject))
124 return throwVMTypeError(state, throwScope);
125 return JSValue::encode(JSreadonly::getConstructor(state->vm(), domObject->globalObject()));
128 bool setJSreadonlyConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
130 VM& vm = state->vm();
131 auto throwScope = DECLARE_THROW_SCOPE(vm);
132 JSValue value = JSValue::decode(encodedValue);
133 JSreadonlyPrototype* domObject = jsDynamicCast<JSreadonlyPrototype*>(JSValue::decode(thisValue));
134 if (UNLIKELY(!domObject)) {
135 throwVMTypeError(state, throwScope);
138 // Shadowing a built-in constructor
139 return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
142 JSValue JSreadonly::getConstructor(VM& vm, const JSGlobalObject* globalObject)
144 return getDOMConstructor<JSreadonlyConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
147 bool JSreadonlyOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
149 UNUSED_PARAM(handle);
150 UNUSED_PARAM(visitor);
154 void JSreadonlyOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
156 auto* jsreadonly = jsCast<JSreadonly*>(handle.slot()->asCell());
157 auto& world = *static_cast<DOMWrapperWorld*>(context);
158 uncacheWrapper(world, &jsreadonly->wrapped(), jsreadonly);
161 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<readonly>&& impl)
164 // If you hit this failure the interface definition has the ImplementationLacksVTable
165 // attribute. You should remove that attribute. If the class has subclasses
166 // that may be passed through this toJS() function you should use the SkipVTableValidation
167 // attribute to readonly.
168 static_assert(!__is_polymorphic(readonly), "readonly is polymorphic but the IDL claims it is not");
170 return createWrapper<readonly>(globalObject, WTFMove(impl));
173 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, readonly& impl)
175 return wrap(state, globalObject, impl);
178 readonly* JSreadonly::toWrapped(JSC::JSValue value)
180 if (auto* wrapper = jsDynamicCast<JSreadonly*>(value))
181 return &wrapper->wrapped();