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 "JSProcessingInstruction.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMConvertNullable.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMGlobalObject.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "JSStyleSheet.h" |
34 | #include "ScriptExecutionContext.h" |
35 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
36 | #include <JavaScriptCore/JSCInlines.h> |
37 | #include <wtf/GetPtr.h> |
38 | #include <wtf/PointerPreparations.h> |
39 | #include <wtf/URL.h> |
40 | |
41 | |
42 | namespace WebCore { |
43 | using namespace JSC; |
44 | |
45 | // Attributes |
46 | |
47 | JSC::EncodedJSValue jsProcessingInstructionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | bool setJSProcessingInstructionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
49 | JSC::EncodedJSValue jsProcessingInstructionTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | JSC::EncodedJSValue jsProcessingInstructionSheet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | |
52 | class JSProcessingInstructionPrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSProcessingInstructionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSProcessingInstructionPrototype* ptr = new (NotNull, JSC::allocateCell<JSProcessingInstructionPrototype>(vm.heap)) JSProcessingInstructionPrototype(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 | JSProcessingInstructionPrototype(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 JSProcessingInstructionConstructor = JSDOMConstructorNotConstructable<JSProcessingInstruction>; |
78 | |
79 | template<> JSValue JSProcessingInstructionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
80 | { |
81 | return JSCharacterData::getConstructor(vm, &globalObject); |
82 | } |
83 | |
84 | template<> void JSProcessingInstructionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
85 | { |
86 | putDirect(vm, vm.propertyNames->prototype, JSProcessingInstruction::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
87 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ProcessingInstruction"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
88 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
89 | } |
90 | |
91 | template<> const ClassInfo JSProcessingInstructionConstructor::s_info = { "ProcessingInstruction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSProcessingInstructionConstructor) }; |
92 | |
93 | /* Hash table for prototype */ |
94 | |
95 | static const HashTableValue JSProcessingInstructionPrototypeTableValues[] = |
96 | { |
97 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProcessingInstructionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSProcessingInstructionConstructor) } }, |
98 | { "target" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProcessingInstructionTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
99 | { "sheet" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProcessingInstructionSheet), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
100 | }; |
101 | |
102 | const ClassInfo JSProcessingInstructionPrototype::s_info = { "ProcessingInstructionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSProcessingInstructionPrototype) }; |
103 | |
104 | void JSProcessingInstructionPrototype::finishCreation(VM& vm) |
105 | { |
106 | Base::finishCreation(vm); |
107 | reifyStaticProperties(vm, JSProcessingInstruction::info(), JSProcessingInstructionPrototypeTableValues, *this); |
108 | } |
109 | |
110 | const ClassInfo JSProcessingInstruction::s_info = { "ProcessingInstruction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSProcessingInstruction) }; |
111 | |
112 | JSProcessingInstruction::JSProcessingInstruction(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ProcessingInstruction>&& impl) |
113 | : JSCharacterData(structure, globalObject, WTFMove(impl)) |
114 | { |
115 | } |
116 | |
117 | void JSProcessingInstruction::finishCreation(VM& vm) |
118 | { |
119 | Base::finishCreation(vm); |
120 | ASSERT(inherits(vm, info())); |
121 | |
122 | } |
123 | |
124 | JSObject* JSProcessingInstruction::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
125 | { |
126 | return JSProcessingInstructionPrototype::create(vm, &globalObject, JSProcessingInstructionPrototype::createStructure(vm, &globalObject, JSCharacterData::prototype(vm, globalObject))); |
127 | } |
128 | |
129 | JSObject* JSProcessingInstruction::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
130 | { |
131 | return getDOMPrototype<JSProcessingInstruction>(vm, globalObject); |
132 | } |
133 | |
134 | JSValue JSProcessingInstruction::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
135 | { |
136 | return getDOMConstructor<JSProcessingInstructionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
137 | } |
138 | |
139 | template<> inline JSProcessingInstruction* IDLAttribute<JSProcessingInstruction>::cast(ExecState& state, EncodedJSValue thisValue) |
140 | { |
141 | return jsDynamicCast<JSProcessingInstruction*>(state.vm(), JSValue::decode(thisValue)); |
142 | } |
143 | |
144 | EncodedJSValue jsProcessingInstructionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
145 | { |
146 | VM& vm = state->vm(); |
147 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
148 | auto* prototype = jsDynamicCast<JSProcessingInstructionPrototype*>(vm, JSValue::decode(thisValue)); |
149 | if (UNLIKELY(!prototype)) |
150 | return throwVMTypeError(state, throwScope); |
151 | return JSValue::encode(JSProcessingInstruction::getConstructor(state->vm(), prototype->globalObject())); |
152 | } |
153 | |
154 | bool setJSProcessingInstructionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
155 | { |
156 | VM& vm = state->vm(); |
157 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
158 | auto* prototype = jsDynamicCast<JSProcessingInstructionPrototype*>(vm, JSValue::decode(thisValue)); |
159 | if (UNLIKELY(!prototype)) { |
160 | throwVMTypeError(state, throwScope); |
161 | return false; |
162 | } |
163 | // Shadowing a built-in constructor |
164 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
165 | } |
166 | |
167 | static inline JSValue jsProcessingInstructionTargetGetter(ExecState& state, JSProcessingInstruction& thisObject, ThrowScope& throwScope) |
168 | { |
169 | UNUSED_PARAM(throwScope); |
170 | UNUSED_PARAM(state); |
171 | auto& impl = thisObject.wrapped(); |
172 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.target()); |
173 | return result; |
174 | } |
175 | |
176 | EncodedJSValue jsProcessingInstructionTarget(ExecState* state, EncodedJSValue thisValue, PropertyName) |
177 | { |
178 | return IDLAttribute<JSProcessingInstruction>::get<jsProcessingInstructionTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "target" ); |
179 | } |
180 | |
181 | static inline JSValue jsProcessingInstructionSheetGetter(ExecState& state, JSProcessingInstruction& thisObject, ThrowScope& throwScope) |
182 | { |
183 | UNUSED_PARAM(throwScope); |
184 | UNUSED_PARAM(state); |
185 | auto& impl = thisObject.wrapped(); |
186 | JSValue result = toJS<IDLNullable<IDLInterface<StyleSheet>>>(state, *thisObject.globalObject(), throwScope, impl.sheet()); |
187 | return result; |
188 | } |
189 | |
190 | EncodedJSValue jsProcessingInstructionSheet(ExecState* state, EncodedJSValue thisValue, PropertyName) |
191 | { |
192 | return IDLAttribute<JSProcessingInstruction>::get<jsProcessingInstructionSheetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sheet" ); |
193 | } |
194 | |
195 | void JSProcessingInstruction::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
196 | { |
197 | auto* thisObject = jsCast<JSProcessingInstruction*>(cell); |
198 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
199 | if (thisObject->scriptExecutionContext()) |
200 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
201 | Base::heapSnapshot(cell, builder); |
202 | } |
203 | |
204 | #if ENABLE(BINDING_INTEGRITY) |
205 | #if PLATFORM(WIN) |
206 | #pragma warning(disable: 4483) |
207 | extern "C" { extern void (*const __identifier("??_7ProcessingInstruction@WebCore@@6B@" )[])(); } |
208 | #else |
209 | extern "C" { extern void* _ZTVN7WebCore21ProcessingInstructionE[]; } |
210 | #endif |
211 | #endif |
212 | |
213 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ProcessingInstruction>&& impl) |
214 | { |
215 | |
216 | #if ENABLE(BINDING_INTEGRITY) |
217 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
218 | #if PLATFORM(WIN) |
219 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7ProcessingInstruction@WebCore@@6B@" )); |
220 | #else |
221 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore21ProcessingInstructionE[2]); |
222 | #endif |
223 | |
224 | // If this fails ProcessingInstruction does not have a vtable, so you need to add the |
225 | // ImplementationLacksVTable attribute to the interface definition |
226 | static_assert(std::is_polymorphic<ProcessingInstruction>::value, "ProcessingInstruction is not polymorphic" ); |
227 | |
228 | // If you hit this assertion you either have a use after free bug, or |
229 | // ProcessingInstruction has subclasses. If ProcessingInstruction has subclasses that get passed |
230 | // to toJS() we currently require ProcessingInstruction you to opt out of binding hardening |
231 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
232 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
233 | #endif |
234 | return createWrapper<ProcessingInstruction>(globalObject, WTFMove(impl)); |
235 | } |
236 | |
237 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ProcessingInstruction& impl) |
238 | { |
239 | return wrap(state, globalObject, impl); |
240 | } |
241 | |
242 | |
243 | } |
244 | |