Merge branch 'master' of git://factorcode.org/git/factor into clean-linux-x86-32

db4
Maxim Savchenko 2009-04-18 11:25:13 -04:00
commit dc1f9af7c6
211 changed files with 2545 additions and 819 deletions

2
.gitignore vendored
View File

@ -25,3 +25,5 @@ build-support/wordsize
.#* .#*
*.swo *.swo
checksums.txt checksums.txt
*.so
a.out

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types arrays assocs effects grouping kernel USING: alien alien.c-types arrays assocs effects grouping kernel
parser sequences splitting words fry locals ; parser sequences splitting words fry locals lexer namespaces ;
IN: alien.parser IN: alien.parser
: parse-arglist ( parameters return -- types effect ) : parse-arglist ( parameters return -- types effect )
@ -12,8 +12,15 @@ IN: alien.parser
: function-quot ( return library function types -- quot ) : function-quot ( return library function types -- quot )
'[ _ _ _ _ alien-invoke ] ; '[ _ _ _ _ alien-invoke ] ;
:: define-function ( return library function parameters -- ) :: make-function ( return library function parameters -- word quot effect )
function create-in dup reset-generic function create-in dup reset-generic
return library function return library function
parameters return parse-arglist [ function-quot ] dip parameters return parse-arglist [ function-quot ] dip ;
define-declared ;
: (FUNCTION:) ( -- word quot effect )
scan "c-library" get scan ";" parse-tokens
[ "()" subseq? not ] filter
make-function ;
: define-function ( return library function parameters -- )
make-function define-declared ;

View File

@ -16,9 +16,7 @@ SYNTAX: BAD-ALIEN <bad-alien> parsed ;
SYNTAX: LIBRARY: scan "c-library" set ; SYNTAX: LIBRARY: scan "c-library" set ;
SYNTAX: FUNCTION: SYNTAX: FUNCTION:
scan "c-library" get scan ";" parse-tokens (FUNCTION:) define-declared ;
[ "()" subseq? not ] filter
define-function ;
SYNTAX: TYPEDEF: SYNTAX: TYPEDEF:
scan scan typedef ; scan scan typedef ;

View File

@ -8,7 +8,7 @@ namespaces eval kernel vocabs.loader io ;
(command-line) parse-command-line (command-line) parse-command-line
load-vocab-roots load-vocab-roots
run-user-init run-user-init
"e" get [ eval ] when* "e" get [ eval( -- ) ] when*
ignore-cli-args? not script get and ignore-cli-args? not script get and
[ run-script ] [ "run" get run ] if* [ run-script ] [ "run" get run ] if*
output-stream get [ stream-flush ] when* output-stream get [ stream-flush ] when*

View File

