src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
[sod] / doc / layout.tex
CommitLineData
756f4928
MW
1%%% -*-latex-*-
2%%%
3%%% Class layout and method combination protocols
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.
756f4928
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{Class layout and method combination}
27
28%%%--------------------------------------------------------------------------
29\section{Class layout protocol} \label{sec:layout.instance}
30
31\begin{describe}{fun}{islots-struct-tag @<class> @> @<string>}
32\end{describe}
33
34\begin{describe}{fun}{ichain-struct-tag @<class> @<chain-head> @> @<string>}
35\end{describe}
36
37\begin{describe}{fun}{ichain-union-tag @<class> @<chain-head> @> @<string>}
38\end{describe}
39
40\begin{describe}{fun}{ilayout-struct-tag @<class> @> @<string>}
41\end{describe}
42
43\begin{describe}{fun}{vtmsgs-struct-tag @<class> @<super> @> @<string>}
44\end{describe}
45
46\begin{describe}{fun}{vtable-union-tag @<class> @<chain-head> @> @<string>}
47\end{describe}
48
49\begin{describe}{fun}{vtable-struct-tag @<class> @<chain-head> @> @<string>}
50\end{describe}
51
52\begin{describe}{fun}{vtable-name @<class> @<chain-head> @> @<string>}
53\end{describe}
54
55\begin{describe}{fun}{message-macro-name @<class> @<entry> @> @<string>}
56\end{describe}
57
58\begin{describe}{cls}{effective-slot () \&key :class :slot :initializer}
59\end{describe}
60
61\begin{describe*}
62 {\dhead{gf}{effective-slot-class @<slot> @> @<class>}
63 \dhead{gf}{effective-slot-direct-slot @<slot> @> @<direct-slot>}
64 \dhead{gf}{effective-slot-initializer @<slot> @> @<init-or-nil>}}
65\end{describe*}
66
67\begin{describe}{gf}
68 {find-slot-initializer @<class> @<slot> @> @<init-or-nil>}
69\end{describe}
70
71\begin{describe}{gf}
72 {compute-effective-slot @<class> @<slot> @> @<effective-slot>}
73\end{describe}
74
75\begin{describe}{cls}
76 {sod-class-effective-slot (effective-slot) \\ \ind
77 \&key :class :slot :initializer-function :prepare-function}
78\end{describe}
79
80\begin{describe*}
81 {\dhead{gf}{effective-slot-initializer-function @<slot> @> @<function>}
82 \dhead{gf}{effective-slot-prepare-function @<slot> @> @<function>}}
83\end{describe*}
84
85\begin{describe}{cls}{islots () \&key :class :subclass :slots}
86\end{describe}
87
88\begin{describe*}
89 {\dhead{gf}{islots-class @<islots> @> @<class>}
90 \dhead{gf}{islots-subclass @<islots> @> @<class>}
91 \dhead{gf}{islots-slots @<islots> @> @<list>}}
92\end{describe*}
93
94\begin{describe}{gf}{compute-islots @<class> @<subclass> @> @<islots>}
95\end{describe}
96
97\begin{describe}{gf}{vtable-pointer () \&key :class :chain-head :chain-tail}
98\end{describe}
99
100\begin{describe*}
101 {\dhead{gf}{vtable-pointer-class @<vtable-pointer> @> @<class>}
102 \dhead{gf}{vtable-pointer-chain-head @<vtable-pointer> @> @<class>}
103 \dhead{gf}{vtable-pointer-chain-tail @<vtable-pointer> @> @<class>}}
104\end{describe*}
105
106\begin{describe}{gf}{ichain () \&key :class :chain-head :chain-tail :body}
107\end{describe}
108
109\begin{describe*}
110 {\dhead{gf}{ichain-class @<ichain> @> @<class>}
111 \dhead{gf}{ichain-chain-head @<ichain> @> @<class>}
112 \dhead{gf}{ichain-chain-tail @<ichain> @> @<class>}
113 \dhead{gf}{ichain-body @<ichain> @> @<list>}}
114\end{describe*}
115
116\begin{describe}{gf}{compute-ichain @<class> @<chain> @> @<ichain>}
117\end{describe}
118
119\begin{describe}{gf}{ilayout () \&key :class :ichains}
120\end{describe}
121
122\begin{describe*}
123 {\dhead{gf}{ilayout-class @<ilayout> @> @<class>}
124 \dhead{gf}{ilayout-ichains @<ilayout> @> @<list>}}
125\end{describe*}
126
e6f472d6
MW
127\begin{describe}{gf}{sod-class-ilayout <class> @> @<ilayout>}
128\end{describe}
129
756f4928
MW
130\begin{describe}{gf}{compute-ilayout @<class> @> @<ilayout>}
131\end{describe}
132
133\begin{describe}{cls}
134 {vtmsgs () \&key :class :subclass :chain-head :chain-tail :entries}
135\end{describe}
136
137\begin{describe*}
138 {\dhead{gf}{vtmsgs-class @<vtmsgs> @> @<class>}
139 \dhead{gf}{vtmsgs-subclass @<vtmsgs> @> @<class>}
140 \dhead{gf}{vtmsgs-chain-head @<vtmsgs> @> @<class>}
141 \dhead{gf}{vtmsgs-chain-tail @<vtmsgs> @> @<class>}
142 \dhead{gf}{vtmsgs-entries @<vtmsgs> @> @<list>}}
143\end{describe*}
144
145\begin{describe}{cls}
146 {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head}
147\end{describe}
148
149\begin{describe*}
150 {\dhead{gf}{class-pointer-class @<class-pointer> @> @<class>}
151 \dhead{gf}{class-pointer-chain-head @<class-pointer> @> @<class>}
152 \dhead{gf}{class-pointer-metaclass @<class-pointer> @> @<class>}
153 \dhead{gf}{class-pointer-meta-chain-head @<class-pointer> @> @<class>}}
154\end{describe*}
155
156\begin{describe}{fun}
157 {make-class-pointer @<class> @<chain-head>
158 @<metaclass> @<meta-chain-head>
159 @> @<class-pointer>}
160\end{describe}
161
162\begin{describe}{cls}{base-offset () \&key :class :chain-head}
163\end{describe}
164
165\begin{describe*}
166 {\dhead{gf}{base-offset-class @<base-offset> @> @<class>}
167 \dhead{gf}{base-offset-chain-head @<base-offset> @> @<class>}}
168\end{describe*}
169
170\begin{describe}{fun}
171 {make-base-offset @<class> @<chain-head> @> @<base-offset>}
172\end{describe}
173
174\begin{describe}{cls}{chain-offset () \&key :class :chain-head :target-head}
175\end{describe}
176
177\begin{describe*}
178 {\dhead{gf}{chain-offset-class @<chain-offset> @> @<class>}
179 \dhead{gf}{chain-offset-chain-head @<chain-offset> @> @<class>}
180 \dhead{gf}{chain-offset-target-head @<chain-offset> @> @<class>}}
181\end{describe*}
182
183\begin{describe}{fun}
184 {make-chain-offset @<class> @<chain-head> @<target-head>
185 @> @<chain-offset>}
186\end{describe}
187
188\begin{describe}{gf}{vtable () \&key :class :chain-head :chain-tail :body}
189\end{describe}
190
191\begin{describe*}
192 {\dhead{gf}{vtable-class @<vtable> @> @<class>}
193 \dhead{gf}{vtable-chain-head @<vtable> @> @<class>}
194 \dhead{gf}{vtable-chain-tail @<vtable> @> @<class>}
195 \dhead{gf}{vtable-body @<vtable> @> @<list>}}
196\end{describe*}
197
198\begin{describe}{gf}
199 {compute-vtable-items @<class> @<super>
200 @<chain-head> @<chain-tail>
201 @<emit-function>}
202\end{describe}
203
204\begin{describe}{gf}{compute-vtable @<class> @<chain> @> @<vtable>}
205\end{describe}
206
e6f472d6
MW
207\begin{describe}{gf}{sod-class-vtables @<class> @> @<list>}
208\end{describe}
209
756f4928
MW
210\begin{describe}{gf}{compute-vtables @<class> @> @<list>}
211\end{describe}
212
213%%%--------------------------------------------------------------------------
214\section{Method combination} \label{sec:layout.methods}
215
43073476 216\begin{describe}{cls}{effective-method () \&key :message :class :keywords}
756f4928
MW
217\end{describe}
218
219\begin{describe*}
220 {\dhead{gf}{effective-method-message @<method> @> @<message>}
43073476
MW
221 \dhead{gf}{effective-method-class @<method> @> @<class>}
222 \dhead{gf}{effective-method-keywords @<method> @> @<list>}}
756f4928
MW
223\end{describe*}
224
7f2917d2
MW
225\begin{describe}{gf}
226 {sod-message-effective-method-class @<message> @> @<class>}
756f4928
MW
227\end{describe}
228
229\begin{describe}{gf}{primary-method-class @<message> @> @<class>}
230\end{describe}
231
232\begin{describe}{gf}
43ce48fd
MW
233 {method-keyword-argument-lists @<method> @<direct-methods> @> @<list>}
234\end{describe}
235
236\begin{describe}{gf}
756f4928
MW
237 {compute-sod-effective-method @<message> @<class> @> @<method>}
238\end{describe}
239
e6f472d6
MW
240\begin{describe}{gf}{sod-class-effective-methods @<class> @> @<list>}
241\end{describe}
242
756f4928
MW
243\begin{describe}{gf}{compute-effective-methods @<class> @> @<list>}
244\end{describe}
245
246\begin{describe}{cls}
247 {method-entry () \&key :method :chain-head :chain-tail :role}
248\end{describe}
249
250\begin{describe*}
251 {\dhead{gf}{method-entry-effective-method @<method-entry> @> @<method>}
252 \dhead{gf}{method-entry-chain-head @<method-entry> @> @<class>}
253 \dhead{gf}{method-entry-chain-tail @<method-entry> @> @<class>}
254 \dhead{gf}{method-entry-role @<method-entry> @> @<role>}}
255\end{describe*}
256
257\begin{describe}{gf}
258 {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
259 @> @<list>}
260\end{describe}
261
262
263\begin{describe}{gf}{sod-message-argument-tail @<message> @> @<list>}
264\end{describe}
265
756f4928
MW
266\begin{describe}{gf}{sod-method-function-type @<method> @> @<c-type>}
267\end{describe}
268
269\begin{describe}{gf}{sod-method-next-method-type @<method> @> @<c-type>}
270\end{describe}
271
272\begin{describe}{gf}{sod-method-function-name @<method> @> @<string>}
273\end{describe}
274
275\begin{describe}{fun}{varargs-message-p @<message> @> @<generalized-boolean>}
276\end{describe}
277
43073476
MW
278\begin{describe}{fun}{keyword-message-p @<message> @> @<generalized-boolean>}
279\end{describe}
280
756f4928
MW
281\begin{describe}{gf}{method-entry-function-type @<entry> @> @<c-type>}
282\end{describe}
283
284\begin{describe}{gf}{method-entry-slot-name @<entry> @> @<string>}
285\end{describe}
286
287\begin{describe}{gf}
288 {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>}
289\end{describe}
290
291\begin{describe}{gf}
292 {effective-method-basic-argument-names @<method> @> @<list>}
293\end{describe}
294
5135d00a
MW
295\begin{describe}{gf}
296 {effective-method-live-p @<method> @> @<generalized-boolean>}
297\end{describe}
756f4928
MW
298
299
300\begin{describe}{cls}
301 {method-codegen (codegen) \\ \ind
302 \&key :vars :insts :temp-index
303 :message :class :method :target}
304\end{describe}
305
306\begin{describe*}
307 {\dhead{gf}{codegen-message @<codegen> @> @<message>}
308 \dhead{gf}{codegen-class @<codegen> @> @<class>}
309 \dhead{gf}{codegen-method @<codegen> @> @<method>}
310 \dhead{gf}{codegen-target @<codegen> @> @<target>}}
311\end{describe*}
312
313\begin{describe*}
314 {\dhead{cls}{convert-to-ilayout-inst (inst)}
315 \dhead{fun}
316 {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>}}
317 \begin{prog}
318 SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
319 \end{prog}
320\end{describe*}
321
322
323\begin{describe}{gf}
324 {compute-effective-method-body @<method> @<codegen> @<target>}
325\end{describe}
326
327\begin{describe}{gf}{simple-method-body @<method> @<codegen> @<target>}
328\end{describe}
329
330\begin{describe}{fun}
331 {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>}
332\end{describe}
333
334\begin{describe}{fun}{ensure-ilayout-var @<codegen> @<super>}
335\end{describe}
336
337\begin{describe}{fun}{make-trampoline @<codegen> @<super> @<body-func>}
338\end{describe}
339
340\begin{describe}{gf}{effective-method-function-name @<method> @> @<string>}
341\end{describe}
342
343\begin{describe}{gf}
344 {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>}
345\end{describe}
346
347\begin{describe}{gf}{compute-method-entry-functions @<method> @> @<list>}
348\end{describe}
349
350\begin{describe}{fun}
351 {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
352 @<chain> @<kernel-func>}
353\end{describe}
354
355\begin{describe}{cls}
356 {basic-message (sod-message) \&key :name :location :class :type}
357\end{describe}
358
359\begin{describe}{cls}
360 {simple-message (basic-message) \&key :name :location :class :type}
361\end{describe}
362
363\begin{describe}{cls}
364 {basic-direct-method (sod-method)
365 \&key :message :location :class :type :body :role}
366\end{describe}
367
368\begin{describe}{gf}{sod-method-role @<method> @> @<role>}
369\end{describe}
370
371\begin{describe}{cls}
372 {daemon-direct-method (basic-direct-method) \\ \ind
373 \&key :message :location :class :type :body :role}
374\end{describe}
375
376\begin{describe}{cls}
377 {delegating-direct-method (basic-direct-method) \\ \ind
378 \&key :message :location :class :type :body :role}
379\end{describe}
380
381\begin{describe}{cls}
382 {basic-effective-method (effective-method) \\ \ind
383 \&key :message :class :around-methods :before-methods :after-methods}
384\end{describe}
385
386\begin{describe*}
387 {\dhead{gf}
388 {effective-method-around-methods @<effective-method> @> @<list>}
389 \dhead{gf}
390 {effective-method-before-methods @<effective-method> @> @<list>}
391 \dhead{gf}
392 {effective-method-after-methods @<effective-method> @> @<list>}
393 \dhead{gf}{effective-method-functions @<effective-method> @> @<list>}}
394\end{describe*}
395
396\begin{describe}{cls}
397 {simple-effective-method (basic-effective-method) \\ \ind
398 \&key :message :class
399 :around-methods :before-methods :after-methods :primary-methods}
400\end{describe}
401
402\begin{describe}{fun}
403 {basic-effective-method-body @<codegen> @<target> @<method> @<body>}
404\end{describe}
405
406\begin{describe}{cls}
407 {standard-message (simple-message) \&key :name :location :class :type}
408\end{describe}
409
410\begin{describe}{cls}
411 {standard-effective-method (simple-effective-method) \\ \ind
412 \&key :message :class
413 :around-methods :before-methods :after-methods :primary-methods}
414\end{describe}
415
416\begin{describe}{cls}
417 {aggregating-message (simple-message)
418 \&key :name :location :class :type :combination}
419\end{describe}
420
421\begin{describe}{gf}
422 {aggregating-message-properties @<message> @<combination> @> @<plist>}
423\end{describe}
424
425\begin{describe}{gf}
426 {compute-aggregating-message-kernel
427 \=@<message> @<combination> @<target> \+ \\
428 @<methods> @<arg-names> \&key}
429\end{describe}
430
431\begin{describe}{gf}
432 {check-aggregating-message-type @<message> @<combination> @<c-type>}
433\end{describe}
434
435\begin{describe}{cls}
436 {aggregating-effective-method (simple-effective-method) \\ \ind
437 \&key :message :class
438 :around-methods :before-methods :after-methods :primary-methods}
439\end{describe}
440
441\begin{describe}{mac}
442 {define-aggregating-method-combination @<combination> \\ \ind\ind
443 ((@<var-name>^*)
444 @[[ :codegen @<codegen-var> @!
445 :methods @<methods-var> @]]) \- \\
446 @[[ \=:properties (@{ (@{ @<name> @! (@[@<keyword>@] @<name>) @}
447 @<c-type>
448 @[@<default>
449 @[@<suppliedp-var>@]@]) @}^*) @! \+ \\
450 :return-type @<c-type> @! \\
451 :around @<around-func> @!
452 :first-method @<first-method-func> @!
453 :method @<method-func> @]]}
454\end{describe}
455
456%%% the method combination story
457%% compute-effective-methods --> compute-sod-effective-method
458
459%% hook-output (basic-effective-method :c)
460%% basic-effective-method.functions
461%% compute-method-entry-functions
462%% compute-effective-method-body
463%%
464%% compute-effective-method-body (simple-effective-method)
465%% basic-effective-method-body
466%% simple-method-body (standard-effective-method)
467%% simple-method-body (aggregating-effective-method)
468%% message-kernel-function
469
470%%%----- That's all, folks --------------------------------------------------
471
472%%% Local variables:
473%%% mode: LaTeX
474%%% TeX-master: "sod.tex"
475%%% TeX-PDF-mode: t
476%%% End: