Rename AtomicString to AtomString
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestNamedDeleterWithIdentifier.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 "JSTestNamedDeleterWithIdentifier.h"
23
24 #include "JSDOMAbstractOperations.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructorNotConstructable.h"
27 #include "JSDOMConvertStrings.h"
28 #include "JSDOMExceptionHandling.h"
29 #include "JSDOMOperation.h"
30 #include "JSDOMWrapperCache.h"
31 #include "ScriptExecutionContext.h"
32 #include <JavaScriptCore/FunctionPrototype.h>
33 #include <JavaScriptCore/HeapSnapshotBuilder.h>
34 #include <JavaScriptCore/JSCInlines.h>
35 #include <wtf/GetPtr.h>
36 #include <wtf/PointerPreparations.h>
37 #include <wtf/URL.h>
38
39
40 namespace WebCore {
41 using namespace JSC;
42
43 // Functions
44
45 JSC::EncodedJSValue JSC_HOST_CALL jsTestNamedDeleterWithIdentifierPrototypeFunctionNamedDeleter(JSC::ExecState*);
46
47 // Attributes
48
49 JSC::EncodedJSValue jsTestNamedDeleterWithIdentifierConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50 bool setJSTestNamedDeleterWithIdentifierConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51
52 class JSTestNamedDeleterWithIdentifierPrototype : public JSC::JSNonFinalObject {
53 public:
54     using Base = JSC::JSNonFinalObject;
55     static JSTestNamedDeleterWithIdentifierPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
56     {
57         JSTestNamedDeleterWithIdentifierPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNamedDeleterWithIdentifierPrototype>(vm.heap)) JSTestNamedDeleterWithIdentifierPrototype(vm, globalObject, structure);
58         ptr->finishCreation(vm);
59         return ptr;
60     }
61
62     DECLARE_INFO;
63     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
64     {
65         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
66     }
67
68 private:
69     JSTestNamedDeleterWithIdentifierPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
70         : JSC::JSNonFinalObject(vm, structure)
71     {
72     }
73
74     void finishCreation(JSC::VM&);
75 };
76
77 using JSTestNamedDeleterWithIdentifierConstructor = JSDOMConstructorNotConstructable<JSTestNamedDeleterWithIdentifier>;
78
79 template<> JSValue JSTestNamedDeleterWithIdentifierConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
80 {
81     UNUSED_PARAM(vm);
82     return globalObject.functionPrototype();
83 }
84
85 template<> void JSTestNamedDeleterWithIdentifierConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
86 {
87     putDirect(vm, vm.propertyNames->prototype, JSTestNamedDeleterWithIdentifier::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestNamedDeleterWithIdentifier"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 }
91
92 template<> const ClassInfo JSTestNamedDeleterWithIdentifierConstructor::s_info = { "TestNamedDeleterWithIdentifier", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNamedDeleterWithIdentifierConstructor) };
93
94 /* Hash table for prototype */
95
96 static const HashTableValue JSTestNamedDeleterWithIdentifierPrototypeTableValues[] =
97 {
98     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNamedDeleterWithIdentifierConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNamedDeleterWithIdentifierConstructor) } },
99     { "namedDeleter", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNamedDeleterWithIdentifierPrototypeFunctionNamedDeleter), (intptr_t) (1) } },
100 };
101
102 const ClassInfo JSTestNamedDeleterWithIdentifierPrototype::s_info = { "TestNamedDeleterWithIdentifierPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNamedDeleterWithIdentifierPrototype) };
103
104 void JSTestNamedDeleterWithIdentifierPrototype::finishCreation(VM& vm)
105 {
106     Base::finishCreation(vm);
107     reifyStaticProperties(vm, JSTestNamedDeleterWithIdentifier::info(), JSTestNamedDeleterWithIdentifierPrototypeTableValues, *this);
108 }
109
110 const ClassInfo JSTestNamedDeleterWithIdentifier::s_info = { "TestNamedDeleterWithIdentifier", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNamedDeleterWithIdentifier) };
111
112 JSTestNamedDeleterWithIdentifier::JSTestNamedDeleterWithIdentifier(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestNamedDeleterWithIdentifier>&& impl)
113     : JSDOMWrapper<TestNamedDeleterWithIdentifier>(structure, globalObject, WTFMove(impl))
114 {
115 }
116
117 void JSTestNamedDeleterWithIdentifier::finishCreation(VM& vm)
118 {
119     Base::finishCreation(vm);
120     ASSERT(inherits(vm, info()));
121
122 }
123
124 JSObject* JSTestNamedDeleterWithIdentifier::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
125 {
126     return JSTestNamedDeleterWithIdentifierPrototype::create(vm, &globalObject, JSTestNamedDeleterWithIdentifierPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
127 }
128
129 JSObject* JSTestNamedDeleterWithIdentifier::prototype(VM& vm, JSDOMGlobalObject& globalObject)
130 {
131     return getDOMPrototype<JSTestNamedDeleterWithIdentifier>(vm, globalObject);
132 }
133
134 JSValue JSTestNamedDeleterWithIdentifier::getConstructor(VM& vm, const JSGlobalObject* globalObject)
135 {
136     return getDOMConstructor<JSTestNamedDeleterWithIdentifierConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
137 }
138
139 void JSTestNamedDeleterWithIdentifier::destroy(JSC::JSCell* cell)
140 {
141     JSTestNamedDeleterWithIdentifier* thisObject = static_cast<JSTestNamedDeleterWithIdentifier*>(cell);
142     thisObject->JSTestNamedDeleterWithIdentifier::~JSTestNamedDeleterWithIdentifier();
143 }
144
145 bool JSTestNamedDeleterWithIdentifier::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
146 {
147     auto* thisObject = jsCast<JSTestNamedDeleterWithIdentifier*>(object);
148     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
149     using GetterIDLType = IDLDOMString;
150     auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
151         auto result = thisObject.wrapped().namedItem(propertyNameToAtomString(propertyName));
152         if (!GetterIDLType::isNullValue(result))
153             return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
154         return WTF::nullopt;
155     };
156     if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
157         auto value = toJS<IDLDOMString>(*state, WTFMove(namedProperty.value()));
158         slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
159         return true;
160     }
161     return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
162 }
163
164 bool JSTestNamedDeleterWithIdentifier::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
165 {
166     auto* thisObject = jsCast<JSTestNamedDeleterWithIdentifier*>(object);
167     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
168     auto propertyName = Identifier::from(state, index);
169     using GetterIDLType = IDLDOMString;
170     auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
171         auto result = thisObject.wrapped().namedItem(propertyNameToAtomString(propertyName));
172         if (!GetterIDLType::isNullValue(result))
173             return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
174         return WTF::nullopt;
175     };
176     if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
177         auto value = toJS<IDLDOMString>(*state, WTFMove(namedProperty.value()));
178         slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
179         return true;
180     }
181     return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
182 }
183
184 void JSTestNamedDeleterWithIdentifier::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
185 {
186     auto* thisObject = jsCast<JSTestNamedDeleterWithIdentifier*>(object);
187     ASSERT_GC_OBJECT_INHERITS(object, info());
188     for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())
189         propertyNames.add(Identifier::fromString(state, propertyName));
190     JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
191 }
192
193 bool JSTestNamedDeleterWithIdentifier::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName)
194 {
195     auto& thisObject = *jsCast<JSTestNamedDeleterWithIdentifier*>(cell);
196     auto& impl = thisObject.wrapped();
197     if (isVisibleNamedProperty<OverrideBuiltins::No>(*state, thisObject, propertyName)) {
198         impl.namedDeleter(propertyNameToString(propertyName));
199         return true;
200     }
201     return JSObject::deleteProperty(cell, state, propertyName);
202 }
203
204 bool JSTestNamedDeleterWithIdentifier::deletePropertyByIndex(JSCell* cell, ExecState* state, unsigned index)
205 {
206     auto& thisObject = *jsCast<JSTestNamedDeleterWithIdentifier*>(cell);
207     auto& impl = thisObject.wrapped();
208     auto propertyName = Identifier::from(state, index);
209     if (isVisibleNamedProperty<OverrideBuiltins::No>(*state, thisObject, propertyName)) {
210         impl.namedDeleter(propertyNameToString(propertyName));
211         return true;
212     }
213     return JSObject::deletePropertyByIndex(cell, state, index);
214 }
215
216 template<> inline JSTestNamedDeleterWithIdentifier* IDLOperation<JSTestNamedDeleterWithIdentifier>::cast(ExecState& state)
217 {
218     return jsDynamicCast<JSTestNamedDeleterWithIdentifier*>(state.vm(), state.thisValue());
219 }
220
221 EncodedJSValue jsTestNamedDeleterWithIdentifierConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
222 {
223     VM& vm = state->vm();
224     auto throwScope = DECLARE_THROW_SCOPE(vm);
225     auto* prototype = jsDynamicCast<JSTestNamedDeleterWithIdentifierPrototype*>(vm, JSValue::decode(thisValue));
226     if (UNLIKELY(!prototype))
227         return throwVMTypeError(state, throwScope);
228     return JSValue::encode(JSTestNamedDeleterWithIdentifier::getConstructor(state->vm(), prototype->globalObject()));
229 }
230
231 bool setJSTestNamedDeleterWithIdentifierConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
232 {
233     VM& vm = state->vm();
234     auto throwScope = DECLARE_THROW_SCOPE(vm);
235     auto* prototype = jsDynamicCast<JSTestNamedDeleterWithIdentifierPrototype*>(vm, JSValue::decode(thisValue));
236     if (UNLIKELY(!prototype)) {
237         throwVMTypeError(state, throwScope);
238         return false;
239     }
240     // Shadowing a built-in constructor
241     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
242 }
243
244 static inline JSC::EncodedJSValue jsTestNamedDeleterWithIdentifierPrototypeFunctionNamedDeleterBody(JSC::ExecState* state, typename IDLOperation<JSTestNamedDeleterWithIdentifier>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
245 {
246     UNUSED_PARAM(state);
247     UNUSED_PARAM(throwScope);
248     auto& impl = castedThis->wrapped();
249     if (UNLIKELY(state->argumentCount() < 1))
250         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
251     auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
252     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
253     impl.namedDeleter(WTFMove(name));
254     return JSValue::encode(jsUndefined());
255 }
256
257 EncodedJSValue JSC_HOST_CALL jsTestNamedDeleterWithIdentifierPrototypeFunctionNamedDeleter(ExecState* state)
258 {
259     return IDLOperation<JSTestNamedDeleterWithIdentifier>::call<jsTestNamedDeleterWithIdentifierPrototypeFunctionNamedDeleterBody>(*state, "namedDeleter");
260 }
261
262 void JSTestNamedDeleterWithIdentifier::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
263 {
264     auto* thisObject = jsCast<JSTestNamedDeleterWithIdentifier*>(cell);
265     builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
266     if (thisObject->scriptExecutionContext())
267         builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
268     Base::heapSnapshot(cell, builder);
269 }
270
271 bool JSTestNamedDeleterWithIdentifierOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
272 {
273     UNUSED_PARAM(handle);
274     UNUSED_PARAM(visitor);
275     UNUSED_PARAM(reason);
276     return false;
277 }
278
279 void JSTestNamedDeleterWithIdentifierOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
280 {
281     auto* jsTestNamedDeleterWithIdentifier = static_cast<JSTestNamedDeleterWithIdentifier*>(handle.slot()->asCell());
282     auto& world = *static_cast<DOMWrapperWorld*>(context);
283     uncacheWrapper(world, &jsTestNamedDeleterWithIdentifier->wrapped(), jsTestNamedDeleterWithIdentifier);
284 }
285
286 #if ENABLE(BINDING_INTEGRITY)
287 #if PLATFORM(WIN)
288 #pragma warning(disable: 4483)
289 extern "C" { extern void (*const __identifier("??_7TestNamedDeleterWithIdentifier@WebCore@@6B@")[])(); }
290 #else
291 extern "C" { extern void* _ZTVN7WebCore30TestNamedDeleterWithIdentifierE[]; }
292 #endif
293 #endif
294
295 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestNamedDeleterWithIdentifier>&& impl)
296 {
297
298 #if ENABLE(BINDING_INTEGRITY)
299     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
300 #if PLATFORM(WIN)
301     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestNamedDeleterWithIdentifier@WebCore@@6B@"));
302 #else
303     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore30TestNamedDeleterWithIdentifierE[2]);
304 #endif
305
306     // If this fails TestNamedDeleterWithIdentifier does not have a vtable, so you need to add the
307     // ImplementationLacksVTable attribute to the interface definition
308     static_assert(std::is_polymorphic<TestNamedDeleterWithIdentifier>::value, "TestNamedDeleterWithIdentifier is not polymorphic");
309
310     // If you hit this assertion you either have a use after free bug, or
311     // TestNamedDeleterWithIdentifier has subclasses. If TestNamedDeleterWithIdentifier has subclasses that get passed
312     // to toJS() we currently require TestNamedDeleterWithIdentifier you to opt out of binding hardening
313     // by adding the SkipVTableValidation attribute to the interface IDL definition
314     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
315 #endif
316     return createWrapper<TestNamedDeleterWithIdentifier>(globalObject, WTFMove(impl));
317 }
318
319 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestNamedDeleterWithIdentifier& impl)
320 {
321     return wrap(state, globalObject, impl);
322 }
323
324 TestNamedDeleterWithIdentifier* JSTestNamedDeleterWithIdentifier::toWrapped(JSC::VM& vm, JSC::JSValue value)
325 {
326     if (auto* wrapper = jsDynamicCast<JSTestNamedDeleterWithIdentifier*>(vm, value))
327         return &wrapper->wrapped();
328     return nullptr;
329 }
330
331 }