| 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 "JSWorker.h" |
| 23 | |
| 24 | #include "EventNames.h" |
| 25 | #include "JSDOMAttribute.h" |
| 26 | #include "JSDOMBinding.h" |
| 27 | #include "JSDOMConstructor.h" |
| 28 | #include "JSDOMConvertAny.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertObject.h" |
| 31 | #include "JSDOMConvertSequences.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSEventListener.h" |
| 37 | #include "ScriptExecutionContext.h" |
| 38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 39 | #include <JavaScriptCore/JSArray.h> |
| 40 | #include <JavaScriptCore/JSCInlines.h> |
| 41 | #include <wtf/GetPtr.h> |
| 42 | #include <wtf/PointerPreparations.h> |
| 43 | #include <wtf/URL.h> |
| 44 | |
| 45 | |
| 46 | namespace WebCore { |
| 47 | using namespace JSC; |
| 48 | |
| 49 | template<> Worker::Options convertDictionary<Worker::Options>(ExecState& state, JSValue value) |
| 50 | { |
| 51 | VM& vm = state.vm(); |
| 52 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 53 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 54 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 55 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 56 | throwTypeError(&state, throwScope); |
| 57 | return { }; |
| 58 | } |
| 59 | Worker::Options result; |
| 60 | JSValue nameValue; |
| 61 | if (isNullOrUndefined) |
| 62 | nameValue = jsUndefined(); |
| 63 | else { |
| 64 | nameValue = object->get(&state, Identifier::fromString(&state, "name" )); |
| 65 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 66 | } |
| 67 | if (!nameValue.isUndefined()) { |
| 68 | result.name = convert<IDLDOMString>(state, nameValue); |
| 69 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 70 | } else |
| 71 | result.name = emptyString(); |
| 72 | return result; |
| 73 | } |
| 74 | |
| 75 | // Functions |
| 76 | |
| 77 | JSC::EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionTerminate(JSC::ExecState*); |
| 78 | JSC::EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionPostMessage(JSC::ExecState*); |
| 79 | |
| 80 | // Attributes |
| 81 | |
| 82 | JSC::EncodedJSValue jsWorkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 83 | bool setJSWorkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 84 | JSC::EncodedJSValue jsWorkerOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 85 | bool setJSWorkerOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 86 | JSC::EncodedJSValue jsWorkerOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 87 | bool setJSWorkerOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 88 | |
| 89 | class JSWorkerPrototype : public JSC::JSNonFinalObject { |
| 90 | public: |
| 91 | using Base = JSC::JSNonFinalObject; |
| 92 | static JSWorkerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 93 | { |
| 94 | JSWorkerPrototype* ptr = new (NotNull, JSC::allocateCell<JSWorkerPrototype>(vm.heap)) JSWorkerPrototype(vm, globalObject, structure); |
| 95 | ptr->finishCreation(vm); |
| 96 | return ptr; |
| 97 | } |
| 98 | |
| 99 | DECLARE_INFO; |
| 100 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 101 | { |
| 102 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | JSWorkerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 107 | : JSC::JSNonFinalObject(vm, structure) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | void finishCreation(JSC::VM&); |
| 112 | }; |
| 113 | |
| 114 | using JSWorkerConstructor = JSDOMConstructor<JSWorker>; |
| 115 | |
| 116 | template<> EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::construct(ExecState* state) |
| 117 | { |
| 118 | VM& vm = state->vm(); |
| 119 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 120 | UNUSED_PARAM(throwScope); |
| 121 | auto* castedThis = jsCast<JSWorkerConstructor*>(state->jsCallee()); |
| 122 | ASSERT(castedThis); |
| 123 | if (UNLIKELY(state->argumentCount() < 1)) |
| 124 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 125 | auto* context = castedThis->scriptExecutionContext(); |
| 126 | if (UNLIKELY(!context)) |
| 127 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "Worker" ); |
| 128 | auto scriptUrl = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
| 129 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 130 | auto options = convert<IDLDictionary<Worker::Options>>(*state, state->argument(1)); |
| 131 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 132 | auto object = Worker::create(*context, castedThis->globalObject()->runtimeFlags(), WTFMove(scriptUrl), WTFMove(options)); |
| 133 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Worker>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
| 134 | } |
| 135 | |
| 136 | template<> JSValue JSWorkerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 137 | { |
| 138 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 139 | } |
| 140 | |
| 141 | template<> void JSWorkerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 142 | { |
| 143 | putDirect(vm, vm.propertyNames->prototype, JSWorker::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 144 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Worker"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 145 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 146 | } |
| 147 | |
| 148 | template<> const ClassInfo JSWorkerConstructor::s_info = { "Worker" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkerConstructor) }; |
| 149 | |
| 150 | /* Hash table for prototype */ |
| 151 | |
| 152 | static const HashTableValue JSWorkerPrototypeTableValues[] = |
| 153 | { |
| 154 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWorkerConstructor) } }, |
| 155 | { "onmessage" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerOnmessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWorkerOnmessage) } }, |
| 156 | { "onerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWorkerOnerror) } }, |
| 157 | { "terminate" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWorkerPrototypeFunctionTerminate), (intptr_t) (0) } }, |
| 158 | { "postMessage" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWorkerPrototypeFunctionPostMessage), (intptr_t) (1) } }, |
| 159 | }; |
| 160 | |
| 161 | const ClassInfo JSWorkerPrototype::s_info = { "WorkerPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkerPrototype) }; |
| 162 | |
| 163 | void JSWorkerPrototype::finishCreation(VM& vm) |
| 164 | { |
| 165 | Base::finishCreation(vm); |
| 166 | reifyStaticProperties(vm, JSWorker::info(), JSWorkerPrototypeTableValues, *this); |
| 167 | } |
| 168 | |
| 169 | const ClassInfo JSWorker::s_info = { "Worker" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorker) }; |
| 170 | |
| 171 | JSWorker::JSWorker(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Worker>&& impl) |
| 172 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 173 | { |
| 174 | } |
| 175 | |
| 176 | void JSWorker::finishCreation(VM& vm) |
| 177 | { |
| 178 | Base::finishCreation(vm); |
| 179 | ASSERT(inherits(vm, info())); |
| 180 | |
| 181 | } |
| 182 | |
| 183 | JSObject* JSWorker::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 184 | { |
| 185 | return JSWorkerPrototype::create(vm, &globalObject, JSWorkerPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 186 | } |
| 187 | |
| 188 | JSObject* JSWorker::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 189 | { |
| 190 | return getDOMPrototype<JSWorker>(vm, globalObject); |
| 191 | } |
| 192 | |
| 193 | JSValue JSWorker::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 194 | { |
| 195 | return getDOMConstructor<JSWorkerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 196 | } |
| 197 | |
| 198 | template<> inline JSWorker* IDLAttribute<JSWorker>::cast(ExecState& state, EncodedJSValue thisValue) |
| 199 | { |
| 200 | return jsDynamicCast<JSWorker*>(state.vm(), JSValue::decode(thisValue)); |
| 201 | } |
| 202 | |
| 203 | template<> inline JSWorker* IDLOperation<JSWorker>::cast(ExecState& state) |
| 204 | { |
| 205 | return jsDynamicCast<JSWorker*>(state.vm(), state.thisValue()); |
| 206 | } |
| 207 | |
| 208 | EncodedJSValue jsWorkerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 209 | { |
| 210 | VM& vm = state->vm(); |
| 211 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 212 | auto* prototype = jsDynamicCast<JSWorkerPrototype*>(vm, JSValue::decode(thisValue)); |
| 213 | if (UNLIKELY(!prototype)) |
| 214 | return throwVMTypeError(state, throwScope); |
| 215 | return JSValue::encode(JSWorker::getConstructor(state->vm(), prototype->globalObject())); |
| 216 | } |
| 217 | |
| 218 | bool setJSWorkerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 219 | { |
| 220 | VM& vm = state->vm(); |
| 221 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 222 | auto* prototype = jsDynamicCast<JSWorkerPrototype*>(vm, JSValue::decode(thisValue)); |
| 223 | if (UNLIKELY(!prototype)) { |
| 224 | throwVMTypeError(state, throwScope); |
| 225 | return false; |
| 226 | } |
| 227 | // Shadowing a built-in constructor |
| 228 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 229 | } |
| 230 | |
| 231 | static inline JSValue jsWorkerOnmessageGetter(ExecState& state, JSWorker& thisObject, ThrowScope& throwScope) |
| 232 | { |
| 233 | UNUSED_PARAM(throwScope); |
| 234 | UNUSED_PARAM(state); |
| 235 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageEvent, worldForDOMObject(thisObject)); |
| 236 | } |
| 237 | |
| 238 | EncodedJSValue jsWorkerOnmessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 239 | { |
| 240 | return IDLAttribute<JSWorker>::get<jsWorkerOnmessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onmessage" ); |
| 241 | } |
| 242 | |
| 243 | static inline bool setJSWorkerOnmessageSetter(ExecState& state, JSWorker& thisObject, JSValue value, ThrowScope& throwScope) |
| 244 | { |
| 245 | UNUSED_PARAM(throwScope); |
| 246 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().messageEvent, value); |
| 247 | return true; |
| 248 | } |
| 249 | |
| 250 | bool setJSWorkerOnmessage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 251 | { |
| 252 | return IDLAttribute<JSWorker>::set<setJSWorkerOnmessageSetter>(*state, thisValue, encodedValue, "onmessage" ); |
| 253 | } |
| 254 | |
| 255 | static inline JSValue jsWorkerOnerrorGetter(ExecState& state, JSWorker& thisObject, ThrowScope& throwScope) |
| 256 | { |
| 257 | UNUSED_PARAM(throwScope); |
| 258 | UNUSED_PARAM(state); |
| 259 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().errorEvent, worldForDOMObject(thisObject)); |
| 260 | } |
| 261 | |
| 262 | EncodedJSValue jsWorkerOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 263 | { |
| 264 | return IDLAttribute<JSWorker>::get<jsWorkerOnerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onerror" ); |
| 265 | } |
| 266 | |
| 267 | static inline bool setJSWorkerOnerrorSetter(ExecState& state, JSWorker& thisObject, JSValue value, ThrowScope& throwScope) |
| 268 | { |
| 269 | UNUSED_PARAM(throwScope); |
| 270 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().errorEvent, value); |
| 271 | return true; |
| 272 | } |
| 273 | |
| 274 | bool setJSWorkerOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 275 | { |
| 276 | return IDLAttribute<JSWorker>::set<setJSWorkerOnerrorSetter>(*state, thisValue, encodedValue, "onerror" ); |
| 277 | } |
| 278 | |
| 279 | static inline JSC::EncodedJSValue jsWorkerPrototypeFunctionTerminateBody(JSC::ExecState* state, typename IDLOperation<JSWorker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 280 | { |
| 281 | UNUSED_PARAM(state); |
| 282 | UNUSED_PARAM(throwScope); |
| 283 | auto& impl = castedThis->wrapped(); |
| 284 | impl.terminate(); |
| 285 | return JSValue::encode(jsUndefined()); |
| 286 | } |
| 287 | |
| 288 | EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionTerminate(ExecState* state) |
| 289 | { |
| 290 | return IDLOperation<JSWorker>::call<jsWorkerPrototypeFunctionTerminateBody>(*state, "terminate" ); |
| 291 | } |
| 292 | |
| 293 | static inline JSC::EncodedJSValue jsWorkerPrototypeFunctionPostMessageBody(JSC::ExecState* state, typename IDLOperation<JSWorker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 294 | { |
| 295 | UNUSED_PARAM(state); |
| 296 | UNUSED_PARAM(throwScope); |
| 297 | auto& impl = castedThis->wrapped(); |
| 298 | if (UNLIKELY(state->argumentCount() < 1)) |
| 299 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 300 | auto message = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 301 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 302 | auto transfer = state->argument(1).isUndefined() ? Converter<IDLSequence<IDLObject>>::ReturnType{ } : convert<IDLSequence<IDLObject>>(*state, state->uncheckedArgument(1)); |
| 303 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 304 | propagateException(*state, throwScope, impl.postMessage(*state, WTFMove(message), WTFMove(transfer))); |
| 305 | return JSValue::encode(jsUndefined()); |
| 306 | } |
| 307 | |
| 308 | EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionPostMessage(ExecState* state) |
| 309 | { |
| 310 | return IDLOperation<JSWorker>::call<jsWorkerPrototypeFunctionPostMessageBody>(*state, "postMessage" ); |
| 311 | } |
| 312 | |
| 313 | void JSWorker::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 314 | { |
| 315 | auto* thisObject = jsCast<JSWorker*>(cell); |
| 316 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 317 | if (thisObject->scriptExecutionContext()) |
| 318 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 319 | Base::heapSnapshot(cell, builder); |
| 320 | } |
| 321 | |
| 322 | bool JSWorkerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 323 | { |
| 324 | auto* jsWorker = jsCast<JSWorker*>(handle.slot()->asCell()); |
| 325 | if (jsWorker->wrapped().hasPendingActivity()) { |
| 326 | if (UNLIKELY(reason)) |
| 327 | *reason = "ActiveDOMObject with pending activity" ; |
| 328 | return true; |
| 329 | } |
| 330 | if (jsWorker->wrapped().isFiringEventListeners()) { |
| 331 | if (UNLIKELY(reason)) |
| 332 | *reason = "EventTarget firing event listeners" ; |
| 333 | return true; |
| 334 | } |
| 335 | UNUSED_PARAM(visitor); |
| 336 | UNUSED_PARAM(reason); |
| 337 | return false; |
| 338 | } |
| 339 | |
| 340 | void JSWorkerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 341 | { |
| 342 | auto* jsWorker = static_cast<JSWorker*>(handle.slot()->asCell()); |
| 343 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 344 | uncacheWrapper(world, &jsWorker->wrapped(), jsWorker); |
| 345 | } |
| 346 | |
| 347 | #if ENABLE(BINDING_INTEGRITY) |
| 348 | #if PLATFORM(WIN) |
| 349 | #pragma warning(disable: 4483) |
| 350 | extern "C" { extern void (*const __identifier("??_7Worker@WebCore@@6B@" )[])(); } |
| 351 | #else |
| 352 | extern "C" { extern void* _ZTVN7WebCore6WorkerE[]; } |
| 353 | #endif |
| 354 | #endif |
| 355 | |
| 356 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Worker>&& impl) |
| 357 | { |
| 358 | |
| 359 | #if ENABLE(BINDING_INTEGRITY) |
| 360 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 361 | #if PLATFORM(WIN) |
| 362 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7Worker@WebCore@@6B@" )); |
| 363 | #else |
| 364 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore6WorkerE[2]); |
| 365 | #endif |
| 366 | |
| 367 | // If this fails Worker does not have a vtable, so you need to add the |
| 368 | // ImplementationLacksVTable attribute to the interface definition |
| 369 | static_assert(std::is_polymorphic<Worker>::value, "Worker is not polymorphic" ); |
| 370 | |
| 371 | // If you hit this assertion you either have a use after free bug, or |
| 372 | // Worker has subclasses. If Worker has subclasses that get passed |
| 373 | // to toJS() we currently require Worker you to opt out of binding hardening |
| 374 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 375 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 376 | #endif |
| 377 | return createWrapper<Worker>(globalObject, WTFMove(impl)); |
| 378 | } |
| 379 | |
| 380 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Worker& impl) |
| 381 | { |
| 382 | return wrap(state, globalObject, impl); |
| 383 | } |
| 384 | |
| 385 | Worker* JSWorker::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 386 | { |
| 387 | if (auto* wrapper = jsDynamicCast<JSWorker*>(vm, value)) |
| 388 | return &wrapper->wrapped(); |
| 389 | return nullptr; |
| 390 | } |
| 391 | |
| 392 | } |
| 393 | |