diff --git a/internal/cgen/base/core-public.h b/internal/cgen/base/core-public.h index dc7e7fb6..f642fb7d 100644 --- a/internal/cgen/base/core-public.h +++ b/internal/cgen/base/core-public.h @@ -197,6 +197,12 @@ wuffs_base__status__is_warning(wuffs_base__status z) { // -------- +// FourCC constants. + +// !! INSERT FourCCs. + +// -------- + // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks typedef int64_t wuffs_base__flicks; diff --git a/internal/cgen/cgen.go b/internal/cgen/cgen.go index 52f9b3cb..88d23ff3 100644 --- a/internal/cgen/cgen.go +++ b/internal/cgen/cgen.go @@ -263,6 +263,19 @@ func insertBaseAllPrivateH(buf *buffer) error { func insertBaseAllPublicH(buf *buffer) error { if err := expandBangBangInsert(buf, baseCorePublicH, map[string]func(*buffer) error{ + "// !! INSERT FourCCs.\n": func(b *buffer) error { + for _, z := range builtin.FourCCs { + b.printf("// %s.\n#define WUFFS_BASE__FOURCC__%s 0x%02X%02X%02X%02X\n\n", + z[1], + strings.ToUpper(strings.TrimSpace(z[0])), + z[0][0], + z[0][1], + z[0][2], + z[0][3], + ) + } + return nil + }, "// !! INSERT wuffs_base__status names.\n": func(b *buffer) error { for _, z := range builtin.Statuses { msg, _ := t.Unescape(z) diff --git a/internal/cgen/data.go b/internal/cgen/data.go index 926b4c29..832e20cf 100644 --- a/internal/cgen/data.go +++ b/internal/cgen/data.go @@ -71,6 +71,8 @@ const baseCorePublicH = "" + "// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" + "e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '#'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '#');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '#');\n}\n\n" + "" + + "// --------\n\n// FourCC constants.\n\n// !! INSERT FourCCs.\n\n" + + "" + "// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" + "" + "// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__u8__min(uint8_t x, uint8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint8_t //\nwuffs_base__u8__max(uint8_t x, uint8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__min(uint16_t x, uint16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__max(uint16_t x, uint16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__min(uint32_t x, uint32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__max(uint32_t x, uint32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__min(uint64_t x, uint64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__max(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\n\n" + diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index 47de929e..c30e2ead 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -19,6 +19,11 @@ import ( t "github.com/google/wuffs/lang/token" ) +var FourCCs = [...][2]string{ + {"ICCP", "International Color Consortium Profile"}, + {"XMP ", "Extensible Metadata Platform"}, +} + var Statuses = [...]string{ // Warnings. `"@end of data"`, diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index fb99e91d..03431b60 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -236,6 +236,16 @@ wuffs_base__status__is_warning(wuffs_base__status z) { // -------- +// FourCC constants. + +// International Color Consortium Profile. +#define WUFFS_BASE__FOURCC__ICCP 0x49434350 + +// Extensible Metadata Platform. +#define WUFFS_BASE__FOURCC__XMP 0x584D5020 + +// -------- + // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks typedef int64_t wuffs_base__flicks;