CKTfndMod(), return the found model instead of error code
This commit is contained in:
parent
b97c2ba5d1
commit
f0882dbdfd
|
|
@ -624,7 +624,7 @@ finddev_special(
|
|||
|
||||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
err = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
err = *modptr ? OK : E_NOMOD;
|
||||
if (err == OK) {
|
||||
*device_or_model = 1;
|
||||
|
|
@ -1225,7 +1225,7 @@ finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
|
|||
|
||||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
err = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
err = *modptr ? OK : E_NOMOD;
|
||||
if (err == OK)
|
||||
return (type);
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ extern void CKTncDump(CKTcircuit *);
|
|||
extern int CKTfndAnal(CKTcircuit *, int *, JOB **, IFuid , TSKtask *, IFuid);
|
||||
extern int CKTfndBranch(CKTcircuit *, IFuid);
|
||||
extern GENinstance *CKTfndDev(CKTcircuit *, IFuid);
|
||||
extern int CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid);
|
||||
extern GENmodel *CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid);
|
||||
extern int CKTfndNode(CKTcircuit *, CKTnode **, IFuid);
|
||||
extern int CKTfndTask(CKTcircuit *, TSKtask **, IFuid );
|
||||
extern int CKTground(CKTcircuit *, CKTnode **, IFuid);
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ struct IFsimulator {
|
|||
/* set a parameter on a model */
|
||||
int (*askModelQuest) (CKTcircuit *, GENmodel *, int, IFvalue *, IFvalue *);
|
||||
/* ask a questions about a model */
|
||||
int (*findModel) (CKTcircuit *, int *, GENmodel **, IFuid);
|
||||
GENmodel *(*findModel) (CKTcircuit *, int *, GENmodel **, IFuid);
|
||||
/* find a specific model */
|
||||
int (*deleteModel) (CKTcircuit *, GENmodel *);
|
||||
/* delete a model from the circuit*/
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Author: 1985 Thomas L. Quarles
|
|||
|
||||
|
||||
|
||||
int
|
||||
GENmodel *
|
||||
CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
|
||||
{
|
||||
GENmodel *mods;
|
||||
|
|
@ -21,7 +21,7 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
|
|||
if(modfast != NULL && *modfast != NULL) {
|
||||
/* already have modfast, so nothing to do */
|
||||
if(type) *type = (*modfast)->GENmodType;
|
||||
return(OK);
|
||||
return *modfast;
|
||||
}
|
||||
if(*type >=0 && *type < DEVmaxnum) {
|
||||
/* have device type, need to find model */
|
||||
|
|
@ -30,10 +30,10 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
|
|||
mods = mods->GENnextModel) {
|
||||
if(mods->GENmodName == modname) {
|
||||
*modfast = mods;
|
||||
return(OK);
|
||||
return *modfast;
|
||||
}
|
||||
}
|
||||
return(E_NOMOD);
|
||||
return NULL;
|
||||
} else if(*type == -1) {
|
||||
/* look through all types (UGH - worst case - take forever) */
|
||||
for(*type = 0;*type <DEVmaxnum;(*type)++) {
|
||||
|
|
@ -43,11 +43,11 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
|
|||
mods = mods->GENnextModel) {
|
||||
if(mods->GENmodName == modname) {
|
||||
*modfast = mods;
|
||||
return(OK);
|
||||
return *modfast;
|
||||
}
|
||||
}
|
||||
}
|
||||
*type = -1;
|
||||
return(E_NOMOD);
|
||||
} else return(E_NOMOD);
|
||||
return NULL;
|
||||
} else return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name)
|
|||
|
||||
// assert(second)
|
||||
// assert(third && *third == NULL)
|
||||
error = CKTfndMod(ckt, &type, &mymodfast, name);
|
||||
mymodfast = CKTfndMod(ckt, &type, &mymodfast, name);
|
||||
error = mymodfast ? OK : E_NOMOD;
|
||||
if(error == E_NOMOD) {
|
||||
mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize));
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
|||
type = -1;
|
||||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
error = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
error = modfast ? OK : E_NOMOD;
|
||||
if (error)
|
||||
return error;
|
||||
|
|
@ -330,7 +330,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
|||
type = -1;
|
||||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
error = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
error = modfast ? OK : E_NOMOD;
|
||||
if (error)
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -1399,7 +1399,7 @@ get_mod_param TCL_CMDPROCARGS(clientData, interp, argc, argv)
|
|||
typecode = -1;
|
||||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
err = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name);
|
||||
modptr = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name);
|
||||
err = modptr ? OK : E_NOMOD;
|
||||
} else {
|
||||
typecode = devptr->GENmodPtr->GENmodType;
|
||||
|
|
|
|||
Loading…
Reference in New Issue