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

Improvements to bytes #118

Merged
merged 1 commit into from Aug 3, 2021
Merged

Improvements to bytes #118

merged 1 commit into from Aug 3, 2021

Conversation

s-hadinger
Copy link
Contributor

Improvements to bytes() handling already used for some time in Tasmota:

  • fixed conversion from string to bytes when the string contained NULL characters
  • file.write() now supports bytes as argument in addition to string.
  • file.readbytes() directly returns raw bytes() object, and internally avoid double allocation of memory. The bytes object is directly allocated with the right size and filled in-place
  • added be_isbytes() to easily test if an argument is derived from the bytes class

New methods for bytes:

  • getbits and setbits to change a bit-field within bytes. The code is in Berry and solidified
  • added set() function mirroring the get() function
  • added signed alternative geti() to get which remains unsigned. Signed/unsigned only make a difference for values smaller than the int internal size.

@skiars skiars merged commit 1273837 into berry-lang:master Aug 3, 2021
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

2 participants