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

db4
Joe Groff 2009-05-23 08:39:17 -05:00
commit 8e06eab2f2
13 changed files with 102 additions and 33 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006, 2008 Doug Coleman. ! Copyright (C) 2006, 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel io io.binary io.files io.streams.byte-array math USING: alien.c-types kernel io io.binary io.files io.streams.byte-array math
math.functions math.parser namespaces splitting grouping strings math.functions math.parser namespaces splitting grouping strings
sequences byte-arrays locals sequences.private macros fry sequences byte-arrays locals sequences.private macros fry
io.encodings.binary math.bitwise checksums accessors io.encodings.binary math.bitwise checksums accessors
@ -173,9 +173,27 @@ HINTS: (process-md5-block-G) { uint-array md5-state } ;
HINTS: (process-md5-block-H) { uint-array md5-state } ; HINTS: (process-md5-block-H) { uint-array md5-state } ;
HINTS: (process-md5-block-I) { uint-array md5-state } ; HINTS: (process-md5-block-I) { uint-array md5-state } ;
: byte-array>le ( byte-array -- byte-array )
little-endian? [
dup 4 <sliced-groups> [
[ [ 1 2 ] dip exchange-unsafe ]
[ [ 0 3 ] dip exchange-unsafe ] bi
] each
] unless ;
: byte-array>uint-array-le ( byte-array -- uint-array )
byte-array>le byte-array>uint-array ;
HINTS: byte-array>uint-array-le byte-array ;
: uint-array>byte-array-le ( uint-array -- byte-array )
underlying>> byte-array>le ;
HINTS: uint-array>byte-array-le uint-array ;
M: md5-state checksum-block ( block state -- ) M: md5-state checksum-block ( block state -- )
[ [
[ byte-array>uint-array ] [ state>> ] bi* { [ byte-array>uint-array-le ] [ state>> ] bi* {
[ (process-md5-block-F) ] [ (process-md5-block-F) ]
[ (process-md5-block-G) ] [ (process-md5-block-G) ]
[ (process-md5-block-H) ] [ (process-md5-block-H) ]
@ -185,7 +203,7 @@ M: md5-state checksum-block ( block state -- )
nip update-md5 nip update-md5
] 2bi ; ] 2bi ;
: md5>checksum ( md5 -- bytes ) state>> underlying>> ; : md5>checksum ( md5 -- bytes ) state>> uint-array>byte-array-le ;
M: md5-state clone ( md5 -- new-md5 ) M: md5-state clone ( md5 -- new-md5 )
call-next-method call-next-method

View File

@ -112,10 +112,10 @@ $nl
{ $code { $code
"USE: io.monitors" "USE: io.monitors"
": watch-loop ( monitor -- )" ": watch-loop ( monitor -- )"
" dup next-change . nl nl flush watch-loop ;" " dup next-change path>> print nl nl flush watch-loop ;"
"" ""
": watch-directory ( path -- )" ": watch-directory ( path -- )"
" [ t [ watch-loop ] with-monitor ] with-monitors" " [ t [ watch-loop ] with-monitor ] with-monitors ;"
} ; } ;
ABOUT: "io.monitors" ABOUT: "io.monitors"

View File

@ -60,9 +60,6 @@ SYMBOL: +rename-file+
: run-monitor ( path recursive? quot -- ) : run-monitor ( path recursive? quot -- )
'[ [ @ t ] loop ] with-monitor ; inline '[ [ @ t ] loop ] with-monitor ; inline
: spawn-monitor ( path recursive? quot -- )
[ '[ _ _ _ run-monitor ] ] [ 2drop "Monitoring " prepend ] 3bi
spawn drop ;
{ {
{ [ os macosx? ] [ "io.monitors.macosx" require ] } { [ os macosx? ] [ "io.monitors.macosx" require ] }
{ [ os linux? ] [ "io.monitors.linux" require ] } { [ os linux? ] [ "io.monitors.linux" require ] }

View File

@ -1,7 +1,7 @@
USING: accessors alien.c-types byte-arrays USING: accessors alien.c-types byte-arrays
combinators.short-circuit continuations destructors init kernel combinators.short-circuit continuations destructors init kernel
locals namespaces random windows.advapi32 windows.errors locals namespaces random windows.advapi32 windows.errors
windows.kernel32 ; windows.kernel32 math.bitwise ;
IN: random.windows IN: random.windows
TUPLE: windows-rng provider type ; TUPLE: windows-rng provider type ;
@ -25,7 +25,8 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer"
CryptAcquireContextW handle swap ; CryptAcquireContextW handle swap ;
: acquire-crypto-context ( provider type -- handle ) : acquire-crypto-context ( provider type -- handle )
0 (acquire-crypto-context) CRYPT_MACHINE_KEYSET
(acquire-crypto-context)
0 = [ 0 = [
GetLastError NTE_BAD_KEYSET = GetLastError NTE_BAD_KEYSET =
[ drop f ] [ win32-error-string throw ] if [ drop f ] [ win32-error-string throw ] if
@ -34,7 +35,8 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer"
] if ; ] if ;
: create-crypto-context ( provider type -- handle ) : create-crypto-context ( provider type -- handle )
CRYPT_NEWKEYSET (acquire-crypto-context) win32-error=0/f *void* ; { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } flags
(acquire-crypto-context) win32-error=0/f *void* ;
ERROR: acquire-crypto-context-failed provider type ; ERROR: acquire-crypto-context-failed provider type ;

View File

@ -0,0 +1,25 @@
IN: tuple-arrays
USING: help.markup help.syntax sequences ;
HELP: TUPLE-ARRAY:
{ $syntax "TUPLE-ARRAY: class" }
{ $description "Generates a new data type in the current vocabulary named " { $snippet { $emphasis "class" } "-array" } " for holding instances of " { $snippet "class" } ", which must be a tuple class word. Together with the class itself, this also generates words named " { $snippet "<" { $emphasis "class" } "-array>" } " and " { $snippet ">" { $emphasis "class" } "-array" } ", for creating new instances of this tuple array type." } ;
ARTICLE: "tuple-arrays" "Tuple arrays"
"The " { $vocab-link "tuple-arrays" } " vocabulary implements space-efficient unboxed tuple arrays. Whereas an ordinary array of tuples would consist of pointers to heap-allocated objects, a tuple array stores its elements inline. Calling " { $link nth } " copies an element into a new tuple, and calling " { $link set-nth } " copies an existing tuple's slots into an array."
$nl
"Since value semantics differ from reference semantics, it is best to use tuple arrays with tuples where all slots are declared " { $link read-only } "."
$nl
"Tuple arrays should not be used with inheritance; storing an instance of a subclass in a tuple array will slice off the subclass slots, and getting the same value out again will yield an instance of the superclass. Also, tuple arrays do not get updated if tuples are redefined to add or remove slots, so caution should be exercised when doing interactive development on code that uses tuple arrays."
{ $subsection POSTPONE: TUPLE-ARRAY: }
"An example:"
{ $example
"USE: tuple-arrays"
"IN: scratchpad"
"TUPLE: point x y ;"
"TUPLE-ARRAY: point"
"{ T{ point f 1 2 } T{ point f 1 3 } T{ point f 2 3 } } >point-array first short."
"T{ point f 1 2 }"
} ;
ABOUT: "tuple-arrays"

View File

@ -21,7 +21,7 @@ MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ;
[ new ] [ smart-tuple>array ] bi ; inline [ new ] [ smart-tuple>array ] bi ; inline
: tuple-slice ( n seq -- slice ) : tuple-slice ( n seq -- slice )
[ n>> [ * dup ] keep + ] [ seq>> ] bi { array } declare slice boa ; inline [ n>> [ * dup ] keep + ] [ seq>> ] bi slice boa ; inline
: read-tuple ( slice class -- tuple ) : read-tuple ( slice class -- tuple )
'[ _ boa-unsafe ] input<sequence-unsafe ; inline '[ _ boa-unsafe ] input<sequence-unsafe ; inline

View File

@ -619,3 +619,12 @@ EXCLUDE: qualified.tests.bar => x ;
[ [
"USE: kernel UNUSE: kernel dup" <string-reader> "unuse-test" parse-stream "USE: kernel UNUSE: kernel dup" <string-reader> "unuse-test" parse-stream
] [ error>> error>> error>> no-word-error? ] must-fail-with ] [ error>> error>> error>> no-word-error? ] must-fail-with
[ ] [ [ "vocabs.loader.test.l" forget-vocab ] with-compilation-unit ] unit-test
[
[ "vocabs.loader.test.l" use-vocab ] must-fail
[ f ] [ "vocabs.loader.test.l" manifest get search-vocab-names>> key? ] unit-test
[ ] [ "vocabs.loader.test.l" unuse-vocab ] unit-test
[ f ] [ "vocabs.loader.test.l" manifest get search-vocab-names>> key? ] unit-test
] with-file-vocabs

View File

@ -0,0 +1,4 @@
IN: vocabs.loader.test.l
USE: kernel
"Oops" throw

View File

@ -0,0 +1 @@
unportable

View File

@ -108,8 +108,8 @@ TUPLE: no-current-vocab ;
dup using-vocab? dup using-vocab?
[ vocab-name "Already using ``" "'' vocabulary" surround note. ] [ [ vocab-name "Already using ``" "'' vocabulary" surround note. ] [
manifest get manifest get
[ [ vocab-name ] dip search-vocab-names>> conjoin ]
[ [ load-vocab ] dip search-vocabs>> push ] [ [ load-vocab ] dip search-vocabs>> push ]
[ [ vocab-name ] dip search-vocab-names>> conjoin ]
2bi 2bi
] if ; ] if ;
@ -121,8 +121,8 @@ TUPLE: no-current-vocab ;
: unuse-vocab ( vocab -- ) : unuse-vocab ( vocab -- )
dup using-vocab? [ dup using-vocab? [
manifest get manifest get
[ [ vocab-name ] dip search-vocab-names>> delete-at ]
[ [ load-vocab ] dip search-vocabs>> delq ] [ [ load-vocab ] dip search-vocabs>> delq ]
[ [ vocab-name ] dip search-vocab-names>> delete-at ]
2bi 2bi
] [ drop ] if ; ] [ drop ] if ;

View File

@ -1,12 +1,18 @@
<?xml version='1.0' ?> <?xml version='1.0' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<t:chloe xmlns:t="http://factorcode.org/chloe/1.0"> <t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
<html> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<link rel="stylesheet" href="http://factorcode.org/css/master.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<title>Factor binary package for <t:label t:name="platform" /></title> <title>Factor binary package for <t:label t:name="platform" /></title>
</head> </head>
<body> <body>
<div><img src="http://factorcode.org/graphics/logo.png" alt="Logo" /></div>
<h1>Factor binary package for <t:label t:name="platform" /></h1> <h1>Factor binary package for <t:label t:name="platform" /></h1>
<p>Requirements:</p> <p>Requirements:</p>

View File

@ -15,18 +15,19 @@ TUPLE: mason-app < dispatcher ;
: download-link ( builder label -- xml ) : download-link ( builder label -- xml )
[ [
[ URL" download" ] dip [ URL" http://builds.factorcode.org/download" ] dip
[ os>> "os" set-query-param ] [ os>> "os" set-query-param ]
[ cpu>> "cpu" set-query-param ] bi [ cpu>> "cpu" set-query-param ] bi
] dip link ; ] dip link ;
: download-grid-cell ( cpu os -- xml ) : download-grid-cell ( cpu os -- xml )
builder new swap >>os swap >>cpu select-tuple dup builder new swap >>os swap >>cpu select-tuple [
[
dup last-release>> dup dup last-release>> dup
[ "." split1 drop 16 tail* 6 head* download-link ] [ 2drop f ] if [ "." split1 drop 16 tail* 6 head* download-link ] [ 2drop f ] if
] when [XML <td class="supported"><div class="bigdiv"><-></div></td> XML]
[XML <td><-></td> XML] ; ] [
[XML <td class="doesnotexist" /> XML]
] if* ;
CONSTANT: oses CONSTANT: oses
{ {
@ -47,22 +48,26 @@ CONSTANT: cpus
: download-grid ( -- xml ) : download-grid ( -- xml )
oses oses
[ values [ [XML <th><-></th> XML] ] map ] [ values [ [XML <th align='center' scope='col'><-></th> XML] ] map ]
[ [
keys keys
cpus [ cpus [
[ nip second ] [ first ] 2bi [ [ nip second ] [ first ] 2bi [
swap download-grid-cell swap download-grid-cell
] curry map [XML <tr><th><-></th><-></tr> XML] ] curry map
[XML <tr><th align='center' scope='row'><-></th><-></tr> XML]
] with map ] with map
] bi [XML <table><tr><th/><-></tr><-></table> XML] ; ] bi
[XML
<table id="downloads" cellspacing="0">
<tr><th class="nobg">OS/CPU</th><-></tr>
<->
</table>
XML] ;
: <download-grid-action> ( -- action ) : <download-grid-action> ( -- action )
<action> <action>
[ [ download-grid xml>string "text/html" <content> ] >>display ;
download-grid
xml>string "text/html" <content>
] >>display ;
: validate-os/cpu ( -- ) : validate-os/cpu ( -- )
{ {
@ -132,16 +137,16 @@ CONSTANT: cpus
os>> { os>> {
{ "winnt" "Windows XP (also tested on Vista)" } { "winnt" "Windows XP (also tested on Vista)" }
{ "macosx" "Mac OS X 10.5 Leopard" } { "macosx" "Mac OS X 10.5 Leopard" }
{ "linux" "Linux 2.6.16 with GLIBC 2.4" } { "linux" "Ubuntu Linux 9.04 (other distributions may also work)" }
{ "freebsd" "FreeBSD 7.0" } { "freebsd" "FreeBSD 7.0" }
{ "netbsd" "NetBSD 4.0" } { "netbsd" "NetBSD 4.0" }
{ "openbsd" "OpenBSD 4.2" } { "openbsd" "OpenBSD 4.4" }
} at } at
] [ ] [
dup cpu>> "x86.32" = [ dup cpu>> "x86.32" = [
os>> { os>> {
{ [ dup { "winnt" "linux" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] } { [ dup { "winnt" "linux" "freebsd" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] }
{ [ dup { "freebsd" "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] } { [ dup { "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] }
{ [ t ] [ drop f ] } { [ t ] [ drop f ] }
} cond } cond
] [ drop f ] if ] [ drop f ] if

View File

@ -23,7 +23,8 @@ webapps.pastebin
webapps.planet webapps.planet
webapps.wiki webapps.wiki
webapps.user-admin webapps.user-admin
webapps.help ; webapps.help
webapps.mason ;
IN: websites.concatenative IN: websites.concatenative
: test-db ( -- db ) "resource:test.db" <sqlite-db> ; : test-db ( -- db ) "resource:test.db" <sqlite-db> ;
@ -95,6 +96,7 @@ SYMBOL: dh-file
<planet> <login-config> <factor-boilerplate> test-db <alloy> "planet.factorcode.org" add-responder <planet> <login-config> <factor-boilerplate> test-db <alloy> "planet.factorcode.org" add-responder
home "docs" append-path <help-webapp> test-db <alloy> "docs.factorcode.org" add-responder home "docs" append-path <help-webapp> test-db <alloy> "docs.factorcode.org" add-responder
home "cgi" append-path <gitweb> "gitweb.factorcode.org" add-responder home "cgi" append-path <gitweb> "gitweb.factorcode.org" add-responder
<mason-app> "builds.factorcode.org" add-responder
main-responder set-global ; main-responder set-global ;
: <factor-secure-config> ( -- config ) : <factor-secure-config> ( -- config )