make_sym_lcc.awk: declare "value" as local variable inside process_box_line() to avoid clashes with global "value"

This commit is contained in:
Stefan Frederik 2021-06-05 08:58:38 +02:00
parent c1909334cb
commit ddaa431144
16 changed files with 2080 additions and 2060 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Xschem" Language="1033" Version="2.9.9.5" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Product Id="*" Name="Xschem" Language="1033" Version="2.9.9.6" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<WixVariable Id="WixUILicenseRtf"
Value="License.rtf" />
@ -141,6 +141,9 @@
<Component Id="CMPMAKESYMAWK">
<File Id="MAKESYMAWK" KeyPath="yes" Source="../../src/make_sym.awk" />
</Component>
<Component Id="CMPMAKESYMLCCAWK">
<File Id="MAKESYMLCCAWK" KeyPath="yes" Source="../../src/make_sym_lcc.awk" />
</Component>
<Component Id="CMPNGSPICEBACKANNOTATE">
<File Id="NGSPICEBACKANNOTATE" KeyPath="yes" Source="../../src/ngspice_backannotate.tcl" />
</Component>
@ -318,6 +321,7 @@
<ComponentRef Id="CMPMAKESCHFROMSPICEAWK" />
<ComponentRef Id="CMPMAKESCHFROMVHDLAWK" />
<ComponentRef Id="CMPMAKESYMAWK" />
<ComponentRef Id="CMPMAKESYMLCCAWK" />
<ComponentRef Id="CMPNGSPICEBACKANNOTATE" />
<ComponentRef Id="CMPMAKEVHDLFROMSPICEAWK" />
<ComponentRef Id="CMPNETLISTCOMPACTORAWK" />

View File

