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

rough draft of the serialization runtime #31

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

Conversation

laura-a-n-n
Copy link

@laura-a-n-n laura-a-n-n commented Aug 11, 2024

TODOs:

  • go back and fix formatting to be more consistent, i accidentally allowed my ide to auto-format stuff.
  • reorder functions to be in a more logical order
  • implement many of the more specific write methods
  • do a lot more testing

tested on one ksy file that only uses u1, u2, u4, and s2 for primitive data types.

used with a very rough draft of the compiler on the fork here: laura-a-n-n/kaitai_struct_compiler@serialization...laura-a-n-n:kaitai_struct_compiler:javascript-serializer

possible flaws / areas for improvement:

  • write functions create a new DataView object each time. should we be using a shared DataView to do operations?

EDIT for the above task (08/17/2024):

My understanding is that this is not possible at the moment. My initial suspicion was that this was the way to go, especially due to the serial nature of the data, we don't have to worry about concurrency issues that arise when sharing a write buffer.

However, the main problem would be resizing the ArrayBuffer to varying byteLengths. This is completely possible, but it is a relatively new feature. Since the runtime is currently not transpiled with Babel and we'd like to target older browsers, I don't think is afforded to us.

So, I'll stick to creating a new ArrayBuffer and DataView for each write. I ask that reviewers take special note of this and verify my findings. I welcome any corrections or suggestions.

There's probably a better solution.

  • zlib support / compression not implemented

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.

1 participant