summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Bindings/Replaceable.h
blob: 6ed38839352fd921d0c00606ae9467e7a77d0f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 * 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();