From 758476a03faa9e293f77a3f6974ea91ca5bb20c3 Mon Sep 17 00:00:00 2001 From: ostef <47391841+ostef@users.noreply.github.com> Date: Sun, 8 May 2022 22:30:30 +0200 Subject: [PATCH] Deprecate Fmt_Newline note in favor of Fmt_New_Line (to be consistent with Fmt_Same_Line). Fmt_Newline will be removed in the future. --- README.md | 6 +++--- module.jai | 2 +- tests/main.jai | 12 ++++++------ write_any.jai | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 82dfbfa..a690cb0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ For aggregate types (arrays, structs), the formatting options are passed to the * `~`: for fixed and exponent form floating point numbers, leave trailing zeroes after decimal point. By default, trailing zeroes are trimmed, * `\\`: print escape sequences for non printable characters, * `'`: same as `\\`, but also print surrounding single quotes for characters, double quotes for strings, -* `$`: print on one line, for strings and characters, this is the same as the `\\` flag, ignoring `@Fmt_Newline` notes if found, +* `$`: print on one line, for strings and characters, this is the same as the `\\` flag, ignoring `@Fmt_New_Line` notes if found, * `,`: print on multiple lines, for arrays and structs types, if an `@Fmt_Same_Line` note is found, don't print a newline character, * `!`: print struct member names @@ -99,8 +99,8 @@ A byte value of 0 indicates that the end of the formatting have been reached. Th # Additional formatting options * `@Fmt_Ignore` note on struct members: do not print the struct member if this note is found, -* `@Fmt_Newline` note on struct members: if not nested, a newline will be printed after the member on which this note is on is printed. -An example of printing a nested struct member might be when printing an array of a struct type. When this is the case, `@Fmt_Newline` is ignored. +* `@Fmt_New_Line` note on struct members: if not nested, a newline will be printed after the member on which this note is on is printed. +An example of printing a nested struct member might be when printing an array of a struct type. When this is the case, `@Fmt_New_Line` is ignored. * `@Fmt_Same_Line` note on struct members: when the multi line `,` flag is used, don't print a newline after the member. * `@Fmt(...)` note on struct members: instead of passing the formatting options to the member, the formatting string inside the parentheses is used to format the struct member. The formatting string in this case cannot have an argument index and as such should not contain `:` to separate the argument index with the formatting options. It also cannot have `*` instead of numbers for width and precision. If the parentheses are not provided, the note is ignored. diff --git a/module.jai b/module.jai index 09f5eab..26aced9 100644 --- a/module.jai +++ b/module.jai @@ -121,7 +121,7 @@ Fmt_Flags :: enum_flags LEAVE_TRAILING_ZEROES :: 0x020; // For fixed and exponent form floating point numbers, leave trailing zeroes after decimal point PRINT_ESCAPE_SEQUENCES :: 0x040; // Print escape sequences for non printable characters QUOTED :: 0x080; // Surround with quotes for character or string specifiers, and print on one line - SINGLE_LINE :: 0x100; // Print on one line, making Fmt_Newline note do nothing + SINGLE_LINE :: 0x100; // Print on one line, making Fmt_New_Line note do nothing MULTI_LINE :: 0x200; // Print on multiple lines, unless we see a Fmt_Same_Line note PRINT_MEMBER_NAMES :: 0x400; // Print struct member names } diff --git a/tests/main.jai b/tests/main.jai index f5be08e..f659d0d 100644 --- a/tests/main.jai +++ b/tests/main.jai @@ -377,9 +377,9 @@ test_struct :: inline () -> ko : s64 Foo :: struct { - a : string; @Fmt_Newline - b : int; @Fmt_Newline - c : float; @Fmt_Newline + a : string; @Fmt_New_Line + b : int; @Fmt_New_Line + c : float; @Fmt_New_Line } ko += test_print ("{ \"Foo\\nBar\\nBaz\",\n 0,\n 1.234 }", "%", Foo.{ "Foo\nBar\nBaz", 0, 1.234 }); @@ -651,9 +651,9 @@ Test_Proc :: #type (int, *int, *Test_Enum, Test_Poly_Struct (Type, 500)) -> bool Mat3f :: struct { - r0c0 : f32; @Fmt_Same_Line r0c1 : f32; @Fmt_Same_Line r0c2 : f32; @Fmt_Newline - r1c0 : f32; @Fmt_Same_Line r1c1 : f32; @Fmt_Same_Line r1c2 : f32; @Fmt_Newline - r2c0 : f32; @Fmt_Same_Line r2c1 : f32; @Fmt_Same_Line r2c2 : f32; @Fmt_Newline + r0c0 : f32; @Fmt_Same_Line r0c1 : f32; @Fmt_Same_Line r0c2 : f32; @Fmt_New_Line + r1c0 : f32; @Fmt_Same_Line r1c1 : f32; @Fmt_Same_Line r1c2 : f32; @Fmt_New_Line + r2c0 : f32; @Fmt_Same_Line r2c1 : f32; @Fmt_Same_Line r2c2 : f32; @Fmt_New_Line #place r0c0; c0r0, c1r0, c2r0 : f32; diff --git a/write_any.jai b/write_any.jai index 1a31a04..993352f 100644 --- a/write_any.jai +++ b/write_any.jai @@ -210,7 +210,9 @@ write_struct :: (buffer : *$T, arg : Fmt_Arg (T), is_nested : bool) -> length : fmt_str.count -= 1; } } - else if note == "Fmt_Newline" + else if note == "Fmt_Newline" // @Cleanup (stefan): To be removed + found_newline_note = true; + else if note == "Fmt_New_Line" found_newline_note = true; else if note == "Fmt_Same_Line" found_same_line_note = true;