Fixes and formatting

This commit is contained in:
Nathan Fisher 2024-02-10 19:11:35 -05:00
parent e41503ad2e
commit b035e0018a

View file

@ -4,91 +4,101 @@
#define u128 __uint128_t #define u128 __uint128_t
typedef struct { typedef struct {
uint16_t major; uint16_t major;
} __Simple; } __Simple;
typedef struct { typedef struct {
uint16_t major; uint16_t major;
uint16_t minor; uint16_t minor;
} __Rapid; } __Rapid;
typedef struct { typedef struct {
uint16_t major; uint16_t major;
uint16_t minor; uint16_t minor;
uint16_t patch; uint16_t patch;
} __SemVer; } __SemVer;
typedef struct { typedef struct {
uint16_t major; uint16_t major;
uint16_t minor; uint16_t minor;
uint16_t patch; uint16_t patch;
uint16_t build; uint16_t build;
} __Extended; } __Extended;
typedef enum { typedef enum {
Simple, Simple,
Rapid, Rapid,
SemVer, SemVer,
Extended, Extended,
} VersionKindTag; } VersionKindTag;
typedef struct { typedef struct {
char hash[7]; char hash[7];
DateTime dt; DateTime dt;
} GitRevision; } GitRevision;
typedef enum { typedef enum {
Alpha, Alpha,
Beta, Beta,
ReleaseCandidate, ReleaseCandidate,
GitRev, GitRev,
PRNone, PRNone,
} PreReleaseTag; } PreReleaseTag;
typedef enum { typedef enum {
any, any,
arm, arm,
arm64, arm64,
loongson, loongson,
mips32, mips32,
mips64, mips64,
powerepc, powerepc,
powerpc64, powerpc64,
riscv64, riscv64,
s390x, s390x,
sparc, sparc,
sparc64, sparc64,
x86, x86,
x86_64, x86_64,
} Arch; } Arch;
typedef struct { typedef struct {
VersionKindTag vk_tag; PreReleaseTag pr_tag;
union { union {
__Simple simple; uint16_t alpha;
__Rapid rapid; uint16_t beta;
__SemVer semver; uint16_t rc;
__Extended extended; GitRevision *git;
} vk_data; };
PreReleaseTag pr_tag; } PreRelease;
union {
uint16_t alpha; typedef struct {
uint16_t beta; VersionKindTag vk_tag;
uint16_t rc; union {
GitRevision *git; __Simple simple;
} pr_data; __Rapid rapid;
Arch arch; __SemVer semver;
__Extended extended;
} vk_data;
PreReleaseTag pr_tag;
union {
uint16_t alpha;
uint16_t beta;
uint16_t rc;
GitRevision *git;
} pr_data;
Arch arch;
} Version; } Version;
typedef enum { typedef enum {
CompGreater, CompGreater,
CompEqual, CompEqual,
CompLess, CompLess,
CompNone, CompNone,
} Comparison; } Comparison;
u128 u128FromVersion(Version *self); u128 u128FromVersion(Version *self);
Comparison compareVersion(Version *self, Version *other); Comparison compareVersion (Version *self, Version *other);
int parseVersion(Version *self, const char *s); int parseVersion (Version *self, const char *s);
char *versionToString(Version *self); char *versionToString(Version *self);