@ -2,33 +2,4 @@ IN: compiler.errors
USING: help.markup help.syntax vocabs.loader words io USING: help.markup help.syntax vocabs.loader words io
quotations words.symbol ; quotations words.symbol ;
ARTICLE: "compiler-errors" "Compiler warnings and errors"
"After loading a vocabulary, you might see messages like:"
{ $code
":errors - print 2 compiler errors"
":warnings - print 50 compiler warnings"
}
"These messages arise from the compiler's stack effect checker. Production code should not have any warnings and errors in it. Warning and error conditions are documented in " { $link "inference-errors" } "."
$nl
"Words to view warnings and errors:"
{ $subsection :warnings }
{ $subsection :errors }
{ $subsection :linkage }
"Compiler warnings and errors are reported using the " { $link "tools.errors" } " mechanism and are shown in the " { $link "ui.tools.error-list" } "." ;
HELP: compiler-error
{ $values { "error" "an error" } { "word" word } }
{ $description "Saves the error for future persual via " { $link :errors } ", " { $link :warnings } " and " { $link :linkage } "." } ;
HELP: :errors
{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ;
HELP: :warnings
{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ;
HELP: :linkage
{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ;
{ :errors :warnings } related-words
ABOUT: "compiler-errors" ABOUT: "compiler-errors"

View File

@ -1,7 +1,6 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors source-files.errors kernel namespaces assocs USING: accessors source-files.errors kernel namespaces assocs ;
tools.errors ;
IN: compiler.errors IN: compiler.errors
TUPLE: compiler-error < source-file-error ; TUPLE: compiler-error < source-file-error ;
@ -44,6 +43,7 @@ T{ error-type
{ icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" } { icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" }
{ quot [ +linkage-error+ errors-of-type values ] } { quot [ +linkage-error+ errors-of-type values ] }
{ forget-quot [ compiler-errors get delete-at ] } { forget-quot [ compiler-errors get delete-at ] }
{ fatal? f }
} define-error-type } define-error-type
: <compiler-error> ( error word -- compiler-error ) : <compiler-error> ( error word -- compiler-error )
@ -52,12 +52,3 @@ T{ error-type
: compiler-error ( error word -- ) : compiler-error ( error word -- )
compiler-errors get-global pick compiler-errors get-global pick
[ [ [ <compiler-error> ] keep ] dip set-at ] [ delete-at drop ] if ; [ [ [ <compiler-error> ] keep ] dip set-at ] [ delete-at drop ] if ;
: compiler-errors. ( type -- )
errors-of-type values errors. ;
: :errors ( -- ) +compiler-error+ compiler-errors. ;
: :warnings ( -- ) +compiler-warning+ compiler-errors. ;
: :linkage ( -- ) +linkage-error+ compiler-errors. ;

View File

@ -12,7 +12,7 @@ IN: compiler.tests
IN: compiler.tests.folding IN: compiler.tests.folding
GENERIC: foldable-generic ( a -- b ) foldable GENERIC: foldable-generic ( a -- b ) foldable
M: integer foldable-generic f <array> ; M: integer foldable-generic f <array> ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -20,7 +20,7 @@ IN: compiler.tests
USING: math arrays ; USING: math arrays ;
IN: compiler.tests.folding IN: compiler.tests.folding
: fold-test ( -- x ) 10 foldable-generic ; : fold-test ( -- x ) 10 foldable-generic ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ t ] [ [ t ] [

View File

@ -11,7 +11,7 @@ M: integer method-redefine-generic-1 3 + ;
[ 6 ] [ method-redefine-test-1 ] unit-test [ 6 ] [ method-redefine-test-1 ] unit-test
[ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-generic-1 4 + ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-generic-1 4 + ;" eval( -- ) ] unit-test
[ 7 ] [ method-redefine-test-1 ] unit-test [ 7 ] [ method-redefine-test-1 ] unit-test
@ -27,7 +27,7 @@ M: integer method-redefine-generic-2 3 + ;
[ 6 ] [ method-redefine-test-2 ] unit-test [ 6 ] [ method-redefine-test-2 ] unit-test
[ ] [ "IN: compiler.tests USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" eval( -- ) ] unit-test
[ 7 ] [ method-redefine-test-2 ] unit-test [ 7 ] [ method-redefine-test-2 ] unit-test
@ -43,10 +43,10 @@ M: integer method-redefine-generic-2 3 + ;
[ t ] [ \ hey optimized>> ] unit-test [ t ] [ \ hey optimized>> ] unit-test
[ t ] [ \ there optimized>> ] unit-test [ t ] [ \ there optimized>> ] unit-test
[ ] [ "IN: compiler.tests : hey ( -- ) 3 ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests : hey ( -- ) 3 ;" eval( -- ) ] unit-test
[ f ] [ \ hey optimized>> ] unit-test [ f ] [ \ hey optimized>> ] unit-test
[ f ] [ \ there optimized>> ] unit-test [ f ] [ \ there optimized>> ] unit-test
[ ] [ "IN: compiler.tests : hey ( -- ) ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests : hey ( -- ) ;" eval( -- ) ] unit-test
[ t ] [ \ there optimized>> ] unit-test [ t ] [ \ there optimized>> ] unit-test
: good ( -- ) ; : good ( -- ) ;
@ -59,7 +59,7 @@ M: integer method-redefine-generic-2 3 + ;
[ f ] [ \ good compiled-usage assoc-empty? ] unit-test [ f ] [ \ good compiled-usage assoc-empty? ] unit-test
[ ] [ "IN: compiler.tests : good ( -- ) 3 ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests : good ( -- ) 3 ;" eval( -- ) ] unit-test
[ f ] [ \ good optimized>> ] unit-test [ f ] [ \ good optimized>> ] unit-test
[ f ] [ \ bad optimized>> ] unit-test [ f ] [ \ bad optimized>> ] unit-test
@ -67,7 +67,7 @@ M: integer method-redefine-generic-2 3 + ;
[ t ] [ \ good compiled-usage assoc-empty? ] unit-test [ t ] [ \ good compiled-usage assoc-empty? ] unit-test
[ ] [ "IN: compiler.tests : good ( -- ) ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests : good ( -- ) ;" eval( -- ) ] unit-test
[ t ] [ \ good optimized>> ] unit-test [ t ] [ \ good optimized>> ] unit-test
[ t ] [ \ bad optimized>> ] unit-test [ t ] [ \ bad optimized>> ] unit-test

View File

@ -13,7 +13,7 @@ IN: compiler.tests
MIXIN: my-mixin MIXIN: my-mixin
INSTANCE: fixnum my-mixin INSTANCE: fixnum my-mixin
: my-inline ( a -- b ) dup my-mixin instance? [ 1 + ] when ; : my-inline ( a -- b ) dup my-mixin instance? [ 1 + ] when ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -21,7 +21,7 @@ IN: compiler.tests
USE: math USE: math
IN: compiler.tests.redefine10 IN: compiler.tests.redefine10
INSTANCE: float my-mixin INSTANCE: float my-mixin
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ 2.0 ] [ [ 2.0 ] [

View File

@ -17,7 +17,7 @@ IN: compiler.tests
M: my-mixin my-generic drop 0 ; M: my-mixin my-generic drop 0 ;
M: object my-generic drop 1 ; M: object my-generic drop 1 ;
: my-inline ( -- b ) { } my-generic ; : my-inline ( -- b ) { } my-generic ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [

View File

@ -15,6 +15,6 @@ M: object g drop t ;
TUPLE: jeah ; TUPLE: jeah ;
[ ] [ "USE: kernel IN: compiler.tests.redefine12 M: jeah g drop f ;" (( -- )) eval ] unit-test [ ] [ "USE: kernel IN: compiler.tests.redefine12 M: jeah g drop f ;" eval( -- ) ] unit-test
[ f ] [ T{ jeah } h ] unit-test [ f ] [ T{ jeah } h ] unit-test

View File

@ -5,7 +5,7 @@ arrays words assocs eval words.symbol ;
DEFER: redefine2-test DEFER: redefine2-test
[ ] [ "USE: sequences USE: kernel IN: compiler.tests TUPLE: redefine2-test ; M: redefine2-test nth 2drop 3 ; INSTANCE: redefine2-test sequence" (( -- )) eval ] unit-test [ ] [ "USE: sequences USE: kernel IN: compiler.tests TUPLE: redefine2-test ; M: redefine2-test nth 2drop 3 ; INSTANCE: redefine2-test sequence" eval( -- ) ] unit-test
[ t ] [ \ redefine2-test symbol? ] unit-test [ t ] [ \ redefine2-test symbol? ] unit-test

View File

@ -18,7 +18,7 @@ M: empty-mixin sheeple drop "wake up" ;
[ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test [ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
[ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test [ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
[ ] [ "IN: compiler.tests USE: arrays INSTANCE: array empty-mixin" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests USE: arrays INSTANCE: array empty-mixin" eval( -- ) ] unit-test
[ "wake up" ] [ sheeple-test ] unit-test [ "wake up" ] [ sheeple-test ] unit-test
[ f ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test [ f ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test

View File

@ -7,6 +7,6 @@ USING: io.streams.string kernel tools.test eval ;
[ "" ] [ [ declaration-test ] with-string-writer ] unit-test [ "" ] [ [ declaration-test ] with-string-writer ] unit-test
[ ] [ "IN: compiler.tests USE: io : declaration-test-1 ( -- a ) \"X\" write f ;" (( -- )) eval ] unit-test [ ] [ "IN: compiler.tests USE: io : declaration-test-1 ( -- a ) \"X\" write f ;" eval( -- ) ] unit-test
[ "X" ] [ [ declaration-test ] with-string-writer ] unit-test [ "X" ] [ [ declaration-test ] with-string-writer ] unit-test

View File

@ -14,7 +14,7 @@ IN: compiler.tests
GENERIC: my-generic ( a -- b ) GENERIC: my-generic ( a -- b )
M: object my-generic [ <=> ] sort ; M: object my-generic [ <=> ] sort ;
: my-inline ( a -- b ) my-generic ; : my-inline ( a -- b ) my-generic ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -23,7 +23,7 @@ IN: compiler.tests
IN: compiler.tests.redefine5 IN: compiler.tests.redefine5
TUPLE: my-tuple ; TUPLE: my-tuple ;
M: my-tuple my-generic drop 0 ; M: my-tuple my-generic drop 0 ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ 0 ] [ [ 0 ] [

View File

@ -14,7 +14,7 @@ IN: compiler.tests
MIXIN: my-mixin MIXIN: my-mixin
M: my-mixin my-generic drop 0 ; M: my-mixin my-generic drop 0 ;
: my-inline ( a -- b ) { my-mixin } declare my-generic ; : my-inline ( a -- b ) { my-mixin } declare my-generic ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -24,7 +24,7 @@ IN: compiler.tests
TUPLE: my-tuple ; TUPLE: my-tuple ;
M: my-tuple my-generic drop 1 ; M: my-tuple my-generic drop 1 ;
INSTANCE: my-tuple my-mixin INSTANCE: my-tuple my-mixin
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ 1 ] [ [ 1 ] [

View File

@ -13,7 +13,7 @@ IN: compiler.tests
MIXIN: my-mixin MIXIN: my-mixin
INSTANCE: fixnum my-mixin INSTANCE: fixnum my-mixin
: my-inline ( a -- b ) dup my-mixin? [ 1 + ] when ; : my-inline ( a -- b ) dup my-mixin? [ 1 + ] when ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -21,7 +21,7 @@ IN: compiler.tests
USE: math USE: math
IN: compiler.tests.redefine7 IN: compiler.tests.redefine7
INSTANCE: float my-mixin INSTANCE: float my-mixin
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ 2.0 ] [ [ 2.0 ] [

View File

@ -16,7 +16,7 @@ IN: compiler.tests
! We add the bogus quotation here to hinder inlining ! We add the bogus quotation here to hinder inlining
! since otherwise we cannot trigger this bug. ! since otherwise we cannot trigger this bug.
M: my-mixin my-generic 1 + [ [ <=> ] sort ] drop ; M: my-mixin my-generic 1 + [ [ <=> ] sort ] drop ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -24,7 +24,7 @@ IN: compiler.tests
USE: math USE: math
IN: compiler.tests.redefine8 IN: compiler.tests.redefine8
INSTANCE: float my-mixin INSTANCE: float my-mixin
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ 2.0 ] [ [ 2.0 ] [

View File

@ -16,7 +16,7 @@ IN: compiler.tests
! We add the bogus quotation here to hinder inlining ! We add the bogus quotation here to hinder inlining
! since otherwise we cannot trigger this bug. ! since otherwise we cannot trigger this bug.
M: my-mixin my-generic 1 + [ [ <=> ] sort ] drop ; M: my-mixin my-generic 1 + [ [ <=> ] sort ] drop ;
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [
@ -25,7 +25,7 @@ IN: compiler.tests
IN: compiler.tests.redefine9 IN: compiler.tests.redefine9
TUPLE: my-tuple ; TUPLE: my-tuple ;
INSTANCE: my-tuple my-mixin INSTANCE: my-tuple my-mixin
"> (( -- )) eval "> eval( -- )
] unit-test ] unit-test
[ [

View File

@ -237,6 +237,6 @@ M: f single-combination-test-2 single-combination-test-4 ;
10 [ 10 [
[ "compiler.tests.foo" forget-vocab ] with-compilation-unit [ "compiler.tests.foo" forget-vocab ] with-compilation-unit
[ t ] [ [ t ] [
"USING: prettyprint words accessors ; IN: compiler.tests.foo : (recursive) ( -- ) (recursive) (recursive) ; inline recursive : recursive ( -- ) (recursive) ; \\ (recursive) optimized>>" (( -- obj )) eval "USING: prettyprint words accessors ; IN: compiler.tests.foo : (recursive) ( -- ) (recursive) (recursive) ; inline recursive : recursive ( -- ) (recursive) ; \\ (recursive) optimized>>" eval( -- obj )
] unit-test ] unit-test
] times ] times

View File

@ -302,7 +302,7 @@ cell-bits 32 = [
] unit-test ] unit-test
[ t ] [ [ t ] [
[ 1000 [ 1+ ] map ] { 1+ fixnum+ } inlined? [ 1000 iota [ 1+ ] map ] { 1+ fixnum+ } inlined?
] unit-test ] unit-test
: rec ( a -- b ) : rec ( a -- b )

View File

@ -17,13 +17,13 @@ sequences accessors tools.test kernel math ;
[ 2 ] [ [ 3 [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test [ 2 ] [ [ 3 [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test
: foo ( a b -- b a ) swap ; inline recursive : foo ( quot: ( -- ) -- ) call ; inline recursive
: recursive-inputs ( nodes -- n ) : recursive-inputs ( nodes -- n )
[ #recursive? ] find nip child>> first in-d>> length ; [ #recursive? ] find nip child>> first in-d>> length ;
[ 0 2 ] [ [ 1 3 ] [
[ foo ] build-tree [ [ swap ] foo ] build-tree
[ recursive-inputs ] [ recursive-inputs ]
[ analyze-recursive normalize recursive-inputs ] bi [ analyze-recursive normalize recursive-inputs ] bi
] unit-test ] unit-test

View File

@ -310,7 +310,7 @@ CONSTANT: rs-reg 30
4 ds-reg 0 LWZ 4 ds-reg 0 LWZ
5 ds-reg -4 LWZU 5 ds-reg -4 LWZU
5 0 4 CMP 5 0 4 CMP
2 swap execute ! magic number 2 swap execute( offset -- ) ! magic number
\ f tag-number 3 LI \ f tag-number 3 LI
3 ds-reg 0 STW ; 3 ds-reg 0 STW ;
@ -341,7 +341,7 @@ CONSTANT: rs-reg 30
: jit-math ( insn -- ) : jit-math ( insn -- )
3 ds-reg 0 LWZ 3 ds-reg 0 LWZ
4 ds-reg -4 LWZU 4 ds-reg -4 LWZU
[ 5 3 4 ] dip execute [ 5 3 4 ] dip execute( dst src1 src2 -- )
5 ds-reg 0 STW ; 5 ds-reg 0 STW ;
[ \ ADD jit-math ] f f f \ fixnum+fast define-sub-primitive [ \ ADD jit-math ] f f f \ fixnum+fast define-sub-primitive

View File

@ -334,7 +334,7 @@ big-endian off
! compare with second value ! compare with second value
ds-reg [] temp0 CMP ds-reg [] temp0 CMP
! move t if true ! move t if true
[ temp1 temp3 ] dip execute [ temp1 temp3 ] dip execute( dst src -- )
! store ! store
ds-reg [] temp1 MOV ; ds-reg [] temp1 MOV ;
@ -355,7 +355,7 @@ big-endian off
! pop stack ! pop stack
ds-reg bootstrap-cell SUB ds-reg bootstrap-cell SUB
! compute result ! compute result
[ ds-reg [] temp0 ] dip execute ; [ ds-reg [] temp0 ] dip execute( dst src -- ) ;
[ \ ADD jit-math ] f f f \ fixnum+fast define-sub-primitive [ \ ADD jit-math ] f f f \ fixnum+fast define-sub-primitive

View File

@ -35,7 +35,7 @@ M: hello bing hello-test ;
[ 3 ] [ 1 0 <hello> 2 whoa ] unit-test [ 3 ] [ 1 0 <hello> 2 whoa ] unit-test
[ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test [ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test
[ ] [ 3 [ "USING: accessors delegate ; IN: delegate.tests CONSULT: baz goodbye these>> ;" (( -- )) eval ] times ] unit-test [ ] [ 3 [ "USING: accessors delegate ; IN: delegate.tests CONSULT: baz goodbye these>> ;" eval( -- ) ] times ] unit-test
[ H{ { goodbye T{ consultation f baz goodbye [ these>> ] } } } ] [ baz protocol-consult ] unit-test [ H{ { goodbye T{ consultation f baz goodbye [ these>> ] } } } ] [ baz protocol-consult ] unit-test
[ H{ } ] [ bee protocol-consult ] unit-test [ H{ } ] [ bee protocol-consult ] unit-test
@ -63,22 +63,22 @@ CONSULT: beta hey value>> 1- ;
[ 0 ] [ 1 <hey> three ] unit-test [ 0 ] [ 1 <hey> three ] unit-test
[ { hey } ] [ alpha protocol-users ] unit-test [ { hey } ] [ alpha protocol-users ] unit-test
[ { hey } ] [ beta protocol-users ] unit-test [ { hey } ] [ beta protocol-users ] unit-test
[ ] [ "USE: delegate IN: delegate.tests PROTOCOL: alpha one ;" (( -- )) eval ] unit-test [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: alpha one ;" eval( -- ) ] unit-test
[ f ] [ hey \ two method ] unit-test [ f ] [ hey \ two method ] unit-test
[ f ] [ hey \ four method ] unit-test [ f ] [ hey \ four method ] unit-test
[ ] [ "USE: delegate IN: delegate.tests PROTOCOL: beta two three four ;" (( -- )) eval ] unit-test [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: beta two three four ;" eval( -- ) ] unit-test
[ { hey } ] [ alpha protocol-users ] unit-test [ { hey } ] [ alpha protocol-users ] unit-test
[ { hey } ] [ beta protocol-users ] unit-test [ { hey } ] [ beta protocol-users ] unit-test
[ 2 ] [ 1 <hey> one ] unit-test [ 2 ] [ 1 <hey> one ] unit-test
[ 0 ] [ 1 <hey> two ] unit-test [ 0 ] [ 1 <hey> two ] unit-test
[ 0 ] [ 1 <hey> three ] unit-test [ 0 ] [ 1 <hey> three ] unit-test
[ 0 ] [ 1 <hey> four ] unit-test [ 0 ] [ 1 <hey> four ] unit-test
[ ] [ "USING: math accessors delegate ; IN: delegate.tests CONSULT: beta hey value>> 2 - ;" (( -- )) eval ] unit-test [ ] [ "USING: math accessors delegate ; IN: delegate.tests CONSULT: beta hey value>> 2 - ;" eval( -- ) ] unit-test
[ 2 ] [ 1 <hey> one ] unit-test [ 2 ] [ 1 <hey> one ] unit-test
[ -1 ] [ 1 <hey> two ] unit-test [ -1 ] [ 1 <hey> two ] unit-test
[ -1 ] [ 1 <hey> three ] unit-test [ -1 ] [ 1 <hey> three ] unit-test
[ -1 ] [ 1 <hey> four ] unit-test [ -1 ] [ 1 <hey> four ] unit-test
[ ] [ "IN: delegate.tests FORGET: alpha" (( -- )) eval ] unit-test [ ] [ "IN: delegate.tests FORGET: alpha" eval( -- ) ] unit-test
[ f ] [ hey \ one method ] unit-test [ f ] [ hey \ one method ] unit-test
TUPLE: slot-protocol-test-1 a b ; TUPLE: slot-protocol-test-1 a b ;

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,17 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: editors io.launcher kernel make math.parser namespaces
sequences ;
IN: editors.gedit
: gedit-path ( -- path )
\ gedit-path get-global [
"gedit"
] unless* ;
: gedit ( file line -- )
[
gedit-path , number>string "+" prepend , ,
] { } make run-detached drop ;
[ gedit ] edit-hook set-global

View File

@ -0,0 +1 @@
gedit integration

View File

@ -1,4 +1,6 @@
IN: eval.tests IN: eval.tests
USING: eval tools.test ; USING: eval tools.test ;
[ 4 ] [ "USE: math 2 2 +" eval( -- result ) ] unit-test
[ "USE: math 2 2 +" eval( -- ) ] must-fail
[ "4\n" ] [ "USING: math prettyprint ; 2 2 + ." eval>string ] unit-test [ "4\n" ] [ "USING: math prettyprint ; 2 2 + ." eval>string ] unit-test

View File

@ -56,7 +56,7 @@ sequences eval accessors ;
3 '[ [ [ _ 1array ] call 1array ] call 1array ] call 3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
] unit-test ] unit-test
[ "USING: fry locals.backend ; f '[ load-local _ ]" (( -- quot )) eval ] [ "USING: fry locals.backend ; f '[ load-local _ ]" eval( -- quot ) ]
[ error>> >r/r>-in-fry-error? ] must-fail-with [ error>> >r/r>-in-fry-error? ] must-fail-with
[ { { "a" 1 } { "b" 2 } { "c" 3 } { "d" 4 } } ] [ [ { { "a" 1 } { "b" 2 } { "c" 3 } { "d" 4 } } ] [

View File

@ -272,8 +272,8 @@ HELP: nweave
HELP: n*quot HELP: n*quot
{ $values { $values
{ "n" integer } { "seq" sequence } { "n" integer } { "quot" quotation }
{ "seq'" sequence } { "quot'" quotation }
} }
{ $examples { $examples
{ $example "USING: generalizations prettyprint math ;" { $example "USING: generalizations prettyprint math ;"

View File

@ -7,7 +7,7 @@ IN: generalizations
<< <<
: n*quot ( n seq -- seq' ) <repetition> concat >quotation ; : n*quot ( n quot -- quot' ) <repetition> concat >quotation ;
: repeat ( n obj quot -- ) swapd times ; inline : repeat ( n obj quot -- ) swapd times ; inline

View File

@ -4,7 +4,7 @@ definitions assocs sequences kernel namespaces parser arrays
io.streams.string continuations debugger compiler.units eval ; io.streams.string continuations debugger compiler.units eval ;
[ ] [ [ ] [
"IN: help.crossref.tests USING: help.syntax help.markup ; : foo ( -- ) ; HELP: foo \"foo is great\" ; ARTICLE: \"foo\" \"Foo\" { $subsection foo } ;" (( -- )) eval "IN: help.crossref.tests USING: help.syntax help.markup ; : foo ( -- ) ; HELP: foo \"foo is great\" ; ARTICLE: \"foo\" \"Foo\" { $subsection foo } ;" eval( -- )
] unit-test ] unit-test
[ $subsection ] [ [ $subsection ] [
@ -23,7 +23,7 @@ io.streams.string continuations debugger compiler.units eval ;
] unit-test ] unit-test
[ ] [ [ ] [
"IN: help.crossref.tests USING: help.syntax help.markup ; : bar ( -- ) ; HELP: bar \"bar is great\" ; ARTICLE: \"bar\" \"Bar\" { $subsection bar } ;" (( -- )) eval "IN: help.crossref.tests USING: help.syntax help.markup ; : bar ( -- ) ; HELP: bar \"bar is great\" ; ARTICLE: \"bar\" \"Bar\" { $subsection bar } ;" eval( -- )
] unit-test ] unit-test
[ ] [ [ ] [

View File

@ -32,7 +32,7 @@ IN: help.definitions.tests
"hello" "help.definitions.tests" lookup "help" word-prop "hello" "help.definitions.tests" lookup "help" word-prop
] unit-test ] unit-test
[ ] [ "IN: help.definitions.tests USING: help.syntax ; : xxx ( -- ) ; HELP: xxx ;" (( -- )) eval ] unit-test [ ] [ "IN: help.definitions.tests USING: help.syntax ; : xxx ( -- ) ; HELP: xxx ;" eval( -- ) ] unit-test
[ ] [ "xxx" "help.definitions.tests" lookup print-topic ] unit-test [ ] [ "xxx" "help.definitions.tests" lookup print-topic ] unit-test

View File

@ -4,12 +4,12 @@ IN: help.syntax.tests
[ [
[ "foobar" ] [ [ "foobar" ] [
"IN: help.syntax.tests USE: help.syntax ABOUT: \"foobar\"" (( -- )) eval "IN: help.syntax.tests USE: help.syntax ABOUT: \"foobar\"" eval( -- )
"help.syntax.tests" vocab vocab-help "help.syntax.tests" vocab vocab-help
] unit-test ] unit-test
[ { "foobar" } ] [ [ { "foobar" } ] [
"IN: help.syntax.tests USE: help.syntax ABOUT: { \"foobar\" }" (( -- )) eval "IN: help.syntax.tests USE: help.syntax ABOUT: { \"foobar\" }" eval( -- )
"help.syntax.tests" vocab vocab-help "help.syntax.tests" vocab vocab-help
] unit-test ] unit-test

View File

@ -29,7 +29,7 @@ SYMBOL: foo
} "\n" join } "\n" join
[ [
"testfile" source-file file set "testfile" source-file file set
(( -- )) eval eval( -- )
] with-scope ] with-scope
] unit-test ] unit-test

View File

@ -184,6 +184,12 @@ ERROR: download-failed response ;
: http-put ( post-data url -- response data ) : http-put ( post-data url -- response data )
<put-request> http-request ; <put-request> http-request ;
: <delete-request> ( url -- request )
"DELETE" <client-request> ;
: http-delete ( url -- response data )
<delete-request> http-request ;
USING: vocabs vocabs.loader ; USING: vocabs vocabs.loader ;
"debugger" vocab [ "http.client.debugger" require ] when "debugger" vocab [ "http.client.debugger" require ] when

View File

@ -0,0 +1,8 @@
IN: io.crlf.tests
USING: io.crlf tools.test io.streams.string io ;
[ "Hello, world." ] [ "Hello, world." [ read-crlf ] with-string-reader ] unit-test
[ "Hello, world." ] [ "Hello, world.\r\n" [ read-crlf ] with-string-reader ] unit-test
[ "Hello, world.\r" [ read-crlf ] with-string-reader ] must-fail
[ f ] [ "" [ read-crlf ] with-string-reader ] unit-test
[ "" ] [ "\r\n" [ read-crlf ] with-string-reader ] unit-test

View File

@ -1,6 +1,6 @@
! Copyright (C) 2009 Daniel Ehrenberg, Slava Pestov ! Copyright (C) 2009 Daniel Ehrenberg, Slava Pestov
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io kernel ; USING: io kernel sequences ;
IN: io.crlf IN: io.crlf
: crlf ( -- ) : crlf ( -- )
@ -8,4 +8,4 @@ IN: io.crlf
: read-crlf ( -- seq ) : read-crlf ( -- seq )
"\r" read-until "\r" read-until
[ CHAR: \r assert= read1 CHAR: \n assert= ] when* ; [ CHAR: \r assert= read1 CHAR: \n assert= ] [ f like ] if* ;

View File

@ -98,7 +98,7 @@ IN: io.launcher.windows.nt.tests
<process> <process>
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
ascii <process-reader> contents ascii <process-reader> contents
] with-directory eval ] with-directory eval( -- alist )
os-envs = os-envs =
] unit-test ] unit-test
@ -110,7 +110,7 @@ IN: io.launcher.windows.nt.tests
+replace-environment+ >>environment-mode +replace-environment+ >>environment-mode
os-envs >>environment os-envs >>environment
ascii <process-reader> contents ascii <process-reader> contents
] with-directory eval ] with-directory eval( -- alist )
os-envs = os-envs =
] unit-test ] unit-test
@ -121,7 +121,7 @@ IN: io.launcher.windows.nt.tests
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
{ { "A" "B" } } >>environment { { "A" "B" } } >>environment
ascii <process-reader> contents ascii <process-reader> contents
] with-directory eval ] with-directory eval( -- alist )
"A" swap at "A" swap at
] unit-test ] unit-test
@ -133,7 +133,7 @@ IN: io.launcher.windows.nt.tests
{ { "USERPROFILE" "XXX" } } >>environment { { "USERPROFILE" "XXX" } } >>environment
+prepend-environment+ >>environment-mode +prepend-environment+ >>environment-mode
ascii <process-reader> contents ascii <process-reader> contents
] with-directory eval ] with-directory eval( -- alist )
"USERPROFILE" swap at "XXX" = "USERPROFILE" swap at "XXX" =
] unit-test ] unit-test

View File

@ -25,7 +25,7 @@ SYNTAX: hello "Hi" print ;
"\\ + 1 2 3 4" parse-interactive "\\ + 1 2 3 4" parse-interactive
"cont" get continue-with "cont" get continue-with
] ignore-errors ] ignore-errors
"USE: debugger :1" (( -- quot )) eval "USE: debugger :1" eval( -- quot )
] callcc1 ] callcc1
] unit-test ] unit-test
] with-file-vocabs ] with-file-vocabs

View File

@ -261,7 +261,7 @@ M:: fixnum next-method-test ( a -- b ) a call-next-method 1 + ;
CONSTANT: new-definition "USING: math ;\nIN: locals.tests\n: a-word-with-locals ( -- x ) 2 3 + ;\n" CONSTANT: new-definition "USING: math ;\nIN: locals.tests\n: a-word-with-locals ( -- x ) 2 3 + ;\n"
[ ] [ new-definition (( -- )) eval ] unit-test [ ] [ new-definition eval( -- ) ] unit-test
[ t ] [ [ t ] [
[ \ a-word-with-locals see ] with-string-writer [ \ a-word-with-locals see ] with-string-writer
@ -461,7 +461,7 @@ M:: integer lambda-method-forget-test ( a -- b ) ;
[ [
"USING: locals fry math ; 1 '[ [let | A [ 10 ] | A _ + ] ]" "USING: locals fry math ; 1 '[ [let | A [ 10 ] | A _ + ] ]"
(( -- )) eval call eval( -- ) call
] [ error>> >r/r>-in-fry-error? ] must-fail-with ] [ error>> >r/r>-in-fry-error? ] must-fail-with
:: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline :: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline
@ -473,10 +473,10 @@ M:: integer lambda-method-forget-test ( a -- b ) ;
[ f ] [ 2 funny-macro-test ] unit-test [ f ] [ 2 funny-macro-test ] unit-test
! Some odd parser corner cases ! Some odd parser corner cases
[ "USE: locals [let" (( -- )) eval ] [ error>> unexpected-eof? ] must-fail-with [ "USE: locals [let" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
[ "USE: locals [let |" (( -- )) eval ] [ error>> unexpected-eof? ] must-fail-with [ "USE: locals [let |" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
[ "USE: locals [let | a" (( -- )) eval ] [ error>> unexpected-eof? ] must-fail-with [ "USE: locals [let | a" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
[ "USE: locals [|" (( -- )) eval ] [ error>> unexpected-eof? ] must-fail-with [ "USE: locals [|" eval( -- ) ] [ error>> unexpected-eof? ] must-fail-with
[ 25 ] [ 5 [| a | { [ a sq ] } cond ] call ] unit-test [ 25 ] [ 5 [| a | { [ a sq ] } cond ] call ] unit-test
[ 25 ] [ 5 [| | { [| a | a sq ] } ] call first call ] unit-test [ 25 ] [ 5 [| | { [| a | a sq ] } ] call first call ] unit-test
@ -491,19 +491,19 @@ M:: integer lambda-method-forget-test ( a -- b ) ;
[ 3 ] [ 3 [| a | \ a ] call ] unit-test [ 3 ] [ 3 [| a | \ a ] call ] unit-test
[ "USE: locals [| | { [let | a [ 0 ] | a ] } ]" (( -- )) eval ] must-fail [ "USE: locals [| | { [let | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
[ "USE: locals [| | { [wlet | a [ 0 ] | a ] } ]" (( -- )) eval ] must-fail [ "USE: locals [| | { [wlet | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
[ "USE: locals [| | { [let* | a [ 0 ] | a ] } ]" (( -- )) eval ] must-fail [ "USE: locals [| | { [let* | a [ 0 ] | a ] } ]" eval( -- ) ] must-fail
[ "USE: locals [| | [let | a! [ 0 ] | { a! } ] ]" (( -- )) eval ] must-fail [ "USE: locals [| | [let | a! [ 0 ] | { a! } ] ]" eval( -- ) ] must-fail
[ "USE: locals [| | [wlet | a [ 0 ] | { a } ] ]" (( -- )) eval ] must-fail [ "USE: locals [| | [wlet | a [ 0 ] | { a } ] ]" eval( -- ) ] must-fail
[ "USE: locals [| | { :> a } ]" (( -- )) eval ] must-fail [ "USE: locals [| | { :> a } ]" eval( -- ) ] must-fail
[ "USE: locals 3 :> a" (( -- )) eval ] must-fail [ "USE: locals 3 :> a" eval( -- ) ] must-fail
[ 3 ] [ 3 [| | :> a a ] call ] unit-test [ 3 ] [ 3 [| | :> a a ] call ] unit-test

View File

@ -13,11 +13,11 @@ unit-test
[ t ] [ \ see-test macro? ] unit-test [ t ] [ \ see-test macro? ] unit-test
[ t ] [ [ t ] [
"USING: math ;\nIN: macros.tests\n: see-test ( a b -- c ) - ;\n" dup (( -- )) eval "USING: math ;\nIN: macros.tests\n: see-test ( a b -- c ) - ;\n" dup eval( -- )
[ \ see-test see ] with-string-writer = [ \ see-test see ] with-string-writer =
] unit-test ] unit-test
[ f ] [ \ see-test macro? ] unit-test [ f ] [ \ see-test macro? ] unit-test
[ ] [ "USING: macros stack-checker kernel ; IN: hanging-macro MACRO: c ( quot -- ) infer drop [ ] ; : a ( -- ) [ a ] c ;" (( -- )) eval ] unit-test [ ] [ "USING: macros stack-checker kernel ; IN: hanging-macro MACRO: c ( quot -- ) infer drop [ ] ; : a ( -- ) [ a ] c ;" eval( -- ) ] unit-test

View File

@ -9,7 +9,7 @@ MEMO: fib ( m -- n )
[ 89 ] [ 10 fib ] unit-test [ 89 ] [ 10 fib ] unit-test
[ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1+ ] 4 ndip ;" (( -- )) eval ] must-fail [ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1+ ] 4 ndip ;" eval( -- ) ] must-fail
MEMO: see-test ( a -- b ) reverse ; MEMO: see-test ( a -- b ) reverse ;
@ -17,7 +17,7 @@ MEMO: see-test ( a -- b ) reverse ;
[ [ \ see-test see ] with-string-writer ] [ [ \ see-test see ] with-string-writer ]
unit-test unit-test
[ ] [ "IN: memoize.tests : fib ( -- ) ;" (( -- )) eval ] unit-test [ ] [ "IN: memoize.tests : fib ( -- ) ;" eval( -- ) ] unit-test
[ "IN: memoize.tests\n: fib ( -- ) ;\n" ] [ [ \ fib see ] with-string-writer ] unit-test [ "IN: memoize.tests\n: fib ( -- ) ;\n" ] [ [ \ fib see ] with-string-writer ] unit-test

View File

@ -56,6 +56,6 @@ TUPLE: color
! Test reshaping with a mirror ! Test reshaping with a mirror
1 2 3 color boa <mirror> "mirror" set 1 2 3 color boa <mirror> "mirror" set
[ ] [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" (( -- )) eval ] unit-test [ ] [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test
[ 1 ] [ "red" "mirror" get at ] unit-test [ 1 ] [ "red" "mirror" get at ] unit-test

View File

@ -445,11 +445,11 @@ foo=<foreign any-char> 'd'
] unit-test ] unit-test
{ } [ { } [
"USING: kernel peg.ebnf ; \"a\\n\" [EBNF foo='a' '\n' => [[ drop \"\n\" ]] EBNF] drop" (( -- )) eval "USING: kernel peg.ebnf ; \"a\\n\" [EBNF foo='a' '\n' => [[ drop \"\n\" ]] EBNF] drop" eval( -- )
] unit-test ] unit-test
[ [
"USING: peg.ebnf ; <EBNF foo='a' foo='b' EBNF>" (( -- )) eval drop "USING: peg.ebnf ; <EBNF foo='a' foo='b' EBNF>" eval( -- ) drop
] must-fail ] must-fail
{ t } [ { t } [
@ -521,12 +521,12 @@ Tok = Spaces (Number | Special )
"\\" [EBNF foo="\\" EBNF] "\\" [EBNF foo="\\" EBNF]
] unit-test ] unit-test
[ "USE: peg.ebnf [EBNF EBNF]" (( -- )) eval ] must-fail [ "USE: peg.ebnf [EBNF EBNF]" eval( -- ) ] must-fail
[ <" USE: peg.ebnf [EBNF [ <" USE: peg.ebnf [EBNF
lol = a lol = a
lol = b lol = b
EBNF] "> (( -- )) eval EBNF] "> eval( -- )
] [ ] [
error>> [ redefined-rule? ] [ name>> "lol" = ] bi and error>> [ redefined-rule? ] [ name>> "lol" = ] bi and
] must-fail-with ] must-fail-with

View File

@ -2,8 +2,8 @@ USING: arrays definitions io.streams.string io.streams.duplex
kernel math namespaces parser prettyprint prettyprint.config kernel math namespaces parser prettyprint prettyprint.config
prettyprint.sections sequences tools.test vectors words prettyprint.sections sequences tools.test vectors words
effects splitting generic.standard prettyprint.private effects splitting generic.standard prettyprint.private
continuations generic compiler.units tools.walker eval continuations generic compiler.units tools.continuations
accessors make vocabs.parser see ; tools.continuations.private eval accessors make vocabs.parser see ;
IN: prettyprint.tests IN: prettyprint.tests
[ "4" ] [ 4 unparse ] unit-test [ "4" ] [ 4 unparse ] unit-test
@ -254,7 +254,7 @@ M: class-see-layout class-see-layout ;
! Regression ! Regression
[ t ] [ [ t ] [
"IN: prettyprint.tests\nGENERIC: generic-decl-test ( a -- b ) flushable\n" "IN: prettyprint.tests\nGENERIC: generic-decl-test ( a -- b ) flushable\n"
dup (( -- )) eval dup eval( -- )
"generic-decl-test" "prettyprint.tests" lookup "generic-decl-test" "prettyprint.tests" lookup
[ see ] with-string-writer = [ see ] with-string-writer =
] unit-test ] unit-test

View File

@ -1 +1,2 @@
Slava Pestov Slava Pestov
Alex Chapman

View File

@ -1,37 +1,89 @@
! Copyright (C) 2007 Slava Pestov ! Copyright (C) 2007 Slava Pestov, 2009 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax kernel ; USING: boxes help.markup help.syntax kernel math namespaces ;
IN: refs IN: refs
ARTICLE: "refs" "References to assoc entries" ARTICLE: "refs" "References"
"A " { $emphasis "reference" } " is an object encapsulating an assoc and a key; the reference then refers to either the key itself, or the value associated to the key. References can be read, written, and deleted. References are defined in the " { $vocab-link "refs" } " vocabulary." "References provide a uniform way of accessing and changing values. Some examples of referenced values are variables, tuple slots, and keys or values of assocs. References can be read, written, and deleted. References are defined in the " { $vocab-link "refs" } " vocabulary, and new reference types can be made by implementing the " { $link "refs-protocol" } "."
{ $subsection get-ref } { $subsection get-ref }
{ $subsection set-ref } { $subsection set-ref }
{ $subsection set-ref* }
{ $subsection delete-ref } { $subsection delete-ref }
"References to keys:" "References to objects:"
{ $subsection obj-ref }
{ $subsection <obj-ref> }
"References to assoc keys:"
{ $subsection key-ref } { $subsection key-ref }
{ $subsection <key-ref> } { $subsection <key-ref> }
"References to values:" "References to assoc values:"
{ $subsection value-ref } { $subsection value-ref }
{ $subsection <value-ref> } { $subsection <value-ref> }
"References to variables:"
{ $subsection var-ref }
{ $subsection <var-ref> }
{ $subsection global-var-ref }
{ $subsection <global-var-ref> }
"References to tuple slots:"
{ $subsection slot-ref }
{ $subsection <slot-ref> }
"Using boxes as references:"
{ $subsection "box-refs" }
"References are used by the UI inspector." ; "References are used by the UI inspector." ;
ABOUT: "refs" ABOUT: "refs"
ARTICLE: "refs-protocol" "Reference Protocol"
"To use a class of objects as references you must implement the reference protocol for that class, and mark your class as an instance of the " { $link ref } " mixin class. All references must implement these two words:"
{ $subsection get-ref }
{ $subsection set-ref }
"References may also implement:"
{ $subsection delete-ref } ;
ARTICLE: "box-refs" "Using Boxes as References"
"Boxes are elements of the " { $link ref } " mixin class, so any box may be used as a reference. Bear in mind that boxes will still throw an error if you call " { $link get-ref } " on an empty box." ;
HELP: ref HELP: ref
{ $class-description "A class whose instances identify a key or value location in an associative structure. Instances of this clas are never used directly; only instances of " { $link key-ref } " and " { $link value-ref } " should be created." } ; { $class-description "A mixin class whose instances encapsulate a value which can be read, written, and deleted. Instantiable members of this class include:" { $link obj-ref } ", " { $link var-ref } ", " { $link global-var-ref } ", " { $link slot-ref } ", " { $link box } ", " { $link key-ref } ", and " { $link value-ref } "." } ;
HELP: delete-ref HELP: delete-ref
{ $values { "ref" ref } } { $values { "ref" ref } }
{ $description "Deletes the association entry pointed at by this reference." } ; { $description "Deletes the value pointed to by this reference. In most references this simply sets the value to f, but in some cases it is more destructive, such as in " { $link value-ref } " and " { $link key-ref } ", where it actually deletes the entry from the underlying assoc." } ;
HELP: get-ref HELP: get-ref
{ $values { "ref" ref } { "obj" object } } { $values { "ref" ref } { "obj" object } }
{ $description "Outputs the key or the value pointed at by this reference." } ; { $description "Outputs the value pointed at by this reference." } ;
HELP: set-ref HELP: set-ref
{ $values { "obj" object } { "ref" ref } } { $values { "obj" object } { "ref" ref } }
{ $description "Stores a new key or value at by this reference." } ; { $description "Stores a new value at this reference." } ;
HELP: obj-ref
{ $class-description "Instances of this class contain a value which can be changed using the " { $link "refs-protocol" } ". New object references are created by calling " { $link <obj-ref> } "." } ;
HELP: <obj-ref>
{ $values { "obj" object } { "obj-ref" obj-ref } }
{ $description "Creates a reference which contains the value it references." } ;
HELP: var-ref
{ $class-description "Instances of this class reference a variable as defined by the " { $vocab-link "namespaces" } " vocabulary. New variable references are created by calling " { $link <var-ref> } "." } ;
HELP: <var-ref>
{ $values { "var" object } { "var-ref" var-ref } }
{ $description "Creates a reference to the given variable. Note that this reference behaves just like any variable when it comes to dynamic scope. For example, if you use " { $link set-ref } " in an inner scope and then leave that scope, then calling " { $link get-ref } " may not return the expected value. If this is not what you want, try using an " { $link obj-ref } " instead." } ;
HELP: global-var-ref
{ $class-description "Instances of this class reference a global variable. New global references are created by calling " { $link <global-var-ref> } "." } ;
HELP: <global-var-ref>
{ $values { "var" object } { "global-var-ref" global-var-ref } }
{ $description "Creates a reference to a global variable." } ;
HELP: slot-ref
{ $class-description "Instances of this class identify a particular slot of a particular instance of a tuple. New slot references are created by calling " { $link <slot-ref> } "." } ;
HELP: <slot-ref>
{ $values { "tuple" tuple } { "slot" integer } { "slot-ref" slot-ref } }
{ $description "Creates a reference to the value in a particular slot of the given tuple. The slot must be given as an integer, where the first user-defined slot is number 2. This is mostly just a proof of concept until we have a way of generating this slot number from a slot name." } ;
HELP: key-ref HELP: key-ref
{ $class-description "Instances of this class identify a key in an associative structure. New key references are created by calling " { $link <key-ref> } "." } ; { $class-description "Instances of this class identify a key in an associative structure. New key references are created by calling " { $link <key-ref> } "." } ;
@ -47,6 +99,37 @@ HELP: <value-ref>
{ $values { "assoc" "an assoc" } { "key" object } { "value-ref" value-ref } } { $values { "assoc" "an assoc" } { "key" object } { "value-ref" value-ref } }
{ $description "Creates a reference to the value associated with " { $snippet "key" } " in " { $snippet "assoc" } "." } ; { $description "Creates a reference to the value associated with " { $snippet "key" } " in " { $snippet "assoc" } "." } ;
{ get-ref set-ref delete-ref } related-words { get-ref set-ref delete-ref set-ref* } related-words
{ <key-ref> <value-ref> } related-words { <obj-ref> <var-ref> <global-var-ref> <slot-ref> <key-ref> <value-ref> } related-words
HELP: set-ref*
{ $values { "ref" ref } { "obj" object } }
{ $description "Just like " { $link set-ref } ", but leave the ref on the stack." } ;
HELP: ref-on
{ $values { "ref" ref } }
{ $description "Sets the value of the ref to t." } ;
HELP: ref-off
{ $values { "ref" ref } }
{ $description "Sets the value of the ref to f." } ;
HELP: ref-inc
{ $values { "ref" ref } }
{ $description "Increment the value of the ref by 1." } ;
HELP: ref-dec
{ $values { "ref" ref } }
{ $description "Decrement the value of the ref by 1." } ;
HELP: take
{ $values { "ref" ref } { "obj" object } }
{ $description "Retrieve the value of the ref and then delete it, returning the value." } ;
{ ref-on ref-off ref-inc ref-dec take } related-words
{ take delete-ref } related-words
{ on ref-on } related-words
{ off ref-off } related-words
{ inc ref-inc } related-words
{ dec ref-dec } related-words

View File

@ -1,5 +1,7 @@
USING: refs tools.test kernel ; USING: boxes kernel namespaces refs tools.test ;
IN: refs.tests
! assoc-refs
[ 3 ] [ [ 3 ] [
H{ { "a" 3 } } "a" <value-ref> get-ref H{ { "a" 3 } } "a" <value-ref> get-ref
] unit-test ] unit-test
@ -20,3 +22,84 @@ USING: refs tools.test kernel ;
set-ref set-ref
] keep ] keep
] unit-test ] unit-test
SYMBOLS: lion giraffe elephant rabbit ;
! obj-refs
[ rabbit ] [ rabbit <obj-ref> get-ref ] unit-test
[ rabbit ] [ f <obj-ref> rabbit set-ref* get-ref ] unit-test
[ rabbit ] [ rabbit <obj-ref> take ] unit-test
[ rabbit f ] [ rabbit <obj-ref> [ take ] keep get-ref ] unit-test
[ lion ] [ rabbit <obj-ref> dup [ drop lion ] change-ref get-ref ] unit-test
! var-refs
[ giraffe ] [ [ giraffe rabbit set rabbit <var-ref> get-ref ] with-scope ] unit-test
[ rabbit ]
[
[
lion rabbit set [
rabbit rabbit set rabbit <var-ref> get-ref
] with-scope
] with-scope
] unit-test
[ rabbit ] [
rabbit <var-ref>
[
lion rabbit set [
rabbit rabbit set get-ref
] with-scope
] with-scope
] unit-test
[ elephant ] [
rabbit <var-ref>
[
elephant rabbit set [
rabbit rabbit set
] with-scope
get-ref
] with-scope
] unit-test
[ rabbit ] [
rabbit <var-ref>
[
elephant set-ref* [
rabbit set-ref* get-ref
] with-scope
] with-scope
] unit-test
[ elephant ] [
rabbit <var-ref>
[
elephant set-ref* [
rabbit set-ref*
] with-scope
get-ref
] with-scope
] unit-test
! Top Hats
[ lion ] [ lion rabbit set-global rabbit <global-var-ref> get-ref ] unit-test
[ giraffe ] [ rabbit <global-var-ref> giraffe set-ref* get-ref ] unit-test
! Tuple refs
TUPLE: foo bar ;
C: <foo> foo
: test-tuple ( -- tuple )
rabbit <foo> ;
: test-slot-ref ( -- slot-ref )
test-tuple 2 <slot-ref> ; ! hack!
[ rabbit ] [ test-slot-ref get-ref ] unit-test
[ lion ] [ test-slot-ref lion set-ref* get-ref ] unit-test
! Boxes as refs
[ rabbit ] [ <box> rabbit set-ref* get-ref ] unit-test
[ <box> rabbit set-ref* lion set-ref* ] must-fail
[ <box> get-ref ] must-fail

View File

@ -1,22 +1,77 @@
! Copyright (C) 2007, 2008 Slava Pestov ! Copyright (C) 2007, 2008 Slava Pestov, 2009 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: classes.tuple kernel assocs accessors ; USING: kernel assocs accessors boxes math namespaces ;
IN: refs IN: refs
TUPLE: ref assoc key ; MIXIN: ref
: >ref< ( ref -- key value ) [ key>> ] [ assoc>> ] bi ; inline
: delete-ref ( ref -- ) >ref< delete-at ;
GENERIC: get-ref ( ref -- obj ) GENERIC: get-ref ( ref -- obj )
GENERIC: set-ref ( obj ref -- ) GENERIC: set-ref ( obj ref -- )
GENERIC: delete-ref ( ref -- )
TUPLE: key-ref < ref ; ! works like >>slot words
: set-ref* ( ref obj -- ref ) over set-ref ;
! very similar to change, on, off, +@, inc, and dec from namespaces
: change-ref ( ref quot -- )
[ [ get-ref ] keep ] dip dip set-ref ; inline
: ref-on ( ref -- ) t swap set-ref ;
: ref-off ( ref -- ) f swap set-ref ;
: ref-+@ ( n ref -- ) [ 0 or + ] change-ref ;
: ref-inc ( ref -- ) 1 swap ref-+@ ;
: ref-dec ( ref -- ) -1 swap ref-+@ ;
: take ( ref -- obj )
dup get-ref swap delete-ref ;
! delete-ref defaults to setting ref to f
M: ref delete-ref ref-off ;
TUPLE: obj-ref obj ;
C: <obj-ref> obj-ref
M: obj-ref get-ref obj>> ;
M: obj-ref set-ref (>>obj) ;
INSTANCE: obj-ref ref
TUPLE: var-ref var ;
C: <var-ref> var-ref
M: var-ref get-ref var>> get ;
M: var-ref set-ref var>> set ;
INSTANCE: var-ref ref
TUPLE: global-var-ref var ;
C: <global-var-ref> global-var-ref
M: global-var-ref get-ref var>> get-global ;
M: global-var-ref set-ref var>> set-global ;
INSTANCE: global-var-ref ref
USE: slots.private
TUPLE: slot-ref tuple slot ;
C: <slot-ref> slot-ref
: >slot-ref< ( slot-ref -- tuple slot ) [ tuple>> ] [ slot>> ] bi ; inline
M: slot-ref get-ref >slot-ref< slot ;
M: slot-ref set-ref >slot-ref< set-slot ;
INSTANCE: slot-ref ref
M: box get-ref box> ;
M: box set-ref >box ;
M: box delete-ref box> drop ;
INSTANCE: box ref
TUPLE: assoc-ref assoc key ;
: >assoc-ref< ( assoc-ref -- key value ) [ key>> ] [ assoc>> ] bi ; inline
M: assoc-ref delete-ref ( assoc-ref -- ) >assoc-ref< delete-at ;
TUPLE: key-ref < assoc-ref ;
C: <key-ref> key-ref C: <key-ref> key-ref
M: key-ref get-ref key>> ; M: key-ref get-ref key>> ;
M: key-ref set-ref >ref< rename-at ; M: key-ref set-ref >assoc-ref< rename-at ;
INSTANCE: key-ref ref
TUPLE: value-ref < ref ; TUPLE: value-ref < assoc-ref ;
C: <value-ref> value-ref C: <value-ref> value-ref
M: value-ref get-ref >ref< at ; M: value-ref get-ref >assoc-ref< at ;
M: value-ref set-ref >ref< set-at ; M: value-ref set-ref >assoc-ref< set-at ;
INSTANCE: value-ref ref

View File

@ -262,11 +262,11 @@ IN: regexp-tests
! Comment inside a regular expression ! Comment inside a regular expression
[ t ] [ "ac" "a(?#boo)c" <regexp> matches? ] unit-test [ t ] [ "ac" "a(?#boo)c" <regexp> matches? ] unit-test
[ ] [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" (( -- )) eval ] unit-test [ ] [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" eval( -- ) ] unit-test
[ ] [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" (( -- )) eval ] unit-test [ ] [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" eval( -- ) ] unit-test
[ ] [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" (( -- )) eval ] unit-test [ ] [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" eval( -- ) ] unit-test
[ "ab" ] [ "ab" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test [ "ab" ] [ "ab" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
[ "abc" ] [ "abc" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test [ "abc" ] [ "abc" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test

View File

@ -1,3 +1,5 @@
Elie Chaftari Elie Chaftari
Dirk Vleugels Dirk Vleugels
Slava Pestov Slava Pestov
Doug Coleman
Daniel Ehrenberg

View File

@ -36,6 +36,7 @@ SYMBOL: data-mode
: process ( -- ) : process ( -- )
read-crlf { read-crlf {
{ [ dup not ] [ f ] }
{ {
[ dup [ "HELO" head? ] [ "EHLO" head? ] bi or ] [ dup [ "HELO" head? ] [ "EHLO" head? ] bi or ]
[ "220 and..?\r\n" write flush t ] [ "220 and..?\r\n" write flush t ]

View File

@ -1,7 +1,7 @@
! 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: accessors kernel quotations help.syntax help.markup USING: accessors kernel quotations help.syntax help.markup
io.sockets strings calendar ; io.sockets strings calendar io.encodings.utf8 ;
IN: smtp IN: smtp
HELP: smtp-domain HELP: smtp-domain
@ -42,6 +42,8 @@ HELP: email
{ { $slot "cc" } "Carbon-copy. A sequence of e-mail addresses." } { { $slot "cc" } "Carbon-copy. A sequence of e-mail addresses." }
{ { $slot "bcc" } "Blind carbon-copy. A sequence of e-mail addresses." } { { $slot "bcc" } "Blind carbon-copy. A sequence of e-mail addresses." }
{ { $slot "subject" } "The subject of the e-mail. A string." } { { $slot "subject" } "The subject of the e-mail. A string." }
{ { $slot "content-type" } { "The MIME type of the body. A string, default is " { $snippet "text/plain" } "." } }
{ { $slot "encoding" } { "An encoding to send the body as. Default is " { $link utf8 } "." } }
{ { $slot "body" } " The body of the e-mail. A string." } { { $slot "body" } " The body of the e-mail. A string." }
} }
"The " { $slot "from" } " and " { $slot "to" } " slots are required; the rest are optional." "The " { $slot "from" } " and " { $slot "to" } " slots are required; the rest are optional."

View File

@ -16,7 +16,7 @@ IN: smtp.tests
[ { "hello" "." "world" } validate-message ] must-fail [ { "hello" "." "world" } validate-message ] must-fail
[ "aGVsbG8Kd29ybGQ=\r\n.\r\n" ] [ [ "aGVsbG8Kd29ybGQ=\r\n.\r\n" ] [
"hello\nworld" [ send-body ] with-string-writer T{ email { body "hello\nworld" } } [ send-body ] with-string-writer
] unit-test ] unit-test
[ { "500 syntax error" } <response> check-response ] [ { "500 syntax error" } <response> check-response ]
@ -51,7 +51,7 @@ IN: smtp.tests
[ [
{ {
{ "Content-Transfer-Encoding" "base64" } { "Content-Transfer-Encoding" "base64" }
{ "Content-Type" "Text/plain; charset=utf-8" } { "Content-Type" "text/plain; charset=UTF-8" }
{ "From" "Doug <erg@factorcode.org>" } { "From" "Doug <erg@factorcode.org>" }
{ "MIME-Version" "1.0" } { "MIME-Version" "1.0" }
{ "Subject" "Factor rules" } { "Subject" "Factor rules" }

View File

@ -1,12 +1,12 @@
! Copyright (C) 2007, 2008 Elie CHAFTARI, Dirk Vleugels, ! Copyright (C) 2007, 2008 Elie CHAFTARI, Dirk Vleugels,
! Slava Pestov, Doug Coleman. ! Slava Pestov, Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays namespaces make io io.encodings.string USING: arrays namespaces make io io.encodings.string io.encodings.utf8
io.encodings.utf8 io.timeouts io.sockets io.sockets.secure io.encodings.iana io.timeouts io.sockets io.sockets.secure
io.encodings.ascii kernel logging sequences combinators io.encodings.ascii kernel logging sequences combinators splitting
splitting assocs strings math.order math.parser random system assocs strings math.order math.parser random system calendar summary
calendar summary calendar.format accessors sets hashtables calendar.format accessors sets hashtables base64 debugger classes
base64 debugger classes prettyprint io.crlf ; prettyprint io.crlf words ;
IN: smtp IN: smtp
SYMBOL: smtp-domain SYMBOL: smtp-domain
@ -44,6 +44,8 @@ TUPLE: email
{ cc array } { cc array }
{ bcc array } { bcc array }
{ subject string } { subject string }
{ content-type string initial: "text/plain" }
{ encoding word initial: utf8 }
{ body string } ; { body string } ;
: <email> ( -- email ) email new ; inline : <email> ( -- email ) email new ; inline
@ -85,8 +87,8 @@ M: message-contains-dot summary ( obj -- string )
"." over member? "." over member?
[ message-contains-dot ] when ; [ message-contains-dot ] when ;
: send-body ( body -- ) : send-body ( email -- )
utf8 encode [ body>> ] [ encoding>> ] bi encode
>base64-lines write crlf >base64-lines write crlf
"." command ; "." command ;
@ -195,24 +197,23 @@ ERROR: invalid-header-string string ;
! This could be much smarter. ! This could be much smarter.
" " split1-last swap or "<" ?head drop ">" ?tail drop ; " " split1-last swap or "<" ?head drop ">" ?tail drop ;
: utf8-mime-header ( -- alist ) : email-content-type ( email -- content-type )
{ [ content-type>> ] [ encoding>> encoding>name ] bi "; charset=" glue ;
{ "MIME-Version" "1.0" }
{ "Content-Transfer-Encoding" "base64" }
{ "Content-Type" "Text/plain; charset=utf-8" }
} ;
: email>headers ( email -- hashtable ) : email>headers ( email -- assoc )
[ [
now timestamp>rfc822 "Date" set
message-id "Message-Id" set
"1.0" "MIME-Version" set
"base64" "Content-Transfer-Encoding" set
{ {
[ from>> "From" set ] [ from>> "From" set ]
[ to>> ", " join "To" set ] [ to>> ", " join "To" set ]
[ cc>> ", " join [ "Cc" set ] unless-empty ] [ cc>> ", " join [ "Cc" set ] unless-empty ]
[ subject>> "Subject" set ] [ subject>> "Subject" set ]
[ email-content-type "Content-Type" set ]
} cleave } cleave
now timestamp>rfc822 "Date" set ] { } make-assoc ;
message-id "Message-Id" set
] { } make-assoc utf8-mime-header append ;
: (send-email) ( headers email -- ) : (send-email) ( headers email -- )
[ [
@ -227,7 +228,7 @@ ERROR: invalid-header-string string ;
data get-ok data get-ok
swap write-headers swap write-headers
crlf crlf
body>> send-body get-ok send-body get-ok
quit get-ok quit get-ok
] with-smtp-connection ; ] with-smtp-connection ;

View File

@ -14,7 +14,7 @@ HELP: compare-slots
HELP: sort-by-slots HELP: sort-by-slots
{ $values { $values
{ "seq" sequence } { "sort-specs" "a sequence of accessors ending with a comparator" } { "seq" sequence } { "sort-specs" "a sequence of accessors ending with a comparator" }
{ "sortedseq" sequence } { "seq'" sequence }
} }
{ $description "Sorts a sequence of tuples by the sort-specs in " { $snippet "sort-spec" } ". A sort-spec is a sequence of slot accessors ending in a comparator." } { $description "Sorts a sequence of tuples by the sort-specs in " { $snippet "sort-spec" } ". A sort-spec is a sequence of slot accessors ending in a comparator." }
{ $examples { $examples
@ -42,7 +42,7 @@ HELP: split-by-slots
HELP: sort-by HELP: sort-by
{ $values { $values
{ "seq" sequence } { "sort-seq" "a sequence of comparators" } { "seq" sequence } { "sort-seq" "a sequence of comparators" }
{ "sortedseq" sequence } { "seq'" sequence }
} }
{ $description "Sorts a sequence by comparing elements by comparators, using subsequent comparators when there is a tie." } ; { $description "Sorts a sequence by comparing elements by comparators, using subsequent comparators when there is a tie." } ;

View File

@ -159,3 +159,15 @@ TUPLE: tuple2 d ;
{ { 3 2 1 } { 1 2 3 } { 1 3 2 } { 1 } } { { 3 2 1 } { 1 2 3 } { 1 3 2 } { 1 } }
{ length-test<=> <=> } sort-by { length-test<=> <=> } sort-by
] unit-test ] unit-test
[ { { 0 1 } { 1 2 } { 1 1 } { 3 2 } } ]
[
{ { 3 2 } { 1 2 } { 0 1 } { 1 1 } }
{ length-test<=> <=> } sort-keys-by
] unit-test
[ { { 0 1 } { 1 1 } { 3 2 } { 1 2 } } ]
[
{ { 3 2 } { 1 2 } { 0 1 } { 1 1 } }
{ length-test<=> <=> } sort-values-by
] unit-test

View File

@ -8,12 +8,13 @@ IN: sorting.slots
<PRIVATE <PRIVATE
: short-circuit-comparator ( obj1 obj2 word -- comparator/? ) : short-circuit-comparator ( obj1 obj2 word -- comparator/? )
execute dup +eq+ eq? [ drop f ] when ; inline execute( obj1 obj2 -- obj3 )
dup +eq+ eq? [ drop f ] when ; inline
: slot-comparator ( seq -- quot ) : slot-comparator ( seq -- quot )
[ [
but-last-slice but-last-slice
[ '[ [ _ execute ] bi@ ] ] map concat [ '[ [ _ execute( tuple -- value ) ] bi@ ] ] map concat
] [ ] [
peek peek
'[ @ _ short-circuit-comparator ] '[ @ _ short-circuit-comparator ]
@ -25,21 +26,22 @@ MACRO: compare-slots ( sort-specs -- <=> )
#! sort-spec: { accessors comparator } #! sort-spec: { accessors comparator }
[ slot-comparator ] map '[ _ 2|| +eq+ or ] ; [ slot-comparator ] map '[ _ 2|| +eq+ or ] ;
MACRO: sort-by-slots ( sort-specs -- quot ) : sort-by-slots ( seq sort-specs -- seq' )
'[ [ _ compare-slots ] sort ] ; '[ _ compare-slots ] sort ;
MACRO: compare-seq ( seq -- quot ) MACRO: compare-seq ( seq -- quot )
[ '[ _ short-circuit-comparator ] ] map '[ _ 2|| +eq+ or ] ; [ '[ _ short-circuit-comparator ] ] map '[ _ 2|| +eq+ or ] ;
MACRO: sort-by ( sort-seq -- quot ) : sort-by ( seq sort-seq -- seq' )
'[ [ _ compare-seq ] sort ] ; '[ _ compare-seq ] sort ;
MACRO: sort-keys-by ( sort-seq -- quot ) : sort-keys-by ( seq sort-seq -- seq' )
'[ [ first ] bi@ _ compare-seq ] sort ; '[ [ first ] bi@ _ compare-seq ] sort ;
MACRO: sort-values-by ( sort-seq -- quot ) : sort-values-by ( seq sort-seq -- seq' )
'[ [ second ] bi@ _ compare-seq ] sort ; '[ [ second ] bi@ _ compare-seq ] sort ;
MACRO: split-by-slots ( accessor-seqs -- quot ) MACRO: split-by-slots ( accessor-seqs -- quot )
[ [ '[ [ _ execute ] bi@ ] ] map concat [ = ] compose ] map [ [ '[ [ _ execute( tuple -- value ) ] bi@ ] ] map concat
[ = ] compose ] map
'[ [ _ 2&& ] slice monotonic-slice ] ; '[ [ _ 2&& ] slice monotonic-slice ] ;

View File

@ -524,7 +524,7 @@ ERROR: custom-error ;
{ 2 1 } [ [ + ] inference-invalidation-b ] must-infer-as { 2 1 } [ [ + ] inference-invalidation-b ] must-infer-as
[ ] [ "IN: stack-checker.tests : inference-invalidation-a ( -- a b ) 1 2 ;" (( -- )) eval ] unit-test [ ] [ "IN: stack-checker.tests : inference-invalidation-a ( -- a b ) 1 2 ;" eval( -- ) ] unit-test
[ 3 ] [ inference-invalidation-c ] unit-test [ 3 ] [ inference-invalidation-c ] unit-test
@ -536,7 +536,7 @@ M: object inference-invalidation-d inference-invalidation-c 2drop ;
\ inference-invalidation-d must-infer \ inference-invalidation-d must-infer
[ ] [ "IN: stack-checker.tests : inference-invalidation-a ( -- ) ;" (( -- )) eval ] unit-test [ ] [ "IN: stack-checker.tests : inference-invalidation-a ( -- ) ;" eval( -- ) ] unit-test
[ [ inference-invalidation-d ] infer ] must-fail [ [ inference-invalidation-d ] infer ] must-fail

View File

@ -18,7 +18,7 @@ M: integer some-generic 1+ ;
[ 4 ] [ 3 some-generic ] unit-test [ 4 ] [ 3 some-generic ] unit-test
[ ] [ "IN: tools.annotations.tests USE: math M: integer some-generic 1- ;" (( -- )) eval ] unit-test [ ] [ "IN: tools.annotations.tests USE: math M: integer some-generic 1- ;" eval( -- ) ] unit-test
[ 2 ] [ 3 some-generic ] unit-test [ 2 ] [ 3 some-generic ] unit-test
@ -33,7 +33,7 @@ M: object another-generic ;
\ another-generic watch \ another-generic watch
[ ] [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" (( -- )) eval ] unit-test [ ] [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" eval( -- ) ] unit-test
[ ] [ \ another-generic reset ] unit-test [ ] [ \ another-generic reset ] unit-test

View File

@ -357,7 +357,7 @@ IN: tools.deploy.shaker
V{ } set-namestack V{ } set-namestack
V{ } set-catchstack V{ } set-catchstack
"Saving final image" show "Saving final image" show
[ save-image-and-exit ] call-clear ; save-image-and-exit ;
SYMBOL: deploy-vocab SYMBOL: deploy-vocab
@ -421,10 +421,10 @@ SYMBOL: deploy-vocab
: deploy-error-handler ( quot -- ) : deploy-error-handler ( quot -- )
[ [
strip-debugger? strip-debugger?
[ error-continuation get call>> callstack>array die ] [ error-continuation get call>> callstack>array die 1 exit ]
! Don't reference these words literally, if we're stripping the ! Don't reference these words literally, if we're stripping the
! debugger out we don't want to load the prettyprinter at all ! debugger out we don't want to load the prettyprinter at all
[ [:c] execute nl [print-error] execute flush ] if [ [:c] execute( -- ) nl [print-error] execute( error -- ) flush ] if
1 exit 1 exit
] recover ; inline ] recover ; inline

View File

@ -1,5 +1,35 @@
IN: tools.errors IN: tools.errors
USING: help.markup help.syntax source-files.errors ; USING: help.markup help.syntax source-files.errors words io
compiler.errors ;
ARTICLE: "compiler-errors" "Compiler warnings and errors"
"After loading a vocabulary, you might see messages like:"
{ $code
":errors - print 2 compiler errors"
":warnings - print 50 compiler warnings"
}
"These messages arise from the compiler's stack effect checker. Production code should not have any warnings and errors in it. Warning and error conditions are documented in " { $link "inference-errors" } "."
$nl
"Words to view warnings and errors:"
{ $subsection :warnings }
{ $subsection :errors }
{ $subsection :linkage }
"Compiler warnings and errors are reported using the " { $link "tools.errors" } " mechanism and are shown in the " { $link "ui.tools.error-list" } "." ;
HELP: compiler-error
{ $values { "error" "an error" } { "word" word } }
{ $description "Saves the error for future persual via " { $link :errors } ", " { $link :warnings } " and " { $link :linkage } "." } ;
HELP: :errors
{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ;
HELP: :warnings
{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ;
HELP: :linkage
{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ;
{ :errors :warnings :linkage } related-words
HELP: errors. HELP: errors.
{ $values { "errors" "a sequence of " { $link source-file-error } " instances" } } { $values { "errors" "a sequence of " { $link source-file-error } " instances" } }

View File

@ -1,35 +1,28 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs debugger io kernel sequences source-files.errors USING: assocs debugger io kernel sequences source-files.errors
summary accessors continuations make math.parser io.styles namespaces ; summary accessors continuations make math.parser io.styles namespaces
compiler.errors ;
IN: tools.errors IN: tools.errors
#! Tools for source-files.errors. Used by tools.tests and others #! Tools for source-files.errors. Used by tools.tests and others
#! for error reporting #! for error reporting
M: source-file-error summary
error>> summary ;
M: source-file-error compute-restarts M: source-file-error compute-restarts
error>> compute-restarts ; error>> compute-restarts ;
M: source-file-error error-help M: source-file-error error-help
error>> error-help ; error>> error-help ;
M: source-file-error error. M: source-file-error summary
[ [
[ [ file>> [ % ": " % ] [ "<Listener input>" % ] if* ]
[ [ line#>> [ # ] when* ] bi
[ file>> [ % ": " % ] when* ]
[ line#>> [ # "\n" % ] when* ] bi
] "" make ] "" make
] [ ;
[
presented set M: source-file-error error.
bold font-style set [ summary print nl ] [ error>> error. ] bi ;
] H{ } make-assoc
] bi format
] [ error>> error. ] bi ;
: errors. ( errors -- ) : errors. ( errors -- )
group-by-source-file sort-errors group-by-source-file sort-errors
@ -38,3 +31,12 @@ M: source-file-error error.
[ [ nl ] [ error. ] interleave ] [ [ nl ] [ error. ] interleave ]
bi* bi*
] assoc-each ; ] assoc-each ;
: compiler-errors. ( type -- )
errors-of-type values errors. ;
: :errors ( -- ) +compiler-error+ compiler-errors. ;
: :warnings ( -- ) +compiler-warning+ compiler-errors. ;
: :linkage ( -- ) +linkage-error+ compiler-errors. ;

View File

@ -24,6 +24,9 @@ ERROR: no-vocab vocab ;
: contains-separator? ( string -- ? ) [ path-separator? ] any? ; : contains-separator? ( string -- ? ) [ path-separator? ] any? ;
: ensure-vocab-exists ( string -- string )
dup vocabs member? [ no-vocab ] unless ;
: check-vocab-name ( string -- string ) : check-vocab-name ( string -- string )
[ ] [ ]
[ contains-dot? [ vocab-name-contains-dot ] when ] [ contains-dot? [ vocab-name-contains-dot ] when ]
@ -234,6 +237,7 @@ PRIVATE>
[ (help.) ] [ nl vocabulary>> link-vocab ] bi ; [ (help.) ] [ nl vocabulary>> link-vocab ] bi ;
: scaffold-help ( vocab -- ) : scaffold-help ( vocab -- )
ensure-vocab-exists
[ [
dup "-docs.factor" vocab/suffix>path scaffolding? [ dup "-docs.factor" vocab/suffix>path scaffolding? [
set-scaffold-docs-file set-scaffold-docs-file
@ -268,6 +272,7 @@ PRIVATE>
PRIVATE> PRIVATE>
: scaffold-tests ( vocab -- ) : scaffold-tests ( vocab -- )
ensure-vocab-exists
dup "-tests.factor" vocab/suffix>path dup "-tests.factor" vocab/suffix>path
scaffolding? [ scaffolding? [
set-scaffold-tests-file set-scaffold-tests-file

View File

@ -129,13 +129,13 @@ TEST: must-infer
TEST: must-fail-with TEST: must-fail-with
TEST: must-fail TEST: must-fail
M: test-failure summary
asset>> [ [ experiment. ] with-string-writer ] [ "Top-level form" ] if* ;
M: test-failure error. ( error -- ) M: test-failure error. ( error -- )
[ call-next-method ] {
[ summary print nl ]
[ asset>> [ experiment. nl ] when* ]
[ error>> error. ]
[ traceback-button. ] [ traceback-button. ]
bi ; } cleave ;
: :test-failures ( -- ) test-failures get errors. ; : :test-failures ( -- ) test-failures get errors. ;

View File

@ -3,11 +3,11 @@
USING: accessors alien alien.c-types arrays ui ui.private ui.gadgets USING: accessors alien alien.c-types arrays ui ui.private ui.gadgets
ui.gadgets.private ui.gestures ui.backend ui.clipboards ui.gadgets.private ui.gestures ui.backend ui.clipboards
ui.gadgets.worlds ui.render ui.event-loop assocs kernel math ui.gadgets.worlds ui.render ui.event-loop assocs kernel math
namespaces opengl sequences strings x11.xlib x11.events x11.xim namespaces opengl sequences strings x11 x11.xlib x11.events x11.xim
x11.glx x11.clipboard x11.constants x11.windows io.encodings.string x11.glx x11.clipboard x11.constants x11.windows x11.io
io.encodings.ascii io.encodings.utf8 combinators command-line io.encodings.string io.encodings.ascii io.encodings.utf8 combinators
math.vectors classes.tuple opengl.gl threads math.rectangles command-line math.vectors classes.tuple opengl.gl threads
environment ascii ; math.rectangles environment ascii ;
IN: ui.backend.x11 IN: ui.backend.x11
SINGLETON: x11-ui-backend SINGLETON: x11-ui-backend
@ -196,7 +196,7 @@ M: world client-event
QueuedAfterFlush events-queued 0 > [ QueuedAfterFlush events-queued 0 > [
next-event dup next-event dup
None XFilterEvent 0 = [ drop wait-event ] unless None XFilterEvent 0 = [ drop wait-event ] unless
] [ ui-wait wait-event ] if ; ] [ wait-for-display wait-event ] if ;
M: x11-ui-backend do-events M: x11-ui-backend do-events
wait-event dup XAnyEvent-window window dup wait-event dup XAnyEvent-window window dup

View File

@ -27,7 +27,7 @@ INSTANCE: fake-break word-break
[ { 0 0 } ] [ "a" get loc>> ] unit-test [ { 0 0 } ] [ "a" get loc>> ] unit-test
[ { 45 15 } ] [ "b" get loc>> ] unit-test [ { 45 7 } ] [ "b" get loc>> ] unit-test
[ { 0 30 } ] [ "c" get loc>> ] unit-test [ { 0 30 } ] [ "c" get loc>> ] unit-test

View File

@ -26,7 +26,7 @@ MEMO: error-icon ( type -- image-name )
: <error-toggle> ( -- model gadget ) : <error-toggle> ( -- model gadget )
#! Linkage errors are not shown by default. #! Linkage errors are not shown by default.
error-types get keys [ dup +linkage-error+ eq? not <model> ] { } map>assoc error-types get [ fatal?>> <model> ] assoc-map
[ [ [ error-icon ] dip ] assoc-map <checkboxes> ] [ [ [ error-icon ] dip ] assoc-map <checkboxes> ]
[ <mapping> ] bi ; [ <mapping> ] bi ;
@ -80,7 +80,7 @@ M: error-renderer row-columns
{ {
[ error-type error-icon ] [ error-type error-icon ]
[ line#>> [ number>string ] [ "" ] if* ] [ line#>> [ number>string ] [ "" ] if* ]
[ asset>> unparse-short ] [ asset>> [ unparse-short ] [ "" ] if* ]
[ error>> summary ] [ error>> summary ]
} cleave } cleave
] output>array ; ] output>array ;

View File

@ -358,9 +358,8 @@ interactor "completion" f {
} define-command-map } define-command-map
: ui-error-summary ( -- ) : ui-error-summary ( -- )
all-errors [ error-counts keys [
[ error-type ] map prune [ icon>> 1array \ $image prefix " " 2array ] { } map-as
[ error-icon-path 1array \ $image prefix " " 2array ] { } map-as
{ "Press " { $command tool "common" show-error-list } " to view errors." } { "Press " { $command tool "common" show-error-list } " to view errors." }
append print-element nl append print-element nl
] unless-empty ; ] unless-empty ;

View File

@ -7,7 +7,11 @@ HELP: url-decode
HELP: url-encode HELP: url-encode
{ $values { "str" string } { "encoded" string } } { $values { "str" string } { "encoded" string } }
{ $description "URL-encodes a string." } ; { $description "URL-encodes a string, excluding certain characters, such as \"/\"." } ;
HELP: url-encode-full
{ $values { "str" string } { "encoded" string } }
{ $description "URL-encodes a string, including all reserved characters, such as \"/\"." } ;
HELP: url-quotable? HELP: url-quotable?
{ $values { "ch" "a character" } { "?" "a boolean" } } { $values { "ch" "a character" } { "?" "a boolean" } }

View File

@ -14,6 +14,25 @@ IN: urls.encoding
[ "/_-.:" member? ] [ "/_-.:" member? ]
} 1|| ; foldable } 1|| ; foldable
! see http://tools.ietf.org/html/rfc3986#section-2.2
: gen-delim? ( ch -- ? )
":/?#[]@" member? ; foldable
: sub-delim? ( ch -- ? )
"!$&'()*+,;=" member? ; foldable
: reserved? ( ch -- ? )
[ gen-delim? ] [ sub-delim? ] bi or ; foldable
! see http://tools.ietf.org/html/rfc3986#section-2.3
: unreserved? ( ch -- ? )
{
[ letter? ]
[ LETTER? ]
[ digit? ]
[ "-._~" member? ]
} 1|| ; foldable
<PRIVATE <PRIVATE
: push-utf8 ( ch -- ) : push-utf8 ( ch -- )
@ -27,6 +46,11 @@ PRIVATE>
[ dup url-quotable? [ , ] [ push-utf8 ] if ] each [ dup url-quotable? [ , ] [ push-utf8 ] if ] each
] "" make ; ] "" make ;
: url-encode-full ( str -- encoded )
[
[ dup unreserved? [ , ] [ push-utf8 ] if ] each
] "" make ;
<PRIVATE <PRIVATE
: url-decode-hex ( index str -- ) : url-decode-hex ( index str -- )

View File

@ -1,5 +1,6 @@
USING: alien.syntax kernel math windows.types math.bitwise ; USING: alien.syntax kernel math windows.types math.bitwise ;
IN: windows.advapi32 IN: windows.advapi32
LIBRARY: advapi32 LIBRARY: advapi32
CONSTANT: PROV_RSA_FULL 1 CONSTANT: PROV_RSA_FULL 1
@ -122,6 +123,34 @@ C-STRUCT: ACCESS_ALLOWED_CALLBACK_ACE
TYPEDEF: ACCESS_ALLOWED_CALLBACK_ACE* PACCESS_ALLOWED_CALLBACK_ACE TYPEDEF: ACCESS_ALLOWED_CALLBACK_ACE* PACCESS_ALLOWED_CALLBACK_ACE
C-STRUCT: SECURITY_DESCRIPTOR
{ "UCHAR" "Revision" }
{ "UCHAR" "Sbz1" }
{ "WORD" "Control" }
{ "PVOID" "Owner" }
{ "PVOID" "Group" }
{ "PACL" "Sacl" }
{ "PACL" "Dacl" } ;
TYPEDEF: SECURITY_DESCRIPTOR* PSECURITY_DESCRIPTOR
CONSTANT: SE_OWNER_DEFAULTED 1
CONSTANT: SE_GROUP_DEFAULTED 2
CONSTANT: SE_DACL_PRESENT 4
CONSTANT: SE_DACL_DEFAULTED 8
CONSTANT: SE_SACL_PRESENT 16
CONSTANT: SE_SACL_DEFAULTED 32
CONSTANT: SE_DACL_AUTO_INHERIT_REQ 256
CONSTANT: SE_SACL_AUTO_INHERIT_REQ 512
CONSTANT: SE_DACL_AUTO_INHERITED 1024
CONSTANT: SE_SACL_AUTO_INHERITED 2048
CONSTANT: SE_DACL_PROTECTED 4096
CONSTANT: SE_SACL_PROTECTED 8192
CONSTANT: SE_SELF_RELATIVE 32768
TYPEDEF: DWORD SECURITY_DESCRIPTOR_CONTROL
TYPEDEF: SECURITY_DESCRIPTOR_CONTROL* PSECURITY_DESCRIPTOR_CONTROL
! typedef enum _TOKEN_INFORMATION_CLASS { ! typedef enum _TOKEN_INFORMATION_CLASS {
CONSTANT: TokenUser 1 CONSTANT: TokenUser 1
@ -141,6 +170,140 @@ CONSTANT: TokenSessionReference 14
CONSTANT: TokenSandBoxInert 15 CONSTANT: TokenSandBoxInert 15
! } TOKEN_INFORMATION_CLASS; ! } TOKEN_INFORMATION_CLASS;
TYPEDEF: DWORD ACCESS_MODE
C-ENUM:
NOT_USED_ACCESS
GRANT_ACCESS
SET_ACCESS
DENY_ACCESS
REVOKE_ACCESS
SET_AUDIT_SUCCESS
SET_AUDIT_FAILURE ;
TYPEDEF: DWORD MULTIPLE_TRUSTEE_OPERATION
C-ENUM:
NO_MULTIPLE_TRUSTEE
TRUSTEE_IS_IMPERSONATE ;
TYPEDEF: DWORD TRUSTEE_FORM
C-ENUM:
TRUSTEE_IS_SID
TRUSTEE_IS_NAME
TRUSTEE_BAD_FORM
TRUSTEE_IS_OBJECTS_AND_SID
TRUSTEE_IS_OBJECTS_AND_NAME ;
TYPEDEF: DWORD TRUSTEE_TYPE
C-ENUM:
TRUSTEE_IS_UNKNOWN
TRUSTEE_IS_USER
TRUSTEE_IS_GROUP
TRUSTEE_IS_DOMAIN
TRUSTEE_IS_ALIAS
TRUSTEE_IS_WELL_KNOWN_GROUP
TRUSTEE_IS_DELETED
TRUSTEE_IS_INVALID
TRUSTEE_IS_COMPUTER ;
TYPEDEF: DWORD SE_OBJECT_TYPE
C-ENUM:
SE_UNKNOWN_OBJECT_TYPE
SE_FILE_OBJECT
SE_SERVICE
SE_PRINTER
SE_REGISTRY_KEY
SE_LMSHARE
SE_KERNEL_OBJECT
SE_WINDOW_OBJECT
SE_DS_OBJECT
SE_DS_OBJECT_ALL
SE_PROVIDER_DEFINED_OBJECT
SE_WMIGUID_OBJECT
SE_REGISTRY_WOW64_32KEY ;
TYPEDEF: TRUSTEE* PTRUSTEE
C-STRUCT: TRUSTEE
{ "PTRUSTEE" "pMultipleTrustee" }
{ "MULTIPLE_TRUSTEE_OPERATION" "MultipleTrusteeOperation" }
{ "TRUSTEE_FORM" "TrusteeForm" }
{ "TRUSTEE_TYPE" "TrusteeType" }
{ "LPTSTR" "ptstrName" } ;
C-STRUCT: EXPLICIT_ACCESS
{ "DWORD" "grfAccessPermissions" }
{ "ACCESS_MODE" "grfAccessMode" }
{ "DWORD" "grfInheritance" }
{ "TRUSTEE" "Trustee" } ;
C-STRUCT: SID_IDENTIFIER_AUTHORITY
{ { "BYTE" 6 } "Value" } ;
TYPEDEF: SID_IDENTIFIER_AUTHORITY* PSID_IDENTIFIER_AUTHORITY
CONSTANT: SECURITY_NULL_SID_AUTHORITY 0
CONSTANT: SECURITY_WORLD_SID_AUTHORITY 1
CONSTANT: SECURITY_LOCAL_SID_AUTHORITY 2
CONSTANT: SECURITY_CREATOR_SID_AUTHORITY 3
CONSTANT: SECURITY_NON_UNIQUE_AUTHORITY 4
CONSTANT: SECURITY_NT_AUTHORITY 5
CONSTANT: SECURITY_RESOURCE_MANAGER_AUTHORITY 6
CONSTANT: SECURITY_NULL_RID 0
CONSTANT: SECURITY_WORLD_RID 0
CONSTANT: SECURITY_LOCAL_RID 0
CONSTANT: SECURITY_CREATOR_OWNER_RID 0
CONSTANT: SECURITY_CREATOR_GROUP_RID 1
CONSTANT: SECURITY_CREATOR_OWNER_SERVER_RID 2
CONSTANT: SECURITY_CREATOR_GROUP_SERVER_RID 3
CONSTANT: SECURITY_DIALUP_RID 1
CONSTANT: SECURITY_NETWORK_RID 2
CONSTANT: SECURITY_BATCH_RID 3
CONSTANT: SECURITY_INTERACTIVE_RID 4
CONSTANT: SECURITY_SERVICE_RID 6
CONSTANT: SECURITY_ANONYMOUS_LOGON_RID 7
CONSTANT: SECURITY_PROXY_RID 8
CONSTANT: SECURITY_SERVER_LOGON_RID 9
CONSTANT: SECURITY_PRINCIPAL_SELF_RID 10
CONSTANT: SECURITY_AUTHENTICATED_USER_RID 11
CONSTANT: SECURITY_LOGON_IDS_RID 5
CONSTANT: SECURITY_LOGON_IDS_RID_COUNT 3
CONSTANT: SECURITY_LOCAL_SYSTEM_RID 18
CONSTANT: SECURITY_NT_NON_UNIQUE 21
CONSTANT: SECURITY_BUILTIN_DOMAIN_RID 32
CONSTANT: DOMAIN_USER_RID_ADMIN 500
CONSTANT: DOMAIN_USER_RID_GUEST 501
CONSTANT: DOMAIN_GROUP_RID_ADMINS 512
CONSTANT: DOMAIN_GROUP_RID_USERS 513
CONSTANT: DOMAIN_GROUP_RID_GUESTS 514
CONSTANT: DOMAIN_ALIAS_RID_ADMINS 544
CONSTANT: DOMAIN_ALIAS_RID_USERS 545
CONSTANT: DOMAIN_ALIAS_RID_GUESTS 546
CONSTANT: DOMAIN_ALIAS_RID_POWER_USERS 547
CONSTANT: DOMAIN_ALIAS_RID_ACCOUNT_OPS 548
CONSTANT: DOMAIN_ALIAS_RID_SYSTEM_OPS 549
CONSTANT: DOMAIN_ALIAS_RID_PRINT_OPS 550
CONSTANT: DOMAIN_ALIAS_RID_BACKUP_OPS 551
CONSTANT: DOMAIN_ALIAS_RID_REPLICATOR 552
CONSTANT: SE_GROUP_MANDATORY 1
CONSTANT: SE_GROUP_ENABLED_BY_DEFAULT 2
CONSTANT: SE_GROUP_ENABLED 4
CONSTANT: SE_GROUP_OWNER 8
CONSTANT: SE_GROUP_LOGON_ID -1073741824
! SID is a variable length structure
TYPEDEF: void* PSID
TYPEDEF: EXPLICIT_ACCESS* PEXPLICIT_ACCESS
TYPEDEF: DWORD SECURITY_INFORMATION
TYPEDEF: SECURITY_INFORMATION* PSECURITY_INFORMATION
CONSTANT: OWNER_SECURITY_INFORMATION 1
CONSTANT: GROUP_SECURITY_INFORMATION 2
CONSTANT: DACL_SECURITY_INFORMATION 4
CONSTANT: SACL_SECURITY_INFORMATION 8
CONSTANT: DELETE HEX: 00010000 CONSTANT: DELETE HEX: 00010000
CONSTANT: READ_CONTROL HEX: 00020000 CONSTANT: READ_CONTROL HEX: 00020000
CONSTANT: WRITE_DAC HEX: 00040000 CONSTANT: WRITE_DAC HEX: 00040000
@ -187,6 +350,34 @@ CONSTANT: TOKEN_ADJUST_DEFAULT HEX: 0080
TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT
} flags ; foldable } flags ; foldable
CONSTANT: HKEY_CLASSES_ROOT 1
CONSTANT: HKEY_CURRENT_CONFIG 2
CONSTANT: HKEY_CURRENT_USER 3
CONSTANT: HKEY_LOCAL_MACHINE 4
CONSTANT: HKEY_USERS 5
CONSTANT: KEY_ALL_ACCESS HEX: 0001
CONSTANT: KEY_CREATE_LINK HEX: 0002
CONSTANT: KEY_CREATE_SUB_KEY HEX: 0004
CONSTANT: KEY_ENUMERATE_SUB_KEYS HEX: 0008
CONSTANT: KEY_EXECUTE HEX: 0010
CONSTANT: KEY_NOTIFY HEX: 0020
CONSTANT: KEY_QUERY_VALUE HEX: 0040
CONSTANT: KEY_READ HEX: 0080
CONSTANT: KEY_SET_VALUE HEX: 0100
CONSTANT: KEY_WOW64_64KEY HEX: 0200
CONSTANT: KEY_WOW64_32KEY HEX: 0400
CONSTANT: KEY_WRITE HEX: 0800
CONSTANT: REG_BINARY 1
CONSTANT: REG_DWORD 2
CONSTANT: REG_EXPAND_SZ 3
CONSTANT: REG_MULTI_SZ 4
CONSTANT: REG_QWORD 5
CONSTANT: REG_SZ 6
TYPEDEF: DWORD REGSAM
! : I_ScGetCurrentGroupStateW ; ! : I_ScGetCurrentGroupStateW ;
! : A_SHAFinal ; ! : A_SHAFinal ;
@ -224,7 +415,19 @@ FUNCTION: BOOL AdjustTokenPrivileges ( HANDLE TokenHandle,
PTOKEN_PRIVILEGES PreviousState, PTOKEN_PRIVILEGES PreviousState,
PDWORD ReturnLength ) ; PDWORD ReturnLength ) ;
! : AllocateAndInitializeSid ; FUNCTION: BOOL AllocateAndInitializeSid (
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
BYTE nSubAuthorityCount,
DWORD dwSubAuthority0,
DWORD dwSubAuthority1,
DWORD dwSubAuthority2,
DWORD dwSubAuthority3,
DWORD dwSubAuthority4,
DWORD dwSubAuthority5,
DWORD dwSubAuthority6,
DWORD dwSubAuthority7,
PSID* pSid ) ;
! : AllocateLocallyUniqueId ; ! : AllocateLocallyUniqueId ;
! : AreAllAccessesGranted ; ! : AreAllAccessesGranted ;
! : AreAnyAccessesGranted ; ! : AreAnyAccessesGranted ;
@ -442,7 +645,8 @@ FUNCTION: BOOL CryptReleaseContext ( HCRYPTPROV hProv, DWORD dwFlags ) ;
! : GetExplicitEntriesFromAclA ; ! : GetExplicitEntriesFromAclA ;
! : GetExplicitEntriesFromAclW ; ! : GetExplicitEntriesFromAclW ;
! : GetFileSecurityA ; ! : GetFileSecurityA ;
! : GetFileSecurityW ; FUNCTION: BOOL GetFileSecurityW ( LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded ) ;
ALIAS: GetFileSecurity GetFileSecurityW
! : GetInformationCodeAuthzLevelW ; ! : GetInformationCodeAuthzLevelW ;
! : GetInformationCodeAuthzPolicyW ; ! : GetInformationCodeAuthzPolicyW ;
! : GetInheritanceSourceA ; ! : GetInheritanceSourceA ;
@ -459,19 +663,20 @@ FUNCTION: BOOL CryptReleaseContext ( HCRYPTPROV hProv, DWORD dwFlags ) ;
! : GetMultipleTrusteeW ; ! : GetMultipleTrusteeW ;
! : GetNamedSecurityInfoA ; ! : GetNamedSecurityInfoA ;
! : GetNamedSecurityInfoExA ; ! : GetNamedSecurityInfoExA ;
! : GetNamedSecurityInfoExW ; ! FUNCTION: DWORD GetNamedSecurityInfoExW
! : GetNamedSecurityInfoW ; FUNCTION: DWORD GetNamedSecurityInfoW ( LPTSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl, PACL* ppSacl, PSECURITY_DESCRIPTOR* ppSecurityDescriptor ) ;
ALIAS: GetNamedSecurityInfo GetNamedSecurityInfoW
! : GetNumberOfEventLogRecords ; ! : GetNumberOfEventLogRecords ;
! : GetOldestEventLogRecord ; ! : GetOldestEventLogRecord ;
! : GetOverlappedAccessResults ; ! : GetOverlappedAccessResults ;
! : GetPrivateObjectSecurity ; ! : GetPrivateObjectSecurity ;
! : GetSecurityDescriptorControl ; FUNCTION: BOOL GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor, PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision ) ;
! : GetSecurityDescriptorDacl ; FUNCTION: BOOL GetSecurityDescriptorDacl ( PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL* pDacl, LPBOOL lpDaclDefaulted ) ;
! : GetSecurityDescriptorGroup ; FUNCTION: BOOL GetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID* pGroup, LPBOOL lpGroupDefaulted ) ;
! : GetSecurityDescriptorLength ; FUNCTION: BOOL GetSecurityDescriptorLength ( PSECURITY_DESCRIPTOR pSecurityDescriptor ) ;
! : GetSecurityDescriptorOwner ; FUNCTION: BOOL GetSecurityDescriptorOwner ( PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID* pOwner, LPBOOL lpOwnerDefaulted ) ;
! : GetSecurityDescriptorRMControl ; FUNCTION: BOOL GetSecurityDescriptorRMControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor, PUCHAR RMControl ) ;
! : GetSecurityDescriptorSacl ; FUNCTION: BOOL GetSecurityDescriptorSacl ( PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbSaclPresent, PACL* pSacl, LPBOOL lpSaclDefaulted ) ;
! : GetSecurityInfo ; ! : GetSecurityInfo ;
! : GetSecurityInfoExA ; ! : GetSecurityInfoExA ;
! : GetSecurityInfoExW ; ! : GetSecurityInfoExW ;
@ -510,7 +715,7 @@ ALIAS: GetUserName GetUserNameW
! : ImpersonateNamedPipeClient ; ! : ImpersonateNamedPipeClient ;
! : ImpersonateSelf ; ! : ImpersonateSelf ;
FUNCTION: BOOL InitializeAcl ( PACL pAcl, DWORD nAclLength, DWORD dwAclRevision ) ; FUNCTION: BOOL InitializeAcl ( PACL pAcl, DWORD nAclLength, DWORD dwAclRevision ) ;
! : InitializeSecurityDescriptor ; FUNCTION: BOOL InitializeSecurityDescriptor ( PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision ) ;
! : InitializeSid ; ! : InitializeSid ;
! : InitiateSystemShutdownA ; ! : InitiateSystemShutdownA ;
! : InitiateSystemShutdownExA ; ! : InitiateSystemShutdownExA ;
@ -674,8 +879,8 @@ FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL
! : RegConnectRegistryW ; ! : RegConnectRegistryW ;
! : RegCreateKeyA ; ! : RegCreateKeyA ;
! : RegCreateKeyExA ; ! : RegCreateKeyExA ;
! : RegCreateKeyExW ; FUNCTION: LONG RegCreateKeyExW ( HKEY hKey, LPCTSTR lpSubKey, DWORD Reserved, LPTSTR lpClass, DWORD dwOptions, REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition ) ;
! : RegCreateKeyW ; ! : RegCreateKeyW
! : RegDeleteKeyA ; ! : RegDeleteKeyA ;
! : RegDeleteKeyW ; ! : RegDeleteKeyW ;
! : RegDeleteValueA ; ! : RegDeleteValueA ;
@ -692,7 +897,7 @@ FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL
! : RegLoadKeyA ; ! : RegLoadKeyA ;
! : RegLoadKeyW ; ! : RegLoadKeyW ;
! : RegNotifyChangeKeyValue ; ! : RegNotifyChangeKeyValue ;
! : RegOpenCurrentUser ; FUNCTION: LONG RegOpenCurrentUser ( REGSAM samDesired, PHKEY phkResult ) ;
! : RegOpenKeyA ; ! : RegOpenKeyA ;
! : RegOpenKeyExA ; ! : RegOpenKeyExA ;
! : RegOpenKeyExW ; ! : RegOpenKeyExW ;
@ -705,7 +910,7 @@ FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL
! : RegQueryMultipleValuesW ; ! : RegQueryMultipleValuesW ;
! : RegQueryValueA ; ! : RegQueryValueA ;
! : RegQueryValueExA ; ! : RegQueryValueExA ;
! : RegQueryValueExW ; FUNCTION: LONG RegQueryValueExW ( HKEY hKey, LPCTSTR lpValueName, LPWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData ) ;
! : RegQueryValueW ; ! : RegQueryValueW ;
! : RegReplaceKeyA ; ! : RegReplaceKeyA ;
! : RegReplaceKeyW ; ! : RegReplaceKeyW ;
@ -756,7 +961,8 @@ FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL
! : SetEntriesInAccessListA ; ! : SetEntriesInAccessListA ;
! : SetEntriesInAccessListW ; ! : SetEntriesInAccessListW ;
! : SetEntriesInAclA ; ! : SetEntriesInAclA ;
! : SetEntriesInAclW ; FUNCTION: DWORD SetEntriesInAclW ( ULONG cCountOfExplicitEntries, PEXPLICIT_ACCESS pListOfExplicitEntries, PACL OldAcl, PACL* NewAcl ) ;
ALIAS: SetEntriesInAcl SetEntriesInAclW
! : SetEntriesInAuditListA ; ! : SetEntriesInAuditListA ;
! : SetEntriesInAuditListW ; ! : SetEntriesInAuditListW ;
! : SetFileSecurityA ; ! : SetFileSecurityA ;
@ -767,7 +973,8 @@ FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL
! : SetNamedSecurityInfoA ; ! : SetNamedSecurityInfoA ;
! : SetNamedSecurityInfoExA ; ! : SetNamedSecurityInfoExA ;
! : SetNamedSecurityInfoExW ; ! : SetNamedSecurityInfoExW ;
! : SetNamedSecurityInfoW ; FUNCTION: DWORD SetNamedSecurityInfoW ( LPTSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl ) ;
ALIAS: SetNamedSecurityInfo SetNamedSecurityInfoW
! : SetPrivateObjectSecurity ; ! : SetPrivateObjectSecurity ;
! : SetPrivateObjectSecurityEx ; ! : SetPrivateObjectSecurityEx ;
! : SetSecurityDescriptorControl ; ! : SetSecurityDescriptorControl ;

View File

@ -1501,7 +1501,6 @@ DESTRUCTOR: DeleteObject
FUNCTION: BOOL ExtTextOutW ( HDC hdc, int X, int Y, UINT fuOptions, RECT* lprc, LPCTSTR lpString, UINT cbCount, INT* lpDx ) ; FUNCTION: BOOL ExtTextOutW ( HDC hdc, int X, int Y, UINT fuOptions, RECT* lprc, LPCTSTR lpString, UINT cbCount, INT* lpDx ) ;
ALIAS: ExtTextOut ExtTextOutW ALIAS: ExtTextOut ExtTextOutW
! FUNCTION: FillPath ! FUNCTION: FillPath
FUNCTION: int FillRect ( HDC hDC, RECT* lprc, HBRUSH hbr ) ;
! FUNCTION: FillRgn ! FUNCTION: FillRgn
! FUNCTION: FixBrushOrgEx ! FUNCTION: FixBrushOrgEx
! FUNCTION: FlattenPath ! FUNCTION: FlattenPath

View File

@ -1477,7 +1477,7 @@ ALIAS: LoadLibraryEx LoadLibraryExW
! FUNCTION: LoadLibraryW ! FUNCTION: LoadLibraryW
! FUNCTION: LoadModule ! FUNCTION: LoadModule
! FUNCTION: LoadResource ! FUNCTION: LoadResource
! FUNCTION: LocalAlloc FUNCTION: HLOCAL LocalAlloc ( UINT uFlags, SIZE_T uBytes ) ;
! FUNCTION: LocalCompact ! FUNCTION: LocalCompact
! FUNCTION: LocalFileTimeToFileTime ! FUNCTION: LocalFileTimeToFileTime
! FUNCTION: LocalFlags ! FUNCTION: LocalFlags

View File

@ -807,7 +807,7 @@ FUNCTION: UINT EnumClipboardFormats ( UINT format ) ;
! FUNCTION: EqualRect ! FUNCTION: EqualRect
! FUNCTION: ExcludeUpdateRgn ! FUNCTION: ExcludeUpdateRgn
! FUNCTION: ExitWindowsEx ! FUNCTION: ExitWindowsEx
! FUNCTION: FillRect FUNCTION: int FillRect ( HDC hDC, RECT* lprc, HBRUSH hbr ) ;
FUNCTION: HWND FindWindowA ( char* lpClassName, char* lpWindowName ) ; FUNCTION: HWND FindWindowA ( char* lpClassName, char* lpWindowName ) ;
FUNCTION: HWND FindWindowExA ( HWND hwndParent, HWND childAfter, char* lpClassName, char* lpWindowName ) ; FUNCTION: HWND FindWindowExA ( HWND hwndParent, HWND childAfter, char* lpClassName, char* lpWindowName ) ;
! FUNCTION: FindWindowExW ! FUNCTION: FindWindowExW

2
basis/x11/authors.txt Normal file
View File

@ -0,0 +1,2 @@
Eduardo Cavazos
Slava Pestov

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings alien.syntax arrays USING: alien alien.c-types alien.strings alien.syntax arrays
kernel math namespaces sequences io.encodings.string kernel math namespaces sequences io.encodings.string
io.encodings.utf8 io.encodings.ascii x11.xlib x11.constants io.encodings.utf8 io.encodings.ascii x11 x11.xlib x11.constants
specialized-arrays.int accessors ; specialized-arrays.int accessors ;
IN: x11.clipboard IN: x11.clipboard

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types arrays hashtables io kernel math USING: alien alien.c-types arrays hashtables io kernel math
math.order namespaces prettyprint sequences strings combinators math.order namespaces prettyprint sequences strings combinators
x11.xlib ; x11 x11.xlib ;
IN: x11.events IN: x11.events
GENERIC: expose-event ( event window -- ) GENERIC: expose-event ( event window -- )

View File

@ -2,8 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
! !
! based on glx.h from xfree86, and some of glxtokens.h ! based on glx.h from xfree86, and some of glxtokens.h
USING: alien alien.c-types alien.syntax x11.xlib namespaces make USING: alien alien.c-types alien.syntax x11 x11.xlib x11.syntax
kernel sequences parser words specialized-arrays.int accessors ; namespaces make kernel sequences parser words specialized-arrays.int
accessors ;
IN: x11.glx IN: x11.glx
LIBRARY: glx LIBRARY: glx
@ -36,52 +37,52 @@ TYPEDEF: XID GLXFBConfigID
TYPEDEF: void* GLXContext ! typedef struct __GLXcontextRec *GLXContext; TYPEDEF: void* GLXContext ! typedef struct __GLXcontextRec *GLXContext;
TYPEDEF: void* GLXFBConfig ! typedef struct __GLXFBConfigRec *GLXFBConfig; TYPEDEF: void* GLXFBConfig ! typedef struct __GLXFBConfigRec *GLXFBConfig;
FUNCTION: XVisualInfo* glXChooseVisual ( Display* dpy, int screen, int* attribList ) ; X-FUNCTION: XVisualInfo* glXChooseVisual ( Display* dpy, int screen, int* attribList ) ;
FUNCTION: void glXCopyContext ( Display* dpy, GLXContext src, GLXContext dst, ulong mask ) ; X-FUNCTION: void glXCopyContext ( Display* dpy, GLXContext src, GLXContext dst, ulong mask ) ;
FUNCTION: GLXContext glXCreateContext ( Display* dpy, XVisualInfo* vis, GLXContext shareList, bool direct ) ; X-FUNCTION: GLXContext glXCreateContext ( Display* dpy, XVisualInfo* vis, GLXContext shareList, bool direct ) ;
FUNCTION: GLXPixmap glXCreateGLXPixmap ( Display* dpy, XVisualInfo* vis, Pixmap pixmap ) ; X-FUNCTION: GLXPixmap glXCreateGLXPixmap ( Display* dpy, XVisualInfo* vis, Pixmap pixmap ) ;
FUNCTION: void glXDestroyContext ( Display* dpy, GLXContext ctx ) ; X-FUNCTION: void glXDestroyContext ( Display* dpy, GLXContext ctx ) ;
FUNCTION: void glXDestroyGLXPixmap ( Display* dpy, GLXPixmap pix ) ; X-FUNCTION: void glXDestroyGLXPixmap ( Display* dpy, GLXPixmap pix ) ;
FUNCTION: int glXGetConfig ( Display* dpy, XVisualInfo* vis, int attrib, int* value ) ; X-FUNCTION: int glXGetConfig ( Display* dpy, XVisualInfo* vis, int attrib, int* value ) ;
FUNCTION: GLXContext glXGetCurrentContext ( ) ; X-FUNCTION: GLXContext glXGetCurrentContext ( ) ;
FUNCTION: GLXDrawable glXGetCurrentDrawable ( ) ; X-FUNCTION: GLXDrawable glXGetCurrentDrawable ( ) ;
FUNCTION: bool glXIsDirect ( Display* dpy, GLXContext ctx ) ; X-FUNCTION: bool glXIsDirect ( Display* dpy, GLXContext ctx ) ;
FUNCTION: bool glXMakeCurrent ( Display* dpy, GLXDrawable drawable, GLXContext ctx ) ; X-FUNCTION: bool glXMakeCurrent ( Display* dpy, GLXDrawable drawable, GLXContext ctx ) ;
FUNCTION: bool glXQueryExtension ( Display* dpy, int* errorBase, int* eventBase ) ; X-FUNCTION: bool glXQueryExtension ( Display* dpy, int* errorBase, int* eventBase ) ;
FUNCTION: bool glXQueryVersion ( Display* dpy, int* major, int* minor ) ; X-FUNCTION: bool glXQueryVersion ( Display* dpy, int* major, int* minor ) ;
FUNCTION: void glXSwapBuffers ( Display* dpy, GLXDrawable drawable ) ; X-FUNCTION: void glXSwapBuffers ( Display* dpy, GLXDrawable drawable ) ;
FUNCTION: void glXUseXFont ( Font font, int first, int count, int listBase ) ; X-FUNCTION: void glXUseXFont ( Font font, int first, int count, int listBase ) ;
FUNCTION: void glXWaitGL ( ) ; X-FUNCTION: void glXWaitGL ( ) ;
FUNCTION: void glXWaitX ( ) ; X-FUNCTION: void glXWaitX ( ) ;
FUNCTION: char* glXGetClientString ( Display* dpy, int name ) ; X-FUNCTION: char* glXGetClientString ( Display* dpy, int name ) ;
FUNCTION: char* glXQueryServerString ( Display* dpy, int screen, int name ) ; X-FUNCTION: char* glXQueryServerString ( Display* dpy, int screen, int name ) ;
FUNCTION: char* glXQueryExtensionsString ( Display* dpy, int screen ) ; X-FUNCTION: char* glXQueryExtensionsString ( Display* dpy, int screen ) ;
! New for GLX 1.3 ! New for GLX 1.3
FUNCTION: GLXFBConfig* glXGetFBConfigs ( Display* dpy, int screen, int* nelements ) ; X-FUNCTION: GLXFBConfig* glXGetFBConfigs ( Display* dpy, int screen, int* nelements ) ;
FUNCTION: GLXFBConfig* glXChooseFBConfig ( Display* dpy, int screen, int* attrib_list, int* nelements ) ; X-FUNCTION: GLXFBConfig* glXChooseFBConfig ( Display* dpy, int screen, int* attrib_list, int* nelements ) ;
FUNCTION: int glXGetFBConfigAttrib ( Display* dpy, GLXFBConfig config, int attribute, int* value ) ; X-FUNCTION: int glXGetFBConfigAttrib ( Display* dpy, GLXFBConfig config, int attribute, int* value ) ;
FUNCTION: XVisualInfo* glXGetVisualFromFBConfig ( Display* dpy, GLXFBConfig config ) ; X-FUNCTION: XVisualInfo* glXGetVisualFromFBConfig ( Display* dpy, GLXFBConfig config ) ;
FUNCTION: GLXWindow glXCreateWindow ( Display* dpy, GLXFBConfig config, Window win, int* attrib_list ) ; X-FUNCTION: GLXWindow glXCreateWindow ( Display* dpy, GLXFBConfig config, Window win, int* attrib_list ) ;
FUNCTION: void glXDestroyWindow ( Display* dpy, GLXWindow win ) ; X-FUNCTION: void glXDestroyWindow ( Display* dpy, GLXWindow win ) ;
FUNCTION: GLXPixmap glXCreatePixmap ( Display* dpy, GLXFBConfig config, Pixmap pixmap, int* attrib_list ) ; X-FUNCTION: GLXPixmap glXCreatePixmap ( Display* dpy, GLXFBConfig config, Pixmap pixmap, int* attrib_list ) ;
FUNCTION: void glXDestroyPixmap ( Display* dpy, GLXPixmap pixmap ) ; X-FUNCTION: void glXDestroyPixmap ( Display* dpy, GLXPixmap pixmap ) ;
FUNCTION: GLXPbuffer glXCreatePbuffer ( Display* dpy, GLXFBConfig config, int* attrib_list ) ; X-FUNCTION: GLXPbuffer glXCreatePbuffer ( Display* dpy, GLXFBConfig config, int* attrib_list ) ;
FUNCTION: void glXDestroyPbuffer ( Display* dpy, GLXPbuffer pbuf ) ; X-FUNCTION: void glXDestroyPbuffer ( Display* dpy, GLXPbuffer pbuf ) ;
FUNCTION: void glXQueryDrawable ( Display* dpy, GLXDrawable draw, int attribute, uint* value ) ; X-FUNCTION: void glXQueryDrawable ( Display* dpy, GLXDrawable draw, int attribute, uint* value ) ;
FUNCTION: GLXContext glXCreateNewContext ( Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, bool direct ) ; X-FUNCTION: GLXContext glXCreateNewContext ( Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, bool direct ) ;
FUNCTION: bool glXMakeContextCurrent ( Display* display, GLXDrawable draw, GLXDrawable read, GLXContext ctx ) ; X-FUNCTION: bool glXMakeContextCurrent ( Display* display, GLXDrawable draw, GLXDrawable read, GLXContext ctx ) ;
FUNCTION: GLXDrawable glXGetCurrentReadDrawable ( ) ; X-FUNCTION: GLXDrawable glXGetCurrentReadDrawable ( ) ;
FUNCTION: Display* glXGetCurrentDisplay ( ) ; X-FUNCTION: Display* glXGetCurrentDisplay ( ) ;
FUNCTION: int glXQueryContext ( Display* dpy, GLXContext ctx, int attribute, int* value ) ; X-FUNCTION: int glXQueryContext ( Display* dpy, GLXContext ctx, int attribute, int* value ) ;
FUNCTION: void glXSelectEvent ( Display* dpy, GLXDrawable draw, ulong event_mask ) ; X-FUNCTION: void glXSelectEvent ( Display* dpy, GLXDrawable draw, ulong event_mask ) ;
FUNCTION: void glXGetSelectedEvent ( Display* dpy, GLXDrawable draw, ulong* event_mask ) ; X-FUNCTION: void glXGetSelectedEvent ( Display* dpy, GLXDrawable draw, ulong* event_mask ) ;
! GLX 1.4 and later ! GLX 1.4 and later
FUNCTION: void* glXGetProcAddress ( char* procname ) ; X-FUNCTION: void* glXGetProcAddress ( char* procname ) ;
! GLX_ARB_get_proc_address extension ! GLX_ARB_get_proc_address extension
FUNCTION: void* glXGetProcAddressARB ( char* procname ) ; X-FUNCTION: void* glXGetProcAddressARB ( char* procname ) ;
! GLX Events ! GLX Events
! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks) ! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks)

1
basis/x11/io/authors.txt Normal file
View File

@ -0,0 +1 @@
Slava Pestov

16
basis/x11/io/io.factor Normal file
View File

@ -0,0 +1,16 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io.backend calendar threads kernel ;
IN: x11.io
HOOK: init-x-io io-backend ( -- )
M: object init-x-io ;
HOOK: wait-for-display io-backend ( -- )
M: object wait-for-display 10 milliseconds sleep ;
HOOK: awaken-event-loop io-backend ( -- )
M: object awaken-event-loop ;

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,15 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io.backend.unix io.backend.unix.multiplexers
namespaces system x11 x11.xlib x11.io
accessors threads sequences kernel ;
IN: x11.io.unix
SYMBOL: dpy-fd
M: unix init-x-io dpy get XConnectionNumber <fd> dpy-fd set-global ;
M: unix wait-for-display dpy-fd get +input+ wait-for-fd ;
M: unix awaken-event-loop
dpy-fd get [ fd>> mx get remove-input-callbacks [ resume ] each ] when* ;

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,9 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax alien.parser words x11.io sequences kernel ;
IN: x11.syntax
SYNTAX: X-FUNCTION:
(FUNCTION:)
[ \ awaken-event-loop suffix ] dip
define-declared ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005, 2006 Eduardo Cavazos and Slava Pestov ! Copyright (C) 2005, 2006 Eduardo Cavazos and Slava Pestov
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types hashtables kernel math math.vectors USING: alien alien.c-types hashtables kernel math math.vectors
math.bitwise namespaces sequences x11.xlib x11.constants x11.glx math.bitwise namespaces sequences x11 x11.xlib x11.constants x11.glx
arrays fry ; arrays fry ;
IN: x11.windows IN: x11.windows
@ -29,6 +29,8 @@ IN: x11.windows
: window-attributes ( visinfo -- attributes ) : window-attributes ( visinfo -- attributes )
"XSetWindowAttributes" <c-object> "XSetWindowAttributes" <c-object>
0 over set-XSetWindowAttributes-background_pixel
0 over set-XSetWindowAttributes-border_pixel
[ [ create-colormap ] dip set-XSetWindowAttributes-colormap ] keep [ [ create-colormap ] dip set-XSetWindowAttributes-colormap ] keep
event-mask over set-XSetWindowAttributes-event_mask ; event-mask over set-XSetWindowAttributes-event_mask ;

36
basis/x11/x11.factor Normal file
View File

@ -0,0 +1,36 @@
! Copyright (C) 2005, 2009 Eduardo Cavazos, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.strings continuations io
io.encodings.ascii kernel namespaces x11.xlib x11.io
vocabs vocabs.loader ;
IN: x11
SYMBOL: dpy
SYMBOL: scr
SYMBOL: root
: init-locale ( -- )
LC_ALL "" setlocale [ "setlocale() failed" print flush ] unless
XSupportsLocale [ "XSupportsLocale() failed" print flush ] unless ;
: flush-dpy ( -- ) dpy get XFlush drop ;
: x-atom ( string -- atom ) [ dpy get ] dip 0 XInternAtom ;
: check-display ( alien -- alien' )
[ "Cannot connect to X server - check $DISPLAY" throw ] unless* ;
: init-x ( display-string -- )
init-locale
dup [ ascii string>alien ] when
XOpenDisplay check-display dpy set-global
dpy get XDefaultScreen scr set-global
dpy get scr get XRootWindow root set-global
init-x-io ;
: close-x ( -- ) dpy get XCloseDisplay drop ;
: with-x ( display-string quot -- )
[ init-x ] dip [ close-x ] [ ] cleanup ; inline
"io.backend.unix" vocab [ "x11.io.unix" require ] when

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings arrays byte-arrays USING: alien alien.c-types alien.strings arrays byte-arrays
hashtables io io.encodings.string kernel math namespaces hashtables io io.encodings.string kernel math namespaces
sequences strings continuations x11.xlib specialized-arrays.uint sequences strings continuations x11 x11.xlib specialized-arrays.uint
accessors io.encodings.utf16n ; accessors io.encodings.utf16n ;
IN: x11.xim IN: x11.xim

View File

@ -13,7 +13,7 @@
USING: kernel arrays alien alien.c-types alien.strings USING: kernel arrays alien alien.c-types alien.strings
alien.syntax math math.bitwise words sequences namespaces alien.syntax math math.bitwise words sequences namespaces
continuations io io.encodings.ascii ; continuations io io.encodings.ascii x11.syntax ;
IN: x11.xlib IN: x11.xlib
LIBRARY: xlib LIBRARY: xlib
@ -71,26 +71,26 @@ C-STRUCT: Display
{ "void*" "free_funcs" } { "void*" "free_funcs" }
{ "int" "fd" } ; { "int" "fd" } ;
FUNCTION: Display* XOpenDisplay ( void* display_name ) ; X-FUNCTION: Display* XOpenDisplay ( void* display_name ) ;
! 2.2 Obtaining Information about the Display, Image Formats, or Screens ! 2.2 Obtaining Information about the Display, Image Formats, or Screens
FUNCTION: ulong XBlackPixel ( Display* display, int screen_number ) ; X-FUNCTION: ulong XBlackPixel ( Display* display, int screen_number ) ;
FUNCTION: ulong XWhitePixel ( Display* display, int screen_number ) ; X-FUNCTION: ulong XWhitePixel ( Display* display, int screen_number ) ;
FUNCTION: Colormap XDefaultColormap ( Display* display, int screen_number ) ; X-FUNCTION: Colormap XDefaultColormap ( Display* display, int screen_number ) ;
FUNCTION: int XDefaultDepth ( Display* display, int screen_number ) ; X-FUNCTION: int XDefaultDepth ( Display* display, int screen_number ) ;
FUNCTION: GC XDefaultGC ( Display* display, int screen_number ) ; X-FUNCTION: GC XDefaultGC ( Display* display, int screen_number ) ;
FUNCTION: int XDefaultScreen ( Display* display ) ; X-FUNCTION: int XDefaultScreen ( Display* display ) ;
FUNCTION: Window XRootWindow ( Display* display, int screen_number ) ; X-FUNCTION: Window XRootWindow ( Display* display, int screen_number ) ;
FUNCTION: Window XDefaultRootWindow ( Display* display ) ; X-FUNCTION: Window XDefaultRootWindow ( Display* display ) ;
FUNCTION: int XProtocolVersion ( Display* display ) ; X-FUNCTION: int XProtocolVersion ( Display* display ) ;
FUNCTION: int XProtocolRevision ( Display* display ) ; X-FUNCTION: int XProtocolRevision ( Display* display ) ;
FUNCTION: int XQLength ( Display* display ) ; X-FUNCTION: int XQLength ( Display* display ) ;
FUNCTION: int XScreenCount ( Display* display ) ; X-FUNCTION: int XScreenCount ( Display* display ) ;
FUNCTION: int XConnectionNumber ( Display* display ) ; X-FUNCTION: int XConnectionNumber ( Display* display ) ;
! 2.5 Closing the Display ! 2.5 Closing the Display
FUNCTION: int XCloseDisplay ( Display* display ) ; X-FUNCTION: int XCloseDisplay ( Display* display ) ;
! !
! 3 - Window Functions ! 3 - Window Functions
@ -147,17 +147,17 @@ CONSTANT: StaticGravity 10
! 3.3 - Creating Windows ! 3.3 - Creating Windows
FUNCTION: Window XCreateWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint class, Visual* visual, ulong valuemask, XSetWindowAttributes* attributes ) ; X-FUNCTION: Window XCreateWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint class, Visual* visual, ulong valuemask, XSetWindowAttributes* attributes ) ;
FUNCTION: Window XCreateSimpleWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, ulong border, ulong background ) ; X-FUNCTION: Window XCreateSimpleWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, ulong border, ulong background ) ;
FUNCTION: Status XDestroyWindow ( Display* display, Window w ) ; X-FUNCTION: Status XDestroyWindow ( Display* display, Window w ) ;
FUNCTION: Status XMapWindow ( Display* display, Window window ) ; X-FUNCTION: Status XMapWindow ( Display* display, Window window ) ;
FUNCTION: Status XMapSubwindows ( Display* display, Window window ) ; X-FUNCTION: Status XMapSubwindows ( Display* display, Window window ) ;
FUNCTION: Status XUnmapWindow ( Display* display, Window w ) ; X-FUNCTION: Status XUnmapWindow ( Display* display, Window w ) ;
FUNCTION: Status XUnmapSubwindows ( Display* display, Window w ) ; X-FUNCTION: Status XUnmapSubwindows ( Display* display, Window w ) ;
! 3.5 Mapping Windows ! 3.5 Mapping Windows
FUNCTION: int XMapRaised ( Display* display, Window w ) ; X-FUNCTION: int XMapRaised ( Display* display, Window w ) ;
! 3.7 - Configuring Windows ! 3.7 - Configuring Windows
@ -178,25 +178,25 @@ C-STRUCT: XWindowChanges
{ "Window" "sibling" } { "Window" "sibling" }
{ "int" "stack_mode" } ; { "int" "stack_mode" } ;
FUNCTION: Status XConfigureWindow ( Display* display, Window w, uint value_mask, XWindowChanges* values ) ; X-FUNCTION: Status XConfigureWindow ( Display* display, Window w, uint value_mask, XWindowChanges* values ) ;
FUNCTION: Status XMoveWindow ( Display* display, Window w, int x, int y ) ; X-FUNCTION: Status XMoveWindow ( Display* display, Window w, int x, int y ) ;
FUNCTION: Status XResizeWindow ( Display* display, Window w, uint width, uint height ) ; X-FUNCTION: Status XResizeWindow ( Display* display, Window w, uint width, uint height ) ;
FUNCTION: Status XSetWindowBorderWidth ( Display* display, ulong w, uint width ) ; X-FUNCTION: Status XSetWindowBorderWidth ( Display* display, ulong w, uint width ) ;
! 3.8 Changing Window Stacking Order ! 3.8 Changing Window Stacking Order
FUNCTION: Status XRaiseWindow ( Display* display, Window w ) ; X-FUNCTION: Status XRaiseWindow ( Display* display, Window w ) ;
FUNCTION: Status XLowerWindow ( Display* display, Window w ) ; X-FUNCTION: Status XLowerWindow ( Display* display, Window w ) ;
! 3.9 - Changing Window Attributes ! 3.9 - Changing Window Attributes
FUNCTION: Status XChangeWindowAttributes ( X-FUNCTION: Status XChangeWindowAttributes (
Display* display, Window w, ulong valuemask, XSetWindowAttributes* attr ) ; Display* display, Window w, ulong valuemask, XSetWindowAttributes* attr ) ;
FUNCTION: Status XSetWindowBackground ( X-FUNCTION: Status XSetWindowBackground (
Display* display, Window w, ulong background_pixel ) ; Display* display, Window w, ulong background_pixel ) ;
FUNCTION: Status XDefineCursor ( Display* display, Window w, Cursor cursor ) ; X-FUNCTION: Status XDefineCursor ( Display* display, Window w, Cursor cursor ) ;
FUNCTION: Status XUndefineCursor ( Display* display, Window w ) ; X-FUNCTION: Status XUndefineCursor ( Display* display, Window w ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 4 - Window Information Functions ! 4 - Window Information Functions
@ -204,7 +204,7 @@ FUNCTION: Status XUndefineCursor ( Display* display, Window w ) ;
! 4.1 - Obtaining Window Information ! 4.1 - Obtaining Window Information
FUNCTION: Status XQueryTree ( X-FUNCTION: Status XQueryTree (
Display* display, Display* display,
Window w, Window w,
Window* root_return, Window* root_return,
@ -236,13 +236,13 @@ C-STRUCT: XWindowAttributes
{ "Bool" "override_redirect" } { "Bool" "override_redirect" }
{ "Screen*" "screen" } ; { "Screen*" "screen" } ;
FUNCTION: Status XGetWindowAttributes ( Display* display, Window w, XWindowAttributes* attr ) ; X-FUNCTION: Status XGetWindowAttributes ( Display* display, Window w, XWindowAttributes* attr ) ;
CONSTANT: IsUnmapped 0 CONSTANT: IsUnmapped 0
CONSTANT: IsUnviewable 1 CONSTANT: IsUnviewable 1
CONSTANT: IsViewable 2 CONSTANT: IsViewable 2
FUNCTION: Status XGetGeometry ( X-FUNCTION: Status XGetGeometry (
Display* display, Display* display,
Drawable d, Drawable d,
Window* root_return, Window* root_return,
@ -255,27 +255,27 @@ FUNCTION: Status XGetGeometry (
! 4.2 - Translating Screen Coordinates ! 4.2 - Translating Screen Coordinates
FUNCTION: Bool XQueryPointer ( Display* display, Window w, Window* root_return, Window* child_return, int* root_x_return, int* root_y_return, int* win_x_return, int* win_y_return, uint* mask_return ) ; X-FUNCTION: Bool XQueryPointer ( Display* display, Window w, Window* root_return, Window* child_return, int* root_x_return, int* root_y_return, int* win_x_return, int* win_y_return, uint* mask_return ) ;
! 4.3 - Properties and Atoms ! 4.3 - Properties and Atoms
FUNCTION: Atom XInternAtom ( Display* display, char* atom_name, Bool only_if_exists ) ; X-FUNCTION: Atom XInternAtom ( Display* display, char* atom_name, Bool only_if_exists ) ;
FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ; X-FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ;
! 4.4 - Obtaining and Changing Window Properties ! 4.4 - Obtaining and Changing Window Properties
FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, char** prop_return ) ; X-FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, char** prop_return ) ;
FUNCTION: int XChangeProperty ( Display* display, Window w, Atom property, Atom type, int format, int mode, void* data, int nelements ) ; X-FUNCTION: int XChangeProperty ( Display* display, Window w, Atom property, Atom type, int format, int mode, void* data, int nelements ) ;
! 4.5 Selections ! 4.5 Selections
FUNCTION: int XSetSelectionOwner ( Display* display, Atom selection, Window owner, Time time ) ; X-FUNCTION: int XSetSelectionOwner ( Display* display, Atom selection, Window owner, Time time ) ;
FUNCTION: Window XGetSelectionOwner ( Display* display, Atom selection ) ; X-FUNCTION: Window XGetSelectionOwner ( Display* display, Atom selection ) ;
FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom target, Atom property, Window requestor, Time time ) ; X-FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom target, Atom property, Window requestor, Time time ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -284,8 +284,8 @@ FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom target,
! 5.1 - Creating and Freeing Pixmaps ! 5.1 - Creating and Freeing Pixmaps
FUNCTION: Pixmap XCreatePixmap ( Display* display, Drawable d, uint width, uint height, uint depth ) ; X-FUNCTION: Pixmap XCreatePixmap ( Display* display, Drawable d, uint width, uint height, uint depth ) ;
FUNCTION: int XFreePixmap ( Display* display, Pixmap pixmap ) ; X-FUNCTION: int XFreePixmap ( Display* display, Pixmap pixmap ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -300,13 +300,13 @@ C-STRUCT: XColor
{ "char" "flags" } { "char" "flags" }
{ "char" "pad" } ; { "char" "pad" } ;
FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color_name, XColor* exact_def_return, XColor* screen_def_return ) ; X-FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color_name, XColor* exact_def_return, XColor* screen_def_return ) ;
FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ; X-FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ;
FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ; X-FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ;
! 6.4 Creating, Copying, and Destroying Colormaps ! 6.4 Creating, Copying, and Destroying Colormaps
FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, int alloc ) ; X-FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, int alloc ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 7 - Graphics Context Functions ! 7 - Graphics Context Functions
@ -378,27 +378,27 @@ C-STRUCT: XGCValues
{ "int" "dash_offset" } { "int" "dash_offset" }
{ "char" "dashes" } ; { "char" "dashes" } ;
FUNCTION: GC XCreateGC ( Display* display, Window d, ulong valuemask, XGCValues* values ) ; X-FUNCTION: GC XCreateGC ( Display* display, Window d, ulong valuemask, XGCValues* values ) ;
FUNCTION: int XChangeGC ( Display* display, GC gc, ulong valuemask, XGCValues* values ) ; X-FUNCTION: int XChangeGC ( Display* display, GC gc, ulong valuemask, XGCValues* values ) ;
FUNCTION: Status XGetGCValues ( Display* display, GC gc, ulong valuemask, XGCValues* values_return ) ; X-FUNCTION: Status XGetGCValues ( Display* display, GC gc, ulong valuemask, XGCValues* values_return ) ;
FUNCTION: Status XSetForeground ( Display* display, GC gc, ulong foreground ) ; X-FUNCTION: Status XSetForeground ( Display* display, GC gc, ulong foreground ) ;
FUNCTION: Status XSetBackground ( Display* display, GC gc, ulong background ) ; X-FUNCTION: Status XSetBackground ( Display* display, GC gc, ulong background ) ;
FUNCTION: Status XSetFunction ( Display* display, GC gc, int function ) ; X-FUNCTION: Status XSetFunction ( Display* display, GC gc, int function ) ;
FUNCTION: Status XSetSubwindowMode ( Display* display, GC gc, int subwindow_mode ) ; X-FUNCTION: Status XSetSubwindowMode ( Display* display, GC gc, int subwindow_mode ) ;
FUNCTION: GContext XGContextFromGC ( GC gc ) ; X-FUNCTION: GContext XGContextFromGC ( GC gc ) ;
FUNCTION: Status XSetFont ( Display* display, GC gc, Font font ) ; X-FUNCTION: Status XSetFont ( Display* display, GC gc, Font font ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 8 - Graphics Functions ! 8 - Graphics Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION: Status XClearWindow ( Display* display, Window w ) ; X-FUNCTION: Status XClearWindow ( Display* display, Window w ) ;
FUNCTION: Status XDrawPoint ( Display* display, Drawable d, GC gc, int x, int y ) ; X-FUNCTION: Status XDrawPoint ( Display* display, Drawable d, GC gc, int x, int y ) ;
FUNCTION: Status XDrawLine ( Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2 ) ; X-FUNCTION: Status XDrawLine ( Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2 ) ;
FUNCTION: Status XDrawArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ; X-FUNCTION: Status XDrawArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ;
FUNCTION: Status XFillArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ; X-FUNCTION: Status XFillArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ;
! 8.5 - Font Metrics ! 8.5 - Font Metrics
@ -410,9 +410,9 @@ C-STRUCT: XCharStruct
{ "short" "descent" } { "short" "descent" }
{ "ushort" "attributes" } ; { "ushort" "attributes" } ;
FUNCTION: Font XLoadFont ( Display* display, char* name ) ; X-FUNCTION: Font XLoadFont ( Display* display, char* name ) ;
FUNCTION: XFontStruct* XQueryFont ( Display* display, XID font_ID ) ; X-FUNCTION: XFontStruct* XQueryFont ( Display* display, XID font_ID ) ;
FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, char* name ) ; X-FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, char* name ) ;
C-STRUCT: XFontStruct C-STRUCT: XFontStruct
{ "XExtData*" "ext_data" } { "XExtData*" "ext_data" }
@ -432,11 +432,11 @@ C-STRUCT: XFontStruct
{ "int" "ascent" } { "int" "ascent" }
{ "int" "descent" } ; { "int" "descent" } ;
FUNCTION: int XTextWidth ( XFontStruct* font_struct, char* string, int count ) ; X-FUNCTION: int XTextWidth ( XFontStruct* font_struct, char* string, int count ) ;
! 8.6 - Drawing Text ! 8.6 - Drawing Text
FUNCTION: Status XDrawString ( X-FUNCTION: Status XDrawString (
Display* display, Display* display,
Drawable d, Drawable d,
GC gc, GC gc,
@ -479,8 +479,8 @@ C-STRUCT: XImage
{ "XPointer" "obdata" } { "XPointer" "obdata" }
{ "XImage-funcs" "f" } ; { "XImage-funcs" "f" } ;
FUNCTION: XImage* XGetImage ( Display* display, Drawable d, int x, int y, uint width, uint height, ulong plane_mask, int format ) ; X-FUNCTION: XImage* XGetImage ( Display* display, Drawable d, int x, int y, uint width, uint height, ulong plane_mask, int format ) ;
FUNCTION: int XDestroyImage ( XImage *ximage ) ; X-FUNCTION: int XDestroyImage ( XImage *ximage ) ;
: XImage-size ( ximage -- size ) : XImage-size ( ximage -- size )
[ XImage-height ] [ XImage-bytes_per_line ] bi * ; [ XImage-height ] [ XImage-bytes_per_line ] bi * ;
@ -492,12 +492,12 @@ FUNCTION: int XDestroyImage ( XImage *ximage ) ;
! 9 - Window and Session Manager Functions ! 9 - Window and Session Manager Functions
! !
FUNCTION: Status XReparentWindow ( Display* display, Window w, Window parent, int x, int y ) ; X-FUNCTION: Status XReparentWindow ( Display* display, Window w, Window parent, int x, int y ) ;
FUNCTION: Status XAddToSaveSet ( Display* display, Window w ) ; X-FUNCTION: Status XAddToSaveSet ( Display* display, Window w ) ;
FUNCTION: Status XRemoveFromSaveSet ( Display* display, Window w ) ; X-FUNCTION: Status XRemoveFromSaveSet ( Display* display, Window w ) ;
FUNCTION: Status XGrabServer ( Display* display ) ; X-FUNCTION: Status XGrabServer ( Display* display ) ;
FUNCTION: Status XUngrabServer ( Display* display ) ; X-FUNCTION: Status XUngrabServer ( Display* display ) ;
FUNCTION: Status XKillClient ( Display* display, XID resource ) ; X-FUNCTION: Status XKillClient ( Display* display, XID resource ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 10 - Events ! 10 - Events
@ -1066,11 +1066,11 @@ C-UNION: XEvent
! 11 - Event Handling Functions ! 11 - Event Handling Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION: Status XSelectInput ( Display* display, Window w, long event_mask ) ; X-FUNCTION: Status XSelectInput ( Display* display, Window w, long event_mask ) ;
FUNCTION: Status XFlush ( Display* display ) ; X-FUNCTION: Status XFlush ( Display* display ) ;
FUNCTION: Status XSync ( Display* display, int discard ) ; X-FUNCTION: Status XSync ( Display* display, int discard ) ;
FUNCTION: Status XNextEvent ( Display* display, XEvent* event ) ; X-FUNCTION: Status XNextEvent ( Display* display, XEvent* event ) ;
FUNCTION: Status XMaskEvent ( Display* display, long event_mask, XEvent* event_return ) ; X-FUNCTION: Status XMaskEvent ( Display* display, long event_mask, XEvent* event_return ) ;
! 11.3 - Event Queue Management ! 11.3 - Event Queue Management
@ -1078,16 +1078,16 @@ CONSTANT: QueuedAlready 0
CONSTANT: QueuedAfterReading 1 CONSTANT: QueuedAfterReading 1
CONSTANT: QueuedAfterFlush 2 CONSTANT: QueuedAfterFlush 2
FUNCTION: int XEventsQueued ( Display* display, int mode ) ; X-FUNCTION: int XEventsQueued ( Display* display, int mode ) ;
FUNCTION: int XPending ( Display* display ) ; X-FUNCTION: int XPending ( Display* display ) ;
! 11.6 - Sending Events to Other Applications ! 11.6 - Sending Events to Other Applications
FUNCTION: Status XSendEvent ( Display* display, Window w, Bool propagate, long event_mask, XEvent* event_send ) ; X-FUNCTION: Status XSendEvent ( Display* display, Window w, Bool propagate, long event_mask, XEvent* event_send ) ;
! 11.8 - Handling Protocol Errors ! 11.8 - Handling Protocol Errors
FUNCTION: int XSetErrorHandler ( void* handler ) ; X-FUNCTION: int XSetErrorHandler ( void* handler ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 12 - Input Device Functions ! 12 - Input Device Functions
@ -1095,7 +1095,7 @@ FUNCTION: int XSetErrorHandler ( void* handler ) ;
CONSTANT: None 0 CONSTANT: None 0
FUNCTION: int XGrabPointer ( X-FUNCTION: int XGrabPointer (
Display* display, Display* display,
Window grab_window, Window grab_window,
Bool owner_events, Bool owner_events,
@ -1106,16 +1106,16 @@ FUNCTION: int XGrabPointer (
Cursor cursor, Cursor cursor,
Time time ) ; Time time ) ;
FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ; X-FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ;
FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ; X-FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ;
FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ; X-FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ;
FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ; X-FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ;
FUNCTION: Status XGetInputFocus ( Display* display, X-FUNCTION: Status XGetInputFocus ( Display* display,
Window* focus_return, Window* focus_return,
int* revert_to_return ) ; int* revert_to_return ) ;
FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y ) ; X-FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 14 - Inter-Client Communication Functions ! 14 - Inter-Client Communication Functions
@ -1123,15 +1123,15 @@ FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, i
! 14.1 Client to Window Manager Communication ! 14.1 Client to Window Manager Communication
FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ; X-FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ;
FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ; X-FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ;
! 14.1.1. Manipulating Top-Level Windows ! 14.1.1. Manipulating Top-Level Windows
FUNCTION: Status XIconifyWindow ( X-FUNCTION: Status XIconifyWindow (
Display* display, Window w, int screen_number ) ; Display* display, Window w, int screen_number ) ;
FUNCTION: Status XWithdrawWindow ( X-FUNCTION: Status XWithdrawWindow (
Display* display, Window w, int screen_number ) ; Display* display, Window w, int screen_number ) ;
! 14.1.6 - Setting and Reading the WM_HINTS Property ! 14.1.6 - Setting and Reading the WM_HINTS Property
@ -1173,10 +1173,10 @@ C-STRUCT: XSizeHints
! 14.1.10. Setting and Reading the WM_PROTOCOLS Property ! 14.1.10. Setting and Reading the WM_PROTOCOLS Property
FUNCTION: Status XSetWMProtocols ( X-FUNCTION: Status XSetWMProtocols (
Display* display, Window w, Atom* protocols, int count ) ; Display* display, Window w, Atom* protocols, int count ) ;
FUNCTION: Status XGetWMProtocols ( X-FUNCTION: Status XGetWMProtocols (
Display* display, Display* display,
Window w, Window w,
Atom** protocols_return, Atom** protocols_return,
@ -1188,9 +1188,9 @@ FUNCTION: Status XGetWMProtocols (
! 16.1 Keyboard Utility Functions ! 16.1 Keyboard Utility Functions
FUNCTION: KeySym XLookupKeysym ( XKeyEvent* key_event, int index ) ; X-FUNCTION: KeySym XLookupKeysym ( XKeyEvent* key_event, int index ) ;
FUNCTION: int XLookupString ( X-FUNCTION: int XLookupString (
XKeyEvent* event_struct, XKeyEvent* event_struct,
void* buffer_return, void* buffer_return,
int bytes_buffer, int bytes_buffer,
@ -1227,7 +1227,7 @@ C-STRUCT: XVisualInfo
! Appendix D - Compatibility Functions ! Appendix D - Compatibility Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION: Status XSetStandardProperties ( X-FUNCTION: Status XSetStandardProperties (
Display* display, Display* display,
Window w, Window w,
char* window_name, char* window_name,
@ -1314,10 +1314,10 @@ CONSTANT: XA_LAST_PREDEFINED 68
! The rest of the stuff is not from the book. ! The rest of the stuff is not from the book.
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION: void XFree ( void* data ) ; X-FUNCTION: void XFree ( void* data ) ;
FUNCTION: int XStoreName ( Display* display, Window w, char* window_name ) ; X-FUNCTION: int XStoreName ( Display* display, Window w, char* window_name ) ;
FUNCTION: void XSetWMNormalHints ( Display* display, Window w, XSizeHints* hints ) ; X-FUNCTION: void XSetWMNormalHints ( Display* display, Window w, XSizeHints* hints ) ;
FUNCTION: int XBell ( Display* display, int percent ) ; X-FUNCTION: int XBell ( Display* display, int percent ) ;
! !!! INPUT METHODS ! !!! INPUT METHODS
@ -1381,23 +1381,23 @@ CONSTANT: XLookupChars 2
CONSTANT: XLookupKeySym 3 CONSTANT: XLookupKeySym 3
CONSTANT: XLookupBoth 4 CONSTANT: XLookupBoth 4
FUNCTION: Bool XFilterEvent ( XEvent* event, Window w ) ; X-FUNCTION: Bool XFilterEvent ( XEvent* event, Window w ) ;
FUNCTION: XIM XOpenIM ( Display* dpy, void* rdb, char* res_name, char* res_class ) ; X-FUNCTION: XIM XOpenIM ( Display* dpy, void* rdb, char* res_name, char* res_class ) ;
FUNCTION: Status XCloseIM ( XIM im ) ; X-FUNCTION: Status XCloseIM ( XIM im ) ;
FUNCTION: XIC XCreateIC ( XIM im, char* key1, Window value1, char* key2, Window value2, char* key3, int value3, char* key4, char* value4, char* key5, char* value5, int key6 ) ; X-FUNCTION: XIC XCreateIC ( XIM im, char* key1, Window value1, char* key2, Window value2, char* key3, int value3, char* key4, char* value4, char* key5, char* value5, int key6 ) ;
FUNCTION: void XDestroyIC ( XIC ic ) ; X-FUNCTION: void XDestroyIC ( XIC ic ) ;
FUNCTION: void XSetICFocus ( XIC ic ) ; X-FUNCTION: void XSetICFocus ( XIC ic ) ;
FUNCTION: void XUnsetICFocus ( XIC ic ) ; X-FUNCTION: void XUnsetICFocus ( XIC ic ) ;
FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; X-FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ;
FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; X-FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ;
! !!! category of setlocale ! !!! category of setlocale
CONSTANT: LC_ALL 0 CONSTANT: LC_ALL 0
@ -1407,37 +1407,8 @@ CONSTANT: LC_MONETARY 3
CONSTANT: LC_NUMERIC 4 CONSTANT: LC_NUMERIC 4
CONSTANT: LC_TIME 5 CONSTANT: LC_TIME 5
FUNCTION: char* setlocale ( int category, char* name ) ; X-FUNCTION: char* setlocale ( int category, char* name ) ;
FUNCTION: Bool XSupportsLocale ( ) ; X-FUNCTION: Bool XSupportsLocale ( ) ;
FUNCTION: char* XSetLocaleModifiers ( char* modifier_list ) ; X-FUNCTION: char* XSetLocaleModifiers ( char* modifier_list ) ;
SYMBOL: dpy
SYMBOL: scr
SYMBOL: root
: init-locale ( -- )
LC_ALL "" setlocale [ "setlocale() failed" print flush ] unless
XSupportsLocale [ "XSupportsLocale() failed" print flush ] unless ;
: flush-dpy ( -- ) dpy get XFlush drop ;
: x-atom ( string -- atom ) dpy get swap 0 XInternAtom ;
: check-display ( alien -- alien' )
[
"Cannot connect to X server - check $DISPLAY" throw
] unless* ;
: initialize-x ( display-string -- )
init-locale
dup [ ascii string>alien ] when
XOpenDisplay check-display dpy set-global
dpy get XDefaultScreen scr set-global
dpy get scr get XRootWindow root set-global ;
: close-x ( -- ) dpy get XCloseDisplay drop ;
: with-x ( display-string quot -- )
[ initialize-x ] dip [ close-x ] [ ] cleanup ; inline

Some files were not shown because too many files have changed in this diff Show More