xeme/xemeversion.h

Sat, 21 Sep 2024 19:19:25 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sat, 21 Sep 2024 19:19:25 -0500
changeset 49
e02f61a4476e
parent 47
0822a5847e59
permissions
-rw-r--r--

Remove nick and blurb from properties

Also fix a typo.

Testing Done:
Compiled only.

Reviewed at https://reviews.imfreedom.org/r/3519/

/*
 * Copyright (C) 2023 Xeme Developers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#ifndef XEME_VERSION_H
#define XEME_VERSION_H

#include <glib.h>

#include "xemeversionconsts.h"

/* clang-format tries to remove the space after 'if', which confuses
 * gobject-introspection, so turn it off temporarily. */
/* clang-format off */
#if (defined(_WIN32) || defined(__CYGWIN__)) && \
	!defined(XEME_STATIC_COMPILATION)
/* clang-format on */
#define _XEME_EXPORT __declspec(dllexport)
#define _XEME_IMPORT __declspec(dllimport)
#elif __GNUC__ >= 4
#define _XEME_EXPORT __attribute__((visibility("default")))
#define _XEME_IMPORT
#else
#define _XEME_EXPORT
#define _XEME_IMPORT
#endif
#ifdef XEME_COMPILATION
#define _XEME_API _XEME_EXPORT
#else
#define _XEME_API _XEME_IMPORT
#endif

#define _XEME_EXTERN _XEME_API extern

#ifdef XEME_DISABLE_DEPRECATION_WARNINGS
#define XEME_DEPRECATED _XEME_EXTERN
#define XEME_DEPRECATED_FOR(f) _XEME_EXTERN
#define XEME_UNAVAILABLE(maj, min) _XEME_EXTERN
#define XEME_UNAVAILABLE_STATIC_INLINE(maj, min)
#define XEME_UNAVAILABLE_TYPE(maj, min)
#else
#define XEME_DEPRECATED G_DEPRECATED _XEME_EXTERN
#define XEME_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _XEME_EXTERN
#define XEME_UNAVAILABLE(maj, min) G_UNAVAILABLE(maj, min) _XEME_EXTERN
#define XEME_UNAVAILABLE_STATIC_INLINE(maj, min) G_UNAVAILABLE(maj, min)
#define XEME_UNAVAILABLE_TYPE(maj, min) G_UNAVAILABLE(maj, min)
#endif

/**
 * XEME_VERSION_MIN_REQUIRED:
 *
 * A macro that should be defined by the user prior to including the `xeme.h`
 * header.
 *
 * The definition should be one of the predefined Xeme version macros:
 * %XEME_VERSION_0_1, %XEME_VERSION_0_2, ...
 *
 * This macro defines the earliest version of Xeme that the package is required
 * to be able to compile against.
 *
 * If the compiler is configured to warn about the use of deprecated functions,
 * then using functions that were deprecated in version
 * %XEME_VERSION_MIN_REQUIRED or earlier will cause warnings (but using
 * functions deprecated in later releases will not).
 *
 * Since: 0.1
 */

/**
 * XEME_VERSION_CUR_STABLE:
 *
 * A macro that evaluates to the current stable version of xeme, in a format
 * that can be used by the C pre-processor.
 *
 * Since: 0.1
 */
#define XEME_VERSION_CUR_STABLE \
	(G_ENCODE_VERSION(XEME_MAJOR_VERSION, XEME_MINOR_VERSION))

#ifndef XEME_VERSION_MIN_REQUIRED
#define XEME_VERSION_MIN_REQUIRED (XEME_VERSION_CUR_STABLE)
#elif XEME_VERSION_MIN_REQUIRED == 0
#undef XEME_VERSION_MIN_REQUIRED
#define XEME_VERSION_MIN_REQUIRED (XEME_VERSION_CUR_STABLE + 1)
#endif /* XEME_VERSION_MIN_REQUIRED */

#if !defined(XEME_VERSION_MAX_ALLOWED) || (XEME_VERSION_MAX_ALLOWED == 0)
#undef XEME_VERSION_MAX_ALLOWED
#define XEME_VERSION_MAX_ALLOWED (XEME_VERSION_CUR_STABLE)
#endif /* XEME_VERSION_MAX_ALLOWED */

