doc/*.tex: Add stubs for `file-location' reader methods.
[sod] / doc / output.tex
CommitLineData
1f7d590d
MW
1%%% -*-latex-*-
2%%%
3%%% Output machinery
4%%%
5%%% (c) 2015 Straylight/Edgeware
6%%%
7
8%%%----- Licensing notice ---------------------------------------------------
9%%%
e0808c47 10%%% This file is part of the Sensible Object Design, an object system for C.
1f7d590d
MW
11%%%
12%%% SOD is free software; you can redistribute it and/or modify
13%%% it under the terms of the GNU General Public License as published by
14%%% the Free Software Foundation; either version 2 of the License, or
15%%% (at your option) any later version.
16%%%
17%%% SOD is distributed in the hope that it will be useful,
18%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20%%% GNU General Public License for more details.
21%%%
22%%% You should have received a copy of the GNU General Public License
23%%% along with SOD; if not, write to the Free Software Foundation,
24%%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26\chapter{The output system} \label{ch:output}
27
d3dac74a
MW
28This chapter deals with actually generating output files. It will be of
29interest to programmers introducing new layout object classes, or new kinds
30of output files. An understanding of the material in
31\xref{sec:structures.layout} will prove valuable.
32
1f7d590d 33%%%--------------------------------------------------------------------------
d3dac74a
MW
34\section{Output sequencing} \label{sec:output.sequencer}
35
36C compilers are picky about the order in which things are presented to them
37in their input; but information about the structure of our classes is
38scattered among a variety of different layout objects. It's not the case
39that a layout object only contributes to a single localized portion of the
40output: for example, a @|vtmsgs| layout object is responsible for declaring
41both the appropriate @|struct $C$__vtmsgs_$a$| structure in the header file,
42populated with method entry pointers, but also declaring its member in the
43enclosing @|struct $C$__vt_$i$| structure.
44
45One approach would be to have the various layout objects just know how to
46call each other in the right order so as to have everything come out
47properly. That would make extending the translator, e.g., to add new kinds
48of layout objects, rather difficult. And it doesn't let users insert custom
49C fragments in flexible ways.
50
51Instead, there's a clear separation between which things need to be output,
52and the order in which they're produced.
53
54Ordering is handled by a \emph{sequencer} object. A sequencer doesn't know
55anything particular about output: its job is simply to do things in a
56particular order. It's described here because Sod only uses it for output
57scheduling.
58
59A sequencer maintains a collection of named \emph{items}, each of which has a
60name and a list of functions associated with it. A name can be any Lisp
61object. Names are compared using @|equal|, so lists can be used to construct
62a hierarchical namespace.
63
64The sequencer also maintains a collection of \emph{constraints}, which take
65the form of lists of item names. A constraint of the form @|($N_1$, $N_2$,
66$\ldots$, $N_k$)| requires that the item named $N_1$ must be scheduled before
67the item named $N_2$, and so on, all of which must be scheduled before the
68item named $N_k$. Items with these names do not need to exist or be known to
69the sequencer. An item name may appear in any number of constraints, all of
70which apply.
71
72It might be that a collection of constraints is impossible to satisfy: for
73example, the set
74\begin{center} \codeface
75 (alice bob) \qquad (bob carol) \qquad (carol alice)
76\end{center}
77can't be satisfied, since the first constraint requires that @|alice|
78precedes @|bob|, but the third says that @|alice| must come after @|carol|,
79and the second that @|carol| comes after @|bob|: it's not possible that
80@|alice| comes before @|bob| and after @|bob|. In this case, the sequencer
81fails and signals an error of type @|inconsistent-merge-error|.
82
83It is possible, but tedious, to explicitly order an entire collection of
84items by adding constraints. In the absence of explicit constraints to order
85them, items are ordered according to the order in which constraints naming
86them were first added to the sequencer. Items not named in any constraint
87are not processed at all.
88
89For example, suppose we have the following constraints.
90\begin{center} \codeface
91 (perl java) \qquad
92 (lisp java) \qquad
93 (python icon) \qquad
94 (icon perl)
95\end{center}
96The constraints give us that $@|python| < @|icon| < @|perl| < @|java|$, and
97also $@|lisp| < @|java|$. In this case, @|lisp| precedes @|python| because
98@|lisp| is mentioned in the second constraint while @|python| isn't mentioned
99until the third. So the final processing order is
100\begin{center}
101 @|lisp|, \quad
102 @|python|, \quad
103 @|icon|, \quad
104 @|perl|, \quad
105 @|java|
106\end{center}
107
1f7d590d 108
bca101d9 109\begin{describe}{cls}{sequencer-item}
d3dac74a
MW
110 An object of class @|sequencer-item| represents a sequencer item.
111 Sequencer items maintain a \emph{name} and a list of \emph{functions}.
112 Names are compared using @|equal|.
113
114 The functions are maintained in \emph{reverse order}, because it's
115 convenient to be able to add new functions using @|push|.
bca101d9
MW
116\end{describe}
117
118\begin{describe}{fun}{sequencer-item-p @<object> @> @<generalized-boolean>}
d3dac74a 119 Return non-nil if and only if @<object> is a @|sequencer-item|.
bca101d9
MW
120\end{describe}
121
d3dac74a
MW
122\begin{describe}{fun}
123 {make-sequencer-item @<name> \&optional @<functions> @> @<item>}
124 Create and return a new sequencer item with the given @<name> and list of
125 @<functions>; the list of functions defaults to nil if omitted.
bca101d9
MW
126\end{describe}
127
128\begin{describe*}
129 {\dhead{fun}{sequencer-item-name @<item> @> @<name>}
130 \dhead{fun}{sequencer-item-functions @<item> @> @<list>}
131 \dhead{fun}{setf (sequencer-item-functions @<item>) @<list>}}
d3dac74a
MW
132 These functions read or modify the state of a sequencer @<item>, as
133 originally established by @|make-sequencer-item|.
134
135 It is an error to modify an item's list of functions during a call to
136 @|invoke-sequencer-items| on the item's owning sequencer.
bca101d9
MW
137\end{describe*}
138
139\begin{describe}{cls}{sequencer () \&key :constraints}
140\end{describe}
141
a75cd932
MW
142\begin{describe*}
143 {\dhead{fun}{sequencer-constraints @<sequencer> @> @<list>}
144 \dhead{fun}{setf (sequencer-constraints @<sequencer>) @<list>}
145 \dhead{fun}{sequencer-table @<sequencer> @> @<hash-table>}}
146\end{describe*}
147
bca101d9
MW
148\begin{describe}{fun}{ensure-sequencer-item @<sequencer> @<name> @> @<item>}
149\end{describe}
150
151\begin{describe}{fun}{add-sequencer-constraint @<sequencer> @<constraint>}
152\end{describe}
153
154\begin{describe}{fun}
a75cd932
MW
155 {add-sequencer-item-function @<sequencer> @<name> @<function>}
156\end{describe}
157
158\begin{describe}{fun}
bca101d9
MW
159 {invoke-sequencer-items @<sequencer> \&rest @<arguments>}
160\end{describe}
161
d3dac74a 162\begin{describe}{gf}{hook-output progn @<object> @<reason> @<sequencer>}
87883222 163 \begin{describe}{meth}{t,t}
d3dac74a
MW
164 {hook-output progn (@<object> t) (@<reason> t) @<sequencer>}
165 \end{describe}
bca101d9
MW
166\end{describe}
167
168\begin{describe}{mac}
020b9e2b
MW
169 {sequence-output (@<stream-var> @<sequencer>) \\ \ind
170 @{ :constraint (@<item-name>^*) @} \\
bca101d9
MW
171 @{ (@<item-name> @<form>^*) @}^*}
172\end{describe}
173
d3dac74a 174%%%--------------------------------------------------------------------------
831b018f 175\section{Module output} \label{output.module}
d3dac74a 176
831b018f 177\subsection{Producing output}
d3dac74a 178
831b018f
MW
179\begin{describe}{fun}{output-module @<module> @<reason> @<stream>}
180\end{describe}
181
182
183\subsection{Managing output types} \label{output.module.manage}
184
185\begin{describe}{fun}{declare-output-type @<reason> @<pathname>}
186\end{describe}
187
188\begin{describe}{fun}{output-type-pathname @<reason> @> @<pathname>}
189\end{describe}
190
191
192\subsection{Utilities} \label{output.module.utilities}
193
194\begin{describe}{fun}{banner @<title> @<output> \&key :blank-line-p}
195\end{describe}
196
197\begin{describe}{fun}{guard-name @<filename> @> @<string>}
198\end{describe}
d3dac74a 199
e674612e
MW
200\begin{describe}{fun}
201 {one-off-output @<token> @<sequencer> @<item-name> @<function>}
202\end{describe}
203
d3dac74a 204%%%--------------------------------------------------------------------------
831b018f 205\section{Class output} \label{output.class}
d3dac74a
MW
206
207\begin{describe}{var}{*instance-class*}
208\end{describe}
bca101d9 209
1f7d590d
MW
210%% output for `h' files
211%%
212%% prologue
213%% guard start
214%% typedefs start
215%% typedefs
216%% typedefs end
217%% includes start
218%% includes
219%% includes end
220%% classes start
a3e1423b
MW
221%% early-user start
222%% early-user
223%% early-user end
1f7d590d
MW
224%% CLASS banner
225%% CLASS islots start
226%% CLASS islots slots
227%% CLASS islots end
228%% CLASS vtmsgs start
229%% CLASS vtmsgs CLASS start
230%% CLASS vtmsgs CLASS slots
231%% CLASS vtmsgs CLASS end
232%% CLASS vtmsgs end
233%% CLASS vtables start
234%% CLASS vtables CHAIN-HEAD start
235%% CLASS vtables CHAIN-HEAD slots
236%% CLASS vtables CHAIN-HEAD end
237%% CLASS vtables end
238%% CLASS vtable-externs
239%% CLASS vtable-externs-after
240%% CLASS methods start
241%% CLASS methods
242%% CLASS methods end
243%% CLASS ichains start
244%% CLASS ichains CHAIN-HEAD start
245%% CLASS ichains CHAIN-HEAD slots
246%% CLASS ichains CHAIN-HEAD end
247%% CLASS ichains end
248%% CLASS ilayout start
249%% CLASS ilayout slots
250%% CLASS ilayout end
251%% CLASS conversions
252%% CLASS object
253%% classes end
a3e1423b
MW
254%% user start
255%% user
256%% user end
1f7d590d
MW
257%% guard end
258%% epilogue
259
260%% output for `c' files
261%%
262%% prologue
263%% includes start
264%% includes
265%% includes end
a3e1423b
MW
266%% early-user start
267%% early-user
268%% early-user end
1f7d590d
MW
269%% classes start
270%% CLASS banner
271%% CLASS direct-methods start
272%% CLASS direct-methods METHOD start
273%% CLASS direct-methods METHOD body
274%% CLASS direct-methods METHOD end
275%% CLASS direct-methods end
276%% CLASS effective-methods
277%% CLASS vtables start
278%% CLASS vtables CHAIN-HEAD start
279%% CLASS vtables CHAIN-HEAD class-pointer METACLASS
280%% CLASS vtables CHAIN-HEAD base-offset
281%% CLASS vtables CHAIN-HEAD chain-offset TARGET-HEAD
282%% CLASS vtables CHAIN-HEAD vtmsgs CLASS start
283%% CLASS vtables CHAIN-HEAD vtmsgs CLASS slots
284%% CLASS vtables CHAIN-HEAD vtmsgs CLASS end
285%% CLASS vtables CHAIN-HEAD end
286%% CLASS vtables end
287%% CLASS object prepare
288%% CLASS object start
289%% CLASS object CHAIN-HEAD ichain start
290%% CLASS object SUPER slots start
291%% CLASS object SUPER slots
292%% CLASS object SUPER vtable
293%% CLASS object SUPER slots end
294%% CLASS object CHAIN-HEAD ichain end
295%% CLASS object end
296%% classes end
a3e1423b
MW
297%% user start
298%% user
299%% user end
1f7d590d
MW
300%% epilogue
301
302%%%----- That's all, folks --------------------------------------------------
303
304%%% Local variables:
305%%% mode: LaTeX
306%%% TeX-master: "sod.tex"
307%%% TeX-PDF-mode: t
308%%% End: