@@ -273,9 +273,24 @@ public enum BridgeType: Codable, Equatable, Hashable, Sendable {
273273 case namespaceEnum( String )
274274 case swiftProtocol( String )
275275 case swiftStruct( String )
276+ case generic( String )
276277 indirect case closure( ClosureSignature , useJSTypedClosure: Bool )
277278}
278279
280+ extension BridgeType {
281+ public var referencedGenericName : String ? {
282+ switch self {
283+ case . generic( let name) : return name
284+ case . array( . generic( let name) ) : return name
285+ case . nullable( . generic( let name) , _) : return name
286+ case . dictionary( . generic( let name) ) : return name
287+ default : return nil
288+ }
289+ }
290+
291+ public var usesBareGeneric : Bool { referencedGenericName != nil }
292+ }
293+
279294public enum WasmCoreType : String , Codable , Sendable {
280295 case i32, i64, f32, f64, pointer
281296}
@@ -854,6 +869,8 @@ public struct ExportedFunction: Codable, Equatable, Sendable {
854869 public var effects : Effects
855870 public var namespace : [ String ] ?
856871 public var staticContext : StaticContext ?
872+ public var genericParameters : [ String ] ?
873+ public var genericParameterNames : [ String ] { genericParameters ?? [ ] }
857874
858875 public init (
859876 name: String ,
@@ -862,7 +879,8 @@ public struct ExportedFunction: Codable, Equatable, Sendable {
862879 returnType: BridgeType ,
863880 effects: Effects ,
864881 namespace: [ String ] ? = nil ,
865- staticContext: StaticContext ? = nil
882+ staticContext: StaticContext ? = nil ,
883+ genericParameters: [ String ] ? = nil
866884 ) {
867885 self . name = name
868886 self . abiName = abiName
@@ -871,6 +889,7 @@ public struct ExportedFunction: Codable, Equatable, Sendable {
871889 self . effects = effects
872890 self . namespace = namespace
873891 self . staticContext = staticContext
892+ self . genericParameters = genericParameters
874893 }
875894}
876895
@@ -883,6 +902,7 @@ public struct ExportedClass: Codable, NamespacedExportedType {
883902 public var properties : [ ExportedProperty ]
884903 public var namespace : [ String ] ?
885904 public var identityMode : Bool ? // nil = use config default, true/false = override
905+ public var isFinal : Bool ?
886906
887907 public init (
888908 name: String ,
@@ -892,7 +912,8 @@ public struct ExportedClass: Codable, NamespacedExportedType {
892912 methods: [ ExportedFunction ] ,
893913 properties: [ ExportedProperty ] = [ ] ,
894914 namespace: [ String ] ? = nil ,
895- identityMode: Bool ? = nil
915+ identityMode: Bool ? = nil ,
916+ isFinal: Bool ? = nil
896917 ) {
897918 self . name = name
898919 self . swiftCallName = swiftCallName
@@ -902,6 +923,7 @@ public struct ExportedClass: Codable, NamespacedExportedType {
902923 self . properties = properties
903924 self . namespace = namespace
904925 self . identityMode = identityMode
926+ self . isFinal = isFinal
905927 }
906928}
907929
@@ -1100,6 +1122,8 @@ public struct ImportedFunctionSkeleton: Codable {
11001122 /// determine the access level of bridge-generated helpers (e.g. typed
11011123 /// closure inits) that surface through this function's signature.
11021124 public let accessLevel : BridgeJSAccessLevel
1125+ public let genericParameters : [ String ] ?
1126+ public var genericParameterNames : [ String ] { genericParameters ?? [ ] }
11031127
11041128 public init (
11051129 name: String ,
@@ -1109,7 +1133,8 @@ public struct ImportedFunctionSkeleton: Codable {
11091133 returnType: BridgeType ,
11101134 effects: Effects = Effects ( isAsync: false , isThrows: true ) ,
11111135 documentation: String ? = nil ,
1112- accessLevel: BridgeJSAccessLevel = . internal
1136+ accessLevel: BridgeJSAccessLevel = . internal,
1137+ genericParameters: [ String ] ? = nil
11131138 ) {
11141139 self . name = name
11151140 self . jsName = jsName
@@ -1119,10 +1144,11 @@ public struct ImportedFunctionSkeleton: Codable {
11191144 self . effects = effects
11201145 self . documentation = documentation
11211146 self . accessLevel = accessLevel
1147+ self . genericParameters = genericParameters
11221148 }
11231149
11241150 private enum CodingKeys : String , CodingKey {
1125- case name, jsName, from, parameters, returnType, effects, documentation, accessLevel
1151+ case name, jsName, from, parameters, returnType, effects, documentation, accessLevel, genericParameters
11261152 }
11271153
11281154 public init ( from decoder: any Decoder ) throws {
@@ -1135,6 +1161,7 @@ public struct ImportedFunctionSkeleton: Codable {
11351161 self . effects = try container. decode ( Effects . self, forKey: . effects)
11361162 self . documentation = try container. decodeIfPresent ( String . self, forKey: . documentation)
11371163 self . accessLevel = try container. decodeIfPresent ( BridgeJSAccessLevel . self, forKey: . accessLevel) ?? . internal
1164+ self . genericParameters = try container. decodeIfPresent ( [ String ] . self, forKey: . genericParameters)
11381165 }
11391166
11401167 public func abiName( context: ImportedTypeSkeleton ? ) -> String {
@@ -1622,6 +1649,8 @@ extension BridgeType {
16221649 case . dictionary:
16231650 // Dictionaries use stack-based return with entry count (no direct WASM return type)
16241651 return nil
1652+ case . generic:
1653+ return nil
16251654 }
16261655 }
16271656
@@ -1709,6 +1738,8 @@ extension BridgeType {
17091738 case . dictionary( let valueType) :
17101739 // Dictionary mangling: "SD" prefix followed by value type (key is always String)
17111740 return " SD \( valueType. mangleTypeName) "
1741+ case . generic( let name) :
1742+ return " \( name. count) \( name) T "
17121743 }
17131744 }
17141745
0 commit comments