-
-
Notifications
You must be signed in to change notification settings - Fork 63
BridgeJS: Add Dictionary support #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hey @kateinoigakukun, found and fixed a couple bugs in the dictionary PR for optional dictionary handling on exports. Bug 1: Missing Optional dictionary support in BridgeJSIntrinsics.swiftThe Added complete Optional support: extension Optional where Wrapped: _BridgedSwiftDictionaryStackType {
@_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> Int32 {
switch consume self {
case .none:
return 0
case .some(let dict):
dict.bridgeJSLowerReturn()
return 1
}
}
@_spi(BridgeJS) public consuming func bridgeJSLowerReturn() {
switch consume self {
case .none:
_swift_js_push_i32(0)
case .some(let dict):
dict.bridgeJSLowerReturn()
_swift_js_push_i32(1)
}
}
@_spi(BridgeJS) public static func bridgeJSLiftParameter(_ isSome: Int32) -> [String: Wrapped.DictionaryValue]? {
if isSome == 0 {
return nil
}
return Dictionary<String, Wrapped.DictionaryValue>.bridgeJSLiftParameter()
}
// ... plus bridgeJSLiftParameter() and bridgeJSLiftReturn()
}Bug 2: Missing
|
ee19ac2 to
aa82380
Compare
|
|
Overview
Add full dictionary bridging to BridgeJS: generate
[String: T]bindings, carry them through link/mangling/TS typing, and bridge optional/undefined cases at runtime.Examples
Implementation
.dictionarycase for[String: T]/Dictionary<String, T>and map toRecord<string, …>in TS output._BridgedSwiftDictionaryStackTypeso dictionaries integrate with optional stack ABI, and add runtime fixtures/tests covering int/bool/double/JSObject/JSValue dictionaries plus nested/optional/undefined shapes, including export-side round trips.Limitations
String; other key types are unsupported.Object.entriesand is not stable/sorted.