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 "JSTestCustomNamedGetter.h"
23
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>
30
31using namespace JSC;
32
33namespace WebCore {
34
35// Functions
36
37JSC::EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(JSC::ExecState*);
38
39// Attributes
40
41JSC::EncodedJSValue jsTestCustomNamedGetterConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
42
43class JSTestCustomNamedGetterPrototype : public JSC::JSNonFinalObject {
44public:
45    typedef JSC::JSNonFinalObject Base;
46    static JSTestCustomNamedGetterPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
47    {
48        JSTestCustomNamedGetterPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestCustomNamedGetterPrototype>(vm.heap)) JSTestCustomNamedGetterPrototype(vm, globalObject, structure);
49        ptr->finishCreation(vm);
50        return ptr;
51    }
52
53    DECLARE_INFO;
54    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
55    {
56        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
57    }
58
59private:
60    JSTestCustomNamedGetterPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
61        : JSC::JSNonFinalObject(vm, structure)
62    {
63    }
64
65    void finishCreation(JSC::VM&);
66};
67
68class JSTestCustomNamedGetterConstructor : public DOMConstructorObject {
69private:
70    JSTestCustomNamedGetterConstructor(JSC::Structure*, JSDOMGlobalObject*);
71    void finishCreation(JSC::VM&, JSDOMGlobalObject*);
72
73public:
74    typedef DOMConstructorObject Base;
75    static JSTestCustomNamedGetterConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
76    {
77        JSTestCustomNamedGetterConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestCustomNamedGetterConstructor>(vm.heap)) JSTestCustomNamedGetterConstructor(structure, globalObject);
78        ptr->finishCreation(vm, globalObject);
79        return ptr;
80    }
81
82    DECLARE_INFO;
83    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
84    {
85        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
86    }
87};
88
89/* Hash table */
90
91static const struct CompactHashIndex JSTestCustomNamedGetterTableIndex[2] = {
92    { -1, -1 },
93    { 0, -1 },
94};
95
96
97static const HashTableValue JSTestCustomNamedGetterTableValues[] =
98{
99    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCustomNamedGetterConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
100};
101
102static const HashTable JSTestCustomNamedGetterTable = { 1, 1, true, JSTestCustomNamedGetterTableValues, 0, JSTestCustomNamedGetterTableIndex };
103const ClassInfo JSTestCustomNamedGetterConstructor::s_info = { "TestCustomNamedGetterConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterConstructor) };
104
105JSTestCustomNamedGetterConstructor::JSTestCustomNamedGetterConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
106    : DOMConstructorObject(structure, globalObject)
107{
108}
109
110void JSTestCustomNamedGetterConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
111{
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);
116}
117
118/* Hash table for prototype */
119
120static const HashTableValue JSTestCustomNamedGetterPrototypeTableValues[] =
121{
122    { "anotherFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestCustomNamedGetterPrototypeFunctionAnotherFunction), (intptr_t) (1) },
123};
124
125const ClassInfo JSTestCustomNamedGetterPrototype::s_info = { "TestCustomNamedGetterPrototype", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterPrototype) };
126
127void JSTestCustomNamedGetterPrototype::finishCreation(VM& vm)
128{
129    Base::finishCreation(vm);
130    reifyStaticProperties(vm, JSTestCustomNamedGetterPrototypeTableValues, *this);
131}
132
133const ClassInfo JSTestCustomNamedGetter::s_info = { "TestCustomNamedGetter", &Base::s_info, &JSTestCustomNamedGetterTable, 0 , CREATE_METHOD_TABLE(JSTestCustomNamedGetter) };
134
135JSTestCustomNamedGetter::JSTestCustomNamedGetter(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestCustomNamedGetter> impl)
136    : JSDOMWrapper(structure, globalObject)
137    , m_impl(impl.leakRef())
138{
139}
140
141JSObject* JSTestCustomNamedGetter::createPrototype(VM& vm, JSGlobalObject* globalObject)
142{
143    return JSTestCustomNamedGetterPrototype::create(vm, globalObject, JSTestCustomNamedGetterPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
144}
145
146JSObject* JSTestCustomNamedGetter::getPrototype(VM& vm, JSGlobalObject* globalObject)
147{
148    return getDOMPrototype<JSTestCustomNamedGetter>(vm, globalObject);
149}
150
151void JSTestCustomNamedGetter::destroy(JSC::JSCell* cell)
152{
153    JSTestCustomNamedGetter* thisObject = static_cast<JSTestCustomNamedGetter*>(cell);
154    thisObject->JSTestCustomNamedGetter::~JSTestCustomNamedGetter();
155}
156
157JSTestCustomNamedGetter::~JSTestCustomNamedGetter()
158{
159    releaseImplIfNotNull();
160}
161
162bool JSTestCustomNamedGetter::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
163{
164    JSTestCustomNamedGetter* 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);
168        return true;
169    }
170    return getStaticValueSlot<JSTestCustomNamedGetter, Base>(exec, JSTestCustomNamedGetterTable, thisObject, propertyName, slot);
171}
172
173bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
174{
175    JSTestCustomNamedGetter* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
176    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
177    PropertyName propertyName = Identifier::from(exec, index);
178    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
179        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
180        return true;
181    }
182    return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
183}
184
185EncodedJSValue jsTestCustomNamedGetterConstructor(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
186{
187    JSTestCustomNamedGetter* domObject = jsDynamicCast<JSTestCustomNamedGetter*>(JSValue::decode(thisValue));
188    if (!domObject)
189        return throwVMTypeError(exec);
190    return JSValue::encode(JSTestCustomNamedGetter::getConstructor(exec->vm(), domObject->globalObject()));
191}
192
193JSValue JSTestCustomNamedGetter::getConstructor(VM& vm, JSGlobalObject* globalObject)
194{
195    return getDOMConstructor<JSTestCustomNamedGetterConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
196}
197
198EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(ExecState* exec)
199{
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    TestCustomNamedGetter& impl = castedThis->impl();
206    if (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());
213}
214
215bool JSTestCustomNamedGetterOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
216{
217    UNUSED_PARAM(handle);
218    UNUSED_PARAM(visitor);
219    return false;
220}
221
222void JSTestCustomNamedGetterOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
223{
224    JSTestCustomNamedGetter* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.slot()->asCell());
225    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
226    uncacheWrapper(world, &jsTestCustomNamedGetter->impl(), jsTestCustomNamedGetter);
227    jsTestCustomNamedGetter->releaseImpl();
228}
229
230#if ENABLE(BINDING_INTEGRITY)
231#if PLATFORM(WIN)
232#pragma warning(disable: 4483)
233extern "C" { extern void (*const __identifier("??_7TestCustomNamedGetter@WebCore@@6B@")[])(); }
234#else
235extern "C" { extern void* _ZTVN7WebCore21TestCustomNamedGetterE[]; }
236#endif
237#endif
238JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestCustomNamedGetter* impl)
239{
240    if (!impl)
241        return jsNull();
242    if (JSValue result = getExistingWrapper<JSTestCustomNamedGetter>(globalObject, impl))
243        return result;
244
245#if ENABLE(BINDING_INTEGRITY)
246    void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
247#if PLATFORM(WIN)
248    void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestCustomNamedGetter@WebCore@@6B@"));
249#else
250    void* expectedVTablePointer = &_ZTVN7WebCore21TestCustomNamedGetterE[2];
251#if COMPILER(CLANG)
252    // If this fails TestCustomNamedGetter does not have a vtable, so you need to add the
253    // ImplementationLacksVTable attribute to the interface definition
254    COMPILE_ASSERT(__is_polymorphic(TestCustomNamedGetter), TestCustomNamedGetter_is_not_polymorphic);
255#endif
256#endif
257    // If you hit this assertion you either have a use after free bug, or
258    // TestCustomNamedGetter has subclasses. If TestCustomNamedGetter has subclasses that get passed
259    // to toJS() we currently require TestCustomNamedGetter you to opt out of binding hardening
260    // by adding the SkipVTableValidation attribute to the interface IDL definition
261    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
262#endif
263    return createNewWrapper<JSTestCustomNamedGetter>(globalObject, impl);
264}
265
266TestCustomNamedGetter* toTestCustomNamedGetter(JSC::JSValue value)
267{
268    if (auto* wrapper = jsDynamicCast<JSTestCustomNamedGetter*>(value))
269        return &wrapper->impl();
270    return nullptr;
271}
272
273}
274