lang: rename signed integer types sN -> iN

Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.

Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).

Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.

zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
agra
2026-06-12 09:31:53 +03:00
parent 515ecebea7
commit d8076b9333
1054 changed files with 6836 additions and 6839 deletions

View File

@@ -56,7 +56,7 @@ SurfaceView :: #foreign #jni_class("android/view/SurfaceView") {
SurfaceHolderCallback :: #foreign #jni_class("android/view/SurfaceHolder$Callback") { }
MotionEvent :: #foreign #jni_class("android/view/MotionEvent") {
getAction :: (self: *Self) -> s32;
getAction :: (self: *Self) -> i32;
getX :: (self: *Self) -> f32;
getY :: (self: *Self) -> f32;
}
@@ -72,23 +72,23 @@ ActivityClass :: #foreign #jni_class("android/app/Activity") {
// can route through `AAssetManager_open` when running on Android.
sx_android_set_asset_manager :: (mgr: *void) #foreign;
__android_log_print :: (prio: s32, tag: *u8, fmt: *u8) -> s32 #foreign;
usleep :: (us: u32) -> s32 #foreign;
__android_log_print :: (prio: i32, tag: *u8, fmt: *u8) -> i32 #foreign;
usleep :: (us: u32) -> i32 #foreign;
// libandroid
ANativeWindow_fromSurface :: (env: *void, surface: *void) -> *void #foreign;
ANativeWindow_release :: (window: *void) #foreign;
ANativeWindow_getWidth :: (window: *void) -> s32 #foreign;
ANativeWindow_getHeight :: (window: *void) -> s32 #foreign;
ANativeWindow_setBuffersGeometry :: (w: *void, width: s32, height: s32, fmt: s32) -> s32 #foreign;
ANativeWindow_getWidth :: (window: *void) -> i32 #foreign;
ANativeWindow_getHeight :: (window: *void) -> i32 #foreign;
ANativeWindow_setBuffersGeometry :: (w: *void, width: i32, height: i32, fmt: i32) -> i32 #foreign;
AAssetManager_fromJava :: (env: *void, mgr: *void) -> *void #foreign;
// pthread (link libpthread is built into bionic).
pthread_create :: (thread: *u64, attr: *void, start: (*void) -> *void callconv(.c), arg: *void) -> s32 #foreign;
pthread_mutex_init :: (m: *void, attr: *void) -> s32 #foreign;
pthread_mutex_lock :: (m: *void) -> s32 #foreign;
pthread_mutex_unlock :: (m: *void) -> s32 #foreign;
pthread_create :: (thread: *u64, attr: *void, start: (*void) -> *void callconv(.c), arg: *void) -> i32 #foreign;
pthread_mutex_init :: (m: *void, attr: *void) -> i32 #foreign;
pthread_mutex_lock :: (m: *void) -> i32 #foreign;
pthread_mutex_unlock :: (m: *void) -> i32 #foreign;
// EGL. Constants from <EGL/egl.h>. We bring up an ES3 context with a
// 24-bit RGB framebuffer + 24-bit depth (same shape chess used under
@@ -99,25 +99,25 @@ EGL_NO_CONTEXT :*void: null;
EGL_NO_SURFACE :*void: null;
EGL_TRUE :u32: 1;
EGL_FALSE :u32: 0;
EGL_NONE :s32: 0x3038;
EGL_RED_SIZE :s32: 0x3024;
EGL_GREEN_SIZE :s32: 0x3023;
EGL_BLUE_SIZE :s32: 0x3022;
EGL_ALPHA_SIZE :s32: 0x3021;
EGL_DEPTH_SIZE :s32: 0x3025;
EGL_RENDERABLE_TYPE :s32: 0x3040;
EGL_SURFACE_TYPE :s32: 0x3033;
EGL_OPENGL_ES3_BIT :s32: 0x00000040;
EGL_WINDOW_BIT :s32: 0x0004;
EGL_NATIVE_VISUAL_ID :s32: 0x302E;
EGL_CONTEXT_CLIENT_VERSION :s32: 0x3098;
EGL_NONE :i32: 0x3038;
EGL_RED_SIZE :i32: 0x3024;
EGL_GREEN_SIZE :i32: 0x3023;
EGL_BLUE_SIZE :i32: 0x3022;
EGL_ALPHA_SIZE :i32: 0x3021;
EGL_DEPTH_SIZE :i32: 0x3025;
EGL_RENDERABLE_TYPE :i32: 0x3040;
EGL_SURFACE_TYPE :i32: 0x3033;
EGL_OPENGL_ES3_BIT :i32: 0x00000040;
EGL_WINDOW_BIT :i32: 0x0004;
EGL_NATIVE_VISUAL_ID :i32: 0x302E;
EGL_CONTEXT_CLIENT_VERSION :i32: 0x3098;
eglGetDisplay :: (id: u64) -> *void #foreign;
eglInitialize :: (d: *void, major: *s32, minor: *s32) -> u32 #foreign;
eglChooseConfig :: (d: *void, attrs: *s32, configs: **void, sz: s32, num: *s32) -> u32 #foreign;
eglGetConfigAttrib :: (d: *void, cfg: *void, attr: s32, value: *s32) -> u32 #foreign;
eglCreateContext :: (d: *void, cfg: *void, share: *void, attrs: *s32) -> *void #foreign;
eglCreateWindowSurface :: (d: *void, cfg: *void, window: *void, attrs: *s32) -> *void #foreign;
eglInitialize :: (d: *void, major: *i32, minor: *i32) -> u32 #foreign;
eglChooseConfig :: (d: *void, attrs: *i32, configs: **void, sz: i32, num: *i32) -> u32 #foreign;
eglGetConfigAttrib :: (d: *void, cfg: *void, attr: i32, value: *i32) -> u32 #foreign;
eglCreateContext :: (d: *void, cfg: *void, share: *void, attrs: *i32) -> *void #foreign;
eglCreateWindowSurface :: (d: *void, cfg: *void, window: *void, attrs: *i32) -> *void #foreign;
eglMakeCurrent :: (d: *void, draw: *void, read: *void, ctx: *void) -> u32 #foreign;
eglSwapBuffers :: (d: *void, surface: *void) -> u32 #foreign;
eglDestroyContext :: (d: *void, ctx: *void) -> u32 #foreign;
@@ -127,7 +127,7 @@ eglTerminate :: (d: *void) -> u32 #foreign;
// ── Touch ring ──────────────────────────────────────────────────────────
TouchEvent :: struct {
action: s32;
action: i32;
x: f32;
y: f32;
}
@@ -136,10 +136,10 @@ TouchEvent :: struct {
//
// Every per-instance piece of state — EGL handles, ANativeWindow, render
// thread, touch ring + mutex, frame closure, user main fn — lives here.
// No module-level globals: a previous shape had `g_viewport_w : s32` at
// No module-level globals: a previous shape had `g_viewport_w : i32` at
// module scope, which silently shadowed chess's own
// `g_viewport_w : f32` on `#import` and caused the renderer to receive
// a logical width cast to s32 instead of the physical pixel width.
// a logical width cast to i32 instead of the physical pixel width.
//
// `logical_w` is the consumer's design width in points (e.g. chess sets
// 414 to match an iPhone 12 layout). `begin_frame` derives `dpi_scale`
@@ -149,8 +149,8 @@ TouchEvent :: struct {
AndroidPlatform :: struct {
title: [:0]u8 = "";
width: s32 = 0;
height: s32 = 0;
width: i32 = 0;
height: i32 = 0;
// Set by consumer code BEFORE `init` if a fixed design width is
// wanted (chess uses 414). When 0, the platform reports
@@ -168,8 +168,8 @@ AndroidPlatform :: struct {
// Pixel-size from ANativeWindow_get{Width,Height}; derived dpi_scale
// (pixel_w / logical_w when logical_w > 0, else 1.0).
pixel_w: s32 = 0;
pixel_h: s32 = 0;
pixel_w: i32 = 0;
pixel_h: i32 = 0;
dpi_scale: f32 = 1.0;
// Render thread lifecycle. `user_main_fn` is the consumer's `main`
@@ -238,7 +238,7 @@ sx_android_detach_window :: (plat: *AndroidPlatform) {
}
}
sx_android_set_viewport :: (plat: *AndroidPlatform, w: s32, h: s32) {
sx_android_set_viewport :: (plat: *AndroidPlatform, w: i32, h: i32) {
plat.pixel_w = w;
plat.pixel_h = h;
sx_android_recompute_scale(plat);
@@ -280,11 +280,11 @@ sx_android_egl_init :: (plat: *AndroidPlatform) -> bool {
plat.egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if plat.egl_display == EGL_NO_DISPLAY { return false; }
major : s32 = 0;
minor : s32 = 0;
major : i32 = 0;
minor : i32 = 0;
if eglInitialize(plat.egl_display, @major, @minor) == EGL_FALSE { return false; }
cfg_attrs : [13]s32 = .{
cfg_attrs : [13]i32 = .{
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 8,
@@ -293,15 +293,15 @@ sx_android_egl_init :: (plat: *AndroidPlatform) -> bool {
EGL_DEPTH_SIZE, 24,
EGL_NONE,
};
num_cfg : s32 = 0;
num_cfg : i32 = 0;
if eglChooseConfig(plat.egl_display, @cfg_attrs[0], @plat.egl_config, 1, @num_cfg) == EGL_FALSE { return false; }
if num_cfg < 1 { return false; }
visual_id : s32 = 0;
visual_id : i32 = 0;
eglGetConfigAttrib(plat.egl_display, plat.egl_config, EGL_NATIVE_VISUAL_ID, @visual_id);
ANativeWindow_setBuffersGeometry(plat.app_window, 0, 0, visual_id);
ctx_attrs : [3]s32 = .{ EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
ctx_attrs : [3]i32 = .{ EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
plat.egl_context = eglCreateContext(plat.egl_display, plat.egl_config, EGL_NO_CONTEXT, @ctx_attrs[0]);
if plat.egl_context == EGL_NO_CONTEXT { return false; }
@@ -329,7 +329,7 @@ sx_android_recompute_scale :: (plat: *AndroidPlatform) {
// ── Touch event queue ───────────────────────────────────────────────────
sx_android_push_touch :: (plat: *AndroidPlatform, action: s32, x: f32, y: f32) {
sx_android_push_touch :: (plat: *AndroidPlatform, action: i32, x: f32, y: f32) {
sx_android_ensure_touch_mutex(plat);
pthread_mutex_lock(xx @plat.touch_mutex_storage[0]);
next := (plat.touch_tail + 1) % 64;
@@ -373,7 +373,7 @@ sx_android_ensure_touch_mutex :: (plat: *AndroidPlatform) {
// ── Platform impl ───────────────────────────────────────────────────────
impl Platform for AndroidPlatform {
init :: (self: *AndroidPlatform, title: [:0]u8, w: s32, h: s32) -> bool {
init :: (self: *AndroidPlatform, title: [:0]u8, w: i32, h: i32) -> bool {
self.title = title;
self.width = w;
self.height = h;

View File

@@ -12,10 +12,10 @@
// against the bare name within the namespace.
WindowInsets :: #foreign #jni_class("android/view/WindowInsets") {
getSystemWindowInsetTop :: (self: *Self) -> s32;
getSystemWindowInsetLeft :: (self: *Self) -> s32;
getSystemWindowInsetBottom :: (self: *Self) -> s32;
getSystemWindowInsetRight :: (self: *Self) -> s32;
getSystemWindowInsetTop :: (self: *Self) -> i32;
getSystemWindowInsetLeft :: (self: *Self) -> i32;
getSystemWindowInsetBottom :: (self: *Self) -> i32;
getSystemWindowInsetRight :: (self: *Self) -> i32;
}
View :: #foreign #jni_class("android/view/View") {

View File

@@ -4,7 +4,7 @@
#import "modules/platform/types.sx";
Platform :: protocol {
init :: (title: [:0]u8, w: s32, h: s32) -> bool;
init :: (title: [:0]u8, w: i32, h: i32) -> bool;
run_frame_loop :: (frame_fn: Closure());

View File

@@ -130,7 +130,7 @@ bundle_main :: () -> bool {
// Android (Week 7) will zip them into the APK at the same relative path.
// Recursive copy shells out to `cp -R` until fs.sx grows `list_dir`.
asset_count := opts.asset_dir_count();
j : s64 = 0;
j : i64 = 0;
while j < asset_count {
src := opts.asset_dir_src_at(j);
dest := opts.asset_dir_dest_at(j);
@@ -156,7 +156,7 @@ bundle_main :: () -> bool {
out("error: bundle: cannot create Frameworks dir\n");
return false;
}
i : s64 = 0;
i : i64 = 0;
while i < fw_count {
fw_name := opts.framework_at(i);
if !embed_framework(opts, fw_name, fw_dir) {
@@ -369,7 +369,7 @@ copy_asset_dir :: (src: string, dest: string, bundle: string) -> bool {
embed_framework :: (opts: BuildOptions, name: string, dest_dir: string) -> bool {
subdir := concat(name, ".framework");
path_count := opts.framework_path_count();
i : s64 = 0;
i : i64 = 0;
while i < path_count {
base := opts.framework_path_at(i);
candidate := concat(base, "/");
@@ -701,7 +701,7 @@ android_bundle_main :: (opts: BuildOptions, binary: string, apk_path: string, bu
// path used a hardcoded `assets/` walk; the sx form respects every
// `add_asset_dir(src, dest)` pair the user registered.
asset_count := opts.asset_dir_count();
j : s64 = 0;
j : i64 = 0;
while j < asset_count {
src := opts.asset_dir_src_at(j);
dest := opts.asset_dir_dest_at(j);
@@ -988,7 +988,7 @@ compile_jni_main_sources :: (opts: BuildOptions, stage: string, android_jar: str
javac_files := "";
d8_files := "";
count := opts.jni_main_count();
i : s64 = 0;
i : i64 = 0;
while i < count {
foreign := opts.jni_main_foreign_path_at(i);
java_source := opts.jni_main_java_source_at(i);

View File

@@ -11,7 +11,7 @@
g_sdl_plat : *SdlPlatform = null;
chdir :: (path: [*]u8) -> s32 #foreign;
chdir :: (path: [*]u8) -> i32 #foreign;
SDL_GetBasePath :: () -> [*]u8 #foreign;
// A macOS `.app` launched via Finder / `open` starts with CWD=`/`, so a
@@ -26,7 +26,7 @@ sdl_chdir_to_bundle :: () {
bp := SDL_GetBasePath();
if bp == null { return; }
// Reorient only when the base path lives inside a `.app` bundle.
i : s64 = 0;
i : i64 = 0;
found := false;
while bp[i] != 0 {
if bp[i] == 46 and bp[i + 1] == 97 and bp[i + 2] == 112 and bp[i + 3] == 112 {
@@ -43,10 +43,10 @@ SdlPlatform :: struct {
gl_ctx: *void = null;
running: bool = true;
width: s32 = 0;
height: s32 = 0;
pixel_w: s32 = 0;
pixel_h: s32 = 0;
width: i32 = 0;
height: i32 = 0;
pixel_w: i32 = 0;
pixel_h: i32 = 0;
dpi_scale: f32 = 1.0;
delta_time: f32 = 0.008;
@@ -59,7 +59,7 @@ SdlPlatform :: struct {
}
impl Platform for SdlPlatform {
init :: (self: *SdlPlatform, title: [:0]u8, w: s32, h: s32) -> bool {
init :: (self: *SdlPlatform, title: [:0]u8, w: i32, h: i32) -> bool {
self.running = true;
self.has_frame_closure = false;
self.delta_time = 0.008;
@@ -178,8 +178,8 @@ impl Platform for SdlPlatform {
self.last_perf = current;
inline if OS == .wasm {
new_w : s32 = 0;
new_h : s32 = 0;
new_w : i32 = 0;
new_h : i32 = 0;
SDL_GetWindowSize(self.window, @new_w, @new_h);
if new_w != self.width or new_h != self.height {
self.width = new_w;

View File

@@ -5,8 +5,8 @@
FrameContext :: struct {
viewport_w: f32;
viewport_h: f32;
pixel_w: s32;
pixel_h: s32;
pixel_w: i32;
pixel_h: i32;
dpi_scale: f32;
delta_time: f32;
// The host clock time at which the next vsync will present the frame

View File

@@ -15,9 +15,9 @@
#import "modules/platform/types.sx";
#import "modules/platform/api.sx";
UIApplicationMain :: (argc: s32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> s32 #foreign;
UIApplicationMain :: (argc: i32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> i32 #foreign;
dlsym :: (handle: *void, name: [*]u8) -> *void #foreign;
chdir :: (path: [*]u8) -> s32 #foreign;
chdir :: (path: [*]u8) -> i32 #foreign;
// QuartzCore's wall-clock helper used by CoreAnimation. Seconds since boot,
// monotonic. We use it as the timebase for keyboard-inset lockstep so the
@@ -67,7 +67,7 @@ NSValue :: #foreign #objc_class("NSValue") {
NSNumber :: #foreign #objc_class("NSNumber") {
#extends NSObject;
// Class method (no `self: *Self` first param → static dispatch).
numberWithBool :: (b: s8) -> *NSNumber;
numberWithBool :: (b: i8) -> *NSNumber;
// Instance value extractors.
doubleValue :: (self: *Self) -> f64;
unsignedLongValue :: (self: *Self) -> u64;
@@ -128,7 +128,7 @@ CADisplayLink :: #foreign #objc_class("CADisplayLink") {
CALayer :: #foreign #objc_class("CALayer") {
#extends NSObject;
setOpaque :: (self: *Self, opaque: s8);
setOpaque :: (self: *Self, opaque: i8);
}
CAEAGLLayer :: #foreign #objc_class("CAEAGLLayer") {
@@ -145,10 +145,10 @@ CAMetalLayer :: #foreign #objc_class("CAMetalLayer") {
EAGLContext :: #foreign #objc_class("EAGLContext") {
#extends NSObject;
alloc :: () -> *EAGLContext;
initWithAPI :: (self: *Self, api: s32) -> *EAGLContext;
initWithAPI :: (self: *Self, api: i32) -> *EAGLContext;
setCurrentContext :: (ctx: *EAGLContext);
renderbufferStorage_fromDrawable :: (self: *Self, target: u32, drawable: *void) -> s8;
presentRenderbuffer :: (self: *Self, target: u32) -> s8;
renderbufferStorage_fromDrawable :: (self: *Self, target: u32, drawable: *void) -> i8;
presentRenderbuffer :: (self: *Self, target: u32) -> i8;
}
// ── UIKit chrome (Phase 3.2 C4) ────────────────────────────────────────
@@ -166,8 +166,8 @@ UIScreen :: #foreign #objc_class("UIScreen") {
// extend it so the runtime picks up the responder-chain behavior.
UIResponder :: #foreign #objc_class("UIResponder") {
#extends NSObject;
becomeFirstResponder :: (self: *Self) -> s8;
resignFirstResponder :: (self: *Self) -> s8;
becomeFirstResponder :: (self: *Self) -> i8;
resignFirstResponder :: (self: *Self) -> i8;
}
UIView :: #foreign #objc_class("UIView") {
@@ -292,8 +292,8 @@ UIKitPlatform :: struct {
viewport_w: f32 = 0.0;
viewport_h: f32 = 0.0;
pixel_w: s32 = 0;
pixel_h: s32 = 0;
pixel_w: i32 = 0;
pixel_h: i32 = 0;
dpi_scale: f32 = 1.0;
delta_time: f32 = 0.016;
@@ -334,7 +334,7 @@ UIKitPlatform :: struct {
}
impl Platform for UIKitPlatform {
init :: (self: *UIKitPlatform, title: [:0]u8, w: s32, h: s32) -> bool {
init :: (self: *UIKitPlatform, title: [:0]u8, w: i32, h: i32) -> bool {
self.dpi_scale = 1.0;
self.delta_time = 0.016;
self.has_frame_closure = false;
@@ -501,8 +501,8 @@ impl Platform for UIKitPlatform {
glBindFramebuffer(GL_FRAMEBUFFER, self.framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, self.color_renderbuffer);
pw : s32 = 0;
ph : s32 = 0;
pw : i32 = 0;
ph : i32 = 0;
GL_RENDERBUFFER_WIDTH :u32: 0x8D42;
GL_RENDERBUFFER_HEIGHT :u32: 0x8D43;
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, @pw);