diff --git a/tetris.jam b/tetris.jam index f59bf83..cde3891 100644 --- 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 getch() i32; 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 @@ fn main() { 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 @@ fn main() { } // 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;