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