ralfbiedert / interoptopus

The polyglot bindings generator for your library (C#, C, Python, …) 🐙
302 stars 27 forks source link

Added support for slice-parameters to be passed in as spans and read-only spans, instead of arrays. #106

Closed Earthmark closed 2 weeks ago

Earthmark commented 1 month ago

The hope being this provides support for more exotic memory structures.

This is not behind a version check because it's an explicit option, and it will panic if span is selected but unsafe code support is not.

I'm not sure a good way to require this without a larger API change, and my goal was to make this a small opt-in feature.

Originally I was planning to have it generate overload methods, but if a consumer is using unsafe code and wants to use spans, all signatures will still work with arrays just as well. That code also needed guards to ensure it wouldn't generate duplicates of methods that didn't use spans, which added a lot of complexity.

ralfbiedert commented 1 month ago

Thanks a lot! Just came back from vacation, give me a few more days to get back into this.

Earthmark commented 2 weeks ago

Any updates on this?

ralfbiedert commented 2 weeks ago

Apologies for the delay, the short summer just started here for real :)

This looks good. It would be interesting to see if return values could be made compatible with spans as well, e.g., if the type happened to be compatible with out Slice type, or if that can be done on rval wrapping.