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>
}
72 {find-class-initializer @<slot> @<class> @> @<init-or-nil>
}
75 \begin{describe
}{gf
}{find-slot-initargs @<class> @<slot> @> @<list>
}
79 {compute-effective-slot @<class> @<slot> @> @<effective-slot>
}
83 {sod-class-effective-slot (effective-slot) \\
\ind
84 \&key :class :slot :initializer-function :prepare-function
}
88 {\dhead{gf
}{effective-slot-initializer-function @<slot> @> @<function>
}
89 \dhead{gf
}{effective-slot-prepare-function @<slot> @> @<function>
}}
92 \begin{describe
}{cls
}{islots () \&key :class :subclass :slots
}
96 {\dhead{gf
}{islots-class @<islots> @> @<class>
}
97 \dhead{gf
}{islots-subclass @<islots> @> @<class>
}
98 \dhead{gf
}{islots-slots @<islots> @> @<list>
}}
101 \begin{describe
}{gf
}{compute-islots @<class> @<subclass> @> @<islots>
}
104 \begin{describe
}{gf
}{vtable-pointer () \&key :class :chain-head :chain-tail
}
108 {\dhead{gf
}{vtable-pointer-class @<vtable-pointer> @> @<class>
}
109 \dhead{gf
}{vtable-pointer-chain-head @<vtable-pointer> @> @<class>
}
110 \dhead{gf
}{vtable-pointer-chain-tail @<vtable-pointer> @> @<class>
}}
113 \begin{describe
}{gf
}{ichain () \&key :class :chain-head :chain-tail :body
}
117 {\dhead{gf
}{ichain-class @<ichain> @> @<class>
}
118 \dhead{gf
}{ichain-chain-head @<ichain> @> @<class>
}
119 \dhead{gf
}{ichain-chain-tail @<ichain> @> @<class>
}
120 \dhead{gf
}{ichain-body @<ichain> @> @<list>
}}
123 \begin{describe
}{gf
}{compute-ichain @<class> @<chain> @> @<ichain>
}
126 \begin{describe
}{gf
}{ilayout () \&key :class :ichains
}
130 {\dhead{gf
}{ilayout-class @<ilayout> @> @<class>
}
131 \dhead{gf
}{ilayout-ichains @<ilayout> @> @<list>
}}
134 \begin{describe
}{gf
}{sod-class-ilayout @<class> @> @<ilayout>
}
137 \begin{describe
}{gf
}{compute-ilayout @<class> @> @<ilayout>
}
140 \begin{describe
}{cls
}
141 {vtmsgs () \&key :class :subclass :chain-head :chain-tail :entries
}
145 {\dhead{gf
}{vtmsgs-class @<vtmsgs> @> @<class>
}
146 \dhead{gf
}{vtmsgs-subclass @<vtmsgs> @> @<class>
}
147 \dhead{gf
}{vtmsgs-chain-head @<vtmsgs> @> @<class>
}
148 \dhead{gf
}{vtmsgs-chain-tail @<vtmsgs> @> @<class>
}
149 \dhead{gf
}{vtmsgs-entries @<vtmsgs> @> @<list>
}}
152 \begin{describe
}{cls
}
153 {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head
}
157 {\dhead{gf
}{class-pointer-class @<class-pointer> @> @<class>
}
158 \dhead{gf
}{class-pointer-chain-head @<class-pointer> @> @<class>
}
159 \dhead{gf
}{class-pointer-metaclass @<class-pointer> @> @<class>
}
160 \dhead{gf
}{class-pointer-meta-chain-head @<class-pointer> @> @<class>
}}
163 \begin{describe
}{fun
}
164 {make-class-pointer @<class> @<chain-head>
165 @<metaclass> @<meta-chain-head>
169 \begin{describe
}{cls
}{base-offset () \&key :class :chain-head
}
173 {\dhead{gf
}{base-offset-class @<base-offset> @> @<class>
}
174 \dhead{gf
}{base-offset-chain-head @<base-offset> @> @<class>
}}
177 \begin{describe
}{fun
}
178 {make-base-offset @<class> @<chain-head> @> @<base-offset>
}
181 \begin{describe
}{cls
}{chain-offset () \&key :class :chain-head :target-head
}
185 {\dhead{gf
}{chain-offset-class @<chain-offset> @> @<class>
}
186 \dhead{gf
}{chain-offset-chain-head @<chain-offset> @> @<class>
}
187 \dhead{gf
}{chain-offset-target-head @<chain-offset> @> @<class>
}}
190 \begin{describe
}{fun
}
191 {make-chain-offset @<class> @<chain-head> @<target-head>
195 \begin{describe
}{gf
}{vtable () \&key :class :chain-head :chain-tail :body
}
199 {\dhead{gf
}{vtable-class @<vtable> @> @<class>
}
200 \dhead{gf
}{vtable-chain-head @<vtable> @> @<class>
}
201 \dhead{gf
}{vtable-chain-tail @<vtable> @> @<class>
}
202 \dhead{gf
}{vtable-body @<vtable> @> @<list>
}}
206 {compute-vtable-items @<class> @<super>
207 @<chain-head> @<chain-tail>
211 \begin{describe
}{gf
}{compute-vtable @<class> @<chain> @> @<vtable>
}
214 \begin{describe
}{gf
}{sod-class-vtables @<class> @> @<list>
}
217 \begin{describe
}{gf
}{compute-vtables @<class> @> @<list>
}
220 %%%--------------------------------------------------------------------------
221 \section{Method combination
} \label{sec:layout.methods
}
223 \begin{describe
}{cls
}{effective-method () \&key :message :class :keywords
}
227 {\dhead{gf
}{effective-method-message @<method> @> @<message>
}
228 \dhead{gf
}{effective-method-class @<method> @> @<class>
}
229 \dhead{gf
}{effective-method-keywords @<method> @> @<list>
}}
233 {sod-message-applicable-methods @<message> @<class> @> list
}
237 {sod-message-keyword-argument-lists @<message> @<class>
238 @<direct-methods> @<state>
242 \begin{describe
}{fun
}
243 {compute-effective-method-keyword-arguments @<message>
250 {sod-message-check-methods @<message> @<class> @<direct-methods>
}
254 {sod-message-effective-method-class @<message> @> @<class>
}
257 \begin{describe
}{gf
}{primary-method-class @<message> @> @<class>
}
261 {compute-sod-effective-method @<message> @<class> @> @<method>
}
264 \begin{describe
}{gf
}{sod-class-effective-methods @<class> @> @<list>
}
267 \begin{describe
}{gf
}{compute-effective-methods @<class> @> @<list>
}
270 \begin{describe
}{cls
}
271 {method-entry () \&key :method :chain-head :chain-tail :role
}
275 {\dhead{gf
}{method-entry-effective-method @<method-entry> @> @<method>
}
276 \dhead{gf
}{method-entry-chain-head @<method-entry> @> @<class>
}
277 \dhead{gf
}{method-entry-chain-tail @<method-entry> @> @<class>
}
278 \dhead{gf
}{method-entry-role @<method-entry> @> @<role>
}}
282 {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
287 \begin{describe
}{gf
}{sod-message-argument-tail @<message> @> @<list>
}
290 \begin{describe
}{gf
}{sod-method-function-type @<method> @> @<c-type>
}
293 \begin{describe
}{gf
}{sod-method-next-method-type @<method> @> @<c-type>
}
296 \begin{describe
}{gf
}{sod-method-description @<method> @> @<string>
}
299 \begin{describe
}{gf
}{sod-method-function-name @<method> @> @<string>
}
302 \begin{describe
}{fun
}{varargs-message-p @<message> @> @<generalized-boolean>
}
305 \begin{describe
}{fun
}{keyword-message-p @<message> @> @<generalized-boolean>
}
308 \begin{describe
}{gf
}{method-entry-function-type @<entry> @> @<c-type>
}
311 \begin{describe
}{gf
}{method-entry-slot-name @<entry> @> @<string>
}
315 {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>
}
319 {effective-method-basic-argument-names @<method> @> @<list>
}
323 {effective-method-live-p @<method> @> @<generalized-boolean>
}
327 \begin{describe
}{cls
}
328 {method-codegen (codegen) \\
\ind
329 \&key :vars :insts :temp-index
330 :message :class :method :target
}
334 {\dhead{gf
}{codegen-message @<codegen> @> @<message>
}
335 \dhead{gf
}{codegen-class @<codegen> @> @<class>
}
336 \dhead{gf
}{codegen-method @<codegen> @> @<method>
}
337 \dhead{gf
}{codegen-target @<codegen> @> @<target>
}}
341 {\dhead{cls
}{convert-to-ilayout-inst (inst)
}
343 {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>
}}
345 SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
351 {compute-effective-method-body @<method> @<codegen> @<target>
}
354 \begin{describe
}{gf
}{simple-method-body @<method> @<codegen> @<target>
}
357 \begin{describe
}{fun
}
358 {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>
}
361 \begin{describe
}{fun
}{ensure-ilayout-var @<codegen> @<super>
}
364 \begin{describe
}{fun
}{make-trampoline @<codegen> @<super> @<body-func>
}
367 \begin{describe
}{gf
}{effective-method-function-name @<method> @> @<string>
}
371 {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>
}
374 \begin{describe
}{gf
}{compute-method-entry-functions @<method> @> @<list>
}
377 \begin{describe
}{fun
}
378 {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
379 @<chain> @<kernel-func>
}
382 \begin{describe
}{cls
}
383 {basic-message (sod-message) \&key :name :location :class :type
}
386 \begin{describe
}{cls
}
387 {simple-message (basic-message) \&key :name :location :class :type
}
390 \begin{describe
}{cls
}
391 {basic-direct-method (sod-method)
392 \&key :message :location :class :type :body :role
}
395 \begin{describe
}{gf
}{sod-method-role @<method> @> @<role>
}
398 \begin{describe
}{cls
}
399 {daemon-direct-method (basic-direct-method) \\
\ind
400 \&key :message :location :class :type :body :role
}
403 \begin{describe
}{cls
}
404 {delegating-direct-method (basic-direct-method) \\
\ind
405 \&key :message :location :class :type :body :role
}
408 \begin{describe
}{cls
}
409 {basic-effective-method (effective-method) \\
\ind
410 \&key :message :class :around-methods :before-methods :after-methods
}
415 {effective-method-around-methods @<effective-method> @> @<list>
}
417 {effective-method-before-methods @<effective-method> @> @<list>
}
419 {effective-method-after-methods @<effective-method> @> @<list>
}
420 \dhead{gf
}{effective-method-functions @<effective-method> @> @<list>
}}
423 \begin{describe
}{cls
}
424 {simple-effective-method (basic-effective-method) \\
\ind
425 \&key :message :class
426 :around-methods :before-methods :after-methods :primary-methods
}
429 \begin{describe
}{fun
}
430 {basic-effective-method-body @<codegen> @<target> @<method> @<body>
}
433 \begin{describe
}{cls
}
434 {standard-message (simple-message) \&key :name :location :class :type
}
437 \begin{describe
}{cls
}
438 {standard-effective-method (simple-effective-method) \\
\ind
439 \&key :message :class
440 :around-methods :before-methods :after-methods :primary-methods
}
443 \begin{describe
}{cls
}
444 {aggregating-message (simple-message)
445 \&key :name :location :class :type :combination
}
449 {aggregating-message-properties @<message> @<combination> @> @<plist>
}
453 {compute-aggregating-message-kernel
454 \=@<message> @<combination> @<target> \+\\
455 @<methods> @<arg-names> \&key
}
459 {check-aggregating-message-type @<message> @<combination> @<c-type>
}
462 \begin{describe
}{cls
}
463 {aggregating-effective-method (simple-effective-method) \\
\ind
464 \&key :message :class
465 :around-methods :before-methods :after-methods :primary-methods
}
468 \begin{describe
}{mac
}
469 {define-aggregating-method-combination @<combination> \\
\ind\ind
471 @
[[ :codegen @<codegen-var> @!
472 :methods @<methods-var> @
]]) \-\\
473 @
[[ \=:properties (@
{ (@
{ @<name> @! (@
[@<keyword>@
] @<name>) @
}
476 @
[@<suppliedp-var>@
]@
]) @
}^*) @! \+\\
477 :return-type @<c-type> @! \\
478 :around @<around-func> @!
479 :first-method @<first-method-func> @!
480 :method @<method-func> @
]]}
483 %%% the method combination story
484 %% compute-effective-methods --> compute-sod-effective-method
486 %% hook-output (basic-effective-method :c)
487 %% basic-effective-method.functions
488 %% compute-method-entry-functions
489 %% compute-effective-method-body
491 %% compute-effective-method-body (simple-effective-method)
492 %% basic-effective-method-body
493 %% simple-method-body (standard-effective-method)
494 %% simple-method-body (aggregating-effective-method)
495 %% message-kernel-function
497 %%%----- That's all, folks --------------------------------------------------
501 %%% TeX-master: "sod.tex"