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

Add a new Int node to parse intBE, intLE, uIntBE and uIntLE values. #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arthurschreiber
Copy link

No description provided.

Copy link
Member

@indutny indutny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a tests, but otherwise looks pretty good!

src/node/int.ts Outdated
* @param field State's property name
*/
constructor(public readonly field: string, public readonly bytes: number, public readonly signed: boolean, public readonly littleEndian: boolean) {
super(field + '_' + (signed ? 'int' : 'uint') + '_' + (bytes * 8) + (bytes > 1 ? '_' + (littleEndian ? 'le' : 'be') : ''));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: let's move compound expressions to separate variables and use template syntax here.

Copy link
Author

@arthurschreiber arthurschreiber Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit problematic - the super call needs to be the very first instruction in the constuctor. 😞I'll try to clean this up a but with the template syntax.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted the name generation to a separate function to work around the super call requirement. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, looks great! 👍

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.

2 participants