refactor(ffi-linkage): Phase 9.2a — rename runtime-class TYPE names → Runtime* (Decision 5)
Mechanical, collision-free PascalCase renames (object-model axis, not linkage): ForeignClassDecl→RuntimeClassDecl, ForeignMethodDecl→RuntimeMethodDecl, ForeignClassMember→RuntimeClassMember, ForeignFieldDecl→RuntimeFieldDecl, ForeignRuntime→RuntimeKind, ForeignClassPrefix→RuntimeClassPrefix. Snapshot-neutral; suite green (646/444). Remaining 9.2: snake_case state (foreign_class_map, current_foreign_class, foreign_path [coupled to .sx hooks], the foreign_class_decl union variant) + the parse/lower/resolve fn names + ForeignClassDecl.is_foreign flag.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Tests for jni_java_emit.zig — #jni_main pipeline slice 1.
|
||||
// Locks in the Java source emitted from `ForeignClassDecl` AST nodes:
|
||||
// Locks in the Java source emitted from `RuntimeClassDecl` AST nodes:
|
||||
// package split, class header, @Override delegate pattern, primitive
|
||||
// type mapping, cross-class refs through the foreign_class registry.
|
||||
|
||||
@@ -40,7 +40,7 @@ fn makeBodyMarker(allocator: std.mem.Allocator) !*Node {
|
||||
|
||||
test "rejects non-main decl" {
|
||||
const a = std.testing.allocator;
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Foo",
|
||||
.foreign_path = "co/example/Foo",
|
||||
.runtime = .jni_class,
|
||||
@@ -64,14 +64,14 @@ test "void onCreate(Bundle) with default Activity superclass" {
|
||||
defer registry.deinit();
|
||||
try registry.put("Bundle", "android/os/Bundle");
|
||||
|
||||
const member: ast.ForeignClassMember = .{ .method = .{
|
||||
const member: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{ self_ty, bundle_ty },
|
||||
.param_names = &.{ "self", "b" },
|
||||
.return_type = null,
|
||||
.body = body,
|
||||
} };
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/swipelab/sx_runtime/SxNativeActivity",
|
||||
.runtime = .jni_class,
|
||||
@@ -107,14 +107,14 @@ test "primitive params" {
|
||||
const bool_ty = try makeTypeExpr(aa, "bool");
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
const member: ast.ForeignClassMember = .{ .method = .{
|
||||
const member: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onWindowFocusChanged",
|
||||
.params = &.{ self_ty, bool_ty },
|
||||
.param_names = &.{ "self", "hasFocus" },
|
||||
.return_type = null,
|
||||
.body = body,
|
||||
} };
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/sample/Sx",
|
||||
.runtime = .jni_class,
|
||||
@@ -140,14 +140,14 @@ test "declaration-only methods are skipped" {
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
// One bodied (override), one declaration-only (calls inherited).
|
||||
const bodied: ast.ForeignClassMember = .{ .method = .{
|
||||
const bodied: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
.return_type = null,
|
||||
.body = body,
|
||||
} };
|
||||
const decl_only: ast.ForeignClassMember = .{ .method = .{
|
||||
const decl_only: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "finish",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
@@ -155,7 +155,7 @@ test "declaration-only methods are skipped" {
|
||||
.body = null, // sx-side just *calls* this; Java's NativeActivity.finish() provides it
|
||||
} };
|
||||
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/example/Sx",
|
||||
.runtime = .jni_class,
|
||||
@@ -179,8 +179,8 @@ test "#extends Alias resolves through class registry" {
|
||||
const self_ty = try makePointer(aa, try makeTypeExpr(aa, "Self"));
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
const extends_member: ast.ForeignClassMember = .{ .extends = "MyParent" };
|
||||
const method_member: ast.ForeignClassMember = .{ .method = .{
|
||||
const extends_member: ast.RuntimeClassMember = .{ .extends = "MyParent" };
|
||||
const method_member: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
@@ -192,7 +192,7 @@ test "#extends Alias resolves through class registry" {
|
||||
defer registry.deinit();
|
||||
try registry.put("MyParent", "co/example/MyParentActivity");
|
||||
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/example/Sx",
|
||||
.runtime = .jni_class,
|
||||
@@ -213,14 +213,14 @@ test "default-package class (no slash in foreign_path)" {
|
||||
const self_ty = try makePointer(aa, try makeTypeExpr(aa, "Self"));
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
const member: ast.ForeignClassMember = .{ .method = .{
|
||||
const member: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
.return_type = null,
|
||||
.body = body,
|
||||
} };
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "SxNoPackage",
|
||||
.runtime = .jni_class,
|
||||
@@ -243,7 +243,7 @@ test "lib_name renders System.loadLibrary static init block" {
|
||||
|
||||
const self_ty = try makePointer(aa, try makeTypeExpr(aa, "Self"));
|
||||
const body = try makeBodyMarker(aa);
|
||||
const method: ast.ForeignClassMember = .{ .method = .{
|
||||
const method: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
@@ -251,7 +251,7 @@ test "lib_name renders System.loadLibrary static init block" {
|
||||
.body = body,
|
||||
} };
|
||||
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
@@ -280,9 +280,9 @@ test "field declarations render as private Java fields" {
|
||||
const self_ty = try makePointer(aa, try makeTypeExpr(aa, "Self"));
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
const view_field: ast.ForeignClassMember = .{ .field = .{ .name = "view", .field_type = surface_view_ty } };
|
||||
const w_field: ast.ForeignClassMember = .{ .field = .{ .name = "viewport_w", .field_type = int_ty } };
|
||||
const method: ast.ForeignClassMember = .{ .method = .{
|
||||
const view_field: ast.RuntimeClassMember = .{ .field = .{ .name = "view", .field_type = surface_view_ty } };
|
||||
const w_field: ast.RuntimeClassMember = .{ .field = .{ .name = "viewport_w", .field_type = int_ty } };
|
||||
const method: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
@@ -294,7 +294,7 @@ test "field declarations render as private Java fields" {
|
||||
defer registry.deinit();
|
||||
try registry.put("SurfaceView", "android/view/SurfaceView");
|
||||
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
@@ -318,9 +318,9 @@ test "#implements clauses on the class header" {
|
||||
const body = try makeBodyMarker(aa);
|
||||
|
||||
// Two interfaces: one resolvable via the registry, one passed through verbatim.
|
||||
const impl_a: ast.ForeignClassMember = .{ .implements = "Callback" };
|
||||
const impl_b: ast.ForeignClassMember = .{ .implements = "java.lang.Runnable" };
|
||||
const method: ast.ForeignClassMember = .{ .method = .{
|
||||
const impl_a: ast.RuntimeClassMember = .{ .implements = "Callback" };
|
||||
const impl_b: ast.RuntimeClassMember = .{ .implements = "java.lang.Runnable" };
|
||||
const method: ast.RuntimeClassMember = .{ .method = .{
|
||||
.name = "onCreate",
|
||||
.params = &.{self_ty},
|
||||
.param_names = &.{"self"},
|
||||
@@ -332,7 +332,7 @@ test "#implements clauses on the class header" {
|
||||
defer registry.deinit();
|
||||
try registry.put("Callback", "android/view/SurfaceHolder$Callback");
|
||||
|
||||
const fcd: ast.ForeignClassDecl = .{
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
|
||||
Reference in New Issue
Block a user