Skip to content

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