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 "JSattribute.h"
24 #include "JSDOMBinding.h"
25 #include "JSDOMConstructor.h"
26 #include "JSDOMConvert.h"
27 #include <runtime/FunctionPrototype.h>
28 #include <wtf/GetPtr.h>
36 JSC::EncodedJSValue jsattributeReadonly(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
37 JSC::EncodedJSValue jsattributeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
38 bool setJSattributeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
40 class JSattributePrototype : public JSC::JSNonFinalObject {
42 using Base = JSC::JSNonFinalObject;
43 static JSattributePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
45 JSattributePrototype* ptr = new (NotNull, JSC::allocateCell<JSattributePrototype>(vm.heap)) JSattributePrototype(vm, globalObject, structure);
46 ptr->finishCreation(vm);
51 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
53 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
57 JSattributePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
58 : JSC::JSNonFinalObject(vm, structure)
62 void finishCreation(JSC::VM&);
65 using JSattributeConstructor = JSDOMConstructorNotConstructable<JSattribute>;
69 static const struct CompactHashIndex JSattributeTableIndex[2] = {
75 static const HashTableValue JSattributeTableValues[] =
77 { "readonly", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsattributeReadonly), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
80 static const HashTable JSattributeTable = { 1, 1, true, JSattributeTableValues, JSattributeTableIndex };
81 template<> JSValue JSattributeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
84 return globalObject.functionPrototype();
87 template<> void JSattributeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
89 putDirect(vm, vm.propertyNames->prototype, JSattribute::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
90 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("attribute"))), ReadOnly | DontEnum);
91 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
94 template<> const ClassInfo JSattributeConstructor::s_info = { "attribute", &Base::s_info, 0, CREATE_METHOD_TABLE(JSattributeConstructor) };
96 /* Hash table for prototype */
98 static const HashTableValue JSattributePrototypeTableValues[] =
100 { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsattributeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSattributeConstructor) } },
103 const ClassInfo JSattributePrototype::s_info = { "attributePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSattributePrototype) };
105 void JSattributePrototype::finishCreation(VM& vm)
107 Base::finishCreation(vm);
108 reifyStaticProperties(vm, JSattributePrototypeTableValues, *this);
111 const ClassInfo JSattribute::s_info = { "attribute", &Base::s_info, &JSattributeTable, CREATE_METHOD_TABLE(JSattribute) };
113 JSattribute::JSattribute(Structure* structure, JSDOMGlobalObject& globalObject, Ref<attribute>&& impl)
114 : JSDOMWrapper<attribute>(structure, globalObject, WTFMove(impl))
118 JSObject* JSattribute::createPrototype(VM& vm, JSGlobalObject* globalObject)
120 return JSattributePrototype::create(vm, globalObject, JSattributePrototype::createStructure(vm, globalObject, globalObject->errorPrototype()));
123 JSObject* JSattribute::prototype(VM& vm, JSGlobalObject* globalObject)
125 return getDOMPrototype<JSattribute>(vm, globalObject);
128 void JSattribute::destroy(JSC::JSCell* cell)
130 JSattribute* thisObject = static_cast<JSattribute*>(cell);
131 thisObject->JSattribute::~JSattribute();
134 template<> inline JSattribute* BindingCaller<JSattribute>::castForAttribute(ExecState&, EncodedJSValue thisValue)
136 return jsDynamicCast<JSattribute*>(JSValue::decode(thisValue));
139 static inline JSValue jsattributeReadonlyGetter(ExecState&, JSattribute&, ThrowScope& throwScope);
141 EncodedJSValue jsattributeReadonly(ExecState* state, EncodedJSValue thisValue, PropertyName)
143 return BindingCaller<JSattribute>::attribute<jsattributeReadonlyGetter>(state, thisValue, "readonly");
146 static inline JSValue jsattributeReadonlyGetter(ExecState& state, JSattribute& thisObject, ThrowScope& throwScope)
148 UNUSED_PARAM(throwScope);
150 auto& impl = thisObject.wrapped();
151 JSValue result = toJS<IDLDOMString>(state, impl.readonly());
155 EncodedJSValue jsattributeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
157 VM& vm = state->vm();
158 auto throwScope = DECLARE_THROW_SCOPE(vm);
159 JSattributePrototype* domObject = jsDynamicCast<JSattributePrototype*>(JSValue::decode(thisValue));
160 if (UNLIKELY(!domObject))
161 return throwVMTypeError(state, throwScope);
162 return JSValue::encode(JSattribute::getConstructor(state->vm(), domObject->globalObject()));
165 bool setJSattributeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
167 VM& vm = state->vm();
168 auto throwScope = DECLARE_THROW_SCOPE(vm);
169 JSValue value = JSValue::decode(encodedValue);
170 JSattributePrototype* domObject = jsDynamicCast<JSattributePrototype*>(JSValue::decode(thisValue));
171 if (UNLIKELY(!domObject)) {
172 throwVMTypeError(state, throwScope);
175 // Shadowing a built-in constructor
176 return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
179 JSValue JSattribute::getConstructor(VM& vm, const JSGlobalObject* globalObject)
181 return getDOMConstructor<JSattributeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
184 bool JSattributeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
186 UNUSED_PARAM(handle);
187 UNUSED_PARAM(visitor);
191 void JSattributeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
193 auto* jsattribute = jsCast<JSattribute*>(handle.slot()->asCell());
194 auto& world = *static_cast<DOMWrapperWorld*>(context);
195 uncacheWrapper(world, &jsattribute->wrapped(), jsattribute);
198 #if ENABLE(BINDING_INTEGRITY)
200 #pragma warning(disable: 4483)
201 extern "C" { extern void (*const __identifier("??_7attribute@WebCore@@6B@")[])(); }
203 extern "C" { extern void* _ZTVN7WebCore9attributeE[]; }
207 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<attribute>&& impl)
210 #if ENABLE(BINDING_INTEGRITY)
211 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
213 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7attribute@WebCore@@6B@"));
215 void* expectedVTablePointer = &_ZTVN7WebCore9attributeE[2];
217 // If this fails attribute does not have a vtable, so you need to add the
218 // ImplementationLacksVTable attribute to the interface definition
219 static_assert(__is_polymorphic(attribute), "attribute is not polymorphic");
222 // If you hit this assertion you either have a use after free bug, or
223 // attribute has subclasses. If attribute has subclasses that get passed
224 // to toJS() we currently require attribute you to opt out of binding hardening
225 // by adding the SkipVTableValidation attribute to the interface IDL definition
226 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
228 return createWrapper<attribute>(globalObject, WTFMove(impl));
231 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, attribute& impl)
233 return wrap(state, globalObject, impl);
236 attribute* JSattribute::toWrapped(JSC::JSValue value)
238 if (auto* wrapper = jsDynamicCast<JSattribute*>(value))
239 return &wrapper->wrapped();