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