1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibJS: Add preparation for Intl constructors and prototypes

Add a JS_ENUMERATE_INTL_OBJECTS macro and use it to generate:

- Forward declarations
- CommonPropertyNames class name members
- Constructor and prototype GlobalObject members, getters, visitors,
  and initialize_constructor() calls
This commit is contained in:
Linus Groh 2021-08-08 18:35:29 +01:00
parent a37dcf8ca7
commit 44a8b55c50
4 changed files with 44 additions and 0 deletions

View file

@ -154,6 +154,18 @@ void GlobalObject::initialize_global_object()
JS_ENUMERATE_BUILTIN_TYPES
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
if (!m_intl_##snake_name##_prototype) \
m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(*this, *this);
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
// Must be allocated before `Intl::Intl` below.
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
initialize_constructor(vm.names.ClassName, m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype);
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
if (!m_temporal_##snake_name##_prototype) \
m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(*this, *this);
@ -276,6 +288,12 @@ void GlobalObject::visit_edges(Visitor& visitor)
JS_ENUMERATE_BUILTIN_TYPES
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
visitor.visit(m_intl_##snake_name##_constructor); \
visitor.visit(m_intl_##snake_name##_prototype);
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
visitor.visit(m_temporal_##snake_name##_constructor); \
visitor.visit(m_temporal_##snake_name##_prototype);