Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
internal.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#ifndef __ASE_INTERNAL_HH__
3#define __ASE_INTERNAL_HH__
4
5// Import simple ASE types into global scope
6using Ase::uint8;
7using Ase::uint16;
8using Ase::uint32;
9using Ase::uint64;
10using Ase::int8;
11using Ase::int16;
12using Ase::int32;
13using Ase::int64;
14using Ase::unichar;
15using Ase::String;
16
18#define _(...) ::Ase::ase_gettext (__VA_ARGS__)
20#define N_(str) (str)
21
23#define APPLY_IDL_PROPERTY(lvalue, rvalue) ASE_OBJECT_APPLY_IDL_PROPERTY(lvalue, rvalue)
24
26#define ARRAY_SIZE(array) ASE_ARRAY_SIZE (array)
27
29#define assert_return(expr, ...) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); return __VA_ARGS__; } while (0)
31#define assert_return_unreached(...) do { ::Ase::assertion_failed (""); return __VA_ARGS__; } while (0)
33#define assert_warn(expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
35#define assert_paranoid(expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
37#define assert_unreached() __builtin_unreachable()
38
40#define if_constexpr if constexpr
41
43#define CQUOTE(str) ASE_CQUOTE(str)
44
45#ifdef __G_MACROS_H__
46#undef MAX
47#undef MIN
48#undef CLAMP
49#endif
50
52#define MAX(a,b) ((a) >= (b) ? (a) : (b))
53
55#define MIN(a,b) ((a) <= (b) ? (a) : (b))
56
58#define CLAMP(v,mi,ma) ((v) < (mi) ? (mi) : ((v) > (ma) ? (ma) : (v)))
59
61#define ISLIKELY(cond) ASE_ISLIKELY (cond)
63#define UNLIKELY(cond) ASE_UNLIKELY (cond)
64
66#define ALIGNMENT16(pointer) ASE_ALIGNMENT16 (pointer)
68#define ALIGNED16(pointer) ASE_ALIGNED16 (pointer)
69
71#define return_unless(cond, ...) ASE_RETURN_UNLESS (cond, __VA_ARGS__)
72
74#define STRING_VECTOR_FROM_ARRAY(ConstCharArray) ASE_STRING_VECTOR_FROM_ARRAY(ConstCharArray)
75
77#define TEST_INTEGRITY(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
78 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'I' }
79
81#define TEST_BENCHMARK(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
82 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'B' }
83
84namespace Ase {
85
86#ifdef ASE_ENABLE_DEBUG
87constexpr const bool __DEV__ = true;
88#else
89constexpr const bool __DEV__ = false;
90#endif
91
92namespace Test {
93
94// == IntegrityCheck ==
96 using TestFunc = void (*) ();
97 IntegrityCheck (const char *name, TestFunc func, char hint) :
98 name_ (name), func_ (func)
99 {
100 next_ = first_;
101 first_ = this;
102 }
103 static void deferred_init(); // see testing.cc
104private:
105 const char *name_;
106 TestFunc func_;
107 IntegrityCheck *next_;
108 static IntegrityCheck *first_; // see testing.cc
109};
110
111} } // Ase::Test
112
113#endif // __ASE_INTERNAL_HH__
The Anklang C++ API namespace.
Definition api.hh:9
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:25
int32_t int32
A 32-bit signed integer.
Definition cxxaux.hh:28
int16_t int16
A 16-bit signed integer.
Definition cxxaux.hh:27
uint8_t uint8
An 8-bit unsigned integer.
Definition cxxaux.hh:22
int8_t int8
An 8-bit signed integer.
Definition cxxaux.hh:26
int64_t int64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:29
uint32_t unichar
A 32-bit unsigned integer used for Unicode characters.
Definition cxxaux.hh:30
uint16_t uint16
A 16-bit unsigned integer.
Definition cxxaux.hh:23
uint32_t uint32
A 32-bit unsigned integer.
Definition cxxaux.hh:24