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

new package Encoding #1236

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft

new package Encoding #1236

wants to merge 25 commits into from

Conversation

jetjinser
Copy link
Contributor

@jetjinser jetjinser commented Nov 22, 2024

WIP, all commits will be reorganized when ready.

TODO

  • implement decoding UTF16BE
  • implement encoding
  • consider Stream {Lossy, Strict}Chars
  • consider Buffer from_{bytes, array} api
  • refactor decode_strict to error-raisable function instead of just abort.

usage

see encoding/encoding_test.mbt.

api

see encoding/encoding.mbti.

@coveralls
Copy link
Collaborator

coveralls commented Nov 22, 2024

Pull Request Test Coverage Report for Build 3948

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 86 of 175 (49.14%) changed or added relevant lines in 8 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.0%) to 78.933%

Changes Missing Coverage Covered Lines Changed/Added Lines %
encoding/encoding.mbt 5 6 83.33%
builtin/iter.mbt 0 3 0.0%
int/int.mbt 0 3 0.0%
encoding/types.mbt 14 19 73.68%
buffer/buffer.mbt 9 16 56.25%
builtin/bytes.mbt 0 19 0.0%
encoding/decoding.mbt 57 108 52.78%
Files with Coverage Reduction New Missed Lines %
strconv/int.mbt 6 82.35%
Totals Coverage Status
Change from base Build 3918: -1.0%
Covered Lines: 4440
Relevant Lines: 5625

💛 - Coveralls

@jetjinser
Copy link
Contributor Author

ping @Yoorkin.

buffer/buffer.mbt Show resolved Hide resolved
buffer/buffer.mbt Show resolved Hide resolved
pub fn to_unchecked_string(
self : T,
offset~ : Int = 0,
length~ : Int = self.len
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may need to avoid labelled dependency: #1231 (comment)

let bs0 = @buffer.new(size_hint=2)
let (j0, j1) = if be { (0, 1) } else { (1, 0) }
bs0[j0] = (hi >> 8).to_byte()
bs0[j1] = hi.land(0xFF).to_byte()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use bs0.write_byte() instead of random access? The op_set method for buffer is weird

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.

3 participants