PATCH: Mono.DataConverter + EndianAwareBinaryWriter + EndianAwareBinaryReader

Jan 16, 2009 at 3:12 PM

Here is my first MOSA patch:

It adds Mono's DataConverter class (basically, BitConverter the way it should have been written). My patch also adds two classes that I have written: EndianAwareBinaryWriter and EndianAwareBinaryReader. (I've added them to the Mosa.Runtime project, with the DataConverter in the global::System namespace and the reader & writer in the global::System.IO namespace.)

The latter two classes are subclasses of System.IO.BinaryWriter and System.IO.BinaryReader, respectively. They use the DataConverter class to make sure that write and read options are kept in context with a desired Endianness.

Not all reads and writes take advantage of the Endianness-awareness. System.Decimal was not implemented in Mono's DataConverter class so my reader and writer here just call the base corelib implementation to read and write them. Also, string and character operations ignore endianness. (Which is particularly an important note because of how the base corelib implementation uses compressed-integer length-prefixing.) All signed and unsigned integer reads and writes, and reading/writing of System.Single and System.Double use endianness-aware conversions.

If we integrate this into the compiler, this will help us easily ensure correct functionality of cross-compilation.

This probably deprecates tgiphil's Mosa.ClassLib.DataFormat class, but I did not include a deletion of it in my patch.

I did not include any unit tests because of laziness, and Mono only had a couple to port, and I'm not sure of where to put them.

Please let me know what you think!

-Bruce Markham

aka Illuminus

Jan 16, 2009 at 3:21 PM
Confounded CodePlex, swallowed my attachment.

Download the patch from here:
Jan 16, 2009 at 4:05 PM
Thanks for the patch.

You now have read/write access to depository.  Please commit your patch there.