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 "JSBarProp.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 | |
39 | namespace WebCore { |
40 | using namespace JSC; |
41 | |
42 | // Attributes |
43 | |
44 | JSC::EncodedJSValue jsBarPropConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
45 | bool setJSBarPropConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
46 | JSC::EncodedJSValue jsBarPropVisible(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
47 | |
48 | class JSBarPropPrototype : public JSC::JSNonFinalObject { |
49 | public: |
50 | using Base = JSC::JSNonFinalObject; |
51 | static JSBarPropPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
52 | { |
53 | JSBarPropPrototype* ptr = new (NotNull, JSC::allocateCell<JSBarPropPrototype>(vm.heap)) JSBarPropPrototype(vm, globalObject, structure); |
54 | ptr->finishCreation(vm); |
55 | return ptr; |
56 | } |
57 | |
58 | DECLARE_INFO; |
59 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
60 | { |
61 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
62 | } |
63 | |
64 | private: |
65 | JSBarPropPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
66 | : JSC::JSNonFinalObject(vm, structure) |
67 | { |
68 | } |
69 | |
70 | void finishCreation(JSC::VM&); |
71 | }; |
72 | |
73 | using JSBarPropConstructor = JSDOMConstructorNotConstructable<JSBarProp>; |
74 | |
75 | template<> JSValue JSBarPropConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
76 | { |
77 | UNUSED_PARAM(vm); |
78 | return globalObject.functionPrototype(); |
79 | } |
80 | |
81 | template<> void JSBarPropConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
82 | { |
83 | putDirect(vm, vm.propertyNames->prototype, JSBarProp::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
84 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("BarProp"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
85 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
86 | } |
87 | |
88 | template<> const ClassInfo JSBarPropConstructor::s_info = { "BarProp" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBarPropConstructor) }; |
89 | |
90 | /* Hash table for prototype */ |
91 | |
92 | static const HashTableValue JSBarPropPrototypeTableValues[] = |
93 | { |
94 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBarPropConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBarPropConstructor) } }, |
95 | { "visible" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBarPropVisible), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
96 | }; |
97 | |
98 | const ClassInfo JSBarPropPrototype::s_info = { "BarPropPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBarPropPrototype) }; |
99 | |
100 | void JSBarPropPrototype::finishCreation(VM& vm) |
101 | { |
102 | Base::finishCreation(vm); |
103 | reifyStaticProperties(vm, JSBarProp::info(), JSBarPropPrototypeTableValues, *this); |
104 | } |
105 | |
106 | const ClassInfo JSBarProp::s_info = { "BarProp" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBarProp) }; |
107 | |
108 | JSBarProp::JSBarProp(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BarProp>&& impl) |
109 | : JSDOMWrapper<BarProp>(structure, globalObject, WTFMove(impl)) |
110 | { |
111 | } |
112 | |
113 | void JSBarProp::finishCreation(VM& vm) |
114 | { |
115 | Base::finishCreation(vm); |
116 | ASSERT(inherits(vm, info())); |
117 | |
118 | } |
119 | |
120 | JSObject* JSBarProp::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
121 | { |
122 | return JSBarPropPrototype::create(vm, &globalObject, JSBarPropPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
123 | } |
124 | |
125 | JSObject* JSBarProp::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
126 | { |
127 | return getDOMPrototype<JSBarProp>(vm, globalObject); |
128 | } |
129 | |
130 | JSValue JSBarProp::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
131 | { |
132 | return getDOMConstructor<JSBarPropConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
133 | } |
134 | |
135 | void JSBarProp::destroy(JSC::JSCell* cell) |
136 | { |
137 | JSBarProp* thisObject = static_cast<JSBarProp*>(cell); |
138 | thisObject->JSBarProp::~JSBarProp(); |
139 | } |
140 | |
141 | template<> inline JSBarProp* IDLAttribute<JSBarProp>::cast(ExecState& state, EncodedJSValue thisValue) |
142 | { |
143 | return jsDynamicCast<JSBarProp*>(state.vm(), JSValue::decode(thisValue)); |
144 | } |
145 | |
146 | EncodedJSValue jsBarPropConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
147 | { |
148 | VM& vm = state->vm(); |
149 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
150 | auto* prototype = jsDynamicCast<JSBarPropPrototype*>(vm, JSValue::decode(thisValue)); |
151 | if (UNLIKELY(!prototype)) |
152 | return throwVMTypeError(state, throwScope); |
153 | return JSValue::encode(JSBarProp::getConstructor(state->vm(), prototype->globalObject())); |
154 | } |
155 | |
156 | bool setJSBarPropConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
157 | { |
158 | VM& vm = state->vm(); |
159 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
160 | auto* prototype = jsDynamicCast<JSBarPropPrototype*>(vm, JSValue::decode(thisValue)); |
161 | if (UNLIKELY(!prototype)) { |
162 | throwVMTypeError(state, throwScope); |
163 | return false; |
164 | } |
165 | // Shadowing a built-in constructor |
166 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
167 | } |
168 | |
169 | static inline JSValue jsBarPropVisibleGetter(ExecState& state, JSBarProp& thisObject, ThrowScope& throwScope) |
170 | { |
171 | UNUSED_PARAM(throwScope); |
172 | UNUSED_PARAM(state); |
173 | auto& impl = thisObject.wrapped(); |
174 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.visible()); |
175 | return result; |
176 | } |
177 | |
178 | EncodedJSValue jsBarPropVisible(ExecState* state, EncodedJSValue thisValue, PropertyName) |
179 | { |
180 | return IDLAttribute<JSBarProp>::get<jsBarPropVisibleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "visible" ); |
181 | } |
182 | |
183 | void JSBarProp::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
184 | { |
185 | auto* thisObject = jsCast<JSBarProp*>(cell); |
186 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
187 | if (thisObject->scriptExecutionContext()) |
188 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
189 | Base::heapSnapshot(cell, builder); |
190 | } |
191 | |
192 | bool JSBarPropOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
193 | { |
194 | auto* jsBarProp = jsCast<JSBarProp*>(handle.slot()->asCell()); |
195 | Frame* root = WTF::getPtr(jsBarProp->wrapped().frame()); |
196 | if (!root) |
197 | return false; |
198 | if (UNLIKELY(reason)) |
199 | *reason = "Reachable from Frame" ; |
200 | return visitor.containsOpaqueRoot(root); |
201 | } |
202 | |
203 | void JSBarPropOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
204 | { |
205 | auto* jsBarProp = static_cast<JSBarProp*>(handle.slot()->asCell()); |
206 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
207 | uncacheWrapper(world, &jsBarProp->wrapped(), jsBarProp); |
208 | } |
209 | |
210 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<BarProp>&& impl) |
211 | { |
212 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
213 | // attribute. You should remove that attribute. If the class has subclasses |
214 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
215 | // attribute to BarProp. |
216 | static_assert(!std::is_polymorphic<BarProp>::value, "BarProp is polymorphic but the IDL claims it is not" ); |
217 | return createWrapper<BarProp>(globalObject, WTFMove(impl)); |
218 | } |
219 | |
220 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, BarProp& impl) |
221 | { |
222 | return wrap(state, globalObject, impl); |
223 | } |
224 | |
225 | BarProp* JSBarProp::toWrapped(JSC::VM& vm, JSC::JSValue value) |
226 | { |
227 | if (auto* wrapper = jsDynamicCast<JSBarProp*>(vm, value)) |
228 | return &wrapper->wrapped(); |
229 | return nullptr; |
230 | } |
231 | |
232 | } |
233 | |