summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mfluadir/otfcc/lib/bk/bkblock.h
blob: fafa78a164437b6d246c23070c0a1bf6a9b72427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CARYLL_BK_BLOCK_H
#define CARYLL_BK_BLOCK_H

#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <limits.h>
#include "caryll/ownership.h"
#include "support/otfcc-alloc.h"
#include "caryll/buffer.h"

struct __caryll_bkblock;
typedef enum {
	bkover = 0,    // nothing
	b8 = 1,        // byte
	b16 = 2,       // short
	b32 = 3,       // long
	p16 = 0x10,    // 16-bit offset, p = pointer to block
	p32 = 0x11,    // 32-bit offset, p = pointer to block
	sp16 = 0x80,   // 16-bit offset, p = pointer to block, marked as compact
	sp32 = 0x81,   // 32-bit offset, p = pointer to block, marked as compact
	bkcopy = 0xFE, // Embed another block
	bkembed = 0xFF // Embed another block
} bk_CellType;
typedef enum { VISIT_WHITE, VISIT_GRAY, VISIT_BLACK } bk_cell_visit_state;

typedef struct {
	bk_CellType t;
	union {
		uint32_t z;
		struct __caryll_bkblock *p;
	};
} bk_Cell;

typedef struct __caryll_bkblock {
	bk_cell_visit_state _visitstate;
	uint32_t _index;
	uint32_t _height;
	uint32_t _depth;
	uint32_t length;
	uint32_t free;
	bk_Cell *cells;
} bk_Block;

bk_Block *_bkblock_init(void);
bk_Block *bk_new_Block(int type0, ...);
bk_Block *bk_push(bk_Block *b, int type0, ...);
bk_Block *bk_newBlockFromStringLen(size_t len, const char *str);
bk_Block *bk_newBlockFromBuffer(MOVE caryll_Buffer *buf);
bk_Block *bk_newBlockFromBufferCopy(OBSERVE caryll_Buffer *buf);
bool bk_cellIsPointer(bk_Cell *cell);
void bk_printBlock(bk_Block *b);

#endif