| GENERIC(1) | IRAF commands | GENERIC(1) |
generic - generic preprocessor for IRAF
generic [options] files...
The generic preprocessor is used to translate generic source code (code written to work for any datatype) into type dependent source code, suitable for compilation and insertion into a library. The generic source is translated for each datatype, producing a type dependent copy of the source code for each datatype. There are two primary modes of operation:
The generic preprocessor operates by token replacement (currently using a UNIX Lex lexical analyzer). The input stream is broken up into a stream of tokens. Each token is examined to see if it is in the following list, and the indicated action is taken if the token is matched. The generic preprocessor directives have the form "$NAME", where $ marks a generic directive, and where NAME is the name of the directive.
"datatype" denotes the current type
ubcsilrdx any subset of these characters
denotes the corresponding datatype
sizeof() the size of the specified type,
e.g., for comparisons
!= == the relational operators
> < >= <=
Examples:
$if (datatype != dx)
(code to be compiled if type not d or x)
$if (sizeof(i) <= sizeof(r))
(code to be compiled if size int <= real)
$IF constructs may be nested. The directive may appear anywhere on a line.
Example:
$for (silrd)
(any amount of generic code)
$endfor
u - C unsigned short b - C byte (char) c - SPP character s - SPP short i - SPP int l - SPP long r - SPP real d - SPP double x - SPP complex
This option cannot be used in combination with the -o option, and should not be used when generic code is expanded inline, rather than written into multiple output files.
1. Translate the generic source "aadd.gx" to produce the six output files "aadds.x", "aaddi.x", etc., in the subdirectory "ak", clobbering any existing files therein. The generic task is a bootstrap utility written in C and is implemented as a CL foreign task, hence the UNIX command syntax.
cl> generic -k -p ak/ -t silrdx aadd.gx
2. Perform an inline transformation ($FOR directive) of the source file "imsum.gx", producing the single file "imsum.x" as output.
cl> generic -k -o imsum.x imsum.gx
3. The following is a simple example of a typical generic source file. For additional examples, see the ".gx" sources in the VOPS, IMIO, IMAGES and other directories.
# ALIM -- Compute the limits (minimum and maximum values)
# of a vector.
# (this is a copy of the file vops$alim.gx).
procedure alim$t (a, npix, minval, maxval)
PIXEL a[ARB], minval, maxval, value
int npix, i
begin
minval = a[1]
maxval = a[1]
do i = 1, npix {
value = a[i]
$if (datatype == x)
if (abs(value) < abs(minval))
minval = value
else if (abs(value) > abs(maxval))
maxval = value
$else
if (value < minval)
minval = value
else if (value > maxval)
maxval = value
$endif
}
end
xc(1), xyacc(1).
This manual page was taken from the IRAF generic.hlp help file.
| June 2021 | IRAF 2.17 |