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

Added support for little endian encoding #35

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

jdl17
Copy link

@jdl17 jdl17 commented Jul 28, 2015

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.

jdl17 added 5 commits July 28, 2015 13:11
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
@jdl17
Copy link
Author

jdl17 commented Jul 29, 2015

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 ByteOrder.BigEndian. This was outside of the scope of my work and I didn't need to use booleans for my decoding and encoding. However, be advised of this if you plan to use boolean in a ByteOrder.LittleEndian encoding.

jdl17 added 13 commits July 30, 2015 13:35
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.
… 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.
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.

None yet

1 participant