Skip to content

Commit

Permalink
Fix Unserialize => Deserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Jul 11, 2024
1 parent 548f240 commit 9f65281
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 210 deletions.
12 changes: 6 additions & 6 deletions include/NZSL/Ast/AstSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ namespace nzsl::Ast
AbstractSerializer& m_serializer;
};

class NZSL_API ShaderAstUnserializer final : public SerializerBase
class NZSL_API ShaderAstDeserializer final : public SerializerBase
{
public:
ShaderAstUnserializer(AbstractUnserializer& stream);
~ShaderAstUnserializer() = default;
ShaderAstDeserializer(AbstractDeserializer& stream);
~ShaderAstDeserializer() = default;

ModulePtr Unserialize();
ModulePtr Deserialize();

private:
using SerializerBase::Serialize;
Expand Down Expand Up @@ -214,12 +214,12 @@ namespace nzsl::Ast
void Value(std::uint64_t& val) override;

std::vector<std::shared_ptr<const std::string>> m_strings;
AbstractUnserializer& m_unserializer;
AbstractDeserializer& m_deserializer;
std::uint32_t m_version;
};

NZSL_API void SerializeShader(AbstractSerializer& serializer, const Module& shader);
NZSL_API ModulePtr UnserializeShader(AbstractUnserializer& unserializer);
NZSL_API ModulePtr DeserializeShader(AbstractDeserializer& deserializer);
}

#include <NZSL/Ast/AstSerializer.inl>
Expand Down
4 changes: 2 additions & 2 deletions include/NZSL/Ast/AstSerializer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ namespace nzsl::Ast
{
}

inline ShaderAstUnserializer::ShaderAstUnserializer(AbstractUnserializer& unserializer) :
m_unserializer(unserializer)
inline ShaderAstDeserializer::ShaderAstDeserializer(AbstractDeserializer& deserializer) :
m_deserializer(deserializer)
{
}
}
Expand Down
58 changes: 29 additions & 29 deletions include/NZSL/Serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ namespace nzsl
virtual void Serialize(const std::string& value);
};

class NZSL_API AbstractUnserializer
class NZSL_API AbstractDeserializer
{
public:
virtual ~AbstractUnserializer();

virtual void Unserialize(bool& value);
virtual void Unserialize(double& value);
virtual void Unserialize(float& value);
virtual void Unserialize(std::int8_t& value);
virtual void Unserialize(std::int16_t& value);
virtual void Unserialize(std::int32_t& value);
virtual void Unserialize(std::int64_t& value);
virtual void Unserialize(std::uint8_t& value) = 0;
virtual void Unserialize(std::uint16_t& value) = 0;
virtual void Unserialize(std::uint32_t& value) = 0;
virtual void Unserialize(std::uint64_t& value) = 0;
virtual void Unserialize(std::string& value);
virtual ~AbstractDeserializer();

virtual void Deserialize(bool& value);
virtual void Deserialize(double& value);
virtual void Deserialize(float& value);
virtual void Deserialize(std::int8_t& value);
virtual void Deserialize(std::int16_t& value);
virtual void Deserialize(std::int32_t& value);
virtual void Deserialize(std::int64_t& value);
virtual void Deserialize(std::uint8_t& value) = 0;
virtual void Deserialize(std::uint16_t& value) = 0;
virtual void Deserialize(std::uint32_t& value) = 0;
virtual void Deserialize(std::uint64_t& value) = 0;
virtual void Deserialize(std::string& value);
};

class NZSL_API Serializer : public AbstractSerializer
Expand All @@ -74,22 +74,22 @@ namespace nzsl
std::vector<std::uint8_t> m_data;
};

class NZSL_API Unserializer : public AbstractUnserializer
class NZSL_API Deserializer : public AbstractDeserializer
{
public:
inline Unserializer(const void* data, std::size_t dataSize);
Unserializer(const Unserializer&) = default;
Unserializer(Unserializer&&) noexcept = default;
~Unserializer() = default;

using AbstractUnserializer::Unserialize;
void Unserialize(std::uint8_t& value) override;
void Unserialize(std::uint16_t& value) override;
void Unserialize(std::uint32_t& value) override;
void Unserialize(std::uint64_t& value) override;

Unserializer& operator=(const Unserializer&) = default;
Unserializer& operator=(Unserializer&&) noexcept = default;
inline Deserializer(const void* data, std::size_t dataSize);
Deserializer(const Deserializer&) = default;
Deserializer(Deserializer&&) noexcept = default;
~Deserializer() = default;

using AbstractDeserializer::Deserialize;
void Deserialize(std::uint8_t& value) override;
void Deserialize(std::uint16_t& value) override;
void Deserialize(std::uint32_t& value) override;
void Deserialize(std::uint64_t& value) override;

Deserializer& operator=(const Deserializer&) = default;
Deserializer& operator=(Deserializer&&) noexcept = default;

private:
const std::uint8_t* m_ptr;
Expand Down
2 changes: 1 addition & 1 deletion include/NZSL/Serializer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace nzsl
return m_data;
}

inline Unserializer::Unserializer(const void* data, std::size_t dataSize)
inline Deserializer::Deserializer(const void* data, std::size_t dataSize)
{
m_ptr = static_cast<const std::uint8_t*>(data);
m_ptrEnd = m_ptr + dataSize;
Expand Down
Loading

0 comments on commit 9f65281

Please sign in to comment.