]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Sep 2008 02:20:21 +0000 (21:20 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Sep 2008 02:20:21 +0000 (21:20 -0500)
basis/alarms/alarms-docs.factor
basis/alarms/alarms.factor
core/alien/alien-docs.factor
unmaintained/random-tester/random-tester.factor
unmaintained/random-tester/random/random.factor
unmaintained/random-tester/safe-words/safe-words.factor

index f07a8b9a2d925399591f4286d2a02edf70ce4c33..49480c0fe0941430d6442a7ec79fc2e4098537c3 100755 (executable)
@@ -9,13 +9,19 @@ HELP: add-alarm
 { $description "Creates and registers an alarm. If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ;\r
 \r
 HELP: later\r
-{ $values { "quot" quotation } { "dt" duration } { "alarm" alarm } }\r
+{ $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }\r
 { $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." } ;\r
 \r
 HELP: cancel-alarm\r
 { $values { "alarm" alarm } }\r
 { $description "Cancels an alarm. Does nothing if the alarm is not active." } ;\r
 \r
+HELP: every\r
+{ $values\r
+     { "quot" quotation } { "duration" duration }\r
+     { "alarm" alarm } }\r
+{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." } ;\r
+\r
 ARTICLE: "alarms" "Alarms"\r
 "Alarms provide a lightweight way to schedule one-time and recurring tasks without spawning a new thread."\r
 { $subsection alarm }\r
index cbbebde579f149d4da1ca85d6997576e712c8879..7fdeca9ae6cc39e5bb8bcf5ced6cd65196aed3a0 100755 (executable)
@@ -82,10 +82,10 @@ PRIVATE>
 : add-alarm ( quot time frequency -- alarm )
     <alarm> [ register-alarm ] keep ;
 
-: later ( quot dt -- alarm )
+: later ( quot duration -- alarm )
     hence f add-alarm ;
 
-: every ( quot dt -- alarm )
+: every ( quot duration -- alarm )
     [ hence ] keep add-alarm ;
 
 : cancel-alarm ( alarm -- )
index 7eca2af8588e8fef9f61ec8d3b8bcf6f52079d68..848af22072457b01f1d7f2a6830571978588343d 100755 (executable)
@@ -10,12 +10,30 @@ HELP: alien
 HELP: dll
 { $class-description "The class of native library handles. See " { $link "syntax-aliens" } " for syntax and " { $link "dll.private" } " for general information." } ;
 
+HELP: dll-valid? ( dll -- ? )
+{ $values { "dll" dll } { "?" "a boolean" } }
+{ $description "Returns true if the library exists and is loaded." } ;
+
 HELP: expired?
-{ $values { "c-ptr" "an alien, byte array, or " { $link f } } { "?" "a boolean" } }
+{ $values { "c-ptr" c-ptr } { "?" "a boolean" } }
 { $description "Tests if the alien is a relic from an earlier session. A byte array is never considered to have expired, whereas passing " { $link f } " always yields true." } ;
 
+HELP: <bad-alien>
+{ $values  { "alien" c-ptr } }
+{ $description "Constructs an invalid alien pointer that has expired." } ;
+
+HELP: <library>
+{ $values
+     { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet "cdecl" } " or " { $snippet "stdcall" } }
+     { "library" library } }
+{ $description "Opens a C library using the path and ABI parameters and outputs a library tuple." }
+{ $notes "User code should use " { $link add-library } " so that the opened library is added to a global hashtable, " { $link libraries } "." } ;
+
+HELP: libraries
+{ $description "A global hashtable that keeps a list of open libraries. Use the " { $link add-library } " word to construct a library and add it with a single call." } ;
+
 HELP: <displaced-alien> ( displacement c-ptr -- alien )
-{ $values { "displacement" "an integer" } { "c-ptr" "an alien, byte array, or " { $link f } } { "alien" "a new alien" } }
+{ $values { "displacement" "an integer" } { "c-ptr" c-ptr } { "alien" "a new alien" } }
 { $description "Creates a new alien address object, wrapping a raw memory address. The alien points to a location in memory which is offset by " { $snippet "displacement" } " from the address of " { $snippet "c-ptr" } "." }
 { $notes "Passing a value of " { $link f } " for " { $snippet "c-ptr" } " creates an alien with an absolute address; this is how " { $link <alien> } " is implemented."
 $nl
@@ -24,7 +42,7 @@ $nl
 { <alien> <displaced-alien> alien-address } related-words
 
 HELP: alien-address ( c-ptr -- addr )
-{ $values { "c-ptr" "an alien or " { $link f } } { "addr" "a non-negative integer" } }
+{ $values { "c-ptr" c-ptr } { "addr" "a non-negative integer" } }
 { $description "Outputs the address of an alien." }
 { $notes "Taking the address of a " { $link byte-array } " is explicitly prohibited since byte arrays can be moved by the garbage collector between the time the address is taken, and when it is accessed. If you need to pass pointers to C functions which will persist across alien calls, you must allocate unmanaged memory instead. See " { $link "malloc" } "." } ;
 
@@ -124,7 +142,7 @@ HELP: alien-callback-error
 } ;
 
 HELP: alien-callback
-{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" "a quotation" } { "alien" c-ptr } }
+{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" "a quotation" } { "c-ptr" c-ptr } }
 { $description
     "Defines a callback from C to Factor which accepts the given set of parameters from the C caller, pushes them on the data stack, calls the quotation, and passes a return value back to the C caller. A return type of " { $snippet "\"void\"" } " indicates that no value is to be returned."
     $nl
@@ -228,7 +246,8 @@ $nl
 "Usually one never has to deal with DLL handles directly; the C library interface creates them as required. However if direct access to these operating system facilities is required, the following primitives can be used:"
 { $subsection dlopen }
 { $subsection dlsym }
-{ $subsection dlclose } ;
+{ $subsection dlclose }
+{ $subsection dll-valid? } ;
 
 ARTICLE: "embedding-api" "Factor embedding API"
 "The Factor embedding API is defined in " { $snippet "vm/master.h" } "."
index 2b2559e02a2c13bce18d4ec26068b6a88b1c6d6c..cbf9f52fa637731d446d800f9ebcf1fa7da3a4c3 100755 (executable)
@@ -1,7 +1,8 @@
 USING: compiler continuations io kernel math namespaces
 prettyprint quotations random sequences vectors
 compiler.units ;
-USING: random-tester.databank random-tester.safe-words ;
+USING: random-tester.databank random-tester.safe-words
+random-tester.random ;
 IN: random-tester
 
 SYMBOL: errored
@@ -13,6 +14,8 @@ ERROR: random-tester-error ;
 : setup-test ( #data #code -- data... quot )
     #! Variable stack effect
     >r [ databank random ] times r>
+    ! 200 300 random-cond ;
+    ! random-if ;
     [ drop \ safe-words get random ] map >quotation ;
 
 : test-compiler ! ( data... quot -- ... )
index 11f2e60d1ab7f64e8054d9bbcb6e9430f02bdb1a..7bedcb8cec7657fb938aaed841bb639e217aaf61 100755 (executable)
@@ -1,6 +1,7 @@
 USING: kernel math sequences namespaces hashtables words
-arrays parser compiler syntax io prettyprint optimizer
-random math.constants math.functions layouts random-tester.utils ;
+arrays parser compiler syntax io prettyprint random
+math.constants math.functions layouts random-tester.utils
+random-tester.safe-words quotations fry combinators ;
 IN: random-tester
 
 ! Tweak me
@@ -72,3 +73,14 @@ IN: random-tester
 : random-complex ( -- C )
     random-number random-number rect> ;
 
+: random-quot ( n -- quot )
+    [ \ safe-words get random ] replicate >quotation ;
+
+: random-if ( n -- quot )
+    [ random-quot ] [ random-quot ] bi
+    '[ , , if ] ;
+
+: random-cond ( m n -- quot )
+    [ '[ , [ random-quot ] [ random-quot ] bi 2array ] replicate ] 
+    [ random-quot ] bi suffix 
+    '[ , cond ] ; 
index 7d8adcbc2aa61e3cad9c689d92b7251d3f3b4809..77e5562f4d299f38a62d1b7aa4c5f8078e195b97 100755 (executable)
@@ -6,8 +6,6 @@ IN: random-tester.safe-words
 
 : ?-words
     {
-        delegate
-
         /f
 
         bits>float bits>double