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
23#if ENABLE(USER_MESSAGE_HANDLERS)
24
25#include "JSUserMessageHandlersNamespace.h"
26
27#include "JSDOMAbstractOperations.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructorNotConstructable.h"
30#include "JSDOMConvertInterface.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMGlobalObject.h"
33#include "JSDOMWrapperCache.h"
34#include "JSUserMessageHandler.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/FunctionPrototype.h>
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43
44namespace WebCore {
45using namespace JSC;
46
47// Attributes
48
49JSC::EncodedJSValue jsUserMessageHandlersNamespaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSUserMessageHandlersNamespaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51
52class JSUserMessageHandlersNamespacePrototype : public JSC::JSNonFinalObject {
53public:
54 using Base = JSC::JSNonFinalObject;
55 static JSUserMessageHandlersNamespacePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
56 {
57 JSUserMessageHandlersNamespacePrototype* ptr = new (NotNull, JSC::allocateCell<JSUserMessageHandlersNamespacePrototype>(vm.heap)) JSUserMessageHandlersNamespacePrototype(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
68private:
69 JSUserMessageHandlersNamespacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
70 : JSC::JSNonFinalObject(vm, structure)
71 {
72 }
73
74 void finishCreation(JSC::VM&);
75};
76
77using JSUserMessageHandlersNamespaceConstructor = JSDOMConstructorNotConstructable<JSUserMessageHandlersNamespace>;
78
79template<> JSValue JSUserMessageHandlersNamespaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
80{
81 UNUSED_PARAM(vm);
82 return globalObject.functionPrototype();
83}
84
85template<> void JSUserMessageHandlersNamespaceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
86{
87 putDirect(vm, vm.propertyNames->prototype, JSUserMessageHandlersNamespace::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("UserMessageHandlersNamespace"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90}
91
92template<> const ClassInfo JSUserMessageHandlersNamespaceConstructor::s_info = { "UserMessageHandlersNamespace", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSUserMessageHandlersNamespaceConstructor) };
93
94/* Hash table for prototype */
95
96static const HashTableValue JSUserMessageHandlersNamespacePrototypeTableValues[] =
97{
98 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsUserMessageHandlersNamespaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSUserMessageHandlersNamespaceConstructor) } },
99};
100
101const ClassInfo JSUserMessageHandlersNamespacePrototype::s_info = { "UserMessageHandlersNamespacePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSUserMessageHandlersNamespacePrototype) };
102
103void JSUserMessageHandlersNamespacePrototype::finishCreation(VM& vm)
104{
105 Base::finishCreation(vm);
106 reifyStaticProperties(vm, JSUserMessageHandlersNamespace::info(), JSUserMessageHandlersNamespacePrototypeTableValues, *this);
107}
108
109const ClassInfo JSUserMessageHandlersNamespace::s_info = { "UserMessageHandlersNamespace", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSUserMessageHandlersNamespace) };
110
111JSUserMessageHandlersNamespace::JSUserMessageHandlersNamespace(Structure* structure, JSDOMGlobalObject& globalObject, Ref<UserMessageHandlersNamespace>&& impl)
112 : JSDOMWrapper<UserMessageHandlersNamespace>(structure, globalObject, WTFMove(impl))
113{
114}
115
116void JSUserMessageHandlersNamespace::finishCreation(VM& vm)
117{
118 Base::finishCreation(vm);
119 ASSERT(inherits(vm, info()));
120
121}
122
123JSObject* JSUserMessageHandlersNamespace::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
124{
125 return JSUserMessageHandlersNamespacePrototype::create(vm, &globalObject, JSUserMessageHandlersNamespacePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
126}
127
128JSObject* JSUserMessageHandlersNamespace::prototype(VM& vm, JSDOMGlobalObject& globalObject)
129{
130 return getDOMPrototype<JSUserMessageHandlersNamespace>(vm, globalObject);
131}
132
133JSValue JSUserMessageHandlersNamespace::getConstructor(VM& vm, const JSGlobalObject* globalObject)
134{
135 return getDOMConstructor<JSUserMessageHandlersNamespaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
136}
137
138void JSUserMessageHandlersNamespace::destroy(JSC::JSCell* cell)
139{
140 JSUserMessageHandlersNamespace* thisObject = static_cast<JSUserMessageHandlersNamespace*>(cell);
141 thisObject->JSUserMessageHandlersNamespace::~JSUserMessageHandlersNamespace();
142}
143
144bool JSUserMessageHandlersNamespace::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
145{
146 auto* thisObject = jsCast<JSUserMessageHandlersNamespace*>(object);
147 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
148 using GetterIDLType = IDLInterface<UserMessageHandler>;
149 auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
150 auto result = thisObject.wrapped().namedItem(worldForDOMObject(thisObject), propertyNameToAtomicString(propertyName));
151 if (!GetterIDLType::isNullValue(result))
152 return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
153 return WTF::nullopt;
154 };
155 if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
156 auto value = toJS<IDLInterface<UserMessageHandler>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value()));
157 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
158 return true;
159 }
160 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
161}
162
163bool JSUserMessageHandlersNamespace::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
164{
165 auto* thisObject = jsCast<JSUserMessageHandlersNamespace*>(object);
166 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
167 auto propertyName = Identifier::from(state, index);
168 using GetterIDLType = IDLInterface<UserMessageHandler>;
169 auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
170 auto result = thisObject.wrapped().namedItem(worldForDOMObject(thisObject), propertyNameToAtomicString(propertyName));
171 if (!GetterIDLType::isNullValue(result))
172 return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
173 return WTF::nullopt;
174 };
175 if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
176 auto value = toJS<IDLInterface<UserMessageHandler>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value()));
177 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
178 return true;
179 }
180 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
181}
182
183void JSUserMessageHandlersNamespace::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
184{
185 auto* thisObject = jsCast<JSUserMessageHandlersNamespace*>(object);
186 ASSERT_GC_OBJECT_INHERITS(object, info());
187 for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())
188 propertyNames.add(Identifier::fromString(state, propertyName));
189 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
190}
191
192EncodedJSValue jsUserMessageHandlersNamespaceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
193{
194 VM& vm = state->vm();
195 auto throwScope = DECLARE_THROW_SCOPE(vm);
196 auto* prototype = jsDynamicCast<JSUserMessageHandlersNamespacePrototype*>(vm, JSValue::decode(thisValue));
197 if (UNLIKELY(!prototype))
198 return throwVMTypeError(state, throwScope);
199 return JSValue::encode(JSUserMessageHandlersNamespace::getConstructor(state->vm(), prototype->globalObject()));
200}
201
202bool setJSUserMessageHandlersNamespaceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
203{
204 VM& vm = state->vm();
205 auto throwScope = DECLARE_THROW_SCOPE(vm);
206 auto* prototype = jsDynamicCast<JSUserMessageHandlersNamespacePrototype*>(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
215void JSUserMessageHandlersNamespace::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
216{
217 auto* thisObject = jsCast<JSUserMessageHandlersNamespace*>(cell);
218 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
219 if (thisObject->scriptExecutionContext())
220 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
221 Base::heapSnapshot(cell, builder);
222}
223
224bool JSUserMessageHandlersNamespaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
225{
226 UNUSED_PARAM(handle);
227 UNUSED_PARAM(visitor);
228 UNUSED_PARAM(reason);
229 return false;
230}
231
232void JSUserMessageHandlersNamespaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
233{
234 auto* jsUserMessageHandlersNamespace = static_cast<JSUserMessageHandlersNamespace*>(handle.slot()->asCell());
235 auto& world = *static_cast<DOMWrapperWorld*>(context);
236 uncacheWrapper(world, &jsUserMessageHandlersNamespace->wrapped(), jsUserMessageHandlersNamespace);
237}
238
239#if ENABLE(BINDING_INTEGRITY)
240#if PLATFORM(WIN)
241#pragma warning(disable: 4483)
242extern "C" { extern void (*const __identifier("??_7UserMessageHandlersNamespace@WebCore@@6B@")[])(); }
243#else
244extern "C" { extern void* _ZTVN7WebCore28UserMessageHandlersNamespaceE[]; }
245#endif
246#endif
247
248JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<UserMessageHandlersNamespace>&& impl)
249{
250
251#if ENABLE(BINDING_INTEGRITY)
252 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
253#if PLATFORM(WIN)
254 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7UserMessageHandlersNamespace@WebCore@@6B@"));
255#else
256 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore28UserMessageHandlersNamespaceE[2]);
257#endif
258
259 // If this fails UserMessageHandlersNamespace does not have a vtable, so you need to add the
260 // ImplementationLacksVTable attribute to the interface definition
261 static_assert(std::is_polymorphic<UserMessageHandlersNamespace>::value, "UserMessageHandlersNamespace is not polymorphic");
262
263 // If you hit this assertion you either have a use after free bug, or
264 // UserMessageHandlersNamespace has subclasses. If UserMessageHandlersNamespace has subclasses that get passed
265 // to toJS() we currently require UserMessageHandlersNamespace you to opt out of binding hardening
266 // by adding the SkipVTableValidation attribute to the interface IDL definition
267 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
268#endif
269 return createWrapper<UserMessageHandlersNamespace>(globalObject, WTFMove(impl));
270}
271
272JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, UserMessageHandlersNamespace& impl)
273{
274 return wrap(state, globalObject, impl);
275}
276
277UserMessageHandlersNamespace* JSUserMessageHandlersNamespace::toWrapped(JSC::VM& vm, JSC::JSValue value)
278{
279 if (auto* wrapper = jsDynamicCast<JSUserMessageHandlersNamespace*>(vm, value))
280 return &wrapper->wrapped();
281 return nullptr;
282}
283
284}
285
286#endif // ENABLE(USER_MESSAGE_HANDLERS)
287