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 | |
23 | #if ENABLE(WEB_AUTHN) |
24 | |
25 | #include "JSBasicCredential.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include <JavaScriptCore/FunctionPrototype.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 jsBasicCredentialConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | bool setJSBasicCredentialConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
49 | JSC::EncodedJSValue jsBasicCredentialId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | JSC::EncodedJSValue jsBasicCredentialType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | |
52 | class JSBasicCredentialPrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSBasicCredentialPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSBasicCredentialPrototype* ptr = new (NotNull, JSC::allocateCell<JSBasicCredentialPrototype>(vm.heap)) JSBasicCredentialPrototype(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 | JSBasicCredentialPrototype(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 JSBasicCredentialConstructor = JSDOMConstructorNotConstructable<JSBasicCredential>; |
78 | |
79 | template<> JSValue JSBasicCredentialConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
80 | { |
81 | UNUSED_PARAM(vm); |
82 | return globalObject.functionPrototype(); |
83 | } |
84 | |
85 | template<> void JSBasicCredentialConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
86 | { |
87 | putDirect(vm, vm.propertyNames->prototype, JSBasicCredential::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
88 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Credential"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
89 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
90 | } |
91 | |
92 | template<> const ClassInfo JSBasicCredentialConstructor::s_info = { "Credential" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBasicCredentialConstructor) }; |
93 | |
94 | /* Hash table for prototype */ |
95 | |
96 | static const HashTableValue JSBasicCredentialPrototypeTableValues[] = |
97 | { |
98 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBasicCredentialConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBasicCredentialConstructor) } }, |
99 | { "id" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBasicCredentialId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
100 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBasicCredentialType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
101 | }; |
102 | |
103 | const ClassInfo JSBasicCredentialPrototype::s_info = { "CredentialPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBasicCredentialPrototype) }; |
104 | |
105 | void JSBasicCredentialPrototype::finishCreation(VM& vm) |
106 | { |
107 | Base::finishCreation(vm); |
108 | reifyStaticProperties(vm, JSBasicCredential::info(), JSBasicCredentialPrototypeTableValues, *this); |
109 | } |
110 | |
111 | const ClassInfo JSBasicCredential::s_info = { "Credential" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBasicCredential) }; |
112 | |
113 | JSBasicCredential::JSBasicCredential(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BasicCredential>&& impl) |
114 | : JSDOMWrapper<BasicCredential>(structure, globalObject, WTFMove(impl)) |
115 | { |
116 | } |
117 | |
118 | void JSBasicCredential::finishCreation(VM& vm) |
119 | { |
120 | Base::finishCreation(vm); |
121 | ASSERT(inherits(vm, info())); |
122 | |
123 | } |
124 | |
125 | JSObject* JSBasicCredential::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
126 | { |
127 | return JSBasicCredentialPrototype::create(vm, &globalObject, JSBasicCredentialPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
128 | } |
129 | |
130 | JSObject* JSBasicCredential::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
131 | { |
132 | return getDOMPrototype<JSBasicCredential>(vm, globalObject); |
133 | } |
134 | |
135 | JSValue JSBasicCredential::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
136 | { |
137 | return getDOMConstructor<JSBasicCredentialConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
138 | } |
139 | |
140 | void JSBasicCredential::destroy(JSC::JSCell* cell) |
141 | { |
142 | JSBasicCredential* thisObject = static_cast<JSBasicCredential*>(cell); |
143 | thisObject->JSBasicCredential::~JSBasicCredential(); |
144 | } |
145 | |
146 | template<> inline JSBasicCredential* IDLAttribute<JSBasicCredential>::cast(ExecState& state, EncodedJSValue thisValue) |
147 | { |
148 | return jsDynamicCast<JSBasicCredential*>(state.vm(), JSValue::decode(thisValue)); |
149 | } |
150 | |
151 | EncodedJSValue jsBasicCredentialConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
152 | { |
153 | VM& vm = state->vm(); |
154 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
155 | auto* prototype = jsDynamicCast<JSBasicCredentialPrototype*>(vm, JSValue::decode(thisValue)); |
156 | if (UNLIKELY(!prototype)) |
157 | return throwVMTypeError(state, throwScope); |
158 | return JSValue::encode(JSBasicCredential::getConstructor(state->vm(), prototype->globalObject())); |
159 | } |
160 | |
161 | bool setJSBasicCredentialConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
162 | { |
163 | VM& vm = state->vm(); |
164 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
165 | auto* prototype = jsDynamicCast<JSBasicCredentialPrototype*>(vm, JSValue::decode(thisValue)); |
166 | if (UNLIKELY(!prototype)) { |
167 | throwVMTypeError(state, throwScope); |
168 | return false; |
169 | } |
170 | // Shadowing a built-in constructor |
171 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
172 | } |
173 | |
174 | static inline JSValue jsBasicCredentialIdGetter(ExecState& state, JSBasicCredential& thisObject, ThrowScope& throwScope) |
175 | { |
176 | UNUSED_PARAM(throwScope); |
177 | UNUSED_PARAM(state); |
178 | auto& impl = thisObject.wrapped(); |
179 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.id()); |
180 | return result; |
181 | } |
182 | |
183 | EncodedJSValue jsBasicCredentialId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
184 | { |
185 | return IDLAttribute<JSBasicCredential>::get<jsBasicCredentialIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id" ); |
186 | } |
187 | |
188 | static inline JSValue jsBasicCredentialTypeGetter(ExecState& state, JSBasicCredential& thisObject, ThrowScope& throwScope) |
189 | { |
190 | UNUSED_PARAM(throwScope); |
191 | UNUSED_PARAM(state); |
192 | auto& impl = thisObject.wrapped(); |
193 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type()); |
194 | return result; |
195 | } |
196 | |
197 | EncodedJSValue jsBasicCredentialType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
198 | { |
199 | return IDLAttribute<JSBasicCredential>::get<jsBasicCredentialTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
200 | } |
201 | |
202 | void JSBasicCredential::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
203 | { |
204 | auto* thisObject = jsCast<JSBasicCredential*>(cell); |
205 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
206 | if (thisObject->scriptExecutionContext()) |
207 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
208 | Base::heapSnapshot(cell, builder); |
209 | } |
210 | |
211 | bool JSBasicCredentialOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
212 | { |
213 | UNUSED_PARAM(handle); |
214 | UNUSED_PARAM(visitor); |
215 | UNUSED_PARAM(reason); |
216 | return false; |
217 | } |
218 | |
219 | void JSBasicCredentialOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
220 | { |
221 | auto* jsBasicCredential = static_cast<JSBasicCredential*>(handle.slot()->asCell()); |
222 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
223 | uncacheWrapper(world, &jsBasicCredential->wrapped(), jsBasicCredential); |
224 | } |
225 | |
226 | BasicCredential* JSBasicCredential::toWrapped(JSC::VM& vm, JSC::JSValue value) |
227 | { |
228 | if (auto* wrapper = jsDynamicCast<JSBasicCredential*>(vm, value)) |
229 | return &wrapper->wrapped(); |
230 | return nullptr; |
231 | } |
232 | |
233 | } |
234 | |
235 | #endif // ENABLE(WEB_AUTHN) |
236 | |