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