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

Add FFIPointer to interoptopus::patterns::ptr #71

Open
ralfbiedert opened this issue Oct 2, 2022 · 0 comments
Open

Add FFIPointer to interoptopus::patterns::ptr #71

ralfbiedert opened this issue Oct 2, 2022 · 0 comments
Labels
c-core Interoptopus Core Crate enhancement Make existing things better. needs-discussion Something rather fuzzy, input wanted.

Comments

@ralfbiedert
Copy link
Owner

ralfbiedert commented Oct 2, 2022

Somewhat experimental idea, needs validation, also see #68:

Names tbd:

  • A generic FFIPointer<T, SingleElementOrMultiple, RustRW, FFIRW> indicating how that pointer is being used (type T of target, single or multiple elements, and who reads and writes; bonus points if we can make T so that it also accepts and enum of type alternatives although I wouldn't know how to do that)
  • various aliases to common FFIPointer<A, B, C, D> combinations.
  • The generic FFIPointer would fallback to *T or *c_void in backends for now or could be used for other optimizations (e.g., deciding if an #[In, out] should be applied.
  • bonus-bonus points if MultipleElements can also encode variable or constant many elements.

This pointer could also subsume Callbacks with the help of const generics, e.g., Callback<Name="Bla"> once &str are available.

Main questions to resolve are:

  • Can this be implemented?
  • Will this make writing APIs more ergonomic (e.g., better C# bindings w.r.t IntPtr, #[In/Out], ...)?
  • Will this be cleaner or more messy than having multiple independent types (e.g., w.r.t. our maintenance)?
@ralfbiedert ralfbiedert added c-core Interoptopus Core Crate enhancement Make existing things better. needs-discussion Something rather fuzzy, input wanted. labels Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-core Interoptopus Core Crate enhancement Make existing things better. needs-discussion Something rather fuzzy, input wanted.
Projects
None yet
Development

No branches or pull requests

1 participant