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 "JSComment.h" |
23 | |
24 | #include "Document.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructor.h" |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMConvertStrings.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMWrapperCache.h" |
31 | #include "ScriptExecutionContext.h" |
32 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
33 | #include <JavaScriptCore/JSCInlines.h> |
34 | #include <wtf/GetPtr.h> |
35 | #include <wtf/PointerPreparations.h> |
36 | #include <wtf/URL.h> |
37 | |
38 | |
39 | namespace WebCore { |
40 | using namespace JSC; |
41 | |
42 | // Attributes |
43 | |
44 | JSC::EncodedJSValue jsCommentConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
45 | bool setJSCommentConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
46 | |
47 | class : public JSC::JSNonFinalObject { |
48 | public: |
49 | using = JSC::JSNonFinalObject; |
50 | static JSCommentPrototype* (JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
51 | { |
52 | JSCommentPrototype* ptr = new (NotNull, JSC::allocateCell<JSCommentPrototype>(vm.heap)) JSCommentPrototype(vm, globalObject, structure); |
53 | ptr->finishCreation(vm); |
54 | return ptr; |
55 | } |
56 | |
57 | DECLARE_INFO; |
58 | static JSC::Structure* (JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
59 | { |
60 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
61 | } |
62 | |
63 | private: |
64 | (JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
65 | : JSC::JSNonFinalObject(vm, structure) |
66 | { |
67 | } |
68 | |
69 | void finishCreation(JSC::VM&); |
70 | }; |
71 | |
72 | using = JSDOMConstructor<JSComment>; |
73 | |
74 | template<> EncodedJSValue JSC_HOST_CALL JSCommentConstructor::construct(ExecState* state) |
75 | { |
76 | VM& vm = state->vm(); |
77 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
78 | UNUSED_PARAM(throwScope); |
79 | auto* castedThis = jsCast<JSCommentConstructor*>(state->jsCallee()); |
80 | ASSERT(castedThis); |
81 | auto* context = castedThis->scriptExecutionContext(); |
82 | if (UNLIKELY(!context)) |
83 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "Comment" ); |
84 | ASSERT(context->isDocument()); |
85 | auto& document = downcast<Document>(*context); |
86 | auto data = state->argument(0).isUndefined() ? emptyString() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
87 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
88 | auto object = Comment::create(document, WTFMove(data)); |
89 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Comment>>(*state, *castedThis->globalObject(), WTFMove(object))); |
90 | } |
91 | |
92 | template<> JSValue JSCommentConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
93 | { |
94 | return JSCharacterData::getConstructor(vm, &globalObject); |
95 | } |
96 | |
97 | template<> void JSCommentConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
98 | { |
99 | putDirect(vm, vm.propertyNames->prototype, JSComment::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
100 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Comment"_s )), 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 JSCommentConstructor::s_info = { "Comment" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommentConstructor) }; |
105 | |
106 | /* Hash table for prototype */ |
107 | |
108 | static const HashTableValue [] = |
109 | { |
110 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCommentConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCommentConstructor) } }, |
111 | }; |
112 | |
113 | const ClassInfo JSCommentPrototype:: = { "CommentPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommentPrototype) }; |
114 | |
115 | void JSCommentPrototype::(VM& vm) |
116 | { |
117 | Base::finishCreation(vm); |
118 | reifyStaticProperties(vm, JSComment::info(), JSCommentPrototypeTableValues, *this); |
119 | } |
120 | |
121 | const ClassInfo JSComment:: = { "Comment" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSComment) }; |
122 | |
123 | JSComment::(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Comment>&& impl) |
124 | : JSCharacterData(structure, globalObject, WTFMove(impl)) |
125 | { |
126 | } |
127 | |
128 | void JSComment::(VM& vm) |
129 | { |
130 | Base::finishCreation(vm); |
131 | ASSERT(inherits(vm, info())); |
132 | |
133 | } |
134 | |
135 | JSObject* JSComment::(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return JSCommentPrototype::create(vm, &globalObject, JSCommentPrototype::createStructure(vm, &globalObject, JSCharacterData::prototype(vm, globalObject))); |
138 | } |
139 | |
140 | JSObject* JSComment::(VM& vm, JSDOMGlobalObject& globalObject) |
141 | { |
142 | return getDOMPrototype<JSComment>(vm, globalObject); |
143 | } |
144 | |
145 | JSValue JSComment::(VM& vm, const JSGlobalObject* globalObject) |
146 | { |
147 | return getDOMConstructor<JSCommentConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
148 | } |
149 | |
150 | EncodedJSValue (ExecState* state, EncodedJSValue thisValue, PropertyName) |
151 | { |
152 | VM& vm = state->vm(); |
153 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
154 | auto* prototype = jsDynamicCast<JSCommentPrototype*>(vm, JSValue::decode(thisValue)); |
155 | if (UNLIKELY(!prototype)) |
156 | return throwVMTypeError(state, throwScope); |
157 | return JSValue::encode(JSComment::getConstructor(state->vm(), prototype->globalObject())); |
158 | } |
159 | |
160 | bool (ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
161 | { |
162 | VM& vm = state->vm(); |
163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
164 | auto* prototype = jsDynamicCast<JSCommentPrototype*>(vm, JSValue::decode(thisValue)); |
165 | if (UNLIKELY(!prototype)) { |
166 | throwVMTypeError(state, throwScope); |
167 | return false; |
168 | } |
169 | // Shadowing a built-in constructor |
170 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
171 | } |
172 | |
173 | void JSComment::(JSCell* cell, HeapSnapshotBuilder& builder) |
174 | { |
175 | auto* thisObject = jsCast<JSComment*>(cell); |
176 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
177 | if (thisObject->scriptExecutionContext()) |
178 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
179 | Base::heapSnapshot(cell, builder); |
180 | } |
181 | |
182 | #if ENABLE(BINDING_INTEGRITY) |
183 | #if PLATFORM(WIN) |
184 | #pragma warning(disable: 4483) |
185 | extern "C" { extern void (*const __identifier("??_7Comment@WebCore@@6B@" )[])(); } |
186 | #else |
187 | extern "C" { extern void* []; } |
188 | #endif |
189 | #endif |
190 | |
191 | JSC::JSValue (JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Comment>&& impl) |
192 | { |
193 | |
194 | #if ENABLE(BINDING_INTEGRITY) |
195 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
196 | #if PLATFORM(WIN) |
197 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7Comment@WebCore@@6B@" )); |
198 | #else |
199 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore7CommentE[2]); |
200 | #endif |
201 | |
202 | // If this fails Comment does not have a vtable, so you need to add the |
203 | // ImplementationLacksVTable attribute to the interface definition |
204 | static_assert(std::is_polymorphic<Comment>::value, "Comment is not polymorphic" ); |
205 | |
206 | // If you hit this assertion you either have a use after free bug, or |
207 | // Comment has subclasses. If Comment has subclasses that get passed |
208 | // to toJS() we currently require Comment you to opt out of binding hardening |
209 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
210 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
211 | #endif |
212 | return createWrapper<Comment>(globalObject, WTFMove(impl)); |
213 | } |
214 | |
215 | JSC::JSValue (JSC::ExecState* state, JSDOMGlobalObject* globalObject, Comment& impl) |
216 | { |
217 | return wrap(state, globalObject, impl); |
218 | } |
219 | |
220 | |
221 | } |
222 | |