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