some code refactoring, duplicate code replaced with set_inst_flags(), set_sym_flags(), various fixes/optimizations about floaters

This commit is contained in:
stefan schippers 2023-05-14 12:58:25 +02:00
parent 9d58f8cbbc
commit 96eea54894
9 changed files with 129 additions and 264 deletions

View File

@ -91,6 +91,36 @@ int there_are_floaters(void)
return floaters;
}
const char *get_text_floater(int i)
{
const char *txt_ptr = xctx->text[i].txt_ptr;
if(xctx->text[i].flags & TEXT_FLOATER) {
int inst = -1;
const char *instname;
if(!xctx->floater_inst_table.table) {
floater_hash_all_names();
}
if(xctx->text[i].floater_instname)
instname = xctx->text[i].floater_instname;
else
instname = get_tok_value(xctx->text[i].prop_ptr, "floater", 0);
inst = get_instance(instname);
if(inst >= 0) {
if(xctx->text[i].floater_ptr) {
txt_ptr = xctx->text[i].floater_ptr;
} else {
/* cache floater translated text to avoid re-evaluating every time schematic is drawn */
my_strdup(_ALLOC_ID_, &xctx->text[i].floater_ptr, translate(inst, xctx->text[i].txt_ptr));
txt_ptr = xctx->text[i].floater_ptr;
}
dbg(1, "floater: %s\n",txt_ptr);
}
}
return txt_ptr;
}
/* mod=-1 used to force set title
* mod=-2 used to reset floaters cache
* if floaters are present set_modify(1) (after a modify opration) must be done before draw()
@ -108,13 +138,8 @@ void set_modify(int mod)
if(xctx->text[i].flags & TEXT_FLOATER) {
floaters++;
my_free(_ALLOC_ID_, &xctx->text[i].floater_ptr); /* clear floater cached value */
my_free(_ALLOC_ID_, &xctx->text[i].floater_instname); /* clear floater cached value */
}
if(floaters) {
floater_hash_all_names();
} else {
int_hash_free(&xctx->floater_inst_table);
}
int_hash_free(&xctx->floater_inst_table);
}
if(mod != -2 && (mod == -1 || mod != xctx->prev_set_modify) ) { /* mod=-1 used to force set title */
if(mod != -1) xctx->prev_set_modify = mod;
@ -619,7 +644,6 @@ void remove_symbols(void)
dbg(1, "remove_symbols(): done\n");
}
/* set cached rect .flags bitmask based on attributes, currently:
* graph 1
* graph_unlocked 1 + 2
@ -641,38 +665,63 @@ int set_rect_flags(xRect *r)
dbg(1, "set_rect_flags(): flags=%d\n", f);
return f;
}
const char *get_text_floater(int i)
int set_sym_flags(xSymbol *sym)
{
const char *txt_ptr = xctx->text[i].txt_ptr;
Int_hashentry *entry;
if(xctx->text[i].flags & TEXT_FLOATER) {
int inst = -1;
const char *instname;
if(xctx->text[i].floater_instname)
instname = xctx->text[i].floater_instname;
else
instname = get_tok_value(xctx->text[i].prop_ptr, "floater", 0);
if(xctx->floater_inst_table.table) {
entry = int_hash_lookup(&xctx->floater_inst_table, instname, 0, XLOOKUP);
inst = entry ? entry->value : -1;
} else {
inst = get_instance(instname);
}
if(inst >= 0) {
if(xctx->text[i].floater_ptr) {
txt_ptr = xctx->text[i].floater_ptr;
} else {
/* cache floater translated text to avoid re-evaluating every time schematic is drawn */
my_strdup(_ALLOC_ID_, &xctx->text[i].floater_ptr, translate(inst, xctx->text[i].txt_ptr));
txt_ptr = xctx->text[i].floater_ptr;
}
dbg(1, "floater: %s\n",txt_ptr);
}
}
return txt_ptr;
}
sym->flags = 0;
my_strdup2(_ALLOC_ID_, &sym->templ,
get_tok_value(sym->prop_ptr, "template", 0));
my_strdup2(_ALLOC_ID_, &sym->type,
get_tok_value(sym->prop_ptr, "type",0));
if(!strcmp(get_tok_value(sym->prop_ptr,"highlight",0), "true"))
sym->flags |= HILIGHT_CONN;
if(!strcmp(get_tok_value(sym->prop_ptr,"hide",0), "true"))
sym->flags |= HIDE_INST;
if(!strcmp(get_tok_value(sym->prop_ptr,"spice_ignore",0), "true"))
sym->flags |= SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(sym->prop_ptr,"verilog_ignore",0), "true"))
sym->flags |= VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(sym->prop_ptr,"vhdl_ignore",0), "true"))
sym->flags |= VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(sym->prop_ptr,"tedax_ignore",0), "true"))
sym->flags |= TEDAX_IGNORE_INST;
return 0;
}
int set_inst_flags(xInstance *inst)
{
inst->flags=0;
inst->instname=NULL;
my_strdup2(_ALLOC_ID_, &inst->instname, get_tok_value(inst->prop_ptr, "name", 0));
if(!strcmp(get_tok_value(inst->prop_ptr,"hide",0), "true"))
inst->flags |= HIDE_INST;
if(!strcmp(get_tok_value(inst->prop_ptr,"spice_ignore",0), "true"))
inst->flags |= SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(inst->prop_ptr,"verilog_ignore",0), "true"))
inst->flags |= VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(inst->prop_ptr,"vhdl_ignore",0), "true"))
inst->flags |= VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(inst->prop_ptr,"tedax_ignore",0), "true"))
inst->flags |= TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(inst->prop_ptr,"hide_texts",0), "true"))
inst->flags |= HIDE_SYMBOL_TEXTS;
if(!strcmp(get_tok_value(inst->prop_ptr,"highlight",0), "true"))
inst->flags |= HILIGHT_CONN;
inst->embed = !strcmp(get_tok_value(inst->prop_ptr, "embed", 2), "true");
return 0;
}
int set_text_flags(xText *t)
{
@ -1143,7 +1192,6 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
dbg(1, "place_symbol(): checked inst_ptr storage, sym number i=%d\n", i);
xctx->inst[n].ptr = i;
xctx->inst[n].name=NULL;
xctx->inst[n].instname=NULL;
xctx->inst[n].lab=NULL;
dbg(1, "place_symbol(): entering my_strdup: name=%s\n",name); /* 03-02-2000 */
my_strdup2(_ALLOC_ID_, &xctx->inst[n].name ,name);
@ -1170,27 +1218,13 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
}
dbg(1, "place_symbol(): done set_inst_prop()\n"); /* 03-02-2000 */
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[n].flags |= SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[n].flags |= VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[n].flags |= VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[n].flags |= TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"hide",0), "true"))
xctx->inst[n].flags |= HIDE_INST;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"highlight",0), "true"))
xctx->inst[n].flags |= HILIGHT_CONN;
if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"hide_texts",0), "true"))
xctx->inst[n].flags |= HIDE_SYMBOL_TEXTS;
set_inst_flags(&xctx->inst[n]);
type = xctx->sym[xctx->inst[n].ptr].type;
cond= type && IS_LABEL_SH_OR_PIN(type);
if(cond) {
xctx->inst[n].flags |= PIN_OR_LABEL;
my_strdup(_ALLOC_ID_, &xctx->inst[n].lab, get_tok_value(xctx->inst[n].prop_ptr,"lab",0));
}
xctx->inst[n].embed = !strcmp(get_tok_value(xctx->inst[n].prop_ptr, "embed", 2), "true");
if(first_call && (draw_sym & 3) ) bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
xctx->instances++; /* must be updated before calling symbol_bbox() */
/* force these vars to 0 to trigger a prepare_netlist_structs(0) needed by symbol_bbox->translate
@ -1857,12 +1891,6 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
updatebbox(count,boundbox,&rect);
}
if(has_x && selected != 2) {
if(xctx->floater_inst_table.table == NULL) {
if(there_are_floaters()) {
floater_hash_all_names();
}
}
for(i=0;i<xctx->texts; ++i)
{
int no_of_lines;

View File

@ -600,13 +600,12 @@ void set_inst_prop(int i)
{
char *ptr;
char *tmp = NULL;
if(xctx->inst[i].ptr == -1) return;
ptr = (xctx->inst[i].ptr+ xctx->sym)->templ;
dbg(1, "set_inst_prop(): i=%d, name=%s, prop_ptr = %s, template=%s\n",
i, xctx->inst[i].name, xctx->inst[i].prop_ptr, ptr);
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, ptr);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, get_tok_value(ptr, "name",0));
if(xctx->inst[i].instname[0]) {
if(get_tok_value(ptr, "name",0)[0]) {
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
new_prop_string(i, tmp, 0, tclgetboolvar("disable_unique_names"));
my_free(_ALLOC_ID_, &tmp);
@ -1391,10 +1390,9 @@ static int update_symbol(const char *result, int x)
if(!pushed) { xctx->push_undo(); pushed=1;}
if(!k) hash_all_names();
new_prop_string(*ii, ptr, k, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */
} else { /* no name attribute was set in instance */
my_strdup2(_ALLOC_ID_, &xctx->inst[*ii].instname, "");
}
set_inst_flags(&xctx->inst[*ii]);
/* set cached flags in instances */
type=xctx->sym[xctx->inst[*ii].ptr].type;
cond= type && IS_LABEL_SH_OR_PIN(type);
@ -1405,36 +1403,6 @@ static int update_symbol(const char *result, int x)
}
else xctx->inst[*ii].flags &= ~PIN_OR_LABEL;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"highlight",0), "true"))
xctx->inst[*ii].flags |= HILIGHT_CONN;
else xctx->inst[*ii].flags &= ~HILIGHT_CONN;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[*ii].flags |= SPICE_IGNORE_INST;
else xctx->inst[*ii].flags &= ~SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[*ii].flags |= VERILOG_IGNORE_INST;
else xctx->inst[*ii].flags &= ~VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[*ii].flags |= VHDL_IGNORE_INST;
else xctx->inst[*ii].flags &= ~VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[*ii].flags |= TEDAX_IGNORE_INST;
else xctx->inst[*ii].flags &= ~TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"hide",0), "true"))
xctx->inst[*ii].flags |= HIDE_INST;
else xctx->inst[*ii].flags &= ~HIDE_INST;
if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"hide_texts",0), "true"))
xctx->inst[*ii].flags |= HIDE_SYMBOL_TEXTS;
else xctx->inst[*ii].flags &= ~HIDE_SYMBOL_TEXTS;
xctx->inst[*ii].embed = !strcmp(get_tok_value(xctx->inst[*ii].prop_ptr, "embed", 2), "true");
} /* end for(k=0;k<xctx->lastsel; ++k) */
if(pushed) modified = 1;
/* new symbol bbox after prop changes (may change due to text length) */

