mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Rename buf1, reader1, etc to io_buffer, io_reader
Also remove the unused Buf1, Buf2 and Usize tokens.
This commit is contained in:
1 parent
82a48796c8
commit
97aab37462
46 files changed
+823
-847
No files matched your search
+32
-34
@@ -99,9 +99,7 @@ typedef struct {
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// TODO: rename buf1 to io_buffer, writer1 to io_writer, etc.
|
||||
|
||||
// wuffs_base__buf1 is a 1-dimensional buffer (a pointer and length), plus
|
||||
// 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.
|
||||
@@ -111,44 +109,44 @@ typedef struct {
|
||||
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__buf1;
|
||||
} wuffs_base__io_buffer;
|
||||
|
||||
// wuffs_base__limit1 provides a limited view of a 1-dimensional byte stream:
|
||||
// wuffs_base__io_limit provides a limited view of a 1-dimensional byte stream:
|
||||
// its first N bytes. That N can be greater than a buffer's current read or
|
||||
// write capacity. N decreases naturally over time as bytes are read from or
|
||||
// written to the stream.
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, unlimited view.
|
||||
typedef struct wuffs_base__limit1 {
|
||||
uint64_t* ptr_to_len; // Pointer to N.
|
||||
struct wuffs_base__limit1* next; // Linked list of limits.
|
||||
} wuffs_base__limit1;
|
||||
typedef struct wuffs_base__io_limit {
|
||||
uint64_t* ptr_to_len; // Pointer to N.
|
||||
struct wuffs_base__io_limit* next; // Linked list of limits.
|
||||
} wuffs_base__io_limit;
|
||||
|
||||
typedef struct {
|
||||
// TODO: move buf into private_impl? As it is, it looks like users can modify
|
||||
// the buf field to point to a different buffer, which can turn the limit and
|
||||
// mark fields into dangling pointers.
|
||||
wuffs_base__buf1* buf;
|
||||
wuffs_base__io_buffer* buf;
|
||||
// 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__limit1 limit;
|
||||
wuffs_base__io_limit limit;
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} wuffs_base__reader1;
|
||||
} wuffs_base__io_reader;
|
||||
|
||||
typedef struct {
|
||||
// TODO: move buf into private_impl? As it is, it looks like users can modify
|
||||
// the buf field to point to a different buffer, which can turn the limit and
|
||||
// mark fields into dangling pointers.
|
||||
wuffs_base__buf1* buf;
|
||||
wuffs_base__io_buffer* buf;
|
||||
// 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__limit1 limit;
|
||||
wuffs_base__io_limit limit;
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
} wuffs_base__io_writer;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
@@ -848,9 +846,9 @@ static inline uint64_t wuffs_base__slice_u8__copy_from_slice(
|
||||
return length;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__writer1__copy_from_history32(
|
||||
static inline uint32_t wuffs_base__io_writer__copy_from_history32(
|
||||
uint8_t** ptr_ptr,
|
||||
uint8_t* start, // May be NULL, meaning an unmarked writer1.
|
||||
uint8_t* start, // May be NULL, meaning an unmarked io_writer.
|
||||
uint8_t* end,
|
||||
uint32_t distance,
|
||||
uint32_t length) {
|
||||
@@ -874,7 +872,7 @@ static inline uint32_t wuffs_base__writer1__copy_from_history32(
|
||||
// copy_from_history32 Wuffs method should also take an unroll hint argument,
|
||||
// and the cgen can look if that argument is the constant expression '3'.
|
||||
//
|
||||
// See also wuffs_base__writer1__copy_from_history32__bco below.
|
||||
// See also wuffs_base__io_writer__copy_from_history32__bco below.
|
||||
//
|
||||
// Alternatively, or additionally, have a sloppy_copy_from_history32 method
|
||||
// that copies 8 bytes at a time, possibly writing more than length bytes?
|
||||
@@ -890,14 +888,14 @@ static inline uint32_t wuffs_base__writer1__copy_from_history32(
|
||||
return length;
|
||||
}
|
||||
|
||||
// wuffs_base__writer1__copy_from_history32__bco is a Bounds Check Optimized
|
||||
// version of the wuffs_base__writer1__copy_from_history32 function above. The
|
||||
// caller needs to prove that:
|
||||
// wuffs_base__io_writer__copy_from_history32__bco is a Bounds Check Optimized
|
||||
// version of the wuffs_base__io_writer__copy_from_history32 function above.
|
||||
// The caller needs to prove that:
|
||||
// - start != NULL
|
||||
// - distance > 0
|
||||
// - distance <= (*ptr_ptr - start)
|
||||
// - length <= (end - *ptr_ptr)
|
||||
static inline uint32_t wuffs_base__writer1__copy_from_history32__bco(
|
||||
static inline uint32_t wuffs_base__io_writer__copy_from_history32__bco(
|
||||
uint8_t** ptr_ptr,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
@@ -918,7 +916,7 @@ static inline uint32_t wuffs_base__writer1__copy_from_history32__bco(
|
||||
return length;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__writer1__copy_from_reader32(
|
||||
static inline uint32_t wuffs_base__io_writer__copy_from_reader32(
|
||||
uint8_t** ptr_wptr,
|
||||
uint8_t* wend,
|
||||
uint8_t** ptr_rptr,
|
||||
@@ -941,7 +939,7 @@ static inline uint32_t wuffs_base__writer1__copy_from_reader32(
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint64_t wuffs_base__writer1__copy_from_slice(
|
||||
static inline uint64_t wuffs_base__io_writer__copy_from_slice(
|
||||
uint8_t** ptr_wptr,
|
||||
uint8_t* wend,
|
||||
wuffs_base__slice_u8 src) {
|
||||
@@ -957,7 +955,7 @@ static inline uint64_t wuffs_base__writer1__copy_from_slice(
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__writer1__copy_from_slice32(
|
||||
static inline uint32_t wuffs_base__io_writer__copy_from_slice32(
|
||||
uint8_t** ptr_wptr,
|
||||
uint8_t* wend,
|
||||
wuffs_base__slice_u8 src,
|
||||
@@ -979,7 +977,7 @@ static inline uint32_t wuffs_base__writer1__copy_from_slice32(
|
||||
|
||||
// Note that the *__limit and *__mark methods are private (in base-impl.h) not
|
||||
// public (in base-header.h). We assume that, at the boundary between user code
|
||||
// and Wuffs code, the reader1 and writer1's private_impl fields (including
|
||||
// and Wuffs code, the io_reader and io_writer's private_impl fields (including
|
||||
// limit and mark) are NULL. Otherwise, some internal assumptions break down.
|
||||
// For example, limits could be represented as pointers, even though
|
||||
// conceptually they are counts, but that pointer-to-count correspondence
|
||||
@@ -989,26 +987,26 @@ static inline uint32_t wuffs_base__writer1__copy_from_slice32(
|
||||
// code is still Wuffs code, not user code. Other Wuffs test code modifies
|
||||
// private_impl fields directly.
|
||||
|
||||
static inline wuffs_base__reader1 wuffs_base__reader1__limit(
|
||||
wuffs_base__reader1* o,
|
||||
static inline wuffs_base__io_reader wuffs_base__io_reader__limit(
|
||||
wuffs_base__io_reader* o,
|
||||
uint64_t* ptr_to_len) {
|
||||
wuffs_base__reader1 ret = *o;
|
||||
wuffs_base__io_reader ret = *o;
|
||||
ret.private_impl.limit.ptr_to_len = ptr_to_len;
|
||||
ret.private_impl.limit.next = &o->private_impl.limit;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct wuffs_base__reader1__mark(
|
||||
wuffs_base__reader1* o,
|
||||
static inline wuffs_base__empty_struct wuffs_base__io_reader__mark(
|
||||
wuffs_base__io_reader* o,
|
||||
uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
// TODO: static inline wuffs_base__writer1 wuffs_base__writer1__limit()
|
||||
// TODO: static inline wuffs_base__io_writer wuffs_base__io_writer__limit()
|
||||
|
||||
static inline wuffs_base__empty_struct wuffs_base__writer1__mark(
|
||||
wuffs_base__writer1* o,
|
||||
static inline wuffs_base__empty_struct wuffs_base__io_writer__mark(
|
||||
wuffs_base__io_writer* o,
|
||||
uint8_t* mark) {
|
||||
o->private_impl.mark = mark;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
|
||||
Reference in new issue
Block a user