Anklang-0.3.0.dev595+g65331842 anklang-0.3.0.dev595+g65331842
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()
39#define paranoid(expr) ASE_PARANOID (expr)
40
42#define if_constexpr if constexpr
43
45#define CQUOTE(str) ASE_CQUOTE(str)
46
47#ifdef __G_MACROS_H__
48#undef MAX
49#undef MIN
50#undef CLAMP
51#endif
52
54#define MAX(a,b) ((a) >= (b) ? (a) : (b))
55
57#define MIN(a,b) ((a) <= (b) ? (a) : (b))
58
60#define CLAMP(v,mi,ma) ((v) < (mi) ? (mi) : ((v) > (ma) ? (ma) : (v)))
61
63#define ISLIKELY(cond) ASE_ISLIKELY (cond)
65#define UNLIKELY(cond) ASE_UNLIKELY (cond)
66
68#define ALIGNMENT16(pointer) ASE_ALIGNMENT16 (pointer)
70#define ALIGNED16(pointer) ASE_ALIGNED16 (pointer)
71
73#define return_unless(cond, ...) ASE_RETURN_UNLESS (cond, __VA_ARGS__)
74
76#define STRING_VECTOR_FROM_ARRAY(ConstCharArray) ASE_STRING_VECTOR_FROM_ARRAY(ConstCharArray)
77
79#define TEST_INTEGRITY(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
80 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'I' }
81
83#define TEST_BENCHMARK(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
84 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'B' }
85
86namespace Ase {
87
88#ifdef ASE_ENABLE_DEBUG
89constexpr const bool __DEV__ = true;
90#else
91constexpr const bool __DEV__ = false;
92#endif
93
94namespace Test {
95
96// == IntegrityCheck ==
98 using TestFunc = void (*) ();
99 IntegrityCheck (const char *name, TestFunc func, char hint) :
100 name_ (name), func_ (func)
101 {
102 next_ = first_;
103 first_ = this;
104 }
105 static void deferred_init(); // see testing.cc
106private:
107 const char *name_;
108 TestFunc func_;
109 IntegrityCheck *next_;
110 static IntegrityCheck *first_; // see testing.cc
111};
112
113} } // Ase::Test
114
115#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