X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fir.h;h=096c7602e308c4bbbf9a2f652bd3ef8f854485b0;hp=0d271b1dc671ff1408bbd790dfc7f8f1a8a0eae0;hb=db01318a8e246249ceea23255a6512ea8a5c00c2;hpb=1c75266c959f8168fb6a73b6fef22fc91a5affc7 diff --git a/src/ir.h b/src/ir.h old mode 100755 new mode 100644 index 0d271b1..096c760 --- a/src/ir.h +++ b/src/ir.h @@ -1,16 +1,115 @@ +/*!@file +\brief Intermediate Representation (IR) between Directory Structure and Engine + Input -/*!@file -\brief Intermediate Representation (IR) between Directory Structure and Engine Input \details The IR serves as a storage structure that is populated during the parsing of the input directory structure. After parsing is complete, - the IR will be condensed (removed of excess allocated space) and then - output as the input for the engine. In this file we describe the semantic actions - that are called at each step, and the memory buffers that they populate. - See parser.y for the description on how the input grammar is constructed, - and where/when semantic actions are called. - TODO: or just write it here. + the IR will be condensed (removed of excess allocated space) and then + output as the input for the engine. In this file we describe the + semantic actions that are called at each step, and the memory buffers + that they populate. See parser.y for the description on how the input + grammar is constructed, and where/when semantic actions are called. + + All input values are duplicated internally and their memory may be + freed. + \author Jordan Lavatai \date Aug 2016 ----------------------------------------------------------------------------*/ +#ifndef _IR_H_ +#define _IR_H_ +#include +#include "apc.h" + +typedef union ir_setdata_t* ir_setdata; +typedef struct ir_set_t* ir_set; +typedef struct ir_class_t* ir_class; +typedef struct ir_setld_t* ir_setld; +typedef struct ir_classld_t* ir_classld; +/* Classes and Sets + Classes are rooted at a special root class, representing the current working + directory at scan-time, named ".". The root class can always be identified + with ir_class_root, and children may be added to it. The add series of + functions will return a reference to the newly created object, which may also + be used the root for further add functions. + + E.G. + ir_class x = ir_class_root(); + x = ir_class_addchild(x, "mychild"); + x = ir_class_addchild(x, "child of mychild"); + + Sets, like classes, must be rooted. Unlike classes, sets may be rooted on + other sets, in addition to classes. ir_class_addset will return a set rooted + on the class specified, while ir_set_addchild will return a set rooted on the + specified set. +*/ +ir_class ir_class_root(void); +ir_class ir_class_addchild(ir_class,const uint8_t*); +uint8_t* ir_class_name(ir_class); +ir_set ir_class_addset(ir_class,const uint8_t*); +ir_set ir_set_addchild(ir_set,const uint8_t*); +/* Set Data + Each set can contain up to FACING_MAX each of framesheets and mapsheets, one + sheet for each facing, per label. Each set can contain any number of audio + objects, supplied by label. Repeat assignment of conflicting data (e.g. two + SFACE framesheets assigned to the same set and label, or two audio objects + with the same label) causes an internal error. + Each set may also contain any number of link objects, which will be linked in + the order that they are encountered. At link time, repeated assignments of + conflicting data cause data to be silently overwritten for those sets. This + is an intentional side-effect of the linker. + Each setdata may have a path associated with it. If the data depends on the + data of an associated file at that path and no path is provided, the data + will be entered null. +*/ +enum ltype { OLINK, MLINK, VLINK, ALINK }; +void ir_set_assign_data(ir_set,ir_setdata); +void ir_set_assign_ref(ir_set,uint32_t); +void ir_data_assign_path(ir_setdata,const uint8_t*); +ir_setdata ir_framesheet(const uint8_t*, apc_facing, int,int); +ir_setdata ir_mapsheet(const uint8_t*, apc_facing, int,int); +ir_setdata ir_audio(const uint8_t*); +ir_setdata ir_link(enum ltype,ir_setld,const uint8_t*); +/* Reference Linking Data + Create linking data to sets or classes that will be resolved at a later + stage. Class references can be created from an ir_class object, if + available, or from the root class. Set references can be created from a + 64-bit integer ID, or from a class linking data and a child name. Once + created, both Class and Set link data can traverse children, specified by + name, which will be resolved at the linking stage as well. +*/ +ir_classld ir_classld_from_class(ir_class); +ir_classld ir_classld_from_root(void); +ir_classld ir_classld_addchild(ir_classld,const uint8_t*); +ir_setld ir_setld_from_ref(uint32_t); +ir_setld ir_setld_from_classld(ir_classld,const uint8_t*); +ir_setld ir_setld_addchild(ir_setld,const uint8_t*); +#endif //_IR_H_ +int get_class_sibcount(ir_class); +int get_set_sibcount(ir_set); +int get_set_variants(ir_set); +ir_set get_class_root_set(ir_class); +ir_set get_set_nextsib(ir_set); +ir_set get_set_nextchild(ir_set); +ir_setdata get_set_frameboxes(ir_set); +ir_setdata get_set_links(ir_set); +uint8_t* get_set_name(ir_set); +long get_set_filepos(ir_set); +void set_set_filepos(ir_set, long); +ir_set get_set_from_ref(uint32_t); +ir_class get_class_nextchild(ir_class); +ir_class get_class_nextsib(ir_class); +uint8_t* get_class_name(ir_class); +uint8_t* get_link_name(ir_setdata); +ir_setdata get_link_nextsib(ir_setdata); +uint32_t get_link_ref(ir_setdata); +enum ltype get_link_type(ir_setdata); +ir_setdata get_framebox_nextsib(ir_setdata); +uint8_t* get_framebox_name(ir_setdata); +ir_setdata get_framebox_facing_framedata(ir_setdata, apc_facing); +ir_setdata get_framebox_facing_mapdata(ir_setdata, apc_facing); +int get_framedata_height(ir_setdata); +int get_framedata_width(ir_setdata); +uint8_t* get_framedata_name(ir_setdata);