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 "JSTestNamedConstructor.h"
23
24#include "DOMConstructorWithDocument.h"
25#include "ExceptionCode.h"
26#include "JSDOMBinding.h"
27#include "TestNamedConstructor.h"
28#include <runtime/Error.h>
29#include <wtf/GetPtr.h>
30
31using namespace JSC;
32
33namespace WebCore {
34
35// Attributes
36
37JSC::EncodedJSValue jsTestNamedConstructorConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
38
39class JSTestNamedConstructorPrototype : public JSC::JSNonFinalObject {
40public:
41    typedef JSC::JSNonFinalObject Base;
42    static JSTestNamedConstructorPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
43    {
44        JSTestNamedConstructorPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNamedConstructorPrototype>(vm.heap)) JSTestNamedConstructorPrototype(vm, globalObject, structure);
45        ptr->finishCreation(vm);
46        return ptr;
47    }
48
49    DECLARE_INFO;
50    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
51    {
52        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
53    }
54
55private:
56    JSTestNamedConstructorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
57        : JSC::JSNonFinalObject(vm, structure)
58    {
59    }
60
61    void finishCreation(JSC::VM&);
62};
63
64class JSTestNamedConstructorConstructor : public DOMConstructorObject {
65private:
66    JSTestNamedConstructorConstructor(JSC::Structure*, JSDOMGlobalObject*);
67    void finishCreation(JSC::VM&, JSDOMGlobalObject*);
68
69public:
70    typedef DOMConstructorObject Base;
71    static JSTestNamedConstructorConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
72    {
73        JSTestNamedConstructorConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestNamedConstructorConstructor>(vm.heap)) JSTestNamedConstructorConstructor(structure, globalObject);
74        ptr->finishCreation(vm, globalObject);
75        return ptr;
76    }
77
78    DECLARE_INFO;
79    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
80    {
81        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
82    }
83};
84
85class JSTestNamedConstructorNamedConstructor : public DOMConstructorWithDocument {
86public:
87    typedef DOMConstructorWithDocument Base;
88
89    static JSTestNamedConstructorNamedConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
90    {
91        JSTestNamedConstructorNamedConstructor* constructor = new (NotNull, JSC::allocateCell<JSTestNamedConstructorNamedConstructor>(vm.heap)) JSTestNamedConstructorNamedConstructor(structure, globalObject);
92        constructor->finishCreation(vm, globalObject);
93        return constructor;
94    }
95
96    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
97    {
98        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
99    }
100
101    DECLARE_INFO;
102
103private:
104    JSTestNamedConstructorNamedConstructor(JSC::Structure*, JSDOMGlobalObject*);
105    static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestNamedConstructor(JSC::ExecState*);
106    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
107    void finishCreation(JSC::VM&, JSDOMGlobalObject*);
108};
109
110const ClassInfo JSTestNamedConstructorConstructor::s_info = { "TestNamedConstructorConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorConstructor) };
111
112JSTestNamedConstructorConstructor::JSTestNamedConstructorConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
113    : DOMConstructorObject(structure, globalObject)
114{
115}
116
117void JSTestNamedConstructorConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
118{
119    Base::finishCreation(vm);
120    ASSERT(inherits(info()));
121    putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructor::getPrototype(vm, globalObject), DontDelete | ReadOnly);
122    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
123}
124
125EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor(ExecState* exec)
126{
127    JSTestNamedConstructorNamedConstructor* castedThis = jsCast<JSTestNamedConstructorNamedConstructor*>(exec->callee());
128    if (exec->argumentCount() < 1)
129        return throwVMError(exec, createNotEnoughArgumentsError(exec));
130    ExceptionCode ec = 0;
131    const String& str1(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
132    if (UNLIKELY(exec->hadException()))
133        return JSValue::encode(jsUndefined());
134    const String& str2(exec->argument(1).isEmpty() ? String() : exec->argument(1).toString(exec)->value(exec));
135    if (UNLIKELY(exec->hadException()))
136        return JSValue::encode(jsUndefined());
137    const String& str3(argumentOrNull(exec, 2).isEmpty() ? String() : argumentOrNull(exec, 2).toString(exec)->value(exec));
138    if (UNLIKELY(exec->hadException()))
139        return JSValue::encode(jsUndefined());
140    RefPtr<TestNamedConstructor> object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), str1, str2, str3, ec);
141    if (ec) {
142        setDOMException(exec, ec);
143        return JSValue::encode(JSValue());
144    }
145    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
146}
147
148const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "AudioConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) };
149
150JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
151    : DOMConstructorWithDocument(structure, globalObject)
152{
153}
154
155void JSTestNamedConstructorNamedConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
156{
157    Base::finishCreation(globalObject);
158    ASSERT(inherits(info()));
159    putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructor::getPrototype(vm, globalObject), None);
160    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
161}
162
163ConstructType JSTestNamedConstructorNamedConstructor::getConstructData(JSCell*, ConstructData& constructData)
164{
165    constructData.native.function = constructJSTestNamedConstructor;
166    return ConstructTypeHost;
167}
168
169/* Hash table for prototype */
170
171static const HashTableValue JSTestNamedConstructorPrototypeTableValues[] =
172{
173    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNamedConstructorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
174};
175
176const ClassInfo JSTestNamedConstructorPrototype::s_info = { "TestNamedConstructorPrototype", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorPrototype) };
177
178void JSTestNamedConstructorPrototype::finishCreation(VM& vm)
179{
180    Base::finishCreation(vm);
181    reifyStaticProperties(vm, JSTestNamedConstructorPrototypeTableValues, *this);
182}
183
184const ClassInfo JSTestNamedConstructor::s_info = { "TestNamedConstructor", &Base::s_info, 0, 0 , CREATE_METHOD_TABLE(JSTestNamedConstructor) };
185
186JSTestNamedConstructor::JSTestNamedConstructor(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestNamedConstructor> impl)
187    : JSDOMWrapper(structure, globalObject)
188    , m_impl(impl.leakRef())
189{
190}
191
192JSObject* JSTestNamedConstructor::createPrototype(VM& vm, JSGlobalObject* globalObject)
193{
194    return JSTestNamedConstructorPrototype::create(vm, globalObject, JSTestNamedConstructorPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
195}
196
197JSObject* JSTestNamedConstructor::getPrototype(VM& vm, JSGlobalObject* globalObject)
198{
199    return getDOMPrototype<JSTestNamedConstructor>(vm, globalObject);
200}
201
202void JSTestNamedConstructor::destroy(JSC::JSCell* cell)
203{
204    JSTestNamedConstructor* thisObject = static_cast<JSTestNamedConstructor*>(cell);
205    thisObject->JSTestNamedConstructor::~JSTestNamedConstructor();
206}
207
208JSTestNamedConstructor::~JSTestNamedConstructor()
209{
210    releaseImplIfNotNull();
211}
212
213EncodedJSValue jsTestNamedConstructorConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
214{
215    JSTestNamedConstructorPrototype* domObject = jsDynamicCast<JSTestNamedConstructorPrototype*>(baseValue);
216    if (!domObject)
217        return throwVMTypeError(exec);
218    return JSValue::encode(JSTestNamedConstructor::getConstructor(exec->vm(), domObject->globalObject()));
219}
220
221JSValue JSTestNamedConstructor::getConstructor(VM& vm, JSGlobalObject* globalObject)
222{
223    return getDOMConstructor<JSTestNamedConstructorConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
224}
225
226JSValue JSTestNamedConstructor::getNamedConstructor(VM& vm, JSGlobalObject* globalObject)
227{
228    return getDOMConstructor<JSTestNamedConstructorNamedConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
229}
230
231bool JSTestNamedConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
232{
233    JSTestNamedConstructor* jsTestNamedConstructor = jsCast<JSTestNamedConstructor*>(handle.slot()->asCell());
234    if (jsTestNamedConstructor->impl().hasPendingActivity())
235        return true;
236    UNUSED_PARAM(visitor);
237    return false;
238}
239
240void JSTestNamedConstructorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
241{
242    JSTestNamedConstructor* jsTestNamedConstructor = jsCast<JSTestNamedConstructor*>(handle.slot()->asCell());
243    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
244    uncacheWrapper(world, &jsTestNamedConstructor->impl(), jsTestNamedConstructor);
245    jsTestNamedConstructor->releaseImpl();
246}
247
248#if ENABLE(BINDING_INTEGRITY)
249#if PLATFORM(WIN)
250#pragma warning(disable: 4483)
251extern "C" { extern void (*const __identifier("??_7TestNamedConstructor@WebCore@@6B@")[])(); }
252#else
253extern "C" { extern void* _ZTVN7WebCore20TestNamedConstructorE[]; }
254#endif
255#endif
256JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestNamedConstructor* impl)
257{
258    if (!impl)
259        return jsNull();
260    if (JSValue result = getExistingWrapper<JSTestNamedConstructor>(globalObject, impl))
261        return result;
262
263#if ENABLE(BINDING_INTEGRITY)
264    void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
265#if PLATFORM(WIN)
266    void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestNamedConstructor@WebCore@@6B@"));
267#else
268    void* expectedVTablePointer = &_ZTVN7WebCore20TestNamedConstructorE[2];
269#if COMPILER(CLANG)
270    // If this fails TestNamedConstructor does not have a vtable, so you need to add the
271    // ImplementationLacksVTable attribute to the interface definition
272    COMPILE_ASSERT(__is_polymorphic(TestNamedConstructor), TestNamedConstructor_is_not_polymorphic);
273#endif
274#endif
275    // If you hit this assertion you either have a use after free bug, or
276    // TestNamedConstructor has subclasses. If TestNamedConstructor has subclasses that get passed
277    // to toJS() we currently require TestNamedConstructor you to opt out of binding hardening
278    // by adding the SkipVTableValidation attribute to the interface IDL definition
279    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
280#endif
281    return createNewWrapper<JSTestNamedConstructor>(globalObject, impl);
282}
283
284TestNamedConstructor* toTestNamedConstructor(JSC::JSValue value)
285{
286    if (auto* wrapper = jsDynamicCast<JSTestNamedConstructor*>(value))
287        return &wrapper->impl();
288    return nullptr;
289}
290
291}
292