Remove SetterMayThrowException
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestEnabledBySetting.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 "JSTestEnabledBySetting.h"
23
24 #include "Document.h"
25 #include "JSDOMAttribute.h"
26 #include "JSDOMBinding.h"
27 #include "JSDOMConstructorNotConstructable.h"
28 #include "JSDOMExceptionHandling.h"
29 #include "JSDOMOperation.h"
30 #include "JSDOMWrapperCache.h"
31 #include "JSTestSubObj.h"
32 #include "Settings.h"
33 #include "WebCoreJSClientData.h"
34 #include <runtime/FunctionPrototype.h>
35 #include <runtime/JSCInlines.h>
36 #include <wtf/GetPtr.h>
37
38 #if ENABLE(TEST_FEATURE)
39 #include "JSDOMConvertStrings.h"
40 #endif
41
42 using namespace JSC;
43
44 namespace WebCore {
45
46 // Functions
47
48 #if ENABLE(TEST_FEATURE)
49 JSC::EncodedJSValue JSC_HOST_CALL jsTestEnabledBySettingPrototypeFunctionEnabledBySettingOperation(JSC::ExecState*);
50 #endif
51
52 // Attributes
53
54 JSC::EncodedJSValue jsTestEnabledBySettingConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55 bool setJSTestEnabledBySettingConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
56 JSC::EncodedJSValue jsTestEnabledBySettingTestSubObjEnabledBySettingConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57 bool setJSTestEnabledBySettingTestSubObjEnabledBySettingConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
58 #if ENABLE(TEST_FEATURE)
59 JSC::EncodedJSValue jsTestEnabledBySettingEnabledBySettingAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60 bool setJSTestEnabledBySettingEnabledBySettingAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
61 #endif
62
63 class JSTestEnabledBySettingPrototype : public JSC::JSNonFinalObject {
64 public:
65     using Base = JSC::JSNonFinalObject;
66     static JSTestEnabledBySettingPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
67     {
68         JSTestEnabledBySettingPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestEnabledBySettingPrototype>(vm.heap)) JSTestEnabledBySettingPrototype(vm, globalObject, structure);
69         ptr->finishCreation(vm);
70         return ptr;
71     }
72
73     DECLARE_INFO;
74     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
75     {
76         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
77     }
78
79 private:
80     JSTestEnabledBySettingPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
81         : JSC::JSNonFinalObject(vm, structure)
82     {
83     }
84
85     void finishCreation(JSC::VM&);
86 };
87
88 using JSTestEnabledBySettingConstructor = JSDOMConstructorNotConstructable<JSTestEnabledBySetting>;
89
90 template<> JSValue JSTestEnabledBySettingConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
91 {
92     UNUSED_PARAM(vm);
93     return globalObject.functionPrototype();
94 }
95
96 template<> void JSTestEnabledBySettingConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
97 {
98     putDirect(vm, vm.propertyNames->prototype, JSTestEnabledBySetting::prototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
99     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestEnabledBySetting"))), ReadOnly | DontEnum);
100     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
101 }
102
103 template<> const ClassInfo JSTestEnabledBySettingConstructor::s_info = { "TestEnabledBySetting", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEnabledBySettingConstructor) };
104
105 /* Hash table for prototype */
106
107 static const HashTableValue JSTestEnabledBySettingPrototypeTableValues[] =
108 {
109     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEnabledBySettingConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestEnabledBySettingConstructor) } },
110 #if ENABLE(TEST_FEATURE)
111     { "enabledBySettingAttribute", CustomAccessor | DOMAttribute, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEnabledBySettingEnabledBySettingAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestEnabledBySettingEnabledBySettingAttribute) } },
112 #else
113     { 0, 0, NoIntrinsic, { 0, 0 } },
114 #endif
115 #if ENABLE(TEST_FEATURE)
116     { "enabledBySettingOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestEnabledBySettingPrototypeFunctionEnabledBySettingOperation), (intptr_t) (1) } },
117 #else
118     { 0, 0, NoIntrinsic, { 0, 0 } },
119 #endif
120 };
121
122 const ClassInfo JSTestEnabledBySettingPrototype::s_info = { "TestEnabledBySettingPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEnabledBySettingPrototype) };
123
124 void JSTestEnabledBySettingPrototype::finishCreation(VM& vm)
125 {
126     Base::finishCreation(vm);
127     reifyStaticProperties(vm, JSTestEnabledBySetting::info(), JSTestEnabledBySettingPrototypeTableValues, *this);
128 #if ENABLE(TEST_FEATURE)
129     if (!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled()) {
130         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledBySettingOperation"), strlen("enabledBySettingOperation"));
131         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
132         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
133     }
134 #endif
135 #if ENABLE(TEST_FEATURE)
136     if (!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled()) {
137         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledBySettingAttribute"), strlen("enabledBySettingAttribute"));
138         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
139         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
140     }
141 #endif
142 }
143
144 const ClassInfo JSTestEnabledBySetting::s_info = { "TestEnabledBySetting", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEnabledBySetting) };
145
146 JSTestEnabledBySetting::JSTestEnabledBySetting(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestEnabledBySetting>&& impl)
147     : JSDOMWrapper<TestEnabledBySetting>(structure, globalObject, WTFMove(impl))
148 {
149 }
150
151 void JSTestEnabledBySetting::finishCreation(VM& vm)
152 {
153     Base::finishCreation(vm);
154     ASSERT(inherits(vm, info()));
155
156     if (downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled())
157         putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TestSubObjEnabledBySettingPublicName(), CustomGetterSetter::create(vm, jsTestEnabledBySettingTestSubObjEnabledBySettingConstructor, setJSTestEnabledBySettingTestSubObjEnabledBySettingConstructor), attributesForStructure(DontEnum));
158 }
159
160 JSObject* JSTestEnabledBySetting::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
161 {
162     return JSTestEnabledBySettingPrototype::create(vm, &globalObject, JSTestEnabledBySettingPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
163 }
164
165 JSObject* JSTestEnabledBySetting::prototype(VM& vm, JSDOMGlobalObject& globalObject)
166 {
167     return getDOMPrototype<JSTestEnabledBySetting>(vm, globalObject);
168 }
169
170 JSValue JSTestEnabledBySetting::getConstructor(VM& vm, const JSGlobalObject* globalObject)
171 {
172     return getDOMConstructor<JSTestEnabledBySettingConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
173 }
174
175 void JSTestEnabledBySetting::destroy(JSC::JSCell* cell)
176 {
177     JSTestEnabledBySetting* thisObject = static_cast<JSTestEnabledBySetting*>(cell);
178     thisObject->JSTestEnabledBySetting::~JSTestEnabledBySetting();
179 }
180
181 template<> inline JSTestEnabledBySetting* IDLAttribute<JSTestEnabledBySetting>::cast(ExecState& state, EncodedJSValue thisValue)
182 {
183     return jsDynamicDowncast<JSTestEnabledBySetting*>(state.vm(), JSValue::decode(thisValue));
184 }
185
186 template<> inline JSTestEnabledBySetting* IDLOperation<JSTestEnabledBySetting>::cast(ExecState& state)
187 {
188     return jsDynamicDowncast<JSTestEnabledBySetting*>(state.vm(), state.thisValue());
189 }
190
191 EncodedJSValue jsTestEnabledBySettingConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
192 {
193     VM& vm = state->vm();
194     auto throwScope = DECLARE_THROW_SCOPE(vm);
195     auto* prototype = jsDynamicDowncast<JSTestEnabledBySettingPrototype*>(vm, JSValue::decode(thisValue));
196     if (UNLIKELY(!prototype))
197         return throwVMTypeError(state, throwScope);
198     return JSValue::encode(JSTestEnabledBySetting::getConstructor(state->vm(), prototype->globalObject()));
199 }
200
201 bool setJSTestEnabledBySettingConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
202 {
203     VM& vm = state->vm();
204     auto throwScope = DECLARE_THROW_SCOPE(vm);
205     auto* prototype = jsDynamicDowncast<JSTestEnabledBySettingPrototype*>(vm, JSValue::decode(thisValue));
206     if (UNLIKELY(!prototype)) {
207         throwVMTypeError(state, throwScope);
208         return false;
209     }
210     // Shadowing a built-in constructor
211     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
212 }
213
214 static inline JSValue jsTestEnabledBySettingTestSubObjEnabledBySettingConstructorGetter(ExecState& state, JSTestEnabledBySetting& thisObject, ThrowScope& throwScope)
215 {
216     UNUSED_PARAM(throwScope);
217     UNUSED_PARAM(state);
218     return JSTestSubObj::getConstructor(state.vm(), thisObject.globalObject());
219 }
220
221 EncodedJSValue jsTestEnabledBySettingTestSubObjEnabledBySettingConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
222 {
223     return IDLAttribute<JSTestEnabledBySetting>::get<jsTestEnabledBySettingTestSubObjEnabledBySettingConstructorGetter>(*state, thisValue, "TestSubObjEnabledBySetting");
224 }
225
226 static inline bool setJSTestEnabledBySettingTestSubObjEnabledBySettingConstructorSetter(ExecState& state, JSTestEnabledBySetting& thisObject, JSValue value, ThrowScope& throwScope)
227 {
228     UNUSED_PARAM(throwScope);
229     // Shadowing a built-in constructor.
230     return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("TestSubObjEnabledBySetting"), strlen("TestSubObjEnabledBySetting")), value);
231 }
232
233 bool setJSTestEnabledBySettingTestSubObjEnabledBySettingConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
234 {
235     return IDLAttribute<JSTestEnabledBySetting>::set<setJSTestEnabledBySettingTestSubObjEnabledBySettingConstructorSetter>(*state, thisValue, encodedValue, "TestSubObjEnabledBySetting");
236 }
237
238 #if ENABLE(TEST_FEATURE)
239 static inline JSValue jsTestEnabledBySettingEnabledBySettingAttributeGetter(ExecState& state, JSTestEnabledBySetting& thisObject, ThrowScope& throwScope)
240 {
241     UNUSED_PARAM(throwScope);
242     UNUSED_PARAM(state);
243     auto& impl = thisObject.wrapped();
244     JSValue result = toJS<IDLDOMString>(state, impl.enabledBySettingAttribute());
245     return result;
246 }
247
248 EncodedJSValue jsTestEnabledBySettingEnabledBySettingAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
249 {
250     return IDLAttribute<JSTestEnabledBySetting>::get<jsTestEnabledBySettingEnabledBySettingAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "enabledBySettingAttribute");
251 }
252
253 #endif
254
255 #if ENABLE(TEST_FEATURE)
256 static inline bool setJSTestEnabledBySettingEnabledBySettingAttributeSetter(ExecState& state, JSTestEnabledBySetting& thisObject, JSValue value, ThrowScope& throwScope)
257 {
258     UNUSED_PARAM(throwScope);
259     auto& impl = thisObject.wrapped();
260     auto nativeValue = convert<IDLDOMString>(state, value);
261     RETURN_IF_EXCEPTION(throwScope, false);
262     AttributeSetter::call(state, throwScope, [&] {
263         return impl.setEnabledBySettingAttribute(WTFMove(nativeValue));
264     });
265     return true;
266 }
267
268 bool setJSTestEnabledBySettingEnabledBySettingAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
269 {
270     return IDLAttribute<JSTestEnabledBySetting>::set<setJSTestEnabledBySettingEnabledBySettingAttributeSetter>(*state, thisValue, encodedValue, "enabledBySettingAttribute");
271 }
272
273 #endif
274
275 #if ENABLE(TEST_FEATURE)
276 static inline JSC::EncodedJSValue jsTestEnabledBySettingPrototypeFunctionEnabledBySettingOperationBody(JSC::ExecState* state, typename IDLOperation<JSTestEnabledBySetting>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
277 {
278     UNUSED_PARAM(state);
279     UNUSED_PARAM(throwScope);
280     auto& impl = castedThis->wrapped();
281     if (UNLIKELY(state->argumentCount() < 1))
282         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
283     auto testParam = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
284     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
285     impl.enabledBySettingOperation(WTFMove(testParam));
286     return JSValue::encode(jsUndefined());
287 }
288
289 EncodedJSValue JSC_HOST_CALL jsTestEnabledBySettingPrototypeFunctionEnabledBySettingOperation(ExecState* state)
290 {
291     return IDLOperation<JSTestEnabledBySetting>::call<jsTestEnabledBySettingPrototypeFunctionEnabledBySettingOperationBody>(*state, "enabledBySettingOperation");
292 }
293
294 #endif
295
296 bool JSTestEnabledBySettingOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
297 {
298     UNUSED_PARAM(handle);
299     UNUSED_PARAM(visitor);
300     return false;
301 }
302
303 void JSTestEnabledBySettingOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
304 {
305     auto* jsTestEnabledBySetting = static_cast<JSTestEnabledBySetting*>(handle.slot()->asCell());
306     auto& world = *static_cast<DOMWrapperWorld*>(context);
307     uncacheWrapper(world, &jsTestEnabledBySetting->wrapped(), jsTestEnabledBySetting);
308 }
309
310 #if ENABLE(BINDING_INTEGRITY)
311 #if PLATFORM(WIN)
312 #pragma warning(disable: 4483)
313 extern "C" { extern void (*const __identifier("??_7TestEnabledBySetting@WebCore@@6B@")[])(); }
314 #else
315 extern "C" { extern void* _ZTVN7WebCore20TestEnabledBySettingE[]; }
316 #endif
317 #endif
318
319 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestEnabledBySetting>&& impl)
320 {
321
322 #if ENABLE(BINDING_INTEGRITY)
323     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
324 #if PLATFORM(WIN)
325     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestEnabledBySetting@WebCore@@6B@"));
326 #else
327     void* expectedVTablePointer = &_ZTVN7WebCore20TestEnabledBySettingE[2];
328 #endif
329
330     // If this fails TestEnabledBySetting does not have a vtable, so you need to add the
331     // ImplementationLacksVTable attribute to the interface definition
332     static_assert(std::is_polymorphic<TestEnabledBySetting>::value, "TestEnabledBySetting is not polymorphic");
333
334     // If you hit this assertion you either have a use after free bug, or
335     // TestEnabledBySetting has subclasses. If TestEnabledBySetting has subclasses that get passed
336     // to toJS() we currently require TestEnabledBySetting you to opt out of binding hardening
337     // by adding the SkipVTableValidation attribute to the interface IDL definition
338     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
339 #endif
340     return createWrapper<TestEnabledBySetting>(globalObject, WTFMove(impl));
341 }
342
343 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestEnabledBySetting& impl)
344 {
345     return wrap(state, globalObject, impl);
346 }
347
348 TestEnabledBySetting* JSTestEnabledBySetting::toWrapped(JSC::VM& vm, JSC::JSValue value)
349 {
350     if (auto* wrapper = jsDynamicDowncast<JSTestEnabledBySetting*>(vm, value))
351         return &wrapper->wrapped();
352     return nullptr;
353 }
354
355 }