! Copyright (C) 2011 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.accessors alien.c-types alien.data arrays
-classes.struct.private combinators compiler.units endian fry
-generalizations kernel macros math math.bitwise namespaces
-sequences slots words ;
+classes.struct.private combinators compiler.units endian
+generalizations kernel math math.bitwise namespaces sequences
+slots words ;
QUALIFIED-WITH: alien.c-types c
IN: alien.endian
[
drop
[
- dup iota [
+ dup <iota> [
[ 1 + - -8 * ] [ nip 8 * ] 2bi
'[ _ shift 0xff bitand _ shift ]
] with map
first2 [ slot>endian-slot ] dip 2array
] [
{
+ { [ dup bool = ] [ 2drop bool ] }
{ [ dup char = ] [ 2drop char ] }
{ [ dup uchar = ] [ 2drop uchar ] }
{ [ dup c:short = ] [ { le16 be16 } endian-slot ] }
{ [ dup longlong = ] [ { le64 be64 } endian-slot ] }
{ [ dup ulonglong = ] [ { ule64 ube64 } endian-slot ] }
{ [ dup endian-c-type? ] [ nip ] }
+ { [ dup pointer? ] [ nip ] }
[ unsupported-endian-type ]
} cond
] if ;