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:
@@ -380,11 +380,11 @@ test "lower: objcDefinedStateStructType collects user-declared fields" {
|
||||
defer alloc.destroy(ticks_type);
|
||||
ticks_type.* = .{ .span = span, .data = .{ .type_expr = .{ .name = "i64", .is_generic = false } } };
|
||||
|
||||
const members = [_]ast.ForeignClassMember{
|
||||
const members = [_]ast.RuntimeClassMember{
|
||||
.{ .field = .{ .name = "counter", .field_type = counter_type } },
|
||||
.{ .field = .{ .name = "ticks", .field_type = ticks_type } },
|
||||
};
|
||||
const fcd = ast.ForeignClassDecl{
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxFoo",
|
||||
.foreign_path = "SxFoo",
|
||||
.runtime = .objc_class,
|
||||
@@ -416,7 +416,7 @@ test "lower: objcDefinedStateStructType handles empty field set" {
|
||||
defer module.deinit();
|
||||
var lowering = Lowering.init(&module);
|
||||
|
||||
const fcd = ast.ForeignClassDecl{
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxEmpty",
|
||||
.foreign_path = "SxEmpty",
|
||||
.runtime = .objc_class,
|
||||
@@ -443,12 +443,12 @@ test "lower: objcDefinedStateStructType skips non-field members" {
|
||||
defer alloc.destroy(counter_type);
|
||||
counter_type.* = .{ .span = span, .data = .{ .type_expr = .{ .name = "i32", .is_generic = false } } };
|
||||
|
||||
const members = [_]ast.ForeignClassMember{
|
||||
const members = [_]ast.RuntimeClassMember{
|
||||
.{ .extends = "NSObject" },
|
||||
.{ .field = .{ .name = "counter", .field_type = counter_type } },
|
||||
.{ .implements = "UIApplicationDelegate" },
|
||||
};
|
||||
const fcd = ast.ForeignClassDecl{
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxMixed",
|
||||
.foreign_path = "SxMixed",
|
||||
.runtime = .objc_class,
|
||||
@@ -476,7 +476,7 @@ test "lower: objcTypeEncodingFromSignature emits @ for Obj-C class pointers" {
|
||||
const ns_name = module.types.internString("NSString");
|
||||
const ns_struct = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.ForeignClassDecl{
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
@@ -509,7 +509,7 @@ test "lower: objcTypeEncodingFromSignature unwraps optional to wire type" {
|
||||
const ns_name = module.types.internString("NSString");
|
||||
const ns_struct = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.ForeignClassDecl{
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
@@ -627,7 +627,7 @@ test "lower: objcTypeEncodingFromSignature emits nested structs (CGRect)" {
|
||||
// Lock selector derivation, property-kind classification, and Obj-C
|
||||
// class-pointer recognition before they move to `ffi_objc.zig`.
|
||||
|
||||
fn objcMethod(name: []const u8) ast.ForeignMethodDecl {
|
||||
fn objcMethod(name: []const u8) ast.RuntimeMethodDecl {
|
||||
return .{ .name = name, .params = &.{}, .param_names = &.{}, .return_type = null };
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
const ns_name = module.types.internString("NSString");
|
||||
const ns_struct = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.ForeignClassDecl{
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
@@ -694,7 +694,7 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
const proto_name = module.types.internString("NSCopying");
|
||||
const proto_struct = module.types.intern(.{ .@"struct" = .{ .name = proto_name, .fields = &.{} } });
|
||||
const proto_ptr = module.types.ptrTo(proto_struct);
|
||||
var proto_fcd = ast.ForeignClassDecl{
|
||||
var proto_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSCopying",
|
||||
.foreign_path = "NSCopying",
|
||||
.runtime = .objc_protocol,
|
||||
@@ -726,7 +726,7 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
// Register NSString so `*NSString` resolves to an object pointer.
|
||||
const ns_name = module.types.internString("NSString");
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
var ns_fcd = ast.ForeignClassDecl{
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
@@ -737,21 +737,21 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// Primitive field, no modifiers → assign (the non-object default).
|
||||
const prim = ast.ForeignFieldDecl{ .name = "count", .field_type = typeKeyword(alloc, "i32"), .is_property = true };
|
||||
const prim = ast.RuntimeFieldDecl{ .name = "count", .field_type = typeKeyword(alloc, "i32"), .is_property = true };
|
||||
defer alloc.destroy(prim.field_type);
|
||||
try std.testing.expect(lowering.objc().objcPropertyKind(prim) == .assign);
|
||||
|
||||
// Object-pointer field, no modifiers → strong (the object default).
|
||||
const obj_ty = typeKeyword(alloc, "*NSString");
|
||||
defer alloc.destroy(obj_ty);
|
||||
const obj_default = ast.ForeignFieldDecl{ .name = "title", .field_type = obj_ty, .is_property = true };
|
||||
const obj_default = ast.RuntimeFieldDecl{ .name = "title", .field_type = obj_ty, .is_property = true };
|
||||
try std.testing.expect(lowering.objc().objcPropertyKind(obj_default) == .strong);
|
||||
|
||||
// Protocol-pointer field → also strong by default (same object-pointer
|
||||
// predicate accepts .objc_protocol).
|
||||
const proto_name = module.types.internString("NSCoding");
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = proto_name, .fields = &.{} } });
|
||||
var proto_fcd = ast.ForeignClassDecl{
|
||||
var proto_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSCoding",
|
||||
.foreign_path = "NSCoding",
|
||||
.runtime = .objc_protocol,
|
||||
@@ -762,7 +762,7 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
try lowering.program_index.foreign_class_map.put("NSCoding", &proto_fcd);
|
||||
const proto_ty = typeKeyword(alloc, "*NSCoding");
|
||||
defer alloc.destroy(proto_ty);
|
||||
const proto_default = ast.ForeignFieldDecl{ .name = "coder", .field_type = proto_ty, .is_property = true };
|
||||
const proto_default = ast.RuntimeFieldDecl{ .name = "coder", .field_type = proto_ty, .is_property = true };
|
||||
try std.testing.expect(lowering.objc().objcPropertyKind(proto_default) == .strong);
|
||||
|
||||
// Explicit modifiers on an object pointer win over the default.
|
||||
|
||||
Reference in New Issue
Block a user