From 9f76cb71fd1d5edb225872c1b3327321adf1e3bd Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 23 Jun 2018 08:08:40 +1000 Subject: [PATCH] wuffs genrelease -version=0.2.0-alpha.3 --- release/c/wuffs-v0.2/wuffs-v0.2.c | 62 +++++++++++++++++++++++-- release/c/wuffs-v0.2/wuffs-v0.2.h | 76 +++++++++++++++++++++++++++++-- 2 files changed, 130 insertions(+), 8 deletions(-) diff --git a/release/c/wuffs-v0.2/wuffs-v0.2.c b/release/c/wuffs-v0.2/wuffs-v0.2.c index a37a11d0..db191bba 100644 --- a/release/c/wuffs-v0.2/wuffs-v0.2.c +++ b/release/c/wuffs-v0.2/wuffs-v0.2.c @@ -42,9 +42,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // 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 @@ -56,24 +58,44 @@ extern "C" { // work-in-progress version, not a release version, and has no backwards or // forwards compatibility guarantees. // -// WUFFS_VERSION was overridden by "wuffs genrelease" on 2018-06-17 UTC, -// based on revision 43a534934833ce5a13010b0ccc0d9cd9f56f321b. +// WUFFS_VERSION was overridden by "wuffs genrelease" on 2018-06-22 UTC, +// based on revision 0a1ce533fda421304fe97b19dbae4b26e6ebc8f1. #define WUFFS_VERSION ((uint64_t)0x0000000000020000) #define WUFFS_VERSION_MAJOR ((uint64_t)0x00000000) #define WUFFS_VERSION_MINOR ((uint64_t)0x0002) #define WUFFS_VERSION_PATCH ((uint64_t)0x0000) -#define WUFFS_VERSION_EXTENSION "alpha.2" -#define WUFFS_VERSION_STRING "0.2.0-alpha.2" +#define WUFFS_VERSION_EXTENSION "alpha.3" +#define WUFFS_VERSION_STRING "0.2.0-alpha.3" // 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 // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- @@ -697,6 +719,20 @@ typedef struct { } private_impl; } wuffs_base__io_writer; +// wuffs_base__io_buffer__compact moves any written but unread bytes to the +// start of the buffer. +static inline void wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) { + if (!buf || (buf->ri == 0)) { + return; + } + size_t n = buf->wi - buf->ri; + if (n != 0) { + memmove(buf->ptr, buf->ptr + buf->ri, n); + } + buf->wi = n; + buf->ri = 0; +} + static inline wuffs_base__io_reader wuffs_base__io_buffer__reader( wuffs_base__io_buffer* buf) { wuffs_base__io_reader ret = ((wuffs_base__io_reader){}); @@ -1208,6 +1244,22 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( return b ? &b->private_impl.config : NULL; } +static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__bounds( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__bounds(&b->private_impl.config) + : ((wuffs_base__rect_ie_u32){}); +} + +static inline uint32_t wuffs_base__image_buffer__width( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0; +} + +static inline uint32_t wuffs_base__image_buffer__height( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( @@ -1952,6 +2004,8 @@ wuffs_base__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self, #endif // WUFFS_INCLUDE_GUARD +// !! C HEADER ENDS HERE. + // Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/release/c/wuffs-v0.2/wuffs-v0.2.h b/release/c/wuffs-v0.2/wuffs-v0.2.h index fa556751..0f85eea4 100644 --- a/release/c/wuffs-v0.2/wuffs-v0.2.h +++ b/release/c/wuffs-v0.2/wuffs-v0.2.h @@ -1,6 +1,20 @@ #ifndef WUFFS_INCLUDE_GUARD #define WUFFS_INCLUDE_GUARD +// Copyright 2018 The Wuffs Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Code generated by wuffs-c. DO NOT EDIT. // Copyright 2017 The Wuffs Authors. @@ -28,9 +42,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // 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 @@ -42,24 +58,44 @@ extern "C" { // work-in-progress version, not a release version, and has no backwards or // forwards compatibility guarantees. // -// WUFFS_VERSION was overridden by "wuffs genrelease" on 2018-06-17 UTC, -// based on revision 43a534934833ce5a13010b0ccc0d9cd9f56f321b. +// WUFFS_VERSION was overridden by "wuffs genrelease" on 2018-06-22 UTC, +// based on revision 0a1ce533fda421304fe97b19dbae4b26e6ebc8f1. #define WUFFS_VERSION ((uint64_t)0x0000000000020000) #define WUFFS_VERSION_MAJOR ((uint64_t)0x00000000) #define WUFFS_VERSION_MINOR ((uint64_t)0x0002) #define WUFFS_VERSION_PATCH ((uint64_t)0x0000) -#define WUFFS_VERSION_EXTENSION "alpha.2" -#define WUFFS_VERSION_STRING "0.2.0-alpha.2" +#define WUFFS_VERSION_EXTENSION "alpha.3" +#define WUFFS_VERSION_STRING "0.2.0-alpha.3" // 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 // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- @@ -683,6 +719,20 @@ typedef struct { } private_impl; } wuffs_base__io_writer; +// wuffs_base__io_buffer__compact moves any written but unread bytes to the +// start of the buffer. +static inline void wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) { + if (!buf || (buf->ri == 0)) { + return; + } + size_t n = buf->wi - buf->ri; + if (n != 0) { + memmove(buf->ptr, buf->ptr + buf->ri, n); + } + buf->wi = n; + buf->ri = 0; +} + static inline wuffs_base__io_reader wuffs_base__io_buffer__reader( wuffs_base__io_buffer* buf) { wuffs_base__io_reader ret = ((wuffs_base__io_reader){}); @@ -1194,6 +1244,22 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( return b ? &b->private_impl.config : NULL; } +static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__bounds( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__bounds(&b->private_impl.config) + : ((wuffs_base__rect_ie_u32){}); +} + +static inline uint32_t wuffs_base__image_buffer__width( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0; +} + +static inline uint32_t wuffs_base__image_buffer__height( + wuffs_base__image_buffer* b) { + return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( @@ -1254,6 +1320,8 @@ static inline wuffs_base__table_u8 wuffs_base__image_buffer__plane( } // extern "C" #endif +// Code generated by wuffs-c. DO NOT EDIT. + // ---------------- Use Declarations #ifdef __cplusplus