/* * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace JS { class ByteLength { public: static ByteLength auto_() { return { Auto {} }; } static ByteLength detached() { return { Detached {} }; } ByteLength(u32 length) : m_length(length) { } bool is_auto() const { return m_length.has(); } bool is_detached() const { return m_length.has(); } u32 length() const { VERIFY(m_length.has()); return m_length.get(); } private: struct Auto { }; struct Detached { }; using Length = Variant; ByteLength(Length length) : m_length(move(length)) { } Length m_length; }; }