From f031d16f5044f252f3c3fccc3ab13ae45ebd5738 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 18 Jul 2025 22:50:28 +0100 Subject: [PATCH] database.h: refactor struct ArrayInfo defn into it arrayinfo.h EFint.t has an ugly ifndef _DATABASE_H that is very include order dependent (brittle to failure) so this moves the (struct ArrayInfo) type definition into its own file, which has standard ifndef once file guards. So include file order no longer matters. Copyright plate taken from database.h.in --- database/arrayinfo.h | 62 ++++++++++++++++++++++++++++++++++++++++++ database/database.h.in | 41 +--------------------------- extflat/EFint.h | 9 +----- 3 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 database/arrayinfo.h diff --git a/database/arrayinfo.h b/database/arrayinfo.h new file mode 100644 index 00000000..715986c2 --- /dev/null +++ b/database/arrayinfo.h @@ -0,0 +1,62 @@ +/* + * arrayinfo.h -- + * + * ********************************************************************* + * * Copyright (C) 1985, 1990 Regents of the University of California. * + * * Permission to use, copy, modify, and distribute this * + * * software and its documentation for any purpose and without * + * * fee is hereby granted, provided that the above copyright * + * * notice appear in all copies. The University of California * + * * makes no representations about the suitability of this * + * * software for any purpose. It is provided "as is" without * + * * express or implied warranty. Export of this software outside * + * * of the United States of America may require an export license. * + * ********************************************************************* + * + */ + +#ifndef _MAGIC__DATABASE__ARRAYINFO_H +#define _MAGIC__DATABASE__ARRAYINFO_H + +/* + * Description of an array. + * The bounds xlo .. xhi and ylo .. yhi are transformed versions + * of the bounds xlo' .. xhi' and ylo' .. yhi' supplied by the + * user: + * + * User supplies: + * xlo' index of leftmost array element in root coordinates + * xhi' index of rightmost array element in root coordinates + * ylo' index of bottommost array element in root coordinates + * yhi' index of topmost array element in root coordinates + * + * There is no constraint on the order of any of these indices; xlo' may + * be less than, equal to, or greater than xhi', and similarly for ylo' + * and yhi'. + * + * In addition, the separations xsep and ysep are transformed versions + * of the separations xsep' and ysep' supplied by the user: + * + * User supplies: + * xsep' (positive) X spacing between array elements in root coords + * ysep' (positive) Y spacing between array elements in root coords + * + * When the array is made via DBMakeArray, both the indices and the spacings + * are transformed down to the coordinates of the CellDef that is the child + * of the use containing the ArrayInfo. + * + * The significance of the various values is as follows: the [xlo, ylo] + * element of the array is gotten by transforming the celldef by the + * transformation in the celluse. the [x, y] element is gotten by + * transforming the celldef by xsep*abs(x-xlo) in x, ysep*abs(y-ylo) in + * y, and then transforming by the transformation in the celluse. + */ + +typedef struct +{ + int ar_xlo, ar_xhi; /* Inclusive low/high X bounds */ + int ar_ylo, ar_yhi; /* Inclusive low/high Y bounds */ + int ar_xsep, ar_ysep; /* X,Y sep between array elements */ +} ArrayInfo; + +#endif /* _MAGIC__DATABASE__ARRAYINFO_H */ diff --git a/database/database.h.in b/database/database.h.in index 4a1de57f..2496263b 100644 --- a/database/database.h.in +++ b/database/database.h.in @@ -441,46 +441,7 @@ typedef struct celldef #define CDNOEXTRACT 0x20000 #define CDDONTUSE 0x40000 -/* - * Description of an array. - * The bounds xlo .. xhi and ylo .. yhi are transformed versions - * of the bounds xlo' .. xhi' and ylo' .. yhi' supplied by the - * user: - * - * User supplies: - * xlo' index of leftmost array element in root coordinates - * xhi' index of rightmost array element in root coordinates - * ylo' index of bottommost array element in root coordinates - * yhi' index of topmost array element in root coordinates - * - * There is no constraint on the order of any of these indices; xlo' may - * be less than, equal to, or greater than xhi', and similarly for ylo' - * and yhi'. - * - * In addition, the separations xsep and ysep are transformed versions - * of the separations xsep' and ysep' supplied by the user: - * - * User supplies: - * xsep' (positive) X spacing between array elements in root coords - * ysep' (positive) Y spacing between array elements in root coords - * - * When the array is made via DBMakeArray, both the indices and the spacings - * are transformed down to the coordinates of the CellDef that is the child - * of the use containing the ArrayInfo. - * - * The significance of the various values is as follows: the [xlo, ylo] - * element of the array is gotten by transforming the celldef by the - * transformation in the celluse. the [x, y] element is gotten by - * transforming the celldef by xsep*abs(x-xlo) in x, ysep*abs(y-ylo) in - * y, and then transforming by the transformation in the celluse. - */ - -typedef struct -{ - int ar_xlo, ar_xhi; /* Inclusive low/high X bounds */ - int ar_ylo, ar_yhi; /* Inclusive low/high Y bounds */ - int ar_xsep, ar_ysep; /* X,Y sep between array elements */ -} ArrayInfo; +#include "database/arrayinfo.h" /* ArrayInfo */ /* * Since a cell may be used in an orientation different from that diff --git a/extflat/EFint.h b/extflat/EFint.h index d7e09620..a4266a59 100644 --- a/extflat/EFint.h +++ b/extflat/EFint.h @@ -187,14 +187,7 @@ typedef struct def * structure describes the indices and the separation between elements * (for computing transforms). */ -#ifndef _MAGIC__DATABASE__DATABASE_H -typedef struct -{ - int ar_xlo, ar_xhi; - int ar_ylo, ar_yhi; - int ar_xsep, ar_ysep; -} ArrayInfo; -#endif /* _MAGIC__DATABASE__DATABASE_H */ +#include "database/arrayinfo.h" /* ArrayInfo */ typedef struct use {