Ti[GS]etClient() usage enforcement

All naked access to `ti_client` now uses the function-like-macro
to encapsulate this action.  This macro existed before this just
makes all sites utilize it.

Added additional INT and PTR variants to remove the programmer
load on thinking about casing and casts polluting the point
of use.  So the use now looks cleaner.

Equivalent prototypes:

 void TiSetClient(Tile*, ClientData)
 void TiSetClientINT(Tile*, intptr_t) /* pointertype */
 void TiSetClientPTR(Tile*, void*)

 ClientData TiGetClient(Tile*)
 intptr_t TiGetClientINT(Tile*) /* pointertype */
 void *TiGetClientPTR(Tile*)
This commit is contained in:
Darryl L. Miles
2025-04-09 14:55:58 -04:00
committed by R. Timothy Edwards
parent 6e83cbe2d3
commit 606f37cc80
27 changed files with 336 additions and 332 deletions
+30 -30
View File
@@ -3038,10 +3038,10 @@ extTransFindSubsFunc1(tile, noderecptr)
* regions under the same device)
*/
if (tile->ti_client != (ClientData) extUnInit)
if (TiGetClient(tile) != extUnInit)
{
if ((noderecptr->region != (NodeRegion *)NULL) &&
((ClientData)noderecptr->region != tile->ti_client))
(noderecptr->region != TiGetClientPTR(tile)))
TxError("Warning: Split substrate under device at (%d %d)\n",
tile->ti_ll.p_x, tile->ti_ll.p_y);
if (IsSplit(tile))
@@ -3052,7 +3052,7 @@ extTransFindSubsFunc1(tile, noderecptr)
else
type = TiGetTypeExact(tile);
noderecptr->region = (NodeRegion *)tile->ti_client;
noderecptr->region = (NodeRegion *)TiGetClientPTR(tile);
noderecptr->layer = type;
return 1;
}
@@ -3495,8 +3495,8 @@ extTermAPFunc(tile, pNum, eapd)
eapd->eapd_perim += MIN(RIGHT(tile), RIGHT(tp)) -
MAX(LEFT(tile), LEFT(tp));
if (TTMaskHasType(eapd->eapd_gatemask, type))
if (tp->ti_client != (ClientData)eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)tp->ti_client);
if (TiGetClientPTR(tp) != eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)TiGetClientPTR(tp));
}
}
@@ -3509,8 +3509,8 @@ extTermAPFunc(tile, pNum, eapd)
eapd->eapd_perim += MIN(RIGHT(tile), RIGHT(tp)) -
MAX(LEFT(tile), LEFT(tp));
if (TTMaskHasType(eapd->eapd_gatemask, type))
if (tp->ti_client != (ClientData)eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)tp->ti_client);
if (TiGetClientPTR(tp) != eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)TiGetClientPTR(tp));
}
}
@@ -3523,8 +3523,8 @@ extTermAPFunc(tile, pNum, eapd)
eapd->eapd_perim += MIN(TOP(tile), TOP(tp)) -
MAX(BOTTOM(tile), BOTTOM(tp));
if (TTMaskHasType(eapd->eapd_gatemask, type))
if (tp->ti_client != (ClientData)eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)tp->ti_client);
if (TiGetClientPTR(tp) != eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)TiGetClientPTR(tp));
}
}
@@ -3537,8 +3537,8 @@ extTermAPFunc(tile, pNum, eapd)
eapd->eapd_perim += MIN(TOP(tile), TOP(tp)) -
MAX(BOTTOM(tile), BOTTOM(tp));
if (TTMaskHasType(eapd->eapd_gatemask, type))
if (tp->ti_client != (ClientData)eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)tp->ti_client);
if (TiGetClientPTR(tp) != eapd->eapd_gatenode)
extAddSharedDevice(eapd, (NodeRegion *)TiGetClientPTR(tp));
}
}
@@ -4803,9 +4803,9 @@ extNodeAreaFunc(tile, arg)
* been visited in the meantime. If it's still unvisited,
* visit it and process its neighbors.
*/
if (tile->ti_client == (ClientData) reg)
if (TiGetClientPTR(tile) == reg)
continue;
tile->ti_client = (ClientData) reg;
TiSetClientPTR(tile, reg);
if (DebugIsSet(extDebugID, extDebNeighbor))
extShowTile(tile, "neighbor", 1);
@@ -4909,21 +4909,21 @@ topside:
if (IsSplit(tp))
{
t = SplitBottomType(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILEBOTTOM(tp, tilePlaneNum);
}
else if (tp->ti_client != (ClientData)reg && TTMaskHasType(mask, t))
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
{
/* Count split tile twice, once for each node it belongs to. */
tp->ti_client = extUnInit;
TiSetClient(tp, extUnInit);
PUSHTILEBOTTOM(tp, tilePlaneNum);
}
}
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -4954,21 +4954,21 @@ leftside:
if (IsSplit(tp))
{
t = SplitRightType(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILERIGHT(tp, tilePlaneNum);
}
else if (tp->ti_client != (ClientData)reg && TTMaskHasType(mask, t))
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
{
/* Count split tile twice, once for each node it belongs to. */
tp->ti_client = extUnInit;
TiSetClient(tp, extUnInit);
PUSHTILERIGHT(tp, tilePlaneNum);
}
}
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -5000,21 +5000,21 @@ bottomside:
if (IsSplit(tp))
{
t = SplitTopType(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILETOP(tp, tilePlaneNum);
}
else if (tp->ti_client != (ClientData)reg && TTMaskHasType(mask, t))
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
{
/* Count split tile twice, once for each node it belongs to. */
tp->ti_client = extUnInit;
TiSetClient(tp, extUnInit);
PUSHTILETOP(tp, tilePlaneNum);
}
}
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -5045,21 +5045,21 @@ rightside:
if (IsSplit(tp))
{
t = SplitLeftType(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILELEFT(tp, tilePlaneNum);
}
else if (tp->ti_client != (ClientData)reg && TTMaskHasType(mask, t))
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
{
/* Count split tile twice, once for each node it belongs to */
tp->ti_client = extUnInit;
TiSetClient(tp, extUnInit);
PUSHTILELEFT(tp, tilePlaneNum);
}
}
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extUnInit && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -5090,7 +5090,7 @@ donesides:
GOTOPOINT(tp, &tile->ti_ll);
plane->pl_hint = tp;
if (tp->ti_client != extUnInit) continue;
if (TiGetClient(tp) != extUnInit) continue;
/* tp and tile should have the same geometry for a contact */
if (IsSplit(tile) && IsSplit(tp))
+9 -9
View File
@@ -108,7 +108,7 @@ struct extPathFloodArg
};
/* Used to mark tiles during path tracing */
#define MARKED ((ClientData) 1)
#define MARKED (1)
/* Forward declarations */
Label *extPathLabel();
@@ -665,7 +665,7 @@ extPathPairDistance(lab1, lab2, pMin, pMax)
/* Reset ti_client fields in tiles */
for (pNum = PL_TECHDEPBASE; pNum < DBNumPlanes; pNum++)
(void) DBSrPaintClient((Tile *) NULL, extPathDef->cd_planes[pNum],
&TiPlaneRect, &DBAllButSpaceBits, MARKED,
&TiPlaneRect, &DBAllButSpaceBits, (ClientData) MARKED,
extPathResetClient, (ClientData) NULL);
}
@@ -688,7 +688,7 @@ int
extPathResetClient(tile)
Tile *tile;
{
tile->ti_client = (ClientData) CLIENTDEFAULT;
TiSetClient(tile, CLIENTDEFAULT);
return (0);
}
@@ -780,7 +780,7 @@ extPathFlood(tile, p, distance, epa)
Rect r;
/* Mark the tile as being visited */
tile->ti_client = MARKED;
TiSetClientINT(tile, MARKED);
/*
* Are we at the destination yet?
@@ -820,22 +820,22 @@ extPathFlood(tile, p, distance, epa)
/* TOP */
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp))
if (tp->ti_client != MARKED && DBConnectsTo(TiGetType(tp), type))
if (TiGetClientINT(tp) != MARKED && DBConnectsTo(TiGetType(tp), type))
extPathFloodTile(tile, p, distance, tp, epa);
/* RIGHT */
for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp = LB(tp))
if (tp->ti_client != MARKED && DBConnectsTo(TiGetType(tp), type))
if (TiGetClientINT(tp) != MARKED && DBConnectsTo(TiGetType(tp), type))
extPathFloodTile(tile, p, distance, tp, epa);
/* BOTTOM */
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp))
if (tp->ti_client != MARKED && DBConnectsTo(TiGetType(tp), type))
if (TiGetClientINT(tp) != MARKED && DBConnectsTo(TiGetType(tp), type))
extPathFloodTile(tile, p, distance, tp, epa);
/* LEFT */
for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
if (tp->ti_client != MARKED && DBConnectsTo(TiGetType(tp), type))
if (TiGetClientINT(tp) != MARKED && DBConnectsTo(TiGetType(tp), type))
extPathFloodTile(tile, p, distance, tp, epa);
/* Try connections to other planes */
@@ -856,7 +856,7 @@ extPathFlood(tile, p, distance, epa)
plane->pl_hint = tp;
/* If not yet visited, process tp */
if (tp->ti_client == (ClientData) CLIENTDEFAULT
if (TiGetClient(tp) == CLIENTDEFAULT
&& DBConnectsTo(type, TiGetType(tp)))
{
epa->epa_pNum = pNum;
+17 -17
View File
@@ -117,9 +117,9 @@ ExtFindNeighbors(tile, tilePlaneNum, arg)
* been visited in the meantime. If it's still unvisited,
* visit it and process its neighbors.
*/
if (tile->ti_client == (ClientData) arg->fra_region)
if (TiGetClientPTR(tile) == arg->fra_region)
continue;
tile->ti_client = (ClientData) arg->fra_region;
TiSetClientPTR(tile, arg->fra_region);
tilesfound++;
if (DebugIsSet(extDebugID, extDebNeighbor))
extShowTile(tile, "neighbor", 1);
@@ -132,8 +132,8 @@ topside:
if (IsSplit(tp))
{
t = SplitBottomType(tp);
// if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (tp->ti_client != (ClientData)arg->fra_region && TTMaskHasType(mask, t))
// if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClientPTR(tp) != arg->fra_region && TTMaskHasType(mask, t))
{
PUSHTILEBOTTOM(tp, tilePlaneNum);
}
@@ -141,7 +141,7 @@ topside:
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -156,8 +156,8 @@ leftside:
if (IsSplit(tp))
{
t = SplitRightType(tp);
// if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (tp->ti_client != (ClientData)arg->fra_region && TTMaskHasType(mask, t))
// if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClientPTR(tp) != arg->fra_region && TTMaskHasType(mask, t))
{
PUSHTILERIGHT(tp, tilePlaneNum);
}
@@ -165,7 +165,7 @@ leftside:
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -181,8 +181,8 @@ bottomside:
if (IsSplit(tp))
{
t = SplitTopType(tp);
// if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (tp->ti_client != (ClientData)arg->fra_region && TTMaskHasType(mask, t))
// if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClientPTR(tp) != arg->fra_region && TTMaskHasType(mask, t))
{
PUSHTILETOP(tp, tilePlaneNum);
}
@@ -190,7 +190,7 @@ bottomside:
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -205,8 +205,8 @@ rightside:
if (IsSplit(tp))
{
t = SplitLeftType(tp);
// if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (tp->ti_client != (ClientData)arg->fra_region && TTMaskHasType(mask, t))
// if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClientPTR(tp) != arg->fra_region && TTMaskHasType(mask, t))
{
PUSHTILELEFT(tp, tilePlaneNum);
}
@@ -214,7 +214,7 @@ rightside:
else
{
t = TiGetTypeExact(tp);
if (tp->ti_client == extNbrUn && TTMaskHasType(mask, t))
if (TiGetClient(tp) == extNbrUn && TTMaskHasType(mask, t))
{
PUSHTILE(tp, tilePlaneNum);
}
@@ -240,7 +240,7 @@ donesides:
tp = plane->pl_hint;
GOTOPOINT(tp, &tile->ti_ll);
plane->pl_hint = tp;
if (tp->ti_client != extNbrUn) continue;
if (TiGetClient(tp) != extNbrUn) continue;
/* tp and tile should have the same geometry for a contact */
if (IsSplit(tile) && IsSplit(tp))
@@ -317,7 +317,7 @@ fail:
while (!StackEmpty(extNodeStack))
{
POPTILE(tile, tilePlaneNum);
tile->ti_client = (ClientData) arg->fra_region;
TiSetClientPTR(tile, arg->fra_region);
}
return -1;
}
@@ -356,7 +356,7 @@ extNbrPushFunc(tile, pla)
tileArea = &pla->area;
/* Ignore tile if it's already been visited */
if (tile->ti_client != extNbrUn)
if (TiGetClient(tile) != extNbrUn)
return 0;
/* Only consider tile if it overlaps tileArea or shares part of a side */