uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

External type fails for some corner cases

Open bendk opened this issue 1 year ago • 1 comments

It's tricky to get the FFI function signatures correct for external types since we don't know the concrete actual type. Here's where we determine the FFI type to use. I can think of at least 2 cases where this will fail:

  • A external custom type that wraps a primitive type. There's no way to represent that with ExternalKind
  • A "doubly external" type: crate1 defines a type, crate2 uses it as an external type, crate3 uses that type from crate2 as it's external type. In this case, the RustBuffer crate name will be wrong. This is a pretty weird case, but if we could support it it would be nice.

Now that the proc-macro metadata code has matured, I think we can fix both of these issues by:

  • Replacing ExternalKind with the actual type definition.
  • Making name refer to the crate that the type was originally defined in.

bendk avatar May 21 '24 13:05 bendk