Commit | Line | Data |
---|---|---|
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 | ||
235 | \begin{describe}{gf} | |
84b9d17a MW |
236 | {method-keyword-argument-lists @<method> @<direct-methods> @<state> |
237 | @> @<list>} | |
43ce48fd MW |
238 | \end{describe} |
239 | ||
240 | \begin{describe}{gf} | |
756f4928 MW |
241 | {compute-sod-effective-method @<message> @<class> @> @<method>} |
242 | \end{describe} | |
243 | ||
e6f472d6 MW |
244 | \begin{describe}{gf}{sod-class-effective-methods @<class> @> @<list>} |
245 | \end{describe} | |
246 | ||
756f4928 MW |
247 | \begin{describe}{gf}{compute-effective-methods @<class> @> @<list>} |
248 | \end{describe} | |
249 | ||
250 | \begin{describe}{cls} | |
251 | {method-entry () \&key :method :chain-head :chain-tail :role} | |
252 | \end{describe} | |
253 | ||
254 | \begin{describe*} | |
255 | {\dhead{gf}{method-entry-effective-method @<method-entry> @> @<method>} | |
256 | \dhead{gf}{method-entry-chain-head @<method-entry> @> @<class>} | |
257 | \dhead{gf}{method-entry-chain-tail @<method-entry> @> @<class>} | |
258 | \dhead{gf}{method-entry-role @<method-entry> @> @<role>}} | |
259 | \end{describe*} | |
260 | ||
261 | \begin{describe}{gf} | |
262 | {make-method-entries @<effective-method> @<chain-head> @<chain-tail> | |
263 | @> @<list>} | |
264 | \end{describe} | |
265 | ||
266 | ||
267 | \begin{describe}{gf}{sod-message-argument-tail @<message> @> @<list>} | |
268 | \end{describe} | |
269 | ||
756f4928 MW |
270 | \begin{describe}{gf}{sod-method-function-type @<method> @> @<c-type>} |
271 | \end{describe} | |
272 | ||
273 | \begin{describe}{gf}{sod-method-next-method-type @<method> @> @<c-type>} | |
274 | \end{describe} | |
275 | ||
675b4824 MW |
276 | \begin{describe}{gf}{sod-method-description @<method> @> @<string>} |
277 | \end{describe} | |
278 | ||
756f4928 MW |
279 | \begin{describe}{gf}{sod-method-function-name @<method> @> @<string>} |
280 | \end{describe} | |
281 | ||
282 | \begin{describe}{fun}{varargs-message-p @<message> @> @<generalized-boolean>} | |
283 | \end{describe} | |
284 | ||
43073476 MW |
285 | \begin{describe}{fun}{keyword-message-p @<message> @> @<generalized-boolean>} |
286 | \end{describe} | |
287 | ||
756f4928 MW |
288 | \begin{describe}{gf}{method-entry-function-type @<entry> @> @<c-type>} |
289 | \end{describe} | |
290 | ||
291 | \begin{describe}{gf}{method-entry-slot-name @<entry> @> @<string>} | |
292 | \end{describe} | |
293 | ||
294 | \begin{describe}{gf} | |
295 | {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>} | |
296 | \end{describe} | |
297 | ||
298 | \begin{describe}{gf} | |
299 | {effective-method-basic-argument-names @<method> @> @<list>} | |
300 | \end{describe} | |
301 | ||
5135d00a MW |
302 | \begin{describe}{gf} |
303 | {effective-method-live-p @<method> @> @<generalized-boolean>} | |
304 | \end{describe} | |
756f4928 MW |
305 | |
306 | ||
307 | \begin{describe}{cls} | |
020b9e2b | 308 | {method-codegen (codegen) \\ \ind |
756f4928 MW |
309 | \&key :vars :insts :temp-index |
310 | :message :class :method :target} | |
311 | \end{describe} | |
312 | ||
313 | \begin{describe*} | |
314 | {\dhead{gf}{codegen-message @<codegen> @> @<message>} | |
315 | \dhead{gf}{codegen-class @<codegen> @> @<class>} | |
316 | \dhead{gf}{codegen-method @<codegen> @> @<method>} | |
317 | \dhead{gf}{codegen-target @<codegen> @> @<target>}} | |
318 | \end{describe*} | |
319 | ||
320 | \begin{describe*} | |
321 | {\dhead{cls}{convert-to-ilayout-inst (inst)} | |
322 | \dhead{fun} | |
323 | {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>}} | |
324 | \begin{prog} | |
325 | SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>) | |
326 | \end{prog} | |
327 | \end{describe*} | |
328 | ||
329 | ||
330 | \begin{describe}{gf} | |
331 | {compute-effective-method-body @<method> @<codegen> @<target>} | |
332 | \end{describe} | |
333 | ||
334 | \begin{describe}{gf}{simple-method-body @<method> @<codegen> @<target>} | |
335 | \end{describe} | |
336 | ||
337 | \begin{describe}{fun} | |
338 | {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>} | |
339 | \end{describe} | |
340 | ||
341 | \begin{describe}{fun}{ensure-ilayout-var @<codegen> @<super>} | |
342 | \end{describe} | |
343 | ||
344 | \begin{describe}{fun}{make-trampoline @<codegen> @<super> @<body-func>} | |
345 | \end{describe} | |
346 | ||
347 | \begin{describe}{gf}{effective-method-function-name @<method> @> @<string>} | |
348 | \end{describe} | |
349 | ||
350 | \begin{describe}{gf} | |
351 | {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>} | |
352 | \end{describe} | |
353 | ||
354 | \begin{describe}{gf}{compute-method-entry-functions @<method> @> @<list>} | |
355 | \end{describe} | |
356 | ||
357 | \begin{describe}{fun} | |
358 | {invoke-delegation-chain @<codegen> @<target> @<basic-tail> | |
359 | @<chain> @<kernel-func>} | |
360 | \end{describe} | |
361 | ||
362 | \begin{describe}{cls} | |
363 | {basic-message (sod-message) \&key :name :location :class :type} | |
364 | \end{describe} | |
365 | ||
366 | \begin{describe}{cls} | |
367 | {simple-message (basic-message) \&key :name :location :class :type} | |
368 | \end{describe} | |
369 | ||
370 | \begin{describe}{cls} | |
371 | {basic-direct-method (sod-method) | |
372 | \&key :message :location :class :type :body :role} | |
373 | \end{describe} | |
374 | ||
375 | \begin{describe}{gf}{sod-method-role @<method> @> @<role>} | |
376 | \end{describe} | |
377 | ||
378 | \begin{describe}{cls} | |
020b9e2b | 379 | {daemon-direct-method (basic-direct-method) \\ \ind |
756f4928 MW |
380 | \&key :message :location :class :type :body :role} |
381 | \end{describe} | |
382 | ||
383 | \begin{describe}{cls} | |
020b9e2b | 384 | {delegating-direct-method (basic-direct-method) \\ \ind |
756f4928 MW |
385 | \&key :message :location :class :type :body :role} |
386 | \end{describe} | |
387 | ||
388 | \begin{describe}{cls} | |
020b9e2b | 389 | {basic-effective-method (effective-method) \\ \ind |
756f4928 MW |
390 | \&key :message :class :around-methods :before-methods :after-methods} |
391 | \end{describe} | |
392 | ||
393 | \begin{describe*} | |
394 | {\dhead{gf} | |
395 | {effective-method-around-methods @<effective-method> @> @<list>} | |
396 | \dhead{gf} | |
397 | {effective-method-before-methods @<effective-method> @> @<list>} | |
398 | \dhead{gf} | |
399 | {effective-method-after-methods @<effective-method> @> @<list>} | |
400 | \dhead{gf}{effective-method-functions @<effective-method> @> @<list>}} | |
401 | \end{describe*} | |
402 | ||
403 | \begin{describe}{cls} | |
020b9e2b | 404 | {simple-effective-method (basic-effective-method) \\ \ind |
756f4928 MW |
405 | \&key :message :class |
406 | :around-methods :before-methods :after-methods :primary-methods} | |
407 | \end{describe} | |
408 | ||
409 | \begin{describe}{fun} | |
410 | {basic-effective-method-body @<codegen> @<target> @<method> @<body>} | |
411 | \end{describe} | |
412 | ||
413 | \begin{describe}{cls} | |
414 | {standard-message (simple-message) \&key :name :location :class :type} | |
415 | \end{describe} | |
416 | ||
417 | \begin{describe}{cls} | |
020b9e2b | 418 | {standard-effective-method (simple-effective-method) \\ \ind |
756f4928 MW |
419 | \&key :message :class |
420 | :around-methods :before-methods :after-methods :primary-methods} | |
421 | \end{describe} | |
422 | ||
423 | \begin{describe}{cls} | |
424 | {aggregating-message (simple-message) | |
425 | \&key :name :location :class :type :combination} | |
426 | \end{describe} | |
427 | ||
428 | \begin{describe}{gf} | |
429 | {aggregating-message-properties @<message> @<combination> @> @<plist>} | |
430 | \end{describe} | |
431 | ||
432 | \begin{describe}{gf} | |
433 | {compute-aggregating-message-kernel | |
020b9e2b | 434 | \=@<message> @<combination> @<target> \+\\ |
756f4928 MW |
435 | @<methods> @<arg-names> \&key} |
436 | \end{describe} | |
437 | ||
438 | \begin{describe}{gf} | |
439 | {check-aggregating-message-type @<message> @<combination> @<c-type>} | |
440 | \end{describe} | |
441 | ||
442 | \begin{describe}{cls} | |
020b9e2b | 443 | {aggregating-effective-method (simple-effective-method) \\ \ind |
756f4928 MW |
444 | \&key :message :class |
445 | :around-methods :before-methods :after-methods :primary-methods} | |
446 | \end{describe} | |
447 | ||
448 | \begin{describe}{mac} | |
020b9e2b | 449 | {define-aggregating-method-combination @<combination> \\ \ind\ind |
756f4928 MW |
450 | ((@<var-name>^*) |
451 | @[[ :codegen @<codegen-var> @! | |
020b9e2b | 452 | :methods @<methods-var> @]]) \-\\ |
756f4928 MW |
453 | @[[ \=:properties (@{ (@{ @<name> @! (@[@<keyword>@] @<name>) @} |
454 | @<c-type> | |
455 | @[@<default> | |
020b9e2b MW |
456 | @[@<suppliedp-var>@]@]) @}^*) @! \+\\ |
457 | :return-type @<c-type> @! \\ | |
756f4928 MW |
458 | :around @<around-func> @! |
459 | :first-method @<first-method-func> @! | |
460 | :method @<method-func> @]]} | |
461 | \end{describe} | |
462 | ||
463 | %%% the method combination story | |
464 | %% compute-effective-methods --> compute-sod-effective-method | |
465 | ||
466 | %% hook-output (basic-effective-method :c) | |
467 | %% basic-effective-method.functions | |
468 | %% compute-method-entry-functions | |
469 | %% compute-effective-method-body | |
470 | %% | |
471 | %% compute-effective-method-body (simple-effective-method) | |
472 | %% basic-effective-method-body | |
473 | %% simple-method-body (standard-effective-method) | |
474 | %% simple-method-body (aggregating-effective-method) | |
475 | %% message-kernel-function | |
476 | ||
477 | %%%----- That's all, folks -------------------------------------------------- | |
478 | ||
479 | %%% Local variables: | |
480 | %%% mode: LaTeX | |
481 | %%% TeX-master: "sod.tex" | |
482 | %%% TeX-PDF-mode: t | |
483 | %%% End: |