USING: accessors alien.c-types alien.strings assocs byte-arrays
combinators continuations destructors fry io.encodings.8-bit
io io.encodings.string io.encodings.utf8 kernel math
-namespaces prettyprint sequences
+namespaces prettyprint sequences classes.struct
strings threads curses.ffi ;
IN: curses
: move-cursor ( window-name y x -- )
[
- window-ptr
+ window-ptr c-window memory>struct
{
[ ]
[ (curses-window-refresh) ]
- [ c-window-_curx ]
- [ c-window-_cury ]
+ [ _curx>> ]
+ [ _cury>> ]
} cleave
] 2dip mvcur curses-error (curses-window-refresh) ;
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.syntax combinators kernel system
-alien.libraries ;
+alien.libraries classes.struct ;
IN: curses.ffi
<< "curses" {
CONSTANT: CCHARW_MAX 5
-C-STRUCT: cchar_t
- { "attr_t" "attr" }
- { { "wchar_t" CCHARW_MAX } "chars" } ;
+STRUCT: cchar_t
+ { attr attr_t }
+ { chars { wchar_t CCHARW_MAX } } ;
-C-STRUCT: pdat
- { "NCURSES_SIZE_T" "_pad_y" }
- { "NCURSES_SIZE_T" "_pad_x" }
- { "NCURSES_SIZE_T" "_pad_top" }
- { "NCURSES_SIZE_T" "_pad_left" }
- { "NCURSES_SIZE_T" "_pad_bottom" }
- { "NCURSES_SIZE_T" "_pad_right" } ;
+STRUCT: pdat
+ { _pad_y NCURSES_SIZE_T }
+ { _pad_x NCURSES_SIZE_T }
+ { _pad_top NCURSES_SIZE_T }
+ { _pad_left NCURSES_SIZE_T }
+ { _pad_bottom NCURSES_SIZE_T }
+ { _pad_right NCURSES_SIZE_T } ;
-C-STRUCT: c-window
- { "NCURSES_SIZE_T" "_cury" }
- { "NCURSES_SIZE_T" "_curx" }
+STRUCT: c-window
+ { _cury NCURSES_SIZE_T }
+ { _curx NCURSES_SIZE_T }
- { "NCURSES_SIZE_T" "_maxy" }
- { "NCURSES_SIZE_T" "_maxx" }
- { "NCURSES_SIZE_T" "_begy" }
- { "NCURSES_SIZE_T" "_begx" }
+ { _maxy NCURSES_SIZE_T }
+ { _maxx NCURSES_SIZE_T }
+ { _begy NCURSES_SIZE_T }
+ { _begx NCURSES_SIZE_T }
- { "short" " _flags" }
+ { _flags short }
- { "attr_t" "_attrs" }
- { "chtype" "_bkgd" }
+ { _attrs attr_t }
+ { _bkgd chtype }
- { "bool" "_notimeout" }
- { "bool" "_clear" }
- { "bool" "_leaveok" }
- { "bool" "_scroll" }
- { "bool" "_idlok" }
- { "bool" "_idcok" }
- { "bool" "_immed" }
- { "bool" "_sync" }
- { "bool" "_use_keypad" }
- { "int" "_delay" }
+ { _notimeout bool }
+ { _clear bool }
+ { _leaveok bool }
+ { _scroll bool }
+ { _idlok bool }
+ { _idcok bool }
+ { _immed bool }
+ { _sync bool }
+ { _use_keypad bool }
+ { _delay int }
- { "char*" "_line" }
- { "NCURSES_SIZE_T" "_regtop" }
- { "NCURSES_SIZE_T" "_regbottom" }
+ { _line char* }
+ { _regtop NCURSES_SIZE_T }
+ { _regbottom NCURSES_SIZE_T }
- { "int" "_parx" }
- { "int" "_pary" }
- { "WINDOW*" "_parent" }
+ { _parx int }
+ { _pary int }
+ { _parent WINDOW* }
- { "pdat" "_pad" }
+ { _pad pdat }
- { "NCURSES_SIZE_T" "_yoffset" }
+ { _yoffset NCURSES_SIZE_T }
- { "cchar_t" "_bkgrnd" } ;
+ { _bkgrnd cchar_t } ;
LIBRARY: curses
! Copyright (C) 2005, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.syntax kernel system combinators
-alien.libraries ;
+alien.libraries classes.struct ;
IN: freetype
<< "freetype" {
TYPEDEF: void face
TYPEDEF: void glyph
-C-STRUCT: glyph
- { "void*" "library" }
- { "face*" "face" }
- { "glyph*" "next" }
- { "FT_UInt" "reserved" }
- { "void*" "generic" }
- { "void*" "generic" }
+STRUCT: glyph
+ { library void* }
+ { face face* }
+ { next glyph* }
+ { reserved FT_UInt }
+ { generic void* }
+ { generic2 void* }
- { "FT_Pos" "width" }
- { "FT_Pos" "height" }
+ { width FT_Pos }
+ { height FT_Pos }
- { "FT_Pos" "hori-bearing-x" }
- { "FT_Pos" "hori-bearing-y" }
- { "FT_Pos" "hori-advance" }
+ { hori-bearing-x FT_Pos }
+ { hori-bearing-y FT_Pos }
+ { hori-advance FT_Pos }
- { "FT_Pos" "vert-bearing-x" }
- { "FT_Pos" "vert-bearing-y" }
- { "FT_Pos" "vert-advance" }
+ { vert-bearing-x FT_Pos }
+ { vert-bearing-y FT_Pos }
+ { vert-advance FT_Pos }
- { "FT_Fixed" "linear-hori-advance" }
- { "FT_Fixed" "linear-vert-advance" }
- { "FT_Pos" "advance-x" }
- { "FT_Pos" "advance-y" }
+ { linear-hori-advance FT_Fixed }
+ { linear-vert-advance FT_Fixed }
+ { advance-x FT_Pos }
+ { advance-y FT_Pos }
- { "intptr_t" "format" }
+ { format intptr_t }
- { "int" "bitmap-rows" }
- { "int" "bitmap-width" }
- { "int" "bitmap-pitch" }
- { "void*" "bitmap-buffer" }
- { "short" "bitmap-num-grays" }
- { "char" "bitmap-pixel-mode" }
- { "char" "bitmap-palette-mode" }
- { "void*" "bitmap-palette" }
+ { bitmap-rows int }
+ { bitmap-width int }
+ { bitmap-pitch int }
+ { bitmap-buffer void* }
+ { bitmap-num-grays short }
+ { bitmap-pixel-mode char }
+ { bitmap-palette-mode char }
+ { bitmap-palette void* }
- { "FT_Int" "bitmap-left" }
- { "FT_Int" "bitmap-top" }
+ { bitmap-left FT_Int }
+ { bitmap-top FT_Int }
- { "short" "n-contours" }
- { "short" "n-points" }
+ { n-contours short }
+ { n-points short }
- { "void*" "points" }
- { "char*" "tags" }
- { "short*" "contours" }
+ { points void* }
+ { tags char* }
+ { contours short* }
- { "int" "outline-flags" }
+ { outline-flags int }
- { "FT_UInt" "num_subglyphs" }
- { "void*" "subglyphs" }
+ { num_subglyphs FT_UInt }
+ { subglyphs void* }
- { "void*" "control-data" }
- { "long" "control-len" }
+ { control-data void* }
+ { control-len long }
- { "FT_Pos" "lsb-delta" }
- { "FT_Pos" "rsb-delta" }
+ { lsb-delta FT_Pos }
+ { rsb-delta FT_Pos }
- { "void*" "other" } ;
+ { other void* } ;
-C-STRUCT: face-size
- { "face*" "face" }
- { "void*" "generic" }
- { "void*" "generic" }
+STRUCT: face-size
+ { face face* }
+ { generic void* }
+ { generic2 void* }
- { "FT_UShort" "x-ppem" }
- { "FT_UShort" "y-ppem" }
+ { x-ppem FT_UShort }
+ { y-ppem FT_UShort }
- { "FT_Fixed" "x-scale" }
- { "FT_Fixed" "y-scale" }
+ { x-scale FT_Fixed }
+ { y-scale FT_Fixed }
- { "FT_Pos" "ascender" }
- { "FT_Pos" "descender" }
- { "FT_Pos" "height" }
- { "FT_Pos" "max-advance" } ;
+ { ascender FT_Pos }
+ { descender FT_Pos }
+ { height FT_Pos }
+ { max-advance FT_Pos } ;
-C-STRUCT: face
- { "FT_Long" "num-faces" }
- { "FT_Long" "index" }
+STRUCT: face
+ { num-faces FT_Long }
+ { index FT_Long }
- { "FT_Long" "flags" }
- { "FT_Long" "style-flags" }
+ { flags FT_Long }
+ { style-flags FT_Long }
- { "FT_Long" "num-glyphs" }
+ { num-glyphs FT_Long }
- { "FT_Char*" "family-name" }
- { "FT_Char*" "style-name" }
+ { family-name FT_Char* }
+ { style-name FT_Char* }
- { "FT_Int" "num-fixed-sizes" }
- { "void*" "available-sizes" }
+ { num-fixed-sizes FT_Int }
+ { available-sizes void* }
- { "FT_Int" "num-charmaps" }
- { "void*" "charmaps" }
+ { num-charmaps FT_Int }
+ { charmaps void* }
- { "void*" "generic" }
- { "void*" "generic" }
+ { generic void* }
+ { generic2 void* }
- { "FT_Pos" "x-min" }
- { "FT_Pos" "y-min" }
- { "FT_Pos" "x-max" }
- { "FT_Pos" "y-max" }
+ { x-min FT_Pos }
+ { y-min FT_Pos }
+ { x-max FT_Pos }
+ { y-max FT_Pos }
- { "FT_UShort" "units-per-em" }
- { "FT_Short" "ascender" }
- { "FT_Short" "descender" }
- { "FT_Short" "height" }
+ { units-per-em FT_UShort }
+ { ascender FT_Short }
+ { descender FT_Short }
+ { height FT_Short }
- { "FT_Short" "max-advance-width" }
- { "FT_Short" "max-advance-height" }
+ { max-advance-width FT_Short }
+ { max-advance-height FT_Short }
- { "FT_Short" "underline-position" }
- { "FT_Short" "underline-thickness" }
+ { underline-position FT_Short }
+ { underline-thickness FT_Short }
- { "glyph*" "glyph" }
- { "face-size*" "size" }
- { "void*" "charmap" } ;
+ { glyph glyph* }
+ { size face-size* }
+ { charmap void* } ;
-C-STRUCT: FT_Bitmap
- { "int" "rows" }
- { "int" "width" }
- { "int" "pitch" }
- { "void*" "buffer" }
- { "short" "num_grays" }
- { "char" "pixel_mode" }
- { "char" "palette_mode" }
- { "void*" "palette" } ;
+STRUCT: FT_Bitmap
+ { rows int }
+ { width int }
+ { pitch int }
+ { buffer void* }
+ { num_grays short }
+ { pixel_mode char }
+ { palette_mode char }
+ { palette void* } ;
FUNCTION: FT_Error FT_New_Face ( void* library, FT_Char* font, FT_Long index, face* face ) ;
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax kernel sequences system ;
+USING: alien.syntax classes.struct kernel sequences system ;
IN: io.serial.unix.termios
CONSTANT: NCCS 20
TYPEDEF: uchar cc_t
TYPEDEF: uint speed_t
-C-STRUCT: termios
- { "tcflag_t" "iflag" } ! input mode flags
- { "tcflag_t" "oflag" } ! output mode flags
- { "tcflag_t" "cflag" } ! control mode flags
- { "tcflag_t" "lflag" } ! local mode flags
- { { "cc_t" NCCS } "cc" } ! control characters
- { "speed_t" "ispeed" } ! input speed
- { "speed_t" "ospeed" } ; ! output speed
+STRUCT: termios
+ { iflag tcflag_t }
+ { oflag tcflag_t }
+ { cflag tcflag_t }
+ { lflag tcflag_t }
+ { cc { cc_t NCCS } }
+ { ispeed speed_t }
+ { ospeed speed_t } ;
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax kernel system unix ;
+USING: alien.syntax classes.struct kernel system unix ;
IN: io.serial.unix.termios
CONSTANT: NCCS 32
TYPEDEF: uint speed_t
TYPEDEF: uint tcflag_t
-C-STRUCT: termios
- { "tcflag_t" "iflag" } ! input mode flags
- { "tcflag_t" "oflag" } ! output mode flags
- { "tcflag_t" "cflag" } ! control mode flags
- { "tcflag_t" "lflag" } ! local mode flags
- { "cc_t" "line" } ! line discipline
- { { "cc_t" NCCS } "cc" } ! control characters
- { "speed_t" "ispeed" } ! input speed
- { "speed_t" "ospeed" } ; ! output speed
+STRUCT: termios
+ { iflag tcflag_t }
+ { oflag tcflag_t }
+ { cflag tcflag_t }
+ { lflag tcflag_t }
+ { line cc_t }
+ { cc { cc_t NCCS } }
+ { ispeed speed_t }
+ { ospeed speed_t } ;
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.syntax alien.data
-combinators io.ports io.streams.duplex system kernel
-math math.bitwise vocabs.loader unix io.serial
+classes.struct combinators io.ports io.streams.duplex
+system kernel math math.bitwise vocabs.loader unix io.serial
io.serial.unix.termios io.backend.unix ;
IN: io.serial.unix
: get-termios ( serial -- termios )
serial-fd
- "termios" <c-object> [ tcgetattr io-error ] keep ;
+ termios <struct> [ tcgetattr io-error ] keep ;
: configure-termios ( serial -- )
dup termios>>
{
- [ [ iflag>> ] dip over [ set-termios-iflag ] [ 2drop ] if ]
- [ [ oflag>> ] dip over [ set-termios-oflag ] [ 2drop ] if ]
+ [ [ iflag>> ] dip over [ (>>iflag) ] [ 2drop ] if ]
+ [ [ oflag>> ] dip over [ (>>oflag) ] [ 2drop ] if ]
[
[
[ cflag>> 0 or ] [ baud>> lookup-baud ] bi bitor
- ] dip set-termios-cflag
+ ] dip (>>cflag)
]
- [ [ lflag>> ] dip over [ set-termios-lflag ] [ 2drop ] if ]
+ [ [ lflag>> ] dip over [ (>>lflag) ] [ 2drop ] if ]
} 2cleave ;
: tciflush ( serial -- )
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.libraries alien.syntax
combinators kernel system tokyo.alien.tchdb tokyo.alien.tcutil
-tokyo.alien.tctdb ;
+tokyo.alien.tctdb classes.struct ;
IN: tokyo.alien.tcrdb
<< "tokyotyrant" {
LIBRARY: tokyotyrant
TYPEDEF: void* TCRDB*
-! C-STRUCT: TCRDB
-! { "pthread_mutex_t" mmtx }
-! { "pthread_key_t" eckey }
-! { "char*" host }
-! { "int" port }
-! { "char*" expr }
-! { "int" fd }
-! { "TTSOCK*" sock }
-! { "double" timeout }
-! { "int" opts } ;
+! STRUCT: TCRDB
+! { mmtx pthread_mutex_t }
+! { eckey pthread_key_t }
+! { host char* }
+! { port int }
+! { expr char* }
+! { fd int }
+! { sock TTSOCK* }
+! { timeout double }
+! { opts int } ;
C-ENUM:
TTESUCCESS
CONSTANT: RDBITKEEP TDBITKEEP
TYPEDEF: void* RDBQRY*
-! C-STRUCT: RDBQRY
-! { "TCRDB*" rdb }
-! { "TCLIST*" args } ;
+! STRUCT: RDBQRY
+! { rdb TCRDB* }
+! { args TCLIST* } ;
CONSTANT: RDBQCSTREQ TDBQCSTREQ
CONSTANT: RDBQCSTRINC TDBQCSTRINC