Commit Graph

99 Commits

Author SHA1 Message Date
agra
32da32ca66 platform: SDL3 backend (desktop + WASM) + two bug repros
- library/modules/platform/sdl3.sx: SdlPlatform impl wrapping SDL3 init,
  GL context, event pump, swap. run_frame_loop owns the loop: while loop
  on desktop, emscripten_set_main_loop on WASM. Registers an event-watch
  that re-invokes the frame closure during macOS modal resize-drag so
  content keeps rendering at the new size. safe_insets / keyboard /
  show_keyboard / hide_keyboard are no-ops (these targets have no soft
  keyboard).

Two compiler bug repros uncovered during the refactor:

- examples/issue-0020.sx: global `Foo = .{}` zero-initializes, ignoring
  struct field defaults. Local `Foo = .{}` correctly applies defaults.
  Workaround: set fields explicitly in an init method or heap-allocate
  the value.

- examples/issue-0021.sx: an enclosing function's return type bleeds
  into `xx`'s target type inside an `if-then-else` expression on the
  RHS of a struct-field assignment. The same expression in a `-> void`
  function produces the right value; in a `-> bool` function it
  silently produces 0. Bit the SX Chess game's dpi_scale calc inside
  `SdlPlatform.init` (returns bool), making all text labels render
  invisibly on retina. Workaround: hoist each `xx` cast into its own
  f32 local.

Regression gate: 50/50 examples pass, macOS chess game runs at ~2700fps
(close to the pre-refactor 2900 baseline), WASM build still emits a
working .html/.js/.wasm/.data quad.
2026-05-17 15:26:35 +03:00
agra
327c8af9b7 platform: protocol skeleton (types + api, no backend yet)
First commit of the Phase 8 platform abstraction (see current/PLATFORM_PLAN.md):

- `library/modules/platform/types.sx` — `FrameContext` (viewport_w/h,
  pixel_w/h, dpi_scale, delta_time) and `KeyboardState` (visible, height
  + `zero()`). `EdgeInsets`/`Point`/`Size` and `Event` are reused from
  `modules/ui/types.sx` / `modules/ui/events.sx`.
- `library/modules/platform/api.sx` — `Platform :: protocol { init,
  run_frame_loop, poll_events, begin_frame, end_frame, safe_insets,
  keyboard, show_keyboard, hide_keyboard, shutdown }`. Protocol bodies
  omit `self` (matches the `View`/`Allocator` convention).
- `run_frame_loop` takes `Closure()` so backends own the run loop:
  SDL drives a `while !quit`, UIKit hands it to a `CADisplayLink` tick,
  Emscripten hands it to `emscripten_set_main_loop`.

No backend yet. Regression suite still 50/50; game build still green.
2026-05-17 14:39:08 +03:00
agra
e8bd40f710 ios: framework embedding in .app + -F search paths
- `-F <dir>` CLI flag adds Apple framework search paths (parallel to `-L`).
- `TargetConfig.framework_paths` flows into the iOS link line (`-F<dir>`).
- iOS link adds `-Wl,-rpath,@executable_path/Frameworks` so embedded
  frameworks resolve at runtime.
- `createBundle` now takes the framework list; for each one it locates
  `<name>.framework` in the `-F` paths and `cp -R`s it into
  `<bundle>.app/Frameworks/`.
- `c_import.compileCToObjects` forwards `-target`/`-isysroot` to clang so
  `#c_import` works under cross-compile (was using host clang implicitly).
- iOS SDK is auto-discovered once at startup and shared by both the C
  compile and the link paths.
- `SX_DEBUG_LINK=1` prints the resolved link argv.
- `library/modules/sdl3.sx`: drop `#library "SDL3"` — linking is now
  per-target (build.sx handles `-lSDL3` on macOS, `-framework SDL3` on iOS).
2026-05-17 14:38:58 +03:00
agra
dc8529e3ea ui: port game UI framework into library/modules/ui
20 files (~3,830 lines): view protocol, layout, renderer, glyph cache,
fonts, gestures, animation, scroll, stacks, modifiers, etc.

Internal imports rewritten from "ui/..." to "modules/ui/...".
Consumers now `#import "modules/ui"` from any project; no symlink
hacks needed. Verified by compiling game/main.sx without its local
ui/ — resolves via the Phase 6 stdlib fallback.
2026-05-17 13:54:11 +03:00
agra
c027e1969b stdlib: relocate modules under library/
- examples/modules/ -> library/modules/ (top-level, no more
  symlink hacks in consumer projects)
- compiler discovers stdlib via _NSGetExecutablePath / readlink
  /proc/self/exe; searches dev layout (../../library), install
  layout (../library), and alongside-binary fallback
