classes.struct: set dependency on slot types in slot accessors, so that accessors update when types change. enables pointers to make circular references between struct types

db4
Joe Groff 2010-02-21 22:46:52 -08:00
parent 310b3df2ec
commit c7acbda342
1 changed files with 12 additions and 3 deletions

View File

@ -8,7 +8,8 @@ generalizations generic.parser kernel kernel.private lexer libc
locals macros make math math.order parser quotations sequences
slots slots.private specialized-arrays vectors words summary
namespaces assocs vocabs.parser math.functions
classes.struct.bit-accessors bit-arrays ;
classes.struct.bit-accessors bit-arrays
stack-checker.dependencies ;
QUALIFIED: math
IN: classes.struct
@ -124,6 +125,14 @@ M: struct-bit-slot-spec (writer-quot)
: (unboxer-quot) ( class -- quot )
drop [ >c-ptr ] ;
MACRO: read-struct-slot ( slot -- )
dup type>> depends-on-c-type
(reader-quot) ;
MACRO: write-struct-slot ( slot -- )
dup type>> depends-on-c-type
(writer-quot) ;
PRIVATE>
M: struct-class boa>object
@ -138,10 +147,10 @@ M: struct-class initial-value* <struct> ; inline
GENERIC: struct-slot-values ( struct -- sequence )
M: struct-class reader-quot
nip (reader-quot) ;
nip '[ _ read-struct-slot ] ;
M: struct-class writer-quot
nip (writer-quot) ;
nip '[ _ write-struct-slot ] ;
: offset-of ( field struct -- offset )
struct-slots slot-named offset>> ; inline