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 {compute-effective-slot @<class> @<slot> @> @<effective-slot>
}
76 {sod-class-effective-slot (effective-slot) \\
\ind
77 \&key :class :slot :initializer-function :prepare-function
}
81 {\dhead{gf
}{effective-slot-initializer-function @<slot> @> @<function>
}
82 \dhead{gf
}{effective-slot-prepare-function @<slot> @> @<function>
}}
85 \begin{describe
}{cls
}{islots () \&key :class :subclass :slots
}
89 {\dhead{gf
}{islots-class @<islots> @> @<class>
}
90 \dhead{gf
}{islots-subclass @<islots> @> @<class>
}
91 \dhead{gf
}{islots-slots @<islots> @> @<list>
}}
94 \begin{describe
}{gf
}{compute-islots @<class> @<subclass> @> @<islots>
}
97 \begin{describe
}{gf
}{vtable-pointer () \&key :class :chain-head :chain-tail
}
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>
}}
106 \begin{describe
}{gf
}{ichain () \&key :class :chain-head :chain-tail :body
}
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>
}}
116 \begin{describe
}{gf
}{compute-ichain @<class> @<chain> @> @<ichain>
}
119 \begin{describe
}{gf
}{ilayout () \&key :class :ichains
}
123 {\dhead{gf
}{ilayout-class @<ilayout> @> @<class>
}
124 \dhead{gf
}{ilayout-ichains @<ilayout> @> @<list>
}}
127 \begin{describe
}{gf
}{sod-class-ilayout <class> @> @<ilayout>
}
130 \begin{describe
}{gf
}{compute-ilayout @<class> @> @<ilayout>
}
133 \begin{describe
}{cls
}
134 {vtmsgs () \&key :class :subclass :chain-head :chain-tail :entries
}
138 {\dhead{gf
}{vtmsgs-class @<vtmsgs> @> @<class>
}
139 \dhead{gf
}{vtmsgs-subclass @<vtmsgs> @> @<class>
}
140 \dhead{gf
}{vtmsgs-chain-head @<vtmsgs> @> @<class>
}
141 \dhead{gf
}{vtmsgs-chain-tail @<vtmsgs> @> @<class>
}
142 \dhead{gf
}{vtmsgs-entries @<vtmsgs> @> @<list>
}}
145 \begin{describe
}{cls
}
146 {class-pointer () \&key :class :chain-head :metaclass :meta-chain-head
}
150 {\dhead{gf
}{class-pointer-class @<class-pointer> @> @<class>
}
151 \dhead{gf
}{class-pointer-chain-head @<class-pointer> @> @<class>
}
152 \dhead{gf
}{class-pointer-metaclass @<class-pointer> @> @<class>
}
153 \dhead{gf
}{class-pointer-meta-chain-head @<class-pointer> @> @<class>
}}
156 \begin{describe
}{fun
}
157 {make-class-pointer @<class> @<chain-head>
158 @<metaclass> @<meta-chain-head>
162 \begin{describe
}{cls
}{base-offset () \&key :class :chain-head
}
166 {\dhead{gf
}{base-offset-class @<base-offset> @> @<class>
}
167 \dhead{gf
}{base-offset-chain-head @<base-offset> @> @<class>
}}
170 \begin{describe
}{fun
}
171 {make-base-offset @<class> @<chain-head> @> @<base-offset>
}
174 \begin{describe
}{cls
}{chain-offset () \&key :class :chain-head :target-head
}
178 {\dhead{gf
}{chain-offset-class @<chain-offset> @> @<class>
}
179 \dhead{gf
}{chain-offset-chain-head @<chain-offset> @> @<class>
}
180 \dhead{gf
}{chain-offset-target-head @<chain-offset> @> @<class>
}}
183 \begin{describe
}{fun
}
184 {make-chain-offset @<class> @<chain-head> @<target-head>
188 \begin{describe
}{gf
}{vtable () \&key :class :chain-head :chain-tail :body
}
192 {\dhead{gf
}{vtable-class @<vtable> @> @<class>
}
193 \dhead{gf
}{vtable-chain-head @<vtable> @> @<class>
}
194 \dhead{gf
}{vtable-chain-tail @<vtable> @> @<class>
}
195 \dhead{gf
}{vtable-body @<vtable> @> @<list>
}}
199 {compute-vtable-items @<class> @<super>
200 @<chain-head> @<chain-tail>
204 \begin{describe
}{gf
}{compute-vtable @<class> @<chain> @> @<vtable>
}
207 \begin{describe
}{gf
}{sod-class-vtables @<class> @> @<list>
}
210 \begin{describe
}{gf
}{compute-vtables @<class> @> @<list>
}
213 %%%--------------------------------------------------------------------------
214 \section{Method combination
} \label{sec:layout.methods
}
216 \begin{describe
}{cls
}{effective-method () \&key :message :class :keywords
}
220 {\dhead{gf
}{effective-method-message @<method> @> @<message>
}
221 \dhead{gf
}{effective-method-class @<method> @> @<class>
}
222 \dhead{gf
}{effective-method-keywords @<method> @> @<list>
}}
226 {sod-message-effective-method-class @<message> @> @<class>
}
229 \begin{describe
}{gf
}{primary-method-class @<message> @> @<class>
}
233 {compute-sod-effective-method @<message> @<class> @> @<method>
}
236 \begin{describe
}{gf
}{sod-class-effective-methods @<class> @> @<list>
}
239 \begin{describe
}{gf
}{compute-effective-methods @<class> @> @<list>
}
242 \begin{describe
}{cls
}
243 {method-entry () \&key :method :chain-head :chain-tail :role
}
247 {\dhead{gf
}{method-entry-effective-method @<method-entry> @> @<method>
}
248 \dhead{gf
}{method-entry-chain-head @<method-entry> @> @<class>
}
249 \dhead{gf
}{method-entry-chain-tail @<method-entry> @> @<class>
}
250 \dhead{gf
}{method-entry-role @<method-entry> @> @<role>
}}
254 {make-method-entries @<effective-method> @<chain-head> @<chain-tail>
259 \begin{describe
}{gf
}{sod-message-argument-tail @<message> @> @<list>
}
262 \begin{describe
}{gf
}{sod-method-function-type @<method> @> @<c-type>
}
265 \begin{describe
}{gf
}{sod-method-next-method-type @<method> @> @<c-type>
}
268 \begin{describe
}{gf
}{sod-method-function-name @<method> @> @<string>
}
271 \begin{describe
}{fun
}{varargs-message-p @<message> @> @<generalized-boolean>
}
274 \begin{describe
}{fun
}{keyword-message-p @<message> @> @<generalized-boolean>
}
277 \begin{describe
}{gf
}{method-entry-function-type @<entry> @> @<c-type>
}
280 \begin{describe
}{gf
}{method-entry-slot-name @<entry> @> @<string>
}
284 {method-entry-slot-name-by-role @<entry> @<role> @<name> @> @<string>
}
288 {effective-method-basic-argument-names @<method> @> @<list>
}
293 \begin{describe
}{cls
}
294 {method-codegen (codegen) \\
\ind
295 \&key :vars :insts :temp-index
296 :message :class :method :target
}
300 {\dhead{gf
}{codegen-message @<codegen> @> @<message>
}
301 \dhead{gf
}{codegen-class @<codegen> @> @<class>
}
302 \dhead{gf
}{codegen-method @<codegen> @> @<method>
}
303 \dhead{gf
}{codegen-target @<codegen> @> @<target>
}}
307 {\dhead{cls
}{convert-to-ilayout-inst (inst)
}
309 {make-convert-to-ilayout-inst @<class> @<chain-head> @<expr>
}}
311 SOD_ILAYOUT(@<class>, @<chain-head-nick>, @<expr>)
317 {compute-effective-method-body @<method> @<codegen> @<target>
}
320 \begin{describe
}{gf
}{simple-method-body @<method> @<codegen> @<target>
}
323 \begin{describe
}{fun
}
324 {invoke-method @<codegen> @<target> @<arguments-tail> @<direct-method>
}
327 \begin{describe
}{fun
}{ensure-ilayout-var @<codegen> @<super>
}
330 \begin{describe
}{fun
}{make-trampoline @<codegen> @<super> @<body-func>
}
333 \begin{describe
}{gf
}{effective-method-function-name @<method> @> @<string>
}
337 {method-entry-function-name @<method> @<chain-head> @<role> @> @<string>
}
340 \begin{describe
}{gf
}{compute-method-entry-functions @<method> @> @<list>
}
343 \begin{describe
}{fun
}
344 {invoke-delegation-chain @<codegen> @<target> @<basic-tail>
345 @<chain> @<kernel-func>
}
348 \begin{describe
}{cls
}
349 {basic-message (sod-message) \&key :name :location :class :type
}
352 \begin{describe
}{cls
}
353 {simple-message (basic-message) \&key :name :location :class :type
}
356 \begin{describe
}{cls
}
357 {basic-direct-method (sod-method)
358 \&key :message :location :class :type :body :role
}
361 \begin{describe
}{gf
}{sod-method-role @<method> @> @<role>
}
364 \begin{describe
}{cls
}
365 {daemon-direct-method (basic-direct-method) \\
\ind
366 \&key :message :location :class :type :body :role
}
369 \begin{describe
}{cls
}
370 {delegating-direct-method (basic-direct-method) \\
\ind
371 \&key :message :location :class :type :body :role
}
374 \begin{describe
}{cls
}
375 {basic-effective-method (effective-method) \\
\ind
376 \&key :message :class :around-methods :before-methods :after-methods
}
381 {effective-method-around-methods @<effective-method> @> @<list>
}
383 {effective-method-before-methods @<effective-method> @> @<list>
}
385 {effective-method-after-methods @<effective-method> @> @<list>
}
386 \dhead{gf
}{effective-method-functions @<effective-method> @> @<list>
}}
389 \begin{describe
}{cls
}
390 {simple-effective-method (basic-effective-method) \\
\ind
391 \&key :message :class
392 :around-methods :before-methods :after-methods :primary-methods
}
395 \begin{describe
}{fun
}
396 {basic-effective-method-body @<codegen> @<target> @<method> @<body>
}
399 \begin{describe
}{cls
}
400 {standard-message (simple-message) \&key :name :location :class :type
}
403 \begin{describe
}{cls
}
404 {standard-effective-method (simple-effective-method) \\
\ind
405 \&key :message :class
406 :around-methods :before-methods :after-methods :primary-methods
}
409 \begin{describe
}{cls
}
410 {aggregating-message (simple-message)
411 \&key :name :location :class :type :combination
}
415 {aggregating-message-properties @<message> @<combination> @> @<plist>
}
419 {compute-aggregating-message-kernel
420 \=@<message> @<combination> @<target> \+ \\
421 @<methods> @<arg-names> \&key
}
425 {check-aggregating-message-type @<message> @<combination> @<c-type>
}
428 \begin{describe
}{cls
}
429 {aggregating-effective-method (simple-effective-method) \\
\ind
430 \&key :message :class
431 :around-methods :before-methods :after-methods :primary-methods
}
434 \begin{describe
}{mac
}
435 {define-aggregating-method-combination @<combination> \\
\ind\ind
437 @
[[ :codegen @<codegen-var> @!
438 :methods @<methods-var> @
]]) \- \\
439 @
[[ \=:properties (@
{ (@
{ @<name> @! (@
[@<keyword>@
] @<name>) @
}
442 @
[@<suppliedp-var>@
]@
]) @
}^*) @! \+ \\
443 :return-type @<c-type> @! \\
444 :around @<around-func> @!
445 :first-method @<first-method-func> @!
446 :method @<method-func> @
]]}
449 %%% the method combination story
450 %% compute-effective-methods --> compute-sod-effective-method
452 %% hook-output (basic-effective-method :c)
453 %% basic-effective-method.functions
454 %% compute-method-entry-functions
455 %% compute-effective-method-body
457 %% compute-effective-method-body (simple-effective-method)
458 %% basic-effective-method-body
459 %% simple-method-body (standard-effective-method)
460 %% simple-method-body (aggregating-effective-method)
461 %% message-kernel-function
463 %%%----- That's all, folks --------------------------------------------------
467 %%% TeX-master: "sod.tex"