beginnings of binaryout
[henge/apc.git] / src / ir.h
old mode 100755 (executable)
new mode 100644 (file)
index 0d271b1..096c760
--- a/src/ir.h
+++ b/src/ir.h
+/*!@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
+typedef union ir_setdata_t*  ir_setdata;\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_set_addchild(ir_set,const uint8_t*);\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
+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
+/* 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
+#endif //_IR_H_\r
 \r
+int get_class_sibcount(ir_class);\r
+int get_set_sibcount(ir_set);\r
+int get_set_variants(ir_set);\r
+ir_set get_class_root_set(ir_class);\r
+ir_set get_set_nextsib(ir_set);\r
+ir_set get_set_nextchild(ir_set);\r
+ir_setdata get_set_frameboxes(ir_set);\r
+ir_setdata get_set_links(ir_set);\r
+uint8_t* get_set_name(ir_set);\r
+long get_set_filepos(ir_set);\r
+void set_set_filepos(ir_set, long);\r
+ir_set get_set_from_ref(uint32_t);\r
+ir_class get_class_nextchild(ir_class);\r
+ir_class get_class_nextsib(ir_class);\r
+uint8_t* get_class_name(ir_class);\r
+uint8_t* get_link_name(ir_setdata);\r
+ir_setdata get_link_nextsib(ir_setdata);\r
+uint32_t get_link_ref(ir_setdata);\r
+enum ltype get_link_type(ir_setdata);\r
+ir_setdata get_framebox_nextsib(ir_setdata);\r
+uint8_t* get_framebox_name(ir_setdata);\r
+ir_setdata get_framebox_facing_framedata(ir_setdata, apc_facing);\r
+ir_setdata get_framebox_facing_mapdata(ir_setdata, apc_facing);\r
+int get_framedata_height(ir_setdata);\r
+int get_framedata_width(ir_setdata);\r
+uint8_t* get_framedata_name(ir_setdata);\r