1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#ifndef MESSAGES_H
#define MESSAGES_H
global_variable String8List *errors;
global_variable String8List *warnings;
internal void WARN(String8List *warning_list);
internal void ERROR(String8List *error_list);
#define PUSH_WARNING(message) _PUSH_WARNING(global_arena, warnings, message)
#define PUSH_ERROR(message) _PUSH_ERROR(global_arena, errors, message)
#if DEBUG // DEBUG
#define PANIC(panic_message) \
do { \
Log(panic_message "\n" \
"panic information: \n" \
"function:\t%s\n" \
"file:\t\t%s", \
__FUNCTION__, __FILE__); \
OSExit(0); \
} while (0);
#else
#define PANIC(panic_message) \
do { \
Log(panic_message); \
breakpoint(); \
} while (0);
#endif //-
#define _PUSH_ERROR(global_arena, error_list, message) \
do { \
if (error_list != NULL) { \
errors_list = PushStruct(global_arena, String8List) \
} \
str8_list_push_node(error_list, str8_node(message)); \
} while (0);
#define _PUSH_WARNING(global_arena, error_list, message) \
do { \
if (error_list != NULL) { \
errors_list = PushStruct(global_arena, String8List) \
} \
str8_list_push_node(error_list, str8_node(message)); \
} while (0);
internal void warn(MemArena *arena, String8List *warning_list)
{
u64 total_size = 0;
FOR_STR8_NODE(warning_list, current) {
total_size += current->value.size;
}
String8 big_buffer = PushString8(arena, total_size);
FOR_STR8_NODE(warning_list, current) {
str8_append(&big_buffer, str8("Warning: "));
str8_append(&big_buffer, current->value);
str8_append(&big_buffer, str8("\n"));
}
LogStr8(big_buffer);
}
internal void error(MemArena *arena, String8List *error_list)
{
u64 total_size = 0;
FOR_STR8_NODE(error_list, current) {
total_size += current->value.size;
}
String8 big_buffer = PushString8(arena, total_size);
FOR_STR8_NODE(error_list, current) {
str8_append(&big_buffer, str8("Error: "));
str8_append(&big_buffer, current->value);
str8_append(&big_buffer, str8("\n"));
}
LogStr8(big_buffer);
}
#endif // MESSAGES_H
|