cif: use 'const' with readonly data (also consumer DBpaint)

This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
This commit is contained in:
Darryl L. Miles 2024-10-04 11:42:25 +01:00 committed by Tim Edwards
parent 4e768d5a3d
commit ac56dd71a9
7 changed files with 18 additions and 17 deletions

View File

@ -67,8 +67,8 @@ global Plane *CIFPlanes[MAXCIFLAYERS];
* have two entries each.
*/
PaintResultType CIFPaintTable[] = {CIF_SOLIDTYPE, CIF_SOLIDTYPE};
PaintResultType CIFEraseTable[] = {TT_SPACE, TT_SPACE};
const PaintResultType CIFPaintTable[] = {CIF_SOLIDTYPE, CIF_SOLIDTYPE};
const PaintResultType CIFEraseTable[] = {TT_SPACE, TT_SPACE};
/* The following local variables are used as a convenience to pass
* information between CIFGen and the various search functions.
@ -549,7 +549,7 @@ cifGrowGridFunc(
int
cifGrowEuclideanFunc(
Tile *tile,
PaintResultType *table) /* Table to be used for painting. */
const PaintResultType *table) /* Table to be used for painting. */
{
Tile *tp;
Rect area, rtmp;
@ -762,7 +762,7 @@ cifGrowEuclideanFunc(
int
cifGrowFunc(
Tile *tile,
PaintResultType *table) /* Table to be used for painting. */
const PaintResultType *table) /* Table to be used for painting. */
{
Rect area;
TileType oldType = TiGetTypeExact(tile);

View File

@ -374,7 +374,7 @@ extern int CIFHierRects;
/* Tables used for painting and erasing CIF. */
extern PaintResultType CIFPaintTable[], CIFEraseTable[];
extern const PaintResultType CIFPaintTable[], CIFEraseTable[];
/* Procedures and variables for reporting errors. */

View File

@ -234,7 +234,7 @@ LinkedRect *
CIFPolyToRects(
CIFPath *path, /* Path describing a polygon. */
Plane *plane, /* Plane to draw on */
PaintResultType *resultTbl,
const PaintResultType *resultTbl,
PaintUndoInfo *ui,
bool isCalma) /* TRUE for Calma, FALSE for CIF */
{

View File

@ -321,7 +321,7 @@ CIFPaintWirePath(
int width,
bool endcap,
Plane *plane,
PaintResultType *ptable,
const PaintResultType *ptable,
PaintUndoInfo *ui)
{
CIFPath *pathp, *previousp, *nextp, *polypath;

View File

@ -1052,7 +1052,7 @@ void
CIFMakeManhattanPath(
CIFPath *pathHead,
Plane *plane,
PaintResultType *resultTbl,
const PaintResultType *resultTbl,
PaintUndoInfo *ui)
{
CIFPath *new, *new2, *next, *path;

View File

@ -174,7 +174,7 @@ extern void CIFFreePath(CIFPath *path);
extern void CIFCleanPath(CIFPath *pathHead);
extern void CIFReadCellInit(int ptrkeys);
extern void CIFReadCellCleanup(int filetype);
extern LinkedRect *CIFPolyToRects(CIFPath *path, Plane *plane, PaintResultType *resultTbl,
extern LinkedRect *CIFPolyToRects(CIFPath *path, Plane *plane, const PaintResultType *resultTbl,
PaintUndoInfo *ui, bool isCalma);
extern const Transform *CIFDirectionToTrans(const Point *point);
extern int CIFReadNameToType(char *name, bool newOK);
@ -182,8 +182,9 @@ extern int CIFReadNameToType(char *name, bool newOK);
extern int CIFCalmaLayerToCifLayer(int layer, int datatype, CIFReadStyle *calmaStyle);
extern void CIFPropRecordPath(CellDef *def, CIFPath *pathheadp, bool iswire, char *propname);
extern void CIFPaintWirePath(CIFPath *pathheadp, int width, bool endcap, Plane *plane,
PaintResultType *ptable, PaintUndoInfo *ui);
extern void CIFMakeManhattanPath(CIFPath *pathHead, Plane *plane, PaintResultType *resultTbl, PaintUndoInfo *ui);
const PaintResultType *ptable, PaintUndoInfo *ui);
extern void CIFMakeManhattanPath(CIFPath *pathHead, Plane *plane, const PaintResultType *resultTbl, PaintUndoInfo *ui);
extern int CIFEdgeDirection(CIFPath *first, CIFPath *last);
/* Variable argument procedures require complete prototype */

View File

@ -240,7 +240,7 @@ int
DBPaintPlane0(plane, area, resultTbl, undo, method)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
PaintResultType *resultTbl; /* Table, indexed by the type of tile already
const PaintResultType *resultTbl; /* Table, indexed by the type of tile already
* present in the plane, giving the type to
* which the existing tile must change as a
* result of this paint operation.
@ -766,7 +766,7 @@ void
DBFracturePlane(plane, area, resultTbl, undo)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
PaintResultType *resultTbl; /* Paint table, to pinpoint those tiles
const PaintResultType *resultTbl; /* Paint table, to pinpoint those tiles
* that interact with the paint type.
*/
PaintUndoInfo *undo; /* Record containing everything needed to
@ -1340,7 +1340,7 @@ DBDiagonalProc(oldtype, dinfo)
TileType old_n, old_s, old_e, old_w;
TileType new_n, new_s, new_e, new_w;
TileType newtype;
PaintResultType *resultTbl = dinfo->resultTbl;
const PaintResultType *resultTbl = dinfo->resultTbl;
/* Disassemble old and new types into four quadrants, find the */
/* paint result for each quadrant, then reassemble the result. */
@ -1457,7 +1457,7 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
Plane *plane; /* Plane whose paint is to be modified */
TileType exacttype; /* diagonal info for tile to be changed */
Rect *area; /* Area to be changed */
PaintResultType *resultTbl; /* Table, indexed by the type of tile already
const PaintResultType *resultTbl; /* Table, indexed by the type of tile already
* present in the plane, giving the type to
* which the existing tile must change as a
* result of this paint operation.
@ -2064,7 +2064,7 @@ void
DBPaintType(plane, area, resultTbl, client, undo, tileMask)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
PaintResultType *resultTbl; /* Table, indexed by the type of tile already
const PaintResultType *resultTbl; /* Table, indexed by the type of tile already
* present in the plane, giving the type to
* which the existing tile must change as a
* result of this paint operation.
@ -2555,7 +2555,7 @@ int
DBPaintPlaneVert(plane, area, resultTbl, undo)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
PaintResultType *resultTbl; /* Table, indexed by the type of tile already
const PaintResultType *resultTbl; /* Table, indexed by the type of tile already
* present in the plane, giving the type to
* which the existing tile must change as a
* result of this paint operation.