Anklang-0.3.0.dev956+gd75ac925 anklang-0.3.0.dev956+gd75ac925
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#pragma once
3
4// Import simple ASE types into global scope
5using Ase::uint8;
6using Ase::uint16;
7using Ase::uint32;
8using Ase::uint64;
9using Ase::int8;
10using Ase::int16;
11using Ase::int32;
12using Ase::int64;
13using Ase::unichar;
14using Ase::String;
15
17#define _(...) ::Ase::ase_gettext (__VA_ARGS__)
19#define N_(str) (str)
20
22#define APPLY_IDL_PROPERTY(lvalue, rvalue) ASE_OBJECT_APPLY_IDL_PROPERTY(lvalue, rvalue)
23
25#define ARRAY_SIZE(array) ASE_ARRAY_SIZE (array)
26
28#define assert_return(expr, ...) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); return __VA_ARGS__; } while (0)
30#define assert_return_unreached(...) do { ::Ase::assertion_failed (""); return __VA_ARGS__; } while (0)
32#define assert_warn(expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
34#define assert_paranoid(expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
36#define assert_unreached() __builtin_unreachable()
38#define paranoid(expr) ASE_PARANOID (expr)
39
41#define if_constexpr if constexpr
42
44#define CQUOTE(str) ASE_CQUOTE(str)
45
46#ifdef __G_MACROS_H__
47#undef MAX
48#undef MIN
49#undef CLAMP
50#endif
51
53#define MAX(a,b) ((a) >= (b) ? (a) : (b))
54
56#define MIN(a,b) ((a) <= (b) ? (a) : (b))
57
59#define CLAMP(v,mi,ma) ((v) < (mi) ? (mi) : ((v) > (ma) ? (ma) : (v)))
60
62#define ISLIKELY(cond) ASE_ISLIKELY (cond)
64#define UNLIKELY(cond) ASE_UNLIKELY (cond)
65
67#define ALIGNMENT16(pointer) ASE_ALIGNMENT16 (pointer)
69#define ALIGNED16(pointer) ASE_ALIGNED16 (pointer)
70
72#define return_unless(cond, ...) ASE_RETURN_UNLESS (cond, __VA_ARGS__)
73
75#define STRING_VECTOR_FROM_ARRAY(ConstCharArray) ASE_STRING_VECTOR_FROM_ARRAY(ConstCharArray)
76
78#define TEST_INTEGRITY(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
79 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'I' }
80
82#define TEST_BENCHMARK(FUNC) static void FUNC() __attribute__ ((__cold__, __unused__)); \
83 static ::Ase::Test::IntegrityCheck ASE_CPP_PASTE2 (__Ase__Test__IntegrityCheck__line, __LINE__) { #FUNC, FUNC, 'B' }
84
85namespace Ase {
86
87#ifdef ASE_ENABLE_DEBUG
88constexpr const bool __DEV__ = true;
89#else
90constexpr const bool __DEV__ = false;
91#endif
92
93namespace Test {
94
95// == IntegrityCheck ==
97 using TestFunc = void (*) ();
98 IntegrityCheck (const char *name, TestFunc func, char hint) :
99 name_ (name), func_ (func)
100 {
101 next_ = first_;
102 first_ = this;
103 }
104 static void deferred_init(); // see testing.cc
105private:
106 const char *name_;
107 TestFunc func_;
108 IntegrityCheck *next_;
109 static IntegrityCheck *first_; // see testing.cc
110};
111
112} } // Ase::Test
113
The Anklang C++ API namespace.
Definition api.hh:8
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:24
int32_t int32
A 32-bit signed integer.
Definition cxxaux.hh:27
int16_t int16
A 16-bit signed integer.
Definition cxxaux.hh:26
uint8_t uint8
An 8-bit unsigned integer.
Definition cxxaux.hh:21
int8_t int8
An 8-bit signed integer.
Definition cxxaux.hh:25
int64_t int64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:28
uint32_t unichar
A 32-bit unsigned integer used for Unicode characters.
Definition cxxaux.hh:29
uint16_t uint16
A 16-bit unsigned integer.
Definition cxxaux.hh:22
uint32_t uint32
A 32-bit unsigned integer.
Definition cxxaux.hh:23