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