From 64ae99f016998fe78a5a0304767463c46050567a Mon Sep 17 00:00:00 2001 From: VladPavliuk Date: Sat, 13 Jul 2024 14:13:59 +0300 Subject: Add support of `ignore` tag for `json.marshal` --- tests/core/encoding/json/test_core_json.odin | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/core/encoding') diff --git a/tests/core/encoding/json/test_core_json.odin b/tests/core/encoding/json/test_core_json.odin index 92c050952..9fde5a443 100644 --- a/tests/core/encoding/json/test_core_json.odin +++ b/tests/core/encoding/json/test_core_json.odin @@ -368,4 +368,25 @@ utf8_string_of_multibyte_characters :: proc(t: ^testing.T) { val, err := json.parse_string(`"🐛✅"`) defer json.destroy_value(val) testing.expectf(t, err == nil, "Expected `json.parse` to return nil, got %v", err) +} + +@test +struct_with_ignore_tags :: proc(t: ^testing.T) { + My_Struct :: struct { + a: string `json:"_,ignore"`, + } + + my_struct := My_Struct{ + a = "test", + } + + my_struct_marshaled, marshal_err := json.marshal(my_struct) + defer delete(my_struct_marshaled) + + testing.expectf(t, marshal_err == nil, "Expected `json.marshal` to return nil error, got %v", marshal_err) + + my_struct_json := transmute(string)my_struct_marshaled + expected_json := `{}` + + testing.expectf(t, expected_json == my_struct_json, "Expected `json.marshal` to return %s, got %s", expected_json, my_struct_json) } \ No newline at end of file -- cgit v1.2.3 From 76fe5d1346e623b535d5168ec36e1254ef769c68 Mon Sep 17 00:00:00 2001 From: VladPavliuk Date: Sun, 14 Jul 2024 00:21:05 +0300 Subject: Align ignore syntax of json tags with fmt, cbor --- core/encoding/json/marshal.odin | 9 ++++++--- tests/core/encoding/json/test_core_json.odin | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/core/encoding') diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 99ae81485..30426f911 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -406,16 +406,19 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: ti := runtime.type_info_base(type_info_of(v.id)) info := ti.variant.(runtime.Type_Info_Struct) first_iteration := true - fields_loop: for name, i in info.names { + for name, i in info.names { omitempty := false json_name, extra := json_name_from_tag_value(reflect.struct_tag_get(reflect.Struct_Tag(info.tags[i]), "json")) + + if json_name == "-" { + continue + } + for flag in strings.split_iterator(&extra, ",") { switch flag { case "omitempty": omitempty = true - case "ignore": - continue fields_loop } } diff --git a/tests/core/encoding/json/test_core_json.odin b/tests/core/encoding/json/test_core_json.odin index 9fde5a443..a50dd7fe0 100644 --- a/tests/core/encoding/json/test_core_json.odin +++ b/tests/core/encoding/json/test_core_json.odin @@ -373,7 +373,7 @@ utf8_string_of_multibyte_characters :: proc(t: ^testing.T) { @test struct_with_ignore_tags :: proc(t: ^testing.T) { My_Struct :: struct { - a: string `json:"_,ignore"`, + a: string `json:"-"`, } my_struct := My_Struct{ -- cgit v1.2.3 From c7bd9547529a4957e56c7302c5eaca650258ecdc Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 14 Jul 2024 11:56:04 +0100 Subject: Add more uses of `#no_capture` --- base/runtime/core_builtin.odin | 14 ++++++------ base/runtime/core_builtin_soa.odin | 6 ++--- base/runtime/print.odin | 4 ++-- core/container/small_array/small_array.odin | 2 +- core/encoding/xml/tokenizer.odin | 6 ++--- core/log/log.odin | 32 +++++++++++++-------------- core/math/big/helpers.odin | 10 ++++----- core/math/big/internal.odin | 8 +++---- core/odin/parser/parser.odin | 12 +++++----- core/odin/tokenizer/tokenizer.odin | 6 ++--- core/testing/testing.odin | 10 ++++----- core/text/scanner/scanner.odin | 2 +- core/text/table/table.odin | 2 +- core/unicode/tools/generate_entity_table.odin | 2 +- tests/core/encoding/xml/test_core_xml.odin | 2 +- tests/core/fmt/test_core_fmt.odin | 2 +- tests/documentation/documentation_tester.odin | 2 +- vendor/OpenGL/wrappers.odin | 2 +- vendor/raylib/raylib.odin | 4 ++-- 19 files changed, 64 insertions(+), 64 deletions(-) (limited to 'tests/core/encoding') diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin index ff87316f2..5f6e1ec16 100644 --- a/base/runtime/core_builtin.odin +++ b/base/runtime/core_builtin.odin @@ -484,7 +484,7 @@ non_zero_append_elem :: proc(array: ^$T/[dynamic]$E, #no_broadcast arg: E, loc : return _append_elem(array, arg, false, loc=loc) } -_append_elems :: #force_inline proc(array: ^$T/[dynamic]$E, should_zero: bool, loc := #caller_location, args: ..E) -> (n: int, err: Allocator_Error) #optional_allocator_error { +_append_elems :: #force_inline proc(array: ^$T/[dynamic]$E, should_zero: bool, loc := #caller_location, args: []E) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { return 0, nil } @@ -524,13 +524,13 @@ _append_elems :: #force_inline proc(array: ^$T/[dynamic]$E, should_zero: bool, l } @builtin -append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { - return _append_elems(array, true, loc, ..args) +append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { + return _append_elems(array, true, loc, args) } @builtin -non_zero_append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { - return _append_elems(array, false, loc, ..args) +non_zero_append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { + return _append_elems(array, false, loc, args) } // The append_string built-in procedure appends a string to the end of a [dynamic]u8 like type @@ -617,7 +617,7 @@ inject_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast arg: E, } @builtin -inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { +inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if array == nil { return } @@ -679,7 +679,7 @@ assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle @builtin -assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { +assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { new_size := index + len(args) if len(args) == 0 { ok = true diff --git a/base/runtime/core_builtin_soa.odin b/base/runtime/core_builtin_soa.odin index f1b17cbef..108183ea6 100644 --- a/base/runtime/core_builtin_soa.odin +++ b/base/runtime/core_builtin_soa.odin @@ -342,17 +342,17 @@ _append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broa } @builtin -append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_soa_elems(array, true, args=args, loc=loc) } @builtin -non_zero_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +non_zero_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_soa_elems(array, false, args=args, loc=loc) } -_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broadcast args: []E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { return } diff --git a/base/runtime/print.odin b/base/runtime/print.odin index 0262e8ef6..ecd301d21 100644 --- a/base/runtime/print.odin +++ b/base/runtime/print.odin @@ -72,7 +72,7 @@ when !ODIN_NO_RTTI { print_string("") } } - println_any :: #force_no_inline proc "contextless" (args: ..any) { + println_any :: #force_no_inline proc "contextless" (#no_capture args: ..any) { context = default_context() loop: for arg, i in args { assert(arg.id != nil) @@ -127,7 +127,7 @@ print_string :: #force_no_inline proc "contextless" (str: string) -> (n: int) { return } -print_strings :: #force_no_inline proc "contextless" (args: ..string) -> (n: int) { +print_strings :: #force_no_inline proc "contextless" (#no_capture args: ..string) -> (n: int) { for str in args { m, err := stderr_write(transmute([]byte)str) n += m diff --git a/core/container/small_array/small_array.odin b/core/container/small_array/small_array.odin index b2068469d..a698d965c 100644 --- a/core/container/small_array/small_array.odin +++ b/core/container/small_array/small_array.odin @@ -139,7 +139,7 @@ clear :: proc "contextless" (a: ^$A/Small_Array($N, $T)) { resize(a, 0) } -push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), items: ..T) { +push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), #no_capture items: ..T) { n := copy(a.data[a.len:], items[:]) a.len += n } diff --git a/core/encoding/xml/tokenizer.odin b/core/encoding/xml/tokenizer.odin index a2bbaf28e..8a26f1bce 100644 --- a/core/encoding/xml/tokenizer.odin +++ b/core/encoding/xml/tokenizer.odin @@ -17,7 +17,7 @@ import "core:fmt" import "core:unicode" import "core:unicode/utf8" -Error_Handler :: #type proc(pos: Pos, fmt: string, args: ..any) +Error_Handler :: #type proc(pos: Pos, fmt: string, #no_capture args: ..any) Token :: struct { kind: Token_Kind, @@ -112,13 +112,13 @@ offset_to_pos :: proc(t: ^Tokenizer, offset: int) -> Pos { } } -default_error_handler :: proc(pos: Pos, msg: string, args: ..any) { +default_error_handler :: proc(pos: Pos, msg: string, #no_capture args: ..any) { fmt.eprintf("%s(%d:%d) ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -error :: proc(t: ^Tokenizer, offset: int, msg: string, args: ..any) { +error :: proc(t: ^Tokenizer, offset: int, msg: string, #no_capture args: ..any) { pos := offset_to_pos(t, offset) if t.err != nil { t.err(pos, msg, ..args) diff --git a/core/log/log.odin b/core/log/log.odin index 0d89fdb74..35dff086f 100644 --- a/core/log/log.odin +++ b/core/log/log.odin @@ -75,43 +75,43 @@ nil_logger :: proc() -> Logger { return Logger{nil_logger_proc, nil, Level.Debug, nil} } -debugf :: proc(fmt_str: string, args: ..any, location := #caller_location) { +debugf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { logf(.Debug, fmt_str, ..args, location=location) } -infof :: proc(fmt_str: string, args: ..any, location := #caller_location) { +infof :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { logf(.Info, fmt_str, ..args, location=location) } -warnf :: proc(fmt_str: string, args: ..any, location := #caller_location) { +warnf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { logf(.Warning, fmt_str, ..args, location=location) } -errorf :: proc(fmt_str: string, args: ..any, location := #caller_location) { +errorf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { logf(.Error, fmt_str, ..args, location=location) } -fatalf :: proc(fmt_str: string, args: ..any, location := #caller_location) { +fatalf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { logf(.Fatal, fmt_str, ..args, location=location) } -debug :: proc(args: ..any, sep := " ", location := #caller_location) { +debug :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { log(.Debug, ..args, sep=sep, location=location) } -info :: proc(args: ..any, sep := " ", location := #caller_location) { +info :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { log(.Info, ..args, sep=sep, location=location) } -warn :: proc(args: ..any, sep := " ", location := #caller_location) { +warn :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { log(.Warning, ..args, sep=sep, location=location) } -error :: proc(args: ..any, sep := " ", location := #caller_location) { +error :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { log(.Error, ..args, sep=sep, location=location) } -fatal :: proc(args: ..any, sep := " ", location := #caller_location) { +fatal :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { log(.Fatal, ..args, sep=sep, location=location) } -panic :: proc(args: ..any, location := #caller_location) -> ! { +panic :: proc(#no_capture args: ..any, location := #caller_location) -> ! { log(.Fatal, ..args, location=location) runtime.panic("log.panic", location) } -panicf :: proc(fmt_str: string, args: ..any, location := #caller_location) -> ! { +panicf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) -> ! { logf(.Fatal, fmt_str, ..args, location=location) runtime.panic("log.panicf", location) } @@ -133,14 +133,14 @@ assert :: proc(condition: bool, message := "", loc := #caller_location) { } @(disabled=ODIN_DISABLE_ASSERT) -assertf :: proc(condition: bool, fmt_str: string, args: ..any, loc := #caller_location) { +assertf :: proc(condition: bool, fmt_str: string, #no_capture args: ..any, loc := #caller_location) { if !condition { // NOTE(dragos): We are using the same trick as in builtin.assert // to improve performance to make the CPU not // execute speculatively, making it about an order of // magnitude faster @(cold) - internal :: proc(loc: runtime.Source_Code_Location, fmt_str: string, args: ..any) { + internal :: proc(loc: runtime.Source_Code_Location, fmt_str: string, #no_capture args: ..any) { p := context.assertion_failure_proc if p == nil { p = runtime.default_assertion_failure_proc @@ -155,7 +155,7 @@ assertf :: proc(condition: bool, fmt_str: string, args: ..any, loc := #caller_lo -log :: proc(level: Level, args: ..any, sep := " ", location := #caller_location) { +log :: proc(level: Level, #no_capture args: ..any, sep := " ", location := #caller_location) { logger := context.logger if logger.procedure == nil { return @@ -167,7 +167,7 @@ log :: proc(level: Level, args: ..any, sep := " ", location := #caller_location) logger.procedure(logger.data, level, str, logger.options, location) } -logf :: proc(level: Level, fmt_str: string, args: ..any, location := #caller_location) { +logf :: proc(level: Level, fmt_str: string, #no_capture args: ..any, location := #caller_location) { logger := context.logger if logger.procedure == nil { return diff --git a/core/math/big/helpers.odin b/core/math/big/helpers.odin index ee09bb2c7..c82b5eead 100644 --- a/core/math/big/helpers.odin +++ b/core/math/big/helpers.odin @@ -404,7 +404,7 @@ clear_if_uninitialized_single :: proc(arg: ^Int, allocator := context.allocator) return #force_inline internal_clear_if_uninitialized_single(arg, allocator) } -clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context.allocator) -> (err: Error) { +clear_if_uninitialized_multi :: proc(#no_capture args: ..^Int, allocator := context.allocator) -> (err: Error) { args := args assert_if_nil(..args) @@ -420,7 +420,7 @@ error_if_immutable_single :: proc(arg: ^Int) -> (err: Error) { return nil } -error_if_immutable_multi :: proc(args: ..^Int) -> (err: Error) { +error_if_immutable_multi :: proc(#no_capture args: ..^Int) -> (err: Error) { for i in args { if i != nil && .Immutable in i.flags { return .Assignment_To_Immutable } } @@ -431,7 +431,7 @@ error_if_immutable :: proc {error_if_immutable_single, error_if_immutable_multi, /* Allocates several `Int`s at once. */ -int_init_multi :: proc(integers: ..^Int, allocator := context.allocator) -> (err: Error) { +int_init_multi :: proc(#no_capture integers: ..^Int, allocator := context.allocator) -> (err: Error) { assert_if_nil(..integers) integers := integers @@ -812,13 +812,13 @@ assert_if_nil :: proc{ assert_if_nil_rat, } -assert_if_nil_int :: #force_inline proc(integers: ..^Int, loc := #caller_location) { +assert_if_nil_int :: #force_inline proc(#no_capture integers: ..^Int, loc := #caller_location) { for i in integers { assert(i != nil, "(nil)", loc) } } -assert_if_nil_rat :: #force_inline proc(rationals: ..^Rat, loc := #caller_location) { +assert_if_nil_rat :: #force_inline proc(#no_capture rationals: ..^Rat, loc := #caller_location) { for r in rationals { assert(r != nil, "(nil)", loc) } diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin index c9b331e55..9eaa0c8e1 100644 --- a/core/math/big/internal.odin +++ b/core/math/big/internal.odin @@ -1844,7 +1844,7 @@ internal_root_n :: proc { internal_int_root_n, } Deallocates the backing memory of one or more `Int`s. Asssumes none of the `integers` to be a `nil`. */ -internal_int_destroy :: proc(integers: ..^Int) { +internal_int_destroy :: proc(#no_capture integers: ..^Int) { integers := integers for &a in integers { @@ -2872,7 +2872,7 @@ internal_clear_if_uninitialized_single :: proc(arg: ^Int, allocator := context.a return err } -internal_clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context.allocator) -> (err: Error) { +internal_clear_if_uninitialized_multi :: proc(#no_capture args: ..^Int, allocator := context.allocator) -> (err: Error) { context.allocator = allocator for i in args { @@ -2890,7 +2890,7 @@ internal_error_if_immutable_single :: proc(arg: ^Int) -> (err: Error) { return nil } -internal_error_if_immutable_multi :: proc(args: ..^Int) -> (err: Error) { +internal_error_if_immutable_multi :: proc(#no_capture args: ..^Int) -> (err: Error) { for i in args { if i != nil && .Immutable in i.flags { return .Assignment_To_Immutable } } @@ -2901,7 +2901,7 @@ internal_error_if_immutable :: proc {internal_error_if_immutable_single, interna /* Allocates several `Int`s at once. */ -internal_int_init_multi :: proc(integers: ..^Int, allocator := context.allocator) -> (err: Error) { +internal_int_init_multi :: proc(#no_capture integers: ..^Int, allocator := context.allocator) -> (err: Error) { context.allocator = allocator integers := integers diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index dec892f84..3ae3b5dba 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -5,8 +5,8 @@ import "core:odin/tokenizer" import "core:fmt" -Warning_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, args: ..any) -Error_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, args: ..any) +Warning_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, #no_capture args: ..any) +Error_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, #no_capture args: ..any) Flag :: enum u32 { Optional_Semicolons, @@ -67,25 +67,25 @@ Import_Decl_Kind :: enum { -default_warning_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { +default_warning_handler :: proc(pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { fmt.eprintf("%s(%d:%d): Warning: ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -default_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { +default_error_handler :: proc(pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { fmt.eprintf("%s(%d:%d): ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -warn :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, args: ..any) { +warn :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { if p.warn != nil { p.warn(pos, msg, ..args) } p.file.syntax_warning_count += 1 } -error :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, args: ..any) { +error :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { if p.err != nil { p.err(pos, msg, ..args) } diff --git a/core/odin/tokenizer/tokenizer.odin b/core/odin/tokenizer/tokenizer.odin index 62170aa10..c5992e5f4 100644 --- a/core/odin/tokenizer/tokenizer.odin +++ b/core/odin/tokenizer/tokenizer.odin @@ -4,7 +4,7 @@ import "core:fmt" import "core:unicode" import "core:unicode/utf8" -Error_Handler :: #type proc(pos: Pos, fmt: string, args: ..any) +Error_Handler :: #type proc(pos: Pos, fmt: string, #no_capture args: ..any) Flag :: enum { Insert_Semicolon, @@ -62,13 +62,13 @@ offset_to_pos :: proc(t: ^Tokenizer, offset: int) -> Pos { } } -default_error_handler :: proc(pos: Pos, msg: string, args: ..any) { +default_error_handler :: proc(pos: Pos, msg: string, #no_capture args: ..any) { fmt.eprintf("%s(%d:%d) ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -error :: proc(t: ^Tokenizer, offset: int, msg: string, args: ..any) { +error :: proc(t: ^Tokenizer, offset: int, msg: string, #no_capture args: ..any) { pos := offset_to_pos(t, offset) if t.err != nil { t.err(pos, msg, ..args) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index 29fe853ef..04dc79095 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -53,12 +53,12 @@ T :: struct { @(deprecated="prefer `log.error`") -error :: proc(t: ^T, args: ..any, loc := #caller_location) { +error :: proc(t: ^T, #no_capture args: ..any, loc := #caller_location) { pkg_log.error(..args, location = loc) } @(deprecated="prefer `log.errorf`") -errorf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { +errorf :: proc(t: ^T, format: string, #no_capture args: ..any, loc := #caller_location) { pkg_log.errorf(format, ..args, location = loc) } @@ -87,12 +87,12 @@ failed :: proc(t: ^T) -> bool { } @(deprecated="prefer `log.info`") -log :: proc(t: ^T, args: ..any, loc := #caller_location) { +log :: proc(t: ^T, #no_capture args: ..any, loc := #caller_location) { pkg_log.info(..args, location = loc) } @(deprecated="prefer `log.infof`") -logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { +logf :: proc(t: ^T, format: string, #no_capture args: ..any, loc := #caller_location) { pkg_log.infof(format, ..args, location = loc) } @@ -121,7 +121,7 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo return ok } -expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool { +expectf :: proc(t: ^T, ok: bool, format: string, #no_capture args: ..any, loc := #caller_location) -> bool { if !ok { pkg_log.errorf(format, ..args, location=loc) } diff --git a/core/text/scanner/scanner.odin b/core/text/scanner/scanner.odin index d27c66f24..6eb366b49 100644 --- a/core/text/scanner/scanner.odin +++ b/core/text/scanner/scanner.odin @@ -250,7 +250,7 @@ error :: proc(s: ^Scanner, msg: string) { } } -errorf :: proc(s: ^Scanner, format: string, args: ..any) { +errorf :: proc(s: ^Scanner, format: string, #no_capture args: ..any) { error(s, fmt.tprintf(format, ..args)) } diff --git a/core/text/table/table.odin b/core/text/table/table.odin index 27c99b1f1..4d0baef64 100644 --- a/core/text/table/table.odin +++ b/core/text/table/table.odin @@ -145,7 +145,7 @@ set_cell_value_and_alignment :: proc(tbl: ^Table, row, col: int, value: any, ali cell.alignment = alignment } -format :: proc(tbl: ^Table, _fmt: string, args: ..any) -> string { +format :: proc(tbl: ^Table, _fmt: string, #no_capture args: ..any) -> string { context.allocator = tbl.format_allocator return fmt.aprintf(_fmt, ..args) } diff --git a/core/unicode/tools/generate_entity_table.odin b/core/unicode/tools/generate_entity_table.odin index 16baa1adf..238a3e219 100644 --- a/core/unicode/tools/generate_entity_table.odin +++ b/core/unicode/tools/generate_entity_table.odin @@ -12,7 +12,7 @@ import "core:fmt" /* Silent error handler for the parser. */ -Error_Handler :: proc(pos: xml.Pos, fmt: string, args: ..any) {} +Error_Handler :: proc(pos: xml.Pos, fmt: string, #no_capture args: ..any) {} OPTIONS :: xml.Options{ flags = { .Ignore_Unsupported, }, expected_doctype = "unicode", } diff --git a/tests/core/encoding/xml/test_core_xml.odin b/tests/core/encoding/xml/test_core_xml.odin index b29431e10..811ee27dc 100644 --- a/tests/core/encoding/xml/test_core_xml.odin +++ b/tests/core/encoding/xml/test_core_xml.odin @@ -8,7 +8,7 @@ import "core:fmt" import "core:log" import "core:hash" -Silent :: proc(pos: xml.Pos, format: string, args: ..any) {} +Silent :: proc(pos: xml.Pos, format: string, #no_capture args: ..any) {} OPTIONS :: xml.Options{ flags = { .Ignore_Unsupported, .Intern_Comments, }, expected_doctype = "", diff --git a/tests/core/fmt/test_core_fmt.odin b/tests/core/fmt/test_core_fmt.odin index 49142e24d..0aaef93a4 100644 --- a/tests/core/fmt/test_core_fmt.odin +++ b/tests/core/fmt/test_core_fmt.odin @@ -373,7 +373,7 @@ test_odin_value_export :: proc(t: ^testing.T) { } @(private) -check :: proc(t: ^testing.T, exp: string, format: string, args: ..any, loc := #caller_location) { +check :: proc(t: ^testing.T, exp: string, format: string, #no_capture args: ..any, loc := #caller_location) { got := fmt.tprintf(format, ..args) testing.expectf(t, got == exp, "(%q, %v): %q != %q", format, args, got, exp, loc = loc) } diff --git a/tests/documentation/documentation_tester.odin b/tests/documentation/documentation_tester.odin index 8a798d6c5..7fc37b9f0 100644 --- a/tests/documentation/documentation_tester.odin +++ b/tests/documentation/documentation_tester.odin @@ -51,7 +51,7 @@ common_prefix :: proc(strs: []string) -> string { return prefix } -errorf :: proc(format: string, args: ..any) -> ! { +errorf :: proc(format: string, #no_capture args: ..any) -> ! { fmt.eprintf("%s ", os.args[0]) fmt.eprintf(format, ..args) fmt.eprintln() diff --git a/vendor/OpenGL/wrappers.odin b/vendor/OpenGL/wrappers.odin index 1eb8fc72f..971452be5 100644 --- a/vendor/OpenGL/wrappers.odin +++ b/vendor/OpenGL/wrappers.odin @@ -754,7 +754,7 @@ when !GL_DEBUG { MultiDrawElementsIndirectCount :: proc "c" (mode: i32, type: i32, indirect: [^]DrawElementsIndirectCommand, drawcount: i32, maxdrawcount, stride: i32) { impl_MultiDrawElementsIndirectCount(mode, type, indirect, drawcount, maxdrawcount, stride) } PolygonOffsetClamp :: proc "c" (factor, units, clamp: f32) { impl_PolygonOffsetClamp(factor, units, clamp) } } else { - debug_helper :: proc"c"(from_loc: runtime.Source_Code_Location, num_ret: int, args: ..any, loc := #caller_location) { + debug_helper :: proc"c"(from_loc: runtime.Source_Code_Location, num_ret: int, #no_capture args: ..any, loc := #caller_location) { context = runtime.default_context() Error_Enum :: enum { diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index 3d1b74058..c2995ba36 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -1667,7 +1667,7 @@ IsGestureDetected :: proc "c" (gesture: Gesture) -> bool { // Text formatting with variables (sprintf style) -TextFormat :: proc(text: cstring, args: ..any) -> cstring { +TextFormat :: proc(text: cstring, #no_capture args: ..any) -> cstring { @static buffers: [MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH]byte @static index: u32 @@ -1683,7 +1683,7 @@ TextFormat :: proc(text: cstring, args: ..any) -> cstring { } // Text formatting with variables (sprintf style) and allocates (must be freed with 'MemFree') -TextFormatAlloc :: proc(text: cstring, args: ..any) -> cstring { +TextFormatAlloc :: proc(text: cstring, #no_capture args: ..any) -> cstring { str := fmt.tprintf(string(text), ..args) return strings.clone_to_cstring(str, MemAllocator()) } -- cgit v1.2.3 From 8642d719f0ece3625d535d47b41ff4d35072f47f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 14 Jul 2024 12:19:47 +0100 Subject: Imply `#no_capture` to all variadic parameters --- base/runtime/core_builtin.odin | 8 ++-- base/runtime/core_builtin_soa.odin | 4 +- base/runtime/print.odin | 4 +- core/container/small_array/small_array.odin | 2 +- core/encoding/xml/tokenizer.odin | 6 +-- core/fmt/fmt.odin | 58 +++++++++++++-------------- core/fmt/fmt_js.odin | 24 +++++------ core/fmt/fmt_os.odin | 24 +++++------ core/log/log.odin | 32 +++++++-------- core/math/big/helpers.odin | 10 ++--- core/math/big/internal.odin | 8 ++-- core/odin/parser/parser.odin | 12 +++--- core/odin/tokenizer/tokenizer.odin | 6 +-- core/testing/testing.odin | 10 ++--- core/text/scanner/scanner.odin | 2 +- core/text/table/table.odin | 2 +- core/unicode/tools/generate_entity_table.odin | 2 +- src/check_type.cpp | 10 ++++- src/llvm_backend.hpp | 1 - src/parser.hpp | 5 ++- tests/core/encoding/xml/test_core_xml.odin | 2 +- tests/core/fmt/test_core_fmt.odin | 2 +- tests/documentation/documentation_tester.odin | 2 +- vendor/OpenGL/wrappers.odin | 2 +- vendor/raylib/raylib.odin | 4 +- 25 files changed, 125 insertions(+), 117 deletions(-) (limited to 'tests/core/encoding') diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin index 5f6e1ec16..d68eefe23 100644 --- a/base/runtime/core_builtin.odin +++ b/base/runtime/core_builtin.odin @@ -524,12 +524,12 @@ _append_elems :: #force_inline proc(array: ^$T/[dynamic]$E, should_zero: bool, l } @builtin -append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_elems(array, true, loc, args) } @builtin -non_zero_append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +non_zero_append_elems :: proc(array: ^$T/[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_elems(array, false, loc, args) } @@ -617,7 +617,7 @@ inject_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast arg: E, } @builtin -inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { +inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if array == nil { return } @@ -679,7 +679,7 @@ assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle @builtin -assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { +assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, #no_broadcast args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { new_size := index + len(args) if len(args) == 0 { ok = true diff --git a/base/runtime/core_builtin_soa.odin b/base/runtime/core_builtin_soa.odin index 108183ea6..7f7f5f086 100644 --- a/base/runtime/core_builtin_soa.odin +++ b/base/runtime/core_builtin_soa.odin @@ -342,12 +342,12 @@ _append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broa } @builtin -append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_soa_elems(array, true, args=args, loc=loc) } @builtin -non_zero_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast #no_capture args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { +non_zero_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { return _append_soa_elems(array, false, args=args, loc=loc) } diff --git a/base/runtime/print.odin b/base/runtime/print.odin index ecd301d21..0262e8ef6 100644 --- a/base/runtime/print.odin +++ b/base/runtime/print.odin @@ -72,7 +72,7 @@ when !ODIN_NO_RTTI { print_string("") } } - println_any :: #force_no_inline proc "contextless" (#no_capture args: ..any) { + println_any :: #force_no_inline proc "contextless" (args: ..any) { context = default_context() loop: for arg, i in args { assert(arg.id != nil) @@ -127,7 +127,7 @@ print_string :: #force_no_inline proc "contextless" (str: string) -> (n: int) { return } -print_strings :: #force_no_inline proc "contextless" (#no_capture args: ..string) -> (n: int) { +print_strings :: #force_no_inline proc "contextless" (args: ..string) -> (n: int) { for str in args { m, err := stderr_write(transmute([]byte)str) n += m diff --git a/core/container/small_array/small_array.odin b/core/container/small_array/small_array.odin index a698d965c..b2068469d 100644 --- a/core/container/small_array/small_array.odin +++ b/core/container/small_array/small_array.odin @@ -139,7 +139,7 @@ clear :: proc "contextless" (a: ^$A/Small_Array($N, $T)) { resize(a, 0) } -push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), #no_capture items: ..T) { +push_back_elems :: proc "contextless" (a: ^$A/Small_Array($N, $T), items: ..T) { n := copy(a.data[a.len:], items[:]) a.len += n } diff --git a/core/encoding/xml/tokenizer.odin b/core/encoding/xml/tokenizer.odin index 8a26f1bce..a2bbaf28e 100644 --- a/core/encoding/xml/tokenizer.odin +++ b/core/encoding/xml/tokenizer.odin @@ -17,7 +17,7 @@ import "core:fmt" import "core:unicode" import "core:unicode/utf8" -Error_Handler :: #type proc(pos: Pos, fmt: string, #no_capture args: ..any) +Error_Handler :: #type proc(pos: Pos, fmt: string, args: ..any) Token :: struct { kind: Token_Kind, @@ -112,13 +112,13 @@ offset_to_pos :: proc(t: ^Tokenizer, offset: int) -> Pos { } } -default_error_handler :: proc(pos: Pos, msg: string, #no_capture args: ..any) { +default_error_handler :: proc(pos: Pos, msg: string, args: ..any) { fmt.eprintf("%s(%d:%d) ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -error :: proc(t: ^Tokenizer, offset: int, msg: string, #no_capture args: ..any) { +error :: proc(t: ^Tokenizer, offset: int, msg: string, args: ..any) { pos := offset_to_pos(t, offset) if t.err != nil { t.err(pos, msg, ..args) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index e56211346..234f4afbd 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -125,7 +125,7 @@ register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Regist // Returns: A formatted string. // @(require_results) -aprint :: proc(#no_capture args: ..any, sep := " ", allocator := context.allocator) -> string { +aprint :: proc(args: ..any, sep := " ", allocator := context.allocator) -> string { str: strings.Builder strings.builder_init(&str, allocator) return sbprint(&str, ..args, sep=sep) @@ -141,7 +141,7 @@ aprint :: proc(#no_capture args: ..any, sep := " ", allocator := context.allocat // Returns: A formatted string with a newline character at the end. // @(require_results) -aprintln :: proc(#no_capture args: ..any, sep := " ", allocator := context.allocator) -> string { +aprintln :: proc(args: ..any, sep := " ", allocator := context.allocator) -> string { str: strings.Builder strings.builder_init(&str, allocator) return sbprintln(&str, ..args, sep=sep) @@ -158,7 +158,7 @@ aprintln :: proc(#no_capture args: ..any, sep := " ", allocator := context.alloc // Returns: A formatted string. The returned string must be freed accordingly. // @(require_results) -aprintf :: proc(fmt: string, #no_capture args: ..any, allocator := context.allocator, newline := false) -> string { +aprintf :: proc(fmt: string, args: ..any, allocator := context.allocator, newline := false) -> string { str: strings.Builder strings.builder_init(&str, allocator) return sbprintf(&str, fmt, ..args, newline=newline) @@ -174,7 +174,7 @@ aprintf :: proc(fmt: string, #no_capture args: ..any, allocator := context.alloc // Returns: A formatted string. The returned string must be freed accordingly. // @(require_results) -aprintfln :: proc(fmt: string, #no_capture args: ..any, allocator := context.allocator) -> string { +aprintfln :: proc(fmt: string, args: ..any, allocator := context.allocator) -> string { return aprintf(fmt, ..args, allocator=allocator, newline=true) } // Creates a formatted string @@ -188,7 +188,7 @@ aprintfln :: proc(fmt: string, #no_capture args: ..any, allocator := context.all // Returns: A formatted string. // @(require_results) -tprint :: proc(#no_capture args: ..any, sep := " ") -> string { +tprint :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) return sbprint(&str, ..args, sep=sep) @@ -204,7 +204,7 @@ tprint :: proc(#no_capture args: ..any, sep := " ") -> string { // Returns: A formatted string with a newline character at the end. // @(require_results) -tprintln :: proc(#no_capture args: ..any, sep := " ") -> string { +tprintln :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) return sbprintln(&str, ..args, sep=sep) @@ -221,7 +221,7 @@ tprintln :: proc(#no_capture args: ..any, sep := " ") -> string { // Returns: A formatted string. // @(require_results) -tprintf :: proc(fmt: string, #no_capture args: ..any, newline := false) -> string { +tprintf :: proc(fmt: string, args: ..any, newline := false) -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) return sbprintf(&str, fmt, ..args, newline=newline) @@ -237,7 +237,7 @@ tprintf :: proc(fmt: string, #no_capture args: ..any, newline := false) -> strin // Returns: A formatted string. // @(require_results) -tprintfln :: proc(fmt: string, #no_capture args: ..any) -> string { +tprintfln :: proc(fmt: string, args: ..any) -> string { return tprintf(fmt, ..args, newline=true) } // Creates a formatted string using a supplied buffer as the backing array. Writes into the buffer. @@ -249,7 +249,7 @@ tprintfln :: proc(fmt: string, #no_capture args: ..any) -> string { // // Returns: A formatted string // -bprint :: proc(buf: []byte, #no_capture args: ..any, sep := " ") -> string { +bprint :: proc(buf: []byte, args: ..any, sep := " ") -> string { sb := strings.builder_from_bytes(buf) return sbprint(&sb, ..args, sep=sep) } @@ -262,7 +262,7 @@ bprint :: proc(buf: []byte, #no_capture args: ..any, sep := " ") -> string { // // Returns: A formatted string with a newline character at the end // -bprintln :: proc(buf: []byte, #no_capture args: ..any, sep := " ") -> string { +bprintln :: proc(buf: []byte, args: ..any, sep := " ") -> string { sb := strings.builder_from_bytes(buf) return sbprintln(&sb, ..args, sep=sep) } @@ -276,7 +276,7 @@ bprintln :: proc(buf: []byte, #no_capture args: ..any, sep := " ") -> string { // // Returns: A formatted string // -bprintf :: proc(buf: []byte, fmt: string, #no_capture args: ..any, newline := false) -> string { +bprintf :: proc(buf: []byte, fmt: string, args: ..any, newline := false) -> string { sb := strings.builder_from_bytes(buf) return sbprintf(&sb, fmt, ..args, newline=newline) } @@ -289,7 +289,7 @@ bprintf :: proc(buf: []byte, fmt: string, #no_capture args: ..any, newline := fa // // Returns: A formatted string // -bprintfln :: proc(buf: []byte, fmt: string, #no_capture args: ..any) -> string { +bprintfln :: proc(buf: []byte, fmt: string, args: ..any) -> string { return bprintf(buf, fmt, ..args, newline=true) } // Runtime assertion with a formatted message @@ -301,14 +301,14 @@ bprintfln :: proc(buf: []byte, fmt: string, #no_capture args: ..any) -> string { // - loc: The location of the caller // @(disabled=ODIN_DISABLE_ASSERT) -assertf :: proc(condition: bool, fmt: string, #no_capture args: ..any, loc := #caller_location) { +assertf :: proc(condition: bool, fmt: string, args: ..any, loc := #caller_location) { if !condition { // NOTE(dragos): We are using the same trick as in builtin.assert // to improve performance to make the CPU not // execute speculatively, making it about an order of // magnitude faster @(cold) - internal :: proc(loc: runtime.Source_Code_Location, fmt: string, #no_capture args: ..any) { + internal :: proc(loc: runtime.Source_Code_Location, fmt: string, args: ..any) { p := context.assertion_failure_proc if p == nil { p = runtime.default_assertion_failure_proc @@ -326,7 +326,7 @@ assertf :: proc(condition: bool, fmt: string, #no_capture args: ..any, loc := #c // - args: A variadic list of arguments to be formatted // - loc: The location of the caller // -panicf :: proc(fmt: string, #no_capture args: ..any, loc := #caller_location) -> ! { +panicf :: proc(fmt: string, args: ..any, loc := #caller_location) -> ! { p := context.assertion_failure_proc if p == nil { p = runtime.default_assertion_failure_proc @@ -346,7 +346,7 @@ panicf :: proc(fmt: string, #no_capture args: ..any, loc := #caller_location) -> // Returns: A formatted C string // @(require_results) -caprintf :: proc(format: string, #no_capture args: ..any, newline := false) -> cstring { +caprintf :: proc(format: string, args: ..any, newline := false) -> cstring { str: strings.Builder strings.builder_init(&str) sbprintf(&str, format, ..args, newline=newline) @@ -365,7 +365,7 @@ caprintf :: proc(format: string, #no_capture args: ..any, newline := false) -> c // Returns: A formatted C string // @(require_results) -caprintfln :: proc(format: string, #no_capture args: ..any) -> cstring { +caprintfln :: proc(format: string, args: ..any) -> cstring { return caprintf(format, ..args, newline=true) } // Creates a formatted C string @@ -379,7 +379,7 @@ caprintfln :: proc(format: string, #no_capture args: ..any) -> cstring { // Returns: A formatted C string. // @(require_results) -ctprint :: proc(#no_capture args: ..any, sep := " ") -> cstring { +ctprint :: proc(args: ..any, sep := " ") -> cstring { str: strings.Builder strings.builder_init(&str, context.temp_allocator) sbprint(&str, ..args, sep=sep) @@ -399,7 +399,7 @@ ctprint :: proc(#no_capture args: ..any, sep := " ") -> cstring { // Returns: A formatted C string // @(require_results) -ctprintf :: proc(format: string, #no_capture args: ..any, newline := false) -> cstring { +ctprintf :: proc(format: string, args: ..any, newline := false) -> cstring { str: strings.Builder strings.builder_init(&str, context.temp_allocator) sbprintf(&str, format, ..args, newline=newline) @@ -418,7 +418,7 @@ ctprintf :: proc(format: string, #no_capture args: ..any, newline := false) -> c // Returns: A formatted C string // @(require_results) -ctprintfln :: proc(format: string, #no_capture args: ..any) -> cstring { +ctprintfln :: proc(format: string, args: ..any) -> cstring { return ctprintf(format, ..args, newline=true) } // Formats using the default print settings and writes to the given strings.Builder @@ -430,7 +430,7 @@ ctprintfln :: proc(format: string, #no_capture args: ..any) -> cstring { // // Returns: A formatted string // -sbprint :: proc(buf: ^strings.Builder, #no_capture args: ..any, sep := " ") -> string { +sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string { wprint(strings.to_writer(buf), ..args, sep=sep, flush=true) return strings.to_string(buf^) } @@ -443,7 +443,7 @@ sbprint :: proc(buf: ^strings.Builder, #no_capture args: ..any, sep := " ") -> s // // Returns: The resulting formatted string // -sbprintln :: proc(buf: ^strings.Builder, #no_capture args: ..any, sep := " ") -> string { +sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string { wprintln(strings.to_writer(buf), ..args, sep=sep, flush=true) return strings.to_string(buf^) } @@ -457,7 +457,7 @@ sbprintln :: proc(buf: ^strings.Builder, #no_capture args: ..any, sep := " ") -> // // Returns: The resulting formatted string // -sbprintf :: proc(buf: ^strings.Builder, fmt: string, #no_capture args: ..any, newline := false) -> string { +sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any, newline := false) -> string { wprintf(strings.to_writer(buf), fmt, ..args, flush=true, newline=newline) return strings.to_string(buf^) } @@ -469,7 +469,7 @@ sbprintf :: proc(buf: ^strings.Builder, fmt: string, #no_capture args: ..any, ne // // Returns: A formatted string // -sbprintfln :: proc(buf: ^strings.Builder, format: string, #no_capture args: ..any) -> string { +sbprintfln :: proc(buf: ^strings.Builder, format: string, args: ..any) -> string { return sbprintf(buf, format, ..args, newline=true) } // Formats and writes to an io.Writer using the default print settings @@ -481,7 +481,7 @@ sbprintfln :: proc(buf: ^strings.Builder, format: string, #no_capture args: ..an // // Returns: The number of bytes written // -wprint :: proc(w: io.Writer, #no_capture args: ..any, sep := " ", flush := true) -> int { +wprint :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int { fi: Info fi.writer = w @@ -522,7 +522,7 @@ wprint :: proc(w: io.Writer, #no_capture args: ..any, sep := " ", flush := true) // // Returns: The number of bytes written // -wprintln :: proc(w: io.Writer, #no_capture args: ..any, sep := " ", flush := true) -> int { +wprintln :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int { fi: Info fi.writer = w @@ -549,11 +549,11 @@ wprintln :: proc(w: io.Writer, #no_capture args: ..any, sep := " ", flush := tru // // Returns: The number of bytes written // -wprintf :: proc(w: io.Writer, fmt: string, #no_capture args: ..any, flush := true, newline := false) -> int { +wprintf :: proc(w: io.Writer, fmt: string, args: ..any, flush := true, newline := false) -> int { MAX_CHECKED_ARGS :: 64 assert(len(args) <= MAX_CHECKED_ARGS, "number of args > 64 is unsupported") - parse_options :: proc(fi: ^Info, fmt: string, index, end: int, unused_args: ^bit_set[0 ..< MAX_CHECKED_ARGS], #no_capture args: ..any) -> int { + parse_options :: proc(fi: ^Info, fmt: string, index, end: int, unused_args: ^bit_set[0 ..< MAX_CHECKED_ARGS], args: ..any) -> int { i := index // Prefix @@ -809,7 +809,7 @@ wprintf :: proc(w: io.Writer, fmt: string, #no_capture args: ..any, flush := tru // // Returns: The number of bytes written. // -wprintfln :: proc(w: io.Writer, format: string, #no_capture args: ..any, flush := true) -> int { +wprintfln :: proc(w: io.Writer, format: string, args: ..any, flush := true) -> int { return wprintf(w, format, ..args, flush=flush, newline=true) } // Writes a ^runtime.Type_Info value to an io.Writer diff --git a/core/fmt/fmt_js.odin b/core/fmt/fmt_js.odin index 4389b8d87..acf218eb5 100644 --- a/core/fmt/fmt_js.odin +++ b/core/fmt/fmt_js.odin @@ -43,7 +43,7 @@ fd_to_writer :: proc(fd: os.Handle, loc := #caller_location) -> io.Writer { } // fprint formats using the default print settings and writes to fd -fprint :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true, loc := #caller_location) -> int { +fprint :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true, loc := #caller_location) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -54,7 +54,7 @@ fprint :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true } // fprintln formats using the default print settings and writes to fd -fprintln :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true, loc := #caller_location) -> int { +fprintln :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true, loc := #caller_location) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -66,7 +66,7 @@ fprintln :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := tr } // fprintf formats according to the specified format string and writes to fd -fprintf :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := true, newline := false, loc := #caller_location) -> int { +fprintf :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true, newline := false, loc := #caller_location) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -78,24 +78,24 @@ fprintf :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := tr } // fprintfln formats according to the specified format string and writes to fd, followed by a newline. -fprintfln :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := true, loc := #caller_location) -> int { +fprintfln :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true, loc := #caller_location) -> int { return fprintf(fd, fmt, ..args, flush=flush, newline=true, loc=loc) } // print formats using the default print settings and writes to stdout -print :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return wprint(w=stdout, args=args, sep=sep, flush=flush) } +print :: proc(args: ..any, sep := " ", flush := true) -> int { return wprint(w=stdout, args=args, sep=sep, flush=flush) } // println formats using the default print settings and writes to stdout -println :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stdout, args=args, sep=sep, flush=flush) } +println :: proc(args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stdout, args=args, sep=sep, flush=flush) } // printf formats according to the specififed format string and writes to stdout -printf :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush) } +printf :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush) } // printfln formats according to the specified format string and writes to stdout, followed by a newline. -printfln :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush, newline=true) } +printfln :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush, newline=true) } // eprint formats using the default print settings and writes to stderr -eprint :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return wprint(w=stderr, args=args, sep=sep, flush=flush) } +eprint :: proc(args: ..any, sep := " ", flush := true) -> int { return wprint(w=stderr, args=args, sep=sep, flush=flush) } // eprintln formats using the default print settings and writes to stderr -eprintln :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stderr, args=args, sep=sep, flush=flush) } +eprintln :: proc(args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stderr, args=args, sep=sep, flush=flush) } // eprintf formats according to the specififed format string and writes to stderr -eprintf :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return wprintf(stderr, fmt, ..args, flush=flush) } +eprintf :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stderr, fmt, ..args, flush=flush) } // eprintfln formats according to the specified format string and writes to stderr, followed by a newline. -eprintfln :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush, newline=true) } +eprintfln :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush, newline=true) } diff --git a/core/fmt/fmt_os.odin b/core/fmt/fmt_os.odin index 538f7a08b..9de0d43be 100644 --- a/core/fmt/fmt_os.odin +++ b/core/fmt/fmt_os.odin @@ -9,7 +9,7 @@ import "core:io" import "core:bufio" // fprint formats using the default print settings and writes to fd -fprint :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true) -> int { +fprint :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -20,7 +20,7 @@ fprint :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true } // fprintln formats using the default print settings and writes to fd -fprintln :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := true) -> int { +fprintln :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -31,7 +31,7 @@ fprintln :: proc(fd: os.Handle, #no_capture args: ..any, sep := " ", flush := tr return wprintln(w, ..args, sep=sep, flush=flush) } // fprintf formats according to the specified format string and writes to fd -fprintf :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := true, newline := false) -> int { +fprintf :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true, newline := false) -> int { buf: [1024]byte b: bufio.Writer defer bufio.writer_flush(&b) @@ -42,7 +42,7 @@ fprintf :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := tr return wprintf(w, fmt, ..args, flush=flush, newline=newline) } // fprintfln formats according to the specified format string and writes to fd, followed by a newline. -fprintfln :: proc(fd: os.Handle, fmt: string, #no_capture args: ..any, flush := true) -> int { +fprintfln :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true) -> int { return fprintf(fd, fmt, ..args, flush=flush, newline=true) } fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info, flush := true) -> (n: int, err: io.Error) { @@ -67,19 +67,19 @@ fprint_typeid :: proc(fd: os.Handle, id: typeid, flush := true) -> (n: int, err: } // print formats using the default print settings and writes to os.stdout -print :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return fprint(os.stdout, ..args, sep=sep, flush=flush) } +print :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stdout, ..args, sep=sep, flush=flush) } // println formats using the default print settings and writes to os.stdout -println :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stdout, ..args, sep=sep, flush=flush) } +println :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stdout, ..args, sep=sep, flush=flush) } // printf formats according to the specified format string and writes to os.stdout -printf :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush) } +printf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush) } // printfln formats according to the specified format string and writes to os.stdout, followed by a newline. -printfln :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush, newline=true) } +printfln :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush, newline=true) } // eprint formats using the default print settings and writes to os.stderr -eprint :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return fprint(os.stderr, ..args, sep=sep, flush=flush) } +eprint :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stderr, ..args, sep=sep, flush=flush) } // eprintln formats using the default print settings and writes to os.stderr -eprintln :: proc(#no_capture args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stderr, ..args, sep=sep, flush=flush) } +eprintln :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stderr, ..args, sep=sep, flush=flush) } // eprintf formats according to the specified format string and writes to os.stderr -eprintf :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush) } +eprintf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush) } // eprintfln formats according to the specified format string and writes to os.stderr, followed by a newline. -eprintfln :: proc(fmt: string, #no_capture args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush, newline=true) } +eprintfln :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush, newline=true) } diff --git a/core/log/log.odin b/core/log/log.odin index 35dff086f..0d89fdb74 100644 --- a/core/log/log.odin +++ b/core/log/log.odin @@ -75,43 +75,43 @@ nil_logger :: proc() -> Logger { return Logger{nil_logger_proc, nil, Level.Debug, nil} } -debugf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { +debugf :: proc(fmt_str: string, args: ..any, location := #caller_location) { logf(.Debug, fmt_str, ..args, location=location) } -infof :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { +infof :: proc(fmt_str: string, args: ..any, location := #caller_location) { logf(.Info, fmt_str, ..args, location=location) } -warnf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { +warnf :: proc(fmt_str: string, args: ..any, location := #caller_location) { logf(.Warning, fmt_str, ..args, location=location) } -errorf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { +errorf :: proc(fmt_str: string, args: ..any, location := #caller_location) { logf(.Error, fmt_str, ..args, location=location) } -fatalf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) { +fatalf :: proc(fmt_str: string, args: ..any, location := #caller_location) { logf(.Fatal, fmt_str, ..args, location=location) } -debug :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { +debug :: proc(args: ..any, sep := " ", location := #caller_location) { log(.Debug, ..args, sep=sep, location=location) } -info :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { +info :: proc(args: ..any, sep := " ", location := #caller_location) { log(.Info, ..args, sep=sep, location=location) } -warn :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { +warn :: proc(args: ..any, sep := " ", location := #caller_location) { log(.Warning, ..args, sep=sep, location=location) } -error :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { +error :: proc(args: ..any, sep := " ", location := #caller_location) { log(.Error, ..args, sep=sep, location=location) } -fatal :: proc(#no_capture args: ..any, sep := " ", location := #caller_location) { +fatal :: proc(args: ..any, sep := " ", location := #caller_location) { log(.Fatal, ..args, sep=sep, location=location) } -panic :: proc(#no_capture args: ..any, location := #caller_location) -> ! { +panic :: proc(args: ..any, location := #caller_location) -> ! { log(.Fatal, ..args, location=location) runtime.panic("log.panic", location) } -panicf :: proc(fmt_str: string, #no_capture args: ..any, location := #caller_location) -> ! { +panicf :: proc(fmt_str: string, args: ..any, location := #caller_location) -> ! { logf(.Fatal, fmt_str, ..args, location=location) runtime.panic("log.panicf", location) } @@ -133,14 +133,14 @@ assert :: proc(condition: bool, message := "", loc := #caller_location) { } @(disabled=ODIN_DISABLE_ASSERT) -assertf :: proc(condition: bool, fmt_str: string, #no_capture args: ..any, loc := #caller_location) { +assertf :: proc(condition: bool, fmt_str: string, args: ..any, loc := #caller_location) { if !condition { // NOTE(dragos): We are using the same trick as in builtin.assert // to improve performance to make the CPU not // execute speculatively, making it about an order of // magnitude faster @(cold) - internal :: proc(loc: runtime.Source_Code_Location, fmt_str: string, #no_capture args: ..any) { + internal :: proc(loc: runtime.Source_Code_Location, fmt_str: string, args: ..any) { p := context.assertion_failure_proc if p == nil { p = runtime.default_assertion_failure_proc @@ -155,7 +155,7 @@ assertf :: proc(condition: bool, fmt_str: string, #no_capture args: ..any, loc : -log :: proc(level: Level, #no_capture args: ..any, sep := " ", location := #caller_location) { +log :: proc(level: Level, args: ..any, sep := " ", location := #caller_location) { logger := context.logger if logger.procedure == nil { return @@ -167,7 +167,7 @@ log :: proc(level: Level, #no_capture args: ..any, sep := " ", location := #call logger.procedure(logger.data, level, str, logger.options, location) } -logf :: proc(level: Level, fmt_str: string, #no_capture args: ..any, location := #caller_location) { +logf :: proc(level: Level, fmt_str: string, args: ..any, location := #caller_location) { logger := context.logger if logger.procedure == nil { return diff --git a/core/math/big/helpers.odin b/core/math/big/helpers.odin index c82b5eead..ee09bb2c7 100644 --- a/core/math/big/helpers.odin +++ b/core/math/big/helpers.odin @@ -404,7 +404,7 @@ clear_if_uninitialized_single :: proc(arg: ^Int, allocator := context.allocator) return #force_inline internal_clear_if_uninitialized_single(arg, allocator) } -clear_if_uninitialized_multi :: proc(#no_capture args: ..^Int, allocator := context.allocator) -> (err: Error) { +clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context.allocator) -> (err: Error) { args := args assert_if_nil(..args) @@ -420,7 +420,7 @@ error_if_immutable_single :: proc(arg: ^Int) -> (err: Error) { return nil } -error_if_immutable_multi :: proc(#no_capture args: ..^Int) -> (err: Error) { +error_if_immutable_multi :: proc(args: ..^Int) -> (err: Error) { for i in args { if i != nil && .Immutable in i.flags { return .Assignment_To_Immutable } } @@ -431,7 +431,7 @@ error_if_immutable :: proc {error_if_immutable_single, error_if_immutable_multi, /* Allocates several `Int`s at once. */ -int_init_multi :: proc(#no_capture integers: ..^Int, allocator := context.allocator) -> (err: Error) { +int_init_multi :: proc(integers: ..^Int, allocator := context.allocator) -> (err: Error) { assert_if_nil(..integers) integers := integers @@ -812,13 +812,13 @@ assert_if_nil :: proc{ assert_if_nil_rat, } -assert_if_nil_int :: #force_inline proc(#no_capture integers: ..^Int, loc := #caller_location) { +assert_if_nil_int :: #force_inline proc(integers: ..^Int, loc := #caller_location) { for i in integers { assert(i != nil, "(nil)", loc) } } -assert_if_nil_rat :: #force_inline proc(#no_capture rationals: ..^Rat, loc := #caller_location) { +assert_if_nil_rat :: #force_inline proc(rationals: ..^Rat, loc := #caller_location) { for r in rationals { assert(r != nil, "(nil)", loc) } diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin index 9eaa0c8e1..c9b331e55 100644 --- a/core/math/big/internal.odin +++ b/core/math/big/internal.odin @@ -1844,7 +1844,7 @@ internal_root_n :: proc { internal_int_root_n, } Deallocates the backing memory of one or more `Int`s. Asssumes none of the `integers` to be a `nil`. */ -internal_int_destroy :: proc(#no_capture integers: ..^Int) { +internal_int_destroy :: proc(integers: ..^Int) { integers := integers for &a in integers { @@ -2872,7 +2872,7 @@ internal_clear_if_uninitialized_single :: proc(arg: ^Int, allocator := context.a return err } -internal_clear_if_uninitialized_multi :: proc(#no_capture args: ..^Int, allocator := context.allocator) -> (err: Error) { +internal_clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context.allocator) -> (err: Error) { context.allocator = allocator for i in args { @@ -2890,7 +2890,7 @@ internal_error_if_immutable_single :: proc(arg: ^Int) -> (err: Error) { return nil } -internal_error_if_immutable_multi :: proc(#no_capture args: ..^Int) -> (err: Error) { +internal_error_if_immutable_multi :: proc(args: ..^Int) -> (err: Error) { for i in args { if i != nil && .Immutable in i.flags { return .Assignment_To_Immutable } } @@ -2901,7 +2901,7 @@ internal_error_if_immutable :: proc {internal_error_if_immutable_single, interna /* Allocates several `Int`s at once. */ -internal_int_init_multi :: proc(#no_capture integers: ..^Int, allocator := context.allocator) -> (err: Error) { +internal_int_init_multi :: proc(integers: ..^Int, allocator := context.allocator) -> (err: Error) { context.allocator = allocator integers := integers diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 3ae3b5dba..dec892f84 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -5,8 +5,8 @@ import "core:odin/tokenizer" import "core:fmt" -Warning_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, #no_capture args: ..any) -Error_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, #no_capture args: ..any) +Warning_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, args: ..any) +Error_Handler :: #type proc(pos: tokenizer.Pos, fmt: string, args: ..any) Flag :: enum u32 { Optional_Semicolons, @@ -67,25 +67,25 @@ Import_Decl_Kind :: enum { -default_warning_handler :: proc(pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { +default_warning_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { fmt.eprintf("%s(%d:%d): Warning: ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -default_error_handler :: proc(pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { +default_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { fmt.eprintf("%s(%d:%d): ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -warn :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { +warn :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, args: ..any) { if p.warn != nil { p.warn(pos, msg, ..args) } p.file.syntax_warning_count += 1 } -error :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, #no_capture args: ..any) { +error :: proc(p: ^Parser, pos: tokenizer.Pos, msg: string, args: ..any) { if p.err != nil { p.err(pos, msg, ..args) } diff --git a/core/odin/tokenizer/tokenizer.odin b/core/odin/tokenizer/tokenizer.odin index c5992e5f4..62170aa10 100644 --- a/core/odin/tokenizer/tokenizer.odin +++ b/core/odin/tokenizer/tokenizer.odin @@ -4,7 +4,7 @@ import "core:fmt" import "core:unicode" import "core:unicode/utf8" -Error_Handler :: #type proc(pos: Pos, fmt: string, #no_capture args: ..any) +Error_Handler :: #type proc(pos: Pos, fmt: string, args: ..any) Flag :: enum { Insert_Semicolon, @@ -62,13 +62,13 @@ offset_to_pos :: proc(t: ^Tokenizer, offset: int) -> Pos { } } -default_error_handler :: proc(pos: Pos, msg: string, #no_capture args: ..any) { +default_error_handler :: proc(pos: Pos, msg: string, args: ..any) { fmt.eprintf("%s(%d:%d) ", pos.file, pos.line, pos.column) fmt.eprintf(msg, ..args) fmt.eprintf("\n") } -error :: proc(t: ^Tokenizer, offset: int, msg: string, #no_capture args: ..any) { +error :: proc(t: ^Tokenizer, offset: int, msg: string, args: ..any) { pos := offset_to_pos(t, offset) if t.err != nil { t.err(pos, msg, ..args) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index 04dc79095..29fe853ef 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -53,12 +53,12 @@ T :: struct { @(deprecated="prefer `log.error`") -error :: proc(t: ^T, #no_capture args: ..any, loc := #caller_location) { +error :: proc(t: ^T, args: ..any, loc := #caller_location) { pkg_log.error(..args, location = loc) } @(deprecated="prefer `log.errorf`") -errorf :: proc(t: ^T, format: string, #no_capture args: ..any, loc := #caller_location) { +errorf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { pkg_log.errorf(format, ..args, location = loc) } @@ -87,12 +87,12 @@ failed :: proc(t: ^T) -> bool { } @(deprecated="prefer `log.info`") -log :: proc(t: ^T, #no_capture args: ..any, loc := #caller_location) { +log :: proc(t: ^T, args: ..any, loc := #caller_location) { pkg_log.info(..args, location = loc) } @(deprecated="prefer `log.infof`") -logf :: proc(t: ^T, format: string, #no_capture args: ..any, loc := #caller_location) { +logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { pkg_log.infof(format, ..args, location = loc) } @@ -121,7 +121,7 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo return ok } -expectf :: proc(t: ^T, ok: bool, format: string, #no_capture args: ..any, loc := #caller_location) -> bool { +expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool { if !ok { pkg_log.errorf(format, ..args, location=loc) } diff --git a/core/text/scanner/scanner.odin b/core/text/scanner/scanner.odin index 6eb366b49..d27c66f24 100644 --- a/core/text/scanner/scanner.odin +++ b/core/text/scanner/scanner.odin @@ -250,7 +250,7 @@ error :: proc(s: ^Scanner, msg: string) { } } -errorf :: proc(s: ^Scanner, format: string, #no_capture args: ..any) { +errorf :: proc(s: ^Scanner, format: string, args: ..any) { error(s, fmt.tprintf(format, ..args)) } diff --git a/core/text/table/table.odin b/core/text/table/table.odin index 4d0baef64..27c99b1f1 100644 --- a/core/text/table/table.odin +++ b/core/text/table/table.odin @@ -145,7 +145,7 @@ set_cell_value_and_alignment :: proc(tbl: ^Table, row, col: int, value: any, ali cell.alignment = alignment } -format :: proc(tbl: ^Table, _fmt: string, #no_capture args: ..any) -> string { +format :: proc(tbl: ^Table, _fmt: string, args: ..any) -> string { context.allocator = tbl.format_allocator return fmt.aprintf(_fmt, ..args) } diff --git a/core/unicode/tools/generate_entity_table.odin b/core/unicode/tools/generate_entity_table.odin index 238a3e219..16baa1adf 100644 --- a/core/unicode/tools/generate_entity_table.odin +++ b/core/unicode/tools/generate_entity_table.odin @@ -12,7 +12,7 @@ import "core:fmt" /* Silent error handler for the parser. */ -Error_Handler :: proc(pos: xml.Pos, fmt: string, #no_capture args: ..any) {} +Error_Handler :: proc(pos: xml.Pos, fmt: string, args: ..any) {} OPTIONS :: xml.Options{ flags = { .Ignore_Unsupported, }, expected_doctype = "unicode", } diff --git a/src/check_type.cpp b/src/check_type.cpp index d1c9bb381..466b9b3cd 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2065,9 +2065,10 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para } else if (p->flags & FieldFlag_c_vararg) { error(name, "'#no_capture' cannot be applied to a #c_vararg parameter"); p->flags &= ~FieldFlag_no_capture; + } else { + error(name, "'#no_capture' is already implied on all variadic parameter"); } } - if (is_poly_name) { if (p->flags&FieldFlag_no_alias) { error(name, "'#no_alias' can only be applied to non constant values"); @@ -2085,6 +2086,11 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para error(name, "'#by_ptr' can only be applied to variable fields"); p->flags &= ~FieldFlag_by_ptr; } + if (p->flags&FieldFlag_no_capture) { + error(name, "'#no_capture' can only be applied to variable fields"); + p->flags &= ~FieldFlag_no_capture; + } + if (!is_type_polymorphic(type) && check_constant_parameter_value(type, params[i])) { // failed @@ -2104,6 +2110,8 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para param->flags |= EntityFlag_Ellipsis; if (is_c_vararg) { param->flags |= EntityFlag_CVarArg; + } else { + param->flags |= EntityFlag_NoCapture; } } diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index dd1041702..71fa1dbd0 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -344,7 +344,6 @@ struct lbProcedure { Array no_captures; LLVMValueRef temp_callee_return_struct_memory; - Ast *curr_stmt; Array scope_stack; diff --git a/src/parser.hpp b/src/parser.hpp index 15176f789..451cdf53d 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -330,10 +330,11 @@ enum FieldFlag : u32 { FieldFlag_subtype = 1<<7, FieldFlag_by_ptr = 1<<8, FieldFlag_no_broadcast = 1<<9, // disallow array programming - FieldFlag_no_capture = 1<<10, + + FieldFlag_no_capture = 1<<11, // Internal use by the parser only - FieldFlag_Tags = 1<<11, + FieldFlag_Tags = 1<<15, FieldFlag_Results = 1<<16, diff --git a/tests/core/encoding/xml/test_core_xml.odin b/tests/core/encoding/xml/test_core_xml.odin index 811ee27dc..b29431e10 100644 --- a/tests/core/encoding/xml/test_core_xml.odin +++ b/tests/core/encoding/xml/test_core_xml.odin @@ -8,7 +8,7 @@ import "core:fmt" import "core:log" import "core:hash" -Silent :: proc(pos: xml.Pos, format: string, #no_capture args: ..any) {} +Silent :: proc(pos: xml.Pos, format: string, args: ..any) {} OPTIONS :: xml.Options{ flags = { .Ignore_Unsupported, .Intern_Comments, }, expected_doctype = "", diff --git a/tests/core/fmt/test_core_fmt.odin b/tests/core/fmt/test_core_fmt.odin index 0aaef93a4..49142e24d 100644 --- a/tests/core/fmt/test_core_fmt.odin +++ b/tests/core/fmt/test_core_fmt.odin @@ -373,7 +373,7 @@ test_odin_value_export :: proc(t: ^testing.T) { } @(private) -check :: proc(t: ^testing.T, exp: string, format: string, #no_capture args: ..any, loc := #caller_location) { +check :: proc(t: ^testing.T, exp: string, format: string, args: ..any, loc := #caller_location) { got := fmt.tprintf(format, ..args) testing.expectf(t, got == exp, "(%q, %v): %q != %q", format, args, got, exp, loc = loc) } diff --git a/tests/documentation/documentation_tester.odin b/tests/documentation/documentation_tester.odin index 7fc37b9f0..8a798d6c5 100644 --- a/tests/documentation/documentation_tester.odin +++ b/tests/documentation/documentation_tester.odin @@ -51,7 +51,7 @@ common_prefix :: proc(strs: []string) -> string { return prefix } -errorf :: proc(format: string, #no_capture args: ..any) -> ! { +errorf :: proc(format: string, args: ..any) -> ! { fmt.eprintf("%s ", os.args[0]) fmt.eprintf(format, ..args) fmt.eprintln() diff --git a/vendor/OpenGL/wrappers.odin b/vendor/OpenGL/wrappers.odin index 971452be5..1eb8fc72f 100644 --- a/vendor/OpenGL/wrappers.odin +++ b/vendor/OpenGL/wrappers.odin @@ -754,7 +754,7 @@ when !GL_DEBUG { MultiDrawElementsIndirectCount :: proc "c" (mode: i32, type: i32, indirect: [^]DrawElementsIndirectCommand, drawcount: i32, maxdrawcount, stride: i32) { impl_MultiDrawElementsIndirectCount(mode, type, indirect, drawcount, maxdrawcount, stride) } PolygonOffsetClamp :: proc "c" (factor, units, clamp: f32) { impl_PolygonOffsetClamp(factor, units, clamp) } } else { - debug_helper :: proc"c"(from_loc: runtime.Source_Code_Location, num_ret: int, #no_capture args: ..any, loc := #caller_location) { + debug_helper :: proc"c"(from_loc: runtime.Source_Code_Location, num_ret: int, args: ..any, loc := #caller_location) { context = runtime.default_context() Error_Enum :: enum { diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index c2995ba36..0dd3bd4fd 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -1667,7 +1667,7 @@ IsGestureDetected :: proc "c" (gesture: Gesture) -> bool { // Text formatting with variables (sprintf style) -TextFormat :: proc(text: cstring, #no_capture args: ..any) -> cstring { +TextFormat :: proc(text: cstring, args: ..any) -> cstring { @static buffers: [MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH]byte @static index: u32 @@ -1683,7 +1683,7 @@ TextFormat :: proc(text: cstring, #no_capture args: ..any) -> cstring { } // Text formatting with variables (sprintf style) and allocates (must be freed with 'MemFree') -TextFormatAlloc :: proc(text: cstring, #no_capture args: ..any) -> cstring { +TextFormatAlloc :: proc(text: cstring, args: ..any) -> cstring { str := fmt.tprintf(string(text), ..args) return strings.clone_to_cstring(str, MemAllocator()) } -- cgit v1.2.3