|
Banjo API 0.0.1
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 0 |
| #define | BJ_VERSION_MINOR_NUMBER 1 |
| #define | BJ_VERSION_PATCH_NUMBER 0 |
| #define | BJ_VERSION_STAGE_NUMBER (BJ_VERSION_DEV | 0x00) |
| #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_DEV 0x00 |
| #define | BJ_VERSION_ALPHA 0x40 |
| #define | BJ_VERSION_BETA 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, and RC builds.
SemVer Standard: https://semver.org/
| #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_RC, or BJ_VERSION_STABLE optionally OR'ed with a stage number. |
| #define BJ_NAME "Banjo" |
Library name string.
This macro can be changed to modify the name of the library in case of fork, for example.
| #define BJ_NAME_VARIANT "" |
Variant name for Banjo binary.
The variant is an additional name set after the version number. It can be used in a fork project to specify a non-mainstream version of banjo, while still keeping the name Banjo.
| #define BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER, BJ_VERSION_STAGE_NUMBER) |
Current API version as a packed 32-bit value.
| #define BJ_VERSION_ALPHA 0x40 |
Alpha release.
| #define BJ_VERSION_BETA 0x80 |
Beta release.
| #define BJ_VERSION_DEV 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, rc, or stable. 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. Any 0b00xxxxxx value is implementation-defined.
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 release
| #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. |
| #define BJ_VERSION_MAJOR_NUMBER 0 |
Current major version number.
| #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. |
| #define BJ_VERSION_MINOR_NUMBER 1 |
Current minor version number.
| #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. |
| #define BJ_VERSION_PATCH_NUMBER 0 |
Current patch version number.
| #define BJ_VERSION_RC 0xC0 |
Release Candidate.
| #define BJ_VERSION_STABLE 0xFF |
Stable Release.
| #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. |
| #define BJ_VERSION_STAGE_NUMBER (BJ_VERSION_DEV | 0x00) |
Current stage version specifier.
| 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, rc, or implementation-defined unstable stages) 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.