X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fir.h;h=219fb2700bdcd5f7cc0371ccf2a5d6cd527edc2c;hp=0d271b1dc671ff1408bbd790dfc7f8f1a8a0eae0;hb=6766ae503921c5895a0063f29e005ab28a4c469c;hpb=dbce0e5aa9599ae86cb1aa33966b09b9dad3e810 diff --git a/src/ir.h b/src/ir.h index 0d271b1..219fb27 100644 --- a/src/ir.h +++ b/src/ir.h @@ -1,16 +1,121 @@ +/*!@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" + +struct ir_frameinfo_t +{ int facing, w, h; }; +typedef union ir_setdata_t* ir_setdata; +typedef struct ir_frameinfo_t* ir_frameinfo; +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*); +uint8_t* ir_set_name(ir_set); +/* Output */ +ir_class ir_class_nextsib(ir_class); +ir_class ir_class_nextchild(ir_class); +long ir_class_fpos(ir_class); +void ir_class_assign_fpos(ir_class,long); +ir_set ir_set_from_ref(uint32_t); +ir_set ir_set_nextsib(ir_set); +ir_set ir_set_nextchild(ir_set); +long ir_set_fpos(ir_set); +void ir_set_assign_fpos(ir_set,long); +/* 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. +*/ +typedef ir_setdata ir_framebox; +typedef ir_setdata ir_audio; +typedef ir_setdata ir_link; +typedef ir_setdata ir_framedata; +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*); +/* Output */ +ir_framebox ir_set_framebox(ir_set); +ir_audio ir_set_audio(ir_set); +ir_link ir_set_link(ir_set); +ir_setdata ir_setdata_nextsib(ir_setdata); +uint8_t* ir_setdata_name(ir_setdata); +uint8_t* ir_setdata_filename(ir_setdata); +long ir_setdata_fpos(void); +void ir_setdata_assign_fpos(ir_setdata,long); +ir_framedata ir_framebox_framesheet(ir_framebox,apc_facing); +ir_framedata ir_framebox_mapsheet(ir_framebox,apc_facing); +ir_frameinfo ir_framedata_frameinfo(ir_framedata); +/* 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*); +/* Output */ +enum ltype ir_setld_type(ir_setld); +uint32_t ir_setld_ref(ir_setld); +#endif //_IR_H_