mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-10-06 18:02:52 +02:00
Extended the "cellname rename" command to add an option "-force"
that can be used to force renaming of a read-only cell. The action revokes the read-only status of the cell and removes any GDS filename and pointers from the cell's properties. This can be used to swap out a library cell in a layout for a custom version, by first forcing a rename of the cell, and then resetting the filepath of the cell and flushing.
This commit is contained in:
+7
-2
@@ -837,6 +837,7 @@ CmdCellname(w, cmd)
|
||||
bool is_cellname;
|
||||
bool dolist = FALSE;
|
||||
bool dodef = FALSE;
|
||||
bool doforce = FALSE;
|
||||
int option;
|
||||
int locargc = cmd->tx_argc;
|
||||
char *cellname = NULL, *orient = NULL;
|
||||
@@ -909,6 +910,10 @@ CmdCellname(w, cmd)
|
||||
dodef = TRUE;
|
||||
locargc--;
|
||||
}
|
||||
else if (!strcmp(option, "force")) {
|
||||
doforce = TRUE;
|
||||
locargc--;
|
||||
}
|
||||
}
|
||||
|
||||
if (locargc > 5 || locargc < 2) goto badusage;
|
||||
@@ -1276,7 +1281,7 @@ CmdCellname(w, cmd)
|
||||
case IDX_RENAME:
|
||||
/* Rename the cell and mark as modified. Do not write to disk. */
|
||||
if (locargc != 4) goto badusage;
|
||||
DBCellRename(cellname, cmd->tx_argv[3 + ((dolist) ? 1 : 0)]);
|
||||
DBCellRename(cellname, cmd->tx_argv[3 + ((dolist) ? 1 : 0)], doforce);
|
||||
break;
|
||||
case IDX_CREATE:
|
||||
newDef = DBCellLookDef(cellname);
|
||||
@@ -1312,7 +1317,7 @@ badusage:
|
||||
"instances|celldef|delete [name]\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s [list] allcells|topcells|window\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s create name\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s rename name newname\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s rename name newname [-force]\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s [un]lock [name]\n", cmd->tx_argv[0]);
|
||||
TxError("or: %s writeable [name] [true|false]\n", cmd->tx_argv[0]);
|
||||
return;
|
||||
|
||||
+32
-4
@@ -77,7 +77,10 @@ extern void DBSetUseIdHash();
|
||||
*
|
||||
* Rename a cell. This differs from the "save" command in that the
|
||||
* cell is not immediately written to disk. However, the cell is
|
||||
* marked as modified.
|
||||
* marked as modified. If "doforce" is TRUE, then allow renaming
|
||||
* of vendor (read-only) cells. Because vendor cells are tied to
|
||||
* a GDS file, then the vendor status gets revoked and the pointer
|
||||
* to the GDS file gets removed.
|
||||
*
|
||||
* Results:
|
||||
* Return TRUE if the cell was successfully renamed. Return FALSE
|
||||
@@ -89,9 +92,10 @@ extern void DBSetUseIdHash();
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
bool
|
||||
DBCellRename(cellname, newname)
|
||||
DBCellRename(cellname, newname, doforce)
|
||||
char *cellname;
|
||||
char *newname;
|
||||
bool doforce;
|
||||
{
|
||||
HashEntry *entry;
|
||||
CellDef *celldef;
|
||||
@@ -119,8 +123,16 @@ DBCellRename(cellname, newname)
|
||||
|
||||
if ((celldef->cd_flags & CDVENDORGDS) == CDVENDORGDS)
|
||||
{
|
||||
TxError("Error: Attempt to rename read-only cell \"%s\"\n", cellname);
|
||||
return FALSE;
|
||||
if (doforce)
|
||||
{
|
||||
TxPrintf("Warning: Renaming read-only cell \"%s\"\n", cellname);
|
||||
TxPrintf("Read-only status will be revoked and GDS file pointer removed.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
TxError("Error: Attempt to rename read-only cell \"%s\"\n", cellname);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Good to go! */
|
||||
@@ -129,6 +141,22 @@ DBCellRename(cellname, newname)
|
||||
result = DBCellRenameDef(celldef, newname);
|
||||
DBWAreaChanged(celldef, &celldef->cd_bbox, DBW_ALLWINDOWS,
|
||||
(TileTypeBitMask *) NULL);
|
||||
|
||||
if (doforce && ((celldef->cd_flags & CDVENDORGDS) == CDVENDORGDS))
|
||||
{
|
||||
char *chkgdsfile;
|
||||
bool isReadOnly;
|
||||
|
||||
chkgdsfile = (char *)DBPropGet(celldef, "GDS_FILE", &isReadOnly);
|
||||
/* Note that clearing GDS_FILE will also clear CDVENDORGDS flag */
|
||||
if (isReadOnly) DBPropPut(celldef, "GDS_FILE", NULL);
|
||||
|
||||
DBPropGet(celldef, "GDS_START", &isReadOnly);
|
||||
if (isReadOnly) DBPropPut(celldef, "GDS_START", NULL);
|
||||
DBPropGet(celldef, "GDS_END", &isReadOnly);
|
||||
if (isReadOnly) DBPropPut(celldef, "GDS_END", NULL);
|
||||
}
|
||||
|
||||
UndoEnable();
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user