| |
| /* |
| * |
| * Copyright (c) 2018-2019 Google LLC. |
| * Copyright (c) 2014-2018 Nest Labs, Inc. |
| * All rights reserved. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| /** |
| * @file |
| * This file defines constants and macros for introspecting and |
| * manipulating Weave versions. |
| * |
| * !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! |
| * |
| * DO NOT EDIT THIS FILE! This file is automatically-generated by |
| * the 'gen-weave-version' script. |
| * |
| * The constants and macros defined here may be used to, for , |
| * example, conditionally-compile older, newer, or changed Weave |
| * APIs based on the Weave version. For example: |
| * |
| * @code |
| * #if WEAVE_VERSION_CODE >= WEAVE_VERSION_CODE_ENCODE(1, 5, 0) |
| * ... |
| * #else |
| * ... |
| * #endif |
| * @endcode |
| * |
| */ |
| |
| #ifndef WEAVEVERSION_H_ |
| #define WEAVEVERSION_H_ |
| |
| #define _WEAVE_VERSION_CODE_MAJOR_WIDTH 8 |
| #define _WEAVE_VERSION_CODE_MINOR_WIDTH 8 |
| #define _WEAVE_VERSION_CODE_PATCH_WIDTH 8 |
| |
| #define _WEAVE_VERSION_CODE_MAJOR_MASK ((1 << _WEAVE_VERSION_CODE_MAJOR_WIDTH) - 1) |
| #define _WEAVE_VERSION_CODE_MINOR_MASK ((1 << _WEAVE_VERSION_CODE_MINOR_WIDTH) - 1) |
| #define _WEAVE_VERSION_CODE_PATCH_MASK ((1 << _WEAVE_VERSION_CODE_PATCH_WIDTH) - 1) |
| |
| #define _WEAVE_VERSION_CODE_MAJOR_SHIFT 24 |
| #define _WEAVE_VERSION_CODE_MINOR_SHIFT 16 |
| #define _WEAVE_VERSION_CODE_PATCH_SHIFT 8 |
| |
| /** |
| * @def WEAVE_VERSION_CODE_ENCODE(major, minor, patch) |
| * |
| * @brief |
| * Encode a Weave version code from its constituent @a major, @a minor, and @a patch |
| * components. |
| * |
| * This macro may be used in conjunction with WEAVE_VERSION_CODE to, for |
| * example, conditionally-compile older, newer, or changed Weave APIs based |
| * on the Weave version. For example: |
| * |
| * @code |
| * #if WEAVE_VERSION_CODE >= WEAVE_VERSION_CODE_ENCODE(1, 5, 0) |
| * ... |
| * #else |
| * ... |
| * #endif |
| * @endcode |
| * |
| */ |
| #define WEAVE_VERSION_CODE_ENCODE(major, minor, patch) \ |
| ((((major) & _WEAVE_VERSION_CODE_MAJOR_MASK) << _WEAVE_VERSION_CODE_MAJOR_SHIFT) | \ |
| (((minor) & _WEAVE_VERSION_CODE_MINOR_MASK) << _WEAVE_VERSION_CODE_MINOR_SHIFT) | \ |
| (((patch) & _WEAVE_VERSION_CODE_PATCH_MASK) << _WEAVE_VERSION_CODE_PATCH_SHIFT)) |
| |
| /** |
| * @def WEAVE_VERSION_CODE_DECODE_MAJOR(code) |
| * |
| * @brief |
| * Decode a Weave major version component from a Weave version @a code. |
| * |
| */ |
| #define WEAVE_VERSION_CODE_DECODE_MAJOR(code) (((code) >> _WEAVE_VERSION_CODE_MAJOR_SHIFT) & _WEAVE_VERSION_CODE_MAJOR_MASK) |
| |
| /** |
| * @def WEAVE_VERSION_CODE_DECODE_MINOR(code) |
| * |
| * @brief |
| * Decode a Weave minor version component from a Weave version @a code. |
| * |
| */ |
| #define WEAVE_VERSION_CODE_DECODE_MINOR(code) (((code) >> _WEAVE_VERSION_CODE_MINOR_SHIFT) & _WEAVE_VERSION_CODE_MINOR_MASK) |
| |
| /** |
| * @def WEAVE_VERSION_CODE_DECODE_PATCH(code) |
| * |
| * @brief |
| * Decode a Weave patch version component from a Weave version @a code. |
| * |
| */ |
| #define WEAVE_VERSION_CODE_DECODE_PATCH(code) (((code) >> _WEAVE_VERSION_CODE_PATCH_SHIFT) & _WEAVE_VERSION_CODE_PATCH_MASK) |
| |
| /** |
| * @def WEAVE_VERSION_MAJOR |
| * |
| * @brief |
| * The Weave version major component, as an unsigned integer. |
| * |
| */ |
| #define WEAVE_VERSION_MAJOR 0 |
| |
| /** |
| * @def WEAVE_VERSION_MINOR |
| * |
| * @brief |
| * The Weave version minor component, as an unsigned integer. |
| * |
| */ |
| #define WEAVE_VERSION_MINOR 0 |
| |
| /** |
| * @def WEAVE_VERSION_PATCH |
| * |
| * @brief |
| * The Weave version patch component, as an unsigned integer. |
| * |
| */ |
| #define WEAVE_VERSION_PATCH 0 |
| |
| /** |
| * @def WEAVE_VERSION_EXTRA |
| * |
| * @brief |
| * The Weave version extra component, as a quoted C string. |
| * |
| */ |
| #define WEAVE_VERSION_EXTRA "" |
| |
| /** |
| * @def WEAVE_VERSION_STRING |
| * |
| * @brief |
| * The Weave version, as a quoted C string. |
| * |
| */ |
| #define WEAVE_VERSION_STRING "0.0" |
| |
| /** |
| * @def WEAVE_VERSION_CODE |
| * |
| * @brief |
| * The Weave version, including the major, minor, and patch components, |
| * encoded as an unsigned integer. |
| * |
| * This macro may be used in conjunction with WEAVE_VERSION_CODE_ENCODE |
| * to, for example, conditionally-compile older, newer, or changed Weave |
| * APIs based on the Weave version. For example: |
| * |
| * @code |
| * #if WEAVE_VERSION_CODE >= WEAVE_VERSION_CODE_ENCODE(1, 5, 0) |
| * ... |
| * #else |
| * ... |
| * #endif |
| * @endcode |
| * |
| */ |
| #define WEAVE_VERSION_CODE WEAVE_VERSION_CODE_ENCODE( \ |
| WEAVE_VERSION_MAJOR, \ |
| WEAVE_VERSION_MINOR, \ |
| WEAVE_VERSION_PATCH \ |
| ) |
| |
| #endif /* WEAVEVERSION_H_ */ |