mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibJS: Convert Error::create() to NonnullGCPtr
This commit is contained in:
parent
73efdb1cc4
commit
d21ac9d820
5 changed files with 41 additions and 41 deletions
|
@ -14,15 +14,15 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
Error* Error::create(Realm& realm)
|
||||
NonnullGCPtr<Error> Error::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
|
||||
return *realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
|
||||
}
|
||||
|
||||
Error* Error::create(Realm& realm, DeprecatedString const& message)
|
||||
NonnullGCPtr<Error> Error::create(Realm& realm, DeprecatedString const& message)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
auto* error = Error::create(realm);
|
||||
auto error = Error::create(realm);
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr);
|
||||
return error;
|
||||
|
@ -98,24 +98,24 @@ DeprecatedString Error::stack_string() const
|
|||
return stack_string_builder.build();
|
||||
}
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
ClassName* ClassName::create(Realm& realm) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
|
||||
} \
|
||||
\
|
||||
ClassName* ClassName::create(Realm& realm, DeprecatedString const& message) \
|
||||
{ \
|
||||
auto& vm = realm.vm(); \
|
||||
auto* error = ClassName::create(realm); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \
|
||||
return error; \
|
||||
} \
|
||||
\
|
||||
ClassName::ClassName(Object& prototype) \
|
||||
: Error(prototype) \
|
||||
{ \
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
|
||||
{ \
|
||||
return *realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
|
||||
} \
|
||||
\
|
||||
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, DeprecatedString const& message) \
|
||||
{ \
|
||||
auto& vm = realm.vm(); \
|
||||
auto error = ClassName::create(realm); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \
|
||||
return error; \
|
||||
} \
|
||||
\
|
||||
ClassName::ClassName(Object& prototype) \
|
||||
: Error(prototype) \
|
||||
{ \
|
||||
}
|
||||
|
||||
JS_ENUMERATE_NATIVE_ERRORS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue