Unreviewed, rolling out r251040.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestStringifierAnonymousOperation.cpp
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 "JSTestStringifierAnonymousOperation.h"
23
24 #include "JSDOMBinding.h"
25 #include "JSDOMConstructorNotConstructable.h"
26 #include "JSDOMConvertStrings.h"
27 #include "JSDOMExceptionHandling.h"
28 #include "JSDOMOperation.h"
29 #include "JSDOMWrapperCache.h"
30 #include "ScriptExecutionContext.h"
31 #include <JavaScriptCore/FunctionPrototype.h>
32 #include <JavaScriptCore/HeapAnalyzer.h>
33 #include <JavaScriptCore/JSCInlines.h>
34 #include <wtf/GetPtr.h>
35 #include <wtf/PointerPreparations.h>
36 #include <wtf/URL.h>
37
38
39 namespace WebCore {
40 using namespace JSC;
41
42 // Functions
43
44 JSC::EncodedJSValue JSC_HOST_CALL jsTestStringifierAnonymousOperationPrototypeFunctionToString(JSC::JSGlobalObject*, JSC::CallFrame*);
45
46 // Attributes
47
48 JSC::EncodedJSValue jsTestStringifierAnonymousOperationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49 bool setJSTestStringifierAnonymousOperationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50
51 class JSTestStringifierAnonymousOperationPrototype : public JSC::JSNonFinalObject {
52 public:
53     using Base = JSC::JSNonFinalObject;
54     static JSTestStringifierAnonymousOperationPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
55     {
56         JSTestStringifierAnonymousOperationPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestStringifierAnonymousOperationPrototype>(vm.heap)) JSTestStringifierAnonymousOperationPrototype(vm, globalObject, structure);
57         ptr->finishCreation(vm);
58         return ptr;
59     }
60
61     DECLARE_INFO;
62     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63     {
64         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65     }
66
67 private:
68     JSTestStringifierAnonymousOperationPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69         : JSC::JSNonFinalObject(vm, structure)
70     {
71     }
72
73     void finishCreation(JSC::VM&);
74 };
75
76 using JSTestStringifierAnonymousOperationConstructor = JSDOMConstructorNotConstructable<JSTestStringifierAnonymousOperation>;
77
78 template<> JSValue JSTestStringifierAnonymousOperationConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
79 {
80     UNUSED_PARAM(vm);
81     return globalObject.functionPrototype();
82 }
83
84 template<> void JSTestStringifierAnonymousOperationConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
85 {
86     putDirect(vm, vm.propertyNames->prototype, JSTestStringifierAnonymousOperation::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
87     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestStringifierAnonymousOperation"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 }
90
91 template<> const ClassInfo JSTestStringifierAnonymousOperationConstructor::s_info = { "TestStringifierAnonymousOperation", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierAnonymousOperationConstructor) };
92
93 /* Hash table for prototype */
94
95 static const HashTableValue JSTestStringifierAnonymousOperationPrototypeTableValues[] =
96 {
97     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestStringifierAnonymousOperationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestStringifierAnonymousOperationConstructor) } },
98     { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestStringifierAnonymousOperationPrototypeFunctionToString), (intptr_t) (0) } },
99 };
100
101 const ClassInfo JSTestStringifierAnonymousOperationPrototype::s_info = { "TestStringifierAnonymousOperationPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierAnonymousOperationPrototype) };
102
103 void JSTestStringifierAnonymousOperationPrototype::finishCreation(VM& vm)
104 {
105     Base::finishCreation(vm);
106     reifyStaticProperties(vm, JSTestStringifierAnonymousOperation::info(), JSTestStringifierAnonymousOperationPrototypeTableValues, *this);
107 }
108
109 const ClassInfo JSTestStringifierAnonymousOperation::s_info = { "TestStringifierAnonymousOperation", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierAnonymousOperation) };
110
111 JSTestStringifierAnonymousOperation::JSTestStringifierAnonymousOperation(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestStringifierAnonymousOperation>&& impl)
112     : JSDOMWrapper<TestStringifierAnonymousOperation>(structure, globalObject, WTFMove(impl))
113 {
114 }
115
116 void JSTestStringifierAnonymousOperation::finishCreation(VM& vm)
117 {
118     Base::finishCreation(vm);
119     ASSERT(inherits(vm, info()));
120
121 }
122
123 JSObject* JSTestStringifierAnonymousOperation::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
124 {
125     return JSTestStringifierAnonymousOperationPrototype::create(vm, &globalObject, JSTestStringifierAnonymousOperationPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
126 }
127
128 JSObject* JSTestStringifierAnonymousOperation::prototype(VM& vm, JSDOMGlobalObject& globalObject)
129 {
130     return getDOMPrototype<JSTestStringifierAnonymousOperation>(vm, globalObject);
131 }
132
133 JSValue JSTestStringifierAnonymousOperation::getConstructor(VM& vm, const JSGlobalObject* globalObject)
134 {
135     return getDOMConstructor<JSTestStringifierAnonymousOperationConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
136 }
137
138 void JSTestStringifierAnonymousOperation::destroy(JSC::JSCell* cell)
139 {
140     JSTestStringifierAnonymousOperation* thisObject = static_cast<JSTestStringifierAnonymousOperation*>(cell);
141     thisObject->JSTestStringifierAnonymousOperation::~JSTestStringifierAnonymousOperation();
142 }
143
144 template<> inline JSTestStringifierAnonymousOperation* IDLOperation<JSTestStringifierAnonymousOperation>::cast(ExecState& state)
145 {
146     return jsDynamicCast<JSTestStringifierAnonymousOperation*>(state.vm(), state.thisValue());
147 }
148
149 EncodedJSValue jsTestStringifierAnonymousOperationConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
150 {
151     VM& vm = state->vm();
152     auto throwScope = DECLARE_THROW_SCOPE(vm);
153     auto* prototype = jsDynamicCast<JSTestStringifierAnonymousOperationPrototype*>(vm, JSValue::decode(thisValue));
154     if (UNLIKELY(!prototype))
155         return throwVMTypeError(state, throwScope);
156     return JSValue::encode(JSTestStringifierAnonymousOperation::getConstructor(state->vm(), prototype->globalObject()));
157 }
158
159 bool setJSTestStringifierAnonymousOperationConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
160 {
161     VM& vm = state->vm();
162     auto throwScope = DECLARE_THROW_SCOPE(vm);
163     auto* prototype = jsDynamicCast<JSTestStringifierAnonymousOperationPrototype*>(vm, JSValue::decode(thisValue));
164     if (UNLIKELY(!prototype)) {
165         throwVMTypeError(state, throwScope);
166         return false;
167     }
168     // Shadowing a built-in constructor
169     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
170 }
171
172 static inline JSC::EncodedJSValue jsTestStringifierAnonymousOperationPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierAnonymousOperation>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
173 {
174     UNUSED_PARAM(state);
175     UNUSED_PARAM(throwScope);
176     auto& impl = castedThis->wrapped();
177     return JSValue::encode(toJS<IDLDOMString>(*state, impl.toString()));
178 }
179
180 EncodedJSValue JSC_HOST_CALL jsTestStringifierAnonymousOperationPrototypeFunctionToString(JSGlobalObject* globalObject, CallFrame* state)
181 {
182     UNUSED_PARAM(globalObject);
183     return IDLOperation<JSTestStringifierAnonymousOperation>::call<jsTestStringifierAnonymousOperationPrototypeFunctionToStringBody>(*state, "toString");
184 }
185
186 void JSTestStringifierAnonymousOperation::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
187 {
188     auto* thisObject = jsCast<JSTestStringifierAnonymousOperation*>(cell);
189     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
190     if (thisObject->scriptExecutionContext())
191         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
192     Base::analyzeHeap(cell, analyzer);
193 }
194
195 bool JSTestStringifierAnonymousOperationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
196 {
197     UNUSED_PARAM(handle);
198     UNUSED_PARAM(visitor);
199     UNUSED_PARAM(reason);
200     return false;
201 }
202
203 void JSTestStringifierAnonymousOperationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
204 {
205     auto* jsTestStringifierAnonymousOperation = static_cast<JSTestStringifierAnonymousOperation*>(handle.slot()->asCell());
206     auto& world = *static_cast<DOMWrapperWorld*>(context);
207     uncacheWrapper(world, &jsTestStringifierAnonymousOperation->wrapped(), jsTestStringifierAnonymousOperation);
208 }
209
210 #if ENABLE(BINDING_INTEGRITY)
211 #if PLATFORM(WIN)
212 #pragma warning(disable: 4483)
213 extern "C" { extern void (*const __identifier("??_7TestStringifierAnonymousOperation@WebCore@@6B@")[])(); }
214 #else
215 extern "C" { extern void* _ZTVN7WebCore33TestStringifierAnonymousOperationE[]; }
216 #endif
217 #endif
218
219 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestStringifierAnonymousOperation>&& impl)
220 {
221
222 #if ENABLE(BINDING_INTEGRITY)
223     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
224 #if PLATFORM(WIN)
225     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestStringifierAnonymousOperation@WebCore@@6B@"));
226 #else
227     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore33TestStringifierAnonymousOperationE[2]);
228 #endif
229
230     // If this fails TestStringifierAnonymousOperation does not have a vtable, so you need to add the
231     // ImplementationLacksVTable attribute to the interface definition
232     static_assert(std::is_polymorphic<TestStringifierAnonymousOperation>::value, "TestStringifierAnonymousOperation is not polymorphic");
233
234     // If you hit this assertion you either have a use after free bug, or
235     // TestStringifierAnonymousOperation has subclasses. If TestStringifierAnonymousOperation has subclasses that get passed
236     // to toJS() we currently require TestStringifierAnonymousOperation you to opt out of binding hardening
237     // by adding the SkipVTableValidation attribute to the interface IDL definition
238     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
239 #endif
240     return createWrapper<TestStringifierAnonymousOperation>(globalObject, WTFMove(impl));
241 }
242
243 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestStringifierAnonymousOperation& impl)
244 {
245     return wrap(state, globalObject, impl);
246 }
247
248 TestStringifierAnonymousOperation* JSTestStringifierAnonymousOperation::toWrapped(JSC::VM& vm, JSC::JSValue value)
249 {
250     if (auto* wrapper = jsDynamicCast<JSTestStringifierAnonymousOperation*>(vm, value))
251         return &wrapper->wrapped();
252     return nullptr;
253 }
254
255 }