[go: nahoru, domu]

Skip to content

Commit

Permalink
Deprecate Fmt_Newline note in favor of Fmt_New_Line (to be consistent…
Browse files Browse the repository at this point in the history
… with Fmt_Same_Line). Fmt_Newline will be removed in the future.
  • Loading branch information
ostef committed May 8, 2022
1 parent 8da8702 commit 758476a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion module.jai
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions tests/main.jai
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion write_any.jai
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 758476a

Please sign in to comment.