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

BitStructure: improve constructor argument processing #17

Closed
pabigot opened this issue Dec 23, 2017 · 0 comments
Closed

BitStructure: improve constructor argument processing #17

pabigot opened this issue Dec 23, 2017 · 0 comments
Assignees
Milestone

Comments

@pabigot
Copy link
Owner

pabigot commented Dec 23, 2017

This code:

const bs = lo.bits(lo.u8(), 'flags');
const str = lo.struct([bs]);

will result in failure to process the structure flags field because the intended property name is interpreted as the rarely-used second parameter boolean specifying the bit order, leaving the field without a property name and so with no way to represent the field content.

If the second parameter to lo.bits is a string and there is no third parameter, treat the second parameter as property and set msb to undefined.

@pabigot pabigot changed the title BitStructure: improve argument processing BitStructure: improve constructor argument processing Dec 23, 2017
pabigot added a commit that referenced this issue Dec 23, 2017
BitStructure's constructor takes two parameters, with the second being a
rarely-used option to order allocation from the most significant bit
down.  The developer forgets this, and passes a property name without a
second argument, which results in no data.  If the argument is
type-compatible with property and no third argument is present, treat
the argument as property rather than msb.

Technically this is an API change, but I'm going to rule it minor
because anybody who's affected will have been using it wrong.

Closes #17.
@pabigot pabigot self-assigned this Dec 23, 2017
@pabigot pabigot added this to the 1.1.0 milestone Jan 6, 2018
@pabigot pabigot closed this as completed in e091ed0 Jan 6, 2018
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

No branches or pull requests

1 participant