From: ken Date: Thu, 16 Feb 2017 01:34:16 +0000 (-0800) Subject: fixes X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=commitdiff_plain;h=3dead973a71aae59d2cb04205f8ae64ab7fc6fcd;hp=c02ac2539fe718add1da1103cd63c7fb191985bf fixes --- diff --git a/src/ir.c b/src/ir.c index ac47a85..c59441a 100644 --- a/src/ir.c +++ b/src/ir.c @@ -44,13 +44,14 @@ struct ir_classld_t }; struct ir_setld_t { struct ir_classld_t* classld; - long long ref; + uint32_t ref; struct ir_namelist_t* namelist, * namelist_head; }; struct ir_setdata_header_t { enum dtype type; uint8_t* src_filename, * data_name; union ir_setdata_t* nextsib; + long filepos; }; struct ir_framedata_t { struct ir_setdata_header_t header; @@ -80,6 +81,7 @@ struct ir_class_t { struct ir_class_t* nextchild, * nextsib; struct ir_set_t* root_set; uint8_t* name; + long filepos; }; struct ir_set_t { struct ir_set_t* nextchild, * nextsib; @@ -88,7 +90,7 @@ struct ir_set_t struct ir_framebox_t* frameboxes; struct ir_simplex_t* audio; struct ir_link_t* links; - long filepos; + long filepos; }; /* Functions */ static inline @@ -220,6 +222,11 @@ struct ir_set_t* ir_class_addset return iter->nextsib; } +/* Get the root set of the class */ +struct ir_set_t* ir_class_rootset +( struct ir_class_t* class ) +{ return class->root_set; } + struct ir_set_t* ir_set_from_ref ( uint32_t ref ) { uint16_t hash; @@ -328,6 +335,55 @@ int classnames_identical return (ca == cb); } +/* Return the name of the set */ +uint8_t* ir_set_name +( struct ir_set_t* set) +{ return set->name; } + +/* Return the next sib of the class */ +struct ir_class_t* ir_class_nextsib +( struct ir_class_t* class ) +{ return class->nextsib; } + +/* Return the next sib of the class */ +struct ir_class_t* ir_class_nextchild +( struct ir_class_t* class ) +{ return class->nextchild; } + +/* Get the file position of the class */ +long ir_class_fpos +( struct ir_class_t* class ) +{ return class->filepos; } + +/* Set the file position of the class */ +void ir_class_assign_fpos +( struct ir_class_t* class, + long newpos +) +{ class->filepos = newpos; } + +/* Get the next sibling of the provided set */ +struct ir_set_t* ir_set_nextsib +( struct ir_set_t* set ) +{ return set->nextsib; } + +/* Get the next child of the provided set */ +struct ir_set_t* ir_set_nextchild +( struct ir_set_t* set ) +{ return set->nextchild; } + +/* Get the file position of the class */ +long ir_set_fpos +( struct ir_set_t* set ) +{ return set->filepos; } + +/* Set the file position of the class */ +void ir_set_assign_fpos +( struct ir_set_t* set, + long newpos +) +{ set->filepos = newpos; } + /* Assign Setdata to Set */ void ir_set_assign_data ( struct ir_set_t* set, @@ -544,7 +600,93 @@ union ir_setdata_t* ir_link return (union ir_setdata_t*) link; } +/* Return a set's root framebox */ +union ir_setdata_t* ir_set_framebox +( struct ir_set_t* set ) +{ return (union ir_setdata_t*) set->frameboxes; } + +/* Return a set's root audio data */ +union ir_setdata_t* ir_set_audio +( struct ir_set_t* set ) +{ return (union ir_setdata_t*) set->audio; } + +/* Return a set's root link data */ +union ir_setdata_t* ir_set_link +( struct ir_set_t* set ) +{ return (union ir_setdata_t*) set->links; } + +/* Return the link type */ +enum ltype ir_linkdata_type +( union ir_setdata_t* linkdata ) +{ if (linkdata->header.type != LDAT) + eprintf("Data %s is not a link\n", linkdata->header.data_name); + return linkdata->link.type; +} + +/* Return the link type */ +uint32_t ir_linkdata_ref +( union ir_setdata_t* linkdata ) +{ if (linkdata->header.type != LDAT) + eprintf("Data %s is not a link\n", linkdata->header.data_name); + return linkdata->link.setld->ref; +} + +/* Get a setdata's next sibling */ +union ir_setdata_t* ir_setdata_nextsib +( union ir_setdata_t* setdata ) +{ return setdata->header.nextsib; } + +/* Get a setdata's name */ +uint8_t* ir_setdata_name +( union ir_setdata_t* setdata ) +{ return setdata->header.data_name; } + +/* Get a setdata's filename */ +uint8_t* ir_setdata_filename +( union ir_setdata_t* setdata ) +{ return setdata->header.src_filename; } + +/* Get a setdata's file position */ +long ir_setdata_fpos +( union ir_setdata_t* setdata ) +{ return setdata->header.filepos; } + +/* Set a setdata's file position */ +void ir_setdata_assign_fpos +( union ir_setdata_t* setdata, + long newpos +) +{ setdata->header.filepos = newpos; } + +/* Return a framebox's specified framesheet */ +union ir_setdata_t* ir_framebox_framesheet +( union ir_setdata_t* fbox, + apc_facing facing +) +{ if (fbox->header.type != FBDAT) + eprintf("Data %s is not a framebox\n", fbox->header.data_name); + return (union ir_setdata_t*) &fbox->framebox.framesheets[facing]; +} + +/* Return a framebox's specified mapsheet */ +union ir_setdata_t* ir_framebox_mapsheet +( union ir_setdata_t* fbox, + apc_facing facing +) +{ if (fbox->header.type != FBDAT) + eprintf("Data %s is not a framebox\n", fbox->header.data_name); + return (union ir_setdata_t*) &fbox->framebox.mapsheets[facing]; +} + +/* Return a framedata's frame info */ +struct ir_frameinfo_t* ir_framedata_mapsheet +( union ir_setdata_t* framedata ) +{ if (framedata->header.type != MSDAT && framedata->header.type != FSDAT) + eprintf("Data %s is not a framedata\n", framedata->header.data_name); + return &framedata->mapsheet.frameinfo; +} +/** Allocators **/ static uint8_t* name_alloc ( const uint8_t* name_src ) @@ -586,13 +728,15 @@ uint8_t* classname_alloc static void crawl_class(struct ir_class_t*); static void crawl_set(struct ir_set_t*,int); +extern +int binout_init(ir_class); void ir_test(void) { uprintf("IR From Directory: %s\n",getcwd(NULL,255)); crawl_class(&root_class); if (root_class.root_set != NULL) crawl_set(root_class.root_set, 0); uprintf("starting binaryout \n"); - ir_binout_init(&root_class); + binout_init(&root_class); } diff --git a/src/ir.h b/src/ir.h index ac57470..3086e5a 100644 --- a/src/ir.h +++ b/src/ir.h @@ -94,10 +94,12 @@ ir_setdata ir_link(enum ltype,ir_setld,const uint8_t*); framebox ir_set_framebox(ir_set); audiodata ir_set_audio(ir_set); linkdata ir_set_link(ir_set); +enum ltype ir_linkdata_type(linkdata); +uint32_t ir_linkdata_ref(linkdata); 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); +long ir_setdata_fpos(ir_setdata); void ir_setdata_assign_fpos(ir_setdata,long); framedata ir_framebox_framesheet(framebox,apc_facing); framedata ir_framebox_mapsheet(framebox,apc_facing);