GSoC Midterm Evaluation: Changing the way the serialize, serialize_into and deserialize functions work

Reporter: FaresAtef1  |  Status: open  |  Last Modified: September 06, 2023, 03:30:49 am

Midterm GSoC Update

Closes #2326.
This pull request contains updates for my Google Summer of Code (GSoC) project at the midterm evaluation stage.

Second PR (Final Evaluation Part1): Implementing (de)serialization routines for generic data types
Third PR (Final Evaluation Part2): Adding support for JSON format

Existing Errors

  • Fixing existing errors.

Updating Functions

  • Updating enigma_internal_sizeof function.
  • Updating serialize_into function.
  • Updating serialize function.
  • Updating deserialize function.
  • Updating resize_buffer_for function.
  • Updating enigma_internal_deserialize function.

Testing Functions (SOG/unit tests)

  • Testing enigma_internal_sizeof function.
  • Testing serialize_into function.
  • Testing serialize function.
  • Testing deserialize function.
  • Testing resize_buffer_for function.
  • Testing enigma_internal_deserialize function.
  • SOG test for game_save_buffer and game_load_buffer

Organization

  • Making detect_size.h file.
  • Better naming for all serialization.h functions.
  • Making a Serialization directory.
  • Making serialization_fwd_decl.h file.

To Be Done Before Merging

  • Resolve multiple definitions of the function Size gist (To have Cleaner Code)
  • Replace has_byte_size_free_function_v2
  • Replace has_serialize_into_fn_free_function_v2
  • Replace has_serialize_free_function_v2
  • Replace has_deserialize_free_function_v2
  • Replace has_resize_buffer_for_free_function_v2
  • Replace has_enigma_internal_deserialize_free_function_v2

Newly Implemented Features

  • HAS_FREE_FUNCTION macro in detect_serialization.h, which is used to determine whether there exists a free function that can be called with a particular signature.
    HAS_FREE_FUNCTION(NAMESPACE, NAME, PARAMETERS...)

Adding new types for the bytes format

Create a new file in the Types_Impl_Bytes directory for your new type, and then include this file in the bytes_types_serialization_includes.h file.

Every new data type in our system should implement the following functions

is_new_type is a type trait that should be implemented in type_traits.h.

  • byte_size
    template <typename T>
    matches_t<T, std::size_t, is_new_type> inline byte_size(const T& value) {
        std::size_t totalSize = // ....
        return totalSize;
    }
  • internal_serialize_into_fn
    template <typename T>
    matches_t<T, void, is_new_type> inline internal_serialize_into_fn(std::byte *iter, T &&value) {
        // ....
    }
  • internal_serialize_fn
    template <typename T>
    matches_t<T, std::vector<std::byte>, is_new_type> inline internal_serialize_fn(T &&value) {
        std::vector<std::byte> result;
        // ....
        return result;
    }
  • internal_deserialize_fn
    template <typename T>
    matches_t<T, T, is_new_type> inline internal_deserialize_fn(std::byte *iter) {
        // ....
    }
  • internal_resize_buffer_for_fn
    template <typename T>
    matches_t<T, void, is_new_type> inline internal_resize_buffer_for_fn(std::vector<std::byte> &buffer, T &&value) {
        // ....
    }
  • enigma_internal_deserialize_fn
    template <typename T>
    matches_t<T, void, is_new_type> inline void enigma_internal_deserialize_fn(T &value, std::byte *iter, std::size_t &len) {
        value = ....
        len += ....
    }

Sample game that is compatible with the AST_Generation branch

Balloon_Pop (It is the same game in the ENIGMA site but with modified scripts).

Ongoing Work

What's Next

GSoC Final Evaluation: Implementing (de)serialization routines for generic data types

Please sign in to post comments, or you can view this issue on GitHub.