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 "JSTestCustomNamedGetter.h"
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "TestCustomNamedGetter.h"
27 #include "wtf/text/AtomicString.h"
28 #include <runtime/Error.h>
29 #include <wtf/GetPtr.h>
37 JSC::EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(JSC::ExecState*);
41 JSC::EncodedJSValue jsTestCustomNamedGetterConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
43 class JSTestCustomNamedGetterPrototype : public JSC::JSNonFinalObject {
45 typedef JSC::JSNonFinalObject Base;
46 static JSTestCustomNamedGetterPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
48 JSTestCustomNamedGetterPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestCustomNamedGetterPrototype>(vm.heap)) JSTestCustomNamedGetterPrototype(vm, globalObject, structure);
49 ptr->finishCreation(vm);
54 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
56 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
60 JSTestCustomNamedGetterPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
61 : JSC::JSNonFinalObject(vm, structure)
65 void finishCreation(JSC::VM&);
68 class JSTestCustomNamedGetterConstructor : public DOMConstructorObject {
70 JSTestCustomNamedGetterConstructor(JSC::Structure*, JSDOMGlobalObject*);
71 void finishCreation(JSC::VM&, JSDOMGlobalObject*);
74 typedef DOMConstructorObject Base;
75 static JSTestCustomNamedGetterConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
77 JSTestCustomNamedGetterConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestCustomNamedGetterConstructor>(vm.heap)) JSTestCustomNamedGetterConstructor(structure, globalObject);
78 ptr->finishCreation(vm, globalObject);
83 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
85 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
91 static const struct CompactHashIndex JSTestCustomNamedGetterTableIndex[2] = {
97 static const HashTableValue JSTestCustomNamedGetterTableValues[] =
99 { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCustomNamedGetterConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
102 static const HashTable JSTestCustomNamedGetterTable = { 1, 1, true, JSTestCustomNamedGetterTableValues, 0, JSTestCustomNamedGetterTableIndex };
103 const ClassInfo JSTestCustomNamedGetterConstructor::s_info = { "TestCustomNamedGetterConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterConstructor) };
105 JSTestCustomNamedGetterConstructor::JSTestCustomNamedGetterConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
106 : DOMConstructorObject(structure, globalObject)
110 void JSTestCustomNamedGetterConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
112 Base::finishCreation(vm);
113 ASSERT(inherits(info()));
114 putDirect(vm, vm.propertyNames->prototype, JSTestCustomNamedGetter::getPrototype(vm, globalObject), DontDelete | ReadOnly);
115 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
118 /* Hash table for prototype */
120 static const HashTableValue JSTestCustomNamedGetterPrototypeTableValues[] =
122 { "anotherFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestCustomNamedGetterPrototypeFunctionAnotherFunction), (intptr_t) (1) },
125 const ClassInfo JSTestCustomNamedGetterPrototype::s_info = { "TestCustomNamedGetterPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterPrototype) };
127 void JSTestCustomNamedGetterPrototype::finishCreation(VM& vm)
129 Base::finishCreation(vm);
130 reifyStaticProperties(vm, JSTestCustomNamedGetterPrototypeTableValues, *this);
133 const ClassInfo JSTestCustomNamedGetter::s_info = { "TestCustomNamedGetter", &Base::s_info, &JSTestCustomNamedGetterTable, CREATE_METHOD_TABLE(JSTestCustomNamedGetter) };
135 JSTestCustomNamedGetter::JSTestCustomNamedGetter(Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestCustomNamedGetter>&& impl)
136 : JSDOMWrapper(structure, globalObject)
137 , m_impl(&impl.leakRef())
141 JSObject* JSTestCustomNamedGetter::createPrototype(VM& vm, JSGlobalObject* globalObject)
143 return JSTestCustomNamedGetterPrototype::create(vm, globalObject, JSTestCustomNamedGetterPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
146 JSObject* JSTestCustomNamedGetter::getPrototype(VM& vm, JSGlobalObject* globalObject)
148 return getDOMPrototype<JSTestCustomNamedGetter>(vm, globalObject);
151 void JSTestCustomNamedGetter::destroy(JSC::JSCell* cell)
153 JSTestCustomNamedGetter* thisObject = static_cast<JSTestCustomNamedGetter*>(cell);
154 thisObject->JSTestCustomNamedGetter::~JSTestCustomNamedGetter();
157 JSTestCustomNamedGetter::~JSTestCustomNamedGetter()
162 bool JSTestCustomNamedGetter::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
164 auto* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
165 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
166 if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
167 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
170 return getStaticValueSlot<JSTestCustomNamedGetter, Base>(exec, JSTestCustomNamedGetterTable, thisObject, propertyName, slot);
173 bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
175 auto* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
176 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
177 Identifier propertyName = Identifier::from(exec, index);
178 if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
179 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
182 return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
185 EncodedJSValue jsTestCustomNamedGetterConstructor(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
187 JSTestCustomNamedGetter* domObject = jsDynamicCast<JSTestCustomNamedGetter*>(JSValue::decode(thisValue));
189 return throwVMTypeError(exec);
190 return JSValue::encode(JSTestCustomNamedGetter::getConstructor(exec->vm(), domObject->globalObject()));
193 JSValue JSTestCustomNamedGetter::getConstructor(VM& vm, JSGlobalObject* globalObject)
195 return getDOMConstructor<JSTestCustomNamedGetterConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
198 EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(ExecState* exec)
200 JSValue thisValue = exec->thisValue();
201 JSTestCustomNamedGetter* castedThis = jsDynamicCast<JSTestCustomNamedGetter*>(thisValue);
202 if (UNLIKELY(!castedThis))
203 return throwThisTypeError(*exec, "TestCustomNamedGetter", "anotherFunction");
204 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestCustomNamedGetter::info());
205 auto& impl = castedThis->impl();
206 if (UNLIKELY(exec->argumentCount() < 1))
207 return throwVMError(exec, createNotEnoughArgumentsError(exec));
208 const String str(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
209 if (UNLIKELY(exec->hadException()))
210 return JSValue::encode(jsUndefined());
211 impl.anotherFunction(str);
212 return JSValue::encode(jsUndefined());
215 bool JSTestCustomNamedGetterOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
217 UNUSED_PARAM(handle);
218 UNUSED_PARAM(visitor);
222 void JSTestCustomNamedGetterOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
224 auto* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.slot()->asCell());
225 auto& world = *static_cast<DOMWrapperWorld*>(context);
226 uncacheWrapper(world, &jsTestCustomNamedGetter->impl(), jsTestCustomNamedGetter);
229 #if ENABLE(BINDING_INTEGRITY)
231 #pragma warning(disable: 4483)
232 extern "C" { extern void (*const __identifier("??_7TestCustomNamedGetter@WebCore@@6B@")[])(); }
234 extern "C" { extern void* _ZTVN7WebCore21TestCustomNamedGetterE[]; }
237 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestCustomNamedGetter* impl)
241 if (JSValue result = getExistingWrapper<JSTestCustomNamedGetter>(globalObject, impl))
244 #if ENABLE(BINDING_INTEGRITY)
245 void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
247 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestCustomNamedGetter@WebCore@@6B@"));
249 void* expectedVTablePointer = &_ZTVN7WebCore21TestCustomNamedGetterE[2];
251 // If this fails TestCustomNamedGetter does not have a vtable, so you need to add the
252 // ImplementationLacksVTable attribute to the interface definition
253 COMPILE_ASSERT(__is_polymorphic(TestCustomNamedGetter), TestCustomNamedGetter_is_not_polymorphic);
256 // If you hit this assertion you either have a use after free bug, or
257 // TestCustomNamedGetter has subclasses. If TestCustomNamedGetter has subclasses that get passed
258 // to toJS() we currently require TestCustomNamedGetter you to opt out of binding hardening
259 // by adding the SkipVTableValidation attribute to the interface IDL definition
260 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
262 return createNewWrapper<JSTestCustomNamedGetter>(globalObject, impl);
265 TestCustomNamedGetter* JSTestCustomNamedGetter::toWrapped(JSC::JSValue value)
267 if (auto* wrapper = jsDynamicCast<JSTestCustomNamedGetter*>(value))
268 return &wrapper->impl();