pub struct SwiftFirstClassMap {
pub first_class_types: HashSet<String>,
pub field_types: HashMap<String, HashMap<String, String>>,
pub vec_field_names: HashSet<String>,
pub root_type: Option<String>,
}Expand description
Swift first-class struct classification + chain-resolution metadata.
alef-backend-swift emits two flavors of binding types:
- First-class Codable structs —
public struct Foo: Codable { public let id: String }. Fields are Swift properties; access with.id(no parens). - Opaque typealiases —
public typealias Foo = RustBridge.Foowhere the RustBridge class exposes swift-bridge methods. Fields are methods; access with.id()(parens).
The renderer needs per-segment dispatch because a path can traverse both:
e.g. BatchListResponse (first-class Codable, with data: [BatchObject]) →
indexed [0] → BatchObject (opaque typealias). At the BatchObject cursor
the renderer must switch to method-call access for .id, .status, etc.
first_class_types— set of TypeDef names whose binding is a first-class Codable struct. Membership = “use property access for fields on this type”.field_types[type_name][field_name]— the IR-resolvedNamedtype thatfield_nametraverses into.vec_field_names— flat set of field names whose IR type isVec<T>on any owner. Used by swift_count_target to keep.countstraight on RustVec-typed method-call accessors (don’t inject.toString()).root_type— the IR type name backing the result variable.
Fields§
§first_class_types: HashSet<String>§field_types: HashMap<String, HashMap<String, String>>§vec_field_names: HashSet<String>§root_type: Option<String>Implementations§
Source§impl SwiftFirstClassMap
impl SwiftFirstClassMap
Sourcepub fn is_first_class(&self, type_name: Option<&str>) -> bool
pub fn is_first_class(&self, type_name: Option<&str>) -> bool
Returns true when fields on type_name should be accessed as properties
(no parens), false when they should be accessed via method-call.
When type_name is None the renderer defaults to property syntax
(matching the common case where result types are first-class).
Sourcepub fn advance(
&self,
owner_type: Option<&str>,
field_name: &str,
) -> Option<String>
pub fn advance( &self, owner_type: Option<&str>, field_name: &str, ) -> Option<String>
Returns the IR Named type that field_name traverses into for the
next chain segment, or None if the field is terminal/scalar/unknown.
Sourcepub fn is_vec_field_name(&self, field_name: &str) -> bool
pub fn is_vec_field_name(&self, field_name: &str) -> bool
True when field_name appears as a Vec<T> (or Option<Vec<T>>) on
any IR type. swift codegen consults this when deciding whether .count
on a method-call accessor needs .toString() injected: RustVec already
supports .count directly; RustString does not.
Trait Implementations§
Source§impl Clone for SwiftFirstClassMap
impl Clone for SwiftFirstClassMap
Source§fn clone(&self) -> SwiftFirstClassMap
fn clone(&self) -> SwiftFirstClassMap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more