View File

@ -552,7 +552,5 @@ void mem_pop_undo(int redo, int set_modify_status)
xctx->prep_net_structs = 0;
xctx->prep_hi_structs = 0;
update_conn_cues(WIRELAYER, 0, 0);
if(there_are_floaters()) {
floater_hash_all_names();
}
int_hash_free(&xctx->floater_inst_table);
}

View File

@ -913,6 +913,7 @@ void copy_objects(int what)
xctx->text[xctx->texts].floater_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->text[xctx->texts].prop_ptr, xctx->text[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->text[xctx->texts].floater_ptr, xctx->text[n].floater_ptr);
my_strdup(_ALLOC_ID_, &xctx->text[xctx->texts].floater_instname, xctx->text[n].floater_instname);
set_text_flags(&xctx->text[xctx->texts]);
xctx->text[xctx->texts].xscale=xctx->text[n].xscale;
xctx->text[xctx->texts].yscale=xctx->text[n].yscale;
@ -967,10 +968,6 @@ void copy_objects(int what)
xctx->inst[xctx->instances].name=NULL;
my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].name, xctx->inst[n].name);
my_strdup(_ALLOC_ID_, &xctx->inst[xctx->instances].prop_ptr, xctx->inst[n].prop_ptr);
/*
* my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].instname, get_tok_value(xctx->inst[n].prop_ptr, "name",0));
*/
xctx->inst[xctx->instances].instname = NULL; /* will be set in new_prop_string() */
my_strdup(_ALLOC_ID_, &xctx->inst[xctx->instances].lab, xctx->inst[n].lab);
xctx->inst[n].sel=0;
xctx->inst[xctx->instances].embed = xctx->inst[n].embed;
@ -987,6 +984,8 @@ void copy_objects(int what)
if(!newpropcnt) hash_all_names();
new_prop_string(xctx->instances, xctx->inst[n].prop_ptr,newpropcnt++,
tclgetboolvar("disable_unique_names"));
my_strdup(_ALLOC_ID_, &xctx->inst[xctx->instances].instname,
get_tok_value(xctx->inst[xctx->instances].prop_ptr, "name", 0));
/* this is needed since no find_inst_to_be_redrawn() is executed if floaters are present */
if(floaters) symbol_bbox(xctx->instances,
&xctx->inst[xctx->instances].x1, &xctx->inst[xctx->instances].y1,

View File

@ -266,11 +266,9 @@ static void merge_inst(int k,FILE *fd)
return;
}
xctx->inst[i].sel=0;
xctx->inst[i].flags=0;
xctx->inst[i].color=-10000;
xctx->inst[i].ptr=-1;
xctx->inst[i].prop_ptr=NULL;
xctx->inst[i].instname=NULL;
xctx->inst[i].lab=NULL; /* assigned in link_symbols_to_instances */
xctx->inst[i].node=NULL;
load_ascii_string(&prop_ptr,fd);
@ -278,25 +276,7 @@ static void merge_inst(int k,FILE *fd)
new_prop_string(i, prop_ptr, k, tclgetboolvar("disable_unique_names")); /* will also assign .instname */
/* the final tmp argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"hide",0), "true"))
xctx->inst[i].flags |= HIDE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true"))
xctx->inst[i].flags |= HILIGHT_CONN;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[i].flags |= SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[i].flags |= VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[i].flags |= VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[i].flags |= TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"hide_texts",0), "true"))
xctx->inst[i].flags |= HIDE_SYMBOL_TEXTS;
xctx->inst[i].embed = !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "embed", 2), "true");
set_inst_flags(&xctx->inst[i]);
my_free(_ALLOC_ID_, &prop_ptr);
xctx->instances++;
}

View File

@ -1889,38 +1889,17 @@ static void load_inst(int k, FILE *fd)
read_line(fd, 0);
} else {
xctx->inst[i].color=-10000;
xctx->inst[i].flags=0;
xctx->inst[i].sel=0;
xctx->inst[i].ptr=-1; /*04112003 was 0 */
xctx->inst[i].prop_ptr=NULL;
xctx->inst[i].instname=NULL;
xctx->inst[i].lab=NULL; /* assigned in link_symbols_to_instances */
xctx->inst[i].node=NULL;
load_ascii_string(&prop_ptr,fd);
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, prop_ptr);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0));
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"hide",0), "true"))
xctx->inst[i].flags |= HIDE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[i].flags |= SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[i].flags |= VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[i].flags |= VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[i].flags |= TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"hide_texts",0), "true"))
xctx->inst[i].flags |= HIDE_SYMBOL_TEXTS;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true"))
xctx->inst[i].flags |= HILIGHT_CONN;
set_inst_flags(&xctx->inst[i]);
dbg(2, "load_inst(): n=%d name=%s prop=%s\n", i, xctx->inst[i].name? xctx->inst[i].name:"<NULL>",
xctx->inst[i].prop_ptr? xctx->inst[i].prop_ptr:"<NULL>");
xctx->inst[i].embed = !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "embed", 2), "true");
xctx->instances++;
}
my_free(_ALLOC_ID_, &prop_ptr);
@ -2246,9 +2225,7 @@ static void read_xschem_file(FILE *fd)
dbg(1, "read_xschem_file(): no file_version, assuming file_version=%s\n", xctx->file_version);
}
}
if(there_are_floaters()) {
floater_hash_all_names();
}
int_hash_free(&xctx->floater_inst_table);
}
void load_ascii_string(char **ptr, FILE *fd)
@ -3307,32 +3284,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
load_ascii_string(&symbol[symbols].prop_ptr, lcc[level].fd);
dbg(1, "load_sym_def: K prop=\n%s\n", symbol[symbols].prop_ptr);
if(!symbol[symbols].prop_ptr) break;
my_strdup2(_ALLOC_ID_, &symbol[symbols].templ,
get_tok_value(symbol[symbols].prop_ptr, "template", 0));
my_strdup2(_ALLOC_ID_, &symbol[symbols].type,
get_tok_value(symbol[symbols].prop_ptr, "type",0));
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"highlight",0), "true"))
symbol[symbols].flags |= HILIGHT_CONN;
else symbol[symbols].flags &= ~HILIGHT_CONN;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"hide",0), "true"))
symbol[symbols].flags |= HIDE_INST;
else symbol[symbols].flags &= ~HIDE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"spice_ignore",0), "true"))
symbol[symbols].flags |= SPICE_IGNORE_INST;
else symbol[symbols].flags &= ~SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"verilog_ignore",0), "true"))
symbol[symbols].flags |= VERILOG_IGNORE_INST;
else symbol[symbols].flags &= ~VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"vhdl_ignore",0), "true"))
symbol[symbols].flags |= VHDL_IGNORE_INST;
else symbol[symbols].flags &= ~VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"tedax_ignore",0), "true"))
symbol[symbols].flags |= TEDAX_IGNORE_INST;
else symbol[symbols].flags &= ~TEDAX_IGNORE_INST;
set_sym_flags(& symbol[symbols]);
}
else {
load_ascii_string(&aux_ptr, lcc[level].fd);
@ -3342,32 +3294,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
if (level==0 && !symbol[symbols].prop_ptr) {
load_ascii_string(&symbol[symbols].prop_ptr, lcc[level].fd);
if(!symbol[symbols].prop_ptr) break;
my_strdup2(_ALLOC_ID_, &symbol[symbols].templ,
get_tok_value(symbol[symbols].prop_ptr, "template", 0));
my_strdup2(_ALLOC_ID_, &symbol[symbols].type,
get_tok_value(symbol[symbols].prop_ptr, "type",0));
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"highlight",0), "true"))
symbol[symbols].flags |= HILIGHT_CONN;
else symbol[symbols].flags &= ~HILIGHT_CONN;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"hide",0), "true"))
symbol[symbols].flags |= HIDE_INST;
else symbol[symbols].flags &= ~HIDE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"spice_ignore",0), "true"))
symbol[symbols].flags |= SPICE_IGNORE_INST;
else symbol[symbols].flags &= ~SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"verilog_ignore",0), "true"))
symbol[symbols].flags |= VERILOG_IGNORE_INST;
else symbol[symbols].flags &= ~VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"vhdl_ignore",0), "true"))
symbol[symbols].flags |= VHDL_IGNORE_INST;
else symbol[symbols].flags &= ~VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"tedax_ignore",0), "true"))
symbol[symbols].flags |= TEDAX_IGNORE_INST;
else symbol[symbols].flags &= ~TEDAX_IGNORE_INST;
set_sym_flags(& symbol[symbols]);
}
else {
load_ascii_string(&aux_ptr, lcc[level].fd);

View File

@ -59,19 +59,26 @@ static int get_symbol(const char *s)
int get_instance(const char *s)
{
int i, found=0;
for(i=0;i<xctx->instances; ++i) {
if(!strcmp(xctx->inst[i].instname, s)) {
found=1;
break;
Int_hashentry *entry;
if(xctx->floater_inst_table.table) {
entry = int_hash_lookup(&xctx->floater_inst_table, s, 0, XLOOKUP);
i = entry ? entry->value : -1;
} else {
for(i=0;i<xctx->instances; ++i) {
if(!strcmp(xctx->inst[i].instname, s)) {
found=1;
break;
}
}
dbg(1, "get_instance(): found=%d, i=%d\n", found, i);
if(!found) {
if(!isonlydigit(s)) return -1;
i=atoi(s);
}
if(i<0 || i>xctx->instances) {
return -1;
}
}
dbg(1, "get_instance(): found=%d, i=%d\n", found, i);
if(!found) {
if(!isonlydigit(s)) return -1;
i=atoi(s);
}
if(i<0 || i>xctx->instances) {
return -1;
}
return i;
}
@ -2858,7 +2865,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
/* changing ysmbol, otherwise i might end up deleting non allocated data. */
my_strdup2(_ALLOC_ID_, &xctx->inst[inst].name, rel_sym_path(symbol));
xctx->inst[inst].ptr=sym_number;
dbg(0, "bbox1: %g %g %g %g\n", xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
dbg(0, "bbox1: %g %g %g %g\n",
xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
my_strdup(_ALLOC_ID_, &name, xctx->inst[inst].instname);
if(name && name[0] )
{
@ -2867,8 +2875,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_strdup(_ALLOC_ID_, &ptr,subst_token(xctx->inst[inst].prop_ptr, "name", name) );
hash_all_names();
new_prop_string(inst, ptr,0, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */
type=xctx->sym[xctx->inst[inst].ptr].type;
my_strdup(_ALLOC_ID_, &xctx->inst[inst].instname, get_tok_value(xctx->inst[inst].prop_ptr, "name", 0));
type=xctx->sym[xctx->inst[inst].ptr].type;
cond= type && IS_LABEL_SH_OR_PIN(type);
if(cond) {
xctx->inst[inst].flags |= PIN_OR_LABEL;
@ -3338,6 +3347,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[4], NULL),fast,
tclgetboolvar("disable_unique_names"));
}
set_inst_flags(&xctx->inst[inst]);
type=xctx->sym[xctx->inst[inst].ptr].type;
cond= type && IS_LABEL_SH_OR_PIN(type);
if(cond) {
@ -3346,35 +3357,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
else xctx->inst[inst].flags &= ~PIN_OR_LABEL;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"highlight",0), "true"))
xctx->inst[inst].flags |= HILIGHT_CONN;
else xctx->inst[inst].flags &= ~HILIGHT_CONN;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"hide",0), "true"))
xctx->inst[inst].flags |= HIDE_INST;
else xctx->inst[inst].flags &= ~HIDE_INST;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[inst].flags |= SPICE_IGNORE_INST;
else xctx->inst[inst].flags &= ~SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[inst].flags |= VERILOG_IGNORE_INST;
else xctx->inst[inst].flags &= ~VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[inst].flags |= VHDL_IGNORE_INST;
else xctx->inst[inst].flags &= ~VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[inst].flags |= TEDAX_IGNORE_INST;
else xctx->inst[inst].flags &= ~TEDAX_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[inst].prop_ptr,"hide_texts",0), "true"))
xctx->inst[inst].flags |= HIDE_SYMBOL_TEXTS;
else xctx->inst[inst].flags &= ~HIDE_SYMBOL_TEXTS;
xctx->inst[inst].embed = !strcmp(get_tok_value(xctx->inst[inst].prop_ptr, "embed", 2), "true");
set_modify(1);
if(!fast) {
/* new symbol bbox after prop changes (may change due to text length) */
@ -3728,23 +3710,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} else {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, "true"));
}
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0), "true"))
xctx->inst[i].flags |= SPICE_IGNORE_INST;
else xctx->inst[i].flags &= ~SPICE_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"verilog_ignore",0), "true"))
xctx->inst[i].flags |= VERILOG_IGNORE_INST;
else xctx->inst[i].flags &= ~VERILOG_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"vhdl_ignore",0), "true"))
xctx->inst[i].flags |= VHDL_IGNORE_INST;
else xctx->inst[i].flags &= ~VHDL_IGNORE_INST;
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0), "true"))
xctx->inst[i].flags |= TEDAX_IGNORE_INST;
else xctx->inst[i].flags &= ~TEDAX_IGNORE_INST;
set_inst_flags(&xctx->inst[i]);
set_modify(1);
}
}

