+/*!@file\r
\r
+\brief Intermediate Representation (IR) between Directory Structure and Engine\r
+ Input\r
\r
-/*!@file\r
-\brief Intermediate Representation (IR) between Directory Structure and Engine Input\r
\details The IR serves as a storage structure that is populated during the\r
parsing of the input directory structure. After parsing is complete,\r
- the IR will be condensed (removed of excess allocated space) and then\r
- output as the input for the engine. In this file we describe the semantic actions\r
- that are called at each step, and the memory buffers that they populate.\r
- See parser.y for the description on how the input grammar is constructed,\r
- and where/when semantic actions are called.\r
- TODO: or just write it here.\r
+ the IR will be condensed (removed of excess allocated space) and then \r
+ output as the input for the engine. In this file we describe the\r
+ semantic actions that are called at each step, and the memory buffers\r
+ that they populate. See parser.y for the description on how the input\r
+ grammar is constructed, and where/when semantic actions are called.\r
+\r
+ All input values are duplicated internally and their memory may be\r
+ freed.\r
+\r
\author Jordan Lavatai\r
\date Aug 2016\r
----------------------------------------------------------------------------*/\r
+#ifndef _IR_H_\r
+#define _IR_H_\r
+#include <unitypes.h>\r
+#include "apc.h"\r
+\r
+struct ir_frameinfo_t\r
+{ int facing, w, h; };\r
+typedef union ir_setdata_t* ir_setdata;\r
+typedef struct ir_frameinfo_t* ir_frameinfo;\r
+typedef struct ir_set_t* ir_set;\r
+typedef struct ir_class_t* ir_class;\r
+typedef struct ir_setld_t* ir_setld;\r
+typedef struct ir_classld_t* ir_classld;\r
+/* Classes and Sets\r
+ Classes are rooted at a special root class, representing the current working\r
+ directory at scan-time, named ".". The root class can always be identified\r
+ with ir_class_root, and children may be added to it. The add series of\r
+ functions will return a reference to the newly created object, which may also\r
+ be used the root for further add functions.\r
+\r
+ E.G.\r
+ ir_class x = ir_class_root();\r
+ x = ir_class_addchild(x, "mychild");\r
+ x = ir_class_addchild(x, "child of mychild");\r
\r
+ Sets, like classes, must be rooted. Unlike classes, sets may be rooted on\r
+ other sets, in addition to classes. ir_class_addset will return a set rooted\r
+ on the class specified, while ir_set_addchild will return a set rooted on the\r
+ specified set.\r
+*/\r
+ir_class ir_class_root(void);\r
+ir_class ir_class_addchild(ir_class,const uint8_t*);\r
+uint8_t* ir_class_name(ir_class);\r
+ir_set ir_class_addset(ir_class,const uint8_t*);\r
+ir_set ir_class_rootset(ir_class);\r
+ir_set ir_set_addchild(ir_set,const uint8_t*);\r
+uint8_t* ir_set_name(ir_set);\r
+/* Output */\r
+ir_class ir_class_nextsib(ir_class);\r
+ir_class ir_class_nextchild(ir_class);\r
+long ir_class_fpos(ir_class);\r
+void ir_class_assign_fpos(ir_class,long);\r
+ir_set ir_set_from_ref(uint32_t);\r
+ir_set ir_set_nextsib(ir_set);\r
+ir_set ir_set_nextchild(ir_set);\r
+long ir_set_fpos(ir_set);\r
+void ir_set_assign_fpos(ir_set,long);\r
+/* Set Data\r
+ Each set can contain up to FACING_MAX each of framesheets and mapsheets, one\r
+ sheet for each facing, per label. Each set can contain any number of audio\r
+ objects, supplied by label. Repeat assignment of conflicting data (e.g. two\r
+ SFACE framesheets assigned to the same set and label, or two audio objects\r
+ with the same label) causes an internal error.\r
+ Each set may also contain any number of link objects, which will be linked in\r
+ the order that they are encountered. At link time, repeated assignments of\r
+ conflicting data cause data to be silently overwritten for those sets. This\r
+ is an intentional side-effect of the linker.\r
+ Each setdata may have a path associated with it. If the data depends on the\r
+ data of an associated file at that path and no path is provided, the data\r
+ will be entered null.\r
+*/\r
+typedef ir_setdata framebox;\r
+typedef ir_setdata audiodata;\r
+typedef ir_setdata linkdata;\r
+typedef ir_setdata framedata;\r
+enum ltype { OLINK, MLINK, VLINK, ALINK };\r
+void ir_set_assign_data(ir_set,ir_setdata);\r
+void ir_set_assign_ref(ir_set,uint32_t);\r
+void ir_data_assign_path(ir_setdata,const uint8_t*);\r
+ir_setdata ir_framesheet(const uint8_t*, apc_facing, int,int);\r
+ir_setdata ir_mapsheet(const uint8_t*, apc_facing, int,int);\r
+ir_setdata ir_audio(const uint8_t*);\r
+ir_setdata ir_link(enum ltype,ir_setld,const uint8_t*);\r
+/* Output */\r
+framebox ir_set_framebox(ir_set);\r
+audiodata ir_set_audio(ir_set);\r
+linkdata ir_set_link(ir_set);\r
+enum ltype ir_linkdata_type(linkdata);\r
+uint32_t ir_linkdata_ref(linkdata);\r
+ir_set ir_linkdata_set(linkdata);\r
+void ir_linkdata_assign_set(ir_set);\r
+ir_setdata ir_setdata_nextsib(ir_setdata);\r
+uint8_t* ir_setdata_name(ir_setdata);\r
+uint8_t* ir_setdata_filename(ir_setdata);\r
+long ir_setdata_fpos(ir_setdata);\r
+void ir_setdata_assign_fpos(ir_setdata,long);\r
+framedata ir_framebox_framesheet(framebox,apc_facing);\r
+framedata ir_framebox_mapsheet(framebox,apc_facing);\r
+ir_frameinfo ir_framedata_frameinfo(framedata);\r
+/* Reference Linking Data \r
+ Create linking data to sets or classes that will be resolved at a later\r
+ stage. Class references can be created from an ir_class object, if\r
+ available, or from the root class. Set references can be created from a\r
+ 64-bit integer ID, or from a class linking data and a child name. Once\r
+ created, both Class and Set link data can traverse children, specified by\r
+ name, which will be resolved at the linking stage as well.\r
+*/\r
+ir_classld ir_classld_from_class(ir_class);\r
+ir_classld ir_classld_from_root(void);\r
+ir_classld ir_classld_addchild(ir_classld,const uint8_t*);\r
+ir_setld ir_setld_from_ref(uint32_t);\r
+ir_setld ir_setld_from_classld(ir_classld,const uint8_t*);\r
+ir_setld ir_setld_addchild(ir_setld,const uint8_t*);\r
+/* Output */\r
+enum ltype ir_setld_type(ir_setld);\r
+uint32_t ir_setld_ref(ir_setld);\r
+#endif //_IR_H_\r