Replaceable.h 845 B

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