base: rename min/max arg to no_more/less_than
diff --git a/doc/changelog.md b/doc/changelog.md
index 9f4381d..f6c3a6d 100644
--- a/doc/changelog.md
+++ b/doc/changelog.md
@@ -13,6 +13,7 @@
code (instead of writing C/C++ code that _uses_ Wuffs' standard library).
- Added read-only type decorators: `roarray`, `roslice` and `rotable`.
+- Renamed `base` `min/max` argument from `a` to `no_more/less_than`.
- Wuffs struct private data now needs a "+" between the "()" pairs.
- `wuffsfmt` double-indents hanging lines and each indent is now 4 spaces (not
a tab).
diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go
index 37522ee..77a6ccd 100644
--- a/lang/builtin/builtin.go
+++ b/lang/builtin/builtin.go
@@ -347,23 +347,23 @@
var funcsOther = [...]string{
"u8.high_bits(n: u32[..= 7]) u8",
"u8.low_bits(n: u32[..= 7]) u8",
- "u8.max(a: u8) u8",
- "u8.min(a: u8) u8",
+ "u8.max(no_less_than: u8) u8",
+ "u8.min(no_more_than: u8) u8",
"u16.high_bits(n: u32[..= 15]) u16",
"u16.low_bits(n: u32[..= 15]) u16",
- "u16.max(a: u16) u16",
- "u16.min(a: u16) u16",
+ "u16.max(no_less_than: u16) u16",
+ "u16.min(no_more_than: u16) u16",
"u32.high_bits(n: u32[..= 31]) u32",
"u32.low_bits(n: u32[..= 31]) u32",
- "u32.max(a: u32) u32",
- "u32.min(a: u32) u32",
+ "u32.max(no_less_than: u32) u32",
+ "u32.min(no_more_than: u32) u32",
"u64.high_bits(n: u32[..= 63]) u64",
"u64.low_bits(n: u32[..= 63]) u64",
- "u64.max(a: u64) u64",
- "u64.min(a: u64) u64",
+ "u64.max(no_less_than: u64) u64",
+ "u64.min(no_more_than: u64) u64",
// ---- utility
diff --git a/std/bmp/decode_bmp.wuffs b/std/bmp/decode_bmp.wuffs
index c071ef8..e725054 100644
--- a/std/bmp/decode_bmp.wuffs
+++ b/std/bmp/decode_bmp.wuffs
@@ -577,7 +577,7 @@
return "#unsupported BMP file"
}
n = args.src.length() / (src_bytes_per_pixel as base.u64)
- n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
+ n = n.min(no_more_than: (this.width ~mod- this.dst_x) as base.u64)
j = n
while j >= 8 {
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
@@ -770,7 +770,7 @@
p0 = (p0 & 255) + 0x04
chunk_count -= 1
} endwhile
- p0 = p0.min(a: this.rle_length)
+ p0 = p0.min(no_more_than: this.rle_length)
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
@@ -930,7 +930,7 @@
// -------- BEGIN convert to PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE.
p1_temp = this.width ~mod- this.dst_x
- p1 = p1_temp.min(a: 256)
+ p1 = p1_temp.min(no_more_than: 256)
p0 = 0
while p0 < p1 {
assert p0 < 256 via "a < b: a < c; c <= b"(c: p1)
@@ -1057,12 +1057,12 @@
}
while (chunk_count >= 64) and (args.src.length() >= 256) {
args.src.skip_u32_fast!(actual: 256, worst_case: 256)
- this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 64))
+ this.dst_x = this.width.min(no_more_than: this.dst_x ~mod+ (pixels_per_chunk * 64))
chunk_count -= 64
} endwhile
while (chunk_count >= 8) and (args.src.length() >= 32) {
args.src.skip_u32_fast!(actual: 32, worst_case: 32)
- this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 8))
+ this.dst_x = this.width.min(no_more_than: this.dst_x ~mod+ (pixels_per_chunk * 8))
chunk_count -= 8
} endwhile
while chunk_count > 0 {
@@ -1070,7 +1070,7 @@
return "@internal note: short read"
}
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
- this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 1))
+ this.dst_x = this.width.min(no_more_than: this.dst_x ~mod+ (pixels_per_chunk * 1))
chunk_count -= 1
} endwhile
continue.loop
@@ -1082,7 +1082,7 @@
// Calculate the remaining number of 32-bit chunks. At 1 bit per
// pixel there are 32 pixels per chunk. Division rounds up.
chunk_count = ((this.width ~sat- this.dst_x) + 31) / 32
- chunk_count = chunk_count.min(a: 16) // Keep p0 <= 512.
+ chunk_count = chunk_count.min(no_more_than: 16) // Keep p0 <= 512.
while (chunk_count > 0) and (args.src.length() >= 4) {
chunk_bits = args.src.peek_u32be()
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
@@ -1126,7 +1126,7 @@
// Calculate the remaining number of 32-bit chunks. At 2 bits per
// pixel there are 16 pixels per chunk. Division rounds up.
chunk_count = ((this.width ~sat- this.dst_x) + 15) / 16
- chunk_count = chunk_count.min(a: 32) // Keep p0 <= 512.
+ chunk_count = chunk_count.min(no_more_than: 32) // Keep p0 <= 512.
while (chunk_count > 0) and (args.src.length() >= 4) {
chunk_bits = args.src.peek_u32be()
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
@@ -1154,7 +1154,7 @@
// Calculate the remaining number of 32-bit chunks. At 4 bits per
// pixel there are 8 pixels per chunk. Division rounds up.
chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8
- chunk_count = chunk_count.min(a: 64) // Keep p0 <= 512.
+ chunk_count = chunk_count.min(no_more_than: 64) // Keep p0 <= 512.
while (chunk_count > 0) and (args.src.length() >= 4) {
chunk_bits = args.src.peek_u32be()
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
@@ -1171,7 +1171,7 @@
} endwhile
}
- p0 = p0.min(a: this.width ~sat- this.dst_x)
+ p0 = p0.min(no_more_than: this.width ~sat- this.dst_x)
n = this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
diff --git a/std/cbor/decode_cbor.wuffs b/std/cbor/decode_cbor.wuffs
index a74812d..3fd0e94 100644
--- a/std/cbor/decode_cbor.wuffs
+++ b/std/cbor/decode_cbor.wuffs
@@ -330,7 +330,7 @@
yield? base."$short write"
continue
}
- n64 = string_length.min(a: args.src.length())
+ n64 = string_length.min(no_more_than: args.src.length())
token_length = (n64 & 0xFFFF) as base.u32
if n64 > 0xFFFF {
token_length = 0xFFFF
@@ -413,7 +413,7 @@
yield? base."$short write"
continue
}
- n64 = string_length.min(a: 0xFFFF)
+ n64 = string_length.min(no_more_than: 0xFFFF)
n64 = args.src.valid_utf_8_length(up_to: n64)
token_length = (n64 & 0xFFFF) as base.u32
if token_length <= 0 {
diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs
index d671e4d..f661483 100644
--- a/std/gif/decode_gif.wuffs
+++ b/std/gif/decode_gif.wuffs
@@ -294,13 +294,13 @@
}
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
- // The "foo.min(a:this.width_or_height)" calls clip the nominal frame_rect
- // to the image_rect.
+ // The "foo.min(no_more_than: this.width_or_height)" calls clip the nominal
+ // frame_rect to the image_rect.
return this.util.make_rect_ie_u32(
- min_incl_x: this.frame_rect_x0.min(a: this.width),
- min_incl_y: this.frame_rect_y0.min(a: this.height),
- max_excl_x: this.frame_rect_x1.min(a: this.width),
- max_excl_y: this.dirty_max_excl_y.min(a: this.height))
+ min_incl_x: this.frame_rect_x0.min(no_more_than: this.width),
+ min_incl_y: this.frame_rect_y0.min(no_more_than: this.height),
+ max_excl_x: this.frame_rect_x1.min(no_more_than: this.width),
+ max_excl_y: this.dirty_max_excl_y.min(no_more_than: this.height))
}
pub func decoder.workbuf_len() base.range_ii_u64 {
@@ -390,13 +390,13 @@
}
if args.dst <> nullptr {
- // The "foo.min(a:this.width_or_height)" calls clip the nominal
- // frame_rect to the image_rect.
+ // The "foo.min(no_more_than: this.width_or_height)" calls clip the
+ // nominal frame_rect to the image_rect.
args.dst.set!(bounds: this.util.make_rect_ie_u32(
- min_incl_x: this.frame_rect_x0.min(a: this.width),
- min_incl_y: this.frame_rect_y0.min(a: this.height),
- max_excl_x: this.frame_rect_x1.min(a: this.width),
- max_excl_y: this.frame_rect_y1.min(a: this.height)),
+ min_incl_x: this.frame_rect_x0.min(no_more_than: this.width),
+ min_incl_y: this.frame_rect_y0.min(no_more_than: this.height),
+ max_excl_x: this.frame_rect_x1.min(no_more_than: this.width),
+ max_excl_y: this.frame_rect_y1.min(no_more_than: this.height)),
duration: this.gc_duration,
index: this.num_decoded_frame_configs_value,
io_position: this.frame_config_io_position,
@@ -804,8 +804,8 @@
// test/data/artificial/gif-frame-out-of-bounds.gif.make-artificial.txt for
// more discussion.
if (this.num_decoded_frame_configs_value == 0) and (not this.quirks[QUIRK_IMAGE_BOUNDS_ARE_STRICT - QUIRKS_BASE]) {
- this.width = this.width.max(a: this.frame_rect_x1)
- this.height = this.height.max(a: this.frame_rect_y1)
+ this.width = this.width.max(no_less_than: this.frame_rect_x1)
+ this.height = this.height.max(no_less_than: this.frame_rect_y1)
}
}
@@ -936,7 +936,7 @@
this.compressed_wi = 0
}
while this.compressed_wi <= (4096 - 255) {
- n_compressed = block_size.min(a: args.src.length())
+ n_compressed = block_size.min(no_more_than: args.src.length())
if n_compressed <= 0 {
break
}
@@ -1078,7 +1078,7 @@
src_ri ~sat+= n
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
- this.dirty_max_excl_y = this.dirty_max_excl_y.max(a: this.dst_y ~sat+ 1)
+ this.dirty_max_excl_y = this.dirty_max_excl_y.max(no_less_than: this.dst_y ~sat+ 1)
}
if this.frame_rect_x1 <= this.dst_x {
@@ -1102,14 +1102,14 @@
replicate_src = tab.row_u32(y: this.dst_y)
replicate_y0 = this.dst_y ~sat+ 1
replicate_y1 = this.dst_y ~sat+ (INTERLACE_COUNT[this.interlace] as base.u32)
- replicate_y1 = replicate_y1.min(a: this.frame_rect_y1)
+ replicate_y1 = replicate_y1.min(no_more_than: this.frame_rect_y1)
while replicate_y0 < replicate_y1 {
assert replicate_y0 < 0xFFFF_FFFF via "a < b: a < c; c <= b"(c: replicate_y1)
replicate_dst = tab.row_u32(y: replicate_y0)
replicate_dst.copy_from_slice!(s: replicate_src)
replicate_y0 += 1
} endwhile
- this.dirty_max_excl_y = this.dirty_max_excl_y.max(a: replicate_y1)
+ this.dirty_max_excl_y = this.dirty_max_excl_y.max(no_less_than: replicate_y1)
}
this.dst_y ~sat+= INTERLACE_DELTA[this.interlace] as base.u32
@@ -1131,7 +1131,7 @@
// Set n to the number of pixels (i.e. the number of bytes) to skip.
n = (this.frame_rect_x1 - this.dst_x) as base.u64
- n = n.min(a: args.src.length() - src_ri)
+ n = n.min(no_more_than: args.src.length() - src_ri)
src_ri ~sat+= n
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
diff --git a/std/nie/decode_nie.wuffs b/std/nie/decode_nie.wuffs
index 619369a..9de8467 100644
--- a/std/nie/decode_nie.wuffs
+++ b/std/nie/decode_nie.wuffs
@@ -246,7 +246,7 @@
assert src_bytes_per_pixel > 0
}
n = args.src.length() / (src_bytes_per_pixel as base.u64)
- n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
+ n = n.min(no_more_than: (this.width ~mod- this.dst_x) as base.u64)
j = n
while j >= 8 {
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
diff --git a/std/png/decode_filter_fallback.wuffs b/std/png/decode_filter_fallback.wuffs
index 1049988..6a13b9c 100644
--- a/std/png/decode_filter_fallback.wuffs
+++ b/std/png/decode_filter_fallback.wuffs
@@ -84,7 +84,7 @@
var n : base.u64
var i : base.u64
- n = args.curr.length().min(a: args.prev.length())
+ n = args.curr.length().min(no_more_than: args.prev.length())
i = 0
while i < n,
inv n <= args.curr.length(),
@@ -122,7 +122,7 @@
} endwhile
} else {
- n = args.curr.length().min(a: args.prev.length())
+ n = args.curr.length().min(no_more_than: args.prev.length())
i = 0
while (i < n) and (i < filter_distance),
inv n <= args.curr.length(),
@@ -238,7 +238,7 @@
var pc : base.u32
filter_distance = this.filter_distance as base.u64
- n = args.curr.length().min(a: args.prev.length())
+ n = args.curr.length().min(no_more_than: args.prev.length())
i = 0
while (i < n) and (i < filter_distance),
inv n <= args.curr.length(),
diff --git a/std/tga/decode_tga.wuffs b/std/tga/decode_tga.wuffs
index c3bddd6..5247960 100644
--- a/std/tga/decode_tga.wuffs
+++ b/std/tga/decode_tga.wuffs
@@ -378,7 +378,7 @@
if lit_length > 0 {
mark = args.src.mark()
num_pixels64 = args.src.length() / (this.src_bytes_per_pixel as base.u64)
- num_pixels32 = num_pixels64.min(a: lit_length as base.u64) as base.u32
+ num_pixels32 = num_pixels64.min(no_more_than: lit_length as base.u64) as base.u32
num_dst_bytes = (num_pixels32 as base.u64) * dst_bytes_per_pixel
num_src_bytes = num_pixels32 * this.src_bytes_per_pixel
args.src.skip_u32?(n: num_src_bytes)