Finally reworked "cells" command behavior into something
consistent.
This commit is contained in:
parent
fdf2f32654
commit
70bb33cc62
|
|
@ -563,8 +563,11 @@ static int PrintCellHashTableElement(struct hashlist *p)
|
||||||
/* only print primitive cells if Debug is enabled */
|
/* only print primitive cells if Debug is enabled */
|
||||||
if (Debug == 1) Printf("Cell: %s (instanced %d times); Primitive\n",
|
if (Debug == 1) Printf("Cell: %s (instanced %d times); Primitive\n",
|
||||||
ptr->name, ptr->number);
|
ptr->name, ptr->number);
|
||||||
|
else if (Debug == 3) { /* list */
|
||||||
|
Tcl_AppendElement(netgeninterp, ptr->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Debug == 2) { /* list only */
|
else if ((Debug == 2) || (Debug == 3)) { /* list only */
|
||||||
#ifdef TCL_NETGEN
|
#ifdef TCL_NETGEN
|
||||||
Tcl_AppendElement(netgeninterp, ptr->name);
|
Tcl_AppendElement(netgeninterp, ptr->name);
|
||||||
#else
|
#else
|
||||||
|
|
@ -595,7 +598,7 @@ void PrintCellHashTable(int full, int filenum)
|
||||||
|
|
||||||
bins = RecurseHashTable(&cell_dict, CountHashTableBinsUsed);
|
bins = RecurseHashTable(&cell_dict, CountHashTableBinsUsed);
|
||||||
total = RecurseHashTable(&cell_dict, CountHashTableEntries);
|
total = RecurseHashTable(&cell_dict, CountHashTableEntries);
|
||||||
if (full != 2)
|
if (full < 2)
|
||||||
Printf("Hash table: %d of %d bins used; %d cells total (%.2f per bin)\n",
|
Printf("Hash table: %d of %d bins used; %d cells total (%.2f per bin)\n",
|
||||||
bins, CELLHASHSIZE, total, (bins == 0) ? 0 :
|
bins, CELLHASHSIZE, total, (bins == 0) ? 0 :
|
||||||
(float)((float)total / (float)bins));
|
(float)((float)total / (float)bins));
|
||||||
|
|
@ -605,7 +608,7 @@ void PrintCellHashTable(int full, int filenum)
|
||||||
RecurseHashTable(&cell_dict, PrintCellHashTableElement);
|
RecurseHashTable(&cell_dict, PrintCellHashTableElement);
|
||||||
Debug = OldDebug;
|
Debug = OldDebug;
|
||||||
#ifndef TCL_NETGEN
|
#ifndef TCL_NETGEN
|
||||||
if (full == 2) Printf("\n");
|
if (full >= 2) Printf("\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1437,9 +1437,9 @@ _netgen_cells(ClientData clientData,
|
||||||
char *optstart;
|
char *optstart;
|
||||||
int filenum = -1;
|
int filenum = -1;
|
||||||
struct nlist *np = NULL;
|
struct nlist *np = NULL;
|
||||||
int result, dolist = 0;
|
int result, printopt, dolist = 0, doall = 0, dotop = 0;
|
||||||
|
|
||||||
if (objc > 1) {
|
while (objc > 1) {
|
||||||
optstart = Tcl_GetString(objv[1]);
|
optstart = Tcl_GetString(objv[1]);
|
||||||
if (*optstart == '-') optstart++;
|
if (*optstart == '-') optstart++;
|
||||||
if (!strcmp(optstart, "list")) {
|
if (!strcmp(optstart, "list")) {
|
||||||
|
|
@ -1447,27 +1447,41 @@ _netgen_cells(ClientData clientData,
|
||||||
objv++;
|
objv++;
|
||||||
objc--;
|
objc--;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(optstart, "all")) {
|
||||||
|
doall = 1;
|
||||||
|
objv++;
|
||||||
|
objc--;
|
||||||
|
}
|
||||||
|
else if (!strcmp(optstart, "top")) {
|
||||||
|
dotop = 1;
|
||||||
|
objv++;
|
||||||
|
objc--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = CommonParseCell(interp, objv[1], &np, &filenum);
|
||||||
|
if (result != TCL_OK) return result;
|
||||||
|
objv++;
|
||||||
|
objc--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objc == 1) {
|
if (objc != 1) {
|
||||||
PrintCellHashTable((dolist) ? 2 : 0, -1);
|
Tcl_WrongNumArgs(interp, 1, objv, "[list] [-top] [-all] [valid_filename]");
|
||||||
}
|
|
||||||
else if (objc != 2 && objc != 3) {
|
|
||||||
Tcl_WrongNumArgs(interp, 1, objv, "[list] -top|[-all] valid_filename");
|
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Tcl_Obj *lobj;
|
Tcl_Obj *lobj;
|
||||||
|
|
||||||
repstr = Tcl_GetString(objv[1]);
|
if (dotop) {
|
||||||
if (!strncmp(repstr, "-top", 4)) {
|
|
||||||
if (dolist)
|
if (dolist)
|
||||||
lobj = Tcl_NewListObj(0, NULL);
|
lobj = Tcl_NewListObj(0, NULL);
|
||||||
else
|
else
|
||||||
Fprintf(stdout, "Top level cells: ");
|
Fprintf(stdout, "Top level cells: ");
|
||||||
np = FirstCell();
|
np = FirstCell();
|
||||||
while (np != NULL) {
|
while (np != NULL) {
|
||||||
if (np->flags & CELL_TOP) {
|
if ((np->flags & CELL_TOP) && ((filenum == -1) ||
|
||||||
|
(np->file == filenum))) {
|
||||||
|
|
||||||
if (dolist)
|
if (dolist)
|
||||||
Tcl_ListObjAppendElement(interp, lobj,
|
Tcl_ListObjAppendElement(interp, lobj,
|
||||||
Tcl_NewStringObj(np->name, -1));
|
Tcl_NewStringObj(np->name, -1));
|
||||||
|
|
@ -1483,11 +1497,13 @@ _netgen_cells(ClientData clientData,
|
||||||
|
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
else if (strncmp(repstr, "-all", 4)) {
|
else {
|
||||||
result = CommonParseCell(interp, objv[2], &np, &filenum);
|
if (dolist)
|
||||||
if (result != TCL_OK) return result;
|
printopt = (doall) ? 3 : 2;
|
||||||
|
else
|
||||||
|
printopt = (doall) ? 1 : 0;
|
||||||
|
PrintCellHashTable(printopt, filenum);
|
||||||
}
|
}
|
||||||
PrintCellHashTable((dolist) ? 2 : 1, filenum);
|
|
||||||
}
|
}
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue