1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

LibWeb: Stop using Bindings::wrap() in generated code

This commit is contained in:
Andreas Kling 2022-09-04 21:55:35 +02:00
parent 9176a0de99
commit 266136b32f

View file

@ -1518,7 +1518,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
if (impl_is_wrapper(sequence_generic_type.parameters.first())) { if (impl_is_wrapper(sequence_generic_type.parameters.first())) {
scoped_generator.append(R"~~~( scoped_generator.append(R"~~~(
auto* wrapped_element@recursion_depth@ = wrap(realm, *element@recursion_depth@); auto* wrapped_element@recursion_depth@ = &(*element@recursion_depth@);
)~~~"); )~~~");
} else { } else {
generate_wrap_statement(scoped_generator, String::formatted("element{}", recursion_depth), sequence_generic_type.parameters.first(), interface, String::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1); generate_wrap_statement(scoped_generator, String::formatted("element{}", recursion_depth), sequence_generic_type.parameters.first(), interface, String::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1);
@ -1669,11 +1669,11 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
} else { } else {
if (wrapping_reference == WrappingReference::No) { if (wrapping_reference == WrappingReference::No) {
scoped_generator.append(R"~~~( scoped_generator.append(R"~~~(
@result_expression@ wrap(realm, const_cast<@type@&>(*@value@)); @result_expression@ &const_cast<@type@&>(*@value@);
)~~~"); )~~~");
} else { } else {
scoped_generator.append(R"~~~( scoped_generator.append(R"~~~(
@result_expression@ wrap(realm, const_cast<@type@&>(@value@)); @result_expression@ &const_cast<@type@&>(@value@);
)~~~"); )~~~");
} }
} }
@ -2064,7 +2064,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject
)~~~"); )~~~");
} }
generator.append(R"~~~( generator.append(R"~~~(
return wrap(realm, *impl); return &(*impl);
)~~~"); )~~~");
} else { } else {
// Multiple constructor overloads - can't do that yet. // Multiple constructor overloads - can't do that yet.
@ -2635,10 +2635,9 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::to_string)
iterator_generator.append(R"~~~( iterator_generator.append(R"~~~(
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::entries) JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::entries)
{ {
auto& realm = *vm.current_realm();
auto* impl = TRY(impl_from(vm)); auto* impl = TRY(impl_from(vm));
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue)); return @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue).ptr();
} }
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each) JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each)
@ -2665,18 +2664,16 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each)
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::keys) JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::keys)
{ {
auto& realm = *vm.current_realm();
auto* impl = TRY(impl_from(vm)); auto* impl = TRY(impl_from(vm));
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Key)); return @iterator_name@::create(*impl, Object::PropertyKind::Key).ptr();
} }
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::values) JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::values)
{ {
auto& realm = *vm.current_realm();
auto* impl = TRY(impl_from(vm)); auto* impl = TRY(impl_from(vm));
return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Value)); return @iterator_name@::create(*impl, Object::PropertyKind::Value).ptr();
} }
)~~~"); )~~~");
} }