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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
typedef struct fz_obj_s fz_obj;
typedef enum fz_objkind_e
{
FZ_NULL,
FZ_BOOL,
FZ_INT,
FZ_REAL,
FZ_STRING,
FZ_NAME,
FZ_ARRAY,
FZ_DICT,
FZ_INDIRECT,
FZ_POINTER
} fz_objkind;
struct fz_keyval_s
{
fz_obj *k;
fz_obj *v;
};
struct fz_obj_s
{
unsigned short refs;
unsigned short kind; /* fz_objkind takes 4 bytes :( */
union
{
int b;
int i;
float f;
struct {
unsigned short len;
char buf[1];
} s;
char n[1];
struct {
int len;
int cap;
fz_obj **items;
} a;
struct {
int len;
int cap;
struct fz_keyval_s *items;
} d;
struct {
int oid;
int gid;
} r;
void *p;
} u;
};
fz_error *fz_newnull(fz_obj **op);
fz_error *fz_newbool(fz_obj **op, int b);
fz_error *fz_newint(fz_obj **op, int i);
fz_error *fz_newreal(fz_obj **op, float f);
fz_error *fz_newname(fz_obj **op, char *str);
fz_error *fz_newstring(fz_obj **op, char *str, int len);
fz_error *fz_newindirect(fz_obj **op, int oid, int gid);
fz_error *fz_newpointer(fz_obj **op, void *p);
fz_error *fz_newarray(fz_obj **op, int initialcap);
fz_error *fz_newdict(fz_obj **op, int initialcap);
fz_error *fz_copyarray(fz_obj **op, fz_obj *array);
fz_error *fz_copydict(fz_obj **op, fz_obj *dict);
fz_error *fz_deepcopyarray(fz_obj **op, fz_obj *array);
fz_error *fz_deepcopydict(fz_obj **op, fz_obj *dict);
fz_obj *fz_keepobj(fz_obj *obj);
void fz_dropobj(fz_obj *obj);
/* type queries */
int fz_isnull(fz_obj *obj);
int fz_isbool(fz_obj *obj);
int fz_isint(fz_obj *obj);
int fz_isreal(fz_obj *obj);
int fz_isname(fz_obj *obj);
int fz_isstring(fz_obj *obj);
int fz_isarray(fz_obj *obj);
int fz_isdict(fz_obj *obj);
int fz_isindirect(fz_obj *obj);
int fz_ispointer(fz_obj *obj);
int fz_cmpobj(fz_obj *a, fz_obj *b);
/* silent failure, no error reporting */
int fz_tobool(fz_obj *obj);
int fz_toint(fz_obj *obj);
float fz_toreal(fz_obj *obj);
char *fz_toname(fz_obj *obj);
char *fz_tostringbuf(fz_obj *obj);
int fz_tostringlen(fz_obj *obj);
int fz_tonum(fz_obj *obj);
int fz_togen(fz_obj *obj);
void *fz_topointer(fz_obj *obj);
int fz_arraylen(fz_obj *array);
fz_obj *fz_arrayget(fz_obj *array, int i);
fz_error *fz_arrayput(fz_obj *array, int i, fz_obj *obj);
fz_error *fz_arraypush(fz_obj *array, fz_obj *obj);
int fz_dictlen(fz_obj *dict);
fz_obj *fz_dictgetkey(fz_obj *dict, int idx);
fz_obj *fz_dictgetval(fz_obj *dict, int idx);
fz_obj *fz_dictget(fz_obj *dict, fz_obj *key);
fz_obj *fz_dictgets(fz_obj *dict, char *key);
fz_obj *fz_dictgetsa(fz_obj *dict, char *key, char *abbrev);
fz_error *fz_dictput(fz_obj *dict, fz_obj *key, fz_obj *val);
fz_error *fz_dictputs(fz_obj *dict, char *key, fz_obj *val);
fz_error *fz_dictdel(fz_obj *dict, fz_obj *key);
fz_error *fz_dictdels(fz_obj *dict, char *key);
int fz_sprintobj(char *s, int n, fz_obj *obj, int tight);
void fz_debugobj(fz_obj *obj);
fz_error *fz_parseobj(fz_obj **objp, char *s);
fz_error *fz_packobj(fz_obj **objp, char *fmt, ...);
fz_error *fz_unpackobj(fz_obj *obj, char *fmt, ...);
|