recursive attribute substitution. use also template attribute of parents if not found in instance prop_ptr
This commit is contained in:
parent
77e4909ca4
commit
0f25befe31
|
|
@ -805,7 +805,7 @@ void attach_labels_to_inst(int interactive) /* offloaded from callback.c 201710
|
|||
int use_label_prefix;
|
||||
int found=0;
|
||||
|
||||
my_strdup(1607, &symname_pin, tcleval("rel_sym_path [find_file lab_pin.sym]"));
|
||||
my_strdup(1611, &symname_pin, tcleval("rel_sym_path [find_file lab_pin.sym]"));
|
||||
my_strdup(1607, &symname_wire, tcleval("rel_sym_path [find_file lab_wire.sym]"));
|
||||
if(symname_pin && symname_wire) {
|
||||
rebuild_selected_array();
|
||||
|
|
@ -1214,7 +1214,7 @@ int descend_schematic(int instnumber)
|
|||
char filename[PATH_MAX];
|
||||
int inst_mult, inst_number;
|
||||
int save_ok = 0;
|
||||
|
||||
int n = 0;
|
||||
|
||||
rebuild_selected_array();
|
||||
if(xctx->lastsel !=1 || xctx->sel_array[0].type!=ELEMENT)
|
||||
|
|
@ -1224,7 +1224,8 @@ int descend_schematic(int instnumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
dbg(1, "descend_schematic(): selected:%s\n", xctx->inst[xctx->sel_array[0].n].name);
|
||||
n = xctx->sel_array[0].n;
|
||||
dbg(1, "descend_schematic(): selected:%s\n", xctx->inst[n].name);
|
||||
/* no name set for current schematic: save it before descending*/
|
||||
if(!strcmp(xctx->sch[xctx->currsch],""))
|
||||
{
|
||||
|
|
@ -1242,12 +1243,12 @@ int descend_schematic(int instnumber)
|
|||
if(save_ok==0) return 0;
|
||||
}
|
||||
|
||||
dbg(1, "descend_schematic(): inst type: %s\n", (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type);
|
||||
dbg(1, "descend_schematic(): inst type: %s\n", (xctx->inst[n].ptr+ xctx->sym)->type);
|
||||
|
||||
if( /* do not descend if not subcircuit */
|
||||
(xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type &&
|
||||
strcmp( (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type, "subcircuit") &&
|
||||
strcmp( (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type, "primitive")
|
||||
(xctx->inst[n].ptr+ xctx->sym)->type &&
|
||||
strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") &&
|
||||
strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "primitive")
|
||||
) return 0;
|
||||
|
||||
if(xctx->modified)
|
||||
|
|
@ -1267,11 +1268,11 @@ int descend_schematic(int instnumber)
|
|||
}
|
||||
|
||||
/* build up current hierarchy path */
|
||||
dbg(1, "descend_schematic(): selected instname=%s\n", xctx->inst[xctx->sel_array[0].n].instname);
|
||||
dbg(1, "descend_schematic(): selected instname=%s\n", xctx->inst[n].instname);
|
||||
|
||||
|
||||
if(xctx->inst[xctx->sel_array[0].n].instname && xctx->inst[xctx->sel_array[0].n].instname[0]) {
|
||||
str=expandlabel(xctx->inst[xctx->sel_array[0].n].instname, &inst_mult);
|
||||
if(xctx->inst[n].instname && xctx->inst[n].instname[0]) {
|
||||
str=expandlabel(xctx->inst[n].instname, &inst_mult);
|
||||
} else {
|
||||
str = "";
|
||||
inst_mult = 1;
|
||||
|
|
@ -1279,7 +1280,9 @@ int descend_schematic(int instnumber)
|
|||
my_strdup(14, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]);
|
||||
xctx->sch_path_hash[xctx->currsch+1] =0;
|
||||
my_strdup(1516, &xctx->hier_attr[xctx->currsch].prop_ptr,
|
||||
xctx->inst[xctx->sel_array[0].n].prop_ptr);
|
||||
xctx->inst[n].prop_ptr);
|
||||
my_strdup(1613, &xctx->hier_attr[xctx->currsch].templ,
|
||||
get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0));
|
||||
inst_number = 1;
|
||||
if(inst_mult > 1) { /* on multiple instances ask where to descend, to correctly evaluate
|
||||
the hierarchy path you descend to */
|
||||
|
|
@ -1312,14 +1315,14 @@ int descend_schematic(int instnumber)
|
|||
dbg(1, "descend_schematic(): current path: %s\n", xctx->sch_path[xctx->currsch+1]);
|
||||
dbg(1, "descend_schematic(): inst_number=%d\n", inst_number);
|
||||
|
||||
xctx->previous_instance[xctx->currsch]=xctx->sel_array[0].n;
|
||||
xctx->previous_instance[xctx->currsch]=n;
|
||||
xctx->zoom_array[xctx->currsch].x=xctx->xorigin;
|
||||
xctx->zoom_array[xctx->currsch].y=xctx->yorigin;
|
||||
xctx->zoom_array[xctx->currsch].zoom=xctx->zoom;
|
||||
xctx->currsch++;
|
||||
hilight_child_pins();
|
||||
|
||||
get_sch_from_sym(filename, xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym);
|
||||
get_sch_from_sym(filename, xctx->inst[n].ptr+ xctx->sym);
|
||||
unselect_all(1);
|
||||
remove_symbols();
|
||||
load_schematic(1,filename, 1);
|
||||
|
|
|
|||
25
src/save.c
25
src/save.c
|
|
@ -3579,13 +3579,14 @@ void descend_symbol(void)
|
|||
FILE *fd;
|
||||
char name[PATH_MAX];
|
||||
char name_embedded[PATH_MAX];
|
||||
int n = 0;
|
||||
rebuild_selected_array();
|
||||
if(xctx->lastsel > 1) return;
|
||||
if(xctx->lastsel==1 && xctx->sel_array[0].type==ELEMENT) {
|
||||
n =xctx->sel_array[0].n;
|
||||
if(xctx->modified)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = save(1);
|
||||
/* if circuit is changed but not saved before descending
|
||||
* state will be inconsistent when returning, can not propagare hilights
|
||||
|
|
@ -3597,39 +3598,39 @@ void descend_symbol(void)
|
|||
if(ret == 0) clear_all_hilights();
|
||||
if(ret == -1) return; /* user cancel */
|
||||
}
|
||||
my_snprintf(name, S(name), "%s", xctx->inst[xctx->sel_array[0].n].name);
|
||||
my_snprintf(name, S(name), "%s", xctx->inst[n].name);
|
||||
/* dont allow descend in the default missing symbol */
|
||||
if((xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type &&
|
||||
!strcmp( (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type,"missing")) return;
|
||||
if((xctx->inst[n].ptr+ xctx->sym)->type &&
|
||||
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type,"missing")) return;
|
||||
}
|
||||
else return;
|
||||
|
||||
/* build up current hierarchy path */
|
||||
my_strdup(363, &str, xctx->inst[xctx->sel_array[0].n].instname);
|
||||
my_strdup(363, &str, xctx->inst[n].instname);
|
||||
my_strdup(364, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]);
|
||||
my_strcat(365, &xctx->sch_path[xctx->currsch+1], str);
|
||||
my_strcat(366, &xctx->sch_path[xctx->currsch+1], ".");
|
||||
xctx->sch_path_hash[xctx->currsch+1] = 0;
|
||||
|
||||
my_strdup(1518, &xctx->hier_attr[xctx->currsch].prop_ptr,
|
||||
xctx->inst[xctx->sel_array[0].n].prop_ptr);
|
||||
|
||||
xctx->inst[n].prop_ptr);
|
||||
my_strdup(1612, &xctx->hier_attr[xctx->currsch].templ,
|
||||
get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0));
|
||||
xctx->sch_inst_number[xctx->currsch+1] = 1;
|
||||
my_free(921, &str);
|
||||
xctx->previous_instance[xctx->currsch]=xctx->sel_array[0].n;
|
||||
xctx->previous_instance[xctx->currsch]=n;
|
||||
xctx->zoom_array[xctx->currsch].x=xctx->xorigin;
|
||||
xctx->zoom_array[xctx->currsch].y=xctx->yorigin;
|
||||
xctx->zoom_array[xctx->currsch].zoom=xctx->zoom;
|
||||
++xctx->currsch;
|
||||
if((xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->flags & EMBEDDED ||
|
||||
!strcmp(get_tok_value(xctx->inst[xctx->sel_array[0].n].prop_ptr,"embed", 0), "true")) {
|
||||
if((xctx->inst[n].ptr+ xctx->sym)->flags & EMBEDDED ||
|
||||
!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"embed", 0), "true")) {
|
||||
/* save embedded symbol into a temporary file */
|
||||
my_snprintf(name_embedded, S(name_embedded),
|
||||
"%s/.xschem_embedded_%d_%s", tclgetvar("XSCHEM_TMP_DIR"), getpid(), get_cell_w_ext(name, 0));
|
||||
if(!(fd = fopen(name_embedded, "w")) ) {
|
||||
fprintf(errfp, "descend_symbol(): problems opening file %s \n", name_embedded);
|
||||
}
|
||||
save_embedded_symbol(xctx->inst[xctx->sel_array[0].n].ptr+xctx->sym, fd);
|
||||
save_embedded_symbol(xctx->inst[n].ptr+xctx->sym, fd);
|
||||
fclose(fd);
|
||||
unselect_all(1);
|
||||
remove_symbols(); /* must follow save (if) embedded */
|
||||
|
|
|
|||
|
|
@ -3355,12 +3355,16 @@ const char *translate(int inst, const char* s)
|
|||
if(xctx->tok_size && tok[0]) {
|
||||
dbg(1, "tok=%s\n", tok);
|
||||
my_strdup2(1523, &value1, tok);
|
||||
} else {
|
||||
tok = get_tok_value(lcc[i-1].templ, value1, 0);
|
||||
if(xctx->tok_size && tok[0]) {
|
||||
dbg(1, "from parent template: tok=%s\n", tok);
|
||||
my_strdup2(1614, &value1, tok);
|
||||
}
|
||||
}
|
||||
dbg(1, "2 translate(): lcc[%d].prop_ptr=%s, value1=%s\n", i-1, lcc[i-1].prop_ptr, value1);
|
||||
i--;
|
||||
}
|
||||
|
||||
|
||||
tmp=strlen(value1);
|
||||
STR_ALLOC(&result, tmp + result_pos, &size);
|
||||
memcpy(result+result_pos, value1, tmp+1);
|
||||
|
|
|
|||
|
|
@ -360,9 +360,10 @@ static void free_xschem_data()
|
|||
my_free(1133, &xctx->maxl);
|
||||
my_free(1108, &xctx->sel_array);
|
||||
for(i=0;i<CADMAXHIER;i++) {
|
||||
my_free(1139, &xctx->sch_path[i]);
|
||||
my_free(959, &xctx->hier_attr[i].prop_ptr);
|
||||
my_free(960, &xctx->hier_attr[i].symname);
|
||||
if(xctx->sch_path[i]) my_free(1139, &xctx->sch_path[i]);
|
||||
if(xctx->hier_attr[i].templ) my_free(1608, &xctx->hier_attr[i].templ);
|
||||
if(xctx->hier_attr[i].prop_ptr) my_free(959, &xctx->hier_attr[i].prop_ptr);
|
||||
if(xctx->hier_attr[i].symname) my_free(960, &xctx->hier_attr[i].symname);
|
||||
}
|
||||
|
||||
my_free(1099, &xctx->gridpoint);
|
||||
|
|
@ -543,6 +544,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
|
|||
xctx->sch_path[i]=NULL;
|
||||
xctx->sch_path_hash[i]=0;
|
||||
xctx->hier_attr[i].prop_ptr = NULL;
|
||||
xctx->hier_attr[i].templ = NULL;
|
||||
xctx->hier_attr[i].symname = NULL;
|
||||
xctx->hier_attr[i].fd = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -578,6 +578,7 @@ typedef struct
|
|||
short flip;
|
||||
FILE *fd;
|
||||
char *prop_ptr;
|
||||
char *templ;
|
||||
char *symname;
|
||||
} Lcc;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue