File: generic.man

package info (click to toggle)
iraf 2.17-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 95,288 kB
  • sloc: ansic: 228,894; fortran: 75,606; lisp: 18,369; xml: 8,401; sh: 6,111; yacc: 5,648; lex: 596; makefile: 575; asm: 153; csh: 95; sed: 4
file content (248 lines) | stat: -rw-r--r-- 7,432 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
.\"                                      Hey, EMACS: -*- nroff -*-
.TH GENERIC "1" "June 2021" "IRAF 2.17" "IRAF commands"
.SH NAME
generic \- generic preprocessor for IRAF
.SH SYNOPSIS
.B generic
.RI [ options ] " files" ...
.SH DESCRIPTION
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:
.TP
.B [1]
The generic source is embedded in a normal file, bracketed by
\fI$for\fR and \fI$endfor\fR directives.  There is one input file and
one somewhat larger output file, with the generic code in the input
file being replaced in the output file by several copies of the
enclosed source, one for each datatype.  This mode is most commonly
used for modules to be linked in their entirety into an applications
package.  The \fB-o\fP parameter is used to specify the output
filename.
.TP
.B [2]
The entire input file is generic.  There may be multiple input files,
and for each input file N output files are generated, one for each
datatype specified with the \fB-t\fP parameter.  The output filenames
are automatically generated by appending the type character to the
root filename of the input file.  This mode is most commonly used for
object libraries.
.PP
The generic preprocessor operates by token replacement (currently
using a UNIX \fILex\fR 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 \fBgeneric\fP directive, and where NAME is the name of
the directive.
.TP
.B PIXEL
Replaced by the current type name, e.g., "int", "real", etc.
.TP
.B XPIXEL
Replaced by the current type name in upper case, preceded by an X,
e.g., "XINT", "XREAL", etc.  This is used for generic C procedures
meant to be called from SPP or Fortran.
.TP
.B INDEF
Replaced by the numeric constant denoting indefinite for the current
datatype.
.TP
.B INDEF[SILRDX]
These strings are \fInot\fR replaced, since the "INDEF" in this case
is not generic.
.TP
.B SZ_PIXEL
Replaced by "SZ_INT", "SZ_REAL", etc.
.TP
.B TY_PIXEL
Replaced by "TY_INT", "TY_REAL", etc.
.TP
.B $PIXEL
Replaced by the string "PIXEL".  This is used in doubly generic
sources, where the first pass translates $PIXEL to PIXEL, and the
second to the actual type string.
.TP
.B $INDEF
Replaced by the string "INDEF".
.TP
.B $t
Replaced by one of the characters [ubcsilrdx].
.TP
.B $T
Replaced by one of the characters [UBCSILRDX].
.TP
.B $/.../
Replaced by the string "...", i.e., whatever is within the //
delimiters.  Used to disable generic preprocessing of arbitrary text.
.TP
.B [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.
.TP
.B $if (expression)
The conditional preprocessing facility.  If the $IF tests false the
code which follows is skipped over, and is not copied to the output
file.  Control transfers to the matching $ELSE or $ENDIF.  The
following may be used in the boolean expression:

.nf
"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)
.fi

$IF constructs may be nested.  The directive may appear anywhere on
a line.
.TP
.B $else
Marks the else clause of a $IF.
.TP
.B $endif
Marks the end of a $IF.  One is required for every $IF.
.TP
.B $for (types)
For each of the listed types, output a translated copy of the code
between the $FOR and the matching $ENDFOR.  Nesting is permitted.

.nf
Example:
        $for (silrd)
        (any amount of generic code)
        $endfor
.fi
.TP
.B $endfor
Marks the end of a $FOR statement.
.TP
.B $$
Replaced by a single $.
.TP
.B /*...*/
C comments are not preprocessed.
.TP
.B "..."
Quoted strings are not preprocessed.
.TP
.B #...(EOL)
SPP comments are not preprocessed.
.TP
.B %...(EOL)
SPP Fortran escapes are not preprocessed.

.SH OPTIONS
.TP
.B \-k
Allow the output files generated by \fBgeneric\fP to clobber any existing
files.
.TP
.B \-o ofile
The name of the output file.  If this option is selected, only a single
file can be processed.
.TP
.B \-p prefix
A prefix to be prepended to the output filenames.  This is useful when
the output files are to be placed in a different directory.
.TP
.B \-t types
The datatypes for which output is desired.  One output file will be generated
for each type specified, with \fBgeneric\fP automatically generating the
output filename by appending the type character to the root filename of
the input file.  The \fItypes\fR string is some subset of [ubscilrdx],
where the type characters are as follows:

.nf
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
.fi

This option cannot be used in combination with the \fB-o\fP option,
and should not be used when generic code is expanded inline, rather
than written into multiple output files.
.TP
.I 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 \fB-o\fP option is
specified.

.SH EXAMPLES
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 \fBgeneric\fP 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.

.nf
# 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
.fi


.SH SEE ALSO
.BR xc (1),
.BR xyacc (1).

.SH AUTHOR
This manual page was taken from the IRAF generic.hlp help file.