1 2 3 typedef struct data_panel data_panel; 4 typedef struct type_union type_union; 5 6 typedef enum type_val { 7 T_END = 0, 8 T_INT, 9 T_FLOAT, 10 T_CHAR, 11 T_STRING 12 } type_val; 13 14 struct type_union 15 { 16 type_val t; 17 union { 18 float f; 19 int i; 20 char c; 21 const char *s; 22 } u; 23 }; 24 25 extern type_union i2u(int i); 26 extern type_union f2u(float f); 27 extern type_union c2u(char c); 28 extern type_union s2u(const char *s); 29 30 static const type_union END = { T_END, { 0 } }; 31 32 /* 33 * Helper classes for the display of typed data 34 */ 35 36 #define MAX_FMT 2 37 struct data_panel 38 { 39 byte color; 40 const char *label; 41 const char *fmt; /* printf format argument */ 42 type_union value[MAX_FMT]; /* (short) arugment list */ 43 }; 44 45