migrate to the new for-loop syntax

Drop the ':' before captures (for xs (x) / for 0..n (i)); the index
capture becomes the trailing open range (for xs, 0.. (x, i)). 136
headers across 26 files, mechanical.

Five headless tests (banner_layout, hit_test, swipe_commit,
swipe_intent, swipe_reshuffle) also gain a direct
#import "modules/ui/types.sx" — they named Point/Frame through a
transitive import, which bare visibility no longer permits.

Gates: sx build --target ios-sim main.sx links; tools/run_tests.sh
23/23.
This commit is contained in:
swipelab
2026-06-10 20:39:59 +03:00
parent 5a0627bb7c
commit a7b41ccbca
28 changed files with 141 additions and 136 deletions

View File

@@ -22,7 +22,7 @@ SEED :: 1337;
// board can be written as a human-readable grid. The hole glyph maps to `.empty`.
char_to_gem :: (c: u8) -> Gem {
if c == EMPTY_CHAR { return .empty; }
for 0..GEM_COUNT: (i) {
for 0..GEM_COUNT (i) {
if GEM_CHARS[i] == c { return cast(Gem) i; }
}
.red
@@ -32,9 +32,9 @@ char_to_gem :: (c: u8) -> Gem {
// The RNG is left unseeded — callers seed it before drawing.
load_board :: (rows: []string) -> Board {
b : Board = ---;
for 0..BOARD_ROWS: (row) {
for 0..BOARD_ROWS (row) {
line := rows[row];
for 0..BOARD_COLS: (col) {
for 0..BOARD_COLS (col) {
b.set(col, row, char_to_gem(line[col]));
}
}
@@ -43,12 +43,12 @@ load_board :: (rows: []string) -> Board {
count_empties :: (b: *Board) -> s64 {
n : s64 = 0;
for 0..BOARD_CELLS: (i) { if b.cells[i] == .empty { n += 1; } }
for 0..BOARD_CELLS (i) { if b.cells[i] == .empty { n += 1; } }
n
}
boards_equal :: (a: *Board, b: *Board) -> bool {
for 0..BOARD_CELLS: (i) { if a.cells[i] != b.cells[i] { return false; } }
for 0..BOARD_CELLS (i) { if a.cells[i] != b.cells[i] { return false; } }
true
}
@@ -101,7 +101,7 @@ main :: () -> s32 {
distinct := false;
have_first := false;
first : Gem = .empty;
for 0..BOARD_CELLS: (i) {
for 0..BOARD_CELLS (i) {
if pre.cells[i] == .empty {
want := cast(Gem) v.next_range(GEM_COUNT);
if b.cells[i] != want { stream_ok = false; }
@@ -125,17 +125,17 @@ main :: () -> s32 {
holes_n := 0;
hole_idx : [BOARD_CELLS]s64 = ---;
fill1 : [BOARD_CELLS]Gem = ---;
for 0..BOARD_CELLS: (i) {
for 0..BOARD_CELLS (i) {
if pre.cells[i] == .empty {
hole_idx[holes_n] = i;
fill1[holes_n] = b.cells[i];
holes_n += 1;
}
}
for 0..holes_n: (k) { b.cells[hole_idx[k]] = .empty; }
for 0..holes_n (k) { b.cells[hole_idx[k]] = .empty; }
refill(@b);
differs := false;
for 0..holes_n: (k) {
for 0..holes_n (k) {
if b.cells[hole_idx[k]] != fill1[k] { differs = true; }
}
t.expect(differs, "refill: a second refill of the same holes draws new gems (RNG threads, no reseed)");