GENERIC(1)
๐ GENERIC(1) โ the IRAF commands era ๐
okay bestie, gather round, because this is generic, the generic preprocessor for IRAF, and she is literally the main character of datatype generation. no cap. ๐ฆ
โจ NAME โจ
generic โ generic preprocessor for IRAF ๐
๐ SYNOPSIS ๐
generic [options] files...
๐ธ DESCRIPTION ๐ธ
so like. the generic preprocessor exists to translate generic source code โ code written so it works for any datatype โ into type dependent source code, aka code that's actually ready to be compiled and dropped into a library. โจ it does this by translating the generic source once for each datatype, which gives you a type dependent copy of the source for every single datatype. it's giving "one source, many outputs" and honestly? obsessed.
there are two primary modes of operation:
- the generic source is embedded inside a normal file, bracketed by
$forand$endfordirectives. one input file, one slightly chunkier output file โ the generic code in the input gets replaced in the output by several copies of the enclosed source, one copy per datatype. this mode is most commonly used for modules that are going to be linked in their entirety into an applications package. you use the-oparameter to name the output file. ๐ - the entire input file is generic. there can be multiple input files, and for each input file you get N output files generated, one for each datatype you specified with the
-tparameter. the output filenames are generated automatically by appending the type character to the root filename of the input file. this mode is most commonly used for object libraries. ๐ฅ
the generic preprocessor works by token replacement (currently using a UNIX Lex lexical analyzer, iykyk). the input stream gets broken up into a stream of tokens, and each token is checked against the following list โ if it matches, the indicated action happens. generic preprocessor directives have the form "$NAME", where $ marks a generic directive and NAME is the name of the directive.
PIXELโ replaced by the current type name, e.g.,"int","real", etc.XPIXELโ replaced by the current type name in upper case, preceded by anX, e.g.,"XINT","XREAL", etc. this one is used for generic C procedures meant to be called from SPP or Fortran.INDEFโ replaced by the numeric constant denoting indefinite for the current datatype.INDEF[SILRDX]โ these strings are not replaced, since the"INDEF"in this case is not generic. ๐SZ_PIXELโ replaced by"SZ_INT","SZ_REAL", etc.TY_PIXELโ replaced by"TY_INT","TY_REAL", etc.$PIXELโ replaced by the string"PIXEL". this is used in doubly generic sources, where the first pass translates$PIXELtoPIXEL, and the second pass translates it to the actual type string. double the slay, double the pass. ๐ซ$INDEFโ replaced by the string"INDEF".$tโ replaced by one of the characters[ubcsilrdx].$Tโ replaced by one of the characters[UBCSILRDX].$/.../โ replaced by the string"...", i.e., whatever is within the//delimiters. used to disable generic preprocessing of arbitrary text. ๐[0-9]+("$f"|"$F")โ replaced by the corresponding real or double constant. for example,"1$f"translates as"1.0"for type real, but as"1.0D0"for type double. math but make it cute. ๐งฎ$if (expression)โ the conditional preprocessing facility. if the$IFtests false, the code that follows is skipped over and is not copied to the output file, and control transfers to the matching$ELSEor$ENDIF. the following may be used in the boolean expression:"datatype"โ denotes the current typeubcsilrdxโ any subset of these characters denotes the corresponding datatypesizeof()โ the size of the specified type, e.g., for comparisons!= ==โ the relational operators> < >= <=โ the other 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. ๐ช
$elseโ marks the else clause of a$IF.$endifโ marks the end of a$IF. one is required for every$IF. (yes, every single one. don't test her.) ๐$for (types)โ for each of the listed types, output a translated copy of the code between the$FORand the matching$ENDFOR. nesting is permitted.
example:
$for (silrd)
(any amount of generic code)
$endfor
$endforโ marks the end of a$FORstatement.$$โ replaced by a single$./*...*/โ C comments are not preprocessed....โ quoted strings are not preprocessed.#...(EOL)โ SPP comments are not preprocessed.%...(EOL)โ SPP Fortran escapes are not preprocessed.
๐ OPTIONS ๐
-kโ allow the output files generated bygenericto clobber any existing files. (she will simply delete your old files and not feel bad about it, bestie ๐ญ)-oofile โ the name of the output file. if this option is selected, only a single file can be processed.-pprefix โ a prefix to be prepended to the output filenames. this is useful when the output files are supposed to go into a different directory. ๐๏ธ-ttypes โ the datatypes for which output is desired. one output file will be generated for each type specified, withgenericautomatically generating the output filename by appending the type character to the root filename of the input file. the types string is some subset of[ubscilrdx], where the type characters are as follows:u- C unsigned shortb- C byte (char)c- SPP characters- SPP shorti- SPP intl- SPP longr- SPP reald- SPP doublex- 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. โ ๏ธ
filesโ the input file or files to be processed. generic input files should have the extension".gx"or".gc", although this is not required. only a single input file can be given if the-ooption is specified.
๐ EXAMPLES ๐
- 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
- perform an inline transformation (
$FORdirective) of the source file"imsum.gx", producing the single file"imsum.x"as output.
cl> generic -k -o imsum.x imsum.gx
- 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
๐ซถ SEE ALSO ๐ซถ
xc(1), xyacc(1). go read those next bestie, they're part of the lore ๐
๐ AUTHOR ๐
this manual page was taken from the IRAF generic.hlp help file.
and that's the whole page, babe โจ this one's from IRAF 2.17, dated June 2021, and it's GENERIC(1) all day long. slay, compile, and preprocess responsibly ๐๐๐ฆ
๐ฆ where this page comes from
- debian trixie: iraf-dev 2.18.1-2 ยท IRAF
- ubuntu noble: iraf-dev 2.17.1-5build3 ยท IRAF
- ubuntu questing: iraf-dev 2.18.1-2
- ubuntu resolute: iraf-dev 2.18.1-2build1 ยท IRAF
- ubuntu stonking: iraf-dev 2.18.1-2build1 ยท IRAF
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms