diff options
author | Vas Crabb <vas@vastheman.com> | 2021-09-06 06:34:42 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2021-09-06 06:34:42 +1000 |
commit | 4f495994c41cd2fbaf89c08f755e828ae3261828 (patch) | |
tree | 8ea2c8522b807e394ea942460687b66e3ec7e381 /src/lib | |
parent | 5e02ff231e2472e7e75a97b6e8758a070b227f8e (diff) |
-ui: Made zoom controls a bit more intuitive.
* The UI controls are described as zoom in/out, but they had the
opposite effect on the palette and tile viewers. That has been
changed to make them consistent with the tilemap viewer.
* Made the default zoom key not act as a toggle. People are familiar
with the function of Ctrl+0/=/- in web browsers, so making them behave
similarly in MAME should make it more approachable. Also added the
default zoom key to the relevant documentation page.
* Implemented the default zoom key for the palette and tile viewers.
* In the tilemap viewer, if the view is in default expand to fit mode,
zoom in/out starting from the actual zoom ratio. Once again, this
behaves more like the zoom controls in a web browser displaying an
image so it should be more intuitive.
* Made more messages from the tilemap viewer localisable.
-util/zippath.cpp: Fixed MT08074.
* There were multiple issues at play here. After #8443 was applied,
is_root was simply never returning true on Windows, as OSD_WINDOWS
isn't actually defined outside libosd and libocore. This caused
phantom parent items to appear in disk roots on Windows, but it meant
that the check in zippath_resolve would always fail so the trailing
backslash would be trimmed. Fixing the macro test in is_root meant
the trailing backslash from C:\ would no longer be trimmed, which
caused the stat in zippath_resolve to fail.
-bigbord2.cpp: Hooked up floppy DRQ that had somehow got lost.
-Reduced tag map lookups in several drivers and devices.
-util/coretmpl.h: Removed an overload of bitswap that can be avoided
using if constexpr.
-Added doxygen comments to some classes, and fixed several doxygen
warnings.
-util, osd: Test for _WIN32 rather than WIN32.
* In C++17 mode, WIN32 is no longer a predefined macro, although various
things in 3rdparty define it to maintain legacy support. We're better
off moving forward anyway for when WIN32 disappears entirely. (WIN32
is not a reserved name, while _WIN32 is, starting with an underscore
follwed by an uppercase letter.)
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/formats/flopimg.h | 8 | ||||
-rw-r--r-- | src/lib/netlist/nl_config.h | 4 | ||||
-rw-r--r-- | src/lib/netlist/tests/test_pfunction.cpp | 2 | ||||
-rw-r--r-- | src/lib/util/bitmap.cpp | 2 | ||||
-rw-r--r-- | src/lib/util/chdcodec.cpp | 2 | ||||
-rw-r--r-- | src/lib/util/coretmpl.h | 19 | ||||
-rw-r--r-- | src/lib/util/ioprocs.h | 138 | ||||
-rw-r--r-- | src/lib/util/path.h | 40 | ||||
-rw-r--r-- | src/lib/util/unicode.cpp | 4 | ||||
-rw-r--r-- | src/lib/util/zippath.cpp | 20 |
10 files changed, 190 insertions, 49 deletions
diff --git a/src/lib/formats/flopimg.h b/src/lib/formats/flopimg.h index 6279def82f8..550c9a62fa8 100644 --- a/src/lib/formats/flopimg.h +++ b/src/lib/formats/flopimg.h @@ -734,9 +734,9 @@ public: //! floppy_image constructor /*! - @param _tracks number of tracks. - @param _heads number of heads. - @param _form_factor form factor of drive (from enum) + @param tracks number of tracks. + @param heads number of heads. + @param form_factor form factor of drive (from enum) */ floppy_image(int tracks, int heads, uint32_t form_factor); virtual ~floppy_image(); @@ -788,7 +788,7 @@ public: //! Returns the variant name for the particular disk form factor/variant //! @param form_factor //! @param variant - //! @param returns a string containing the variant name. + //! @return a string containing the variant name. static const char *get_variant_name(uint32_t form_factor, uint32_t variant); private: diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 76d1d40d530..8dad2b36cc2 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -192,8 +192,8 @@ namespace netlist /// /// This is the recommended clock to be used in fixed clock applications limited /// to 32 bit clock resolution. The MAME code (netlist.cpp) contains code - /// illustrating how to deal with remainders if \ref NETLIST_INTERNAL_RES is - /// bigger than NETLIST_CLOCK. + /// illustrating how to deal with remainders if \ref INTERNAL_RES is bigger than + /// NETLIST_CLOCK. using DEFAULT_CLOCK = std::integral_constant<int, 1'000'000'000>; // NOLINT /// \brief Default logic family diff --git a/src/lib/netlist/tests/test_pfunction.cpp b/src/lib/netlist/tests/test_pfunction.cpp index 3d251d620d0..c87671d8c7a 100644 --- a/src/lib/netlist/tests/test_pfunction.cpp +++ b/src/lib/netlist/tests/test_pfunction.cpp @@ -2,7 +2,7 @@ // copyright-holders:Couriersud /// -/// \file pfunction_test.cpp +/// \file test_pfunction.cpp /// /// tests for pfunction /// diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp index 9722fea7218..8757d928fff 100644 --- a/src/lib/util/bitmap.cpp +++ b/src/lib/util/bitmap.cpp @@ -415,7 +415,7 @@ void bitmap_t::set_palette(palette_t *palette) * -------------------------------------------------. * * @param color The color. - * @param cliprect The cliprect. + * @param bounds The bounds. */ void bitmap_t::fill(uint64_t color, const rectangle &bounds) diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp index eca9403b56c..cd708d0f507 100644 --- a/src/lib/util/chdcodec.cpp +++ b/src/lib/util/chdcodec.cpp @@ -771,7 +771,7 @@ chd_zlib_allocator::chd_zlib_allocator() //------------------------------------------------- -// ~chd_zlib_allocator - constructor +// ~chd_zlib_allocator - destructor //------------------------------------------------- chd_zlib_allocator::~chd_zlib_allocator() diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 18b64e7c0ff..49f01f8415c 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -610,20 +610,6 @@ template <typename T, typename U, typename V> constexpr T BIT(T x, U n, V w) } -/// \brief Extract and right-align a single bit field -/// -/// This overload is used to terminate a recursive template -/// implementation. It is functionally equivalent to the BIT -/// function for extracting a single bit. -/// -/// \param [in] val The integer to extract the bit from. -/// \param [in] b The bit to extract, where zero is the least -/// significant bit of the input. -/// \return The specified bit of the input extracted to the least -/// significant position. -template <typename T, typename U> constexpr T bitswap(T val, U b) noexcept { return BIT(val, b) << 0U; } - - /// \brief Extract bits in arbitrary order /// /// Extracts bits from an integer. Specify the bits in the order they @@ -641,7 +627,10 @@ template <typename T, typename U> constexpr T bitswap(T val, U b) noexcept { ret /// \return The extracted bits packed into a right-aligned field. template <typename T, typename U, typename... V> constexpr T bitswap(T val, U b, V... c) noexcept { - return (BIT(val, b) << sizeof...(c)) | bitswap(val, c...); + if constexpr (sizeof...(c)) + return (BIT(val, b) << sizeof...(c)) | bitswap(val, c...); + else + return BIT(val, b); } diff --git a/src/lib/util/ioprocs.h b/src/lib/util/ioprocs.h index 78c06e71318..0a4e5c384f0 100644 --- a/src/lib/util/ioprocs.h +++ b/src/lib/util/ioprocs.h @@ -27,6 +27,14 @@ class osd_file; namespace util { +/// \defgroup ioprocs Generic I/O interfaces +/// \{ + +/// \brief Interface to an input stream +/// +/// Represents a stream producing a sequence of bytes with no further +/// structure. +/// \sa write_stream read_write_stream random_read class read_stream { public: @@ -34,10 +42,29 @@ public: virtual ~read_stream() = default; + /// \brief Read from the current position in the stream + /// + /// Reads up to the specified number of bytes from the stream into + /// the supplied buffer. May read less than the requested number of + /// bytes if the end of the stream is reached or an error occurs. + /// If the stream supports seeking, reading starts at the current + /// position in the stream, and the current position is incremented + /// by the number of bytes read. + /// \param [out] buffer Destination buffer. Must be large enough to + /// hold the requested number of bytes. + /// \param [in] length Maximum number of bytes to read. + /// \param [out] actual Number of bytes actually read. Will always + /// be less than or equal to the requested length. + /// \return An error condition if reading stopped due to an error. virtual std::error_condition read(void *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to an output stream +/// +/// Represents a stream that accepts a sequence of bytes with no further +/// structure. +/// \sa read_stream read_write_stream random_write class write_stream { public: @@ -45,12 +72,43 @@ public: virtual ~write_stream() = default; + /// \brief Finish writing data + /// + /// Performs any tasks necessary to finish writing data to the + /// stream and guarantee that the written data can be read in its + /// entirety. Further writes may not be possible. + /// \return An error condition if the operation fails. virtual std::error_condition finalize() noexcept = 0; + + /// \brief Flush application-side caches + /// + /// Flushes any caches to the underlying stream. Success does not + /// guarantee that data has reached persistent storage. + /// \return An error condition if flushing caches fails. virtual std::error_condition flush() noexcept = 0; + + /// \brief Write at the current position in the stream + /// + /// Writes up to the specified number of bytes from the supplied + /// buffer to the stream. May write less than the requested number + /// of bytes if an error occurs. If the stream supports seeking, + /// writing starts at the current position in the stream, and the + /// current position is incremented by the number of bytes written. + /// \param [in] buffer Buffer containing the data to write. Must + /// contain at least the specified number of bytes. + /// \param [in] length Number of bytes to write. + /// \param [out] actual Number of bytes actually written. Will + /// always be less than or equal to the requested length. + /// \return An error condition if writing stopped due to an error. virtual std::error_condition write(void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to an I/O stream +/// +/// Represents an object that acts as both a source of and sink for byte +/// sequences. +/// \sa read_stream write_stream random_read_write class read_write_stream : public virtual read_stream, public virtual write_stream { public: @@ -58,41 +116,121 @@ public: }; +/// \brief Interface to a byte sequence that supports seeking +/// +/// Provides an interface for controlling the position within a byte +/// sequence that supports seeking. +/// \sa random_read random_write random_read_write class random_access { public: virtual ~random_access() = default; + /// \brief Set the position in the stream + /// + /// Sets the position for the next read or write operation. It may + /// be possible to set the position beyond the end of the stream. + /// \param [in] offset The offset in bytes, relative to the position + /// specified by the whence parameter. + /// \param [in] whence One of SEEK_SET, SEEK_CUR or SEEK_END, to + /// interpret the offset parameter relative to the beginning of + /// the stream, the current position in the stream, or the end of + /// the stream, respectively. + /// \return An error condition of the operation failed. virtual std::error_condition seek(std::int64_t offset, int whence) noexcept = 0; + + /// \brief Get the current position in the stream + /// + /// Gets the position in the stream for the next read or write + /// operation. The position may be beyond the end of the stream. + /// \param [out] result The position in bytes relative to the + /// beginning of the stream. Not valid if the operation fails. + /// \return An error condition if the operation failed. virtual std::error_condition tell(std::uint64_t &result) noexcept = 0; + + /// \brief Get the length of the stream + /// + /// Gets the current length of the stream. + /// \param [out] result The lenght of the stream in bytes. Not + /// valid if the operation fails. + /// \return An error condtion if the operation failed. virtual std::error_condition length(std::uint64_t &result) noexcept = 0; }; +/// \brief Interface to a random-access byte input sequence +/// +/// Provides an interface for reading from aritrary positions within a +/// byte sequence. No further structure is provided. +/// \sa read_stream random_write random_read_write class random_read : public virtual read_stream, public virtual random_access { public: using ptr = std::unique_ptr<random_read>; + /// \brief Read from specified position + /// + /// Reads up to the specified number of bytes into the supplied + /// buffer. If seeking is supported, reading starts at the + /// specified position and the current position is unaffected. May + /// read less than the requested number of bytes if the end of the + /// stream is encountered or an error occurs. + /// \param [in] offset The position to start reading from, specified + /// as a number of bytes from the beginning of the stream. + /// \param [out] buffer Destination buffer. Must be large enough to + /// hold the requested number of bytes. + /// \param [in] length Maximum number of bytes to read. + /// \param [out] actual Number of bytes actually read. Will always + /// be less than or equal to the requested length. + /// \return An error condition if seeking failed or reading stopped + /// due to an error. virtual std::error_condition read_at(std::uint64_t offset, void *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to a random-access byte output sequence +/// +/// Provides an interface for writing to arbitrary positions within a +/// byte sequence. No further structure is provided. +/// \sa write_stream random_read random_read_write class random_write : public virtual write_stream, public virtual random_access { public: using ptr = std::unique_ptr<random_write>; + /// \brief Write at specified position + /// + /// Writes up to the specified number of bytes from the supplied + /// buffer. If seeking is supported, writing starts at the + /// specified position and the current position is unaffected. May + /// write less than the requested number of bytes if an error + /// occurs. + /// \param [in] offset The position to start writing at, specified + /// as a number of bytes from the beginning of the stream. + /// \param [in] buffer Buffer containing the data to write. Must + /// contain at least the specified number of bytes. + /// \param [in] length Number of bytes to write. + /// \param [out] actual Number of bytes actually written. Will + /// always be less than or equal to the requested length. + /// \return An error condition if seeking failed or writing stopped + /// due to an error. virtual std::error_condition write_at(std::uint64_t offset, void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to a random-access read/write byte sequence +/// +/// Provides an interface for reading from and writing to arbitrary +/// positions within a byte sequence. No further structure is provided. +/// \sa random_read random_write read_write_stream class random_read_write : public read_write_stream, public virtual random_read, public virtual random_write { public: using ptr = std::unique_ptr<random_read_write>; }; +/// \} + random_read::ptr ram_read(void const *data, std::size_t size) noexcept; random_read::ptr ram_read(void const *data, std::size_t size, std::uint8_t filler) noexcept; diff --git a/src/lib/util/path.h b/src/lib/util/path.h index 1291d7b17d3..8638bcb332b 100644 --- a/src/lib/util/path.h +++ b/src/lib/util/path.h @@ -18,15 +18,19 @@ namespace util { -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -// is a given character a directory separator? - +/// \defgroup pathutils Filesystem path utilities +/// \{ + +/// \brief Is a character a directory separator? +/// +/// Determine whether a character is used to separate components within +/// a filesystem path. +/// \param [in] c A character to test. +/// \return True if the character is used to separate components in +/// filesystem paths. constexpr bool is_directory_separator(char c) { -#if defined(WIN32) +#if defined(_WIN32) return ('\\' == c) || ('/' == c) || (':' == c); #else return '/' == c; @@ -34,8 +38,15 @@ constexpr bool is_directory_separator(char c) } -// append to a path - +/// \brief Append components to a filesystem path +/// +/// Appends directory components to a filesystem path. +/// \param [in,out] path The path to append to. +/// \param [in] next The first directory component to append to the +/// path. +/// \param [in] more Additional directory components to append to the +/// path. +/// \return A reference to the modified path. template <typename T, typename... U> inline std::string &path_append(std::string &path, T &&next, U &&... more) { @@ -49,8 +60,13 @@ inline std::string &path_append(std::string &path, T &&next, U &&... more) } -// concatenate paths - +/// \brief Concatenate filsystem paths +/// +/// Concatenates multiple filesystem paths. +/// \param [in] first Initial filesystem path. +/// \param [in] more Additional directory components to append to the +/// intial path. +/// \return The concatenated filesystem path. template <typename T, typename... U> inline std::string path_concat(T &&first, U &&... more) { @@ -60,6 +76,8 @@ inline std::string path_concat(T &&first, U &&... more) return result; } +/// \} + } // namespace util #endif // MAME_LIB_UTIL_PATH_H diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index a375224fd1e..6787db4a501 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -457,7 +457,7 @@ int utf16f_from_uchar(char16_t *utf16string, size_t count, char32_t uchar) std::wstring wstring_from_utf8(const std::string &utf8string) { -#ifdef WIN32 +#ifdef _WIN32 // for some reason, using codecvt yields bad results on MinGW (but not MSVC) return osd::text::to_wstring(utf8string); #else @@ -473,7 +473,7 @@ std::wstring wstring_from_utf8(const std::string &utf8string) std::string utf8_from_wstring(const std::wstring &string) { -#ifdef WIN32 +#ifdef _WIN32 // for some reason, using codecvt yields bad results on MinGW (but not MSVC) return osd::text::from_wstring(string); #else diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 9d2e51a6833..6fad365d6fc 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -48,7 +48,7 @@ int is_path_separator(char c) bool is_root(std::string_view path) { -#if defined(WIN32) +#if defined(_WIN32) // FIXME: don't assume paths are DOS-like - UNC paths, \\?\ long path prefix, etc. complicate this // skip drive letter @@ -58,8 +58,7 @@ bool is_root(std::string_view path) // skip path separators return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #else - // FIXME: handle multiple successive path separators, current directory references, parent directory references - return (path.length() == 1) && (path[0] == '/'); + return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #endif } @@ -208,14 +207,11 @@ std::error_condition zippath_resolve(std::string_view path, osd::directory::entr bool went_up = false; do { - if (!is_root(apath)) - { - // trim the path of trailing path separators - auto i = apath.find_last_not_of(PATH_SEPARATOR); - if (i == std::string::npos) - break; - apath = apath.substr(0, i + 1); - } + // trim the path of trailing path separators + auto i = apath.find_last_not_of(PATH_SEPARATOR); + if (i == std::string::npos) + break; + apath = apath.erase(std::min<decltype(i)>(i + 1, 2)); apath_trimmed = apath; @@ -613,7 +609,7 @@ std::string &zippath_combine(std::string &dst, const std::string &path1, const s { dst.assign(path2); } - else if (!path1.empty() && !is_path_separator(*path1.rbegin())) + else if (!path1.empty() && !is_path_separator(path1.back())) { dst.assign(path1).append(PATH_SEPARATOR).append(path2); } |