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 "JSDeprecatedCSSOMValueList.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMConvertNumbers.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMGlobalObject.h" |
31 | #include "JSDOMOperation.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include <JavaScriptCore/ArrayPrototype.h> |
35 | #include <JavaScriptCore/BuiltinNames.h> |
36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
37 | #include <JavaScriptCore/JSCInlines.h> |
38 | #include <JavaScriptCore/PropertyNameArray.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 | // Functions |
48 | |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsDeprecatedCSSOMValueListPrototypeFunctionItem(JSC::ExecState*); |
50 | |
51 | // Attributes |
52 | |
53 | JSC::EncodedJSValue jsDeprecatedCSSOMValueListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSDeprecatedCSSOMValueListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsDeprecatedCSSOMValueListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | |
57 | class JSDeprecatedCSSOMValueListPrototype : public JSC::JSNonFinalObject { |
58 | public: |
59 | using Base = JSC::JSNonFinalObject; |
60 | static JSDeprecatedCSSOMValueListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
61 | { |
62 | JSDeprecatedCSSOMValueListPrototype* ptr = new (NotNull, JSC::allocateCell<JSDeprecatedCSSOMValueListPrototype>(vm.heap)) JSDeprecatedCSSOMValueListPrototype(vm, globalObject, structure); |
63 | ptr->finishCreation(vm); |
64 | return ptr; |
65 | } |
66 | |
67 | DECLARE_INFO; |
68 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
69 | { |
70 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
71 | } |
72 | |
73 | private: |
74 | JSDeprecatedCSSOMValueListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
75 | : JSC::JSNonFinalObject(vm, structure) |
76 | { |
77 | } |
78 | |
79 | void finishCreation(JSC::VM&); |
80 | }; |
81 | |
82 | using JSDeprecatedCSSOMValueListConstructor = JSDOMConstructorNotConstructable<JSDeprecatedCSSOMValueList>; |
83 | |
84 | template<> JSValue JSDeprecatedCSSOMValueListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
85 | { |
86 | return JSDeprecatedCSSOMValue::getConstructor(vm, &globalObject); |
87 | } |
88 | |
89 | template<> void JSDeprecatedCSSOMValueListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
90 | { |
91 | putDirect(vm, vm.propertyNames->prototype, JSDeprecatedCSSOMValueList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
92 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSValueList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
93 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
94 | } |
95 | |
96 | template<> const ClassInfo JSDeprecatedCSSOMValueListConstructor::s_info = { "CSSValueList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDeprecatedCSSOMValueListConstructor) }; |
97 | |
98 | /* Hash table for prototype */ |
99 | |
100 | static const HashTableValue JSDeprecatedCSSOMValueListPrototypeTableValues[] = |
101 | { |
102 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeprecatedCSSOMValueListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDeprecatedCSSOMValueListConstructor) } }, |
103 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeprecatedCSSOMValueListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
104 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDeprecatedCSSOMValueListPrototypeFunctionItem), (intptr_t) (1) } }, |
105 | }; |
106 | |
107 | const ClassInfo JSDeprecatedCSSOMValueListPrototype::s_info = { "CSSValueListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDeprecatedCSSOMValueListPrototype) }; |
108 | |
109 | void JSDeprecatedCSSOMValueListPrototype::finishCreation(VM& vm) |
110 | { |
111 | Base::finishCreation(vm); |
112 | reifyStaticProperties(vm, JSDeprecatedCSSOMValueList::info(), JSDeprecatedCSSOMValueListPrototypeTableValues, *this); |
113 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
114 | } |
115 | |
116 | const ClassInfo JSDeprecatedCSSOMValueList::s_info = { "CSSValueList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDeprecatedCSSOMValueList) }; |
117 | |
118 | JSDeprecatedCSSOMValueList::JSDeprecatedCSSOMValueList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DeprecatedCSSOMValueList>&& impl) |
119 | : JSDeprecatedCSSOMValue(structure, globalObject, WTFMove(impl)) |
120 | { |
121 | } |
122 | |
123 | void JSDeprecatedCSSOMValueList::finishCreation(VM& vm) |
124 | { |
125 | Base::finishCreation(vm); |
126 | ASSERT(inherits(vm, info())); |
127 | |
128 | } |
129 | |
130 | JSObject* JSDeprecatedCSSOMValueList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
131 | { |
132 | return JSDeprecatedCSSOMValueListPrototype::create(vm, &globalObject, JSDeprecatedCSSOMValueListPrototype::createStructure(vm, &globalObject, JSDeprecatedCSSOMValue::prototype(vm, globalObject))); |
133 | } |
134 | |
135 | JSObject* JSDeprecatedCSSOMValueList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return getDOMPrototype<JSDeprecatedCSSOMValueList>(vm, globalObject); |
138 | } |
139 | |
140 | JSValue JSDeprecatedCSSOMValueList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
141 | { |
142 | return getDOMConstructor<JSDeprecatedCSSOMValueListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
143 | } |
144 | |
145 | bool JSDeprecatedCSSOMValueList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
146 | { |
147 | auto* thisObject = jsCast<JSDeprecatedCSSOMValueList*>(object); |
148 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
149 | if (auto index = parseIndex(propertyName)) { |
150 | if (index.value() < thisObject->wrapped().length()) { |
151 | auto value = toJS<IDLInterface<DeprecatedCSSOMValue>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
152 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
153 | return true; |
154 | } |
155 | } |
156 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
157 | } |
158 | |
159 | bool JSDeprecatedCSSOMValueList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
160 | { |
161 | auto* thisObject = jsCast<JSDeprecatedCSSOMValueList*>(object); |
162 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
163 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
164 | if (index < thisObject->wrapped().length()) { |
165 | auto value = toJS<IDLInterface<DeprecatedCSSOMValue>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
166 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
167 | return true; |
168 | } |
169 | } |
170 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
171 | } |
172 | |
173 | void JSDeprecatedCSSOMValueList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
174 | { |
175 | auto* thisObject = jsCast<JSDeprecatedCSSOMValueList*>(object); |
176 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
177 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
178 | propertyNames.add(Identifier::from(state, i)); |
179 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
180 | } |
181 | |
182 | template<> inline JSDeprecatedCSSOMValueList* IDLAttribute<JSDeprecatedCSSOMValueList>::cast(ExecState& state, EncodedJSValue thisValue) |
183 | { |
184 | return jsDynamicCast<JSDeprecatedCSSOMValueList*>(state.vm(), JSValue::decode(thisValue)); |
185 | } |
186 | |
187 | template<> inline JSDeprecatedCSSOMValueList* IDLOperation<JSDeprecatedCSSOMValueList>::cast(ExecState& state) |
188 | { |
189 | return jsDynamicCast<JSDeprecatedCSSOMValueList*>(state.vm(), state.thisValue()); |
190 | } |
191 | |
192 | EncodedJSValue jsDeprecatedCSSOMValueListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
193 | { |
194 | VM& vm = state->vm(); |
195 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
196 | auto* prototype = jsDynamicCast<JSDeprecatedCSSOMValueListPrototype*>(vm, JSValue::decode(thisValue)); |
197 | if (UNLIKELY(!prototype)) |
198 | return throwVMTypeError(state, throwScope); |
199 | return JSValue::encode(JSDeprecatedCSSOMValueList::getConstructor(state->vm(), prototype->globalObject())); |
200 | } |
201 | |
202 | bool setJSDeprecatedCSSOMValueListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
203 | { |
204 | VM& vm = state->vm(); |
205 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
206 | auto* prototype = jsDynamicCast<JSDeprecatedCSSOMValueListPrototype*>(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 | |
215 | static inline JSValue jsDeprecatedCSSOMValueListLengthGetter(ExecState& state, JSDeprecatedCSSOMValueList& thisObject, ThrowScope& throwScope) |
216 | { |
217 | UNUSED_PARAM(throwScope); |
218 | UNUSED_PARAM(state); |
219 | auto& impl = thisObject.wrapped(); |
220 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
221 | return result; |
222 | } |
223 | |
224 | EncodedJSValue jsDeprecatedCSSOMValueListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
225 | { |
226 | return IDLAttribute<JSDeprecatedCSSOMValueList>::get<jsDeprecatedCSSOMValueListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
227 | } |
228 | |
229 | static inline JSC::EncodedJSValue jsDeprecatedCSSOMValueListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSDeprecatedCSSOMValueList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
230 | { |
231 | UNUSED_PARAM(state); |
232 | UNUSED_PARAM(throwScope); |
233 | auto& impl = castedThis->wrapped(); |
234 | if (UNLIKELY(state->argumentCount() < 1)) |
235 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
236 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
237 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
238 | return JSValue::encode(toJS<IDLInterface<DeprecatedCSSOMValue>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index)))); |
239 | } |
240 | |
241 | EncodedJSValue JSC_HOST_CALL jsDeprecatedCSSOMValueListPrototypeFunctionItem(ExecState* state) |
242 | { |
243 | return IDLOperation<JSDeprecatedCSSOMValueList>::call<jsDeprecatedCSSOMValueListPrototypeFunctionItemBody>(*state, "item" ); |
244 | } |
245 | |
246 | void JSDeprecatedCSSOMValueList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
247 | { |
248 | auto* thisObject = jsCast<JSDeprecatedCSSOMValueList*>(cell); |
249 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
250 | if (thisObject->scriptExecutionContext()) |
251 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
252 | Base::heapSnapshot(cell, builder); |
253 | } |
254 | |
255 | |
256 | } |
257 | |