LibJS: Add Handle::operator->()

This commit is contained in:
Andreas Kling 2021-12-09 18:30:29 +01:00
parent a1580a1d00
commit fed6a76990
Notes: sideshowbarker 2024-07-17 23:03:19 +09:00
2 changed files with 5 additions and 2 deletions

View file

@ -53,6 +53,9 @@ public:
bool is_null() const { return m_impl.is_null(); } bool is_null() const { return m_impl.is_null(); }
T* operator->() { return cell(); }
T const* operator->() const { return cell(); }
private: private:
explicit Handle(NonnullRefPtr<HandleImpl> impl) explicit Handle(NonnullRefPtr<HandleImpl> impl)
: m_impl(move(impl)) : m_impl(move(impl))

View file

@ -388,7 +388,7 @@ ThrowCompletionOr<BalancedDuration> balance_duration(GlobalObject& global_object
days = result.days; days = result.days;
// c. Set nanoseconds to result.[[Nanoseconds]]. // c. Set nanoseconds to result.[[Nanoseconds]].
total_nanoseconds = result.nanoseconds.cell()->big_integer(); total_nanoseconds = result.nanoseconds->big_integer();
} }
// 5. Else, // 5. Else,
else { else {
@ -1238,7 +1238,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto result = TRY(nanoseconds_to_days(global_object, *nanoseconds_bigint, intermediate)); auto result = TRY(nanoseconds_to_days(global_object, *nanoseconds_bigint, intermediate));
// e. Set days to days + result.[[Days]] + result.[[Nanoseconds]] / result.[[DayLength]]. // e. Set days to days + result.[[Days]] + result.[[Nanoseconds]] / result.[[DayLength]].
auto nanoseconds_division_result = result.nanoseconds.cell()->big_integer().divided_by(Crypto::UnsignedBigInteger::create_from((u64)result.day_length)); auto nanoseconds_division_result = result.nanoseconds->big_integer().divided_by(Crypto::UnsignedBigInteger::create_from((u64)result.day_length));
days += result.days + nanoseconds_division_result.quotient.to_double() + nanoseconds_division_result.remainder.to_double() / result.day_length; days += result.days + nanoseconds_division_result.quotient.to_double() + nanoseconds_division_result.remainder.to_double() / result.day_length;
// f. Set hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0. // f. Set hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.