extflat: integrate cb_extflat_visitresists_t for EFVisitResists()

Additionally the HierName's hierName1 and hierName2 arguments have been
made 'const' to help convey the receiver can not modify the referenced
data passed.
This commit is contained in:
Darryl L. Miles 2025-07-20 16:09:08 +01:00
parent 0bb29ae5f8
commit 0141a99af5
5 changed files with 26 additions and 22 deletions

View File

@ -1122,7 +1122,7 @@ runexttospice:
if (flatFlags & EF_FLATCAPS)
EFVisitCaps(spccapVisit, (ClientData) NULL);
EFVisitResists(spcresistVisit, (ClientData) NULL);
EFVisitResists(spcresistVisit, PTR2CD(NULL));
EFVisitSubcircuits(subcktVisit, (ClientData) NULL);
/* Visit nodes to find the substrate node */
@ -1298,7 +1298,7 @@ main(
if (flatFlags & EF_FLATCAPS)
EFVisitCaps(spccapVisit, (ClientData) NULL);
EFVisitResists(spcresistVisit, (ClientData) NULL);
EFVisitResists(spcresistVisit, PTR2CD(NULL));
EFVisitSubcircuits(subcktVisit, (ClientData) NULL);
esSpiceCapNode = StrDup((char **)NULL, esSpiceDefaultGnd);
EFVisitNodes(spcnodeVisit, (ClientData) NULL);
@ -3653,11 +3653,12 @@ spccapVisit(
* ----------------------------------------------------------------------------
*/
/* ARGSUSED */
/* @typedef cb_extflat_visitresists_t (UNUSED) */
int
spcresistVisit(
HierName *hierName1,
HierName *hierName2,
const HierName *hierName1,
const HierName *hierName2,
float res,
ClientData cdata) /* unused */
{

View File

@ -25,7 +25,7 @@ extern int spccapVisit(HierName *hierName1, HierName *hierName2, double cap, Cli
extern int spcdevVisit(Dev *dev, HierContext *hc, float scale, Transform *trans, ClientData cdata); /* @typedef cb_extflat_visitdevs_t (UNUSED) */
extern int spcnodeVisit(EFNode *node, int res, double cap, ClientData cdata); /* @typedef cb_extflat_visitnodes_t (UNUSED) */
extern int subcktVisit(Use *use, HierName *hierName, bool is_top); /* @typedef cb_extflat_visitsubcircuits_t */
extern int spcresistVisit(HierName *hierName1, HierName *hierName2, float res, ClientData cdata); /* @typedef cb_extflat_visitresists_t (UNUSED) */
extern int spcresistVisit(const HierName *hierName1, const HierName *hierName2, float res, ClientData cdata); /* @typedef cb_extflat_visitresists_t (UNUSED) */
extern int devMergeVisit(Dev *dev, HierContext *hc, float scale, Transform *trans, ClientData cdata); /* @typedef cb_extflat_visitdevs_t (UNUSED) */
extern int devDistJunctVisit(Dev *dev, HierContext *hc, float scale, Transform *trans, ClientData cdata); /* @typedef cb_extflat_visitdevs_t (UNUSED) */
extern int spcsubVisit(EFNode *node, int res, double cap, ClientData cdata); /* @typedef cb_extflat_visitnodes_t (char** resstr) */

View File

@ -54,7 +54,7 @@ int ecNumNodeResists;
int nodeVisit(EFNode *node, int res, double cap, ClientData cdata); /* @typedef cb_extflat_visitnodes_t (UNUSED) */
int devVisit(Dev *dev, HierContext *hc, float scale, Transform *trans, ClientData cdata); /* @typedef cb_extflat_visitdevs_t (UNUSED) */
int capVisit(HierName *hn1, HierName *hn2, double cap, ClientData cdata); /* @typedef cb_extflat_visitcaps_t (UNUSED) */
int resistVisit(HierName *hn1, HierName *hn2, float res, ClientData cdata); /* @typedef cb_extflat_visitresists_t (UNUSED) */
int resistVisit(const HierName *hn1, const HierName *hn2, float res, ClientData cdata); /* @typedef cb_extflat_visitresists_t (UNUSED) */
/*
* ----------------------------------------------------------------------------
@ -89,7 +89,7 @@ main(int argc, char *argv[])
if (IS_FINITE_F(EFCapThreshold))
EFVisitCaps(capVisit, (ClientData) NULL);
if (EFResistThreshold != INFINITE_THRESHOLD)
EFVisitResists(resistVisit, (ClientData) NULL);
EFVisitResists(resistVisit, PTR2CD(NULL));
EFVisitNodes(nodeVisit, (ClientData) NULL);
#ifdef free_all_mem
@ -181,8 +181,8 @@ capVisit(
/* @typedef cb_extflat_visitresists_t (UNUSED) */
int
resistVisit(
HierName *hn1,
HierName *hn2, /* UNUSED */
const HierName *hn1,
const HierName *hn2,/* UNUSED */
float res,
ClientData cdata) /* UNUSED */
{

View File

@ -456,12 +456,14 @@ skip:
* Must be called after EFFlatBuild().
* For each resistor in the circuit, call the user-supplied procedure
* (*resProc)(), which should be of the following form, where hn1 and
* hn2 are the HierNames of the two nodes connected by the resistor.
* hn2 are the HierNames of the two nodes connected by the resistor
* see also typedef cb_extflat_visitresists_t:
*
* (*resProc)(hn1, hn2, resistance, cdata)
* HierName *hn1, *hn2;
* int resistance;
* ClientData cdata;
* int (*resProc)(
* const HierName *hn1,
* const HierName *hn2,
* float resistance,
* ClientData cdata)
* {
* }
*
@ -482,15 +484,15 @@ skip:
*/
int
EFVisitResists(resProc, cdata)
int (*resProc)();
ClientData cdata;
EFVisitResists(
const cb_extflat_visitresists_t resProc,
ClientData cdata)
{
CallArg ca;
ca.ca_proc = resProc;
ca.ca_proc = (int (*)()) resProc;
ca.ca_cdata = cdata;
return efVisitResists(&efFlatContext, (ClientData) &ca);
return efVisitResists(&efFlatContext, &ca);
}
/*
@ -585,7 +587,7 @@ efVisitSingleResist(hc, name1, name2, res, ca)
return (*ca->ca_proc)(n1->efnode_name->efnn_hier,
n2->efnode_name->efnn_hier,
res->conn_res, ca->ca_cdata);
res->conn_res, ca->ca_cdata); /* @invoke cb_extflat_visitresists_t */
}
/*

View File

@ -118,8 +118,9 @@ typedef int (*cb_extflat_visitdevs_t)(Dev *dev, HierContext *hc, float scale, Tr
extern int EFVisitDevs(const cb_extflat_visitdevs_t devProc, ClientData cdata);
extern int efVisitDevs(HierContext *hc, CallArg *ca);
extern bool efSymLook();
extern int efVisitResists();
extern int EFVisitResists();
extern int efVisitResists(HierContext *hc, CallArg *ca);
typedef int (*cb_extflat_visitresists_t)(const HierName *hn1, const HierName *hn2, float resistance, ClientData cdata);
extern int EFVisitResists(const cb_extflat_visitresists_t resProc, ClientData cdata);
extern int EFVisitNodes();
extern int EFVisitCaps();
extern void EFGetLengthAndWidth();