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

GSoC Part 1 & 2: Binary Buffer functions, Serialization and Deserialization #2318

Merged
merged 98 commits into from
Mar 19, 2023

Conversation

dc03
Copy link
Contributor

@dc03 dc03 commented Sep 8, 2022

This pull request marks the completion of my GSoC Project for Summer 2022, and contains all the commits pertaining to my changes in both the pull requests for Part 1 and Part 2 of my project, which are:

Aside from these, I also made the following pull requests which got merged:

Also, I made the following pull requests which did not get merged:

I tracked my progress approximately weekly on my personal blog: https://dc03.github.io/

dc03 added 30 commits June 26, 2022 22:29
Update buffer_fill and buffer_poke
- Update serialize_to_type to automatically switch between integer types
  when the value can't fit in the signed type
- Update deserialize_from_type to only use unsigned integers
- Update buffer_fill to set the position of the buffer back to the start so that it can be read from again
- Update buffer_peek to use 'deserialize_from_type'
- Add a new class, `BinaryBufferAsset`, to act as a wrapper around
  `std::unique_ptr<BinaryBuffer>` so that the `AssetArray` interface is
  satisfied.
- Add a function `push_buffer` to handle creating a buffer
- Create a new file `buffers_internal.cpp` to store function definitions
- No longer reliant only on int, thus less possibility for bugs as
  strict typing is enforced
- Move buffer enums into `buffers_data.h` and give them names,
  `buffer_seek_t`, `buffer_type_t`, `buffer_data_t`
- Update buffer functions and BinaryBuffer class to use these type names
- Previously, they used to read only 0 bytes from the given file, that
  too in a non-portable way, as `pos_type` is not guaranteed to be a
  `std::size_t` or whatever, and is instead an implementation-defined
  type.
- Previously, it wasn't using the buffer's type correctly. It would
  always use `.insert()` so the size of the buffer would always
  increase. Now, it only makes the buffer bigger when using
  `buffer_grow`.
- Also fix `buffer_create` and `buffer_delete` not using the correct
  `AssetArray` functions.
- Add a (big) test case for `buffer_load_ext` to test the various buffer
  types being loaded properly.
- Make the `buffer_fill` test much more comprehensive, using `offset`
  too
- Fix `buffer_fill` implementation not using `offset`
- Make the implementation better, check for more edge cases
- Change `buffer_seek` to use `buffer_seek_t`
- Update `buffer_fill` test case to check buffer size
- Change `buffer_poke` to write bytes using `serialize_to_type`
- Set `position` to 0 when `offset` is negative
- Clamp to `GetSize() - 1` instead of `GetSize()` as it is zero-indexed
- Turn `M_USER_ERROR` into `M_WARNING`
- When seeking `buffer_seek_end`, use `GetSize() - 1` instead of
  `GetSize()` as it is zero indexed.
- Pad buffer with extra 0s after data for alignment purposes
- Update test to reflect change
- Have it properly pad with zeroes, i.e. only insert zeroes if there is
  space for it after the element
- Make `buffer_read` more compliant because GMS only pushes `position`
  forward when using `buffer_read` not `buffer_peek`
- Update test case
@JoshDreamland JoshDreamland merged commit 44b5040 into enigma-dev:AST-Generation Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants