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." } ; { $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 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." } ; { $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 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." } ; { $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 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." } ; { $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 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." } ; { $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 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* 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* 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." } ; { $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 HELP: float

View File

@ -1,6 +1,6 @@
USING: alien alien.syntax alien.c-types alien.parser USING: alien alien.syntax alien.c-types alien.parser
kernel tools.test sequences system libc alien.strings eval kernel tools.test sequences system libc alien.strings
io.encodings.utf8 math.constants classes.struct ; io.encodings.utf8 math.constants classes.struct classes ;
IN: alien.c-types.tests IN: alien.c-types.tests
CONSTANT: xyz 123 CONSTANT: xyz 123
@ -15,28 +15,28 @@ UNION-STRUCT: foo
{ a int } { a int }
{ b int } ; { b int } ;
[ f ] [ "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**" parse-c-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 [ t ] [ foo heap-size int heap-size = ] unit-test
TYPEDEF: int MyInt TYPEDEF: int MyInt
[ t ] [ int c-type MyInt c-type eq? ] unit-test [ 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 TYPEDEF: char MyChar
[ t ] [ char c-type MyChar c-type eq? ] unit-test [ t ] [ char c-type MyChar c-type eq? ] unit-test
[ f ] [ void* 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*" parse-c-type c-type "MyChar*" parse-c-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 [ 32 ] [ { int 8 } heap-size ] unit-test
TYPEDEF: char* MyString TYPEDEF: char* MyString
[ t ] [ char* c-type MyString c-type eq? ] unit-test [ 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 TYPEDEF: int* MyIntArray
@ -59,3 +59,44 @@ os windows? cpu x86.64? and [
[ -10 ] [ -10 char c-type-clamp ] unit-test [ -10 ] [ -10 char c-type-clamp ] unit-test
[ 127 ] [ 230 char c-type-clamp ] unit-test [ 127 ] [ 230 char c-type-clamp ] unit-test
[ t ] [ pi dup float 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 PREDICATE: c-type-word < word
"c-type" word-prop ; "c-type" word-prop ;
UNION: c-type-name string word ; UNION: c-type-name string c-type-word ;
! C type protocol ! C type protocol
GENERIC: c-type ( name -- c-type ) foldable 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 \ void* "pointer-c-type" set-word-prop >>
: void? ( c-type -- ? )
{ void "void" } member? ;
M: word resolve-pointer-type M: word resolve-pointer-type
dup "pointer-c-type" word-prop dup "pointer-c-type" word-prop
[ ] [ drop void* ] ?if ; [ ] [ drop void* ] ?if ;
@ -75,6 +78,7 @@ M: string resolve-pointer-type
] if ; ] if ;
: resolve-typedef ( name -- c-type ) : resolve-typedef ( name -- c-type )
dup void? [ no-c-type ] when
dup c-type-name? [ c-type ] when ; dup c-type-name? [ c-type ] when ;
: parse-array-type ( name -- dims c-type ) : parse-array-type ( name -- dims c-type )
@ -91,10 +95,8 @@ M: string c-type ( name -- c-type )
] if ; ] if ;
M: word c-type M: word c-type
"c-type" word-prop resolve-typedef ; dup "c-type" word-prop resolve-typedef
[ ] [ no-c-type ] ?if ;
: void? ( c-type -- ? )
{ void "void" } member? ;
GENERIC: c-struct? ( c-type -- ? ) GENERIC: c-struct? ( c-type -- ? )
@ -310,7 +312,7 @@ CONSTANT: primitive-types
} }
SYMBOLS: SYMBOLS:
ptrdiff_t intptr_t size_t ptrdiff_t intptr_t uintptr_t size_t
char* uchar* ; char* uchar* ;
[ [
@ -471,9 +473,10 @@ SYMBOLS:
[ >float ] >>unboxer-quot [ >float ] >>unboxer-quot
\ double define-primitive-type \ double define-primitive-type
\ long \ ptrdiff_t typedef \ long c-type \ ptrdiff_t typedef
\ long \ intptr_t typedef \ long c-type \ intptr_t typedef
\ ulong \ size_t typedef \ ulong c-type \ uintptr_t typedef
\ ulong c-type \ size_t typedef
] with-compilation-unit ] with-compilation-unit
M: char-16-rep rep-component-type drop char ; M: char-16-rep rep-component-type drop char ;

View File

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

View File

@ -1,5 +1,5 @@
IN: alien.syntax 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" HELP: DLL"
{ $syntax "DLL\" path\"" } { $syntax "DLL\" path\"" }
@ -65,6 +65,16 @@ HELP: C-ENUM:
{ $code "CONSTANT: red 0" "CONSTANT: green 1" "CONSTANT: blue 2" } { $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: HELP: CALLBACK:
{ $syntax "CALLBACK: return type ( parameters ) ;" } { $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, ..." } } } { $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 ; [ [ create-in ] dip define-constant ] each-index ;
SYNTAX: C-TYPE: SYNTAX: C-TYPE:
"Primitive C type definition not supported" throw ; void CREATE-C-TYPE typedef ;
ERROR: no-such-symbol name library ; ERROR: no-such-symbol name library ;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ CONSTANT: SSL_ERROR_WANT_ACCEPT 8
TYPEDEF: void* ssl-method TYPEDEF: void* ssl-method
TYPEDEF: void* SSL_CTX* TYPEDEF: void* SSL_CTX*
TYPEDEF: void* SSL_SESSION* TYPEDEF: void* SSL_SESSION*
TYPEDEF: void* SSL* C-TYPE: SSL
LIBRARY: libssl LIBRARY: libssl
@ -101,7 +101,7 @@ LIBRARY: libssl
TYPEDEF: void* X509_NAME* 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: 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 ) ; FUNCTION: X509_NAME* X509_get_subject_name ( X509* a ) ;

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ CONSTANT: PANGO_SCALE 1024
: pango>float ( n -- x ) PANGO_SCALE /f ; inline : pango>float ( n -- x ) PANGO_SCALE /f ; inline
: float>pango ( x -- n ) PANGO_SCALE * >integer ; inline : float>pango ( x -- n ) PANGO_SCALE * >integer ; inline
TYPEDEF: void* PangoContext* C-TYPE: PangoContext
FUNCTION: PangoContext* pango_context_new ( ) ; 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 IN: unix
CONSTANT: FD_SETSIZE 1024 CONSTANT: FD_SETSIZE 1024

View File

@ -1,5 +1,5 @@
USING: alien.syntax alien.c-types math vocabs.loader USING: alien.syntax alien.c-types math vocabs.loader
classes.struct ; classes.struct unix.types ;
IN: unix IN: unix
CONSTANT: FD_SETSIZE 256 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 IN: unix
CONSTANT: FD_SETSIZE 1024 CONSTANT: FD_SETSIZE 1024

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.getfsstat.freebsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.getfsstat.netbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete 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_NOWAIT 2 ! start all I/O, but do not wait for it
CONSTANT: MNT_LAZY 3 ! push data not written by filesystem syncer 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. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.getfsstat.openbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete 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 IN: unix.kqueue
STRUCT: kevent 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 IN: unix.kqueue
STRUCT: kevent 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 IN: unix.kqueue
STRUCT: kevent STRUCT: kevent

View File

@ -1,6 +1,7 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix
! Linux. ! Linux.

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006 Patrick Mauritz. ! Copyright (C) 2006 Patrick Mauritz.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix
! Solaris. ! 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 IN: unix.stat
! FreeBSD 8.0-CURRENT ! 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 IN: unix.stat
! stat64 ! 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 IN: unix.stat
! Ubuntu 7.10 64-bit ! 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 IN: unix.stat
! NetBSD 4.0 ! 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 IN: unix.stat
! NetBSD 4.0 ! 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 IN: unix.stat
! OpenBSD 4.2 ! OpenBSD 4.2

View File

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

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.statfs.linux
STRUCT: statfs64 STRUCT: statfs64

View File

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

View File

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

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.statvfs.freebsd
STRUCT: statvfs STRUCT: statvfs

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.statvfs.linux
STRUCT: statvfs64 STRUCT: statvfs64

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.statvfs.netbsd
CONSTANT: _VFS_NAMELEN 32 CONSTANT: _VFS_NAMELEN 32

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: unix.statvfs.openbsd
STRUCT: statvfs STRUCT: statvfs

View File

@ -37,11 +37,11 @@ TYPEDEF: fsfilcnt_t __fsfilcnt_t
TYPEDEF: __uint64_t rlim_t TYPEDEF: __uint64_t rlim_t
TYPEDEF: uint32_t id_t TYPEDEF: uint32_t id_t
TYPEDEF: void* DIR* C-TYPE: DIR
TYPEDEF: void* FILE* C-TYPE: FILE
TYPEDEF: void* rlimit* C-TYPE: rlimit
TYPEDEF: void* rusage* C-TYPE: rusage
TYPEDEF: void* sockaddr* C-TYPE: sockaddr
os { os {
{ linux [ "unix.types.linux" require ] } { 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 ) ; 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 ; M: unix open-file [ open ] unix-system-call ;
FUNCTION: DIR* opendir ( char* path ) ; FUNCTION: DIR* opendir ( char* path ) ;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,9 +6,9 @@ IN: tokyo.alien.tctdb
LIBRARY: tokyocabinet LIBRARY: tokyocabinet
TYPEDEF: void* TDBIDX* C-TYPE: TDBIDX
TYPEDEF: void* TCTDB* C-TYPE: TCTDB
TYPEDEF: void* TCMAP* C-TYPE: TCMAP
CONSTANT: TDBFOPEN HDBFOPEN CONSTANT: TDBFOPEN HDBFOPEN
CONSTANT: TDBFFATAL HDBFFATAL CONSTANT: TDBFFATAL HDBFFATAL
@ -35,8 +35,8 @@ CONSTANT: TDBITOPT 9998
CONSTANT: TDBITVOID 9999 CONSTANT: TDBITVOID 9999
CONSTANT: TDBITKEEP 16777216 CONSTANT: TDBITKEEP 16777216
TYPEDEF: void* TDBCOND* C-TYPE: TDBCOND
TYPEDEF: void* TDBQRY* C-TYPE: TDBQRY
C-ENUM: C-ENUM:
TDBQCSTREQ 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 ! FIXME: on windows 64bits this isn't correct, because long is 32bits there, and time_t is int64
TYPEDEF: long tokyo_time_t TYPEDEF: long tokyo_time_t
TYPEDEF: void* TCLIST* C-TYPE: TCLIST
FUNCTION: TCLIST* tclistnew ( ) ; FUNCTION: TCLIST* tclistnew ( ) ;
FUNCTION: TCLIST* tclistnew2 ( int anum ) ; FUNCTION: TCLIST* tclistnew2 ( int anum ) ;

View File

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

View File

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