From 4b4cd358375d4e4fdffac027bf932743eb974cb3 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Mon, 04 May 2026 11:53:21 +0000 Subject: [PATCH] change ptr notation --- tetris.jam | 29 +++++++++++++---------------- 1 file(s) changed, 13 insertion(s)(+), 16 deletion(s)(-) diff --git a/tetris.jam b/tetris.jam --- a/tetris.jam +++ b/tetris.jam @@ -1,21 +1,18 @@ const { assert } = import("test"); -// the imports from ncurses that we need -// `WINDOW *` is opaque on the C side so we -// model it as `*u8` (we never deref it). ncurses' `bool` is traditionally +// the imports from ncurses that we need. +// `WINDOW *` is opaque on the C side so we model it as `*const u8` — +// we never deref it from Jam. ncurses' `bool` is traditionally // `unsigned char`, not C99 _Bool, so we pass i8 with 1 = TRUE, 0 = FALSE. - -// TODO: I am not sure about [*] notation, for now I am following zig idea but -// it's very likely it will change. // TODO: Need to evaluate C exports depending of jam build options (more tbd). -extern fn initscr() *u8; +extern fn initscr() *const u8; extern fn endwin() i32; extern fn cbreak() i32; extern fn noecho() i32; -extern fn keypad(win: *u8, bf: i8) i32; -extern fn nodelay(win: *u8, bf: i8) i32; +extern fn keypad(win: *const u8, bf: i8) i32; +extern fn nodelay(win: *const u8, bf: i8) i32; extern fn curs_set(visibility: i32) i32; extern fn start_color() i32; extern fn init_pair(pair: i16, fg: i16, bg: i16) i32; @@ -23,15 +20,15 @@ extern fn refresh() i32; extern fn clear() i32; extern fn mvaddch(y: i32, x: i32, ch: u32) i32; -extern fn mvprintw(y: i32, x: i32, format: [*]u8, ...) i32; +extern fn mvprintw(y: i32, x: i32, format: *const[] u8, ...) i32; extern fn attron(attrs: i32) i32; extern fn attroff(attrs: i32) i32; extern fn napms(ms: i32) i32; -extern fn mvaddstr(y: i32, x: i32, s: [*]u8) i32; +extern fn mvaddstr(y: i32, x: i32, s: *const[] u8) i32; extern fn use_default_colors() i32; -extern fn write(fd: i32, buf: [*]u8, count: u64) i64; -extern fn setlocale(category: i32, locale: [*]u8) [*]u8; -extern fn setenv(name: [*]u8, value: [*]u8, overwrite: i32) i32; +extern fn write(fd: i32, buf: *const[] u8, count: u64) i64; +extern fn setlocale(category: i32, locale: *const[] u8) *const[] u8; +extern fn setenv(name: *const[] u8, value: *const[] u8, overwrite: i32) i32; // basically is `(n & 0xff) << 8` in ncurses' chtype encoding. fn colorPair(n: i32) i32 { @@ -70,7 +67,7 @@ var loc: []u8 = ""; setlocale(0, loc.ptr); - var win: *u8 = initscr(); + var win: *const u8 = initscr(); cbreak(); noecho(); keypad(win, 1); @@ -157,7 +154,7 @@ } // it ideally tries to match github.com/samtay/tetris's relCells impl -fn fillRelCells(shape: u8, out: [*]i8) { +fn fillRelCells(shape: u8, out: *mut[] i8) { if (shape == 0) { // I: (-2,0), (-1,0), (1,0) out[0] = -2; out[1] = 0; -- tangled.sh