- SX_STDLIB_PATH env var overrides for tests / dev convenience
- SX_DEBUG_STDLIB env var dumps the discovery results
- build.zig installs library/ alongside the binary
- Compilation gains stdlib_paths field threaded through resolveImports
- 50 tests pass; consumer projects can now build from any cwd
2026-05-17 13:49:25 +03:00
agra
535e7b9c24 zig 0.16.0 stable
std.time.Instant -> std.Io.Timestamp (Timing helper gets an io handle).
.monotonic clock variant -> .awake.
50 tests pass.
2026-05-17 13:26:07 +03:00
agra
1c32d54e01 ios + ir cleanup
- ios: --target ios/ios-sim shorthands, iOS SDK auto-discovery,
  #framework directive + BuildOptions.add_framework hook,
  .app bundle + Info.plist + codesign (ad-hoc and real),
  --codesign-identity/--provisioning-profile/--entitlements flags,
  modules/std/{objc,uikit}.sx, dynamic class registration,
  typed objc_msgSend cast pattern, UIApplicationMain handoff,
  UIWindow scene attach. Runs on iPhone hardware.
- ir: silent .s64 defaults → loud diagnostics,
  resolveReturnType infers from body, sub-byte int sizes match LLVM,
  tuple type interning includes names, compile errors exit 1
- issue-NNNN convention: resolved bugs rename to focused features
- 50 regression tests passing
2026-05-17 13:19:08 +03:00
agra
69934592d8 c import 2026-03-06 10:46:28 +02:00
agra
f9dda972d2 fixes 2026-03-05 16:20:36 +02:00
agra
22bc2439ce fixes 2026-03-04 17:12:56 +02:00
agra
67e02a20a5 ... 2026-03-04 09:18:24 +02:00
agra
0336f361c7 issue 06 2026-03-03 16:18:58 +02:00
agra
23f444033a ... 2026-03-03 13:25:00 +02:00
agra
004aff5f67 wasm shell + destructuring 2026-03-03 13:21:54 +02:00
agra
6c5672c7df trailing commas 2026-03-03 09:42:01 +02:00
agra
03074472e5 build options #compiler 2026-03-03 09:35:50 +02:00
agra
aa1235c621 ... 2026-03-02 21:08:09 +02:00
agra
bbb5426777 sm 2026-03-02 21:00:55 +02:00
agra
2f4f898d54 asm... 2026-03-02 17:19:41 +02:00
agra
ba9c4d69ce wasm 2026-03-02 09:49:43 +02:00
agra
f763765ea2 ir done'ish 2026-03-01 22:38:41 +02:00
agra
6a920dbd2c ir 2026-02-28 18:03:38 +02:00
agra
2552882ce6 05 2026-02-26 14:46:21 +02:00
agra
dd14f1206b ir 2026-02-26 02:25:02 +02:00
agra
7209e8e69d ... 2026-02-26 00:18:36 +02:00
agra
f0569a8a3e dot-shorthand and more 2026-02-25 15:51:22 +02:00
agra
4abc7abb54 auto type erasure for protocols & struct literal init bloc 2026-02-25 12:25:06 +02:00
agra
bfc784734c lsp import 2026-02-24 20:05:24 +02:00
agra
06d10541da protocols 2026-02-24 19:46:17 +02:00
agra
9dba8eef5b xxx 2026-02-24 19:31:10 +02:00
agra
7a381e1b4c .... 2026-02-24 18:17:33 +02:00
agra
630e76c319 chained dereference 2026-02-24 17:42:13 +02:00
agra
566121c45a more forward declarations 2026-02-24 17:37:52 +02:00
agra
97475d6cfe forward declaration 2026-02-24 15:10:02 +02:00
agra
b98711a1d3 imports 2026-02-24 13:37:27 +02:00
agra
170e236764 vtables, protocol 2026-02-24 06:20:38 +02:00
agra
0cc7b69441 closures 2026-02-23 13:45:44 +02:00
agra
1cc67f9b5a optionals 2026-02-22 22:16:30 +02:00
agra
d3e574eae5 import c 2026-02-22 17:24:04 +02:00
agra
775dcb44cc ... 2026-02-22 13:17:38 +02:00
agra
b02fe37a87 ... 2026-02-21 02:25:21 +02:00
agra
ff2b2a69ab ... 2026-02-21 00:49:37 +02:00
agra
be99b26c1d ... 2026-02-20 23:18:17 +02:00
agra
efa60fa670 ... 2026-02-20 21:50:49 +02:00
agra
2f95810f9d ... 2026-02-20 18:22:42 +02:00
agra
6f927361aa pipes 2026-02-20 13:28:38 +02:00
agra
5956303366 dir import 2026-02-20 12:27:06 +02:00
agra
1ecac79642 bit ops 2026-02-20 12:12:51 +02:00
agra
e0e655cd36 tuples 2026-02-19 01:26:04 +02:00
agra
fbf8a62362 comptime format 2026-02-18 18:57:51 +02:00