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

Convert MemoryBufferProtocolWrapper to generic #1906

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

BCSharp
Copy link
Member

@BCSharp BCSharp commented Feb 6, 2025

MemoryBufferProtocolWrapper was born out of a desire to provide a seamless and efficient conversion from CLR arrays (and Memory<byte> etc.) to IBufferProtocol, which proliferates the public API for "bytes-like" parameters.

It turns out that the wrapper class can be useful also for adapting Memory of other underlying unmanaged types to IBufferProtocol, hence the change to the generic MemoryBufferProtocolWrapper<T>. The rules in the conversion binder did not change, that is, still only byte-oriented types (byte[], Memory<byte>, ReadOnlyMemory<byte>) are eligible to be automatically converted by the ConversionBinder. However, C# code may now use the class for other conversions, therefore be able to call methods accepting IBufferProtocol using arrays/memory with other underlying types.

@BCSharp BCSharp merged commit 662a97d into IronLanguages:main Feb 6, 2025
8 checks passed
@BCSharp BCSharp deleted the memorybp_wrapper_generic branch February 6, 2025 22:02
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