beginnings of binaryout
[henge/apc.git] / src / ir.h
1 /*!@file
2
3 \brief Intermediate Representation (IR) between Directory Structure and Engine
4 Input
5
6 \details The IR serves as a storage structure that is populated during the
7 parsing of the input directory structure. After parsing is complete,
8 the IR will be condensed (removed of excess allocated space) and then
9 output as the input for the engine. In this file we describe the
10 semantic actions that are called at each step, and the memory buffers
11 that they populate. See parser.y for the description on how the input
12 grammar is constructed, and where/when semantic actions are called.
13
14 All input values are duplicated internally and their memory may be
15 freed.
16
17 \author Jordan Lavatai
18 \date Aug 2016
19 ----------------------------------------------------------------------------*/
20 #ifndef _IR_H_
21 #define _IR_H_
22 #include <unitypes.h>
23 #include "apc.h"
24
25 typedef union ir_setdata_t* ir_setdata;
26 typedef struct ir_set_t* ir_set;
27 typedef struct ir_class_t* ir_class;
28 typedef struct ir_setld_t* ir_setld;
29 typedef struct ir_classld_t* ir_classld;
30 /* Classes and Sets
31 Classes are rooted at a special root class, representing the current working
32 directory at scan-time, named ".". The root class can always be identified
33 with ir_class_root, and children may be added to it. The add series of
34 functions will return a reference to the newly created object, which may also
35 be used the root for further add functions.
36
37 E.G.
38 ir_class x = ir_class_root();
39 x = ir_class_addchild(x, "mychild");
40 x = ir_class_addchild(x, "child of mychild");
41
42 Sets, like classes, must be rooted. Unlike classes, sets may be rooted on
43 other sets, in addition to classes. ir_class_addset will return a set rooted
44 on the class specified, while ir_set_addchild will return a set rooted on the
45 specified set.
46 */
47 ir_class ir_class_root(void);
48 ir_class ir_class_addchild(ir_class,const uint8_t*);
49 uint8_t* ir_class_name(ir_class);
50 ir_set ir_class_addset(ir_class,const uint8_t*);
51 ir_set ir_set_addchild(ir_set,const uint8_t*);
52 /* Set Data
53 Each set can contain up to FACING_MAX each of framesheets and mapsheets, one
54 sheet for each facing, per label. Each set can contain any number of audio
55 objects, supplied by label. Repeat assignment of conflicting data (e.g. two
56 SFACE framesheets assigned to the same set and label, or two audio objects
57 with the same label) causes an internal error.
58 Each set may also contain any number of link objects, which will be linked in
59 the order that they are encountered. At link time, repeated assignments of
60 conflicting data cause data to be silently overwritten for those sets. This
61 is an intentional side-effect of the linker.
62 Each setdata may have a path associated with it. If the data depends on the
63 data of an associated file at that path and no path is provided, the data
64 will be entered null.
65 */
66 enum ltype { OLINK, MLINK, VLINK, ALINK };
67 void ir_set_assign_data(ir_set,ir_setdata);
68 void ir_set_assign_ref(ir_set,uint32_t);
69 void ir_data_assign_path(ir_setdata,const uint8_t*);
70 ir_setdata ir_framesheet(const uint8_t*, apc_facing, int,int);
71 ir_setdata ir_mapsheet(const uint8_t*, apc_facing, int,int);
72 ir_setdata ir_audio(const uint8_t*);
73 ir_setdata ir_link(enum ltype,ir_setld,const uint8_t*);
74 /* Reference Linking Data
75 Create linking data to sets or classes that will be resolved at a later
76 stage. Class references can be created from an ir_class object, if
77 available, or from the root class. Set references can be created from a
78 64-bit integer ID, or from a class linking data and a child name. Once
79 created, both Class and Set link data can traverse children, specified by
80 name, which will be resolved at the linking stage as well.
81 */
82 ir_classld ir_classld_from_class(ir_class);
83 ir_classld ir_classld_from_root(void);
84 ir_classld ir_classld_addchild(ir_classld,const uint8_t*);
85 ir_setld ir_setld_from_ref(uint32_t);
86 ir_setld ir_setld_from_classld(ir_classld,const uint8_t*);
87 ir_setld ir_setld_addchild(ir_setld,const uint8_t*);
88 #endif //_IR_H_
89
90 int get_class_sibcount(ir_class);
91 int get_set_sibcount(ir_set);
92 int get_set_variants(ir_set);
93 ir_set get_class_root_set(ir_class);
94 ir_set get_set_nextsib(ir_set);
95 ir_set get_set_nextchild(ir_set);
96 ir_setdata get_set_frameboxes(ir_set);
97 ir_setdata get_set_links(ir_set);
98 uint8_t* get_set_name(ir_set);
99 long get_set_filepos(ir_set);
100 void set_set_filepos(ir_set, long);
101 ir_set get_set_from_ref(uint32_t);
102 ir_class get_class_nextchild(ir_class);
103 ir_class get_class_nextsib(ir_class);
104 uint8_t* get_class_name(ir_class);
105 uint8_t* get_link_name(ir_setdata);
106 ir_setdata get_link_nextsib(ir_setdata);
107 uint32_t get_link_ref(ir_setdata);
108 enum ltype get_link_type(ir_setdata);
109 ir_setdata get_framebox_nextsib(ir_setdata);
110 uint8_t* get_framebox_name(ir_setdata);
111 ir_setdata get_framebox_facing_framedata(ir_setdata, apc_facing);
112 ir_setdata get_framebox_facing_mapdata(ir_setdata, apc_facing);
113 int get_framedata_height(ir_setdata);
114 int get_framedata_width(ir_setdata);
115 uint8_t* get_framedata_name(ir_setdata);