Skip to content

Commit

Permalink
lone/types: improve endian writer macros
Browse files Browse the repository at this point in the history
Define curried, partially applied versions to make them combinatorial.
Even less repetition and editing!
  • Loading branch information
matheusmoreira committed Jul 8, 2024
1 parent 878230a commit a423e6d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions source/lone/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,21 @@ LONE_ENDIAN_SIGNED_READERS_FOR_BITS(16)
LONE_ENDIAN_SIGNED_READERS_FOR_BITS(32) \
LONE_ENDIAN_SIGNED_READERS_FOR_BITS(64) \

LONE_ENDIAN_SIGNED_READERS()
#define LONE_ENDIAN_SIGNED_WRITERS_FOR_BITS(bits) \
LONE_ENDIAN_SIGNED_WRITER(bits, le) \
LONE_ENDIAN_SIGNED_WRITER(bits, be) \

#define LONE_ENDIAN_SIGNED_WRITERS() \
LONE_ENDIAN_SIGNED_WRITERS_FOR_BITS(16) \
LONE_ENDIAN_SIGNED_WRITERS_FOR_BITS(32) \
LONE_ENDIAN_SIGNED_WRITERS_FOR_BITS(64) \

LONE_ENDIAN_SIGNED_WRITER(16, le)
LONE_ENDIAN_SIGNED_WRITER(16, be)
LONE_ENDIAN_SIGNED_WRITER(32, le)
LONE_ENDIAN_SIGNED_WRITER(32, be)
LONE_ENDIAN_SIGNED_WRITER(64, le)
LONE_ENDIAN_SIGNED_WRITER(64, be)
LONE_ENDIAN_SIGNED_READERS()
LONE_ENDIAN_SIGNED_WRITERS()

#undef LONE_ENDIAN_SIGNED_READER
#undef LONE_ENDIAN_SIGNED_READERS_FOR_BITS
#undef LONE_ENDIAN_SIGNED_READERS
#undef LONE_ENDIAN_SIGNED_WRITER
#undef LONE_ENDIAN_SIGNED_WRITERS_FOR_BITS
#undef LONE_ENDIAN_SIGNED_WRITERS

0 comments on commit a423e6d

Please sign in to comment.