Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-09-28 02:19:05 -05:00
commit 790611666c
57 changed files with 213 additions and 138 deletions

View File

@ -88,16 +88,24 @@ HELP: uint
{ $description "This C type represents a four-byte unsigned integer type. Input values will be converted to " { $link math:integer } "s and truncated to 32 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: long
{ $description "This C type represents a four- or eight-byte signed integer type. On Windows and on 32-bit Unix platforms, it will be four bytes. On 64-bit Unix platforms, it will be eight bytes. Input values will be converted to " { $link math:integer } "s and truncated to 32 or 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: intptr_t
{ $description "This C type represents a signed integer type large enough to hold any pointer value; that is, on 32-bit platforms, it will be four bytes, and on 64-bit platforms, it will be eight bytes. Input values will be converted to " { $link math:integer } "s and truncated to 32 or 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: ulong
{ $description "This C type represents a four- or eight-byte unsigned integer type. On Windows and on 32-bit Unix platforms, it will be four bytes. On 64-bit Unix platforms, it will be eight bytes. Input values will be converted to " { $link math:integer } "s and truncated to 32 or 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: uintptr_t
{ $description "This C type represents an unsigned integer type large enough to hold any pointer value; that is, on 32-bit platforms, it will be four bytes, and on 64-bit platforms, it will be eight bytes. Input values will be converted to " { $link math:integer } "s and truncated to 32 or 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: ptrdiff_t
{ $description "This C type represents a signed integer type large enough to hold the distance between two pointer values; that is, on 32-bit platforms, it will be four bytes, and on 64-bit platforms, it will be eight bytes. Input values will be converted to " { $link math:integer } "s and truncated to 32 or 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: size_t
{ $description "This C type represents unsigned size values of the size expected by the platform's standard C library (usually four bytes on a 32-bit platform, and eight on a 64-bit platform). Input values will be converted to " { $link math:integer } "s and truncated to the appropriate size; output values will be returned as " { $link math:integer } "s." } ;
HELP: longlong
{ $description "This C type represents an eight-byte signed integer type. Input values will be converted to " { $link math:integer } "s and truncated to 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: ulonglong
{ $description "This C type represents an eight-byte unsigned integer type. Input values will be converted to " { $link math:integer } "s and truncated to 64 bits; output values will be returned as " { $link math:integer } "s." } ;
HELP: void
{ $description "This symbol is not a valid C type, but it can be used as the return type for a " { $link POSTPONE: FUNCTION: } " or " { $link POSTPONE: CALLBACK: } " definition, or an " { $link alien-invoke } " or " { $link alien-callback } " call." } ;
{ $description "This symbol is not a valid C type, but it can be used as the return type for a " { $link POSTPONE: FUNCTION: } " or " { $link POSTPONE: CALLBACK: } " definition or for an " { $link alien-invoke } " or " { $link alien-callback } " call." } ;
HELP: void*
{ $description "This C type represents a pointer to C memory. " { $link byte-array } " and " { $link alien } " values can be passed as inputs, but see " { $link "byte-arrays-gc" } " for notes about passing byte arrays into C functions. Output values are returned as " { $link alien } "s." } ;
{ $description "This C type represents a pointer to C memory. " { $link byte-array } " and " { $link alien } " values can be passed as " { $snippet "void*" } " function inputs, but see " { $link "byte-arrays-gc" } " for notes about passing byte arrays into C functions. " { $snippet "void*" } " output values are returned as " { $link alien } "s." } ;
HELP: char*
{ $description "This C type represents a pointer to a C string. See " { $link "c-strings" } " for details about using strings with the FFI." } ;
HELP: float

View File

@ -1,6 +1,6 @@
USING: alien alien.syntax alien.c-types alien.parser
kernel tools.test sequences system libc alien.strings
io.encodings.utf8 math.constants classes.struct ;
eval kernel tools.test sequences system libc alien.strings
io.encodings.utf8 math.constants classes.struct classes ;
IN: alien.c-types.tests
CONSTANT: xyz 123
@ -15,28 +15,28 @@ UNION-STRUCT: foo
{ a int }
{ b int } ;
[ f ] [ "char*" parse-c-type c-type void* c-type eq? ] unit-test
[ t ] [ "char**" parse-c-type c-type void* c-type eq? ] unit-test
[ f ] [ char resolve-pointer-type c-type void* c-type eq? ] unit-test
[ t ] [ char* resolve-pointer-type c-type void* c-type eq? ] unit-test
[ t ] [ foo heap-size int heap-size = ] unit-test
TYPEDEF: int MyInt
[ t ] [ int c-type MyInt c-type eq? ] unit-test
[ t ] [ void* c-type "MyInt*" parse-c-type c-type eq? ] unit-test
[ t ] [ void* c-type MyInt resolve-pointer-type c-type eq? ] unit-test
TYPEDEF: char MyChar
[ t ] [ char c-type MyChar c-type eq? ] unit-test
[ f ] [ void* c-type "MyChar*" parse-c-type c-type eq? ] unit-test
[ t ] [ "char*" parse-c-type c-type "MyChar*" parse-c-type c-type eq? ] unit-test
[ f ] [ void* c-type MyChar resolve-pointer-type c-type eq? ] unit-test
[ t ] [ char* c-type MyChar resolve-pointer-type c-type eq? ] unit-test
[ 32 ] [ { int 8 } heap-size ] unit-test
TYPEDEF: char* MyString
[ t ] [ char* c-type MyString c-type eq? ] unit-test
[ t ] [ void* c-type "MyString*" parse-c-type c-type eq? ] unit-test
[ t ] [ void* c-type MyString resolve-pointer-type c-type eq? ] unit-test
TYPEDEF: int* MyIntArray
@ -59,3 +59,44 @@ os windows? cpu x86.64? and [
[ -10 ] [ -10 char c-type-clamp ] unit-test
[ 127 ] [ 230 char c-type-clamp ] unit-test
[ t ] [ pi dup float c-type-clamp = ] unit-test
C-TYPE: opaque
[ t ] [ void* c-type opaque resolve-pointer-type c-type eq? ] unit-test
[ opaque c-type ] [ no-c-type? ] must-fail-with
[ """
USING: alien.syntax ;
IN: alien.c-types.tests
FUNCTION: opaque return_opaque ( ) ;
""" eval( -- ) ] [ no-c-type? ] must-fail-with
C-TYPE: forward
STRUCT: backward { x forward* } ;
STRUCT: forward { x backward* } ;
[ t ] [ forward c-type struct-c-type? ] unit-test
[ t ] [ backward c-type struct-c-type? ] unit-test
DEFER: struct-redefined
[ f ]
[
"""
USING: alien.c-types classes.struct ;
IN: alien.c-types.tests
STRUCT: struct-redefined { x int } ;
""" eval( -- )
"""
USING: alien.syntax ;
IN: alien.c-types.tests
C-TYPE: struct-redefined
""" eval( -- )
\ struct-redefined class?
] unit-test

View File

@ -53,7 +53,7 @@ ERROR: no-c-type name ;
PREDICATE: c-type-word < word
"c-type" word-prop ;
UNION: c-type-name string word ;
UNION: c-type-name string c-type-word ;
! C type protocol
GENERIC: c-type ( name -- c-type ) foldable
@ -62,6 +62,9 @@ GENERIC: resolve-pointer-type ( name -- c-type )
<< \ void \ void* "pointer-c-type" set-word-prop >>
: void? ( c-type -- ? )
{ void "void" } member? ;
M: word resolve-pointer-type
dup "pointer-c-type" word-prop
[ ] [ drop void* ] ?if ;
@ -75,6 +78,7 @@ M: string resolve-pointer-type
] if ;
: resolve-typedef ( name -- c-type )
dup void? [ no-c-type ] when
dup c-type-name? [ c-type ] when ;
: parse-array-type ( name -- dims c-type )
@ -91,10 +95,8 @@ M: string c-type ( name -- c-type )
] if ;
M: word c-type
"c-type" word-prop resolve-typedef ;
: void? ( c-type -- ? )
{ void "void" } member? ;
dup "c-type" word-prop resolve-typedef
[ ] [ no-c-type ] ?if ;
GENERIC: c-struct? ( c-type -- ? )
@ -310,7 +312,7 @@ CONSTANT: primitive-types
}
SYMBOLS:
ptrdiff_t intptr_t size_t
ptrdiff_t intptr_t uintptr_t size_t
char* uchar* ;
[
@ -471,9 +473,10 @@ SYMBOLS:
[ >float ] >>unboxer-quot
\ double define-primitive-type
\ long \ ptrdiff_t typedef
\ long \ intptr_t typedef
\ ulong \ size_t typedef
\ long c-type \ ptrdiff_t typedef
\ long c-type \ intptr_t typedef
\ ulong c-type \ uintptr_t typedef
\ ulong c-type \ size_t typedef
] with-compilation-unit
M: char-16-rep rep-component-type drop char ;

View File

@ -1,22 +1,22 @@
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types arrays assocs
combinators combinators.short-circuit effects grouping
kernel parser sequences splitting words fry locals lexer
namespaces summary math vocabs.parser ;
USING: accessors alien alien.c-types arrays assocs classes
combinators combinators.short-circuit compiler.units effects
grouping kernel parser sequences splitting words fry locals
lexer namespaces summary math vocabs.parser ;
IN: alien.parser
: parse-c-type-name ( name -- word/string )
[ search ] keep or ;
: parse-c-type-name ( name -- word )
dup search [ nip ] [ no-word ] if* ;
: parse-c-type ( string -- array )
{
{ [ dup "void" = ] [ drop void ] }
{ [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] }
{ [ dup search c-type-word? ] [ parse-c-type-name ] }
{ [ dup c-types get at ] [ ] }
{ [ "**" ?tail ] [ drop void* ] }
{ [ "*" ?tail ] [ parse-c-type-name resolve-pointer-type ] }
[ no-c-type ]
[ parse-c-type-name no-c-type ]
} cond ;
: scan-c-type ( -- c-type )
@ -25,10 +25,17 @@ IN: alien.parser
[ parse-c-type ] if ;
: reset-c-type ( word -- )
dup "struct-size" word-prop
[ dup [ forget-class ] [ { "struct-size" } reset-props ] bi ] when
{ "c-type" "pointer-c-type" "callback-effect" "callback-abi" } reset-props ;
: CREATE-C-TYPE ( -- word )
scan current-vocab create dup reset-c-type ;
scan current-vocab create {
[ fake-definition ]
[ set-word ]
[ reset-c-type ]
[ ]
} cleave ;
: normalize-c-arg ( type name -- type' name' )
[ length ]

View File

@ -1,5 +1,5 @@
IN: alien.syntax
USING: alien alien.c-types alien.parser classes.struct help.markup help.syntax ;
USING: alien alien.c-types alien.parser classes.struct help.markup help.syntax see ;
HELP: DLL"
{ $syntax "DLL\" path\"" }
@ -65,6 +65,16 @@ HELP: C-ENUM:
{ $code "CONSTANT: red 0" "CONSTANT: green 1" "CONSTANT: blue 2" }
} ;
HELP: C-TYPE:
{ $syntax "C-TYPE: type" }
{ $values { "type" "a new C type" } }
{ $description "Defines a new, opaque C type. Since it is opaque, " { $snippet "type" } " will not be directly usable as a parameter or return type of a " { $link POSTPONE: FUNCTION: } " or as a slot of a " { $link POSTPONE: STRUCT: } ". However, it can be used as the type of a pointer (that is, as " { $snippet "type*" } ")." $nl
{ $snippet "C-TYPE:" } " can also be used to forward-declare C types to enable circular dependencies. For example:"
{ $code """C-TYPE: forward
STRUCT: backward { x forward* } ;
STRUCT: forward { x backward* } ; """ } }
{ $notes "Primitive C types are also displayed using " { $snippet "C-TYPE:" } " syntax when they are displayed by " { $link see } "." } ;
HELP: CALLBACK:
{ $syntax "CALLBACK: return type ( parameters ) ;" }
{ $values { "return" "a C return type" } { "type" "a type name" } { "parameters" "a comma-separated sequence of type/name pairs; " { $snippet "type1 arg1, type2 arg2, ..." } } }

View File

@ -32,7 +32,7 @@ SYNTAX: C-ENUM:
[ [ create-in ] dip define-constant ] each-index ;
SYNTAX: C-TYPE:
"Primitive C type definition not supported" throw ;
void CREATE-C-TYPE typedef ;
ERROR: no-such-symbol name library ;

View File

@ -8,8 +8,8 @@ SPECIALIZED-ARRAY: void*
TYPEDEF: void* CFDictionaryRef
TYPEDEF: void* CFMutableDictionaryRef
TYPEDEF: void* CFDictionaryKeyCallBacks*
TYPEDEF: void* CFDictionaryValueCallBacks*
C-TYPE: CFDictionaryKeyCallBacks
C-TYPE: CFDictionaryValueCallBacks
FUNCTION: CFDictionaryRef CFDictionaryCreate (
CFAllocatorRef allocator,

View File

@ -6,7 +6,7 @@ IN: core-foundation.file-descriptors
TYPEDEF: void* CFFileDescriptorRef
TYPEDEF: int CFFileDescriptorNativeDescriptor
TYPEDEF: void* CFFileDescriptorCallBack
TYPEDEF: void* CFFileDescriptorContext*
C-TYPE: CFFileDescriptorContext
FUNCTION: CFFileDescriptorRef CFFileDescriptorCreate (
CFAllocatorRef allocator,

View File

@ -59,18 +59,18 @@ TYPEDEF: int PostgresPollingStatusType
TYPEDEF: int PGTransactionStatusType
TYPEDEF: int PGVerbosity
TYPEDEF: void* PGconn*
TYPEDEF: void* PGresult*
TYPEDEF: void* PGcancel*
C-TYPE: PGconn
C-TYPE: PGresult
C-TYPE: PGcancel
TYPEDEF: uint Oid
TYPEDEF: uint* Oid*
TYPEDEF: char pqbool
TYPEDEF: void* PQconninfoOption*
TYPEDEF: void* PGnotify*
TYPEDEF: void* PQArgBlock*
TYPEDEF: void* PQprintOpt*
TYPEDEF: void* SSL*
TYPEDEF: void* FILE*
C-TYPE: PQconninfoOption
C-TYPE: PGnotify
C-TYPE: PQArgBlock
C-TYPE: PQprintOpt
C-TYPE: SSL
C-TYPE: FILE
LIBRARY: postgresql

View File

@ -1,6 +1,6 @@
USING: accessors alien.syntax arrays assocs biassocs
classes.struct combinators kernel literals math math.bitwise
math.floats.env math.floats.env.private system ;
USING: accessors alien.c-types alien.syntax arrays assocs
biassocs classes.struct combinators kernel literals math
math.bitwise math.floats.env math.floats.env.private system ;
IN: math.floats.env.ppc
STRUCT: ppc-fpu-env

View File

@ -104,7 +104,7 @@ FUNCTION: void* BIO_f_buffer ( ) ;
CONSTANT: EVP_MAX_MD_SIZE 64
TYPEDEF: void* EVP_MD*
TYPEDEF: void* ENGINE*
C-TYPE: ENGINE
STRUCT: EVP_MD_CTX
{ digest EVP_MD* }

View File

@ -91,7 +91,7 @@ CONSTANT: SSL_ERROR_WANT_ACCEPT 8
TYPEDEF: void* ssl-method
TYPEDEF: void* SSL_CTX*
TYPEDEF: void* SSL_SESSION*
TYPEDEF: void* SSL*
C-TYPE: SSL
LIBRARY: libssl
@ -101,7 +101,7 @@ LIBRARY: libssl
TYPEDEF: void* X509_NAME*
TYPEDEF: void* X509*
C-TYPE: X509
FUNCTION: int X509_NAME_get_text_by_NID ( X509_NAME* name, int nid, void* buf, int len ) ;
FUNCTION: X509_NAME* X509_get_subject_name ( X509* a ) ;

View File

@ -19,8 +19,8 @@ IN: pango.cairo
LIBRARY: pangocairo
TYPEDEF: void* PangoCairoFontMap*
TYPEDEF: void* PangoCairoFont*
C-TYPE: PangoCairoFontMap
C-TYPE: PangoCairoFont
FUNCTION: PangoFontMap*
pango_cairo_font_map_new ( ) ;

View File

@ -15,14 +15,14 @@ PANGO_STYLE_OBLIQUE
PANGO_STYLE_ITALIC ;
TYPEDEF: int PangoWeight
TYPEDEF: void* PangoFont*
TYPEDEF: void* PangoFontFamily*
TYPEDEF: void* PangoFontFace*
TYPEDEF: void* PangoFontMap*
TYPEDEF: void* PangoFontMetrics*
TYPEDEF: void* PangoFontDescription*
TYPEDEF: void* PangoGlyphString*
TYPEDEF: void* PangoLanguage*
C-TYPE: PangoFont
C-TYPE: PangoFontFamily
C-TYPE: PangoFontFace
C-TYPE: PangoFontMap
C-TYPE: PangoFontMetrics
C-TYPE: PangoFontDescription
C-TYPE: PangoGlyphString
C-TYPE: PangoLanguage
CONSTANT: PANGO_WEIGHT_THIN 100
CONSTANT: PANGO_WEIGHT_ULTRALIGHT 200

View File

@ -10,9 +10,9 @@ IN: pango.layouts
LIBRARY: pango
TYPEDEF: void* PangoLayout*
TYPEDEF: void* PangoLayoutIter*
TYPEDEF: void* PangoLayoutLine*
C-TYPE: PangoLayout
C-TYPE: PangoLayoutIter
C-TYPE: PangoLayoutLine
FUNCTION: PangoLayout*
pango_layout_new ( PangoContext* context ) ;

View File

@ -23,7 +23,7 @@ CONSTANT: PANGO_SCALE 1024
: pango>float ( n -- x ) PANGO_SCALE /f ; inline
: float>pango ( x -- n ) PANGO_SCALE * >integer ; inline
TYPEDEF: void* PangoContext*
C-TYPE: PangoContext
FUNCTION: PangoContext* pango_context_new ( ) ;

View File

@ -1,4 +1,4 @@
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix
CONSTANT: FD_SETSIZE 1024

View File

@ -1,5 +1,5 @@
USING: alien.syntax alien.c-types math vocabs.loader
classes.struct ;
classes.struct unix.types ;
IN: unix
CONSTANT: FD_SETSIZE 256

View File

@ -1,4 +1,4 @@
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix
CONSTANT: FD_SETSIZE 1024

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
USING: alien.c-types alien.syntax unix.statfs.freebsd ;
IN: unix.getfsstat.freebsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
USING: alien.c-types alien.syntax unix.statvfs.netbsd ;
IN: unix.getfsstat.netbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete
CONSTANT: MNT_NOWAIT 2 ! start all I/O, but do not wait for it
CONSTANT: MNT_LAZY 3 ! push data not written by filesystem syncer
FUNCTION: int getvfsstat ( statfs* buf, int bufsize, int flags ) ;
FUNCTION: int getvfsstat ( statvfs* buf, int bufsize, int flags ) ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
USING: alien.c-types alien.syntax unix.statfs.openbsd ;
IN: unix.getfsstat.openbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete

View File

@ -1,4 +1,4 @@
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.time ;
IN: unix.kqueue
STRUCT: kevent

View File

@ -1,4 +1,4 @@
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.time ;
IN: unix.kqueue
STRUCT: kevent

View File

@ -1,4 +1,4 @@
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.time ;
IN: unix.kqueue
STRUCT: kevent

View File

@ -1,6 +1,7 @@
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax alien system classes.struct ;
USING: alien.c-types alien.syntax alien system classes.struct
unix.types ;
IN: unix
! Linux.

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006 Patrick Mauritz.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax system kernel layouts ;
USING: alien.c-types alien.syntax system kernel layouts ;
IN: unix
! Solaris.

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! FreeBSD 8.0-CURRENT

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! stat64

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! Ubuntu 7.10 64-bit

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! NetBSD 4.0

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! NetBSD 4.0

View File

@ -1,4 +1,5 @@
USING: kernel alien.syntax math classes.struct ;
USING: kernel alien.c-types alien.syntax math classes.struct
unix.time unix.types ;
IN: unix.stat
! OpenBSD 4.2

View File

@ -27,8 +27,8 @@ STRUCT: statfs
{ f_owner uid_t }
{ f_fsid fsid_t }
{ f_charspare char[80] }
{ f_fstypename { "char" MFSNAMELEN } }
{ f_mntfromname { "char" MNAMELEN } }
{ f_mntonname { "char" MNAMELEN } } ;
{ f_fstypename { char MFSNAMELEN } }
{ f_mntfromname { char MNAMELEN } }
{ f_mntonname { char MNAMELEN } } ;
FUNCTION: int statfs ( char* path, statvfs* buf ) ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax unix.types unix.stat classes.struct ;
USING: alien.c-types alien.syntax unix.types unix.stat classes.struct ;
IN: unix.statfs.linux
STRUCT: statfs64

View File

@ -111,9 +111,9 @@ STRUCT: statfs64
{ f_type uint32_t }
{ f_flags uint32_t }
{ f_fssubtype uint32_t }
{ f_fstypename { "char" MFSTYPENAMELEN } }
{ f_mntonname { "char" MAXPATHLEN } }
{ f_mntfromname { "char" MAXPATHLEN } }
{ f_fstypename { char MFSTYPENAMELEN } }
{ f_mntonname { char MAXPATHLEN } }
{ f_mntfromname { char MAXPATHLEN } }
{ f_reserved uint32_t[8] } ;
FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax unix.types unix.stat classes.struct ;
USING: alien.c-types alien.syntax unix.types unix.stat classes.struct ;
IN: unix.statfs.openbsd
CONSTANT: MFSNAMELEN 16
@ -25,9 +25,9 @@ STRUCT: statfs
{ f_owner uid_t }
{ f_ctime u_int32_t }
{ f_spare u_int32_t[3] }
{ f_fstypename { "char" MFSNAMELEN } }
{ f_mntonname { "char" MNAMELEN } }
{ f_mntfromname { "char" MNAMELEN } }
{ f_fstypename { char MFSNAMELEN } }
{ f_mntonname { char MNAMELEN } }
{ f_mntfromname { char MNAMELEN } }
{ mount_info char[160] } ;
FUNCTION: int statfs ( char* path, statvfs* buf ) ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix.statvfs.freebsd
STRUCT: statvfs

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix.statvfs.linux
STRUCT: statvfs64

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix.statvfs.netbsd
CONSTANT: _VFS_NAMELEN 32

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax classes.struct ;
USING: alien.c-types alien.syntax classes.struct unix.types ;
IN: unix.statvfs.openbsd
STRUCT: statvfs

View File

@ -37,11 +37,11 @@ TYPEDEF: fsfilcnt_t __fsfilcnt_t
TYPEDEF: __uint64_t rlim_t
TYPEDEF: uint32_t id_t
TYPEDEF: void* DIR*
TYPEDEF: void* FILE*
TYPEDEF: void* rlimit*
TYPEDEF: void* rusage*
TYPEDEF: void* sockaddr*
C-TYPE: DIR
C-TYPE: FILE
C-TYPE: rlimit
C-TYPE: rusage
C-TYPE: sockaddr
os {
{ linux [ "unix.types.linux" require ] }

View File

@ -62,6 +62,8 @@ MACRO:: unix-system-call ( quot -- )
]
] ;
HOOK: open-file os ( path flags mode -- fd )
<<
{
@ -155,8 +157,6 @@ FUNCTION: int shutdown ( int fd, int how ) ;
FUNCTION: int open ( char* path, int flags, int prot ) ;
HOOK: open-file os ( path flags mode -- fd )
M: unix open-file [ open ] unix-system-call ;
FUNCTION: DIR* opendir ( char* path ) ;

View File

@ -4,7 +4,7 @@ USING: classes.struct alien.c-types alien.syntax ;
IN: vm
TYPEDEF: void* cell
TYPEDEF: void* context*
C-TYPE: context
STRUCT: zone
{ start cell }

View File

@ -10,7 +10,7 @@ COM-INTERFACE: IUnknown f {00000000-0000-0000-C000-000000000046}
ULONG AddRef ( )
ULONG Release ( ) ;
TYPEDEF: void* IAdviseSink*
C-TYPE: IAdviseSink
COM-INTERFACE: IDataObject IUnknown {0000010E-0000-0000-C000-000000000046}
HRESULT GetData ( FORMATETC* pFormatetc, STGMEDIUM* pmedium )

View File

@ -58,7 +58,7 @@ STRUCT: SCRIPT_VISATTR
{ flags WORD } ;
TYPEDEF: void* SCRIPT_CACHE*
TYPEDEF: void* ABC*
C-TYPE: ABC
FUNCTION: HRESULT ScriptShape (
HDC hdc,

View File

@ -105,7 +105,7 @@ CONSTANT: SD_BOTH 2
CONSTANT: SOL_SOCKET HEX: ffff
TYPEDEF: void* sockaddr*
C-TYPE: sockaddr
STRUCT: sockaddr-in
{ family short }

View File

@ -31,12 +31,12 @@ TYPEDEF: XID KeySym
TYPEDEF: ulong Atom
TYPEDEF: char* XPointer
TYPEDEF: void* Screen*
C-TYPE: Screen
TYPEDEF: void* GC
TYPEDEF: void* Visual*
TYPEDEF: void* XExtData*
TYPEDEF: void* XFontProp*
TYPEDEF: void* XComposeStatus*
C-TYPE: Visual
C-TYPE: XExtData
C-TYPE: XFontProp
C-TYPE: XComposeStatus
TYPEDEF: void* XIM
TYPEDEF: void* XIC
@ -47,9 +47,6 @@ TYPEDEF: int Bool
TYPEDEF: ulong VisualID
TYPEDEF: ulong Time
TYPEDEF: void* Window**
TYPEDEF: void* Atom**
ALIAS: <XID> <ulong>
ALIAS: <Window> <XID>
ALIAS: <Drawable> <XID>

View File

@ -10,8 +10,8 @@ IN: curses.ffi
{ [ os unix? ] [ "libcurses.so" ] }
} cond "cdecl" add-library >>
TYPEDEF: void* WINDOW*
TYPEDEF: void* SCREEN*
C-TYPE: WINDOW
C-TYPE: SCREEN
TYPEDEF: void* va_list
TYPEDEF: uint chtype

View File

@ -38,8 +38,8 @@ TYPEDEF: long FT_F26Dot6
FUNCTION: FT_Error FT_Init_FreeType ( void* library ) ;
! circular reference between glyph and face
TYPEDEF: void* face*
TYPEDEF: void* glyph*
C-TYPE: face
C-TYPE: glyph
STRUCT: glyph
{ library void* }

View File

@ -17,10 +17,10 @@ os {
LIBRARY: glu
! These are defined as structs in glu.h, but we only ever use pointers to them
TYPEDEF: void* GLUnurbs*
TYPEDEF: void* GLUquadric*
TYPEDEF: void* GLUtesselator*
TYPEDEF: void* GLubyte*
C-TYPE: GLUnurbs
C-TYPE: GLUquadric
C-TYPE: GLUtesselator
C-TYPE: GLubyte
TYPEDEF: void* GLUfuncptr
! StringName

View File

@ -6,8 +6,8 @@ IN: tokyo.alien.tchdb
LIBRARY: tokyocabinet
TYPEDEF: void* TCXSTR*
TYPEDEF: void* TCHDB*
C-TYPE: TCXSTR
C-TYPE: TCHDB
CONSTANT: HDBFOPEN 1
CONSTANT: HDBFFATAL 2

View File

@ -13,7 +13,7 @@ IN: tokyo.alien.tcrdb
LIBRARY: tokyotyrant
TYPEDEF: void* TCRDB*
C-TYPE: TCRDB
! STRUCT: TCRDB
! { mmtx pthread_mutex_t }
! { eckey pthread_key_t }
@ -95,7 +95,7 @@ CONSTANT: RDBITOPT TDBITOPT
CONSTANT: RDBITVOID TDBITVOID
CONSTANT: RDBITKEEP TDBITKEEP
TYPEDEF: void* RDBQRY*
C-TYPE: RDBQRY
! STRUCT: RDBQRY
! { rdb TCRDB* }
! { args TCLIST* } ;

View File

@ -6,9 +6,9 @@ IN: tokyo.alien.tctdb
LIBRARY: tokyocabinet
TYPEDEF: void* TDBIDX*
TYPEDEF: void* TCTDB*
TYPEDEF: void* TCMAP*
C-TYPE: TDBIDX
C-TYPE: TCTDB
C-TYPE: TCMAP
CONSTANT: TDBFOPEN HDBFOPEN
CONSTANT: TDBFFATAL HDBFFATAL
@ -35,8 +35,8 @@ CONSTANT: TDBITOPT 9998
CONSTANT: TDBITVOID 9999
CONSTANT: TDBITKEEP 16777216
TYPEDEF: void* TDBCOND*
TYPEDEF: void* TDBQRY*
C-TYPE: TDBCOND
C-TYPE: TDBQRY
C-ENUM:
TDBQCSTREQ

View File

@ -21,7 +21,7 @@ C-ENUM:
! FIXME: on windows 64bits this isn't correct, because long is 32bits there, and time_t is int64
TYPEDEF: long tokyo_time_t
TYPEDEF: void* TCLIST*
C-TYPE: TCLIST
FUNCTION: TCLIST* tclistnew ( ) ;
FUNCTION: TCLIST* tclistnew2 ( int anum ) ;

View File

@ -123,8 +123,9 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle
" LIBRARY:
"#\ "
syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline
syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline
syn region factorString start=/\<"/ skip=/\\"/ end=/"/
syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/
syn region factorSbuf start=/\<SBUF"\>/ skip=/\\"/ end=/"/
syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents
syn match factorMultiStringContents /.*/ contained
@ -201,6 +202,7 @@ if version >= 508 || !exists("did_factor_syn_inits")
HiLink factorPGenericDelims Special
HiLink factorPGenericNDelims Special
HiLink factorString String
HiLink factorTriString String
HiLink factorSbuf String
HiLink factorMultiStringContents String
HiLink factorMultiStringDelims Typedef

View File

@ -19,7 +19,7 @@ TYPEDEF: int SQLINTEGER
TYPEDEF: char SQLCHAR
TYPEDEF: char* SQLCHAR*
TYPEDEF: void* SQLHANDLE
TYPEDEF: void* SQLHANDLE*
C-TYPE: SQLHANDLE
TYPEDEF: void* SQLHENV
TYPEDEF: void* SQLHDBC
TYPEDEF: void* SQLHSTMT