2020-04-01 19:42:07 +01:00
|
|
|
/*
|
2021-04-22 22:51:19 +02:00
|
|
|
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
2020-04-01 19:42:07 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-01 19:42:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-04-10 12:42:33 +02:00
|
|
|
#include <LibJS/Runtime/Error.h>
|
2020-04-01 19:42:07 +01:00
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class ErrorConstructor final : public NativeFunction {
|
2020-06-21 15:14:02 +02:00
|
|
|
JS_OBJECT(ErrorConstructor, NativeFunction);
|
|
|
|
|
2020-04-01 19:42:07 +01:00
|
|
|
public:
|
2020-06-20 15:40:48 +02:00
|
|
|
explicit ErrorConstructor(GlobalObject&);
|
2020-07-22 17:50:18 +02:00
|
|
|
virtual void initialize(GlobalObject&) override;
|
2021-04-12 00:08:28 +02:00
|
|
|
virtual ~ErrorConstructor() override = default;
|
2020-04-01 19:42:07 +01:00
|
|
|
|
2020-09-27 17:24:14 +02:00
|
|
|
virtual Value call() override;
|
2021-06-27 21:48:34 +02:00
|
|
|
virtual Value construct(FunctionObject& new_target) override;
|
2020-04-01 19:42:07 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool has_constructor() const override { return true; }
|
|
|
|
};
|
|
|
|
|
2021-06-11 17:54:42 +01:00
|
|
|
#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
|
|
|
|
class ConstructorName final : public NativeFunction { \
|
|
|
|
JS_OBJECT(ConstructorName, NativeFunction); \
|
|
|
|
\
|
|
|
|
public: \
|
|
|
|
explicit ConstructorName(GlobalObject&); \
|
|
|
|
virtual void initialize(GlobalObject&) override; \
|
|
|
|
virtual ~ConstructorName() override; \
|
|
|
|
virtual Value call() override; \
|
2021-06-27 21:48:34 +02:00
|
|
|
virtual Value construct(FunctionObject& new_target) override; \
|
2021-06-11 17:54:42 +01:00
|
|
|
\
|
|
|
|
private: \
|
|
|
|
virtual bool has_constructor() const override { return true; } \
|
2020-04-10 12:42:33 +02:00
|
|
|
};
|
|
|
|
|
2020-12-01 21:05:25 +01:00
|
|
|
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
2021-06-11 17:54:42 +01:00
|
|
|
DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName)
|
|
|
|
JS_ENUMERATE_NATIVE_ERRORS
|
2020-04-10 14:06:52 +02:00
|
|
|
#undef __JS_ENUMERATE
|
2020-04-10 12:42:33 +02:00
|
|
|
|
2020-04-01 19:42:07 +01:00
|
|
|
}
|