View File

@ -151,6 +151,7 @@ void check_unique_names(int rename)
if( (xctx->inst[i].color != -10000) && rename) {
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
new_prop_string(i, tmp, newpropcnt++, 0);
my_strdup(_ALLOC_ID_, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0));
my_strdup(_ALLOC_ID_, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
int_hash_lookup(&xctx->inst_table, upinst, i, XINSERT);
@ -694,7 +695,6 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
if(old_prop==NULL)
{
my_free(_ALLOC_ID_, &xctx->inst[i].prop_ptr);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, "");
return;
}
old_name_len = my_strdup(_ALLOC_ID_, &old_name,get_tok_value(old_prop,"name",0) ); /* added old_name_len */
@ -704,7 +704,6 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
if(old_name==NULL)
{
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, old_prop); /* changed to copy old props if no name */
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, "");
my_free(_ALLOC_ID_, &up_old_name);
return;
}
@ -715,7 +714,6 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
entry->value == i)
{
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, old_prop);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, old_name);
int_hash_lookup(&xctx->inst_table, up_old_name, i, XINSERT);
my_free(_ALLOC_ID_, &old_name);
my_free(_ALLOC_ID_, &up_old_name);
@ -745,7 +743,6 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
tmp2 = subst_token(old_prop, "name", new_name);
if(strcmp(tmp2, old_prop) ) {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, tmp2);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, new_name);
int_hash_lookup(&xctx->inst_table, up_new_name, i, XINSERT); /* reinsert in hash */
}
my_free(_ALLOC_ID_, &old_name);

View File

@ -1129,6 +1129,8 @@ extern int raw_read_from_attr(const char *type);
extern char *base64_from_file(const char *f, size_t *length);
extern int set_rect_flags(xRect *r);
extern int set_text_flags(xText *t);
extern int set_inst_flags(xInstance *inst);
extern int set_sym_flags(xSymbol *sym);
extern const char *get_text_floater(int i);
extern int set_rect_extraptr(int what, xRect *drptr);
extern unsigned char *base64_decode(const char *data, const size_t input_length, size_t *output_length);