mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Place assertf and printf to package fmt
This commit is contained in:
@@ -192,6 +192,27 @@ bprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assertf :: proc "contextless" (condition: bool, fmt: string, args: ..any, loc := #caller_location) -> bool {
|
||||||
|
if !condition {
|
||||||
|
p := context.assertion_failure_proc;
|
||||||
|
if p == nil {
|
||||||
|
p = runtime.default_assertion_failure_proc;
|
||||||
|
}
|
||||||
|
message := tprintf(fmt, ..args);
|
||||||
|
p("Runtime assertion", message, loc);
|
||||||
|
}
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
panicf :: proc "contextless" (fmt: string, args: ..any, loc := #caller_location) {
|
||||||
|
p := context.assertion_failure_proc;
|
||||||
|
if p == nil {
|
||||||
|
p = runtime.default_assertion_failure_proc;
|
||||||
|
}
|
||||||
|
message := tprintf(fmt, ..args);
|
||||||
|
p("Panic", message, loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package runtime
|
|||||||
|
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "core:fmt"
|
|
||||||
|
|
||||||
// Naming Conventions:
|
// Naming Conventions:
|
||||||
// In general, Ada_Case for types and snake_case for values
|
// In general, Ada_Case for types and snake_case for values
|
||||||
@@ -575,31 +574,6 @@ panic :: proc "contextless" (message: string, loc := #caller_location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@(builtin)
|
|
||||||
assertf :: proc "contextless" (condition: bool, format: string, args: ..any, loc := #caller_location) -> bool {
|
|
||||||
if !condition {
|
|
||||||
p := context.assertion_failure_proc;
|
|
||||||
if p == nil {
|
|
||||||
p = default_assertion_failure_proc;
|
|
||||||
}
|
|
||||||
message := fmt.tprintf(format, ..args);
|
|
||||||
p("Runtime assertion", message, loc);
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@(builtin)
|
|
||||||
panicf :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
|
|
||||||
p := context.assertion_failure_proc;
|
|
||||||
if p == nil {
|
|
||||||
p = default_assertion_failure_proc;
|
|
||||||
}
|
|
||||||
message := fmt.tprintf(format, ..args);
|
|
||||||
p("Panic", message, loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Dynamic Array
|
// Dynamic Array
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user