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 "JSStaticRange.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNumbers.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMGlobalObject.h"
32#include "JSDOMWrapperCache.h"
33#include "JSNode.h"
34#include "ScriptExecutionContext.h"
35#include <JavaScriptCore/FunctionPrototype.h>
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <wtf/GetPtr.h>
39#include <wtf/PointerPreparations.h>
40#include <wtf/URL.h>
41
42
43namespace WebCore {
44using namespace JSC;
45
46// Attributes
47
48JSC::EncodedJSValue jsStaticRangeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49bool setJSStaticRangeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50JSC::EncodedJSValue jsStaticRangeStartOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsStaticRangeEndOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsStaticRangeStartContainer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsStaticRangeEndContainer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54JSC::EncodedJSValue jsStaticRangeCollapsed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55
56class JSStaticRangePrototype : public JSC::JSNonFinalObject {
57public:
58 using Base = JSC::JSNonFinalObject;
59 static JSStaticRangePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
60 {
61 JSStaticRangePrototype* ptr = new (NotNull, JSC::allocateCell<JSStaticRangePrototype>(vm.heap)) JSStaticRangePrototype(vm, globalObject, structure);
62 ptr->finishCreation(vm);
63 return ptr;
64 }
65
66 DECLARE_INFO;
67 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
68 {
69 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
70 }
71
72private:
73 JSStaticRangePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
74 : JSC::JSNonFinalObject(vm, structure)
75 {
76 }
77
78 void finishCreation(JSC::VM&);
79};
80
81using JSStaticRangeConstructor = JSDOMConstructorNotConstructable<JSStaticRange>;
82
83template<> JSValue JSStaticRangeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
84{
85 UNUSED_PARAM(vm);
86 return globalObject.functionPrototype();
87}
88
89template<> void JSStaticRangeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
90{
91 putDirect(vm, vm.propertyNames->prototype, JSStaticRange::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("StaticRange"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94}
95
96template<> const ClassInfo JSStaticRangeConstructor::s_info = { "StaticRange", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStaticRangeConstructor) };
97
98/* Hash table for prototype */
99
100static const HashTableValue JSStaticRangePrototypeTableValues[] =
101{
102 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSStaticRangeConstructor) } },
103 { "startOffset", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeStartOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
104 { "endOffset", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeEndOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
105 { "startContainer", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeStartContainer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
106 { "endContainer", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeEndContainer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
107 { "collapsed", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStaticRangeCollapsed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
108};
109
110const ClassInfo JSStaticRangePrototype::s_info = { "StaticRangePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStaticRangePrototype) };
111
112void JSStaticRangePrototype::finishCreation(VM& vm)
113{
114 Base::finishCreation(vm);
115 reifyStaticProperties(vm, JSStaticRange::info(), JSStaticRangePrototypeTableValues, *this);
116}
117
118const ClassInfo JSStaticRange::s_info = { "StaticRange", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStaticRange) };
119
120JSStaticRange::JSStaticRange(Structure* structure, JSDOMGlobalObject& globalObject, Ref<StaticRange>&& impl)
121 : JSDOMWrapper<StaticRange>(structure, globalObject, WTFMove(impl))
122{
123}
124
125void JSStaticRange::finishCreation(VM& vm)
126{
127 Base::finishCreation(vm);
128 ASSERT(inherits(vm, info()));
129
130}
131
132JSObject* JSStaticRange::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
133{
134 return JSStaticRangePrototype::create(vm, &globalObject, JSStaticRangePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
135}
136
137JSObject* JSStaticRange::prototype(VM& vm, JSDOMGlobalObject& globalObject)
138{
139 return getDOMPrototype<JSStaticRange>(vm, globalObject);
140}
141
142JSValue JSStaticRange::getConstructor(VM& vm, const JSGlobalObject* globalObject)
143{
144 return getDOMConstructor<JSStaticRangeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
145}
146
147void JSStaticRange::destroy(JSC::JSCell* cell)
148{
149 JSStaticRange* thisObject = static_cast<JSStaticRange*>(cell);
150 thisObject->JSStaticRange::~JSStaticRange();
151}
152
153template<> inline JSStaticRange* IDLAttribute<JSStaticRange>::cast(ExecState& state, EncodedJSValue thisValue)
154{
155 return jsDynamicCast<JSStaticRange*>(state.vm(), JSValue::decode(thisValue));
156}
157
158EncodedJSValue jsStaticRangeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
159{
160 VM& vm = state->vm();
161 auto throwScope = DECLARE_THROW_SCOPE(vm);
162 auto* prototype = jsDynamicCast<JSStaticRangePrototype*>(vm, JSValue::decode(thisValue));
163 if (UNLIKELY(!prototype))
164 return throwVMTypeError(state, throwScope);
165 return JSValue::encode(JSStaticRange::getConstructor(state->vm(), prototype->globalObject()));
166}
167
168bool setJSStaticRangeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
169{
170 VM& vm = state->vm();
171 auto throwScope = DECLARE_THROW_SCOPE(vm);
172 auto* prototype = jsDynamicCast<JSStaticRangePrototype*>(vm, JSValue::decode(thisValue));
173 if (UNLIKELY(!prototype)) {
174 throwVMTypeError(state, throwScope);
175 return false;
176 }
177 // Shadowing a built-in constructor
178 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
179}
180
181static inline JSValue jsStaticRangeStartOffsetGetter(ExecState& state, JSStaticRange& thisObject, ThrowScope& throwScope)
182{
183 UNUSED_PARAM(throwScope);
184 UNUSED_PARAM(state);
185 auto& impl = thisObject.wrapped();
186 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.startOffset());
187 return result;
188}
189
190EncodedJSValue jsStaticRangeStartOffset(ExecState* state, EncodedJSValue thisValue, PropertyName)
191{
192 return IDLAttribute<JSStaticRange>::get<jsStaticRangeStartOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startOffset");
193}
194
195static inline JSValue jsStaticRangeEndOffsetGetter(ExecState& state, JSStaticRange& thisObject, ThrowScope& throwScope)
196{
197 UNUSED_PARAM(throwScope);
198 UNUSED_PARAM(state);
199 auto& impl = thisObject.wrapped();
200 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.endOffset());
201 return result;
202}
203
204EncodedJSValue jsStaticRangeEndOffset(ExecState* state, EncodedJSValue thisValue, PropertyName)
205{
206 return IDLAttribute<JSStaticRange>::get<jsStaticRangeEndOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "endOffset");
207}
208
209static inline JSValue jsStaticRangeStartContainerGetter(ExecState& state, JSStaticRange& thisObject, ThrowScope& throwScope)
210{
211 UNUSED_PARAM(throwScope);
212 UNUSED_PARAM(state);
213 auto& impl = thisObject.wrapped();
214 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.startContainer());
215 return result;
216}
217
218EncodedJSValue jsStaticRangeStartContainer(ExecState* state, EncodedJSValue thisValue, PropertyName)
219{
220 return IDLAttribute<JSStaticRange>::get<jsStaticRangeStartContainerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startContainer");
221}
222
223static inline JSValue jsStaticRangeEndContainerGetter(ExecState& state, JSStaticRange& thisObject, ThrowScope& throwScope)
224{
225 UNUSED_PARAM(throwScope);
226 UNUSED_PARAM(state);
227 auto& impl = thisObject.wrapped();
228 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.endContainer());
229 return result;
230}
231
232EncodedJSValue jsStaticRangeEndContainer(ExecState* state, EncodedJSValue thisValue, PropertyName)
233{
234 return IDLAttribute<JSStaticRange>::get<jsStaticRangeEndContainerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "endContainer");
235}
236
237static inline JSValue jsStaticRangeCollapsedGetter(ExecState& state, JSStaticRange& thisObject, ThrowScope& throwScope)
238{
239 UNUSED_PARAM(throwScope);
240 UNUSED_PARAM(state);
241 auto& impl = thisObject.wrapped();
242 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.collapsed());
243 return result;
244}
245
246EncodedJSValue jsStaticRangeCollapsed(ExecState* state, EncodedJSValue thisValue, PropertyName)
247{
248 return IDLAttribute<JSStaticRange>::get<jsStaticRangeCollapsedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "collapsed");
249}
250
251void JSStaticRange::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
252{
253 auto* thisObject = jsCast<JSStaticRange*>(cell);
254 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
255 if (thisObject->scriptExecutionContext())
256 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
257 Base::heapSnapshot(cell, builder);
258}
259
260bool JSStaticRangeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
261{
262 UNUSED_PARAM(handle);
263 UNUSED_PARAM(visitor);
264 UNUSED_PARAM(reason);
265 return false;
266}
267
268void JSStaticRangeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
269{
270 auto* jsStaticRange = static_cast<JSStaticRange*>(handle.slot()->asCell());
271 auto& world = *static_cast<DOMWrapperWorld*>(context);
272 uncacheWrapper(world, &jsStaticRange->wrapped(), jsStaticRange);
273}
274
275JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<StaticRange>&& impl)
276{
277 // If you hit this failure the interface definition has the ImplementationLacksVTable
278 // attribute. You should remove that attribute. If the class has subclasses
279 // that may be passed through this toJS() function you should use the SkipVTableValidation
280 // attribute to StaticRange.
281 static_assert(!std::is_polymorphic<StaticRange>::value, "StaticRange is polymorphic but the IDL claims it is not");
282 return createWrapper<StaticRange>(globalObject, WTFMove(impl));
283}
284
285JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, StaticRange& impl)
286{
287 return wrap(state, globalObject, impl);
288}
289
290StaticRange* JSStaticRange::toWrapped(JSC::VM& vm, JSC::JSValue value)
291{
292 if (auto* wrapper = jsDynamicCast<JSStaticRange*>(vm, value))
293 return &wrapper->wrapped();
294 return nullptr;
295}
296
297}
298