X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/8263521d93a9cdb7c64a7fcb79a9dd8bc6684d8a..c6b4ed992d81518f240509e6ab212d8fe705485a:/lib/sod-structs.3 diff --git a/lib/sod-structs.3 b/lib/sod-structs.3 index 16daa87..161fc4e 100644 --- a/lib/sod-structs.3 +++ b/lib/sod-structs.3 @@ -542,7 +542,7 @@ struct \fIC\fB__ilayout { \h'6n'} \fIc\fB; \h'4n'} \fIc\fB; \h'4n'\fR...\fB -\h'4n'struct \fIH\fB__ichain_\fIh\fB \fIh\fB; +\h'4n'struct \fIA\fB__ichain_\fIh\fB \fIa\fB; \h'2n'} \fIh\fB; \h'2n'union \fIB\fB__ichainu_\fIi\fB \fIi\fB; \h'2n'\fR...\fB @@ -626,13 +626,9 @@ for each of superclasses .IR A in the same chain in some (unimportant) order. -A `pointer to -.IR C ' -is always assumed -(and, indeed, defined in C's type system) -to be a pointer to the -.B struct -.IB C __ichain_ h \fR. +The (somewhat obtuse) purpose of this union is to +engage the `common initial sequence' rule of +C99 (clause 6.5.2.3). .PP The .B ichain @@ -664,6 +660,14 @@ then the last member is .IB C __islots .IB c ; .PP +A `pointer to +.IR C ' +is always assumed +(and, indeed, defined in C's type system) +to be a pointer to the +.B struct +.IB C __ichain_ h \fR. +.PP Finally, the .B islots structure simply contains one member for each slot defined by @@ -688,7 +692,7 @@ will have .I different structures. .PP -The instance layout split neatly into disjoint chains. +The instance layout splits neatly into disjoint chains. This is necessary because each .B ichain @@ -701,7 +705,7 @@ it doesn't matter that there are multiple method entry pointers for the same effective method as long as they all work correctly. -Indeed, it's essential that they do, +Indeed, it's essential that there are multiple entry pointers, because each chain's method entry function will need to apply a different offset to the receiver pointer before invoking the effective method. @@ -865,8 +869,9 @@ be the most specific superclass of .I M in the same chain as .IR J . -Then, if there is currently no class pointer of type -.IR Q , +If there is currently no class pointer +for the chain headed by +.IR J , then add a member .RS .IP @@ -879,7 +884,13 @@ pointing to the appropriate .B islots structure within .IR M 's -class object. +class object, +where +.I Q +is the most specific superclass of +.I M +in the same chain as +.IR J . .RE .hP \*o Examine the superclass chains of @@ -1103,6 +1114,12 @@ Finally, the class object is defined as .B #define .IB C __class .BI (& C __classobj. j . r ) +.br +.B #define +.IB C __cls_ k +.BI (& C __classobj. k . n ) +.br +\&... .PP The exported symbol .IB C __classobj @@ -1121,7 +1138,32 @@ is the root metaclass of i.e., the metaclass of the least specific superclass of .IR C ; usually this is -.BR "const SodClass *" . +.BR "const SodClass\ *" . +For each chain of +.IR C 's +metaclass, a macro +.IB C __cls_ k +is defined, usable as a pointer of type +.B const +.IR N \ \c +.BR * , +where +.I K +and +.I N +are the chain's head and tail classes +(i.e., the least- and most-specific classes in the chain) +respectively; +this macro is +.I omitted +if +.IR N "\ =\ " R , +i.e., in the common case where +.IR C 's +metaclass is precisely the root metaclass, +since the existing +.IB C __class +macro is already sufficient. . .\"-------------------------------------------------------------------------- .SH SEE ALSO