mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Add C++ convenience methods
This commit is contained in:
1 parent
60a7b48745
commit
30cfaa5db7
20 files changed
+1444
-229
No files matched your search
+120
-13
@@ -671,23 +671,13 @@ static inline uint32_t wuffs_base__rect_ie_u32__height(
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length), plus
|
||||
// additional indexes into that buffer, plus an opened / closed flag.
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty buffer.
|
||||
typedef struct {
|
||||
uint8_t* ptr; // Pointer.
|
||||
size_t len; // Length.
|
||||
size_t wi; // Write index. Invariant: wi <= len.
|
||||
size_t ri; // Read index. Invariant: ri <= wi.
|
||||
bool closed; // No further writes are expected.
|
||||
} wuffs_base__io_buffer;
|
||||
struct wuffs_base__io_buffer__struct;
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
wuffs_base__io_buffer* buf;
|
||||
struct wuffs_base__io_buffer__struct* buf;
|
||||
// The bounds values are typically NULL, when created by the Wuffs public
|
||||
// API. NULL means that the callee substitutes the implicit bounds derived
|
||||
// from buf.
|
||||
@@ -699,7 +689,7 @@ typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
wuffs_base__io_buffer* buf;
|
||||
struct wuffs_base__io_buffer__struct* buf;
|
||||
// The bounds values are typically NULL, when created by the Wuffs public
|
||||
// API. NULL means that the callee substitutes the implicit bounds derived
|
||||
// from buf.
|
||||
@@ -707,6 +697,25 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__io_writer;
|
||||
|
||||
// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length), plus
|
||||
// additional indexes into that buffer, plus an opened / closed flag.
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty buffer.
|
||||
typedef struct wuffs_base__io_buffer__struct {
|
||||
uint8_t* ptr; // Pointer.
|
||||
size_t len; // Length.
|
||||
size_t wi; // Write index. Invariant: wi <= len.
|
||||
size_t ri; // Read index. Invariant: ri <= wi.
|
||||
bool closed; // No further writes are expected.
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline void compact();
|
||||
inline wuffs_base__io_reader reader();
|
||||
inline wuffs_base__io_writer writer();
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_base__io_buffer;
|
||||
|
||||
// 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) {
|
||||
@@ -735,6 +744,22 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline void wuffs_base__io_buffer__struct::compact() {
|
||||
wuffs_base__io_buffer__compact(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__io_reader wuffs_base__io_buffer__struct::reader() {
|
||||
return wuffs_base__io_buffer__reader(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__io_writer wuffs_base__io_buffer__struct::writer() {
|
||||
return wuffs_base__io_buffer__writer(this);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
@@ -1350,6 +1375,13 @@ typedef struct {
|
||||
uint32_t f_state;
|
||||
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline void check_wuffs_version(size_t sizeof_star_self,
|
||||
uint64_t wuffs_version);
|
||||
inline uint32_t update(wuffs_base__slice_u8 a_x);
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_crc32__ieee_hasher;
|
||||
|
||||
// ---------------- Public Initializer Prototypes
|
||||
@@ -1369,6 +1401,23 @@ void wuffs_crc32__ieee_hasher__check_wuffs_version(
|
||||
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||
wuffs_base__slice_u8 a_x);
|
||||
|
||||
// ---------------- C++ Convenience Methods
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline void wuffs_crc32__ieee_hasher::check_wuffs_version(
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version) {
|
||||
wuffs_crc32__ieee_hasher__check_wuffs_version(this, sizeof_star_self,
|
||||
wuffs_version);
|
||||
}
|
||||
|
||||
inline uint32_t wuffs_crc32__ieee_hasher::update(wuffs_base__slice_u8 a_x) {
|
||||
return wuffs_crc32__ieee_hasher__update(this, a_x);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1503,6 +1552,14 @@ typedef struct {
|
||||
uint32_t v_hdist;
|
||||
} c_decode_huffman_slow[1];
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline void check_wuffs_version(size_t sizeof_star_self,
|
||||
uint64_t wuffs_version);
|
||||
inline wuffs_base__status decode(wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src);
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_deflate__decoder;
|
||||
|
||||
// ---------------- Public Initializer Prototypes
|
||||
@@ -1522,6 +1579,25 @@ wuffs_base__status wuffs_deflate__decoder__decode(wuffs_deflate__decoder* self,
|
||||
wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src);
|
||||
|
||||
// ---------------- C++ Convenience Methods
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline void wuffs_deflate__decoder::check_wuffs_version(
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version) {
|
||||
wuffs_deflate__decoder__check_wuffs_version(this, sizeof_star_self,
|
||||
wuffs_version);
|
||||
}
|
||||
|
||||
inline wuffs_base__status wuffs_deflate__decoder::decode(
|
||||
wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src) {
|
||||
return wuffs_deflate__decoder__decode(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1578,6 +1654,15 @@ typedef struct {
|
||||
uint64_t scratch;
|
||||
} c_decode[1];
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline void check_wuffs_version(size_t sizeof_star_self,
|
||||
uint64_t wuffs_version);
|
||||
inline void set_ignore_checksum(bool a_ic);
|
||||
inline wuffs_base__status decode(wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src);
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_gzip__decoder;
|
||||
|
||||
// ---------------- Public Initializer Prototypes
|
||||
@@ -1600,6 +1685,28 @@ wuffs_base__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
||||
wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src);
|
||||
|
||||
// ---------------- C++ Convenience Methods
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline void wuffs_gzip__decoder::check_wuffs_version(size_t sizeof_star_self,
|
||||
uint64_t wuffs_version) {
|
||||
wuffs_gzip__decoder__check_wuffs_version(this, sizeof_star_self,
|
||||
wuffs_version);
|
||||
}
|
||||
|
||||
inline void wuffs_gzip__decoder::set_ignore_checksum(bool a_ic) {
|
||||
return wuffs_gzip__decoder__set_ignore_checksum(this, a_ic);
|
||||
}
|
||||
|
||||
inline wuffs_base__status wuffs_gzip__decoder::decode(
|
||||
wuffs_base__io_writer a_dst,
|
||||
wuffs_base__io_reader a_src) {
|
||||
return wuffs_gzip__decoder__decode(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user