acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
_macro.h
1
// Created by camilo on 2022-11-08 21:46 <3ThomasBorregaardSorensen!!
2
#pragma once
3
4
// Sorensen oe
5
6
7
#include "acme/platform/_referencing_debugging.h"
8
9
#include "acme/platform/release_time_for_project.h"
10
11
12
#define __RELEASE_TIME(library) library ## _release_time
13
#define __DECLARE_RELEASE_TIME(library) extern "C" release_time_for_project __RELEASE_TIME(library)()
14
#define __DECLARE_APPLICATION_RELEASE_TIME() release_time_for_project release_time() override
15
#define __IMPLEMENT_APPLICATION_RELEASE_TIME(library) \
16
extern "C" release_time_for_project __RELEASE_TIME(library)(); \
17
namespace library { \
18
release_time_for_project application::release_time() { return __RELEASE_TIME(library)(); } \
19
}
// namespace library
20
21
22
#define ALOG_CONTEXT context_trace_object()
23
24
#define _S_ALOG_CONTEXT ::context_trace_object()
25
26
//#define __STD_FORMAT__
27
28
//#include <format>
29
30
#ifdef WINDOWS_DESKTOP
31
32
33
#if defined _M_IX86
34
#define _ACME_LINKER_SYMBOL_PREFIX "_"
35
#elif defined _M_X64 || defined _M_ARM || defined _M_ARM64
36
#define _ACME_LINKER_SYMBOL_PREFIX ""
37
#else
38
#error Unsupported architecture
39
#endif
40
41
42
#endif
43
44
45
46
#if defined(APPLE_IOS) || defined(__ANDROID__) || defined(UNIVERSAL_WINDOWS)
47
48
#define MOBILE_PLATFORM 1
49
50
#else
51
52
#define MOBILE_PLATFORM 0
53
54
#endif
55
56
#if defined(WINDOWS_DESKTOP) || defined(LINUX) || defined(MACOS) || defined(__BSD__)
57
#define DESKTOP_PLATFORM
58
#endif
59
60
61
#if defined(__ANDROID__) || defined(APPLE_IOS) || defined(UNIVERSAL_WINDOWS)
62
#define SANDBOXED_PLATFORM
63
#endif
64
65
#if defined(__ANDROID__) || defined(APPLE_IOS) || defined(UNIVERSAL_WINDOWS)
66
#define SANDBOXED_WINDOWING
67
#endif
68
69
70
#define _MAKE_STRING(identifier) #identifier
71
#define MAKE_STRING(identifier) _MAKE_STRING(identifier)
72
#define STRING_PREFIX_LAYER_NAMESPACE(str) MAKE_STRING(LAYER_NAMESPACE) str
73
74
#define PLATFORM_INCLUDE(include) MAKE_STRING(__IDENTIFIER(OPERATING_SYSTEM_NAMESPACE)/include)
75
76
#ifndef __STRING
77
# define __STRING(x) "x"
78
#endif
79
80
81
#define __EVALUATE(xxx) xxx
82
#ifndef __CONCATENATE
83
#define __CONCATENATE(xxx, yyy) xxx ## yyy
84
#endif
85
86
#define __CONCATENATE3(xxx, yyy, zzz) xxx ## yyy ## zzz
87
88
89
#define TOKEN_CONCATENATE_PHASE1(x, y) x ## y
90
91
#define TOKEN_CONCATENATE(x, y) TOKEN_CONCATENATE_PHASE1(x, y)
92
93
94
95
#define ___PREFIX_UNDERSCORE(prefix,name) prefix##_##name
96
#define __PREFIX_UNDERSCORE(prefix,name) ___PREFIX_UNDERSCORE(prefix,name)
97
#define __EVALUATE_MACRO(name) name
98
99
101
102
103
104
105
106
107
108
109
110
//#define __CONCAT3____(xxx, yyy, zzz) xxx ## yyy ## zzz
111
112
113
// #define __unsigned_short(a, b) ((::u16)(((::u8)(((::uptr)(a)) & 0xff)) | ((::u16)((::u8)(((::uptr)(b)) & 0xff))) << 8))
114
// #define as_u32(a, b) ((::u32)(((::u16)(((::uptr)(a)) & 0xffff)) | ((::u32)((::u16)(((::uptr)(b)) & 0xffff))) << 16))
115
116
117
// #ifdef __cplusplus
118
119
120
// #define as_u64(a, b) (((::u64)(((::u32)(((::u64)(a)) & 0xffffffff)) | ((::u64)((::u32)(((::u64)(b)) & 0xffffffff))) << 32)))
121
122
123
// #else
124
125
// #define __MAKE_LONG64(a, b) (((::u64)(((::u32)(((::u64)(a)) & 0xffffffff)) | ((::u64)((::u32)(((::u64)(b)) & 0xffffffff))) << 32)))
126
// #define __u64(a, b) (((::u64)(((::u32)(((::u64)(a)) & 0xffffffff)) | ((::u64)((::u32)(((::u64)(b)) & 0xffffffff))) << 32)))
127
128
// #endif
129
130
// #define lower_unsigned_short(u) ((::u16)(((::uptr)(u)) & 0xffff))
131
// #define upper_unsigned_short(u) ((::u16)((((::uptr)(u)) >> 16) & 0xffff))
132
// #define lower_u32(u) ((::u32)(u))
133
// #define upper_u32(u) ((::u32)(((u) >> 32) & 0xffffffff))
134
135
// #define u32_x(u) ((::i16)lower_unsigned_short(u))
136
// #define u32_y(u) ((::i16)upper_unsigned_short(u))
137
138
// #define __u32xy(u) u32_x(u), u32_y(u)
139
140
// #define u64_x(u) ((::i32)lower_u32(u))
141
// #define u64_y(u) ((::i32)upper_u32(u))
142
143
// #define __u64xy(u) u64_x(u), u64_y(u)
144
145
146
//#define GET_X_LPARAM64(lparam) ((::i32)(::i16)lower_u32(lparam))
147
//#define GET_Y_LPARAM64(lparam) ((::i32)(::i16)upper_u32(lparam))
148
149
150
151
152
// #define make_int(a, b) ((::i32)(((::u16)(((::uptr)(a)) & 0xffff)) | ((::u32)((::u16)(((::uptr)(b)) & 0xffff))) << 16))
153
154
// #define __MAKE_LONG64(a, b) ((::i64)(((::u32)(((::u64)(a)) & 0xffffffff)) | ((::u64)((::u32)(((::u64)(b)) & 0xffffffff))) << 32))
155
156
// #define make_u32(l, h) ((::uptr)(::u32)make_int(l, h))
157
158
//#define lower_byte(w) ((::u8)(((dword_ptr)(w)) & 0xff))
159
160
161
162
//
163
//
164
//#if !defined(O_BINARY) && !defined(WINDOWS)
165
//# define O_BINARY 0
166
//#endif
167
//
168
169
170
171
// #undef _
172
173
// #define _(str) (__get_text(str))
174
175
176
#define DECLARE_NEW_ACME_LIBRARY(X) extern "C" \
177
::acme::library* X##_new_acme_library()
178
179
180
#define REGISTER_GET_NEW_ACME_LIBRARY(X) register_get_new_acme_library(#X, &X##_get_new_library)
181
182
183
184
185
//#define gp(TYPE) ::guard_pointer < TYPE >
186
//
187
188
#ifdef __APPLE__
189
#undef err_none
190
#endif
191
192
#define BAD_WCHAR ((::wide_character)(-1))
193
194
195
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
196
197
198
199
// return - result - if not ok
200
#ifndef RINOK
201
#define RINOK(x) { ::i32 __result__ = (x); if (__result__ != 0) return __result__; }
202
#endif
203
204
// throw ::exception( - exception - result exception - if not ok
205
#ifndef TINOK
206
#define TINOK(e, x) { ::i32 __result__ = (x); if (__result__ != 0) throw ::exception(e(get_app(), __result__)); }
207
#endif
208
209
210
#define SECOND_NANOS 1'000'000'000
211
212
213
214
215
216
//
217
//#define TRACE_FORMATTED_CATEGORY_INFORMATION(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_information )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
218
//#define TRACE_FORMATTED_CATEGORY_WARNING(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_warning )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
219
//#define TRACE_FORMATTED_CATEGORY_ERROR(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_error )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
220
//#define TRACE_FORMATTED_CATEGORY_FATAL(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_fatal )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
221
//
222
//
223
//#define TRACE_CATEGORY_INFORMATION(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_information )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
224
//#define TRACE_CATEGORY_WARNING(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_warning )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
225
//#define TRACE_CATEGORY_ERROR(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_error )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
226
//#define TRACE_CATEGORY_FATAL(p, etracecategory, ...) p->log_statement()(p)(e_trace_level_fatal )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
227
//
228
//
229
//#define TRACE_FORMATTED_INFORMATION(p, ...) p->log_statement()(p)(e_trace_level_information )() (__VA_ARGS__)
230
//#define TRACE_FORMATTED_WARNING(p, ...) p->log_statement()(p)(e_trace_level_warning )() (__VA_ARGS__)
231
//#define TRACE_FORMATTED_ERROR(p, ...) p->log_statement()(p)(e_trace_level_error )() (__VA_ARGS__)
232
//#define TRACE_FORMATTED_FATAL(p, ...) p->log_statement()(p)(e_trace_level_fatal )() (__VA_ARGS__)
233
//
234
//
235
//#define TRACE_INFORMATION(p, ...) p->log_statement()(p)(e_trace_level_information )() << __VA_ARGS__
236
//#define TRACE_WARNING(p, ...) p->log_statement()(p)(e_trace_level_warning )() << __VA_ARGS__
237
//#define TRACE_ERROR(p, ...) p->log_statement()(p)(e_trace_level_error )() << __VA_ARGS__
238
//#define TRACE_FATAL(p, ...) p->log_statement()(p)(e_trace_level_fatal )() << __VA_ARGS__
239
//
240
//
241
//#define FORMATTED_CATEGORY_INFORMATION(etracecategory, ...) log_statement()(trace_this())(e_trace_level_information )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
242
//#define FORMATTED_CATEGORY_WARNING(etracecategory, ...) log_statement()(trace_this())(e_trace_level_warning )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
243
//#define FORMATTED_CATEGORY_ERROR(etracecategory, ...) log_statement()(trace_this())(e_trace_level_error )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
244
//#define FORMATTED_CATEGORY_FATAL(etracecategory, ...) log_statement()(trace_this())(e_trace_level_fatal )() (e_trace_category_ ## etracecategory, __VA_ARGS__)
245
//
246
//
247
//#define CATEGORY_INFORMATION(etracecategory, ...) log_statement()(trace_this())(e_trace_level_information )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
248
//#define CATEGORY_WARNING(etracecategory, ...) log_statement()(trace_this())(e_trace_level_warning )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
249
//#define CATEGORY_ERROR(etracecategory, ...) log_statement()(trace_this())(e_trace_level_error )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
250
//#define CATEGORY_FATAL(etracecategory, ...) log_statement()(trace_this())(e_trace_level_fatal )() (e_trace_category_ ## etracecategory) << __VA_ARGS__
251
//
252
//
253
//#define LOG_FORMATTED_INFORMATION(...) log_statement()(trace_this())(e_trace_level_information )() (__VA_ARGS__)
254
//#define LOG_FORMATTED_WARNING(...) log_statement()(trace_this())(e_trace_level_warning )() (__VA_ARGS__)
255
//#define LOG_FORMATTED_ERROR(...) log_statement()(trace_this())(e_trace_level_error )() (__VA_ARGS__)
256
//#define LOG_FORMATTED_FATAL(...) log_statement()(trace_this())(e_trace_level_fatal )() (__VA_ARGS__)
257
//
258
//
259
//#define LOG_INFORMATION(...) log_statement()(trace_this())(e_trace_level_information )() << e_start_reference << __VA_ARGS__
260
//#define LOG_WARNING(...) log_statement()(trace_this())(e_trace_level_warning )() << e_start_reference << __VA_ARGS__
261
//#define LOG_ERROR(...) log_statement()(trace_this())(e_trace_level_error )() << e_start_reference << __VA_ARGS__
262
//#define LOG_FATAL(...) log_statement()(trace_this())(e_trace_level_fatal )() << e_start_reference << __VA_ARGS__
263
//
264
//
265
//#define information(...) LOG_FORMATTED_INFORMATION(__VA_ARGS__)
266
//#define warning(...) LOG_FORMATTED_WARNING(__VA_ARGS__)
267
//#define error(...) LOG_FORMATTED_ERROR(__VA_ARGS__)
268
//#define fatal(...) LOG_FORMATTED_FATAL(__VA_ARGS__)
269
//
270
//
271
//#define log_information((...) LOG_INFORMATION(__VA_ARGS__)
272
//#define log_warning(...) LOG_WARNING(__VA_ARGS__)
273
//#define log_error(...) LOG_ERROR(__VA_ARGS__)
274
//#define log_fatal(...) LOG_FATAL(__VA_ARGS__)
275
//
276
//
281
//
282
//
283
//#define information(...) information(__VA_ARGS__)
284
//#define information(...) log_information((__VA_ARGS__)
285
//
286
287
//#define LOG_INFORMATION log_information()()
288
//#define LOG_WARNING log_warning()()
289
//#define LOG_ERROR log_error()()
290
//#define LOG_FATAL log_fatal()()
291
//
292
//
293
//#define INFORMATION LOG_INFORMATION
294
//#define WARNING LOG_WARNING
295
//#define ERROR LOG_ERROR
296
//#define FATAL LOG_FATAL
297
298
#ifdef _WIN32
299
300
301
#define LONG_IS_32BIT 1
302
#define LONG_IS_64BIT 0
303
304
305
#else
306
307
308
#if OSBIT == 64
309
310
311
#define LONG_IS_32BIT 0
312
#define LONG_IS_64BIT 1
313
314
315
#else
316
317
318
#define LONG_IS_32BIT 1
319
#define LONG_IS_64BIT 0
320
321
322
#endif
323
324
325
#endif
326
327
328
#if OSBIT == 64
329
330
#define PRI0xPTR "016" PRIxPTR
331
332
#else
333
334
#define PRI0xPTR "08" PRIxPTR
335
336
#endif
337
338
339
340
#define IMPL_OPERATOR_PLUS(type) \
341
template < typename TYPE > \
342
type operator + (const TYPE & t) const { auto copy = *this; copy.add(t); return copy; }
343
344
345
//#define TOKENPASTE_PROCESS(x, y) x ## y
346
//#define TOKEN_CONCATENATE(x, y) TOKENPASTE_PROCESS(x, y)
347
#define COUNTER_TOKEN(token) TOKEN_CONCATENATE(token, __COUNTER__)
348
349
350
#define __DEBUG_POWER
351
352
353
#if defined(__cplusplus)
354
355
#define DECL_EXTERN_C extern "C"
356
#define BEGIN_EXTERN_C extern "C" {
357
#define END_EXTERN_C }
358
359
#else
360
361
#define DECL_EXTERN_C
362
#define BEGIN_EXTERN_C
363
#define END_EXTERN_C
364
365
#endif
366
367
368
369
// #ifndef i32_x
370
// #define lparam_int_x(lparam) ((::i32)(::i16)LOWORD(lparam))
371
// #endif
372
373
374
// #ifndef i32_y
375
// #define lparam_int_y(lparam) ((::i32)(::i16)HIWORD(lparam))
376
// #endif
377
378
379
// #ifndef lower_u32
380
// #define lower_u32(l) ((::u32)(((::u64)(l)) & 0xffffffffu))
381
// #endif
382
// #ifndef upper_u32
383
// #define upper_u32(l) ((::u32)((((::u64)(l)) >> 32) & 0xffffffffu))
384
// #endif
385
386
388
//#define SAFE_BOOL_OPERATOR(type) \
389
//typedef void (type:: * bool_type)() const; \
390
//constexpr void this_type_does_not_support_comparisons() const {} \
391
//constexpr operator bool_type() const { return this->is_set() ? &type::this_type_does_not_support_comparisons : 0; }
393
394
395
#define DECLARE_FACTORY(name) \
396
__FACTORY_IMPORT void TOKEN_CONCATENATE(name, _factory)(::factory::factory * pfactory)
397
398
399
#define IMPLEMENT_FACTORY(name) \
400
__FACTORY_EXPORT void TOKEN_CONCATENATE(name, _factory)(::factory::factory * pfactory)
401
402
#define CALL_FACTORY(name) \
403
TOKEN_CONCATENATE(name, _factory)(pfactory)
404
405
406
#if defined(MACOS) || defined(WINDOWS_DESKTOP) || defined(LINUX) || defined(__BSD__)
407
#define IS_DESKTOP_SYSTEM() (true)
408
#else
409
#define IS_DESKTOP_SYSTEM() (false)
410
#endif
411
412
413
#define sizeof_in_bits(TYPE) (sizeof(TYPE) * 8)
414
415
416
417
418
_STUD_API
bool
is_system(enum_operating_system eoperatingsystem)
noexcept
{
419
if
(eoperatingsystem == e_operating_system_windows) {
420
return
is_windows();
421
}
422
else
if
(eoperatingsystem == e_operating_system_linux) {
423
return
is_linux();
424
}
425
else
if
(eoperatingsystem == e_operating_system_unix) {
426
return
is_unix();
427
}
428
else
if
(eoperatingsystem == e_operating_system_macos) {
429
return
is_macos();
430
}
431
else
if
(eoperatingsystem == e_operating_system_freebsd) {
432
return
is_freebsd();
433
}
434
else
if
(eoperatingsystem == e_operating_system_android) {
435
return
is_android();
436
}
437
else
{
438
return
false
;
439
}
440
}
441
442
#define _STUD_MAKE_NONCOPYABLE(type) _STUD_API type(const ::platform::type &) noexcept = delete; \
443
_STUD_API type& operator=(const ::platform::type &) noexcept = delete
444
#define _STUD_MAKE_NONMOVEABLE(type) _STUD_API type(type&&) noexcept = delete;
445
446
//_STUD_API_END
447
include
_macro.h
Generated by
1.17.0