-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for already_declared enums (#125)
This commit allows enums to use the `already_declared` attribute. This is useful when you want to use the same enum across multiple bridge modules. --- For example, the following is now possible: ```rust use some_other_bridge_module::SomeEnum; #[swift_bridge::bridge] mod ffi { #[swift_bridge(already_declared)] enum SomeEnum {} extern "Rust" { fn print(val: SomeEnum); } } ```
- Loading branch information
Showing
17 changed files
with
282 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...tIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumAttributeTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// SharedEnumAttributeTests.swift | ||
// SwiftRustIntegrationTestRunnerTests | ||
// | ||
// Created by Frankie Nwafili on 12/15/22. | ||
// | ||
|
||
import XCTest | ||
@testable import SwiftRustIntegrationTestRunner | ||
|
||
/// Tests for attributes on transparent enum types. | ||
class SharedEnumAttributeTests: XCTestCase { | ||
/// Verify that we can call a function that uses a type that was already declared in a different bridge module. | ||
func testSharedEnumAlreadyDeclared() throws { | ||
XCTAssertEqual( | ||
reflect_already_declared_enum( | ||
AlreadyDeclaredEnumTest.Variant | ||
), | ||
AlreadyDeclaredEnumTest.Variant | ||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.