ZT_VALUE(3)

πŸŽ€ zt_value(3) πŸŽ€

okay bestie, welcome to the local manual for zt_value and zt_value_kind β€” the variant type that carries data into claim verifiers. it's a LOCAL page, it's untitled in the fancy header sense, and it is so much more fun than it sounds. let's go πŸ’…


✨ NAME ✨

zt_value, zt_value_kind β€” variant type for passing data into claim verifiers


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <zt.h>

typedef struct zt_value { ... } zt_value;

so the struct is giving little container energy, and here's every single thing inside it:

  • zt_value_kind β€” kind β€” the discriminator for the union. she decides which member is the main character πŸ‘‘
  • const char * β€” source β€” the source code used to compute the value
  • union { ... } β€” as β€” the union containing the actual value
    • bool β€” as.boolean β€” value when used as ZT_BOOLEAN
    • int β€” as.integer β€” value when used as ZT_INTEGER
    • unsigned β€” as.unsigned_integer β€” value when used as ZT_UNSIGNED
    • int β€” as.rune β€” value when used as ZT_RUNE
    • const char * β€” as.string β€” value when used as ZT_STRING
    • const void * β€” as.pointer β€” value when used as ZT_POINTER
    • intmax_t β€” as.intmax β€” value when used as ZT_INTMAX
    • uintmax_t β€” as.uintmax β€” value when used as ZT_UINTMAX

and then the enum, which is literally the vibe check for the union:

typedef enum zt_value_kind { ... } zt_value_kind;
  • ZT_NOTHING β€” placeholder for unused values
  • ZT_BOOLEAN β€” zt_value.as.boolean is valid
  • ZT_INTEGER β€” zt_value.as.integer is valid (deprecated)
  • ZT_UNSIGNED β€” zt_value.as.unsigned_integer is valid (deprecated)
  • ZT_RUNE β€” zt_value.as.rune is valid
  • ZT_STRING β€” zt_value.as.string is valid
  • ZT_POINTER β€” zt_value.as.pointer is valid
  • ZT_INTMAX β€” zt_value.as.intmax is valid
  • ZT_UINTMAX β€” zt_value.as.uintmax is valid

πŸ’– DESCRIPTION πŸ’–

zt_value is a variant-like type that gets used to pass values around libzt internals. she's built from three things and you're gonna remember all three, fr fr: the kind enumeration, the as union, and the source string. that's the whole girl. ✨

zt_value_kind describes the type of verification function arguments.


🧚 IMPLEMENTATION NOTES 🧚

zt_value exists to pass packed values of several types from the test source code, through the zt_claim type, and into private verification functions that determine test outcome. yes bestie, she's a little courier 🫢

Tests using binary relations encode the operator as an argument of kind ZT_STRING.


πŸ’€ BUGS πŸ’€

On some architectures ZT_INTEGER and ZT_UNSIGNED are too short to handle size_t and ssize_t values correctly.

not me finding out they're too tiny 😭 they are now deprecated and automatically promoted to ZT_INTMAX and ZT_UINTMAX respectively.


🌈 SEE ALSO 🌈


πŸ“œ HISTORY πŸ“œ

zt_value and zt_value_kind first appeared in libzt 0.1

ZT_INTMAX, ZT_UINTMAX and the corresponding union members first appeared in libzt 0.3. glow-up era, honestly.


πŸ‘‘ AUTHORS πŸ‘‘

Zygmunt Krynicki <me@zygoon.pl>


and that's the whole page, bestie πŸŽ€ this one is from libzt 0.3.1, dated January 12, 2020 β€” slay, periodt πŸ’–