mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
Have WUFFS_VERSION encode major.minor.patch
This commit is contained in:
1 parent
2d838db184
commit
27e0139500
18 files changed
+277
-163
No files matched your search
@@ -28,16 +28,23 @@
|
||||
#error "Wuffs requires a word size of either 32 or 64 bits"
|
||||
#endif
|
||||
|
||||
// WUFFS_VERSION is the major.minor version number as a uint32_t. The major
|
||||
// number is the high 16 bits. The minor number is the low 16 bits.
|
||||
// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,
|
||||
// as a uint64_t. The major number is the high 32 bits. The minor number is the
|
||||
// middle 16 bits. The patch number is the low 16 bits. The version extension
|
||||
// (such as "", "beta" or "rc.1") is part of the string representation (such as
|
||||
// "1.2.3-beta") but not the uint64_t representation.
|
||||
//
|
||||
// The intention is to bump the version number at least on every API / ABI
|
||||
// backwards incompatible change.
|
||||
// All three of major, minor and patch being zero means that this is a
|
||||
// work-in-progress version, not a release version, and has no backwards or
|
||||
// forwards compatibility guarantees.
|
||||
//
|
||||
// For now, the API and ABI are simply unstable and can change at any time.
|
||||
//
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION ((uint32_t)0x00001)
|
||||
// !! Some code generation programs can override WUFFS_VERSION.
|
||||
#define WUFFS_VERSION ((uint64_t)0)
|
||||
#define WUFFS_VERSION_MAJOR ((uint64_t)0)
|
||||
#define WUFFS_VERSION_MINOR ((uint64_t)0)
|
||||
#define WUFFS_VERSION_PATCH ((uint64_t)0)
|
||||
#define WUFFS_VERSION_EXTENSION ""
|
||||
#define WUFFS_VERSION_STRING "0.0.0"
|
||||
|
||||
// wuffs_base__empty_struct is used when a Wuffs function returns an empty
|
||||
// struct. In C, if a function f returns void, you can't say "x = f()", but in
|
||||
|
||||
@@ -665,7 +665,7 @@ func (g *gen) writeInitializerSignature(b *buffer, n *a.Struct, public bool) err
|
||||
b.printf("//\n")
|
||||
b.printf("// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.\n")
|
||||
}
|
||||
b.printf("void %s%s__check_wuffs_version(%s%s *self, size_t sizeof_star_self, uint32_t wuffs_version)",
|
||||
b.printf("void %s%s__check_wuffs_version(%s%s *self, size_t sizeof_star_self, uint64_t wuffs_version)",
|
||||
g.pkgPrefix, structName, g.pkgPrefix, structName)
|
||||
return nil
|
||||
}
|
||||
@@ -695,7 +695,8 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
b.printf("self->private_impl.status = %sERROR_BAD_SIZEOF_RECEIVER;\n", g.PKGPREFIX)
|
||||
b.printf("return;\n")
|
||||
b.printf("}\n")
|
||||
b.printf("if (wuffs_version != WUFFS_VERSION) {\n")
|
||||
b.printf("if (((wuffs_version >> 32) != WUFFS_VERSION_MAJOR) || " +
|
||||
"(((wuffs_version >> 16) & 0xFFFF) > WUFFS_VERSION_MINOR)) {\n")
|
||||
b.printf("self->private_impl.status = %sERROR_BAD_WUFFS_VERSION;\n", g.PKGPREFIX)
|
||||
b.printf("return;\n")
|
||||
b.printf("}\n")
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
package cgen
|
||||
|
||||
const baseHeader = "" +
|
||||
"#ifndef WUFFS_BASE_HEADER_H\n#define WUFFS_BASE_HEADER_H\n\n// Copyright 2017 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <string.h>\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor version number " +
|
||||
"as a uint32_t. The major\n// number is the high 16 bits. The minor number is the low 16 bits.\n//\n// The intention is to bump the version number at least on every API / ABI\n// backwards incompatible change.\n//\n// For now, the API and ABI are simply unstable and can change at any time.\n//\n// TODO: don't hard code this in base-header.h.\n#define WUFFS_VERSION ((uint32_t)0x00001)\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n" +
|
||||
"#ifndef WUFFS_BASE_HEADER_H\n#define WUFFS_BASE_HEADER_H\n\n// Copyright 2017 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <string.h>\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, " +
|
||||
"as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The version extension\n// (such as \"\", \"beta\" or \"rc.1\") is part of the string representation (such as\n// \"1.2.3-beta\") but not the uint64_t representation.\n//\n// All three of major, minor and patch being zero means that this is a\n// work-in-progress version, not a release version, and has no backwards or\n// forwards compatibility guarantees.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_EXTENSION \"\"\n#define WUFFS_VERSION_STRING \"0.0.0\"\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g(" +
|
||||
")\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n" +
|
||||
"" +
|
||||
"// ---------------- Numeric Types\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" +
|
||||
"" +
|
||||
|
||||
Reference in new issue
Block a user