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
}{cls
}{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
}{cls
}{ichain () \&key :class :chain-head :chain-tail :body
}
117 {\dhead{gf
}{ichain-class @<ichain> @> @<class>
}
118 \dhead{gf
}{ichain-head @<ichain> @> @<class>
}
119 \dhead{gf
}{ichain-tail @<ichain> @> @<class>
}
120 \dhead{gf
}{ichain-body @<ichain> @> @<list>
}}
123 \begin{describe
}{gf
}{compute-ichain @<class> @<chain> @> @<ichain>
}
126 \begin{describe
}{cls
}{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>
}}
153 {compute-vtmsgs @<class> @<subclass> @<chain-head> @<chain-tail>
157 \begin{describe
}{cls
}
158 {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head
}
162 {\dhead{gf
}{class-pointer-class @<class-pointer> @> @<class>
}
163 \dhead{gf
}{class-pointer-chain-head @<class-pointer> @> @<class>
}
164 \dhead{gf
}{class-pointer-metaclass @<class-pointer> @> @<class>
}
165 \dhead{gf
}{class-pointer-meta-chain-head @<class-pointer> @> @<class>
}}
168 \begin{describe
}{fun
}
169 {make-class-pointer @<class> @<chain-head>
170 @<metaclass> @<meta-chain-head>
174 \begin{describe
}{cls
}{base-offset () \&key :class :chain-head
}
178 {\dhead{gf
}{base-offset-class @<base-offset> @> @<class>
}
179 \dhead{gf
}{base-offset-chain-head @<base-offset> @> @<class>
}}
182 \begin{describe
}{fun
}
183 {make-base-offset @<class> @<chain-head> @> @<base-offset>
}
186 \begin{describe
}{cls
}{chain-offset () \&key :class :chain-head :target-head
}
190 {\dhead{gf
}{chain-offset-class @<chain-offset> @> @<class>
}
191 \dhead{gf
}{chain-offset-chain-head @<chain-offset> @> @<class>
}
192 \dhead{gf
}{chain-offset-target-head @<chain-offset> @> @<class>
}}
195 \begin{describe
}{fun
}
196 {make-chain-offset @<class> @<chain-head> @<target-head>
200 \begin{describe
}{cls
}{vtable () \&key :class :chain-head :chain-tail :body
}
204 {\dhead{gf
}{vtable-class @<vtable> @> @<class>
}
205 \dhead{gf
}{vtable-chain-head @<vtable> @> @<class>
}
206 \dhead{gf
}{vtable-chain-tail @<vtable> @> @<class>
}
207 \dhead{gf
}{vtable-body @<vtable> @> @<list>
}}
211 {compute-vtable-items @<class> @<super>
212 @<chain-head> @<chain-tail>
216 \begin{describe
}{gf
}{compute-vtable @<class> @<chain> @> @<vtable>
}
219 \begin{describe
}{gf
}{sod-class-vtables @<class> @> @<list>
}
222 \begin{describe
}{gf
}{compute-vtables @<class> @> @<list>
}
225 %%%--------------------------------------------------------------------------
226 \section{Method combination
} \label{sec:layout.methods
}
228 \begin{describe
}{cls
}{effective-method () \&key :message :class :keywords
}
232 {\dhead{gf
}{effective-method-message @<method> @> @<message>
}
233 \dhead{gf
}{effective-method-class @<method> @> @<class>
}
234 \dhead{gf
}{effective-method-keywords @<method> @> @<list>
}}
238 {sod-message-applicable-methods @<message> @<class> @> list
}
242 {sod-message-keyword-argument-lists @<message> @<class>
243 @<direct-methods> @<state>
247 \begin{describe
}{fun
}
248 {compute-effective-method-keyword-arguments @<message>
255 {sod-message-check-methods @<message> @<class> @<direct-methods>
}
259 {sod-message-effective-method-class @<message> @> @<class>
}
262 \begin{describe
}{gf
}{primary-method-class @<message> @> @<class>
}
266 {compute-sod-effective-method @<message> @<class> @> @<method>
}
269 \begin{describe
}{gf
}{sod-class-effective-methods @<class> @> @<list>
}
272 \begin{describe
}{gf
}{compute-effective-methods @<class> @> @<list>
}
275 \begin{describe
}{cls
}
276 {method-entry () \&key :method :chain-head :chain-tail :role
}
280 {\dhead{gf
}{method-entry-effective-method @<method-entry> @> @<method>
}
281 \dhead{gf
}{method-entry-chain-head @<method-entry> @> @<class>
}
282 \dhead{gf
}{method-entry-chain-tail @<method-entry> @> @<class>
}
283 \dhead{gf
}{method-entry-role @<method-entry> @> @<role>
}}
287 {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
292 \begin{describe
}{gf
}{sod-message-argument-tail @<message> @> @<list>
}
295 \begin{describe
}{gf
}{sod-method-function-type @<method> @> @<c-type>
}
298 \begin{describe
}{gf
}{sod-method-next-method-type @<method> @> @<c-type>
}
301 \begin{describe
}{gf
}{sod-method-description @<method> @> @<string>
}
304 \begin{describe
}{gf
}{sod-method-function-name @<method> @> @<string>
}
307 \begin{describe
}{fun
}{varargs-message-p @<message> @> @<generalized-boolean>
}
310 \begin{describe
}{fun
}{keyword-message-p @<message> @> @<generalized-boolean>
}
313 \begin{describe
}{gf
}{method-entry-function-type @<entry> @> @<c-type>
}
316 \begin{describe
}{gf
}{method-entry-slot-name @<entry> @> @<string>
}
320 {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>
}
324 {effective-method-basic-argument-names @<method> @> @<list>
}
328 {effective-method-live-p @<method> @> @<generalized-boolean>
}
332 \begin{describe
}{cls
}
333 {method-codegen (codegen) \\
\ind
334 \&key :vars :insts :temp-index
335 :message :class :method :target
}
339 {\dhead{gf
}{codegen-message @<codegen> @> @<message>
}
340 \dhead{gf
}{codegen-class @<codegen> @> @<class>
}
341 \dhead{gf
}{codegen-method @<codegen> @> @<method>
}
342 \dhead{gf
}{codegen-target @<codegen> @> @<target>
}}
346 {\dhead{cls
}{convert-to-ilayout-inst (inst)
}
348 {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>
}}
349 \def\makelabels#1#2{%
350 #1{gf
}{inst-class
}[#2]#1{gf
}{inst-chain-head
}[#2]%
351 \descindex{gf
}{inst-expr
}[#2]%
353 \makelabels{\desclabel}{|(
}
356 SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
359 \makelabels{\descindex}{|)
}
364 {compute-effective-method-body @<method> @<codegen> @<target>
}
367 \begin{describe
}{gf
}{simple-method-body @<method> @<codegen> @<target>
}
370 \begin{describe
}{fun
}
371 {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>
}
374 \begin{describe
}{fun
}{ensure-ilayout-var @<codegen> @<super>
}
377 \begin{describe
}{fun
}{make-trampoline @<codegen> @<super> @<body-func>
}
380 \begin{describe
}{gf
}{effective-method-function-name @<method> @> @<string>
}
384 {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>
}
387 \begin{describe
}{gf
}{compute-method-entry-functions @<method> @> @<list>
}
390 \begin{describe
}{fun
}
391 {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
392 @<chain> @<kernel-func>
}
395 \begin{describe
}{cls
}
396 {basic-message (sod-message) \&key :name :location :class :type
}
399 \begin{describe
}{cls
}
400 {simple-message (basic-message) \&key :name :location :class :type
}
403 \begin{describe
}{cls
}
404 {basic-direct-method (sod-method)
405 \&key :message :location :class :type :body :role
}
408 \begin{describe
}{gf
}{sod-method-role @<method> @> @<role>
}
411 \begin{describe
}{cls
}
412 {daemon-direct-method (basic-direct-method) \\
\ind
413 \&key :message :location :class :type :body :role
}
416 \begin{describe
}{cls
}
417 {delegating-direct-method (basic-direct-method) \\
\ind
418 \&key :message :location :class :type :body :role
}
421 \begin{describe
}{cls
}
422 {basic-effective-method (effective-method) \\
\ind
423 \&key :message :class :around-methods :before-methods :after-methods
}
428 {effective-method-around-methods @<effective-method> @> @<list>
}
430 {effective-method-before-methods @<effective-method> @> @<list>
}
432 {effective-method-after-methods @<effective-method> @> @<list>
}
433 \dhead{gf
}{effective-method-functions @<effective-method> @> @<list>
}}
436 \begin{describe
}{cls
}
437 {simple-effective-method (basic-effective-method) \\
\ind
438 \&key :message :class
439 :around-methods :before-methods :after-methods :primary-methods
}
442 \begin{describe
}{fun
}
443 {basic-effective-method-body @<codegen> @<target> @<method> @<body>
}
446 \begin{describe
}{cls
}
447 {standard-message (simple-message) \&key :name :location :class :type
}
450 \begin{describe
}{cls
}
451 {standard-effective-method (simple-effective-method) \\
\ind
452 \&key :message :class
453 :around-methods :before-methods :after-methods :primary-methods
}
456 \begin{describe
}{cls
}
457 {aggregating-message (simple-message)
458 \&key :name :location :class :type :combination
}
462 {\dhead{gf
}{sod-message-combination @<message> @> @<keyword>
}
463 \dhead{gf
}{sod-message-kernel-function @<message> @> @<function>
}}
467 {aggregating-message-properties @<message> @<combination> @> @<plist>
}
471 {compute-aggregating-message-kernel
472 \=@<message> @<combination> @<target> \+\\
473 @<methods> @<arg-names> \&key
}
477 {check-aggregating-message-type @<message> @<combination> @<c-type>
}
480 \begin{describe
}{cls
}
481 {aggregating-effective-method (simple-effective-method) \\
\ind
482 \&key :message :class
483 :around-methods :before-methods :after-methods :primary-methods
}
486 \begin{describe
}{mac
}
487 {define-aggregating-method-combination @<combination> \\
\ind\ind
489 @
[[ :codegen @<codegen-var> @!
490 :methods @<methods-var> @
]]) \-\\
491 @
[[ \=:properties (@
{ (@
{ @<name> @! (@
[@<keyword>@
] @<name>) @
}
494 @
[@<suppliedp-var>@
]@
]) @
}^*) @! \+\\
495 :return-type @<c-type> @! \\
496 :around @<around-func> @!
497 :first-method @<first-method-func> @!
498 :method @<method-func> @
]]}
501 %%% the method combination story
502 %% compute-effective-methods --> compute-sod-effective-method
504 %% hook-output (basic-effective-method :c)
505 %% basic-effective-method.functions
506 %% compute-method-entry-functions
507 %% compute-effective-method-body
509 %% compute-effective-method-body (simple-effective-method)
510 %% basic-effective-method-body
511 %% simple-method-body (standard-effective-method)
512 %% simple-method-body (aggregating-effective-method)
513 %% message-kernel-function
515 %%%----- That's all, folks --------------------------------------------------
519 %%% TeX-master: "sod.tex"