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 "JSMemoryInfo.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConvertNumbers.h" |
27 | #include "JSDOMExceptionHandling.h" |
28 | #include "JSDOMWrapperCache.h" |
29 | #include "ScriptExecutionContext.h" |
30 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
31 | #include <JavaScriptCore/JSCInlines.h> |
32 | #include <wtf/GetPtr.h> |
33 | #include <wtf/PointerPreparations.h> |
34 | #include <wtf/URL.h> |
35 | |
36 | |
37 | namespace WebCore { |
38 | using namespace JSC; |
39 | |
40 | // Attributes |
41 | |
42 | JSC::EncodedJSValue jsMemoryInfoUsedJSHeapSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
43 | JSC::EncodedJSValue jsMemoryInfoTotalJSHeapSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
44 | |
45 | class JSMemoryInfoPrototype : public JSC::JSNonFinalObject { |
46 | public: |
47 | using Base = JSC::JSNonFinalObject; |
48 | static JSMemoryInfoPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
49 | { |
50 | JSMemoryInfoPrototype* ptr = new (NotNull, JSC::allocateCell<JSMemoryInfoPrototype>(vm.heap)) JSMemoryInfoPrototype(vm, globalObject, structure); |
51 | ptr->finishCreation(vm); |
52 | return ptr; |
53 | } |
54 | |
55 | DECLARE_INFO; |
56 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
57 | { |
58 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
59 | } |
60 | |
61 | private: |
62 | JSMemoryInfoPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
63 | : JSC::JSNonFinalObject(vm, structure) |
64 | { |
65 | } |
66 | |
67 | void finishCreation(JSC::VM&); |
68 | }; |
69 | |
70 | /* Hash table for prototype */ |
71 | |
72 | static const HashTableValue JSMemoryInfoPrototypeTableValues[] = |
73 | { |
74 | { "usedJSHeapSize" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMemoryInfoUsedJSHeapSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
75 | { "totalJSHeapSize" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMemoryInfoTotalJSHeapSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
76 | }; |
77 | |
78 | const ClassInfo JSMemoryInfoPrototype::s_info = { "MemoryInfoPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMemoryInfoPrototype) }; |
79 | |
80 | void JSMemoryInfoPrototype::finishCreation(VM& vm) |
81 | { |
82 | Base::finishCreation(vm); |
83 | reifyStaticProperties(vm, JSMemoryInfo::info(), JSMemoryInfoPrototypeTableValues, *this); |
84 | } |
85 | |
86 | const ClassInfo JSMemoryInfo::s_info = { "MemoryInfo" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMemoryInfo) }; |
87 | |
88 | JSMemoryInfo::JSMemoryInfo(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MemoryInfo>&& impl) |
89 | : JSDOMWrapper<MemoryInfo>(structure, globalObject, WTFMove(impl)) |
90 | { |
91 | } |
92 | |
93 | void JSMemoryInfo::finishCreation(VM& vm) |
94 | { |
95 | Base::finishCreation(vm); |
96 | ASSERT(inherits(vm, info())); |
97 | |
98 | } |
99 | |
100 | JSObject* JSMemoryInfo::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
101 | { |
102 | return JSMemoryInfoPrototype::create(vm, &globalObject, JSMemoryInfoPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
103 | } |
104 | |
105 | JSObject* JSMemoryInfo::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
106 | { |
107 | return getDOMPrototype<JSMemoryInfo>(vm, globalObject); |
108 | } |
109 | |
110 | void JSMemoryInfo::destroy(JSC::JSCell* cell) |
111 | { |
112 | JSMemoryInfo* thisObject = static_cast<JSMemoryInfo*>(cell); |
113 | thisObject->JSMemoryInfo::~JSMemoryInfo(); |
114 | } |
115 | |
116 | template<> inline JSMemoryInfo* IDLAttribute<JSMemoryInfo>::cast(ExecState& state, EncodedJSValue thisValue) |
117 | { |
118 | return jsDynamicCast<JSMemoryInfo*>(state.vm(), JSValue::decode(thisValue)); |
119 | } |
120 | |
121 | static inline JSValue jsMemoryInfoUsedJSHeapSizeGetter(ExecState& state, JSMemoryInfo& thisObject, ThrowScope& throwScope) |
122 | { |
123 | UNUSED_PARAM(throwScope); |
124 | UNUSED_PARAM(state); |
125 | auto& impl = thisObject.wrapped(); |
126 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.usedJSHeapSize()); |
127 | return result; |
128 | } |
129 | |
130 | EncodedJSValue jsMemoryInfoUsedJSHeapSize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
131 | { |
132 | return IDLAttribute<JSMemoryInfo>::get<jsMemoryInfoUsedJSHeapSizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "usedJSHeapSize" ); |
133 | } |
134 | |
135 | static inline JSValue jsMemoryInfoTotalJSHeapSizeGetter(ExecState& state, JSMemoryInfo& thisObject, ThrowScope& throwScope) |
136 | { |
137 | UNUSED_PARAM(throwScope); |
138 | UNUSED_PARAM(state); |
139 | auto& impl = thisObject.wrapped(); |
140 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.totalJSHeapSize()); |
141 | return result; |
142 | } |
143 | |
144 | EncodedJSValue jsMemoryInfoTotalJSHeapSize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
145 | { |
146 | return IDLAttribute<JSMemoryInfo>::get<jsMemoryInfoTotalJSHeapSizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "totalJSHeapSize" ); |
147 | } |
148 | |
149 | void JSMemoryInfo::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
150 | { |
151 | auto* thisObject = jsCast<JSMemoryInfo*>(cell); |
152 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
153 | if (thisObject->scriptExecutionContext()) |
154 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
155 | Base::heapSnapshot(cell, builder); |
156 | } |
157 | |
158 | bool JSMemoryInfoOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
159 | { |
160 | UNUSED_PARAM(handle); |
161 | UNUSED_PARAM(visitor); |
162 | UNUSED_PARAM(reason); |
163 | return false; |
164 | } |
165 | |
166 | void JSMemoryInfoOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
167 | { |
168 | auto* jsMemoryInfo = static_cast<JSMemoryInfo*>(handle.slot()->asCell()); |
169 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
170 | uncacheWrapper(world, &jsMemoryInfo->wrapped(), jsMemoryInfo); |
171 | } |
172 | |
173 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MemoryInfo>&& impl) |
174 | { |
175 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
176 | // attribute. You should remove that attribute. If the class has subclasses |
177 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
178 | // attribute to MemoryInfo. |
179 | static_assert(!std::is_polymorphic<MemoryInfo>::value, "MemoryInfo is polymorphic but the IDL claims it is not" ); |
180 | return createWrapper<MemoryInfo>(globalObject, WTFMove(impl)); |
181 | } |
182 | |
183 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MemoryInfo& impl) |
184 | { |
185 | return wrap(state, globalObject, impl); |
186 | } |
187 | |
188 | MemoryInfo* JSMemoryInfo::toWrapped(JSC::VM& vm, JSC::JSValue value) |
189 | { |
190 | if (auto* wrapper = jsDynamicCast<JSMemoryInfo*>(vm, value)) |
191 | return &wrapper->wrapped(); |
192 | return nullptr; |
193 | } |
194 | |
195 | } |
196 | |