|
Banjo API 1.0.0-rc.2
Low-level C99 game development API
|
#include <banjo/api.h>Go to the source code of this file.
Macros | |
| #define | BJ_VERSION_MAJOR(version) |
| #define | BJ_VERSION_MINOR(version) |
| #define | BJ_VERSION_PATCH(version) |
| #define | BJ_VERSION_STAGE(version) |
| #define | BJ_MAKE_VERSION(major, minor, patch, stage) |
| #define | BJ_NAME "Banjo" |
| #define | BJ_NAME_VARIANT "" |
| #define | BJ_VERSION_MAJOR_NUMBER 1 |
| #define | BJ_VERSION_MINOR_NUMBER 0 |
| #define | BJ_VERSION_PATCH_NUMBER 0 |
| #define | BJ_VERSION_STAGE_NUMBER (BJ_VERSION_RC | 0x02) |
| #define | BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER, BJ_VERSION_STAGE_NUMBER) |
| #define | BJ_VERSION_ALPHA 0x00 |
| #define | BJ_VERSION_BETA 0x40 |
| #define | BJ_VERSION_PREVIEW 0x80 |
| #define | BJ_VERSION_RC 0xC0 |
| #define | BJ_VERSION_STABLE 0xFF |
Functions | |
| size_t | bj_format_version (char *buffer, size_t bufsize, uint32_t version) |
32-bit packed version storage following the SemVer standard.
Banjo versions are stored in a single 32-bit integer, with each byte representing a different component in order from most significant to least significant: major version, minor version, patch version, and stage (pre-release type and number).
For example, the version 3.4.0-rc.2 is represented as 0x030400C2:
This header provides macros to construct packed version integers, extract each component, and define stage flags. The encoding respects SemVer precedence, so comparing two packed versions using standard integer comparison operators correctly reflects SemVer ordering. Pre-release stages always compare lower than stable releases, and the stage byte allows internal numbering for alpha, beta, preview, and RC builds.
SemVer Standard: https://semver.org/
Definition in file version.h.
| #define BJ_MAKE_VERSION | ( | major, | |
| minor, | |||
| patch, | |||
| stage ) |
Construct a packed 32-bit version.
The 32-bit version layout is [major:8 | minor:8 | patch:8 | stage:8].
| major | Major version in the range [0, 255]. |
| minor | Minor version in the range [0, 255]. |
| patch | Patch version in the range [0, 255]. |
| stage | Stage byte, typically one of BJ_VERSION_ALPHA, BJ_VERSION_BETA, BJ_VERSION_PREVIEW, BJ_VERSION_RC, or BJ_VERSION_STABLE optionally OR'ed with a stage number. |
| #define BJ_NAME "Banjo" |
| #define BJ_NAME_VARIANT "" |
| #define BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER, BJ_VERSION_STAGE_NUMBER) |
| #define BJ_VERSION_ALPHA 0x00 |
Version stage flags.
The least significant byte of the 32-bit version integer encodes the stage of the release.
The two most significant bits indicate the stage type: alpha, beta, preview, or rc. The remaining six bits store the stage number, for example rc.2 would be encoded as BJ_VERSION_RC | 0x02.
Certain values are treated specially: 0xFF always represents a stable release and has the highest precedence.
This encoding cannot distinguish between, for example, rc and rc.0. Version precedence follows SemVer rules, so all pre-release stages are considered lower than stable releases. Alpha (development version)
Definition at line 49 of file version.h.
Referenced by stage_type_name().
| #define BJ_VERSION_BETA 0x40 |
Beta (maturing, can still add features)
Definition at line 50 of file version.h.
Referenced by stage_type_name().
| #define BJ_VERSION_MAJOR | ( | version | ) |
Extract the major version from a packed 32-bit version.
The most significant byte of the version represents the major version.
| version | The packed 32-bit version value. |
Definition at line 64 of file version.h.
Referenced by print_combined().
| #define BJ_VERSION_MAJOR_NUMBER 1 |
| #define BJ_VERSION_MINOR | ( | version | ) |
Extract the minor version from a packed 32-bit version.
The second byte of the packed version represents the minor version.
| version | The packed 32-bit version value. |
Definition at line 73 of file version.h.
Referenced by print_combined().
| #define BJ_VERSION_MINOR_NUMBER 0 |
| #define BJ_VERSION_PATCH | ( | version | ) |
Extract the patch version from a packed 32-bit version.
The third byte of the packed version represents the patch version.
| version | The packed 32-bit version value. |
Definition at line 82 of file version.h.
Referenced by print_combined().
| #define BJ_VERSION_PATCH_NUMBER 0 |
| #define BJ_VERSION_PREVIEW 0x80 |
Preview (feature freeze, bug fixes only)
Definition at line 51 of file version.h.
Referenced by stage_type_name().
| #define BJ_VERSION_RC 0xC0 |
Release Candidate (critical fixes only)
Definition at line 52 of file version.h.
Referenced by stage_type_name().
| #define BJ_VERSION_STABLE 0xFF |
Stable Release.
Definition at line 53 of file version.h.
Referenced by format_stage(), and stage_type_name().
| #define BJ_VERSION_STAGE | ( | version | ) |
Extract the stage byte from a packed 32-bit version.
The least significant byte of the packed version contains the stage type and stage number.
| version | The packed 32-bit version value. |
Definition at line 92 of file version.h.
Referenced by print_combined().
| #define BJ_VERSION_STAGE_NUMBER (BJ_VERSION_RC | 0x02) |
| size_t bj_format_version | ( | char * | buffer, |
| size_t | bufsize, | ||
| uint32_t | version ) |
Format a packed version number as a SemVer-compatible string.
Writes a human-readable Semantic Version string into the provided buffer, using the packed 32-bit version representation defined in version.h. The output follows the form:
major.minor.patch[-stage[.number]]
Stable releases are printed without a pre-release suffix. Pre-release stages (alpha, beta, preview, rc) are formatted according to the encoded stage type and stage number.
This function behaves like snprintf: it writes at most bufsize bytes (including the null terminator), never overflows the buffer, and returns the number of characters that would have been written if the buffer were sufficiently large.
| buffer | Destination buffer for the formatted version string. |
| bufsize | Size of the destination buffer in bytes, including the terminating null character. |
| version | Packed 32-bit version value to format. |
bufsize, the output has been truncated. Referenced by print_all().