Index: trunk/src/libcschem/abstract.c =================================================================== --- trunk/src/libcschem/abstract.c (revision 709) +++ trunk/src/libcschem/abstract.c (revision 710) @@ -38,15 +38,24 @@ memset(abs, 0, sizeof(csch_abstract_t)); htsp_init(&abs->nets, strhash, strkeyeq); htsp_init(&abs->comps, strhash, strkeyeq); + htip_init(&abs->aid2obj, longhash, longkeyeq); + abs->next_aid = 1; } /* Initialize an object by setting the common header fields; the only purpose of this function is to get compiler warnings at every caller when the header is extended (because the number of args would be extended here) */ -csch_inline void csch_aobj_init(csch_ahdr_t *dst, csch_atype_t type) +csch_inline void csch_aobj_init(csch_abstract_t *abs, csch_ahdr_t *dst, csch_atype_t type) { dst->type = type; csch_attrib_init(&dst->attr); + + /* assign unique aid */ + dst->aid = abs->next_aid; + abs->next_aid++; + if (abs->next_aid < 1) + abs->next_aid = 1; + htip_set(&abs->aid2obj, dst->aid, dst); } csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname, int alloc) @@ -58,7 +67,7 @@ return net; net = calloc(sizeof(csch_anet_t), 1); - csch_aobj_init(&net->hdr, CSCH_ATYPE_NET); + csch_aobj_init(abs, &net->hdr, CSCH_ATYPE_NET); net->netname = csch_strdup(netname); htsp_set(&abs->nets, net->netname, net); return net; @@ -73,7 +82,7 @@ return comp; comp = calloc(sizeof(csch_acomp_t), 1); - csch_aobj_init(&comp->hdr, CSCH_ATYPE_COMP); + csch_aobj_init(abs, &comp->hdr, CSCH_ATYPE_COMP); comp->name = csch_strdup(name); htsp_set(&abs->comps, comp->name, comp); htsp_init(&comp->ports, strhash, strkeyeq); @@ -89,7 +98,7 @@ return port; port = calloc(sizeof(csch_aport_t), 1); - csch_aobj_init(&port->hdr, CSCH_ATYPE_PORT); + csch_aobj_init(abs, &port->hdr, CSCH_ATYPE_PORT); port->name = csch_strdup(name); htsp_set(&comp->ports, port->name, port); return port; Index: trunk/src/libcschem/abstract.h =================================================================== --- trunk/src/libcschem/abstract.h (revision 709) +++ trunk/src/libcschem/abstract.h (revision 710) @@ -42,7 +42,8 @@ htsl_t net2id; /* (global) net name -> net object ID */ htsp_t nets; /* netname -> csch_anet_t */ htsp_t comps; /* name -> csch_acomp_t */ - csch_oid_t next_id; + htip_t aid2obj; /* global aid -> (csch_anet_t *) */ + long next_aid; } csch_abstract_t; typedef enum csch_atype_e { @@ -59,6 +60,7 @@ typedef struct csch_ahdr_s { csch_atype_t type; csch_attribs_t attr; + long aid; } csch_ahdr_t; typedef struct csch_acomp_s csch_acomp_t;