@@ -25,7 +25,7 @@ public struct ABINameGenerator {
2525 let contextPart : String ?
2626 if let staticContext = staticContext {
2727 switch staticContext {
28- case . className ( let name ) , . enumName ( let name ) :
28+ case . className ( let name ) , . enumName ( let name ) , . structName ( let name ) :
2929 contextPart = name
3030 case . namespaceEnum :
3131 contextPart = namespacePart
@@ -115,6 +115,7 @@ public enum BridgeType: Codable, Equatable, Hashable, Sendable {
115115 case associatedValueEnum ( String )
116116 case namespaceEnum ( String )
117117 case swiftProtocol ( String )
118+ case swiftStruct ( String )
118119 indirect case closure ( ClosureSignature )
119120}
120121
@@ -205,10 +206,51 @@ public struct Effects: Codable, Equatable, Sendable {
205206
206207public enum StaticContext : Codable , Equatable , Sendable {
207208 case className ( String )
209+ case structName ( String )
208210 case enumName ( String )
209211 case namespaceEnum
210212}
211213
214+ // MARK: - Struct Skeleton
215+
216+ public struct StructField : Codable , Equatable , Sendable {
217+ public let name : String
218+ public let type : BridgeType
219+
220+ public init ( name : String , type : BridgeType ) {
221+ self . name = name
222+ self . type = type
223+ }
224+ }
225+
226+ public struct ExportedStruct : Codable , Equatable , Sendable {
227+ public let name : String
228+ public let swiftCallName : String
229+ public let explicitAccessControl : String ?
230+ public var properties : [ ExportedProperty ]
231+ public var constructor : ExportedConstructor ?
232+ public var methods : [ ExportedFunction ]
233+ public let namespace : [ String ] ?
234+
235+ public init (
236+ name : String ,
237+ swiftCallName : String ,
238+ explicitAccessControl : String ? ,
239+ properties : [ ExportedProperty ] = [ ] ,
240+ constructor : ExportedConstructor ? = nil ,
241+ methods : [ ExportedFunction ] = [ ] ,
242+ namespace : [ String ] ?
243+ ) {
244+ self . name = name
245+ self . swiftCallName = swiftCallName
246+ self . explicitAccessControl = explicitAccessControl
247+ self . properties = properties
248+ self . constructor = constructor
249+ self . methods = methods
250+ self . namespace = namespace
251+ }
252+ }
253+
212254// MARK: - Enum Skeleton
213255
214256public struct AssociatedValue : Codable , Equatable , Sendable {
@@ -416,7 +458,7 @@ public struct ExportedClass: Codable {
416458 }
417459}
418460
419- public struct ExportedConstructor : Codable {
461+ public struct ExportedConstructor : Codable , Equatable , Sendable {
420462 public var abiName : String
421463 public var parameters : [ Parameter ]
422464 public var effects : Effects
@@ -457,7 +499,7 @@ public struct ExportedProperty: Codable, Equatable, Sendable {
457499 public func callName ( prefix : String ? = nil ) -> String {
458500 if let staticContext = staticContext {
459501 switch staticContext {
460- case . className ( let baseName ) , . enumName ( let baseName ) :
502+ case . className ( let baseName ) , . enumName ( let baseName ) , . structName ( let baseName ) :
461503 return " \( baseName ) . \( name ) "
462504 case . namespaceEnum :
463505 if let namespace = namespace , ! namespace . isEmpty {
@@ -498,6 +540,7 @@ public struct ExportedSkeleton: Codable {
498540 public let functions : [ ExportedFunction ]
499541 public let classes : [ ExportedClass ]
500542 public let enums : [ ExportedEnum ]
543+ public let structs : [ ExportedStruct ]
501544 public let protocols : [ ExportedProtocol ]
502545 /// Whether to expose exported APIs to the global namespace.
503546 ///
@@ -511,13 +554,15 @@ public struct ExportedSkeleton: Codable {
511554 functions : [ ExportedFunction ] ,
512555 classes : [ ExportedClass ] ,
513556 enums : [ ExportedEnum ] ,
557+ structs : [ ExportedStruct ] = [ ] ,
514558 protocols : [ ExportedProtocol ] = [ ] ,
515559 exposeToGlobal : Bool
516560 ) {
517561 self . moduleName = moduleName
518562 self . functions = functions
519563 self . classes = classes
520564 self . enums = enums
565+ self . structs = structs
521566 self . protocols = protocols
522567 self . exposeToGlobal = exposeToGlobal
523568 }
@@ -624,6 +669,9 @@ extension BridgeType {
624669 case . swiftProtocol :
625670 // Protocols pass JSObject IDs as Int32
626671 return . i32
672+ case . swiftStruct :
673+ // Structs use stack-based return (no direct WASM return type)
674+ return nil
627675 case . closure :
628676 // Closures pass callback ID as Int32
629677 return . i32
@@ -660,6 +708,8 @@ extension BridgeType {
660708 return " \( name . count ) \( name ) O "
661709 case . swiftProtocol ( let name ) :
662710 return " \( name . count ) \( name ) P "
711+ case . swiftStruct ( let name ) :
712+ return " \( name . count ) \( name ) V "
663713 case . closure ( let signature ) :
664714 let params =
665715 signature . parameters . isEmpty
0 commit comments