correctly save embedded symbol attributes in embeeded symbols, do not save multiple times the same embedded symbol definition

This commit is contained in:
Stefan Frederik 2022-02-02 02:14:23 +01:00
parent a8e1a6c047
commit 77b900569b
4 changed files with 34 additions and 28 deletions

View File

@ -26,7 +26,7 @@
void merge_text(FILE *fd)
static void merge_text(FILE *fd)
{
int i;
const char *str;
@ -72,7 +72,7 @@ void merge_text(FILE *fd)
xctx->texts++;
}
void merge_wire(FILE *fd)
static void merge_wire(FILE *fd)
{
int i;
double x1,y1,x2,y2;
@ -89,7 +89,7 @@ void merge_wire(FILE *fd)
select_wire(i, SELECTED, 1);
}
void merge_box(FILE *fd)
static void merge_box(FILE *fd)
{
int i,c,n;
xRect *ptr;
@ -128,7 +128,7 @@ void merge_box(FILE *fd)
set_modify(1);
}
void merge_arc(FILE *fd)
static void merge_arc(FILE *fd)
{
int i,c,n;
xArc *ptr;
@ -171,7 +171,7 @@ void merge_arc(FILE *fd)
}
void merge_polygon(FILE *fd)
static void merge_polygon(FILE *fd)
{
int i,c, j, points;
xPoly *ptr;
@ -227,7 +227,7 @@ void merge_polygon(FILE *fd)
set_modify(1);
}
void merge_line(FILE *fd)
static void merge_line(FILE *fd)
{
int i,c,n;
xLine *ptr;
@ -267,7 +267,7 @@ void merge_line(FILE *fd)
void merge_inst(int k,FILE *fd)
static void merge_inst(int k,FILE *fd)
{
int i;
char *prop_ptr=NULL;

View File

@ -676,13 +676,14 @@ void save_ascii_string(const char *ptr, FILE *fd, int newline)
fwrite(strbuf, 1, strbuf_pos, fd);
}
void save_embedded_symbol(xSymbol *s, FILE *fd)
static void save_embedded_symbol(xSymbol *s, FILE *fd)
{
int c, i, j;
fprintf(fd, "v {xschem version=%s file_version=%s}\n", XSCHEM_VERSION, XSCHEM_FILE_VERSION);
fprintf(fd, "G ");
fprintf(fd, "K ");
save_ascii_string(s->prop_ptr,fd, 1);
fprintf(fd, "G {}\n");
fprintf(fd, "V {}\n");
fprintf(fd, "S {}\n");
fprintf(fd, "E {}\n");
@ -745,15 +746,17 @@ void save_embedded_symbol(xSymbol *s, FILE *fd)
}
}
void save_inst(FILE *fd, int select_only)
static void save_inst(FILE *fd, int select_only)
{
int i, oldversion;
xInstance *ptr;
char *tmp = NULL;
int *embedded_saved = NULL;
ptr=xctx->inst;
oldversion = !strcmp(xctx->file_version, "1.0");
for(i=0;i<xctx->symbols;i++) xctx->sym[i].flags &=~EMBEDDED;
embedded_saved = my_calloc(538, xctx->symbols, sizeof(int));
for(i=0;i<xctx->instances;i++)
{
if (select_only && ptr[i].sel != SELECTED) continue;
@ -767,17 +770,19 @@ void save_inst(FILE *fd, int select_only)
}
fprintf(fd, " %.16g %.16g %hd %hd ",ptr[i].x0, ptr[i].y0, ptr[i].rot, ptr[i].flip );
save_ascii_string(ptr[i].prop_ptr,fd, 1);
if( !strcmp(get_tok_value(ptr[i].prop_ptr, "embed", 0), "true") ) {
if( !embedded_saved[ptr[i].ptr] && !strcmp(get_tok_value(ptr[i].prop_ptr, "embed", 0), "true") ) {
/* && !(xctx->sym[ptr[i].ptr].flags & EMBEDDED)) { */
embedded_saved[ptr[i].ptr] = 1;
fprintf(fd, "[\n");
save_embedded_symbol( xctx->sym+ptr[i].ptr, fd);
fprintf(fd, "]\n");
xctx->sym[ptr[i].ptr].flags |= EMBEDDED;
}
}
my_free(539, &embedded_saved);
}
void save_wire(FILE *fd, int select_only)
static void save_wire(FILE *fd, int select_only)
{
int i;
xWire *ptr;
@ -792,7 +797,7 @@ void save_wire(FILE *fd, int select_only)
}
}
void save_text(FILE *fd, int select_only)
static void save_text(FILE *fd, int select_only)
{
int i;
xText *ptr;
@ -809,7 +814,7 @@ void save_text(FILE *fd, int select_only)
}
}
void save_polygon(FILE *fd, int select_only)
static void save_polygon(FILE *fd, int select_only)
{
int c, i, j;
xPoly *ptr;
@ -828,7 +833,7 @@ void save_polygon(FILE *fd, int select_only)
}
}
void save_arc(FILE *fd, int select_only)
static void save_arc(FILE *fd, int select_only)
{
int c, i;
xArc *ptr;
@ -845,7 +850,7 @@ void save_arc(FILE *fd, int select_only)
}
}
void save_box(FILE *fd, int select_only)
static void save_box(FILE *fd, int select_only)
{
int c, i;
xRect *ptr;
@ -862,7 +867,7 @@ void save_box(FILE *fd, int select_only)
}
}
void save_line(FILE *fd, int select_only)
static void save_line(FILE *fd, int select_only)
{
int c, i;
xLine *ptr;
@ -879,7 +884,7 @@ void save_line(FILE *fd, int select_only)
}
}
void write_xschem_file(FILE *fd)
static void write_xschem_file(FILE *fd)
{
int ty=0;
char *ptr;

View File

@ -2006,7 +2006,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!strcmp(argv[1], "raw_query"))
{
int i;
char s[30];
int dataset = 0;
cmd_found = 1;
Tcl_ResetResult(interp);
@ -2031,8 +2030,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
if(idx >= 0) {
double val = get_raw_value(dataset, idx, point);
my_snprintf(s, S(s), "%g", val);
Tcl_AppendResult(interp, s, NULL);
Tcl_AppendResult(interp, dtoa(val), NULL);
}
}
}
@ -2043,16 +2041,20 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int idx;
entry = int_hash_lookup(xctx->raw_table, argv[3], 0, XLOOKUP);
idx = entry ? entry->value : -1;
my_snprintf(s, S(s), "%d", idx);
Tcl_AppendResult(interp, s, NULL);
Tcl_AppendResult(interp, itoa(idx), NULL);
}
} else if(argc > 2) {
if(!strcmp(argv[2], "datasets")) {
Tcl_AppendResult(interp, itoa(xctx->graph_datasets), NULL);
}
if(!strcmp(argv[2], "points")) {
my_snprintf(s, S(s), "%d", xctx->graph_npoints[0]);
Tcl_AppendResult(interp, s, NULL);
int i, s = 0;
for(i = 0; i < xctx->graph_datasets; i++) {
s += xctx->graph_npoints[i];
}
Tcl_AppendResult(interp, itoa(s), NULL);
} else if(!strcmp(argv[2], "vars")) {
my_snprintf(s, S(s), "%d", xctx->graph_nvars);
Tcl_AppendResult(interp, s, NULL);
Tcl_AppendResult(interp, itoa(xctx->graph_nvars), NULL);
} else if(!strcmp(argv[2], "list")) {
for(i = 0 ; i < xctx->graph_nvars; i++) {
if(i > 0) Tcl_AppendResult(interp, "\n", NULL);

View File

@ -1347,7 +1347,6 @@ extern void check_polygon_storage(int c);
extern const char *expandlabel(const char *s, int *m);
extern void parse(const char *s);
extern void clear_expandlabel_data(void);
extern void merge_inst(int k, FILE *fd);
extern void merge_file(int selection_load, const char ext[]);
extern void select_wire(int i, unsigned short select_mode, int fast);
extern void select_element(int i, unsigned short select_mode, int fast, int override_lock);