Metalang99 1.13.3
Full-blown preprocessor metaprogramming
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
6#ifndef ML99_UTIL_H
7#define ML99_UTIL_H
8
9#include <metalang99/priv/util.h>
10
11#include <metalang99/ident.h> // For backwards compatibility.
12#include <metalang99/lang.h>
13
34#define ML99_catEval(a, b) ML99_call(ML99_catEval, a, b)
35
53#define ML99_cat(a, b) ML99_call(ML99_cat, a, b)
54
58#define ML99_cat3(a, b, c) ML99_call(ML99_cat3, a, b, c)
59
63#define ML99_cat4(a, b, c, d) ML99_call(ML99_cat4, a, b, c, d)
64
77#define ML99_stringify(...) ML99_call(ML99_stringify, __VA_ARGS__)
78
82#define ML99_empty(...) ML99_callUneval(ML99_empty, )
83
96#define ML99_id(...) ML99_call(ML99_id, __VA_ARGS__)
97
110#define ML99_const(x, a) ML99_call(ML99_const, x, a)
111
124#define ML99_flip(f) ML99_call(ML99_flip, f)
125
138#define ML99_uncomma(...) ML99_call(ML99_uncomma, __VA_ARGS__)
139
165#define ML99_reify(f) ML99_call(ML99_reify, f)
166
184#define ML99_todo(f) ML99_call(ML99_todo, f)
185
200#define ML99_todoWithMsg(f, message) ML99_call(ML99_todoWithMsg, f, message)
201
220#define ML99_unimplemented(f) ML99_call(ML99_unimplemented, f)
221
236#define ML99_unimplementedWithMsg(f, message) ML99_call(ML99_unimplementedWithMsg, f, message)
237
238#ifdef __COUNTER__
239
270#define ML99_GEN_SYM(prefix, id) ML99_CAT4(prefix, id, _, __COUNTER__)
271
272#endif // __COUNTER__
273
295#define ML99_TRAILING_SEMICOLON(...) struct ml99_priv_trailing_semicolon
296
312#define ML99_CAT_PRIMITIVE(a, b) a##b
313
317#define ML99_CAT3_PRIMITIVE(a, b, c) a##b##c
318
322#define ML99_CAT4_PRIMITIVE(a, b, c, d) a##b##c##d
323
339#define ML99_STRINGIFY_PRIMITIVE(...) #__VA_ARGS__
340
352#define ML99_LPAREN(...) (
353
359#define ML99_RPAREN(...) )
360
364#define ML99_COMMA(...) ,
365
369#define ML99_GCC_PRAGMA(str) ML99_PRIV_GCC_PRAGMA(str)
370
374#define ML99_CLANG_PRAGMA(str) ML99_PRIV_CLANG_PRAGMA(str)
375
376#define ML99_CAT(a, b) ML99_CAT_PRIMITIVE(a, b)
377#define ML99_CAT3(a, b, c) ML99_CAT3_PRIMITIVE(a, b, c)
378#define ML99_CAT4(a, b, c, d) ML99_CAT4_PRIMITIVE(a, b, c, d)
379#define ML99_STRINGIFY(...) ML99_STRINGIFY_PRIMITIVE(__VA_ARGS__)
380#define ML99_EMPTY(...)
381#define ML99_ID(...) __VA_ARGS__
382
383#ifndef DOXYGEN_IGNORE
384
385#define ML99_catEval_IMPL(a, b) a##b
386#define ML99_cat_IMPL(a, b) v(a##b)
387#define ML99_cat3_IMPL(a, b, c) v(a##b##c)
388#define ML99_cat4_IMPL(a, b, c, d) v(a##b##c##d)
389#define ML99_stringify_IMPL(...) v(ML99_STRINGIFY(__VA_ARGS__))
390#define ML99_empty_IMPL(...) v(ML99_EMPTY())
391#define ML99_id_IMPL(...) v(ML99_ID(__VA_ARGS__))
392#define ML99_const_IMPL(x, _a) v(x)
393#define ML99_flip_IMPL(f) ML99_appl_IMPL(ML99_PRIV_flip, f)
394#define ML99_PRIV_flip_IMPL(f, a, b) ML99_appl2_IMPL(f, b, a)
395#define ML99_uncomma_IMPL(...) __VA_ARGS__
396
397#define ML99_reify_IMPL(f) ML99_appl_IMPL(ML99_PRIV_reify, f)
398#define ML99_PRIV_reify_IMPL(f, ...) v(f(__VA_ARGS__))
399
400// clang-format off
401#define ML99_todo_IMPL(f) ML99_fatal(f, not yet implemented)
402#define ML99_todoWithMsg_IMPL(f, message) ML99_fatal(f, not yet implemented: message)
403
404#define ML99_unimplemented_IMPL(f) ML99_fatal(f, not implemented)
405#define ML99_unimplementedWithMsg_IMPL(f, message) ML99_fatal(f, not implemented: message)
406// clang-format on
407
408#if defined(__GNUC__) && !defined(__clang__)
409#define ML99_PRIV_GCC_PRAGMA(str) _Pragma(str)
410#else
411#define ML99_PRIV_GCC_PRAGMA(str)
412#endif
413
414#if defined(__clang__)
415#define ML99_PRIV_CLANG_PRAGMA(str) _Pragma(str)
416#else
417#define ML99_PRIV_CLANG_PRAGMA(str)
418#endif
419
420// Arity specifiers {
421
422#define ML99_catEval_ARITY 2
423#define ML99_cat_ARITY 2
424#define ML99_cat3_ARITY 3
425#define ML99_cat4_ARITY 4
426#define ML99_stringify_ARITY 1
427#define ML99_empty_ARITY 1
428#define ML99_id_ARITY 1
429#define ML99_const_ARITY 2
430#define ML99_flip_ARITY 1
431#define ML99_uncomma_ARITY 1
432#define ML99_reify_ARITY 1
433#define ML99_todo_ARITY 1
434#define ML99_todoWithMsg_ARITY 2
435#define ML99_unimplemented_ARITY 1
436#define ML99_unimplementedWithMsg_ARITY 2
437
438#define ML99_PRIV_flip_ARITY 3
439#define ML99_PRIV_reify_ARITY 2
440// } (Arity specifiers)
441
442#endif // DOXYGEN_IGNORE
443
444#endif // ML99_UTIL_H
Identifiers: [a-zA-Z0-9_]+.
The core metalanguage.