| 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 "JSPerformanceEntry.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertNumbers.h" |
| 28 | #include "JSDOMConvertStrings.h" |
| 29 | #include "JSDOMExceptionHandling.h" |
| 30 | #include "JSDOMOperation.h" |
| 31 | #include "JSDOMWrapperCache.h" |
| 32 | #include "ScriptExecutionContext.h" |
| 33 | #include <JavaScriptCore/FunctionPrototype.h> |
| 34 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 35 | #include <JavaScriptCore/JSCInlines.h> |
| 36 | #include <JavaScriptCore/ObjectConstructor.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 | // Functions |
| 46 | |
| 47 | JSC::EncodedJSValue JSC_HOST_CALL jsPerformanceEntryPrototypeFunctionToJSON(JSC::ExecState*); |
| 48 | |
| 49 | // Attributes |
| 50 | |
| 51 | JSC::EncodedJSValue jsPerformanceEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 52 | bool setJSPerformanceEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 53 | JSC::EncodedJSValue jsPerformanceEntryName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 54 | JSC::EncodedJSValue jsPerformanceEntryEntryType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | JSC::EncodedJSValue jsPerformanceEntryStartTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 56 | JSC::EncodedJSValue jsPerformanceEntryDuration(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 57 | |
| 58 | class JSPerformanceEntryPrototype : public JSC::JSNonFinalObject { |
| 59 | public: |
| 60 | using Base = JSC::JSNonFinalObject; |
| 61 | static JSPerformanceEntryPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 62 | { |
| 63 | JSPerformanceEntryPrototype* ptr = new (NotNull, JSC::allocateCell<JSPerformanceEntryPrototype>(vm.heap)) JSPerformanceEntryPrototype(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 | |
| 74 | private: |
| 75 | JSPerformanceEntryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 76 | : JSC::JSNonFinalObject(vm, structure) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | void finishCreation(JSC::VM&); |
| 81 | }; |
| 82 | |
| 83 | using JSPerformanceEntryConstructor = JSDOMConstructorNotConstructable<JSPerformanceEntry>; |
| 84 | |
| 85 | template<> JSValue JSPerformanceEntryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 86 | { |
| 87 | UNUSED_PARAM(vm); |
| 88 | return globalObject.functionPrototype(); |
| 89 | } |
| 90 | |
| 91 | template<> void JSPerformanceEntryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 92 | { |
| 93 | putDirect(vm, vm.propertyNames->prototype, JSPerformanceEntry::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 94 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("PerformanceEntry"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 95 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 96 | } |
| 97 | |
| 98 | template<> const ClassInfo JSPerformanceEntryConstructor::s_info = { "PerformanceEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPerformanceEntryConstructor) }; |
| 99 | |
| 100 | /* Hash table for prototype */ |
| 101 | |
| 102 | static const HashTableValue JSPerformanceEntryPrototypeTableValues[] = |
| 103 | { |
| 104 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPerformanceEntryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPerformanceEntryConstructor) } }, |
| 105 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPerformanceEntryName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 106 | { "entryType" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPerformanceEntryEntryType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 107 | { "startTime" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPerformanceEntryStartTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 108 | { "duration" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPerformanceEntryDuration), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 109 | { "toJSON" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPerformanceEntryPrototypeFunctionToJSON), (intptr_t) (0) } }, |
| 110 | }; |
| 111 | |
| 112 | const ClassInfo JSPerformanceEntryPrototype::s_info = { "PerformanceEntryPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPerformanceEntryPrototype) }; |
| 113 | |
| 114 | void JSPerformanceEntryPrototype::finishCreation(VM& vm) |
| 115 | { |
| 116 | Base::finishCreation(vm); |
| 117 | reifyStaticProperties(vm, JSPerformanceEntry::info(), JSPerformanceEntryPrototypeTableValues, *this); |
| 118 | } |
| 119 | |
| 120 | const ClassInfo JSPerformanceEntry::s_info = { "PerformanceEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPerformanceEntry) }; |
| 121 | |
| 122 | JSPerformanceEntry::JSPerformanceEntry(Structure* structure, JSDOMGlobalObject& globalObject, Ref<PerformanceEntry>&& impl) |
| 123 | : JSDOMWrapper<PerformanceEntry>(structure, globalObject, WTFMove(impl)) |
| 124 | { |
| 125 | } |
| 126 | |
| 127 | void JSPerformanceEntry::finishCreation(VM& vm) |
| 128 | { |
| 129 | Base::finishCreation(vm); |
| 130 | ASSERT(inherits(vm, info())); |
| 131 | |
| 132 | } |
| 133 | |
| 134 | JSObject* JSPerformanceEntry::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 135 | { |
| 136 | return JSPerformanceEntryPrototype::create(vm, &globalObject, JSPerformanceEntryPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 137 | } |
| 138 | |
| 139 | JSObject* JSPerformanceEntry::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 140 | { |
| 141 | return getDOMPrototype<JSPerformanceEntry>(vm, globalObject); |
| 142 | } |
| 143 | |
| 144 | JSValue JSPerformanceEntry::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 145 | { |
| 146 | return getDOMConstructor<JSPerformanceEntryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 147 | } |
| 148 | |
| 149 | void JSPerformanceEntry::destroy(JSC::JSCell* cell) |
| 150 | { |
| 151 | JSPerformanceEntry* thisObject = static_cast<JSPerformanceEntry*>(cell); |
| 152 | thisObject->JSPerformanceEntry::~JSPerformanceEntry(); |
| 153 | } |
| 154 | |
| 155 | template<> inline JSPerformanceEntry* IDLAttribute<JSPerformanceEntry>::cast(ExecState& state, EncodedJSValue thisValue) |
| 156 | { |
| 157 | return jsDynamicCast<JSPerformanceEntry*>(state.vm(), JSValue::decode(thisValue)); |
| 158 | } |
| 159 | |
| 160 | template<> inline JSPerformanceEntry* IDLOperation<JSPerformanceEntry>::cast(ExecState& state) |
| 161 | { |
| 162 | return jsDynamicCast<JSPerformanceEntry*>(state.vm(), state.thisValue()); |
| 163 | } |
| 164 | |
| 165 | EncodedJSValue jsPerformanceEntryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 166 | { |
| 167 | VM& vm = state->vm(); |
| 168 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 169 | auto* prototype = jsDynamicCast<JSPerformanceEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 170 | if (UNLIKELY(!prototype)) |
| 171 | return throwVMTypeError(state, throwScope); |
| 172 | return JSValue::encode(JSPerformanceEntry::getConstructor(state->vm(), prototype->globalObject())); |
| 173 | } |
| 174 | |
| 175 | bool setJSPerformanceEntryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 176 | { |
| 177 | VM& vm = state->vm(); |
| 178 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 179 | auto* prototype = jsDynamicCast<JSPerformanceEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 180 | if (UNLIKELY(!prototype)) { |
| 181 | throwVMTypeError(state, throwScope); |
| 182 | return false; |
| 183 | } |
| 184 | // Shadowing a built-in constructor |
| 185 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 186 | } |
| 187 | |
| 188 | static inline JSValue jsPerformanceEntryNameGetter(ExecState& state, JSPerformanceEntry& 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.name()); |
| 194 | return result; |
| 195 | } |
| 196 | |
| 197 | EncodedJSValue jsPerformanceEntryName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 198 | { |
| 199 | return IDLAttribute<JSPerformanceEntry>::get<jsPerformanceEntryNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
| 200 | } |
| 201 | |
| 202 | static inline JSValue jsPerformanceEntryEntryTypeGetter(ExecState& state, JSPerformanceEntry& thisObject, ThrowScope& throwScope) |
| 203 | { |
| 204 | UNUSED_PARAM(throwScope); |
| 205 | UNUSED_PARAM(state); |
| 206 | auto& impl = thisObject.wrapped(); |
| 207 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.entryType()); |
| 208 | return result; |
| 209 | } |
| 210 | |
| 211 | EncodedJSValue jsPerformanceEntryEntryType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 212 | { |
| 213 | return IDLAttribute<JSPerformanceEntry>::get<jsPerformanceEntryEntryTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "entryType" ); |
| 214 | } |
| 215 | |
| 216 | static inline JSValue jsPerformanceEntryStartTimeGetter(ExecState& state, JSPerformanceEntry& thisObject, ThrowScope& throwScope) |
| 217 | { |
| 218 | UNUSED_PARAM(throwScope); |
| 219 | UNUSED_PARAM(state); |
| 220 | auto& impl = thisObject.wrapped(); |
| 221 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.startTime()); |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | EncodedJSValue jsPerformanceEntryStartTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 226 | { |
| 227 | return IDLAttribute<JSPerformanceEntry>::get<jsPerformanceEntryStartTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startTime" ); |
| 228 | } |
| 229 | |
| 230 | static inline JSValue jsPerformanceEntryDurationGetter(ExecState& state, JSPerformanceEntry& thisObject, ThrowScope& throwScope) |
| 231 | { |
| 232 | UNUSED_PARAM(throwScope); |
| 233 | UNUSED_PARAM(state); |
| 234 | auto& impl = thisObject.wrapped(); |
| 235 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.duration()); |
| 236 | return result; |
| 237 | } |
| 238 | |
| 239 | EncodedJSValue jsPerformanceEntryDuration(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 240 | { |
| 241 | return IDLAttribute<JSPerformanceEntry>::get<jsPerformanceEntryDurationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "duration" ); |
| 242 | } |
| 243 | |
| 244 | JSC::JSObject* JSPerformanceEntry::serialize(ExecState& state, JSPerformanceEntry& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) |
| 245 | { |
| 246 | auto& vm = state.vm(); |
| 247 | auto* result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 248 | |
| 249 | auto nameValue = jsPerformanceEntryNameGetter(state, thisObject, throwScope); |
| 250 | throwScope.assertNoException(); |
| 251 | result->putDirect(vm, Identifier::fromString(&vm, "name" ), nameValue); |
| 252 | |
| 253 | auto entryTypeValue = jsPerformanceEntryEntryTypeGetter(state, thisObject, throwScope); |
| 254 | throwScope.assertNoException(); |
| 255 | result->putDirect(vm, Identifier::fromString(&vm, "entryType" ), entryTypeValue); |
| 256 | |
| 257 | auto startTimeValue = jsPerformanceEntryStartTimeGetter(state, thisObject, throwScope); |
| 258 | throwScope.assertNoException(); |
| 259 | result->putDirect(vm, Identifier::fromString(&vm, "startTime" ), startTimeValue); |
| 260 | |
| 261 | auto durationValue = jsPerformanceEntryDurationGetter(state, thisObject, throwScope); |
| 262 | throwScope.assertNoException(); |
| 263 | result->putDirect(vm, Identifier::fromString(&vm, "duration" ), durationValue); |
| 264 | |
| 265 | return result; |
| 266 | } |
| 267 | |
| 268 | static inline EncodedJSValue jsPerformanceEntryPrototypeFunctionToJSONBody(ExecState* state, JSPerformanceEntry* thisObject, JSC::ThrowScope& throwScope) |
| 269 | { |
| 270 | return JSValue::encode(JSPerformanceEntry::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope)); |
| 271 | } |
| 272 | |
| 273 | EncodedJSValue JSC_HOST_CALL jsPerformanceEntryPrototypeFunctionToJSON(ExecState* state) |
| 274 | { |
| 275 | return IDLOperation<JSPerformanceEntry>::call<jsPerformanceEntryPrototypeFunctionToJSONBody>(*state, "toJSON" ); |
| 276 | } |
| 277 | |
| 278 | void JSPerformanceEntry::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 279 | { |
| 280 | auto* thisObject = jsCast<JSPerformanceEntry*>(cell); |
| 281 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 282 | if (thisObject->scriptExecutionContext()) |
| 283 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 284 | Base::heapSnapshot(cell, builder); |
| 285 | } |
| 286 | |
| 287 | bool JSPerformanceEntryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 288 | { |
| 289 | UNUSED_PARAM(handle); |
| 290 | UNUSED_PARAM(visitor); |
| 291 | UNUSED_PARAM(reason); |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | void JSPerformanceEntryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 296 | { |
| 297 | auto* jsPerformanceEntry = static_cast<JSPerformanceEntry*>(handle.slot()->asCell()); |
| 298 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 299 | uncacheWrapper(world, &jsPerformanceEntry->wrapped(), jsPerformanceEntry); |
| 300 | } |
| 301 | |
| 302 | PerformanceEntry* JSPerformanceEntry::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 303 | { |
| 304 | if (auto* wrapper = jsDynamicCast<JSPerformanceEntry*>(vm, value)) |
| 305 | return &wrapper->wrapped(); |
| 306 | return nullptr; |
| 307 | } |
| 308 | |
| 309 | } |
| 310 | |