ffi #jni_main: emit implements clauses from #implements Alias; members

`jni_java_emit` previously dropped `#implements` members on the floor.
They now compose into the Java class header — first one prefixed with
` implements `, subsequent ones comma-separated. Aliases resolve
through the class registry just like `#extends`: an unmapped alias
passes through verbatim (handy for built-in JVM interfaces like
`java.lang.Runnable` without declaring a `#jni_class` for them).

First building block of the chess-on-Pixel migration: the new Activity
needs `implements android.view.SurfaceHolder$Callback` to receive
surfaceCreated / surfaceChanged / surfaceDestroyed callbacks from the
SurfaceView it hosts.

Unit test locks in both the registry-resolved and pass-through paths.
131 host / zig build test green.
This commit is contained in:
agra
2026-05-20 15:38:05 +03:00
parent 619d524bac
commit bce5448fe9
2 changed files with 62 additions and 0 deletions

View File

@@ -90,6 +90,27 @@ pub fn emitJavaSource(
try buf.appendSlice(allocator, parts.cls);
try buf.appendSlice(allocator, " extends ");
try buf.appendSlice(allocator, parent);
// `#implements Alias;` body items become Java `implements` clauses on the
// class header. Aliases resolve through the class registry the same way
// `#extends` does — an unmapped alias passes through verbatim (useful for
// referring to built-in JVM interfaces without declaring them).
var first_iface = true;
for (fcd.members) |m| switch (m) {
.implements => |alias| {
try buf.appendSlice(allocator, if (first_iface) " implements " else ", ");
first_iface = false;
if (opts.classes) |reg| {
if (reg.get(alias)) |path| {
try appendDotted(allocator, &buf, path);
continue;
}
}
try buf.appendSlice(allocator, alias);
},
else => {},
};
try buf.appendSlice(allocator, " {\n");
// Two passes: @Override stubs that call super + native delegate,