Closed gabbifish closed 3 months ago
Not intentional, we've just been adding things as we need them and you're the first to make note of this.
One workaround is to use pub use self::ffi::Foo
from outside of mod foo
to expose Foo
to other module.
Supporting this should be easy though if you're interested. Roughly two lines of implementation code + a couple of tests.
Here's how one might add support for preserving the module's visibility, in case you or any future person wants to tackle this:
Add a parsing test where we verify that we can store the module's visibility https://github.com/chinedufn/swift-bridge/blob/72e1759e0504e3a5a32587605c98e410f12ea9e7/crates/swift-bridge-ir/src/parse.rs#L164-L210
Add a codegen test where we confirm that the module's visibility is preserved in the generated Rust tokens:
Perhaps in a mod module_visibility_tests
in here https://github.com/chinedufn/swift-bridge/blob/4fbd30f81085dc366bda3c0303eac66345de3ed9/crates/swift-bridge-ir/src/codegen/codegen_tests.rs#L30-L54
Add a field SwiftBridgeModule.visibility: syn::Visibility
https://github.com/chinedufn/swift-bridge/blob/b07745108b0daa86255fbc30dc1bce7ce9c02eb5/crates/swift-bridge-ir/src/lib.rs#L59-L60
Then set the field during parsing visibility: item_mod.visibility
https://github.com/chinedufn/swift-bridge/blob/72e1759e0504e3a5a32587605c98e410f12ea9e7/crates/swift-bridge-ir/src/parse.rs#L126-L127
Interpolate the visibility here #visibility #mod_name
Verify that tests pass using cargo test -p swift-bridge-ir
Awesome! I'll try and get a PR open for this soon :)
Fixed in #284.
I defined a transparent type in one ffi submodule:
and tried to import it in another module:
but saw the following error for this line:
use error:ffi:RuntimeError
:It seems the
#[swift_bridge::bridge]
macro forces its module to be private--is this intentional, or can its private/public status be passed through?