ffi #jni_main: emit name: Type; body members as private Java fields

`#jni_class` body items of the form `name: Type;` were parsed into
`ForeignFieldDecl` but dropped by jni_java_emit. They now render as
private Java fields between the static init block and the @Override
delegates, using the same primitive / `*Foo` → fully-qualified-name
type mapping as method parameters.

Needed for the chess-on-Pixel `SxApp` Activity to hold its
`SurfaceView` reference: `view: SurfaceView;` → `private
android.view.SurfaceView view;`.
This commit is contained in:
agra
2026-05-20 17:01:24 +03:00
parent d946e3d577
commit 36f40057f7
2 changed files with 53 additions and 0 deletions

View File

@@ -125,6 +125,20 @@ pub fn emitJavaSource(
try buf.appendSlice(allocator, "\"); }\n");
}
// Fields. `name: Type;` body items render as private Java fields —
// primitive types pass through, pointer types resolve to fully
// qualified Java class names via the class registry.
for (fcd.members) |m| switch (m) {
.field => |fd| {
try buf.appendSlice(allocator, " private ");
try emitJavaType(allocator, &buf, fd.field_type, opts);
try buf.append(allocator, ' ');
try buf.appendSlice(allocator, fd.name);
try buf.appendSlice(allocator, ";\n");
},
else => {},
};
// Two passes: @Override stubs + native delegate; then the native
// declarations.
for (fcd.members) |m| switch (m) {