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 "JSValidityState.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMExceptionHandling.h"
29#include "JSDOMWrapperCache.h"
30#include "ScriptExecutionContext.h"
31#include <JavaScriptCore/FunctionPrototype.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
39namespace WebCore {
40using namespace JSC;
41
42// Attributes
43
44JSC::EncodedJSValue jsValidityStateConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
45bool setJSValidityStateConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
46JSC::EncodedJSValue jsValidityStateValueMissing(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47JSC::EncodedJSValue jsValidityStateTypeMismatch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48JSC::EncodedJSValue jsValidityStatePatternMismatch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49JSC::EncodedJSValue jsValidityStateTooShort(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50JSC::EncodedJSValue jsValidityStateTooLong(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsValidityStateRangeUnderflow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsValidityStateRangeOverflow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsValidityStateStepMismatch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54JSC::EncodedJSValue jsValidityStateBadInput(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55JSC::EncodedJSValue jsValidityStateCustomError(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56JSC::EncodedJSValue jsValidityStateValid(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57
58class JSValidityStatePrototype : public JSC::JSNonFinalObject {
59public:
60 using Base = JSC::JSNonFinalObject;
61 static JSValidityStatePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
62 {
63 JSValidityStatePrototype* ptr = new (NotNull, JSC::allocateCell<JSValidityStatePrototype>(vm.heap)) JSValidityStatePrototype(vm, globalObject, structure);
64 ptr->finishCreation(vm);
65 return ptr;
66 }
67
68 DECLARE_INFO;
69 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
70 {
71 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
72 }
73
74private:
75 JSValidityStatePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
76 : JSC::JSNonFinalObject(vm, structure)
77 {
78 }
79
80 void finishCreation(JSC::VM&);
81};
82
83using JSValidityStateConstructor = JSDOMConstructorNotConstructable<JSValidityState>;
84
85template<> JSValue JSValidityStateConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
86{
87 UNUSED_PARAM(vm);
88 return globalObject.functionPrototype();
89}
90
91template<> void JSValidityStateConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
92{
93 putDirect(vm, vm.propertyNames->prototype, JSValidityState::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ValidityState"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
95 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96}
97
98template<> const ClassInfo JSValidityStateConstructor::s_info = { "ValidityState", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSValidityStateConstructor) };
99
100/* Hash table for prototype */
101
102static const HashTableValue JSValidityStatePrototypeTableValues[] =
103{
104 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSValidityStateConstructor) } },
105 { "valueMissing", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateValueMissing), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
106 { "typeMismatch", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateTypeMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
107 { "patternMismatch", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStatePatternMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
108 { "tooShort", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateTooShort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
109 { "tooLong", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateTooLong), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
110 { "rangeUnderflow", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateRangeUnderflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
111 { "rangeOverflow", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateRangeOverflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
112 { "stepMismatch", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateStepMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
113 { "badInput", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateBadInput), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
114 { "customError", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateCustomError), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
115 { "valid", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateValid), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
116};
117
118const ClassInfo JSValidityStatePrototype::s_info = { "ValidityStatePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSValidityStatePrototype) };
119
120void JSValidityStatePrototype::finishCreation(VM& vm)
121{
122 Base::finishCreation(vm);
123 reifyStaticProperties(vm, JSValidityState::info(), JSValidityStatePrototypeTableValues, *this);
124}
125
126const ClassInfo JSValidityState::s_info = { "ValidityState", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSValidityState) };
127
128JSValidityState::JSValidityState(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ValidityState>&& impl)
129 : JSDOMWrapper<ValidityState>(structure, globalObject, WTFMove(impl))
130{
131}
132
133void JSValidityState::finishCreation(VM& vm)
134{
135 Base::finishCreation(vm);
136 ASSERT(inherits(vm, info()));
137
138}
139
140JSObject* JSValidityState::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
141{
142 return JSValidityStatePrototype::create(vm, &globalObject, JSValidityStatePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
143}
144
145JSObject* JSValidityState::prototype(VM& vm, JSDOMGlobalObject& globalObject)
146{
147 return getDOMPrototype<JSValidityState>(vm, globalObject);
148}
149
150JSValue JSValidityState::getConstructor(VM& vm, const JSGlobalObject* globalObject)
151{
152 return getDOMConstructor<JSValidityStateConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
153}
154
155void JSValidityState::destroy(JSC::JSCell* cell)
156{
157 JSValidityState* thisObject = static_cast<JSValidityState*>(cell);
158 thisObject->JSValidityState::~JSValidityState();
159}
160
161template<> inline JSValidityState* IDLAttribute<JSValidityState>::cast(ExecState& state, EncodedJSValue thisValue)
162{
163 return jsDynamicCast<JSValidityState*>(state.vm(), JSValue::decode(thisValue));
164}
165
166EncodedJSValue jsValidityStateConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSValidityStatePrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype))
172 return throwVMTypeError(state, throwScope);
173 return JSValue::encode(JSValidityState::getConstructor(state->vm(), prototype->globalObject()));
174}
175
176bool setJSValidityStateConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
177{
178 VM& vm = state->vm();
179 auto throwScope = DECLARE_THROW_SCOPE(vm);
180 auto* prototype = jsDynamicCast<JSValidityStatePrototype*>(vm, JSValue::decode(thisValue));
181 if (UNLIKELY(!prototype)) {
182 throwVMTypeError(state, throwScope);
183 return false;
184 }
185 // Shadowing a built-in constructor
186 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
187}
188
189static inline JSValue jsValidityStateValueMissingGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
190{
191 UNUSED_PARAM(throwScope);
192 UNUSED_PARAM(state);
193 auto& impl = thisObject.wrapped();
194 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.valueMissing());
195 return result;
196}
197
198EncodedJSValue jsValidityStateValueMissing(ExecState* state, EncodedJSValue thisValue, PropertyName)
199{
200 return IDLAttribute<JSValidityState>::get<jsValidityStateValueMissingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "valueMissing");
201}
202
203static inline JSValue jsValidityStateTypeMismatchGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
204{
205 UNUSED_PARAM(throwScope);
206 UNUSED_PARAM(state);
207 auto& impl = thisObject.wrapped();
208 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.typeMismatch());
209 return result;
210}
211
212EncodedJSValue jsValidityStateTypeMismatch(ExecState* state, EncodedJSValue thisValue, PropertyName)
213{
214 return IDLAttribute<JSValidityState>::get<jsValidityStateTypeMismatchGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "typeMismatch");
215}
216
217static inline JSValue jsValidityStatePatternMismatchGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
218{
219 UNUSED_PARAM(throwScope);
220 UNUSED_PARAM(state);
221 auto& impl = thisObject.wrapped();
222 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.patternMismatch());
223 return result;
224}
225
226EncodedJSValue jsValidityStatePatternMismatch(ExecState* state, EncodedJSValue thisValue, PropertyName)
227{
228 return IDLAttribute<JSValidityState>::get<jsValidityStatePatternMismatchGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "patternMismatch");
229}
230
231static inline JSValue jsValidityStateTooShortGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
232{
233 UNUSED_PARAM(throwScope);
234 UNUSED_PARAM(state);
235 auto& impl = thisObject.wrapped();
236 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.tooShort());
237 return result;
238}
239
240EncodedJSValue jsValidityStateTooShort(ExecState* state, EncodedJSValue thisValue, PropertyName)
241{
242 return IDLAttribute<JSValidityState>::get<jsValidityStateTooShortGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "tooShort");
243}
244
245static inline JSValue jsValidityStateTooLongGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
246{
247 UNUSED_PARAM(throwScope);
248 UNUSED_PARAM(state);
249 auto& impl = thisObject.wrapped();
250 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.tooLong());
251 return result;
252}
253
254EncodedJSValue jsValidityStateTooLong(ExecState* state, EncodedJSValue thisValue, PropertyName)
255{
256 return IDLAttribute<JSValidityState>::get<jsValidityStateTooLongGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "tooLong");
257}
258
259static inline JSValue jsValidityStateRangeUnderflowGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
260{
261 UNUSED_PARAM(throwScope);
262 UNUSED_PARAM(state);
263 auto& impl = thisObject.wrapped();
264 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.rangeUnderflow());
265 return result;
266}
267
268EncodedJSValue jsValidityStateRangeUnderflow(ExecState* state, EncodedJSValue thisValue, PropertyName)
269{
270 return IDLAttribute<JSValidityState>::get<jsValidityStateRangeUnderflowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "rangeUnderflow");
271}
272
273static inline JSValue jsValidityStateRangeOverflowGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
274{
275 UNUSED_PARAM(throwScope);
276 UNUSED_PARAM(state);
277 auto& impl = thisObject.wrapped();
278 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.rangeOverflow());
279 return result;
280}
281
282EncodedJSValue jsValidityStateRangeOverflow(ExecState* state, EncodedJSValue thisValue, PropertyName)
283{
284 return IDLAttribute<JSValidityState>::get<jsValidityStateRangeOverflowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "rangeOverflow");
285}
286
287static inline JSValue jsValidityStateStepMismatchGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
288{
289 UNUSED_PARAM(throwScope);
290 UNUSED_PARAM(state);
291 auto& impl = thisObject.wrapped();
292 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.stepMismatch());
293 return result;
294}
295
296EncodedJSValue jsValidityStateStepMismatch(ExecState* state, EncodedJSValue thisValue, PropertyName)
297{
298 return IDLAttribute<JSValidityState>::get<jsValidityStateStepMismatchGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "stepMismatch");
299}
300
301static inline JSValue jsValidityStateBadInputGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
302{
303 UNUSED_PARAM(throwScope);
304 UNUSED_PARAM(state);
305 auto& impl = thisObject.wrapped();
306 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.badInput());
307 return result;
308}
309
310EncodedJSValue jsValidityStateBadInput(ExecState* state, EncodedJSValue thisValue, PropertyName)
311{
312 return IDLAttribute<JSValidityState>::get<jsValidityStateBadInputGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "badInput");
313}
314
315static inline JSValue jsValidityStateCustomErrorGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
316{
317 UNUSED_PARAM(throwScope);
318 UNUSED_PARAM(state);
319 auto& impl = thisObject.wrapped();
320 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.customError());
321 return result;
322}
323
324EncodedJSValue jsValidityStateCustomError(ExecState* state, EncodedJSValue thisValue, PropertyName)
325{
326 return IDLAttribute<JSValidityState>::get<jsValidityStateCustomErrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "customError");
327}
328
329static inline JSValue jsValidityStateValidGetter(ExecState& state, JSValidityState& thisObject, ThrowScope& throwScope)
330{
331 UNUSED_PARAM(throwScope);
332 UNUSED_PARAM(state);
333 auto& impl = thisObject.wrapped();
334 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isValid());
335 return result;
336}
337
338EncodedJSValue jsValidityStateValid(ExecState* state, EncodedJSValue thisValue, PropertyName)
339{
340 return IDLAttribute<JSValidityState>::get<jsValidityStateValidGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "valid");
341}
342
343void JSValidityState::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
344{
345 auto* thisObject = jsCast<JSValidityState*>(cell);
346 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
347 if (thisObject->scriptExecutionContext())
348 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
349 Base::heapSnapshot(cell, builder);
350}
351
352bool JSValidityStateOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
353{
354 UNUSED_PARAM(handle);
355 UNUSED_PARAM(visitor);
356 UNUSED_PARAM(reason);
357 return false;
358}
359
360void JSValidityStateOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
361{
362 auto* jsValidityState = static_cast<JSValidityState*>(handle.slot()->asCell());
363 auto& world = *static_cast<DOMWrapperWorld*>(context);
364 uncacheWrapper(world, &jsValidityState->wrapped(), jsValidityState);
365}
366
367JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ValidityState>&& impl)
368{
369 return createWrapper<ValidityState>(globalObject, WTFMove(impl));
370}
371
372JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ValidityState& impl)
373{
374 return wrap(state, globalObject, impl);
375}
376
377ValidityState* JSValidityState::toWrapped(JSC::VM& vm, JSC::JSValue value)
378{
379 if (auto* wrapper = jsDynamicCast<JSValidityState*>(vm, value))
380 return &wrapper->wrapped();
381 return nullptr;
382}
383
384}
385