acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
debug.h
1
// Created by camilo on 2022-10-27 21:50 <3ThomasBorregaardSorensen!!
2
#pragma once
3
4
5
// returns true if it should continue...
6
CLASS_DECL_ACME
bool
__assert_failed_line(const_char_pointer pszFileName, ::i32 iLineNumber);
7
8
CLASS_DECL_ACME ::i32 is_debugger_attached(
void
);
9
10
CLASS_DECL_ACME
void
debug_print(const_char_pointer pszFormat, ...);
11
12
CLASS_DECL_ACME
void
throw_todo();
13
14
CLASS_DECL_ACME ::i32 throw_assert_exception(const_char_pointer pszFileName, ::i32 iLineNumber);
15
16
//CLASS_DECL_ACME void throw_what_exclamation_exclamation(const ::scoped_string & scopedstr);
17
18
#define __pass_array(A) A, sizeof(A)
19
20
#ifndef __cplusplus
21
22
23
#define ASSERT assert
24
25
26
#else
27
28
29
#ifdef _DEBUG
30
31
32
33
34
#define ASSERT(f) \
35
{ \
36
\
37
if(!(f)) \
38
{ \
39
\
40
if(is_debugger_attached()) \
41
{ \
42
\
43
if(!__assert_failed_line(__FILE__, __LINE__)) \
44
{ \
45
\
46
debug_break(); \
47
\
48
} \
49
\
50
} \
51
else \
52
{ \
53
\
54
throw_assert_exception(__FILE__, __LINE__); \
55
\
56
} \
57
\
58
} \
59
\
60
}
61
62
63
template
< prototype_container CONTAINER >
64
inline
void
__assert_container_ok(
const
CONTAINER * pcontainer, const_char_pointer pszFileName, ::i32 nLine);
65
66
67
CLASS_DECL_ACME
void
__assert_particle_ok(const ::particle * pparticle, const_char_pointer pszFileName, ::i32 nLine);
68
69
70
template
<prototype_container CONTAINER>
71
inline
void
__assert_ok(
const
CONTAINER * p, const_char_pointer pszFile, ::i32 iLine)
72
{
73
74
__assert_container_ok(p, pszFile, iLine);
75
76
}
77
78
79
inline
void
__assert_ok(const ::particle * p, const_char_pointer pszFile, ::i32 iLine)
80
{
81
82
__assert_particle_ok(p, pszFile, iLine);
83
84
}
85
86
87
88
89
#define _ASSUME(cond) do { bool _gen__condVal=!!(cond); ASSERT(_gen__condVal); __analysis_assume(_gen__condVal); } while(0)
90
#define ASSERT_OK(p) ::__assert_ok(p, __FILE__, __LINE__)
91
92
93
#else
94
95
96
#define ASSERT(f)
97
#define _ASSUME(cond)
98
#if defined(__ANDROID__)
99
#define ASSERT_OK(cond)
100
#elif defined(__APPLE__)
101
#define ASSERT_OK(cond)
102
#elif defined(LINUX) || defined(__BSD__)
103
#define ASSERT_OK(cond)
104
#else
105
#define ASSERT_OK(cond) __noop;
106
#endif
107
#endif
108
109
110
#endif
111
112
113
114
115
116
117
exception
debug.h
Generated by
1.17.0