Skip to content

Commit 78800eb

Browse files
Merge pull request #684 from swiftwasm/pr-720ce456b1d8a61bcaf3a4a43a6061feae89f16f
BridgeJS: Remove `_BridgedSwiftDictionaryStackType` protocol
2 parents e902160 + bcb952c commit 78800eb

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

Sources/JavaScriptKit/BridgeJSIntrinsics.swift

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,25 +1920,9 @@ extension Array: _BridgedSwiftStackType where Element: _BridgedSwiftStackType, E
19201920

19211921
// MARK: - Dictionary Support
19221922

1923-
public protocol _BridgedSwiftDictionaryStackType: _BridgedSwiftTypeLoweredIntoVoidType,
1924-
_BridgedSwiftStackType
1925-
where StackLiftResult == Self {
1926-
associatedtype DictionaryValue: _BridgedSwiftStackType
1927-
where DictionaryValue.StackLiftResult == DictionaryValue
1928-
}
1929-
19301923
extension Dictionary: _BridgedSwiftStackType
19311924
where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
19321925
public typealias StackLiftResult = [String: Value]
1933-
// Lowering/return use stack-based encoding, so dictionary also behaves like a void-lowered type.
1934-
// Optional/JSUndefinedOr wrappers rely on this conformance to push an isSome flag and
1935-
// then delegate to the stack-based lowering defined below.
1936-
// swiftlint:disable:next type_name
1937-
}
1938-
1939-
extension Dictionary: _BridgedSwiftTypeLoweredIntoVoidType, _BridgedSwiftDictionaryStackType
1940-
where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
1941-
public typealias DictionaryValue = Value
19421926

19431927
@_spi(BridgeJS) public static func bridgeJSStackPop() -> [String: Value] {
19441928
let count = Int(_swift_js_pop_i32())
@@ -1960,7 +1944,10 @@ where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Val
19601944
}
19611945
_swift_js_push_i32(count)
19621946
}
1947+
}
19631948

1949+
extension Dictionary: _BridgedSwiftTypeLoweredIntoVoidType
1950+
where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
19641951
@_spi(BridgeJS) public static func bridgeJSLiftParameter() -> [String: Value] {
19651952
bridgeJSStackPop()
19661953
}
@@ -1975,10 +1962,9 @@ where Key == String, Value: _BridgedSwiftStackType, Value.StackLiftResult == Val
19751962
}
19761963
}
19771964

1978-
extension _BridgedAsOptional where Wrapped: _BridgedSwiftDictionaryStackType {
1979-
typealias DictionaryValue = Wrapped.DictionaryValue
1980-
1981-
@_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> Int32 {
1965+
extension _BridgedAsOptional {
1966+
@_spi(BridgeJS) public consuming func bridgeJSLowerParameter<Value>() -> Int32
1967+
where Wrapped == Dictionary<String, Value>, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
19821968
switch asOptional {
19831969
case .none:
19841970
return 0
@@ -1988,22 +1974,25 @@ extension _BridgedAsOptional where Wrapped: _BridgedSwiftDictionaryStackType {
19881974
}
19891975
}
19901976

1991-
@_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32) -> Self {
1977+
@_spi(BridgeJS) public static func bridgeJSLiftParameter<Value>(_ isSome: Int32) -> Self
1978+
where Wrapped == Dictionary<String, Value>, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
19921979
if isSome == 0 {
19931980
return Self(optional: nil)
19941981
}
1995-
return Self(optional: (Dictionary<String, Wrapped.DictionaryValue>.bridgeJSStackPop() as! Wrapped))
1982+
return Self(optional: Dictionary<String, Value>.bridgeJSStackPop())
19961983
}
19971984

1998-
@_spi(BridgeJS) public static func bridgeJSLiftReturn() -> Self {
1985+
@_spi(BridgeJS) public static func bridgeJSLiftReturn<Value>() -> Self
1986+
where Wrapped == Dictionary<String, Value>, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
19991987
let isSome = _swift_js_pop_i32()
20001988
if isSome == 0 {
20011989
return Self(optional: nil)
20021990
}
2003-
return Self(optional: (Dictionary<String, Wrapped.DictionaryValue>.bridgeJSStackPop() as! Wrapped))
1991+
return Self(optional: Dictionary<String, Value>.bridgeJSStackPop())
20041992
}
20051993

2006-
@_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void {
1994+
@_spi(BridgeJS) public consuming func bridgeJSLowerReturn<Value>() -> Void
1995+
where Wrapped == Dictionary<String, Value>, Value: _BridgedSwiftStackType, Value.StackLiftResult == Value {
20071996
Wrapped.bridgeJSStackPushAsOptional(asOptional)
20081997
}
20091998
}

0 commit comments

Comments
 (0)