The four foreign-class declarations move into a new sub-module
`library/modules/platform/android_jni.sx`, imported under a named
namespace from `android.sx`:
Jni :: #import "modules/platform/android_jni.sx";
This keeps the bare class names (`Activity`, `Window`, `View`,
`WindowInsets`) out of the top level — consumers that flat-import
`modules/platform/android.sx` no longer see `View` collide with
`modules/ui/view.sx`'s protocol of the same name (chess hit this
on the first build attempt).
Compiler-side change: `scanDecls`/`lowerDecls` now also iterate any
`namespace_decl` they encounter and register the contained
`foreign_class_decl`s under their qualified name (`Jni.Activity`).
The recursive scan continues to register the bare names too, so
cross-class refs inside method signatures (e.g. `getWindow ::
(self: *Self) -> *Window`) still resolve through the bare key.
Receiver types like `*Jni.Activity` now route through
`getStructTypeName` → "Jni.Activity" → `foreign_class_map` lookup.
`sx_query_safe_insets_jni`'s param signature changes from
`activity: *Activity` to `activity: *Jni.Activity`; the caller in
`AndroidPlatform.safe_insets` casts via `xx`.
Verified on-device — chess APK built with the new sx, installed via
`adb install -r`, launched on the Pixel. Screencap shows the board
rendering with correct status-bar clearance (time + battery icons
visible above the board, board sized below them) — safe insets are
being queried via the new declarative dispatch and produce the same
values as the pre-migration hand-rolled #jni_call chain.
129/129 examples + cross_compile 3/3 + on-device chess all green.
32 lines
1.3 KiB
Plaintext
32 lines
1.3 KiB
Plaintext
// Declarative JNI class bindings used by the Android platform module's
|
|
// safe-insets dispatch chain. Imported under a named namespace from
|
|
// `modules/platform/android.sx` so the bare class names (`Activity`,
|
|
// `Window`, `View`, `WindowInsets`) don't pollute the top-level
|
|
// namespace when consumers flat-import the platform module — `View`
|
|
// in particular collides with `modules/ui/view.sx`'s protocol.
|
|
//
|
|
// Inside the platform module these are referenced as `Jni.Activity`,
|
|
// `Jni.Window`, etc. The compiler registers the decls both qualified
|
|
// and bare in `foreign_class_map`, so cross-class refs in method
|
|
// signatures (`getWindow :: (self: *Self) -> *Window`) still resolve
|
|
// against the bare name within the namespace.
|
|
|
|
WindowInsets :: #jni_class("android/view/WindowInsets") {
|
|
getSystemWindowInsetTop :: (self: *Self) -> s32;
|
|
getSystemWindowInsetLeft :: (self: *Self) -> s32;
|
|
getSystemWindowInsetBottom :: (self: *Self) -> s32;
|
|
getSystemWindowInsetRight :: (self: *Self) -> s32;
|
|
}
|
|
|
|
View :: #jni_class("android/view/View") {
|
|
getRootWindowInsets :: (self: *Self) -> *WindowInsets;
|
|
}
|
|
|
|
Window :: #jni_class("android/view/Window") {
|
|
getDecorView :: (self: *Self) -> *View;
|
|
}
|
|
|
|
Activity :: #jni_class("android/app/Activity") {
|
|
getWindow :: (self: *Self) -> *Window;
|
|
}
|