-
Notifications
You must be signed in to change notification settings - Fork 80
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
Added support for little endian encoding #35
base: master
Are you sure you want to change the base?
Conversation
implementation of little endian decoding uses LSB 0 bit numbering. However, the encoding seems to only encode with MSB 0 bit numbering. I attempted to resolve this issue and it is currently working for Numerics.
Before the change, preon was complaining of a NullPointerException in CompositeGrammer.getIndirectDelegates. Please see antlr/antlr3#151 for more information on this bug that has been resolved in ANTLR 3.5.2
I should also comment that I added routines to properly encode booleans in little endian and big endian. However, the current implementation of Bound does not allow for for a byteOrder annotation is currently hardcoded to |
Endian. Added methods so that the ByteOrder can be specified. The default encode method remains so and will always flush in Big Endian. Also added overloaded encode methods so the endianness may be specified.
This is useful when you are using a BoundObject with Choices and you want one of the choices to have no data. In this case, you would need to create a class with a Byte that is initialized to null.
…s in a commons-lang MutableInt
… to call one of the overloaded decodeDebug methods. The meat of the change is insides the StandardBindingFactory that looks for the debug flag in the load method. If it sees it, it prints the fields, the value, and bits for what is being decoded. Each Codec that implements the interface needed a new method.
…n order. It was easier to leave the decode routines in tact than to change all the unit tests.
…ly on the byte boundary then we don't want to subtract one byte from the length
getNumberBufAsLong was using a long to extract the bits from the buffer to get the necessary value. However, problems will happen when you are trying to extract a 64-bit field that spans 9 bytes. One of the bytes will be lost when trying to shove it all in a long. Therefore, I rewrote the method to return a BigInteger and did all the math using the BigInteger so the ninth byte will no longer be lost.
Added support for little endian encoding. It appears that the current
implementation of little endian decoding uses LSB 0 bit numbering.
However, the encoding seems to only encode with MSB 0 bit numbering. I
attempted to resolve this issue and it is currently working for
Numerics.