From: Joe Groff Date: Mon, 28 Sep 2009 03:21:42 +0000 (-0500) Subject: Merge branch 'master' of git://factorcode.org/git/factor X-Git-Tag: 0.97~5462^2~1 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=a14855b98a8e87d7edcb5ddf72f4494880525292;hp=d3aa0a538b2d843318517e7a6d54b803fef82ccc Merge branch 'master' of git://factorcode.org/git/factor --- diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index 4f70836737..eb4be08764 100755 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -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 diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index f48ed50a34..d134d57189 100755 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -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 ] [ int c-type MyInt 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 +[ t ] [ char c-type MyChar 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 ] [ char* c-type MyString 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 + diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index ab1c9df77e..dec7f92501 100755 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -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 ; diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index d58f9a315c..89e83a1d9b 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -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 ] diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index e04f6a471d..dbfc067bc6 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -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, ..." } } } diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index 85b763ba51..e27a5ef122 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -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 ; diff --git a/basis/core-foundation/dictionaries/dictionaries.factor b/basis/core-foundation/dictionaries/dictionaries.factor index 04b5aacb39..fc0e98a215 100644 --- a/basis/core-foundation/dictionaries/dictionaries.factor +++ b/basis/core-foundation/dictionaries/dictionaries.factor @@ -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, diff --git a/basis/core-foundation/file-descriptors/file-descriptors.factor b/basis/core-foundation/file-descriptors/file-descriptors.factor index 2520f1c3da..ec5581d463 100644 --- a/basis/core-foundation/file-descriptors/file-descriptors.factor +++ b/basis/core-foundation/file-descriptors/file-descriptors.factor @@ -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, diff --git a/basis/db/postgresql/ffi/ffi.factor b/basis/db/postgresql/ffi/ffi.factor index 88618c6212..f4a55e3280 100644 --- a/basis/db/postgresql/ffi/ffi.factor +++ b/basis/db/postgresql/ffi/ffi.factor @@ -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 diff --git a/basis/math/floats/env/ppc/ppc.factor b/basis/math/floats/env/ppc/ppc.factor index d6a6ae6834..f635a2a0f1 100644 --- a/basis/math/floats/env/ppc/ppc.factor +++ b/basis/math/floats/env/ppc/ppc.factor @@ -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 diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index ed280ecd69..dbc5b9e43c 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -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* } diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index 9e2b13159a..225d4b3da1 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -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 ) ; diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor index 2ad730ee6e..6fd8d57893 100644 --- a/basis/pango/cairo/cairo.factor +++ b/basis/pango/cairo/cairo.factor @@ -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 ( ) ; diff --git a/basis/pango/fonts/fonts.factor b/basis/pango/fonts/fonts.factor index eb3e2208b1..280ddd20d6 100644 --- a/basis/pango/fonts/fonts.factor +++ b/basis/pango/fonts/fonts.factor @@ -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 diff --git a/basis/pango/layouts/layouts.factor b/basis/pango/layouts/layouts.factor index a03d26fb67..74b6d0b0c3 100644 --- a/basis/pango/layouts/layouts.factor +++ b/basis/pango/layouts/layouts.factor @@ -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 ) ; diff --git a/basis/pango/pango.factor b/basis/pango/pango.factor index 03134ed787..6dc48e39fe 100644 --- a/basis/pango/pango.factor +++ b/basis/pango/pango.factor @@ -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 ( ) ; diff --git a/basis/unix/getfsstat/freebsd/freebsd.factor b/basis/unix/getfsstat/freebsd/freebsd.factor index 44d85680a7..fefd316fdb 100644 --- a/basis/unix/getfsstat/freebsd/freebsd.factor +++ b/basis/unix/getfsstat/freebsd/freebsd.factor @@ -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 diff --git a/basis/unix/getfsstat/netbsd/netbsd.factor b/basis/unix/getfsstat/netbsd/netbsd.factor index 1eca6d7dc3..cdad20e4b5 100644 --- a/basis/unix/getfsstat/netbsd/netbsd.factor +++ b/basis/unix/getfsstat/netbsd/netbsd.factor @@ -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 ) ; diff --git a/basis/unix/getfsstat/openbsd/openbsd.factor b/basis/unix/getfsstat/openbsd/openbsd.factor index 19465d8040..07b45f5df5 100644 --- a/basis/unix/getfsstat/openbsd/openbsd.factor +++ b/basis/unix/getfsstat/openbsd/openbsd.factor @@ -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 diff --git a/basis/unix/kqueue/freebsd/freebsd.factor b/basis/unix/kqueue/freebsd/freebsd.factor index 4bf5af8482..54f576ffc1 100644 --- a/basis/unix/kqueue/freebsd/freebsd.factor +++ b/basis/unix/kqueue/freebsd/freebsd.factor @@ -1,4 +1,4 @@ -USING: alien.syntax classes.struct ; +USING: alien.c-types alien.syntax classes.struct unix.time ; IN: unix.kqueue STRUCT: kevent diff --git a/basis/unix/kqueue/netbsd/netbsd.factor b/basis/unix/kqueue/netbsd/netbsd.factor index d9a9116930..9ba6202585 100644 --- a/basis/unix/kqueue/netbsd/netbsd.factor +++ b/basis/unix/kqueue/netbsd/netbsd.factor @@ -1,4 +1,4 @@ -USING: alien.syntax classes.struct ; +USING: alien.c-types alien.syntax classes.struct unix.time ; IN: unix.kqueue STRUCT: kevent diff --git a/basis/unix/kqueue/openbsd/openbsd.factor b/basis/unix/kqueue/openbsd/openbsd.factor index 1d851c8d68..ab680345b6 100644 --- a/basis/unix/kqueue/openbsd/openbsd.factor +++ b/basis/unix/kqueue/openbsd/openbsd.factor @@ -1,4 +1,4 @@ -USING: alien.syntax classes.struct ; +USING: alien.c-types alien.syntax classes.struct unix.time ; IN: unix.kqueue STRUCT: kevent diff --git a/basis/unix/linux/linux.factor b/basis/unix/linux/linux.factor index 48044c731c..1ff5401116 100644 --- a/basis/unix/linux/linux.factor +++ b/basis/unix/linux/linux.factor @@ -1,6 +1,6 @@ ! 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 ; IN: unix ! Linux. diff --git a/basis/unix/solaris/solaris.factor b/basis/unix/solaris/solaris.factor index b7ea3f172e..1a1a7603f0 100644 --- a/basis/unix/solaris/solaris.factor +++ b/basis/unix/solaris/solaris.factor @@ -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. diff --git a/basis/unix/stat/freebsd/freebsd.factor b/basis/unix/stat/freebsd/freebsd.factor index 0acf2512e8..04f884e496 100644 --- a/basis/unix/stat/freebsd/freebsd.factor +++ b/basis/unix/stat/freebsd/freebsd.factor @@ -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 diff --git a/basis/unix/stat/linux/32/32.factor b/basis/unix/stat/linux/32/32.factor index 324237d645..f01140ff4b 100644 --- a/basis/unix/stat/linux/32/32.factor +++ b/basis/unix/stat/linux/32/32.factor @@ -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 diff --git a/basis/unix/stat/linux/64/64.factor b/basis/unix/stat/linux/64/64.factor index cfd6553ca3..bb16133c76 100644 --- a/basis/unix/stat/linux/64/64.factor +++ b/basis/unix/stat/linux/64/64.factor @@ -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 diff --git a/basis/unix/stat/netbsd/32/32.factor b/basis/unix/stat/netbsd/32/32.factor index 98403313b8..fb0d61b7e9 100644 --- a/basis/unix/stat/netbsd/32/32.factor +++ b/basis/unix/stat/netbsd/32/32.factor @@ -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 diff --git a/basis/unix/stat/netbsd/64/64.factor b/basis/unix/stat/netbsd/64/64.factor index c532e7e9ff..47c4e0c129 100644 --- a/basis/unix/stat/netbsd/64/64.factor +++ b/basis/unix/stat/netbsd/64/64.factor @@ -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 diff --git a/basis/unix/stat/openbsd/openbsd.factor b/basis/unix/stat/openbsd/openbsd.factor index 5bf950fd4b..2702e60f6c 100644 --- a/basis/unix/stat/openbsd/openbsd.factor +++ b/basis/unix/stat/openbsd/openbsd.factor @@ -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 diff --git a/basis/unix/statfs/freebsd/freebsd.factor b/basis/unix/statfs/freebsd/freebsd.factor index f8c8257a4e..c9271ff007 100644 --- a/basis/unix/statfs/freebsd/freebsd.factor +++ b/basis/unix/statfs/freebsd/freebsd.factor @@ -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 ) ; diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor index 42d66ff1ba..ab37ab9605 100644 --- a/basis/unix/statfs/linux/linux.factor +++ b/basis/unix/statfs/linux/linux.factor @@ -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 diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index 38709f64fe..e83d2d40a0 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -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 ) ; diff --git a/basis/unix/statfs/openbsd/openbsd.factor b/basis/unix/statfs/openbsd/openbsd.factor index 590faf82a6..cd720d74d4 100644 --- a/basis/unix/statfs/openbsd/openbsd.factor +++ b/basis/unix/statfs/openbsd/openbsd.factor @@ -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 ) ; diff --git a/basis/unix/statvfs/freebsd/freebsd.factor b/basis/unix/statvfs/freebsd/freebsd.factor index 2fcd0c7372..c2834736b7 100644 --- a/basis/unix/statvfs/freebsd/freebsd.factor +++ b/basis/unix/statvfs/freebsd/freebsd.factor @@ -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 diff --git a/basis/unix/statvfs/linux/linux.factor b/basis/unix/statvfs/linux/linux.factor index 6e408c8fa4..d7139d84b2 100644 --- a/basis/unix/statvfs/linux/linux.factor +++ b/basis/unix/statvfs/linux/linux.factor @@ -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 diff --git a/basis/unix/statvfs/netbsd/netbsd.factor b/basis/unix/statvfs/netbsd/netbsd.factor index 25c96dc15d..c72a1a0e82 100644 --- a/basis/unix/statvfs/netbsd/netbsd.factor +++ b/basis/unix/statvfs/netbsd/netbsd.factor @@ -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 diff --git a/basis/unix/statvfs/openbsd/openbsd.factor b/basis/unix/statvfs/openbsd/openbsd.factor index f2d12c29cc..d5b2ee30a8 100644 --- a/basis/unix/statvfs/openbsd/openbsd.factor +++ b/basis/unix/statvfs/openbsd/openbsd.factor @@ -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 diff --git a/basis/unix/types/types.factor b/basis/unix/types/types.factor index 6fdaeef8cf..7650e9962f 100644 --- a/basis/unix/types/types.factor +++ b/basis/unix/types/types.factor @@ -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 ] } diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index fa61e9041a..afe24905d6 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -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 ) ; diff --git a/basis/vm/vm.factor b/basis/vm/vm.factor index 728cbb83d8..11d9dabb3d 100644 --- a/basis/vm/vm.factor +++ b/basis/vm/vm.factor @@ -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 } diff --git a/basis/windows/com/com.factor b/basis/windows/com/com.factor index 45a74e2250..9628b890fb 100755 --- a/basis/windows/com/com.factor +++ b/basis/windows/com/com.factor @@ -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 ) diff --git a/basis/windows/usp10/usp10.factor b/basis/windows/usp10/usp10.factor index f021b55289..57702d8780 100755 --- a/basis/windows/usp10/usp10.factor +++ b/basis/windows/usp10/usp10.factor @@ -58,7 +58,7 @@ STRUCT: SCRIPT_VISATTR { flags WORD } ; TYPEDEF: void* SCRIPT_CACHE* -TYPEDEF: void* ABC* +C-TYPE: ABC FUNCTION: HRESULT ScriptShape ( HDC hdc, diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index b50fadb5ba..7bd86c8e47 100755 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -105,7 +105,7 @@ CONSTANT: SD_BOTH 2 CONSTANT: SOL_SOCKET HEX: ffff -TYPEDEF: void* sockaddr* +C-TYPE: sockaddr STRUCT: sockaddr-in { family short } diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 2b90b1bff2..a6097c9dad 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -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: ALIAS: ALIAS: diff --git a/extra/curses/ffi/ffi.factor b/extra/curses/ffi/ffi.factor index 4eb01e913c..9a5802e73e 100644 --- a/extra/curses/ffi/ffi.factor +++ b/extra/curses/ffi/ffi.factor @@ -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 diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index 6105381f86..23dd62b340 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -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* } diff --git a/extra/opengl/glu/glu.factor b/extra/opengl/glu/glu.factor index a62745cb6a..6409a3781b 100644 --- a/extra/opengl/glu/glu.factor +++ b/extra/opengl/glu/glu.factor @@ -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 diff --git a/extra/tokyo/alien/tchdb/tchdb.factor b/extra/tokyo/alien/tchdb/tchdb.factor index b9503bdab4..fd0464fcec 100755 --- a/extra/tokyo/alien/tchdb/tchdb.factor +++ b/extra/tokyo/alien/tchdb/tchdb.factor @@ -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 diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index 0450e6522c..a6e59dbe03 100755 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -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* } ; diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index 8373a6aaaa..9e8071d0df 100755 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -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 diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index ac6e242be2..7cb6c5e092 100755 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -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 ) ; diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 138e142eae..2975545349 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -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=/\/ skip=/\\"/ end=/"/ syn region factorMultiString matchgroup=factorMultiStringDelims start=/\/ 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 diff --git a/unmaintained/odbc/odbc.factor b/unmaintained/odbc/odbc.factor index 267c7be312..06d47b8937 100644 --- a/unmaintained/odbc/odbc.factor +++ b/unmaintained/odbc/odbc.factor @@ -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