]> gitweb.factorcode.org Git - factor.git/commitdiff
classes.struct: set dependency on slot types in slot accessors, so that accessors...
authorJoe Groff <arcata@gmail.com>
Mon, 22 Feb 2010 06:46:52 +0000 (22:46 -0800)
committerJoe Groff <arcata@gmail.com>
Mon, 22 Feb 2010 06:46:52 +0000 (22:46 -0800)
basis/classes/struct/struct.factor

index 4e7a565a5aba4fa8b6fba621c93e046afbee426e..af73be3aa4146269de3e6627c528499a06eec60c 100644 (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