1 #ifdef CREATE_STRUCT_DEFINITIONS
2 #undef CREATE_STRUCT_DEFINITIONS
3 #define START(funcname, structname) \
4 typedef struct structname {
5 #define GENERIC(type, member) \
7 #define FTVECTOR(member) \
9 #define END(typedefnamename) \
12 #elif defined(CREATE_COMPARISON_FUNCTIONS)
13 #undef CREATE_COMPARISON_FUNCTIONS
14 #define START(funcname, structname) \
15 static int funcname##_compare(void *key1, void *key2, size_t key_size) \
17 struct structname *a = key1; \
18 struct structname *b = key2; \
19 return // conditions follow
20 #define GENERIC(type, member) \
21 a->member == b->member &&
22 #define FTVECTOR(member) \
23 a->member.x == b->member.x && a->member.y == b->member.y &&
24 #define END(typedefname) \
28 #elif defined(CREATE_HASH_FUNCTIONS)
29 #undef CREATE_HASH_FUNCTIONS
30 #define START(funcname, structname) \
31 static unsigned funcname##_hash(void *buf, size_t len) \
33 struct structname *p = buf; \
34 unsigned hval = FNV1_32A_INIT;
35 #define GENERIC(type, member) \
36 hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
37 #define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
38 #define END(typedefname) \
43 #error missing defines
48 // describes a bitmap; bitmaps with equivalents structs are considered identical
49 START(bitmap
, bipmap_hash_key_s
)
50 GENERIC(char, bitmap
) // bool : true = bitmap, false = outline
51 GENERIC(ass_font_t
*, font
)
52 GENERIC(double, size
) // font size
53 GENERIC(uint32_t, ch
) // character code
54 GENERIC(unsigned, outline
) // border width, 16.16 fixed point value
57 GENERIC(char, be
) // blur edges
58 GENERIC(unsigned, scale_x
) // 16.16
59 GENERIC(unsigned, scale_y
) // 16.16
60 GENERIC(int, frx
) // signed 16.16
61 GENERIC(int, fry
) // signed 16.16
62 GENERIC(int, frz
) // signed 16.16
63 // shift vector that was added to glyph before applying rotation
64 // = 0, if frx = fry = frx = 0
65 // = (glyph base point) - (rotation origin), otherwise
68 FTVECTOR(advance
) // subpixel shift vector
69 END(bitmap_hash_key_t
)
71 // describes an outline glyph
72 START(glyph
, glyph_hash_key_s
)
73 GENERIC(ass_font_t
*, font
)
74 GENERIC(double, size
) // font size
75 GENERIC(uint32_t, ch
) // character code
78 GENERIC(unsigned, scale_x
) // 16.16
79 GENERIC(unsigned, scale_y
) // 16.16
80 FTVECTOR(advance
) // subpixel shift vector
81 GENERIC(unsigned, outline
) // border width, 16.16