Skip to content

Commit

Permalink
Add default equality operators
Browse files Browse the repository at this point in the history
  • Loading branch information
RichLogan committed Nov 7, 2023
1 parent 8b0ceb2 commit 504a62e
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 12 deletions.
56 changes: 53 additions & 3 deletions include/gs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,27 @@
namespace gs
{
// Primitive types
struct VarUint { std::uint64_t value; };
struct VarInt { std::int64_t value; };
struct Float16 { float value; };
struct VarUint
{
std::uint64_t value;

auto operator<=>(const VarUint &other) const = default;
};

struct VarInt
{
std::int64_t value;

auto operator<=>(const VarInt &other) const = default;
};

struct Float16
{
float value;

auto operator<=>(const Float16 &other) const = default;
};

typedef float Float32;
typedef double Float64;
typedef std::uint8_t Uint8;
Expand Down Expand Up @@ -104,6 +122,8 @@ namespace gs
Float32 x;
Float32 y;
Float32 z;

auto operator<=>(const Loc1 &other) const = default;
};

struct Loc2
Expand All @@ -114,26 +134,34 @@ namespace gs
Float16 vy;
Float16 vx;
Float16 vz;

auto operator<=>(const Loc2 &other) const = default;
};

struct Norm1
{
Float16 x;
Float16 y;
Float16 z;

auto operator<=>(const Norm1 &other) const = default;
};

struct TextureUV1
{
VarUint u;
VarUint v;

auto operator<=>(const TextureUV1 &other) const = default;
};

struct Rot1
{
Float16 i;
Float16 j;
Float16 k;

auto operator<=>(const Rot1 &other) const = default;
};

struct Rot2
Expand All @@ -144,13 +172,17 @@ namespace gs
Float16 ei;
Float16 ej;
Float16 ek;

auto operator<=>(const Rot2 &other) const = default;
};

struct Transform1
{
Float16 tx;
Float16 ty;
Float16 tz;

auto operator<=>(const Transform1 &other) const = default;
};

struct Object1
Expand All @@ -162,11 +194,15 @@ namespace gs
Loc1 scale;
Boolean active;
std::optional<ObjectID> parent;

bool operator==(const Object1 &other) const = default;
};

struct HeadIPD1
{
Float16 ipd;

auto operator<=>(const HeadIPD1 &other) const = default;
};

struct Head1
Expand All @@ -176,6 +212,8 @@ namespace gs
Loc2 location;
Rot2 rotation;
std::optional<HeadIPD1> ipd;

bool operator==(const Head1 &other) const = default;
};

struct Mesh1
Expand All @@ -185,6 +223,8 @@ namespace gs
std::vector<Norm1> normals;
std::vector<TextureUV1> textures;
std::vector<VarUint> triangles;

bool operator==(const Mesh1 &other) const = default;
};

struct Hand1
Expand All @@ -194,6 +234,8 @@ namespace gs
Boolean left;
Loc2 location;
Rot2 rotation;

auto operator<=>(const Hand1 &other) const = default;
};

struct Thumb
Expand All @@ -202,6 +244,8 @@ namespace gs
Transform1 ip;
Transform1 mcp;
Transform1 cmc;

auto operator<=>(const Thumb &other) const = default;
};

struct Finger
Expand All @@ -211,6 +255,8 @@ namespace gs
Transform1 pip;
Transform1 mcp;
Transform1 cmc;

auto operator<=>(const Finger &other) const = default;
};

struct Hand2
Expand All @@ -226,12 +272,16 @@ namespace gs
Finger middle;
Finger ring;
Finger pinky;

auto operator<=>(const Hand2 &other) const = default;
};

struct UnknownObject
{
VarUint tag;
Blob data;

bool operator==(const UnknownObject &other) const = default;
};

// Variant type that can contain any object type
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_library(gse

set_target_properties(gse
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
target_compile_options(gse PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion test/test_databuffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_databuffer test_databuffer.cpp)

set_target_properties(test_databuffer
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_float/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_float test_float.cpp)

set_target_properties(test_float
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gs_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_gs_api test_gs_api.cpp)

set_target_properties(test_gs_api
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gs_decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_gs_decoder test_gs_decoder.cpp)

set_target_properties(test_gs_decoder
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gs_deserializer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_gs_deserializer test_gs_deserializer.cpp)

set_target_properties(test_gs_deserializer
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gs_encoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_gs_encoder test_gs_encoder.cpp)

set_target_properties(test_gs_encoder
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gs_serializer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_gs_serializer test_gs_serializer.cpp)

set_target_properties(test_gs_serializer
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down
2 changes: 1 addition & 1 deletion test/test_half_float/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(test_half_float test_half_float.cpp)

set_target_properties(test_half_float
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)

Expand Down

0 comments on commit 504a62e

Please sign in to comment.