Debian Codegraph @

texk/web2c/mfluadir/otfcc/lib/table/otl/subtables/chaining/parse.c

raw
1 #include "../chaining.h"
2
3 otl_Subtable *otl_parse_chaining(const json_value *_subtable, const otfcc_Options *options) {
4 json_value *_match = json_obj_get_type(_subtable, "match", json_array);
5 json_value *_apply = json_obj_get_type(_subtable, "apply", json_array);
6 if (!_match || !_apply) return NULL;
7
8 subtable_chaining *subtable = iSubtable_chaining.create();
9 subtable->type = otl_chaining_canonical;
10
11 otl_ChainingRule *rule = &subtable->rule;
12
13 rule->matchCount = _match->u.array.length;
14 NEW(rule->match, rule->matchCount);
15 rule->applyCount = _apply->u.array.length;
16 NEW(rule->apply, rule->applyCount);
17
18 rule->inputBegins = json_obj_getnum_fallback(_subtable, "inputBegins", 0);
19 rule->inputEnds = json_obj_getnum_fallback(_subtable, "inputEnds", rule->matchCount);
20
21 for (tableid_t j = 0; j < rule->matchCount; j++) {
22 rule->match[j] = Coverage.parse(_match->u.array.values[j]);
23 }
24 for (tableid_t j = 0; j < rule->applyCount; j++) {
25 rule->apply[j].index = 0;
26 rule->apply[j].lookup = Handle.empty();
27 json_value *_application = _apply->u.array.values[j];
28 if (_application->type == json_object) {
29 json_value *_ln = json_obj_get_type(_application, "lookup", json_string);
30 if (_ln) {
31 rule->apply[j].lookup = Handle.fromName(sdsnewlen(_ln->u.string.ptr, _ln->u.string.length));
32 rule->apply[j].index = json_obj_getnum(_application, "at");
33 }
34 }
35 }
36 return (otl_Subtable *)subtable;
37 }