-
Notifications
You must be signed in to change notification settings - Fork 65
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
Fix non-deterministic generation order #230
Conversation
edae3d8
to
3db7ced
Compare
It seems like another issue happens:
|
3db7ced
to
100340c
Compare
100340c
to
8786ed2
Compare
I rebased #226 into this branch, and then I fixed the immediately above issue. |
func swift_reflect_already_declared_struct(arg: AlreadyDeclaredStructTest) -> AlreadyDeclaredStructTest { | ||
arg | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix the immediately above issue, I appended this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWESOME! Left some minor feedback but after that LGTM. Thanks so much for solving this problem. Solution looks good.
use quote::quote; | ||
|
||
/// Verify that fields of a structure in a C header file are generated before the structure. | ||
mod structure_fields_generated_before_structure { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
/// Verify that the type that if there is a `Result<Tuple, _>` the generated C header contains
/// the tuple's fields followed by the tuple's FFI representation followed by the Result FFI repr.
mod tuple_fields_generated_before_tuple_generated_before_result
extern "Rust" { | ||
fn rust_func_return_result_tuple_transparent_enum( | ||
succeed: bool, | ||
) -> Result<(i32, ResultTestOpaqueRustType, String), i32>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Result<(RustOpaqueType1, RustOpaqueType1), (RustOpaqueType2, RustOpaqueType2)>
?
(I can't remember if we allow tuples in the E
of Result<T, E>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't implement it, but it might work.
Here's a PR which adds support Result<tuple, _>
#213
@@ -16,6 +16,11 @@ struct Bookkeeping { | |||
slice_types: HashSet<String>, | |||
} | |||
|
|||
struct CFFiStructDeclarationBookkeeping { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that most of the documentation that you put on CFFiStruct
belongs here instead.
As in, we should document why we do this bookkeeping.
/// For example, struct FooStruct {struct BarStruct bar_struct;} is generated in the order of | ||
/// struct BarStruct {int32_t value;}; | ||
/// struct struct FooStruct {struct BarStruct bar_struct;}; | ||
/// | ||
/// Please see https://github.com/chinedufn/swift-bridge/pull/225. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we can move this example to CFFiStructDeclarationBookkeeping
The docs on CFFiStructDeclarationBookkeeping
should
- Explain the problem
- Explain how we use the struct to bookkeeping struct solve the problem
I think we should delete the link to the pull request. Anything relevant should be explained in the code doc.
/// struct struct FooStruct {struct BarStruct bar_struct;}; | ||
/// | ||
/// Please see https://github.com/chinedufn/swift-bridge/pull/225. | ||
pub(crate) struct CFFiStruct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CFfiStruct
@@ -0,0 +1,55 @@ | |||
use super::{CodegenTest, ExpectedCHeader, ExpectedRustTokens, ExpectedSwiftCode}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the work header to this file. Maybe c_header_declaration_order_codegen_tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean:
Replace c_ffi_declaration_order_generation_tests
with c_header_declaration_order_codegen_tests.rs
.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sorry i meant rename. was a typo
@@ -16,6 +16,11 @@ struct Bookkeeping { | |||
slice_types: HashSet<String>, | |||
} | |||
|
|||
struct CFFiStructDeclarationBookkeeping { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CFfiStructDeclarationBookkeeping
b9b2543
to
0056d55
Compare
@chinedufn |
Related to #225.
Before this commit, the integration tests sometimes fail, like so:
This PR fixes the issue.