remove random.backend

db4
Doug Coleman 2008-03-27 06:27:36 -05:00
parent 89cacd416b
commit 2426fc44bb
8 changed files with 27 additions and 44 deletions

View File

@ -1,6 +1,6 @@
USING: vocabs.loader sequences system
random random.mersenne-twister combinators init
namespaces ;
namespaces random.backend ;
"random.mersenne-twister" require
@ -9,5 +9,6 @@ namespaces ;
{ [ unix? ] [ "random.unix" require ] }
} cond
! [ [ 32 random-bits ] with-secure-random <mersenne-twister> random-generator set-global ]
[ millis <mersenne-twister> random-generator set-global ]
"generator.random" add-init-hook

View File

@ -1,24 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types kernel math namespaces sequences
io.backend io.binary combinators system vocabs.loader ;
IN: random.backend
SYMBOL: insecure-random-generator
SYMBOL: secure-random-generator
SYMBOL: random-generator
GENERIC: seed-random ( tuple seed -- )
GENERIC: random-32* ( tuple -- r )
GENERIC: random-bytes* ( n tuple -- bytes )
M: object random-bytes* ( n tuple -- byte-array )
swap [ drop random-32* ] with map >c-uint-array ;
M: object random-32* ( tuple -- n ) 4 random-bytes* le> ;
ERROR: no-random-number-generator ;
M: f random-bytes* ( n obj -- * ) no-random-number-generator ;
M: f random-32* ( obj -- * ) no-random-number-generator ;

View File

@ -1,4 +1,4 @@
USING: kernel random math accessors random.backend ;
USING: kernel random math accessors random ;
IN: random.dummy
TUPLE: random-dummy i ;

View File

@ -1,5 +1,5 @@
USING: kernel math random namespaces random.mersenne-twister
sequences tools.test random.backend ;
sequences tools.test ;
IN: random.mersenne-twister.tests
: check-random ( max -- ? )

View File

@ -5,7 +5,7 @@
USING: arrays kernel math namespaces sequences system init
accessors math.ranges combinators.cleave new-effects
random.backend ;
random ;
IN: random.mersenne-twister
<PRIVATE

View File

@ -1,11 +1,28 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types kernel math namespaces sequences
io.backend io.binary combinators system vocabs.loader
random.backend random.mersenne-twister init ;
USE: prettyprint
io.backend io.binary combinators system vocabs.loader ;
IN: random
SYMBOL: insecure-random-generator
SYMBOL: secure-random-generator
SYMBOL: random-generator
GENERIC: seed-random ( tuple seed -- )
GENERIC: random-32* ( tuple -- r )
GENERIC: random-bytes* ( n tuple -- bytes )
M: object random-bytes* ( n tuple -- byte-array )
swap [ drop random-32* ] with map >c-uint-array ;
M: object random-32* ( tuple -- n ) 4 random-bytes* le> ;
ERROR: no-random-number-generator ;
M: f random-bytes* ( n obj -- * ) no-random-number-generator ;
M: f random-32* ( obj -- * ) no-random-number-generator ;
: random-bytes ( n -- r )
[
dup 4 rem zero? [ 1+ ] unless
@ -29,13 +46,3 @@ IN: random
: with-secure-random ( quot -- )
>r secure-random-generator get r> with-random ; inline
{
{ [ windows? ] [ "random.windows" require ] }
{ [ unix? ] [ "random.unix" require ] }
} cond
[
[ 32 random-bits ] with-secure-random
<mersenne-twister> random-generator set-global
] "random" add-init-hook

View File

@ -1,5 +1,5 @@
USING: alien.c-types io io.files io.nonblocking kernel
namespaces random.backend io.encodings.binary singleton init
namespaces random io.encodings.binary singleton init
accessors ;
IN: random.unix

View File

@ -1,6 +1,5 @@
USING: accessors alien.c-types byte-arrays continuations
kernel windows windows.advapi32 init namespaces
random.backend ;
kernel windows windows.advapi32 init namespaces random ;
IN: random.windows
TUPLE: windows-crypto-context handle ;