Skip to content
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

Support Option<Primitive> in Swift fns #203

Merged
merged 1 commit into from
Mar 19, 2023

Conversation

chinedufn
Copy link
Owner

This commit adds support for Option in extern "Swift"
functions.

For example, the following is now possible:

mod ffi {
    extern "Swift" {
        fn my_func(arg: Option<u8>) -> Option<bool>;
    }
}

This commit adds support for Option<PrimitiveType> in `extern "Swift"`
functions.

For example, the following is now possible:

```rust
mod ffi {
    extern "Swift" {
        fn my_func(arg: Option<u8>) -> Option<bool>;
    }
}
```
@@ -77,21 +83,9 @@ typedef struct RustStr { uint8_t* const start; uintptr_t len; } RustStr;
typedef struct __private__FfiSlice { void* const start; uintptr_t len; } __private__FfiSlice;
void* __swift_bridge__null_pointer(void);

typedef struct __private__OptionU8 { uint8_t val; bool is_some; } __private__OptionU8;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to another file

@@ -1,6 +1,3 @@
// TODO:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented this a long time ago

@@ -1,9 +0,0 @@
// /// `impl BridgeableType for {u8, i8, u16, i16 ... etc}`
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this file

@chinedufn
Copy link
Owner Author

Thanks!

@chinedufn chinedufn merged commit fdca9fc into master Mar 19, 2023
@chinedufn chinedufn deleted the option-primitive-rust-calls-swift branch March 19, 2023 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants