/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * Implements various macros meant to ease the use of variadic macros.
*/
// Concatenates pre-processor tokens in a way that can be used with __LINE__. #define MOZ_CONCAT2(x, y) x##y #define MOZ_CONCAT(x, y) MOZ_CONCAT2(x, y)
/* * MOZ_ARG_COUNT(...) counts the number of variadic arguments. * You must pass in between 0 and 50 (inclusive) variadic arguments. * For example: * * MOZ_ARG_COUNT() expands to 0 * MOZ_ARG_COUNT(a) expands to 1 * MOZ_ARG_COUNT(a, b) expands to 2 * * Implementation notes: * The `##__VA_ARGS__` form is a GCC extension that removes the comma if * __VA_ARGS__ is empty. It is supported by Clang too. MSVC ignores ##, * and its default behavior is already to strip the comma when __VA_ARGS__ * is empty. * * So MOZ_MACROARGS_ARG_COUNT_HELPER() expands to * (_, 50, 49, ...) * MOZ_MACROARGS_ARG_COUNT_HELPER(a) expands to * (_, a, 50, 49, ...) * etc.
*/ #define MOZ_ARG_COUNT(...) \
MOZ_MACROARGS_ARG_COUNT_HELPER2(MOZ_MACROARGS_ARG_COUNT_HELPER(__VA_ARGS__))
/* * MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) counts the number of variadic * arguments and prefixes it with |aPrefix|. For example: * * MOZ_PASTE_PREFIX_AND_ARG_COUNT(, foo, 42) expands to 2 * MOZ_PASTE_PREFIX_AND_ARG_COUNT(A, foo, 42, bar) expands to A3 * MOZ_PASTE_PREFIX_AND_ARG_COUNT(A) expands to A0 * MOZ_PASTE_PREFIX_AND_ARG_COUNT() expands to 0, but MSVC warns there * aren't enough arguments given. * * You must pass in between 0 and 50 (inclusive) variadic arguments, past * |aPrefix|.
*/ #define MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE(a, b) a b #define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) \
MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE(MOZ_CONCAT, \
(aPrefix, MOZ_ARG_COUNT(__VA_ARGS__)))
/* * MOZ_ARGS_AFTER_N expands to its arguments excluding the first |N| * arguments. For example: * * MOZ_ARGS_AFTER_2(a, b, c, d) expands to: c, d
*/ #define MOZ_ARGS_AFTER_1(a1, ...) __VA_ARGS__ #define MOZ_ARGS_AFTER_2(a1, a2, ...) __VA_ARGS__
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.