refactor(ffi-linkage): Phase 9.3-src — purge 'foreign' from src/ comments + a user-facing diagnostic

Reword every 'foreign' comment to the extern/runtime-class vocabulary matching the
renamed identifiers (foreign call→extern call, foreign class→runtime class, foreign
path→runtime path, the #foreign-literal comment mentions → extern, etc.). Also fixes
two USER-FACING issues: the 'expected … #foreign … after type annotation' parse error
no longer advertises the removed keyword, and the Android 'no #jni_main' help
diagnostic now shows '#jni_class(…) extern' instead of the rejected '#foreign
#jni_class'. Removed the now-dead prefix-#foreign-vs-postfix conflict branch in
parseRuntimeClassDecl (the caller rejects #foreign before it runs).

src/ now contains 'foreign' ONLY in the hash_foreign token machinery + its 4
rejection messages — the deprecation mechanism (kept per the 9.0 recommendation; the
message MUST name #foreign to guide migration). Snapshot-neutral; suite green
(646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 09:35:00 +03:00
parent e99383fcb4
commit dc51c4b5bf
35 changed files with 172 additions and 180 deletions

View File

@@ -16,8 +16,8 @@
// f64 → D (jdouble)
// []T → [<elem>
// [*]T → [<elem> (sx many-pointer treated as array for now)
// *Self → L<enclosing-foreign-path>;
// *Foo → L<Foo's foreign path>; (cross-class — step 2.9)
// *Self → L<enclosing-runtime-path>;
// *Foo → L<Foo's runtime path>; (cross-class — step 2.9)
//
// `#jni_method_descriptor("...")` (step 2.6) overrides this whole walk
// when set; sema/lowering use the override verbatim.
@@ -36,7 +36,7 @@ pub const DeriveError = error{
OutOfMemory,
};
/// Map from sx-side alias → foreign path of declared `#jni_class` /
/// Map from sx-side alias → runtime path of declared `#jni_class` /
/// `#jni_interface` decls. Used to resolve `*Foo` into `L<path>;` in
/// the descriptor. Built during lowering's scan pass.
pub const ClassRegistry = std.StringHashMap([]const u8);
@@ -81,7 +81,7 @@ pub fn writeType(
try writeType(allocator, buf, ctx, arr.element_type);
},
.pointer_type_expr => |ptr| {
// *Self → L<enclosing>;, *Foo → L<Foo's foreign path>;,
// *Self → L<enclosing>;, *Foo → L<Foo's runtime path>;,
// *void → Ljava/lang/Object; (opaque jobject — common when
// users don't have a precise Java type for the value).
const inner = ptr.pointee_type;