mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Rename some #ifndef WUFFS_BASE_HEADER_H guards
This commit is contained in:
1 parent
a1ed77cc35
commit
df96e48341
22 files changed
+87
-87
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// After editing this file, run "go generate" in the parent directory.
|
||||
|
||||
#ifndef WUFFS_BASE_HEADER_H
|
||||
#define WUFFS_BASE_HEADER_H
|
||||
#ifndef WUFFS_BASE_PUBLIC_H
|
||||
#define WUFFS_BASE_PUBLIC_H
|
||||
|
||||
// Copyright 2017 The Wuffs Authors.
|
||||
//
|
||||
@@ -1211,4 +1211,4 @@ static inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(
|
||||
: ((wuffs_base__table_u8){});
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
#endif // WUFFS_BASE_PUBLIC_H
|
||||
@@ -351,7 +351,7 @@ func (g *gen) genHeader(b *buffer) error {
|
||||
}
|
||||
|
||||
func (g *gen) genImpl(b *buffer) error {
|
||||
b.writes("#ifndef WUFFS_BASE_IMPL_H\n#define WUFFS_BASE_IMPL_H\n\n")
|
||||
b.writes("#ifndef WUFFS_BASE_PRIVATE_H\n#define WUFFS_BASE_PRIVATE_H\n\n")
|
||||
b.writes(basePrivateH)
|
||||
b.writes("\n")
|
||||
b.printf("static const char* wuffs_base__status__strings[%d] = {\n", len(builtin.StatusList))
|
||||
@@ -359,7 +359,7 @@ func (g *gen) genImpl(b *buffer) error {
|
||||
b.printf("%q,", z.Message)
|
||||
}
|
||||
b.writes("};\n\n")
|
||||
b.writes("#endif // WUFFS_BASE_IMPL_H\n\n")
|
||||
b.writes("#endif // WUFFS_BASE_PRIVATE_H\n\n")
|
||||
|
||||
b.writes("// ---------------- Status Codes Implementations\n\n")
|
||||
b.printf("bool %sstatus__is_error(%sstatus s) { return s < 0; }\n\n", g.pkgPrefix, g.pkgPrefix)
|
||||
@@ -651,8 +651,8 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
||||
}
|
||||
|
||||
var (
|
||||
wuffsBaseHeaderHStart = []byte("#ifndef WUFFS_BASE_HEADER_H\n")
|
||||
wuffsBaseHeaderHEnd = []byte("#endif // WUFFS_BASE_HEADER_H\n")
|
||||
wuffsBasePublicHStart = []byte("#ifndef WUFFS_BASE_PUBLIC_H\n")
|
||||
wuffsBasePublicHEnd = []byte("#endif // WUFFS_BASE_PUBLIC_H\n")
|
||||
)
|
||||
|
||||
func (g *gen) writeUse(b *buffer, n *a.Use) error {
|
||||
@@ -686,17 +686,17 @@ func (g *gen) writeUse(b *buffer, n *a.Use) error {
|
||||
b.printf("// ---------------- BEGIN USE %q\n\n", useDirname)
|
||||
|
||||
// Inline the previously generated .h file, stripping out the redundant
|
||||
// copy of the WUFFS_BASE_HEADER_H code.
|
||||
if i := bytes.Index(hdr, wuffsBaseHeaderHStart); i < 0 {
|
||||
// copy of the WUFFS_BASE_PUBLIC_H code.
|
||||
if i := bytes.Index(hdr, wuffsBasePublicHStart); i < 0 {
|
||||
return fmt.Errorf("use %q: previously generated header %q could not be inlined", useDirname, hdrFilename)
|
||||
} else {
|
||||
b.Write(hdr[:i])
|
||||
hdr = hdr[i+len(wuffsBaseHeaderHStart):]
|
||||
hdr = hdr[i+len(wuffsBasePublicHStart):]
|
||||
}
|
||||
if i := bytes.Index(hdr, wuffsBaseHeaderHEnd); i < 0 {
|
||||
if i := bytes.Index(hdr, wuffsBasePublicHEnd); i < 0 {
|
||||
return fmt.Errorf("use %q: previously generated header %q could not be inlined", useDirname, hdrFilename)
|
||||
} else {
|
||||
b.Write(hdr[i+len(wuffsBaseHeaderHEnd):])
|
||||
b.Write(hdr[i+len(wuffsBasePublicHEnd):])
|
||||
}
|
||||
|
||||
b.writeb('\n')
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package cgen
|
||||
|
||||
const basePublicH = "" +
|
||||
"#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, " +
|
||||
"#ifndef WUFFS_BASE_PUBLIC_H\n#define WUFFS_BASE_PUBLIC_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" +
|
||||
"" +
|
||||
@@ -87,7 +87,7 @@ const basePublicH = "" +
|
||||
"he image bounds.\n dirty_rect.max_exclusive_x = wuffs_base__u32__min(\n dirty_rect.max_exclusive_x, b->private_impl.config.private_impl.width);\n dirty_rect.max_exclusive_y = wuffs_base__u32__min(\n dirty_rect.max_exclusive_y, b->private_impl.config.private_impl.height);\n b->private_impl.dirty_rect = dirty_rect;\n\n b->private_impl.duration = duration;\n b->private_impl.blend = blend;\n b->private_impl.disposal = disposal;\n b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);\n if (b->private_impl.palette_changed) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__image_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments b's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config." +
|
||||
"private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\n}\n\n// wuffs_base__image_config returns the overall configuration for this frame.\nstatic inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(\n wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private" +
|
||||
"_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool wuffs_base__image_buffer__blend(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__image_buffer__palette_changed returns whether this frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool wuffs_base__image_buffer__palette_changed(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_" +
|
||||
"base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#endif // WUFFS_BASE_HEADER_H\n" +
|
||||
"base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#endif // WUFFS_BASE_PUBLIC_H\n" +
|
||||
""
|
||||
|
||||
const basePrivateH = "" +
|
||||
|
||||
Reference in new issue
Block a user