mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
De-duplicate the gen/c/* files
The gen/c/* files are not checked in, due to the .gitignore file In Wuffs version 0.1, they were checked in, and programs were expected to #include them directly. Another goal was for them to be self-contained, without any #include lines to other Wuffs files, so that they would be easy to build, without having to configure an -I dir to a C compiler. They therefore inlined what would otherwise be an #include. For example, the generated std/gif.h code would inline the contents of the std/lzw.h file. The genrelease program would have to de-duplicate these inlines in order to produce a clean, monolithic release/c/* file. In Wuffs version 0.2 (the latest version), programs don't #include gen/c/*. Instead, they #include the monolithic release/c/*. Avoiding the need to configure an -I directory isn't as important as it used to be. This change removes that inlining, using the simpler #include line, and the genrelease program is then simpler because it doesn't need to de-duplicate.
This commit is contained in:
1 parent
51a0b347ed
commit
61d03537c2
7 files changed
+222
-289
No files matched your search
@@ -14,6 +14,16 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef WUFFS_INCLUDE_GUARD__BASE
|
||||
#define WUFFS_INCLUDE_GUARD__BASE
|
||||
|
||||
#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)
|
||||
#define WUFFS_CONFIG__MODULES
|
||||
#define WUFFS_CONFIG__MODULE__BASE
|
||||
#endif
|
||||
|
||||
// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.
|
||||
|
||||
// !! INSERT base-public.h.
|
||||
|
||||
// WUFFS C HEADER ENDS HERE.
|
||||
@@ -29,3 +39,7 @@
|
||||
// defined(WUFFS_CONFIG__MODULE__BASE)
|
||||
|
||||
#endif // WUFFS_IMPLEMENTATION
|
||||
|
||||
// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING BELOW.
|
||||
|
||||
#endif // WUFFS_INCLUDE_GUARD__BASE
|
||||
@@ -1,8 +1,5 @@
|
||||
// After editing this file, run "go generate" in the parent directory.
|
||||
|
||||
#ifndef WUFFS_INCLUDE_GUARD__BASE_PRIVATE
|
||||
#define WUFFS_INCLUDE_GUARD__BASE_PRIVATE
|
||||
|
||||
// Copyright 2017 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -722,5 +719,3 @@ wuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // WUFFS_INCLUDE_GUARD__BASE_PRIVATE
|
||||
@@ -21,11 +21,9 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -254,10 +252,6 @@ func insertBasePrivateH(buf *buffer) error {
|
||||
}
|
||||
|
||||
func insertBasePublicH(buf *buffer) error {
|
||||
buf.writes("// Code generated by wuffs-c. DO NOT EDIT.\n\n")
|
||||
buf.writes("#ifndef WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n")
|
||||
buf.writes("#define WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n\n")
|
||||
|
||||
if err := expandBangBangInsert(buf, baseBasePublicH, map[string]func(*buffer) error{
|
||||
"// !! INSERT wuffs_base__status names.\n": func(b *buffer) error {
|
||||
for _, z := range builtin.StatusList {
|
||||
@@ -278,7 +272,6 @@ func insertBasePublicH(buf *buffer) error {
|
||||
buf.writeb('\n')
|
||||
buf.writes(baseImagePublicH)
|
||||
|
||||
buf.writes("\n#endif // WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -294,12 +287,9 @@ type gen struct {
|
||||
statusMap map[t.QID]status
|
||||
structList []*a.Struct
|
||||
structMap map[t.QID]*a.Struct
|
||||
usesList []string
|
||||
usesMap map[string]struct{}
|
||||
|
||||
currFunk funk
|
||||
funks map[t.QQID]funk
|
||||
wuffsRoot string
|
||||
currFunk funk
|
||||
funks map[t.QQID]funk
|
||||
}
|
||||
|
||||
func (g *gen) generate() ([]byte, error) {
|
||||
@@ -337,6 +327,12 @@ func (g *gen) generate() ([]byte, error) {
|
||||
includeGuard := "WUFFS_INCLUDE_GUARD__" + strings.ToUpper(g.pkgName)
|
||||
b.printf("#ifndef %s\n#define %s\n\n", includeGuard, includeGuard)
|
||||
|
||||
if err := g.genIncludes(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b.writes("// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n\n")
|
||||
|
||||
if err := g.genHeader(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -346,20 +342,50 @@ func (g *gen) generate() ([]byte, error) {
|
||||
}
|
||||
b.writex(wiEnd)
|
||||
|
||||
b.writes("// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING BELOW.\n\n")
|
||||
|
||||
b.printf("#endif // %s\n\n", includeGuard)
|
||||
return *b, nil
|
||||
}
|
||||
|
||||
func (g *gen) genIncludes(b *buffer) error {
|
||||
b.writes("#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n")
|
||||
b.writes("#define WUFFS_CONFIG__MODULES\n")
|
||||
b.printf("#define WUFFS_CONFIG__MODULE__%s\n", strings.ToUpper(g.pkgName))
|
||||
b.writes("#endif\n\n")
|
||||
|
||||
usesList := []string(nil)
|
||||
usesMap := map[string]struct{}{}
|
||||
|
||||
for _, file := range g.files {
|
||||
for _, tld := range file.TopLevelDecls() {
|
||||
if tld.Kind() != a.KUse {
|
||||
continue
|
||||
}
|
||||
useDirname := g.tm.ByID(tld.AsUse().Path())
|
||||
useDirname, _ = t.Unescape(useDirname)
|
||||
|
||||
// TODO: sanity check useDirname via commonflags.IsValidUsePath?
|
||||
|
||||
if _, ok := usesMap[useDirname]; ok {
|
||||
continue
|
||||
}
|
||||
usesMap[useDirname] = struct{}{}
|
||||
usesList = append(usesList, useDirname)
|
||||
}
|
||||
}
|
||||
sort.Strings(usesList)
|
||||
|
||||
b.writes("#include \"base.h\"\n")
|
||||
for _, use := range usesList {
|
||||
b.printf("#include \"%s.h\"\n", use)
|
||||
}
|
||||
|
||||
b.writeb('\n')
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) genHeader(b *buffer) error {
|
||||
if err := insertBasePublicH(b); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.writes("// ---------------- Use Declarations\n\n")
|
||||
if err := g.forEachUse(b, (*gen).writeUse); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.writes("\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n")
|
||||
|
||||
b.writes("// ---------------- Status Codes\n\n")
|
||||
@@ -415,9 +441,6 @@ func (g *gen) genHeader(b *buffer) error {
|
||||
}
|
||||
|
||||
func (g *gen) genImpl(b *buffer) error {
|
||||
b.writes(baseBasePrivateH)
|
||||
b.writeb('\n')
|
||||
|
||||
module := "!defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__" +
|
||||
strings.ToUpper(g.pkgName) + ")"
|
||||
b.printf("#if %s\n\n", module)
|
||||
@@ -515,20 +538,6 @@ func (g *gen) forEachStatus(b *buffer, v visibility, f func(*gen, *buffer, *a.St
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) forEachUse(b *buffer, f func(*gen, *buffer, *a.Use) error) error {
|
||||
for _, file := range g.files {
|
||||
for _, tld := range file.TopLevelDecls() {
|
||||
if tld.Kind() != a.KUse {
|
||||
continue
|
||||
}
|
||||
if err := f(g, b, tld.AsUse()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) cName(name string) string {
|
||||
return cName(name, g.pkgPrefix)
|
||||
}
|
||||
@@ -748,72 +757,8 @@ var (
|
||||
wiStartImpl = []byte("\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n")
|
||||
wiStart = []byte("\n#ifdef WUFFS_IMPLEMENTATION\n\n")
|
||||
wiEnd = []byte("\n#endif // WUFFS_IMPLEMENTATION\n\n")
|
||||
|
||||
wigbpStart = []byte("\n#ifndef WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n")
|
||||
wigbpEnd = []byte("\n#endif // WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n")
|
||||
)
|
||||
|
||||
func (g *gen) writeUse(b *buffer, n *a.Use) error {
|
||||
useDirname := g.tm.ByID(n.Path())
|
||||
useDirname, _ = t.Unescape(useDirname)
|
||||
|
||||
// TODO: sanity check useDirname via commonflags.IsValidUsePath?
|
||||
|
||||
if g.usesMap == nil {
|
||||
g.usesMap = map[string]struct{}{}
|
||||
} else if _, ok := g.usesMap[useDirname]; ok {
|
||||
return nil
|
||||
}
|
||||
g.usesList = append(g.usesList, useDirname)
|
||||
g.usesMap[useDirname] = struct{}{}
|
||||
|
||||
if g.wuffsRoot == "" {
|
||||
var err error
|
||||
g.wuffsRoot, err = generate.WuffsRoot()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
useeFilename := filepath.Join(g.wuffsRoot, "gen", "c", filepath.FromSlash(useDirname)+".h")
|
||||
usee, err := ioutil.ReadFile(useeFilename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
trimmed := []byte(nil)
|
||||
if i := bytes.Index(usee, wiStartImpl); i >= 0 {
|
||||
remaining := usee[i+len(wiStartImpl):]
|
||||
if j := bytes.Index(remaining, wiEnd); j >= 0 {
|
||||
trimmed = append(trimmed, usee[:i]...)
|
||||
trimmed = append(trimmed, '\n')
|
||||
trimmed = append(trimmed, remaining[j+len(wiEnd):]...)
|
||||
usee = trimmed
|
||||
}
|
||||
}
|
||||
if len(trimmed) == 0 {
|
||||
return fmt.Errorf("use %q: previously generated code %q could not be inlined", useDirname, useeFilename)
|
||||
}
|
||||
|
||||
b.printf("// ---------------- BEGIN USE %q\n\n", useDirname)
|
||||
|
||||
// Inline the previously generated .h file, stripping out the redundant
|
||||
// copy of the WUFFS_INCLUDE_GUARD__BASE_PUBLIC code.
|
||||
if i := bytes.Index(usee, wigbpStart); i < 0 {
|
||||
return fmt.Errorf("use %q: previously generated code %q could not be inlined", useDirname, useeFilename)
|
||||
} else {
|
||||
b.Write(usee[:i])
|
||||
usee = usee[i+len(wigbpStart):]
|
||||
}
|
||||
if i := bytes.Index(usee, wigbpEnd); i < 0 {
|
||||
return fmt.Errorf("use %q: previously generated code %q could not be inlined", useDirname, useeFilename)
|
||||
} else {
|
||||
b.Write(usee[i+len(wigbpEnd):])
|
||||
}
|
||||
|
||||
b.printf("\n\n// ---------------- END USE %q\n\n", useDirname)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) writeInitializerSignature(b *buffer, n *a.Struct, public bool) error {
|
||||
structName := n.QID().Str(g.tm)
|
||||
if public {
|
||||
|
||||
@@ -76,10 +76,10 @@ const baseBasePublicH = "" +
|
||||
""
|
||||
|
||||
const baseBasePrivateH = "" +
|
||||
"#ifndef WUFFS_INCLUDE_GUARD__BASE_PRIVATE\n#define WUFFS_INCLUDE_GUARD__BASE_PRIVATE\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#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)\n\nstatic inline void wuffs_base__ignore_check_wuffs_version_status(\n wuffs_base__status z) {}\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero me" +
|
||||
"mory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && __cplusplus >= 201103L\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BASE__FALLTHROUGH __attribute__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and c" +
|
||||
"ase statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status) { \\\n goto ok; \\\n } else if (*status != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point = n; \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!" +
|
||||
"!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__return_empty_struct() {\n return ((wuffs_base__empty_struct){});\n}\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#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)\n\nstatic inline void wuffs_base__ignore_check_wuffs_version_status(\n wuffs_base__status z) {}\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero memory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value i" +
|
||||
"s arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && __cplusplus >= 201103L\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BASE__FALLTHROUGH __attribute__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#d" +
|
||||
"efine WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status) { \\\n goto ok; \\\n } else if (*status != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point = n; \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKE" +
|
||||
"LY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__return_empty_struct() {\n return ((wuffs_base__empty_struct){});\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__load_u8be(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be(uint8_t* p) {\n return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le(uint8_t* p) {\n return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uin" +
|
||||
"t32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |\n ((uint64_t)(p[4]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline u" +
|
||||
@@ -110,11 +110,12 @@ const baseBasePrivateH = "" +
|
||||
"r (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n uint8_t** ptr_ioptr_r,\n uint8_t* iobounds1_r) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = length;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n uint8_t* ioptr_r = *ptr_ioptr_r;\n if (n > ((size_t)(iobounds1_r - ioptr_r))) {\n n = iobounds1_r - ioptr_r;\n }\n if (n > 0) {\n memmove(ioptr_w, ioptr_r, n);\n *ptr_ioptr_w += n;\n *ptr_ioptr_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_ioptr_w,\n u" +
|
||||
"int8_t* iobounds1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* ioptr_r,\n " +
|
||||
" uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - ioptr_r)) > limit)) {\n o->private_impl.limit = ioptr_r + limit;\n }\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ioptr1_ptr,\n uint8_t** ioptr2_ptr,\n wuffs_base__slice_u8 s) {\n b->data.ptr = s.ptr;\n b->data.len = s.len;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = s.ptr;\n o->private_impl.limit = s.ptr + s.len;\n *ioptr1_ptr = s.ptr;\n *ioptr2_ptr = s.ptr + s.len;\n return ((wuffs_base__empty_struct){})" +
|
||||
";\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_INCLUDE_GUARD__BASE_PRIVATE\n" +
|
||||
";\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n" +
|
||||
""
|
||||
|
||||
const baseBaseImplC = "" +
|
||||
"// Copyright 2018 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// !! INSERT base-public.h.\n\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n// !! INSERT base-private.h.\n\n#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE)\n\n// !! INSERT wuffs_base__status strings.\n\n#endif // !defined(WUFFS_CONFIG__MODULES) ||\n // defined(WUFFS_CONFIG__MODULE__BASE)\n\n#endif // WUFFS_IMPLEMENTATION\n" +
|
||||
"// Copyright 2018 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#ifndef WUFFS_INCLUDE_GUARD__BASE\n#define WUFFS_INCLUDE_GUARD__BASE\n\n#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n#define WUFFS_CONFIG__MODULES\n#define WUFFS_CONFIG__MODULE__BASE\n#endif\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n\n// !! INSERT base-public.h.\n\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n// !! INSERT base-private.h.\n\n#if !defined(WUFFS_CONFIG__MODULES) || de" +
|
||||
"fined(WUFFS_CONFIG__MODULE__BASE)\n\n// !! INSERT wuffs_base__status strings.\n\n#endif // !defined(WUFFS_CONFIG__MODULES) ||\n // defined(WUFFS_CONFIG__MODULE__BASE)\n\n#endif // WUFFS_IMPLEMENTATION\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING BELOW.\n\n#endif // WUFFS_INCLUDE_GUARD__BASE\n" +
|
||||
""
|
||||
|
||||
const baseImagePublicH = "" +
|
||||
|
||||
Reference in new issue
Block a user