mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:08:12 +00:00
LibJS: Use enumerator macros for boilerplate code around native types
This commit is contained in:
parent
0bdfb952c5
commit
cb0dfd8f72
11 changed files with 124 additions and 170 deletions
|
@ -40,16 +40,16 @@ Error::~Error()
|
|||
{
|
||||
}
|
||||
|
||||
#define __JS_ENUMERATE_ERROR_SUBCLASS(TitleCase, snake_case) \
|
||||
TitleCase::TitleCase(const String& message) \
|
||||
: Error(#TitleCase, message) \
|
||||
{ \
|
||||
set_prototype(interpreter().snake_case##_prototype()); \
|
||||
} \
|
||||
TitleCase::~TitleCase() {} \
|
||||
const char* TitleCase::class_name() const { return #TitleCase; }
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
|
||||
ClassName::ClassName(const String& message) \
|
||||
: Error(#ClassName, message) \
|
||||
{ \
|
||||
set_prototype(interpreter().snake_name##_prototype()); \
|
||||
} \
|
||||
ClassName::~ClassName() {} \
|
||||
const char* ClassName::class_name() const { return #ClassName; }
|
||||
|
||||
JS_ENUMERATE_ERROR_SUBCLASSES
|
||||
#undef __JS_ENUMERATE_ERROR_SUBCLASS
|
||||
#undef __JS_ENUMERATE
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue