ladybird/Userland/Libraries/LibWeb/Bindings/Replaceable.h
Linus Groh 999da617c5 LibJS: Remove GlobalObject from VM::this_value()
This is a continuation of the previous six commits.

The global object is only needed to return it if the execution context
stack is empty, but that doesn't seem like a useful thing to allow in
the first place - if you're not currently executing JS, and the
execution context stack is empty, there is no this value to retrieve.
2022-08-23 13:58:30 +01:00

16 lines
760 B
C

/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#define REPLACEABLE_PROPERTY_SETTER(ObjectType, property) \
auto this_value = vm.this_value(); \
if (!this_value.is_object() || !is<ObjectType>(this_value.as_object())) \
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, #ObjectType); \
TRY(this_value.as_object().internal_define_own_property( \
#property, JS::PropertyDescriptor { .value = vm.argument(0), .writable = true })); \
return JS::js_undefined();