@ -6,7 +6,7 @@
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>91fbaa21-56d3-42e7-a3e8-df92c89cd027</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>XSchemInstaller</OutputName>
<OutputName>XSchem</OutputName>
<OutputType>Package</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -474,7 +474,10 @@ static void instr_include(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *ar
tmpasm_t *child;
fn = tmpasm_arg2str(ctx, argv[n], 0);
path = scc_path(ud, fn);
if (*fn != '/')
path = scc_path(ud, fn);
else
path = strclone(fn);
fin = fopen(path, "r");
if (fin == NULL) {
tmpasm_runtime_error(ctx, -8, path);

View File

@ -730,15 +730,15 @@ void attach_labels_to_inst() /* offloaded from callback.c 20171005 */
}
if(!strcmp(tclgetvar("use_lab_wire"),"0")) {
if(indirect)
place_symbol(-1,symname_pin, pinx0, piny0, rot1, dir, prop, 2, first_call);
place_symbol(-1,symname_pin, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
else
place_symbol(-1,symname_pin2, pinx0, piny0, rot1, dir, prop, 2, first_call);
place_symbol(-1,symname_pin2, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
first_call=0;
} else {
if(indirect)
place_symbol(-1,symname_wire, pinx0, piny0, rot1, dir, prop, 2, first_call);
place_symbol(-1,symname_wire, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
else
place_symbol(-1,symname_wire2, pinx0, piny0, rot1, dir, prop, 2, first_call);
place_symbol(-1,symname_wire2, pinx0, piny0, rot1, dir, prop, 2, first_call, 1/*to_push_undo*/);
first_call=0;
}
}
@ -773,15 +773,15 @@ void place_net_label(int type)
struct stat buf;
if(type == 1) {
if(!stat(abs_sym_path("lab_pin.sym", ""), &buf)) {
place_symbol(-1, "lab_pin.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
place_symbol(-1, "lab_pin.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
} else if(!stat(abs_sym_path("devices/lab_pin.sym", ""), &buf)) {
place_symbol(-1, "devices/lab_pin.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
place_symbol(-1, "devices/lab_pin.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
}
} else {
if(!stat(abs_sym_path("lab_wire.sym", ""), &buf)) {
place_symbol(-1, "lab_wire.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
place_symbol(-1, "lab_wire.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
} else if(!stat(abs_sym_path("devices/lab_wire.sym", ""), &buf)) {
place_symbol(-1, "devices/lab_wire.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
place_symbol(-1, "devices/lab_wire.sym", xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
}
}
move_objects(START,0,0,0);
@ -796,7 +796,7 @@ void place_net_label(int type)
/* set to 0 on next calls, this speeds up searching for unique names in prop string */
/* returns 1 if symbol successfully placed, 0 otherwise */
int place_symbol(int pos, const char *symbol_name, double x, double y, short rot, short flip,
const char *inst_props, int draw_sym, int first_call)
const char *inst_props, int draw_sym, int first_call, int to_push_undo)
/* if symbol_name is a valid string load specified cell and */
/* use the given params, otherwise query user */
{
@ -813,7 +813,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
dbg(1, "place_symbol(): load_file_dialog returns: name=%s\n",name);
my_strncpy(name, rel_sym_path(name), S(name));
if(name[0]) {
if(first_call) push_undo();
if(first_call && to_push_undo) push_undo();
} else return 0;
i=match_symbol(name);

View File

@ -424,6 +424,10 @@ int callback(int event, int mx, int my, KeySym key,
attach_labels_to_inst();
break;
}
if (key == 'H' && state == (ControlMask | ShiftMask)) { /* create schematic and symbol from selected components */
make_schematic_symbol_from_sel();
break;
}
if(key == 'v' && state==0) {
/* vertically constrained drag 20171023 */
if ( constrained_move == 2 ) {
@ -570,7 +574,7 @@ int callback(int event, int mx, int my, KeySym key,
{
move_objects(ABORT,0,0,0);
if(xctx->ui_state & START_SYMPIN) {
delete();
delete(1/*to_push_undo*/);
xctx->ui_state &= ~START_SYMPIN;
}
break;
@ -581,7 +585,7 @@ int callback(int event, int mx, int my, KeySym key,
break;
}
if(xctx->ui_state & STARTMERGE) {
delete();
delete(1/*to_push_undo*/);
set_modify(0); /* aborted merge: no change, so reset modify flag set by delete() */
}
@ -649,7 +653,7 @@ int callback(int event, int mx, int my, KeySym key,
if(key==XK_Delete && (xctx->ui_state & SELECTION) ) /* delete objects */
{
if(xctx->semaphore >= 2) break;
delete();break;
delete(1/*to_push_undo*/);break;
}
if(key==XK_Right) /* left */
{
@ -797,7 +801,7 @@ int callback(int event, int mx, int my, KeySym key,
rebuild_selected_array();
if(xctx->lastsel) { /* 20071203 check if something selected */
save_selection(2);
delete();
delete(1/*to_push_undo*/);
}
break;
}
@ -903,7 +907,7 @@ int callback(int event, int mx, int my, KeySym key,
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap;
if(place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1) ) {
if(place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/) ) {
xctx->mousey_snap = xctx->my_double_save;
xctx->mousex_snap = xctx->mx_double_save;
move_objects(START,0,0,0);

View File

@ -359,7 +359,6 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
#if HAS_CAIRO==1
char *textfont;
#endif
int dashprop=0, dash=0;
if(xctx->inst[n].ptr == -1) return;
if( (layer != PINLAYER && !enable_layer[layer]) ) return;
@ -370,7 +369,6 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
} else {
hide = 0;
}
dashprop = atoi(get_tok_value(xctx->inst[n].prop_ptr, "dash", 0));
type = (xctx->inst[n].ptr+ xctx->sym)->type;
if(layer==0) {
x1=X_TO_SCREEN(xctx->inst[n].x1+xoffset); /* 20150729 added xoffset, yoffset */
@ -421,16 +419,13 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
for(j=0;j< symptr->lines[layer];j++)
{
line = (symptr->line[layer])[j];
dash = line.dash;
if (line.dash == 0 && dashprop > 0 && layer==4)
dash = dashprop;
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
if(line.bus)
drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, dash);
drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
else
drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, dash);
drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
}
for(j=0;j< symptr->polygons[layer];j++)
{

View File

@ -97,6 +97,7 @@ alt 'g' Hilight selected nets and send to gaw waveform viewer
alt 'h' create symbol pins from schematic pins
ctrl 'h' Follow http link or execute command (url, tclcommand properties)
shift 'H' Attach net labels to selected instance
ctrl+shift 'H' Make schematic and symbol from selected components
- 'i' Descend to symbol
alt 'i' Edit selected symbol in a new window
alt+shift 'J' Create labels with 'i' prefix from highlighted nets/pins

View File

@ -220,13 +220,22 @@ function process_line()
# print "process_line: pin_label=" pin_label " verilog_type=" verilog_type
}
function process_box_line()
function process_box_line( value) # value is also a global. Avoid clashes by declaring it local
{
print "process_box_line"
if($0 ~ /^.*dash=/)
{
sub(/dash=[0-9]/,"dash=0")
# If sch has dash, sym will not have dash
if($0 ~ /^.*dash=/) {
sub(/dash=[1-9]/,"dash=0")
}
else {
value = $0
if (value ~ /\{.*\}/)
{
sub(/^.*\{/,"",value)
sub(/\}/, "", value) # Get rid of }
if (length(value)) sub(/\{.*\}/, "{" value " dash=5}") # Put dash=5 within {} along with its original content
else sub(/\{.*\}/, "{dash=5}")
}
}
print "process_box_line: returning:" $0
# print "process_line: pin_label=" pin_label " verilog_type=" verilog_type

View File

@ -497,7 +497,6 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
xPoly polygon;
xSymbol *symptr;
char *textfont;
int dashprop=0, dash = 0;
if(xctx->inst[n].ptr == -1) return;
if( (layer != PINLAYER && !enable_layer[layer]) ) return;
@ -522,7 +521,6 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
dbg(1, "draw_symbol(): skippinginst %d\n", n);
return;
}
dashprop = atoi(get_tok_value(xctx->inst[n].prop_ptr, "dash", 0));
flip = xctx->inst[n].flip;
if(tmp_flip) flip = !flip;
rot = (xctx->inst[n].rot + rot ) & 0x3;
@ -533,13 +531,10 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->lines[layer];j++)
{
line = ((xctx->inst[n].ptr+ xctx->sym)->line[layer])[j];
dash = line.dash;
if (line.dash == 0 && dashprop > 0 && layer==4)
dash = dashprop;
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
ps_drawline(layer, x0+x1, y0+y1, x0+x2, y0+y2, dash);
ps_drawline(layer, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
}
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->polygons[layer];j++)
{

View File

@ -2146,6 +2146,36 @@ int load_sym_def(const char *name, FILE *embed_fd)
return 1;
}
void make_schematic_symbol_from_sel(void)
{
char filename[PATH_MAX] = "";
char name[1024];
my_snprintf(name, S(name), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR");
tcleval(name);
my_strncpy(filename, tclresult(), S(filename));
if (!strcmp(filename, xctx->sch[xctx->currsch])) {
if (has_x)
tcleval("tk_messageBox -type ok -message {Cannot overwrite current schematic}");
}
else if (strlen(filename)) {
if (xctx->lastsel) push_undo();
make_schematic(filename);
delete(0/*to_push_undo*/);
place_symbol(-1, filename, 0, 0, 0, 0, NULL, 4, 1, 0/*to_push_undo*/);
if (has_x)
{
my_snprintf(name, S(name), "tk_messageBox -type okcancel -message {do you want to make symbol view for %s ?}", filename);
tcleval(name);
}
if (!has_x || !strcmp(tclresult(), "ok")) {
my_snprintf(name, S(name), "make_symbol_lcc {%s}", filename);
dbg(1, "make_symbol_lcc(): making symbol: name=%s\n", filename);
tcleval(name);
}
}
}
void create_sch_from_sym(void)
{
xSymbol *ptr;

View File

@ -311,7 +311,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
cmd_found = 1;
rebuild_selected_array();
save_selection(2);
delete();
delete(1/*to_push_undo*/);
Tcl_ResetResult(interp);
}
}
@ -330,7 +330,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"delete"))
{
cmd_found = 1;
if(argc==2) delete();
if(argc==2) delete(1/*to_push_undo*/);
Tcl_ResetResult(interp);
}
@ -1089,12 +1089,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
cmd_found = 1;
if(argc==7)
/* pos sym_name x y rot flip prop draw first */
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]),NULL, 3, 1);
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]),NULL, 3, 1, 1/*to_push_undo*/);
else if(argc==8)
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 3, 1);
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 3, 1, 1/*to_push_undo*/);
else if(argc==9) {
int x = !(atoi(argv[8]));
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 0, x);
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 0, x, 1/*to_push_undo*/);
}
}
@ -1481,30 +1481,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if (!strcmp(argv[1], "make_sch_from_sel"))
{
char filename[PATH_MAX]="";
cmd_found = 1;
my_snprintf(name, S(name), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR");
tcleval(name);
my_strncpy(filename, tclresult(), S(filename));
if (!strcmp(filename, xctx->sch[xctx->currsch])) {
if (has_x)
tcleval("tk_messageBox -type ok -message {Cannot overwrite current schematic}");
}
else if (strlen(filename)) {
make_schematic(filename);
delete();
place_symbol(-1, filename, 0, 0, 0, 0, NULL, 4, 1);
if (has_x)
{
my_snprintf(name, S(name), "tk_messageBox -type okcancel -message {do you want to make symbol view for %s ?}", filename);
tcleval(name);
}
if (!has_x || !strcmp(tclresult(), "ok")) {
my_snprintf(name, S(name), "make_symbol_lcc {%s}", filename);
dbg(1, "make_symbol_lcc(): making symbol: name=%s\n", filename);
tcleval(name);
}
}
make_schematic_symbol_from_sel();
Tcl_ResetResult(interp);
}
@ -1669,9 +1647,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap;
if(argc == 4) {
ret = place_symbol(-1,argv[2],xctx->mousex_snap, xctx->mousey_snap, 0, 0, argv[3], 4, 1);
ret = place_symbol(-1,argv[2],xctx->mousex_snap, xctx->mousey_snap, 0, 0, argv[3], 4, 1, 1/*to_push_undo*/);
} else if(argc == 3) {
ret = place_symbol(-1,argv[2],xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
ret = place_symbol(-1,argv[2],xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
} else {
#if 1 /* enable on request also in callback.c */
rebuild_selected_array();
@ -1680,7 +1658,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
abs_sym_path(xctx->inst[xctx->sel_array[0].n].name, ""), "}]", NULL);
}
#endif
ret = place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
ret = place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1, 1/*to_push_undo*/);
}
if(ret) {

View File

@ -317,7 +317,7 @@ static void del_rect_line_arc_poly(void)
}
void delete(void)
void delete(int to_push_undo)
{
int i, j, n, tmp;
#if HAS_CAIRO==1
@ -328,7 +328,7 @@ void delete(void)
j = 0;
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
rebuild_selected_array();
if(xctx->lastsel) push_undo();
if(to_push_undo && xctx->lastsel) push_undo();

View File

@ -874,12 +874,13 @@ extern const char *abs_sym_path(const char *s, const char *ext);
extern const char *add_ext(const char *f, const char *ext);
extern void make_symbol(void);
extern void make_schematic(const char *schname);
extern void make_schematic_symbol_from_sel(void);
extern const char *get_sym_template(char *s, char *extra);
/* bit0: invoke change_linewidth(), bit1: centered zoom */
extern void zoom_full(int draw, int sel, int flags, double shrink);
extern void updatebbox(int count,xRect *boundbox,xRect *tmp);
extern void draw_selection(GC g, int interruptable);
extern void delete(void);
extern void delete(int to_push_undo);
extern void delete_only_rect_line_arc_poly(void);
extern void polygon_bbox(double *x, double *y, int points, double *bx1, double *by1, double *bx2, double *by2);
extern void arc_bbox(double x, double y, double r, double a, double b,
@ -1004,7 +1005,7 @@ extern void clear_drawing(void);
extern int load_sym_def(const char name[], FILE *embed_fd);
extern void descend_symbol(void);
extern int place_symbol(int pos, const char *symbol_name, double x, double y, short rot, short flip,
const char *inst_props, int draw_sym, int first_call);
const char *inst_props, int draw_sym, int first_call, int to_push_undo);
extern void place_net_label(int type);
extern void attach_labels_to_inst(void);
extern void delete_files(void);

View File

@ -4097,7 +4097,7 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ]
-command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B
.menubar.sym.menu add command -label "Make symbol from schematic" -command "xschem make_symbol" -accelerator A
.menubar.sym.menu add command -label "Make schematic from symbol" -command "xschem make_sch" -accelerator Ctrl+L
.menubar.sym.menu add command -label "Make schematic and symbol from selected components" -command "xschem make_sch_from_sel"
.menubar.sym.menu add command -label "Make schematic and symbol from selected components" -command "xschem make_sch_from_sel" -accelerator Ctrl+Shift+H
.menubar.sym.menu add command -label "Attach pins to component instance" \
-command "xschem attach_pins" -accelerator Shift+H
.menubar.sym.menu add command -label "Create symbol pins from selected schematic pins" \