From 5e82bfadac1a9eb0e6a45c04ae55cac19e59ff18 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Thu, 21 Mar 2024 21:48:53 +0100 Subject: [PATCH] includes/std: Replace get_attribute_value with get_attribute_argument (#233) Update get_attribute_argument/get_attribute_value Replace std::core::get_attribute_value with std::core::get_attribute_argument Mark optional arguments with square brackets in the documentation comments, and list their default values --- includes/std/core.pat | 12 ++++++++++-- includes/std/math.pat | 6 +++--- includes/std/mem.pat | 4 ++-- includes/std/random.pat | 8 ++++---- includes/std/time.pat | 8 ++++---- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/includes/std/core.pat b/includes/std/core.pat index f44104c..31d416a 100644 --- a/includes/std/core.pat +++ b/includes/std/core.pat @@ -38,12 +38,20 @@ namespace auto std::core { }; /** - Returns the first parameter of the attribute of a pattern if it has one + Returns the nth parameter of the attribute of a pattern if it has one @param pattern The pattern to check @param attribute The attribute's name to query + @param [index] The parameter index of the attribute to return. Defaults to 0 + */ + fn get_attribute_argument(ref auto pattern, str attribute, u32 index = 0) { + return builtin::std::core::get_attribute_argument(pattern, attribute, index); + }; + + /** + @warning Removed in 1.27.0 */ fn get_attribute_value(ref auto pattern, str attribute) { - return builtin::std::core::get_attribute_value(pattern, attribute); + builtin::std::error("`std::core::get_attribute_value(pattern, attribute)` has been removed.\nUse `std::core::get_attribute_argument(pattern, attribute, [index])` instead."); }; diff --git a/includes/std/math.pat b/includes/std/math.pat index acc846f..baa7d75 100644 --- a/includes/std/math.pat +++ b/includes/std/math.pat @@ -328,9 +328,9 @@ namespace auto std::math { @param start Start address @param end End address @param valueSize Size of each value in bytes - @param section Section to use - @param operation Operation to use - @param endian Endianness to use + @param [section] Section to use + @param [operation] Operation to use. Defaults to addition + @param [endian] Endianness to use. Defaults to native @return Sum of all values in the specified memory range */ fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section = 0, AccumulateOperation operation = AccumulateOperation::Add, std::mem::Endian endian = std::mem::Endian::Native) { diff --git a/includes/std/mem.pat b/includes/std/mem.pat index d239cc4..c519a42 100644 --- a/includes/std/mem.pat +++ b/includes/std/mem.pat @@ -104,7 +104,7 @@ namespace auto std::mem { Reads a unsigned value from the memory @param address The address to read from @param size The size of the value to read - @param endian The endianess of the value to read + @param [endian] The endianess of the value to read. Defaults to native @return The value read */ fn read_unsigned(u128 address, u8 size, Endian endian = Endian::Native) { @@ -115,7 +115,7 @@ namespace auto std::mem { Reads a signed value from the memory @param address The address to read from @param size The size of the value to read - @param endian The endianess of the value to read + @param [endian] The endianess of the value to read. Defaults to native @return The value read */ fn read_signed(u128 address, u8 size, Endian endian = Endian::Native) { diff --git a/includes/std/random.pat b/includes/std/random.pat index a5bdb90..5dee371 100644 --- a/includes/std/random.pat +++ b/includes/std/random.pat @@ -61,8 +61,8 @@ namespace auto std::random { > - `Poisson(mean) -> i128` @param distribution Distribution to use - @param param1 This parameter depends on the type of distribution used. - @param param2 This parameter depends on the type of distribution used. + @param [param1] This parameter depends on the type of distribution used. Defaults to 0 + @param [param2] This parameter depends on the type of distribution used. Defaults to 0 */ fn generate_using(Distribution distribution, auto param1 = 0, auto param2 = 0) { return builtin::std::random::generate(u32(distribution), param1, param2); @@ -71,8 +71,8 @@ namespace auto std::random { /** Generates a uniformly distributed random number between `min` and `max` - @param min Minimum number - @param max Maximum number + @param [min] Minimum number. Defaults to 0 + @param [max] Maximum number. Defaults to `u64_max` */ fn generate(u64 min = std::limits::u64_min(), u64 max = std::limits::u64_max()) { return std::random::generate_using(Distribution::Uniform, min, max); diff --git a/includes/std/time.pat b/includes/std/time.pat index 243b4c8..2b8673d 100644 --- a/includes/std/time.pat +++ b/includes/std/time.pat @@ -113,7 +113,7 @@ namespace auto std::time { /** Queries the current time in the specified time zone. - @param time_zone The time zone to query. + @param [time_zone] The time zone to query. Defaults to local. @return The current time in the specified time zone. */ fn now(TimeZone time_zone = TimeZone::Local) { @@ -167,7 +167,7 @@ namespace auto std::time { /** Formats a time according to the specified format string. @param time The time to format. - @param format_string The format string to use. + @param [format_string] The format string to use. Defaults to "%c". @return The formatted time. */ fn format(Time time, str format_string = "%c") { @@ -180,7 +180,7 @@ namespace auto std::time { /** Formats a DOS date according to the specified format string. @param date The DOS date to format. - @param format_string The format string to use. + @param [format_string] The format string to use. Defaults to "{}/{}/{}". @return The formatted DOS date. */ fn format_dos_date(DOSDate date, str format_string = "{}/{}/{}") { @@ -190,7 +190,7 @@ namespace auto std::time { /** Formats a DOS time according to the specified format string. @param time The DOS time to format. - @param format_string The format string to use. + @param [format_string] The format string to use. Defaults to "{:02}:{:02}:{:02}". @return The formatted DOS time. */ fn format_dos_time(DOSTime time, str format_string = "{:02}:{:02}:{:02}") {