3 %%% Class layout and method combination protocols
5 %%% (c) 2015 Straylight/Edgeware
8 %%%----- Licensing notice ---------------------------------------------------
10 %%% This file is part of the Sensible Object Design, an object system for C.
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.
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.
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.
26 \chapter{Class layout and method combination}
28 %%%--------------------------------------------------------------------------
29 \section{Class layout protocol} \label{sec:layout.instance}
31 \begin{describe}{fun}{islots-struct-tag @<class> @> @<string>}
34 \begin{describe}{fun}{ichain-struct-tag @<class> @<chain-head> @> @<string>}
37 \begin{describe}{fun}{ichain-union-tag @<class> @<chain-head> @> @<string>}
40 \begin{describe}{fun}{ilayout-struct-tag @<class> @> @<string>}
43 \begin{describe}{fun}{vtmsgs-struct-tag @<class> @<super> @> @<string>}
46 \begin{describe}{fun}{vtable-union-tag @<class> @<chain-head> @> @<string>}
49 \begin{describe}{fun}{vtable-struct-tag @<class> @<chain-head> @> @<string>}
52 \begin{describe}{fun}{vtable-name @<class> @<chain-head> @> @<string>}
55 \begin{describe}{fun}{message-macro-name @<class> @<entry> @> @<string>}
58 \begin{describe}{cls}{effective-slot () \&key :class :slot :initializer}
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>}}
68 {find-slot-initializer @<class> @<slot> @> @<init-or-nil>}
71 \begin{describe}{gf}{find-slot-initargs @<class> @<slot> @> @<list>}
75 {compute-effective-slot @<class> @<slot> @> @<effective-slot>}
79 {sod-class-effective-slot (effective-slot) \\ \ind
80 \&key :class :slot :initializer-function :prepare-function}
84 {\dhead{gf}{effective-slot-initializer-function @<slot> @> @<function>}
85 \dhead{gf}{effective-slot-prepare-function @<slot> @> @<function>}}
88 \begin{describe}{cls}{islots () \&key :class :subclass :slots}
92 {\dhead{gf}{islots-class @<islots> @> @<class>}
93 \dhead{gf}{islots-subclass @<islots> @> @<class>}
94 \dhead{gf}{islots-slots @<islots> @> @<list>}}
97 \begin{describe}{gf}{compute-islots @<class> @<subclass> @> @<islots>}
100 \begin{describe}{gf}{vtable-pointer () \&key :class :chain-head :chain-tail}
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>}}
109 \begin{describe}{gf}{ichain () \&key :class :chain-head :chain-tail :body}
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>}}
119 \begin{describe}{gf}{compute-ichain @<class> @<chain> @> @<ichain>}
122 \begin{describe}{gf}{ilayout () \&key :class :ichains}
126 {\dhead{gf}{ilayout-class @<ilayout> @> @<class>}
127 \dhead{gf}{ilayout-ichains @<ilayout> @> @<list>}}
130 \begin{describe}{gf}{sod-class-ilayout <class> @> @<ilayout>}
133 \begin{describe}{gf}{compute-ilayout @<class> @> @<ilayout>}
136 \begin{describe}{cls}
137 {vtmsgs () \&key :class :subclass :chain-head :chain-tail :entries}
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>}}
148 \begin{describe}{cls}
149 {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head}
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>}}
159 \begin{describe}{fun}
160 {make-class-pointer @<class> @<chain-head>
161 @<metaclass> @<meta-chain-head>
165 \begin{describe}{cls}{base-offset () \&key :class :chain-head}
169 {\dhead{gf}{base-offset-class @<base-offset> @> @<class>}
170 \dhead{gf}{base-offset-chain-head @<base-offset> @> @<class>}}
173 \begin{describe}{fun}
174 {make-base-offset @<class> @<chain-head> @> @<base-offset>}
177 \begin{describe}{cls}{chain-offset () \&key :class :chain-head :target-head}
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>}}
186 \begin{describe}{fun}
187 {make-chain-offset @<class> @<chain-head> @<target-head>
191 \begin{describe}{gf}{vtable () \&key :class :chain-head :chain-tail :body}
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>}}
202 {compute-vtable-items @<class> @<super>
203 @<chain-head> @<chain-tail>
207 \begin{describe}{gf}{compute-vtable @<class> @<chain> @> @<vtable>}
210 \begin{describe}{gf}{sod-class-vtables @<class> @> @<list>}
213 \begin{describe}{gf}{compute-vtables @<class> @> @<list>}
216 %%%--------------------------------------------------------------------------
217 \section{Method combination} \label{sec:layout.methods}
219 \begin{describe}{cls}{effective-method () \&key :message :class :keywords}
223 {\dhead{gf}{effective-method-message @<method> @> @<message>}
224 \dhead{gf}{effective-method-class @<method> @> @<class>}
225 \dhead{gf}{effective-method-keywords @<method> @> @<list>}}
229 {sod-message-effective-method-class @<message> @> @<class>}
232 \begin{describe}{gf}{primary-method-class @<message> @> @<class>}
236 {method-keyword-argument-lists @<method> @<direct-methods> @<state>
241 {compute-sod-effective-method @<message> @<class> @> @<method>}
244 \begin{describe}{gf}{sod-class-effective-methods @<class> @> @<list>}
247 \begin{describe}{gf}{compute-effective-methods @<class> @> @<list>}
250 \begin{describe}{cls}
251 {method-entry () \&key :method :chain-head :chain-tail :role}
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>}}
262 {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
267 \begin{describe}{gf}{sod-message-argument-tail @<message> @> @<list>}
270 \begin{describe}{gf}{sod-method-function-type @<method> @> @<c-type>}
273 \begin{describe}{gf}{sod-method-next-method-type @<method> @> @<c-type>}
276 \begin{describe}{gf}{sod-method-description @<method> @> @<string>}
279 \begin{describe}{gf}{sod-method-function-name @<method> @> @<string>}
282 \begin{describe}{fun}{varargs-message-p @<message> @> @<generalized-boolean>}
285 \begin{describe}{fun}{keyword-message-p @<message> @> @<generalized-boolean>}
288 \begin{describe}{gf}{method-entry-function-type @<entry> @> @<c-type>}
291 \begin{describe}{gf}{method-entry-slot-name @<entry> @> @<string>}
295 {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>}
299 {effective-method-basic-argument-names @<method> @> @<list>}
303 {effective-method-live-p @<method> @> @<generalized-boolean>}
307 \begin{describe}{cls}
308 {method-codegen (codegen) \\ \ind
309 \&key :vars :insts :temp-index
310 :message :class :method :target}
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>}}
321 {\dhead{cls}{convert-to-ilayout-inst (inst)}
323 {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>}}
325 SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
331 {compute-effective-method-body @<method> @<codegen> @<target>}
334 \begin{describe}{gf}{simple-method-body @<method> @<codegen> @<target>}
337 \begin{describe}{fun}
338 {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>}
341 \begin{describe}{fun}{ensure-ilayout-var @<codegen> @<super>}
344 \begin{describe}{fun}{make-trampoline @<codegen> @<super> @<body-func>}
347 \begin{describe}{gf}{effective-method-function-name @<method> @> @<string>}
351 {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>}
354 \begin{describe}{gf}{compute-method-entry-functions @<method> @> @<list>}
357 \begin{describe}{fun}
358 {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
359 @<chain> @<kernel-func>}
362 \begin{describe}{cls}
363 {basic-message (sod-message) \&key :name :location :class :type}
366 \begin{describe}{cls}
367 {simple-message (basic-message) \&key :name :location :class :type}
370 \begin{describe}{cls}
371 {basic-direct-method (sod-method)
372 \&key :message :location :class :type :body :role}
375 \begin{describe}{gf}{sod-method-role @<method> @> @<role>}
378 \begin{describe}{cls}
379 {daemon-direct-method (basic-direct-method) \\ \ind
380 \&key :message :location :class :type :body :role}
383 \begin{describe}{cls}
384 {delegating-direct-method (basic-direct-method) \\ \ind
385 \&key :message :location :class :type :body :role}
388 \begin{describe}{cls}
389 {basic-effective-method (effective-method) \\ \ind
390 \&key :message :class :around-methods :before-methods :after-methods}
395 {effective-method-around-methods @<effective-method> @> @<list>}
397 {effective-method-before-methods @<effective-method> @> @<list>}
399 {effective-method-after-methods @<effective-method> @> @<list>}
400 \dhead{gf}{effective-method-functions @<effective-method> @> @<list>}}
403 \begin{describe}{cls}
404 {simple-effective-method (basic-effective-method) \\ \ind
405 \&key :message :class
406 :around-methods :before-methods :after-methods :primary-methods}
409 \begin{describe}{fun}
410 {basic-effective-method-body @<codegen> @<target> @<method> @<body>}
413 \begin{describe}{cls}
414 {standard-message (simple-message) \&key :name :location :class :type}
417 \begin{describe}{cls}
418 {standard-effective-method (simple-effective-method) \\ \ind
419 \&key :message :class
420 :around-methods :before-methods :after-methods :primary-methods}
423 \begin{describe}{cls}
424 {aggregating-message (simple-message)
425 \&key :name :location :class :type :combination}
429 {aggregating-message-properties @<message> @<combination> @> @<plist>}
433 {compute-aggregating-message-kernel
434 \=@<message> @<combination> @<target> \+\\
435 @<methods> @<arg-names> \&key}
439 {check-aggregating-message-type @<message> @<combination> @<c-type>}
442 \begin{describe}{cls}
443 {aggregating-effective-method (simple-effective-method) \\ \ind
444 \&key :message :class
445 :around-methods :before-methods :after-methods :primary-methods}
448 \begin{describe}{mac}
449 {define-aggregating-method-combination @<combination> \\ \ind\ind
451 @[[ :codegen @<codegen-var> @!
452 :methods @<methods-var> @]]) \-\\
453 @[[ \=:properties (@{ (@{ @<name> @! (@[@<keyword>@] @<name>) @}
456 @[@<suppliedp-var>@]@]) @}^*) @! \+\\
457 :return-type @<c-type> @! \\
458 :around @<around-func> @!
459 :first-method @<first-method-func> @!
460 :method @<method-func> @]]}
463 %%% the method combination story
464 %% compute-effective-methods --> compute-sod-effective-method
466 %% hook-output (basic-effective-method :c)
467 %% basic-effective-method.functions
468 %% compute-method-entry-functions
469 %% compute-effective-method-body
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
477 %%%----- That's all, folks --------------------------------------------------
481 %%% TeX-master: "sod.tex"