<commit_before>! Copyright (C) 2008, 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.strings alien.c-types alien.accessors alien.structs
arrays words sequences math kernel namespaces fry libc cpu.architecture
io.encodings.utf8 ;
IN: alien.arrays

UNION: value-type array struct-type ;

M: array c-type ;

M: array c-type-class drop object ;

M: array c-type-boxed-class drop object ;

M: array heap-size unclip [ product ] [ heap-size ] bi* * ;

M: array c-type-align first c-type-align ;

M: array c-type-stack-align? drop f ;

M: array unbox-parameter drop "void*" unbox-parameter ;

M: array unbox-return drop "void*" unbox-return ;

M: array box-parameter drop "void*" box-parameter ;

M: array box-return drop "void*" box-return ;

M: array stack-size drop "void*" stack-size ;

M: array c-type-boxer-quot drop [ ] ;

M: array c-type-unboxer-quot drop [ >c-ptr ] ;

M: value-type c-type-rep drop int-rep ;

M: value-type c-type-getter
    drop [ swap <displaced-alien> ] ;

M: value-type c-type-setter ( type -- quot )
    [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
    '[ @ swap @ _ memcpy ] ;

PREDICATE: string-type < pair
    first2 [ "char*" = ] [ word? ] bi* and ;

M: string-type c-type ;

M: string-type c-type-class drop object ;

M: string-type c-type-boxed-class drop object ;

M: string-type heap-size<commit_msg>box array c-types into direct-arrays<commit_after>! Copyright (C) 2008, 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.strings alien.c-types alien.accessors alien.structs
arrays words sequences math kernel namespaces fry libc cpu.architecture
io.encodings.utf8 ;
IN: alien.arrays

UNION: value-type array struct-type ;

M: array c-type ;

M: array c-type-class drop object ;

M: array c-type-boxed-class drop object ;

M: array heap-size unclip [ product ] [ heap-size ] bi* * ;

M: array c-type-align first c-type-align ;

M: array c-type-stack-align? drop f ;

M: array unbox-parameter drop "void*" unbox-parameter ;

M: array unbox-return drop "void*" unbox-return ;

M: array box-parameter drop "void*" box-parameter ;

M: array box-return drop "void*" box-return ;

M: array stack-size drop "void*" stack-size ;

M: array c-type-boxer-quot
    unclip
    [ product ]
    [ [ require-c-type-arrays ] keep ] bi*
    [ <c-type-direct-array> ] 2curry ;

M: array c-type-unboxer-quot drop [ >c-ptr ] ;

M: value-type c-type-rep drop int-rep ;

M: value-type c-type-getter
    drop [ swap <displaced-alien> ] ;

M: value-type c-type-setter ( type -- quot )
    [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
    '[ @ swap @ _ memcpy ] ;

PREDICATE: string-type < pair
    first2 [ "char*" = ] [ word? ] bi* and ;

M: string-type c-type ;

M: string-type c-type-class drop object ;

M: string-type c-type-boxed-class drop object ;

M: string-type heap-size
{'fraction_non_alphanumeric': 0.13910942354159475, 'fraction_numerical': 0.007248878149810148, 'mean_word_length': 3.2555066079295156, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3929570', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1048, 'n_words': 305}