/* sanity checks */
#if XEME_VERSION_MIN_REQUIRED > XEME_VERSION_CUR_STABLE
#error "XEME_VERSION_MIN_REQUIRED must be <= XEME_VERSION_CUR_STABLE"
#endif
#if XEME_VERSION_MAX_ALLOWED < XEME_VERSION_MIN_REQUIRED
#error "XEME_VERSION_MAX_ALLOWED must be >= XEME_VERSION_MIN_REQUIRED"
#endif
#if XEME_VERSION_MIN_REQUIRED < G_ENCODE_VERSION(0, 1)
#error "XEME_VERSION_MIN_REQUIRED must be >= XEME_VERSION_0_1"
#endif

#define XEME_VAR _XEME_EXTERN
#define XEME_AVAILABLE_IN_ALL _XEME_EXTERN

/**
 * XEME_VERSION_0_1:
 *
 * A macro that evaluates to the 0.1 version of xeme, in a format that can be
 * used by the C pre-processor.
 *
 * Since: 0.1
 */
#define XEME_VERSION_0_1 (G_ENCODE_VERSION(0, 1))

#if XEME_VERSION_MAX_ALLOWED < XEME_VERSION_0_1
#define XEME_AVAILABLE_IN_0_1 XEME_UNAVAILABLE(0, 1)
#define XEME_AVAILABLE_STATIC_INLINE_IN_0_1 XEME_UNAVAILABLE_STATIC_INLINE(0, 1)
#define XEME_AVAILABLE_MACRO_IN_0_1 XEME_UNAVAILABLE_MACRO(0, 1)
#define XEME_AVAILABLE_ENUMERATOR_IN_0_1 XEME_UNAVAILABLE_ENUMERATOR(0, 1)
#define XEME_AVAILABLE_TYPE_IN_0_1 XEME_UNAVAILABLE_TYPE(0, 1)
#else
#define XEME_AVAILABLE_IN_0_1 _XEME_EXTERN
#define XEME_AVAILABLE_STATIC_INLINE_IN_0_1
#define XEME_AVAILABLE_MACRO_IN_0_1
#define XEME_AVAILABLE_ENUMERATOR_IN_0_1
#define XEME_AVAILABLE_TYPE_IN_0_1
#endif

G_BEGIN_DECLS

/**
 * XEME_CHECK_VERSION:
 * @major: The major version to check for.
 * @minor: The minor version to check for.
 * @micro: The micro version to check for.
 *
 * Checks the version of xeme being compiled against. See [func@check_version]
 * for a runtime check.
 *
 * Returns: %TRUE if the version is the same or newer than the passed-in
 *          version.
 *
 * Since: 0.1
 */
#define XEME_CHECK_VERSION(major, minor, micro) ((major) == XEME_MAJOR_VERSION && \
                                                 ((minor) < XEME_MINOR_VERSION || \
                                                  ((minor) == XEME_MINOR_VERSION && (micro) <= XEME_MICRO_VERSION)))

/**
 * xeme_check_version:
 * @required_major: the required major version.
 * @required_minor: the required minor version.
 * @required_micro: the required micro version.
 *
 * Checks that the xeme version is compatible with the requested version.
 *
 * Returns: %NULL if the versions are compatible, or a string describing
 *          the version mismatch if not compatible.
 *
 * Since: 0.1
 */
XEME_AVAILABLE_IN_ALL
const char *xeme_check_version(guint required_major, guint required_minor, guint required_micro);

/**
 * xeme_version:
 *
 * The full version string of the running xeme.
 *
 * Since: 0.1
 */
XEME_VAR const char *xeme_version;

/**
 * xeme_major_version:
 *
 * The major version of the running xeme. Contrast with #XEME_MAJOR_VERSION,
 * which expands at compile time to the major version of xeme being compiled
 * against.
 *
 * Since: 0.1
 */
XEME_VAR const guint xeme_major_version;

/**
 * xeme_minor_version:
 *
 * The minor version of the running xeme. Contrast with #XEME_MINOR_VERSION,
 * which expands at compile time to the minor version of xeme being compiled
 * against.
 *
 * Since: 0.1
 */
XEME_VAR const guint xeme_minor_version;

/**
 * xeme_micro_version:
 *
 * The micro version of the running xeme. Contrast with #XEME_MICRO_VERSION,
 * which expands at compile time to the micro version of xeme being compiled
 * against.
 *
 * Since: 0.1
 */
XEME_VAR const guint xeme_micro_version;

G_END_DECLS

#endif /* XEME_VERSION_CONSTS_H */

mercurial