 : (define-byte-length-method) ( class -- )
     [ \ byte-length create-method-in ]
     [ heap-size \ drop swap [ ] 2sequence ] bi define ;
-
-! Struct as c-type
 
 : slot>field ( slot -- field )
     field-spec new swap {

        { "{" [ parse-struct-slot` t ] }
        [ invalid-struct-slot ]
    } case ;

FUNCTOR-SYNTAX: STRUCT:
    scan-param parsed

M: struct clone
    [ >c-ptr ] [ byte-length memory>byte-array ] [ class memory>struct ] tri ;

<PRIVATE
: (init-struct) ( class with-prototype: ( prototype -- alien ) sans-prototype: ( class -- alien ) -- alien )
    '[ dup struct-prototype _ _ ?if ] keep memory>struct ; inline
PRIVATE>

: (malloc-struct) ( class -- struct )
    [ heap-size malloc ] keep memory>struct ; inline
