VapourSynth-llvmexpr
Loading...
Searching...
No Matches
meta.expr
Go to the documentation of this file.
1# Copyright (C) 2025 yuygfgg
2#
3# This file is part of Vapoursynth-llvmexpr.
4#
5# Vapoursynth-llvmexpr is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# Vapoursynth-llvmexpr is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with Vapoursynth-llvmexpr. If not, see <https://www.gnu.org/licenses/>.
17
18@define ___stdlib_meta_ERROR(msg) static_assert(0, msg)
19
20@define ___stdlib_meta_ASSERT_CONST(expr, context, message) (is_consteval(expr) ? static_assert(expr, ___stdlib_meta__PASTE(context, message)) : ___stdlib_meta_ERROR(___stdlib_meta__PASTE(context, _must_be_a_constant_expression)))
21
22@define ___stdlib_meta__PASTE(a, b) a@@b
23
24@define ___stdlib_meta_PASTE(a, b) ___stdlib_meta__PASTE(a, b)
25
26@define ___stdlib_meta__DEC(n) ((n) - 1)
27
28@define ___stdlib_meta__JOIN(count, macro, sep) ((count) == 1 ? macro(0) : (___stdlib_meta__JOIN(___stdlib_meta__DEC(count), macro, sep) sep macro(___stdlib_meta__DEC(count))))
29
30@define ___stdlib_meta_JOIN(count, macro, sep) (___stdlib_meta_ASSERT_CONST(count > 0, First_argument, _must_be_a_positive_integer) ? ___stdlib_meta__JOIN(count, macro, sep) : 0)
31
32@define ___stdlib_meta__UNROLL(count, macro) ((count) == 1 ? macro(0) : ___stdlib_meta__UNROLL(___stdlib_meta__DEC(count), macro); macro(___stdlib_meta__DEC(count)))
33
34@define ___stdlib_meta_UNROLL(count, macro) (___stdlib_meta_ASSERT_CONST(count > 0, First_argument, _must_be_a_positive_integer) ? ___stdlib_meta__UNROLL(count, macro) : 0)