Index: trunk/src/libcschem/attrib.c =================================================================== --- trunk/src/libcschem/attrib.c (revision 643) +++ trunk/src/libcschem/attrib.c (revision 644) @@ -125,17 +125,19 @@ vts0_append(&a->source, s.array); } -int csch_attrib_set(csch_attribs_t *attribs, int prio, const char *key, const char *val, const csch_source_arg_t source) +int csch_attrib_set(csch_attribs_t *attribs, int prio, const char *key, const char *val, const csch_source_arg_t source, csch_attrib_t **attr_out) { csch_attrib_t *a = htsp_get(attribs, key); if (a == NULL) { a = attr_alloc(csch_strdup(key), prio); + if (attr_out != NULL) htsp_set(attribs, a->key, a); } else { if (prio > a->prio) { append_src(a, prio, source, 1); + if (attr_out != NULL) *attr_out = a; return -1; } attr_free_val(a); @@ -142,5 +144,6 @@ } a->val = csch_strdup(val); append_src(a, prio, source, 0); + if (attr_out != NULL) *attr_out = a; return 0; } Index: trunk/src/libcschem/attrib.h =================================================================== --- trunk/src/libcschem/attrib.h (revision 643) +++ trunk/src/libcschem/attrib.h (revision 644) @@ -70,8 +70,9 @@ #define csch_attrib_get(attribs, key) htsp_get(attribs, key) /* Set a scalar attribute; the ptr version takes malloc()'d val and source; - return 0 on success (ptr means "use the ptr provided, don't strdup") */ -int csch_attrib_set(csch_attribs_t *attribs, int prio, const char *key, const char *val, const csch_source_arg_t source); + return 0 on write, -1 on failure or if the attrib didn't change because of prios + (ptr means "use the ptr provided, don't strdup") */ +int csch_attrib_set(csch_attribs_t *attribs, int prio, const char *key, const char *val, const csch_source_arg_t source, csch_attrib_t **attr_out); int csch_attrib_setptr(csch_attribs_t *attribs, int prio, const char *key, char *val, const csch_source_arg_t source); /* Same as above, but for arrays: overwrite an existing item */ Index: trunk/src/libcschem/cnc_any_obj.c =================================================================== --- trunk/src/libcschem/cnc_any_obj.c (revision 643) +++ trunk/src/libcschem/cnc_any_obj.c (revision 644) @@ -86,3 +86,24 @@ case CSCH_CTYPE_PEN: /* nop */ break; } } + +int csch_cobj_attrib_set(csch_sheet_t *sheet, csch_chdr_t *obj, int prio, const char *key, const char *val, const csch_source_arg_t source) +{ + csch_attrib_t *a; + int res = csch_attrib_set(&obj->attr, prio, key, val, source, &a); + if (res == 0) { /* attribute value changed */ + switch(obj->type) { + case CSCH_CTYPE_INVALID: abort(); + case CSCH_CTYPE_LINE: + case CSCH_CTYPE_ARC: + case CSCH_CTYPE_POLY: + case CSCH_CTYPE_BITMAP: + case CSCH_CTYPE_CONN: break; + case CSCH_CTYPE_GRP: + case CSCH_CTYPE_GRP_REF: csch_cgrp_attrib_update(sheet, (csch_cgrp_t *)obj, prio, a->key, a->val, source); break; + case CSCH_CTYPE_PEN: break; + } + } + return res; +} + Index: trunk/src/libcschem/cnc_any_obj.h =================================================================== --- trunk/src/libcschem/cnc_any_obj.h (revision 643) +++ trunk/src/libcschem/cnc_any_obj.h (revision 644) @@ -29,5 +29,6 @@ void csch_cobj_free(csch_chdr_t *obj); csch_chdr_t *csch_cobj_dup(csch_sheet_t *sheet, csch_cgrp_t *grp, const csch_chdr_t *src); void csch_cobj_update(csch_sheet_t *sheet, csch_chdr_t *src, int do_xform); +int csch_cobj_attrib_set(csch_sheet_t *sheet, csch_chdr_t *obj, int prio, const char *key, const char *val, const csch_source_arg_t source); Index: trunk/src/libcschem/cnc_grp.c =================================================================== --- trunk/src/libcschem/cnc_grp.c (revision 643) +++ trunk/src/libcschem/cnc_grp.c (revision 644) @@ -152,7 +152,13 @@ } } +void csch_cgrp_attrib_update(csch_sheet_t *sheet, csch_cgrp_t *grp, int prio, const char *key, const char *val, const csch_source_arg_t source) +{ + if (strcmp(key, "role") == 0) + grp->role = val; +} + /****************************************************************************/ csch_cgrp_t *csch_cgrp_ref_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) Index: trunk/src/libcschem/cnc_grp.h =================================================================== --- trunk/src/libcschem/cnc_grp.h (revision 643) +++ trunk/src/libcschem/cnc_grp.h (revision 644) @@ -35,6 +35,7 @@ void csch_cgrp_free(csch_cgrp_t *grp); csch_cgrp_t *csch_cgrp_get(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_cgrp_update(csch_sheet_t *sheet, csch_cgrp_t *grp, int do_xform); +void csch_cgrp_attrib_update(csch_sheet_t *sheet, csch_cgrp_t *grp, int prio, const char *key, const char *val, const csch_source_arg_t source); csch_cgrp_t *csch_cgrp_init(csch_sheet_t *sheet, csch_cgrp_t *grp, csch_cgrp_t *parent, csch_oid_t oid); Index: trunk/src/plugins/export_animator/export_animator.c =================================================================== --- trunk/src/plugins/export_animator/export_animator.c (revision 643) +++ trunk/src/plugins/export_animator/export_animator.c (revision 644) @@ -32,6 +32,7 @@ #include #include #include +#include #include static csch_plug_io_t eanim; Index: trunk/src/plugins/io_lihata/read.c =================================================================== --- trunk/src/plugins/io_lihata/read.c (revision 643) +++ trunk/src/plugins/io_lihata/read.c (revision 644) @@ -55,7 +55,7 @@ /*** low level field parsing ***/ -static int parse_attribs(read_ctx_t *ctx, csch_attribs_t *dst, lht_node_t *subtree) +static int parse_attribs(read_ctx_t *ctx, csch_chdr_t *dsth, csch_attribs_t *dsta, lht_node_t *subtree) { lht_node_t *n; lht_dom_iterator_t it; @@ -78,7 +78,10 @@ error(n, ("invalid node type for an attribute")); } sprintf(ctx->loc_volatile, "%d.%d", n->line, n->col); - csch_attrib_set(dst, prio, n->name, val, ctx->src); + if (dsth != NULL) + csch_cobj_attrib_set(dsth, prio, n->name, val, ctx->src); + else + csch_attrib_set(dsta, prio, n->name, val, ctx->src, NULL); } return 0; } @@ -372,7 +375,7 @@ return -1; if (parse_pen_shape(ctx, &pen->shape, lht_dom_hash_get(ndpen, "shape")) != 0) return -1; - if (parse_attribs(ctx, &pen->hdr.attr, lht_dom_hash_get(ndpen, "attrib")) != 0) + if (parse_attribs(ctx, &pen->hdr, NULL, lht_dom_hash_get(ndpen, "attrib")) != 0) return -1; } return 0; @@ -428,7 +431,7 @@ return -1; } - if (parse_attribs(ctx, &grp->hdr.attr, lht_dom_hash_get(subtree, "attrib")) != 0) + if (parse_attribs(ctx, &grp->hdr, NULL, lht_dom_hash_get(subtree, "attrib")) != 0) return -1; if (parse_pens(ctx, grp, lht_dom_hash_get(subtree, "pens")) != 0) @@ -470,7 +473,7 @@ return -1; } - if (parse_attribs(ctx, &grp->hdr.attr, lht_dom_hash_get(subtree, "attrib")) != 0) + if (parse_attribs(ctx, &grp->hdr, NULL, lht_dom_hash_get(subtree, "attrib")) != 0) return -1; if (parse_coord(ctx, &grp->xc, lht_dom_hash_get(subtree, "xc")) != 0) @@ -499,7 +502,7 @@ #warning TODO: decide where to read these from: /* parse_uid(&ctx->sheet->uid, lht_dom_hash_get(subtree, "uid")); - if (parse_attribs(ctx, &ctx->sheet->direct.hdr.attr, lht_dom_hash_get(subtree, "attrib")) != 0) + if (parse_attribs(ctx, &ctx->sheet->direct.hdr, NULL, lht_dom_hash_get(subtree, "attrib")) != 0) return -1;*/ if (parse_root_group(ctx, &ctx->sheet->indirect, lht_dom_hash_get(subtree, "obj_indirect.1"), 1) != 0)