Index: trunk/src/libcschem/concrete_arc.c =================================================================== --- trunk/src/libcschem/concrete_arc.c (revision 562) +++ trunk/src/libcschem/concrete_arc.c (revision 563) @@ -31,7 +31,7 @@ #include "concrete_obj.h" #include "gengeo2d/sarc.h" -csch_arc_t *csch_arc_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_arc_t *csch_arc_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_arc_t *arc; Index: trunk/src/libcschem/concrete_arc.h =================================================================== --- trunk/src/libcschem/concrete_arc.h (revision 562) +++ trunk/src/libcschem/concrete_arc.h (revision 563) @@ -41,7 +41,7 @@ unsigned evalid:1; } csch_arc_t; -csch_arc_t *csch_arc_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_arc_t *csch_arc_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_arc_free(csch_arc_t *arc); csch_arc_t *csch_arc_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/libcschem/concrete_bitmap.c =================================================================== --- trunk/src/libcschem/concrete_bitmap.c (revision 562) +++ trunk/src/libcschem/concrete_bitmap.c (revision 563) @@ -30,7 +30,7 @@ #include "concrete_obj.h" #include "concrete_bitmap.h" -csch_cbitmap_t *csch_cbitmap_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_cbitmap_t *csch_cbitmap_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_cbitmap_t *bitmap; Index: trunk/src/libcschem/concrete_bitmap.h =================================================================== --- trunk/src/libcschem/concrete_bitmap.h (revision 562) +++ trunk/src/libcschem/concrete_bitmap.h (revision 563) @@ -38,7 +38,7 @@ csch_pixel_t *bitmap; } csch_cbitmap_t; -csch_cbitmap_t *csch_cbitmap_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_cbitmap_t *csch_cbitmap_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_cbitmap_free(csch_cbitmap_t *bitmap); csch_cbitmap_t *csch_cbitmap_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/libcschem/concrete_conn.c =================================================================== --- trunk/src/libcschem/concrete_conn.c (revision 562) +++ trunk/src/libcschem/concrete_conn.c (revision 563) @@ -30,7 +30,7 @@ #include "concrete_obj.h" #include "concrete_conn.h" -csch_conn_t *csch_conn_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_conn_t *csch_conn_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_conn_t *conn; Index: trunk/src/libcschem/concrete_conn.h =================================================================== --- trunk/src/libcschem/concrete_conn.h (revision 562) +++ trunk/src/libcschem/concrete_conn.h (revision 563) @@ -38,7 +38,7 @@ csch_oid_t gfx; } csch_conn_t; -csch_conn_t *csch_conn_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_conn_t *csch_conn_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_conn_free(csch_conn_t *conn); csch_conn_t *csch_conn_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/libcschem/concrete_grp.c =================================================================== --- trunk/src/libcschem/concrete_grp.c (revision 562) +++ trunk/src/libcschem/concrete_grp.c (revision 563) @@ -30,7 +30,7 @@ #include "concrete_grp.h" #include "concrete_obj.h" -csch_cgrp_t *csch_cgrp_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_cgrp_t *csch_cgrp_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_cgrp_t *grp; @@ -60,7 +60,7 @@ /****************************************************************************/ -csch_cgrp_ref_t *csch_cgrp_ref_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_cgrp_ref_t *csch_cgrp_ref_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_cgrp_ref_t *grp; Index: trunk/src/libcschem/concrete_grp.h =================================================================== --- trunk/src/libcschem/concrete_grp.h (revision 562) +++ trunk/src/libcschem/concrete_grp.h (revision 563) @@ -40,13 +40,13 @@ /*** standard calls on groups ***/ -csch_cgrp_t *csch_cgrp_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_cgrp_t *csch_cgrp_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_cgrp_free(csch_cgrp_t *grp); csch_cgrp_t *csch_cgrp_get(csch_sheet_t *sheet, csch_oid_t oid); /*** standard calls on group refs ***/ -csch_cgrp_ref_t *csch_cgrp_ref_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_cgrp_ref_t *csch_cgrp_ref_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_cgrp_ref_free(csch_cgrp_ref_t *grp); csch_cgrp_ref_t *csch_cgrp_ref_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/libcschem/concrete_line.c =================================================================== --- trunk/src/libcschem/concrete_line.c (revision 562) +++ trunk/src/libcschem/concrete_line.c (revision 563) @@ -31,7 +31,7 @@ #include "concrete_obj.h" #include "gengeo2d/sline.h" -csch_line_t *csch_line_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_line_t *csch_line_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_line_t *line; Index: trunk/src/libcschem/concrete_line.h =================================================================== --- trunk/src/libcschem/concrete_line.h (revision 562) +++ trunk/src/libcschem/concrete_line.h (revision 563) @@ -38,7 +38,7 @@ g2d_sline_t prim; } csch_line_t; -csch_line_t *csch_line_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_line_t *csch_line_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_line_free(csch_line_t *line); csch_line_t *csch_line_get(csch_sheet_t *sheet, csch_oid_t oid); void csch_line_update(csch_line_t *line); Index: trunk/src/libcschem/concrete_pen.c =================================================================== --- trunk/src/libcschem/concrete_pen.c (revision 562) +++ trunk/src/libcschem/concrete_pen.c (revision 563) @@ -38,7 +38,7 @@ }; -csch_cpen_t *csch_pen_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_cpen_t *csch_pen_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_cpen_t *pen; Index: trunk/src/libcschem/concrete_pen.h =================================================================== --- trunk/src/libcschem/concrete_pen.h (revision 562) +++ trunk/src/libcschem/concrete_pen.h (revision 563) @@ -44,7 +44,7 @@ unsigned int dash; }; -csch_cpen_t *csch_pen_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_cpen_t *csch_pen_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_pen_free(csch_cpen_t *pen); csch_cpen_t *csch_pen_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/libcschem/concrete_poly.c =================================================================== --- trunk/src/libcschem/concrete_poly.c (revision 562) +++ trunk/src/libcschem/concrete_poly.c (revision 563) @@ -30,7 +30,7 @@ #include "concrete_obj.h" #include "concrete_poly.h" -csch_cpoly_t *csch_cpoly_alloc(csch_sheet_t *sheet, csch_oid_t oid) +csch_cpoly_t *csch_cpoly_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid) { csch_cpoly_t *poly; Index: trunk/src/libcschem/concrete_poly.h =================================================================== --- trunk/src/libcschem/concrete_poly.h (revision 562) +++ trunk/src/libcschem/concrete_poly.h (revision 563) @@ -37,7 +37,7 @@ csch_vtcoutline_t outline; } csch_cpoly_t; -csch_cpoly_t *csch_cpoly_alloc(csch_sheet_t *sheet, csch_oid_t oid); +csch_cpoly_t *csch_cpoly_alloc(csch_sheet_t *sheet, csch_cgrp_t *parent, csch_oid_t oid); void csch_cpoly_free(csch_cpoly_t *poly); csch_cpoly_t *csch_cpoly_get(csch_sheet_t *sheet, csch_oid_t oid); Index: trunk/src/plugins/io_lihata/read.c =================================================================== --- trunk/src/plugins/io_lihata/read.c (revision 562) +++ trunk/src/plugins/io_lihata/read.c (revision 563) @@ -94,7 +94,7 @@ return 0; } - if ((htip_get(&ctx->sheet->id2obj, oid) != NULL) || (oid == ctx->sheet->grp.hdr.oid)) { + if ((htip_get(&ctx->sheet->id2obj, oid) != NULL) || (oid == ctx->sheet->direct.hdr.oid)) { error(nd, ("duplicate oid %lu\n", oid)); return 0; } @@ -172,10 +172,10 @@ typedef struct dispatch_s { const char *prefix; - int (*handler)(read_ctx_t *ctx, lht_node_t *nd, csch_oid_t oid); + int (*handler)(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *nd, csch_oid_t oid); } dispatch_t; -static int dispatch_node(read_ctx_t *ctx, lht_node_t *nd, const dispatch_t *tbl) +static int dispatch_node(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *nd, const dispatch_t *tbl) { char *sep = strchr(nd->name, '.'); int len; @@ -193,13 +193,13 @@ for(t = tbl; t->prefix != NULL; t++) if (strncmp(nd->name, t->prefix, len) == 0) - return t->handler(ctx, nd, oid); + return t->handler(ctx, parent, nd, oid); error(nd, ("invalid object name '%s': unknown under node %s\n", nd->name, nd->parent->name)); return -1; } -static int dispatch_subtree(read_ctx_t *ctx, lht_node_t *subtree, const dispatch_t *tbl, int allow_empty) +static int dispatch_subtree(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, const dispatch_t *tbl, int allow_empty) { lht_node_t *n; lht_dom_iterator_t it; @@ -212,7 +212,7 @@ } for(n = lht_dom_first(&it, subtree); n != NULL; n = lht_dom_next(&it)) - if (dispatch_node(ctx, n, tbl)) + if (dispatch_node(ctx, parent, n, tbl)) return -1; return 0; @@ -356,7 +356,7 @@ csch_cpen_t *pen; if (oid == 0) return -1; - pen = csch_pen_alloc(ctx->sheet, oid); + pen = csch_pen_alloc(ctx->sheet, &ctx->sheet->direct, oid); if (pen == NULL) { error(subtree, ("failed to allocate pen\n")); return -1; @@ -373,7 +373,7 @@ return 0; } -static int parse_line(read_ctx_t *ctx, lht_node_t *subtree, csch_oid_t oid) +static int parse_line(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, csch_oid_t oid) { csch_line_t *line; @@ -385,7 +385,7 @@ return -1; } - line = csch_line_alloc(ctx->sheet, oid); + line = csch_line_alloc(ctx->sheet, parent, oid); if (parse_coord(ctx, &line->prim.c.p1.x, lht_dom_hash_get(subtree, "x1")) != 0) return -1; @@ -405,8 +405,8 @@ /*** composite object parsing: groups, object lists */ -static int parse_group(read_ctx_t *ctx, lht_node_t *subtree, csch_oid_t oid); -static int parse_group_ref(read_ctx_t *ctx, lht_node_t *subtree, csch_oid_t oid); +static int parse_group(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, csch_oid_t oid); +static int parse_group_ref(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, csch_oid_t oid); static const dispatch_t objs_tbl[] = { {"group", parse_group}, @@ -415,9 +415,9 @@ {NULL, NULL} }; -static int parse_group(read_ctx_t *ctx, lht_node_t *subtree, csch_oid_t oid) +static int parse_group(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, csch_oid_t oid) { - csch_cgrp_t *grp = csch_cgrp_alloc(ctx->sheet, oid); + csch_cgrp_t *grp = csch_cgrp_alloc(ctx->sheet, parent, oid); if (grp == NULL) { error(subtree, ("failed to allocate group\n")); @@ -438,12 +438,12 @@ if (parse_double(ctx, &grp->rot, lht_dom_hash_get(subtree, "rot")) != 0) return -1; - return dispatch_subtree(ctx, lht_dom_hash_get(subtree, "objects"), objs_tbl, 0); + return dispatch_subtree(ctx, grp, lht_dom_hash_get(subtree, "objects"), objs_tbl, 0); } -static int parse_group_ref(read_ctx_t *ctx, lht_node_t *subtree, csch_oid_t oid) +static int parse_group_ref(read_ctx_t *ctx, csch_cgrp_t *parent, lht_node_t *subtree, csch_oid_t oid) { - csch_cgrp_ref_t *grp = csch_cgrp_ref_alloc(ctx->sheet, oid); + csch_cgrp_ref_t *grp = csch_cgrp_ref_alloc(ctx->sheet, parent, oid); if (grp == NULL) { error(subtree, ("failed to allocate group ref\n")); @@ -470,6 +470,8 @@ static int parse_sheet_objs(read_ctx_t *ctx, lht_node_t *subtree, int direct) { + csch_cgrp_t *parent; + if (subtree == NULL) return 0; @@ -478,7 +480,8 @@ return -1; } - return dispatch_subtree(ctx, subtree, objs_tbl, 1); + parent = direct ? &ctx->sheet->direct : &ctx->sheet->indirect; + return dispatch_subtree(ctx, parent, subtree, objs_tbl, 1); } static int parse_sheet(read_ctx_t *ctx, lht_node_t *subtree) @@ -488,7 +491,7 @@ return -1; } /* parse_uid(&ctx->sheet->uid, lht_dom_hash_get(subtree, "uid"));*/ - if (parse_attribs(ctx, &ctx->sheet->grp.hdr.attr, lht_dom_hash_get(subtree, "attrib")) != 0) + if (parse_attribs(ctx, &ctx->sheet->direct.hdr.attr, lht_dom_hash_get(subtree, "attrib")) != 0) return -1; if (parse_pens(ctx, lht_dom_hash_get(subtree, "pens")) != 0) return -1;