swift-bridge
swift-bridge copied to clipboard
Implement BridgeableType for primitive types
Here: https://github.com/chinedufn/swift-bridge/blob/20baa731361c9cb86c2b4a9f5c7d0a5f65f6ff45/crates/swift-bridge-ir/src/bridged_type.rs#L354-L373
Maybe, related to: https://github.com/chinedufn/swift-bridge/blob/20baa731361c9cb86c2b4a9f5c7d0a5f65f6ff45/crates/swift-bridge-ir/src/bridged_type/bridgeable_primitive.rs#L1-L9
The first comment was written before we had the BridgeableType
trait.
I'm not sure what the best abstraction is here. It's hard to say within feeling it out a bit.
Here's what I'm thinking off the top of my head:
A macro seems like a bit much given that the bridging code for primitives should almost never change, and there isn't very much code per primitive kind.
So, maybe a enum PrimitiveType { Null, U8, I8, .. }
and then impl BridgeableType for PrimitiveType
.
Then we can replace this with PrimitiveType::new_with_str(tokens: &str, types: &TypeDeclarations) -> Option<TokenStream>
https://github.com/chinedufn/swift-bridge/blob/832498a8a822690e2ef61e5929a05d713ba2fbe8/crates/swift-bridge-ir/src/bridged_type.rs#L737-L761