Implement Explicit context creation #639

This commit is contained in:
gingerBill
2020-05-14 00:13:26 +01:00
parent af1d4d6e72
commit f661d34049
6 changed files with 39 additions and 11 deletions
+2 -2
View File
@@ -125,7 +125,7 @@ bprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string {
}
assertf :: proc "contextless" (condition: bool, fmt: string, args: ..any, loc := #caller_location) -> bool {
assertf :: proc(condition: bool, fmt: string, args: ..any, loc := #caller_location) -> bool {
if !condition {
p := context.assertion_failure_proc;
if p == nil {
@@ -137,7 +137,7 @@ assertf :: proc "contextless" (condition: bool, fmt: string, args: ..any, loc :=
return condition;
}
panicf :: proc "contextless" (fmt: string, 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;
+6
View File
@@ -440,6 +440,12 @@ default_logger :: proc() -> Logger {
}
default_context :: proc "contextless" () -> Context {
c: Context;
__init_context(&c);
return c;
}
@private
__init_context_from_ptr :: proc "contextless" (c: ^Context, other: ^Context) {
if c == nil do return;