Archived

This forum has been archived. Please start a new discussion on GitHub.

C# byte sequence mapping

kwaclaw
kwaclaw Oshawa, Canada
It would be nice if the C# mapping for byte sequences could be optionally specified to map to a range within an array (similar to the C++ mapping options). That way one could avoid extra copying.

.NET even defines the ArraySegment type, but this is not strictly required here.

Karl

Comments

  • kwaclaw
    kwaclaw Oshawa, Canada
    kwaclaw wrote: »
    It would be nice if the C# mapping for byte sequences could be optionally specified to map to a range within an array (similar to the C++ mapping options). That way one could avoid extra copying.

    .NET even defines the ArraySegment type, but this is not strictly required here.

    Karl

    Maybe I should explain a little. The following Slice
    interface Receiver {
      void Receive(long offset, ByteSeq data);
    };
    

    generates C# code like this:
    [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.4.1")]
    public interface ReceiverPrx : Ice.ObjectPrx
    {
        void Receive(long offset, byte[] data);
        void Receive(long offset, byte[] data, _System.Collections.Generic.Dictionary<string, string> context__);
    
        Ice.AsyncResult<KdSoftIce.Stream.Callback_Receiver_Receive> begin_Receive(long offset, byte[] data);
        Ice.AsyncResult<KdSoftIce.Stream.Callback_Receiver_Receive> begin_Receive(long offset, byte[] data, _System.Collections.Generic.Dictionary<string, string> ctx__);
    
        Ice.AsyncResult begin_Receive(long offset, byte[] data, Ice.AsyncCallback cb__, object cookie__);
        Ice.AsyncResult begin_Receive(long offset, byte[] data, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__);
    
        void end_Receive(Ice.AsyncResult r__);
    }
    

    It would be helpful if it would also (optionally) generate this:
    public interface ReceiverPrx : Ice.ObjectPrx
    {
        ...
        void Receive(long offset, byte[] data, int start, int count);
           // or maybe
        void Receive(long offset, ArraySegment<byte> data);
        ...
    }
    

    Karl