 
 ! Struct as c-type
 
+: slot>field ( slot -- field )
+    [ class>> c-type ] [ name>> ] bi 2array ;
+
+: define-struct-for-class ( class -- )
+    [
+        [ name>> ] [ vocabulary>> ] [ struct-slots [ slot>field ] map ] tri
+        define-struct
+    ] [
+        [ name>> c-type ]
+        [ (unboxer-quot) >>unboxer-quot ]
+        [ (boxer-quot) >>boxer-quot ] tri drop
+    ] bi ;
+
 : align-offset ( offset class -- offset' )
     c-type-align align ;
 

    [ class>> c-type drop ] each ;

: (define-struct-class) ( class slots offsets-quot -- )
    [ drop struct f define-tuple-class ] swap '[
        make-slots dup
        [ check-struct-slots ] _ [ struct-align [ align ] keep ] tri
        (struct-word-props)
    ] 2bi ; inline

: define-struct-class ( class slots -- )
    [ struct-offsets ] (define-struct-class) ;

: struct-align ( slots -- align )
    [ class>> c-type-align ] [ max ] map-reduce ;

M: struct-class c-type
    name>> c-type ;

M: struct-class c-type-align
    "struct-align" word-prop ;
