alien.strings doesn't load utf16 on Unix anymore
parent
ac653d5c31
commit
11c138ae95
|
@ -2,8 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays sequences kernel accessors math alien.accessors
|
||||
alien.c-types byte-arrays words io io.encodings
|
||||
io.streams.byte-array io.streams.memory io.encodings.utf8
|
||||
io.encodings.utf16 system alien strings cpu.architecture fry ;
|
||||
io.encodings.utf8 io.streams.byte-array io.streams.memory system
|
||||
alien strings cpu.architecture fry vocabs.loader combinators ;
|
||||
IN: alien.strings
|
||||
|
||||
GENERIC# alien>string 1 ( c-ptr encoding -- string/f )
|
||||
|
@ -88,27 +88,22 @@ M: string-type c-type-getter
|
|||
M: string-type c-type-setter
|
||||
drop [ set-alien-cell ] ;
|
||||
|
||||
! Native-order UTF-16
|
||||
HOOK: alien>native-string os ( alien -- string )
|
||||
|
||||
SINGLETON: utf16n
|
||||
|
||||
: utf16n ( -- descriptor )
|
||||
little-endian? utf16le utf16be ? ; foldable
|
||||
|
||||
M: utf16n <decoder> drop utf16n <decoder> ;
|
||||
|
||||
M: utf16n <encoder> drop utf16n <encoder> ;
|
||||
|
||||
: alien>native-string ( alien -- string )
|
||||
os windows? [ utf16n ] [ utf8 ] if alien>string ;
|
||||
HOOK: native-string>alien os ( string -- alien )
|
||||
|
||||
: dll-path ( dll -- string )
|
||||
path>> alien>native-string ;
|
||||
|
||||
: string>symbol ( str -- alien )
|
||||
[ os wince? [ utf16n ] [ utf8 ] if string>alien ]
|
||||
over string? [ call ] [ map ] if ;
|
||||
dup string?
|
||||
[ native-string>alien ]
|
||||
[ [ native-string>alien ] map ] if ;
|
||||
|
||||
{ "char*" utf8 } "char*" typedef
|
||||
{ "char*" utf16n } "wchar_t*" typedef
|
||||
"char*" "uchar*" typedef
|
||||
|
||||
{
|
||||
{ [ os windows? ] [ "alien.strings.windows" require ] }
|
||||
{ [ os unix? ] [ "alien.strings.unix" require ] }
|
||||
} cond
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.strings io.encodings.utf8 system ;
|
||||
IN: alien.strings.unix
|
||||
|
||||
M: unix alien>native-string utf8 alien>string ;
|
||||
|
||||
M: unix native-string>alien utf8 string>alien ;
|
|
@ -0,0 +1,13 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.strings alien.c-types io.encodings.utf8
|
||||
io.encodings.utf16n system ;
|
||||
IN: alien.strings.windows
|
||||
|
||||
M: windows alien>native-string utf16n alien>string ;
|
||||
|
||||
M: wince native-string>alien utf16n string>alien ;
|
||||
|
||||
M: winnt native-string>alien utf8 string>alien ;
|
||||
|
||||
{ "char*" utf16n } "wchar_t*" typedef
|
Loading…
Reference in New Issue