c-type


Vocabulary
alien.c-types

Definition
USING: cpu.architecture ;

IN: alien.c-types

TUPLE: c-type < abstract-c-type
boxer unboxer { rep initial: int-rep } ;


Methods
USING: alien.c-types ;

M: c-type base-type ;


USING: accessors alien.c-types combinators
compiler.cfg.builder.alien.boxing compiler.cfg.hats
compiler.cfg.instructions kernel sequences ;

M: c-type box
[ [ first ] bi@ ] [ boxer>> ] bi* {
{ "from_float" [ drop ] }
{ "from_double" [ drop ] }
{ "from_signed_1" [ drop char ^^convert-integer ] }
{ "from_unsigned_1" [ drop uchar ^^convert-integer ] }
{ "from_signed_2" [ drop short ^^convert-integer ] }
{ "from_unsigned_2" [ drop ushort ^^convert-integer ] }
{ "from_signed_4" [ drop int ^^convert-integer ] }
{ "from_unsigned_4" [ drop uint ^^convert-integer ] }
{ "allot_alien" [ drop ^^box-alien ] }
[ swap <gc-map> ^^box ]
} case ;


USING: alien.c-types kernel ;

M: c-type c-type-copier drop [ ] ;


USING: accessors alien.c-types ;

M: c-type c-type-getter getter>> ;


USING: accessors alien.c-types ;

M: c-type c-type-rep rep>> ;


USING: accessors alien.c-types ;

M: c-type c-type-setter setter>> ;


USING: accessors alien.c-types arrays
compiler.cfg.builder.alien.boxing ;

M: c-type flatten-c-type rep>> f f 3array 1array ;


USING: accessors alien.c-types arrays combinators
compiler.cfg.builder.alien.boxing compiler.cfg.hats kernel ;

M: c-type unbox
[ rep>> ] [ unboxer>> ] bi [
{
{ "to_float" [ drop ] }
{ "to_double" [ drop ] }
{ "to_signed_1" [ drop ] }
{ "to_unsigned_1" [ drop ] }
{ "to_signed_2" [ drop ] }
{ "to_unsigned_2" [ drop ] }
{ "to_signed_4" [ drop ] }
{ "to_unsigned_4" [ drop ] }
{ "alien_offset" [ drop ^^unbox-any-c-ptr ] }
[ swap ^^unbox ]
} case 1array
] [ drop f f 3array 1array ] 2bi ;


USING: alien.c-types compiler.cfg.builder.alien.boxing ;

M: c-type unbox-parameter unbox ;