git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

HexFiend/HFGlyphTrie.h

      1 /* HFGlyphTrie is used to represent a trie of glyphs that allows multiple concurrent readers, along with one writer. */
      2 
      3 #import <ApplicationServices/ApplicationServices.h>
      4 
      5 /* BranchFactor is in bits */
      6 #define kHFGlyphTrieBranchFactor 4
      7 #define kHFGlyphTrieBranchCount (1 << kHFGlyphTrieBranchFactor)
      8 
      9 typedef uint16_t HFGlyphFontIndex;
     10 #define kHFGlyphFontIndexInvalid ((HFGlyphFontIndex)(-1))
     11 
     12 #define kHFGlyphInvalid kCGFontIndexInvalid
     13 
     14 struct HFGlyph_t {
     15     HFGlyphFontIndex fontIndex;
     16     CGGlyph glyph;
     17 };
     18 
     19 static inline BOOL HFGlyphEqualsGlyph(struct HFGlyph_t a, struct HFGlyph_t b) __attribute__((unused));
     20 static inline BOOL HFGlyphEqualsGlyph(struct HFGlyph_t a, struct HFGlyph_t b) {
     21     return a.glyph == b.glyph && a.fontIndex == b.fontIndex;
     22 }
     23 
     24 struct HFGlyphTrieBranch_t {
     25     __strong void *children[kHFGlyphTrieBranchCount];
     26 };
     27 
     28 struct HFGlyphTrieLeaf_t {
     29     struct HFGlyph_t glyphs[kHFGlyphTrieBranchCount];
     30 };
     31 
     32 struct HFGlyphTrie_t {
     33     uint8_t branchingDepth;
     34     struct HFGlyphTrieBranch_t root;
     35 };
     36 
     37 /* Initializes a trie witha  given key size */
     38 __private_extern__ void HFGlyphTrieInitialize(struct HFGlyphTrie_t *trie, uint8_t keySize);
     39 
     40 /* Inserts a glyph into the trie */
     41 __private_extern__ void HFGlyphTrieInsert(struct HFGlyphTrie_t *trie, NSUInteger key, struct HFGlyph_t value);
     42 
     43 /* Attempts to fetch a glyph.  If the glyph is not present, returns an HFGlyph_t set to all bits 0. */
     44 __private_extern__ struct HFGlyph_t HFGlyphTrieGet(const struct HFGlyphTrie_t *trie, NSUInteger key);
     45 
     46 /* Frees all storage associated with a glyph tree.  This is not necessary to call under GC. */
     47 __private_extern__ void HFGlyphTreeFree(struct HFGlyphTrie_t * trie);
     48 
     49 

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.