diff --git a/basis/compiler/cfg/linear-scan/allocation/allocation.factor b/basis/compiler/cfg/linear-scan/allocation/allocation.factor index a99fea1d24..3dcc925d7c 100644 --- a/basis/compiler/cfg/linear-scan/allocation/allocation.factor +++ b/basis/compiler/cfg/linear-scan/allocation/allocation.factor @@ -1,21 +1,66 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs heaps kernel namespaces sequences +USING: accessors assocs heaps kernel namespaces sequences fry math +combinators arrays sorting compiler.utilities compiler.cfg.linear-scan.allocation.coalescing compiler.cfg.linear-scan.allocation.spilling compiler.cfg.linear-scan.allocation.splitting compiler.cfg.linear-scan.allocation.state ; IN: compiler.cfg.linear-scan.allocation +: relevant-ranges ( new inactive -- new' inactive' ) + ! Slice off all ranges of 'inactive' that precede the start of 'new' + [ [ ranges>> ] bi@ ] [ nip start>> ] 2bi '[ to>> _ >= ] filter ; + +: intersect-live-range ( range1 range2 -- n/f ) + 2dup [ from>> ] bi@ > [ swap ] when + 2dup [ to>> ] [ from>> ] bi* >= [ nip from>> ] [ 2drop f ] if ; + +: intersect-live-ranges ( ranges1 ranges2 -- n ) + { + { [ over empty? ] [ 2drop 1/0. ] } + { [ dup empty? ] [ 2drop 1/0. ] } + [ + 2dup [ first ] bi@ intersect-live-range dup [ 2nip ] [ + drop + 2dup [ first from>> ] bi@ < + [ [ rest-slice ] dip ] [ rest-slice ] if + intersect-live-ranges + ] if + ] + } cond ; + +: intersect-inactive ( new inactive -- n ) + relevant-ranges intersect-live-ranges ; + +: compute-free-pos ( new -- free-pos ) + dup vreg>> + [ nip reg-class>> registers get at [ 1/0. ] H{ } map>assoc ] + [ inactive-intervals-for [ [ reg>> swap ] keep intersect-inactive ] with H{ } map>assoc ] + [ nip active-intervals-for [ reg>> 0 ] H{ } map>assoc ] + 2tri 3array assoc-combine + >alist alist-max ; + +: no-free-registers? ( result -- ? ) + second 0 = ; inline + +: register-available? ( new result -- ? ) + [ end>> ] [ second ] bi* < ; inline + +: register-available ( new result -- ) + first >>reg add-active ; + +: register-partially-available ( new result -- ) + [ second split-before-use ] keep + '[ _ register-available ] [ add-unhandled ] bi* ; + : assign-register ( new -- ) dup coalesce? [ coalesce ] [ - dup vreg>> free-registers-for [ - dup intersecting-inactive - [ assign-blocked-register ] - [ assign-inactive-register ] - if-empty - ] [ assign-free-register ] - if-empty + dup compute-free-pos { + { [ dup no-free-registers? ] [ drop assign-blocked-register ] } + { [ 2dup register-available? ] [ register-available ] } + [ register-partially-available ] + } cond ] if ; : handle-interval ( live-interval -- ) diff --git a/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor b/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor index 4981a223a4..2f4130e9ad 100644 --- a/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor +++ b/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor @@ -1,12 +1,24 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators fry hints kernel locals -math sequences sets sorting splitting +math sequences sets sorting splitting compiler.utilities compiler.cfg.linear-scan.allocation.state compiler.cfg.linear-scan.allocation.splitting compiler.cfg.linear-scan.live-intervals ; IN: compiler.cfg.linear-scan.allocation.spilling +: find-use ( live-interval n quot -- elt ) + [ uses>> ] 2dip curry find nip ; inline + +: spill-existing? ( new existing -- ? ) + #! Test if 'new' will be used before 'existing'. + over start>> '[ _ [ > ] find-use -1 or ] bi@ < ; + +: interval-to-spill ( active-intervals current -- live-interval ) + #! We spill the interval with the most distant use location. + start>> '[ dup _ [ >= ] find-use ] { } map>assoc + alist-max first ; + : split-for-spill ( live-interval n -- before after ) split-interval [ @@ -17,14 +29,6 @@ IN: compiler.cfg.linear-scan.allocation.spilling [ ] 2tri ; -: find-use ( live-interval n quot -- i elt ) - [ uses>> ] 2dip curry find ; inline - -: interval-to-spill ( active-intervals current -- live-interval ) - #! We spill the interval with the most distant use location. - start>> '[ dup _ [ >= ] find-use nip ] { } map>assoc - [ ] [ [ [ second ] bi@ > ] most ] map-reduce first ; - : assign-spill ( before after -- before after ) #! If it has been spilled already, reuse spill location. over reload-from>> @@ -39,8 +43,8 @@ IN: compiler.cfg.linear-scan.allocation.spilling #! with the most distant use location. Spill the existing #! interval, then process the new interval and the tail end #! of the existing interval again. - [ reuse-register ] [ nip delete-active ] + [ reg>> >>reg add-active ] [ split-and-spill [ add-handled ] [ add-unhandled ] bi* ] 2tri ; : spill-new ( new existing -- ) @@ -50,10 +54,6 @@ IN: compiler.cfg.linear-scan.allocation.spilling #! again. [ dup split-and-spill add-unhandled ] dip spill-existing ; -: spill-existing? ( new existing -- ? ) - #! Test if 'new' will be used before 'existing'. - over start>> '[ _ [ > ] find-use nip -1 or ] bi@ < ; - : assign-blocked-register ( new -- ) [ dup vreg>> active-intervals-for ] keep interval-to-spill 2dup spill-existing? [ spill-existing ] [ spill-new ] if ; diff --git a/basis/compiler/cfg/linear-scan/allocation/splitting/splitting.factor b/basis/compiler/cfg/linear-scan/allocation/splitting/splitting.factor index 40ee4083e4..e31fcedace 100644 --- a/basis/compiler/cfg/linear-scan/allocation/splitting/splitting.factor +++ b/basis/compiler/cfg/linear-scan/allocation/splitting/splitting.factor @@ -28,9 +28,7 @@ IN: compiler.cfg.linear-scan.allocation.splitting '[ _ <= ] partition ; : record-split ( live-interval before after -- ) - [ >>split-next drop ] - [ [ >>split-before ] [ >>split-after ] bi* drop ] - 2bi ; inline + [ >>split-before ] [ >>split-after ] bi* drop ; inline ERROR: splitting-too-early ; @@ -59,62 +57,21 @@ ERROR: splitting-atomic-interval ; HINTS: split-interval live-interval object ; -: reuse-register ( new existing -- ) - reg>> >>reg add-active ; - -: relevant-ranges ( new inactive -- new' inactive' ) - ! Slice off all ranges of 'inactive' that precede the start of 'new' - [ [ ranges>> ] bi@ ] [ nip start>> ] 2bi '[ to>> _ >= ] filter ; - -: intersect-live-range ( range1 range2 -- n/f ) - 2dup [ from>> ] bi@ > [ swap ] when - 2dup [ to>> ] [ from>> ] bi* >= [ nip from>> ] [ 2drop f ] if ; - -: intersect-live-ranges ( ranges1 ranges2 -- n ) - { - { [ over empty? ] [ 2drop 1/0. ] } - { [ dup empty? ] [ 2drop 1/0. ] } - [ - 2dup [ first ] bi@ intersect-live-range dup [ 2nip ] [ - drop - 2dup [ first from>> ] bi@ < - [ [ rest-slice ] dip ] [ rest-slice ] if - intersect-live-ranges - ] if - ] - } cond ; - -: intersect-inactive ( new inactive active-regs -- n/f ) - ! If the interval's register is currently in use, we cannot - ! re-use it. - 2dup [ reg>> ] dip key? - [ 3drop f ] [ drop relevant-ranges intersect-live-ranges ] if ; - -: intersecting-inactive ( new -- live-intervals ) - dup vreg>> - [ inactive-intervals-for ] - [ active-intervals-for [ reg>> ] map unique ] bi - '[ tuck _ intersect-inactive ] with { } map>assoc - [ nip ] assoc-filter ; +: split-between-blocks ( new n -- before after ) + split-interval + 2dup [ compute-start/end ] bi@ ; : insert-use-for-copy ( seq n -- seq' ) - [ 1array split1 ] keep [ 1 - ] keep 2array glue ; + dup 1 + [ nip 1array split1 ] 2keep 2array glue ; : split-before-use ( new n -- before after ) ! Find optimal split position ! Insert move instruction - [ '[ _ insert-use-for-copy ] change-uses ] keep - 1 - split-interval - 2dup [ compute-start/end ] bi@ ; - -: assign-inactive-register ( new live-intervals -- ) - ! If there is an interval which is inactive for the entire lifetime - ! if the new interval, reuse its vreg. Otherwise, split new so that - ! the first half fits. - sort-values last - 2dup [ end>> ] [ second ] bi* < [ - first reuse-register + 1 - + 2dup swap covers? [ + [ '[ _ insert-use-for-copy ] change-uses ] keep + split-between-blocks + 2dup >>split-next drop ] [ - [ second split-before-use ] keep - '[ _ first reuse-register ] [ add-unhandled ] bi* + split-between-blocks ] if ; \ No newline at end of file diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state.factor b/basis/compiler/cfg/linear-scan/allocation/state/state.factor index 2a1e87dcdd..737133aa32 100644 --- a/basis/compiler/cfg/linear-scan/allocation/state/state.factor +++ b/basis/compiler/cfg/linear-scan/allocation/state/state.factor @@ -6,13 +6,7 @@ compiler.cfg.linear-scan.live-intervals ; IN: compiler.cfg.linear-scan.allocation.state ! Mapping from register classes to sequences of machine registers -SYMBOL: free-registers - -: free-registers-for ( vreg -- seq ) - reg-class>> free-registers get at ; - -: deallocate-register ( live-interval -- ) - [ reg>> ] [ vreg>> ] bi free-registers-for push ; +SYMBOL: registers ! Vector of active live intervals SYMBOL: active-intervals @@ -47,7 +41,7 @@ SYMBOL: handled-intervals : finished? ( n live-interval -- ? ) end>> swap < ; : finish ( n live-interval -- keep? ) - nip [ deallocate-register ] [ add-handled ] bi f ; + nip add-handled f ; SYMBOL: check-allocation? @@ -121,7 +115,7 @@ SYMBOL: spill-counts spill-counts get [ dup 1 + ] change-at ; : init-allocator ( registers -- ) - [ reverse >vector ] assoc-map free-registers set + registers set [ 0 ] reg-class-assoc spill-counts set unhandled-intervals set [ V{ } clone ] reg-class-assoc active-intervals set diff --git a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor index 243e83445d..b43294818b 100644 --- a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor +++ b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor @@ -79,7 +79,7 @@ check-allocation? on { end 10 } { uses V{ 0 1 3 7 10 } } } - 4 [ >= ] find-use nip + 4 [ >= ] find-use ] unit-test [ 4 ] [ @@ -89,7 +89,7 @@ check-allocation? on { end 10 } { uses V{ 0 1 3 4 10 } } } - 4 [ >= ] find-use nip + 4 [ >= ] find-use ] unit-test [ f ] [ @@ -99,7 +99,7 @@ check-allocation? on { end 10 } { uses V{ 0 1 3 4 10 } } } - 100 [ >= ] find-use nip + 100 [ >= ] find-use ] unit-test [ @@ -1324,7 +1324,7 @@ USING: math.private compiler.cfg.debugger ; ! Spill slot liveness was computed incorrectly, leading to a FEP ! early in bootstrap on x86-32 -[ t ] [ +[ t t ] [ [ H{ } clone live-ins set H{ } clone live-outs set @@ -1349,7 +1349,9 @@ USING: math.private compiler.cfg.debugger ; } } } dup 1array { { int-regs V{ 0 1 2 3 } } } (linear-scan) - instructions>> first live-spill-slots>> empty? + instructions>> first + [ live-spill-slots>> empty? ] + [ live-registers>> empty? ] bi ] with-scope ] unit-test @@ -1410,7 +1412,6 @@ USING: math.private compiler.cfg.debugger ; { uses { 5 10 } } { ranges V{ T{ live-range f 5 10 } } } } - H{ } intersect-inactive ] unit-test diff --git a/basis/compiler/utilities/utilities.factor b/basis/compiler/utilities/utilities.factor index 31faaef480..ac276b6e41 100644 --- a/basis/compiler/utilities/utilities.factor +++ b/basis/compiler/utilities/utilities.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences sequences.private arrays vectors fry -math.order namespaces assocs ; +math math.order namespaces assocs ; IN: compiler.utilities : flattener ( seq quot -- seq vector quot' ) @@ -25,3 +25,6 @@ IN: compiler.utilities SYMBOL: yield-hook yield-hook [ [ ] ] initialize + +: alist-max ( alist -- pair ) + [ ] [ [ [ second ] bi@ > ] most ] map-reduce ; \ No newline at end of file diff --git a/basis/generalizations/generalizations-tests.factor b/basis/generalizations/generalizations-tests.factor index c877acf936..b781e2a7f0 100644 --- a/basis/generalizations/generalizations-tests.factor +++ b/basis/generalizations/generalizations-tests.factor @@ -67,3 +67,8 @@ IN: generalizations.tests [ 1 2 3 [ ] [ ] 3 nbi-curry ] unit-test [ 15 3 ] [ 1 2 3 4 5 [ + + + + ] [ - - - - ] 5 nbi ] unit-test + +: nover-test ( -- a b c d e f g ) + 1 2 3 4 3 nover ; + +[ 1 2 3 4 1 2 3 ] [ nover-test ] unit-test diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index 0ea179b52c..abcbd54cab 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -40,7 +40,7 @@ MACRO: npick ( n -- ) 1- [ dup ] [ '[ _ dip swap ] ] repeat ; MACRO: nover ( n -- ) - dup '[ _ 1 + npick ] n*quot ; + dup 1 + '[ _ npick ] n*quot ; MACRO: ndup ( n -- ) dup '[ _ npick ] n*quot ; diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index c1dd591013..1fb836427a 100755 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -78,6 +78,7 @@ PRIVATE> : help-lint ( prefix -- ) [ + auto-use? off all-vocabs-seq [ vocab-name ] map all-vocabs set group-articles vocab-articles set child-vocabs diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 19a8f17a0c..314062591d 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -264,5 +264,8 @@ M: real atan fatan ; : ceiling ( x -- y ) neg floor neg ; foldable +: floor-to ( x step -- y ) + dup zero? [ drop ] [ [ / floor ] [ * ] bi ] if ; + : lerp ( a b t -- a_t ) [ over - ] dip * + ; inline diff --git a/basis/models/range/range-docs.factor b/basis/models/range/range-docs.factor index 1adba493b4..5f5b2f4405 100644 --- a/basis/models/range/range-docs.factor +++ b/basis/models/range/range-docs.factor @@ -7,7 +7,7 @@ HELP: range { $notes { $link "ui.gadgets.sliders" } " use range models." } ; HELP: -{ $values { "value" real } { "page" real } { "min" real } { "max" real } { "range" range } } +{ $values { "value" real } { "page" real } { "min" real } { "max" real } { "step" real } { "range" range } } { $description "Creates a new " { $link range } " model." } ; HELP: range-model diff --git a/basis/models/range/range-tests.factor b/basis/models/range/range-tests.factor index e9119e8452..51f8b06ef5 100644 --- a/basis/models/range/range-tests.factor +++ b/basis/models/range/range-tests.factor @@ -3,13 +3,17 @@ USING: arrays generic kernel math models namespaces sequences assocs tools.test models.range ; ! Test -: setup-range ( -- range ) 0 0 0 255 ; +: setup-range ( -- range ) 0 0 0 255 1 ; +: setup-stepped-range ( -- range ) 0 0 0 255 2 ; ! clamp-value should not go past range ends [ 0 ] [ -10 setup-range clamp-value ] unit-test [ 255 ] [ 2000 setup-range clamp-value ] unit-test [ 14 ] [ 14 setup-range clamp-value ] unit-test +! step-value +[ 14 ] [ 15 setup-stepped-range step-value ] unit-test + ! range min/max/page values should be correct [ 0 ] [ setup-range range-page-value ] unit-test [ 0 ] [ setup-range range-min-value ] unit-test diff --git a/basis/models/range/range.factor b/basis/models/range/range.factor index c8bc8d8e54..c39c80c7d1 100644 --- a/basis/models/range/range.factor +++ b/basis/models/range/range.factor @@ -1,22 +1,26 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel models arrays sequences math math.order -models.product ; +models.product generalizations math.functions ; FROM: models.product => product ; IN: models.range TUPLE: range < product ; -: ( value page min max -- range ) - 4array [ ] map range new-product ; +: ( value page min max step -- range ) + 5 narray [ ] map range new-product ; : range-model ( range -- model ) dependencies>> first ; : range-page ( range -- model ) dependencies>> second ; : range-min ( range -- model ) dependencies>> third ; : range-max ( range -- model ) dependencies>> fourth ; +: range-step ( range -- model ) dependencies>> 4 swap nth ; + +: step-value ( value range -- value' ) + range-step value>> floor-to ; M: range range-value - [ range-model value>> ] keep clamp-value ; + [ range-model value>> ] [ clamp-value ] [ step-value ] tri ; M: range range-page-value range-page value>> ; diff --git a/basis/roman/roman.factor b/basis/roman/roman.factor index 92202da8ca..817b6637d6 100644 --- a/basis/roman/roman.factor +++ b/basis/roman/roman.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs fry generalizations grouping -kernel lexer macros make math math.order math.vectors +USING: accessors arrays assocs effects fry generalizations +grouping kernel lexer macros math math.order math.vectors namespaces parser quotations sequences sequences.private -splitting.monotonic stack-checker strings unicode.case -words effects ; +splitting.monotonic stack-checker strings unicode.case words ; IN: roman = ( ch1 ch2 -- ? ) [ roman-digit-index ] bi@ >= ; : roman>n ( ch -- n ) roman-digit-index roman-values nth ; -: (>roman) ( n -- ) - roman-values roman-digits [ - [ /mod swap ] dip concat % - ] 2each drop ; - : (roman>) ( seq -- n ) [ [ roman>n ] map ] [ all-eq? ] bi [ sum ] [ first2 swap - ] if ; @@ -41,12 +35,15 @@ ERROR: roman-range-error n ; PRIVATE> : >roman ( n -- str ) - dup roman-range-check [ (>roman) ] "" make ; + roman-range-check + roman-values roman-digits [ + [ /mod swap ] dip concat + ] 2map "" concat-as nip ; : >ROMAN ( n -- str ) >roman >upper ; : roman> ( str -- n ) - >lower [ roman<= ] monotonic-split [ (roman>) ] sigma ; + >lower [ roman>= ] monotonic-split [ (roman>) ] sigma ; << + SYNTAX: ROMAN-OP: scan-word [ name>> "roman" prepend create-in ] keep 1quotation '[ _ binary-roman-op ] dup infer [ in>> ] [ out>> ] bi [ "string" ] bi@ define-declared ; + >> ROMAN-OP: + diff --git a/basis/serialize/serialize.factor b/basis/serialize/serialize.factor index 4e94b6a51d..b7e395fa35 100644 --- a/basis/serialize/serialize.factor +++ b/basis/serialize/serialize.factor @@ -12,7 +12,7 @@ vectors byte-arrays quotations hashtables assocs help.syntax help.markup splitting io.streams.byte-array io.encodings.string io.encodings.utf8 io.encodings.binary combinators accessors locals prettyprint compiler.units sequences.private -classes.tuple.private ; +classes.tuple.private vocabs.loader ; IN: serialize GENERIC: (serialize) ( obj -- ) @@ -202,7 +202,7 @@ SYMBOL: deserialized (deserialize-string) dup intern-object ; : deserialize-word ( -- word ) - (deserialize) (deserialize) 2dup lookup + (deserialize) (deserialize) 2dup [ require ] keep lookup dup [ 2nip ] [ drop 2array unparse "Unknown word: " prepend throw diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index a63837a0da..03a86fe25f 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -246,10 +246,14 @@ CONSTANT: window-control>ex-style : needs-sysmenu? ( controls -- ? ) { close-button minimize-button maximize-button } intersects? ; +: has-titlebar? ( controls -- ? ) + { small-title-bar normal-title-bar } intersects? ; + : world>style ( world -- n ) window-controls>> [ window-control>style symbols>flags ] - [ needs-sysmenu? [ WS_SYSMENU bitor ] when ] bi ; + [ needs-sysmenu? [ WS_SYSMENU bitor ] when ] + [ has-titlebar? [ WS_POPUP bitor ] unless ] tri ; : world>ex-style ( world -- n ) window-controls>> window-control>ex-style symbols>flags ; @@ -270,12 +274,12 @@ CONSTANT: window-control>ex-style : handle-wm-size ( hWnd uMsg wParam lParam -- ) 2nip [ lo-word ] keep hi-word 2array - dup { 0 0 } = [ 2drop ] [ swap window (>>dim) ] if ; + dup { 0 0 } = [ 2drop ] [ swap window [ (>>dim) ] [ drop ] if* ] if ; : handle-wm-move ( hWnd uMsg wParam lParam -- ) 2nip [ lo-word ] keep hi-word 2array - swap window (>>window-loc) ; + swap window [ (>>window-loc) ] [ drop ] if* ; CONSTANT: wm-keydown-codes H{ diff --git a/basis/ui/gadgets/scrollers/scrollers-tests.factor b/basis/ui/gadgets/scrollers/scrollers-tests.factor index 4002c8b40e..5f5cc91846 100644 --- a/basis/ui/gadgets/scrollers/scrollers-tests.factor +++ b/basis/ui/gadgets/scrollers/scrollers-tests.factor @@ -21,7 +21,7 @@ IN: ui.gadgets.scrollers.tests [ ] [ dup "g" set - 10 1 0 100 20 1 0 100 2array + 10 1 0 100 1 20 1 0 100 1 2array "v" set ] unit-test diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index 0852a6fe5d..8c73226639 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -49,7 +49,7 @@ scroller H{ } set-gestures : ( -- model ) - 0 0 0 0 0 0 0 0 2array ; + 0 0 0 0 1 0 0 0 0 1 2array ; M: viewport pref-dim* gadget-child pref-viewport-dim ; diff --git a/basis/ui/gadgets/sliders/sliders.factor b/basis/ui/gadgets/sliders/sliders.factor index d293fd7f8b..b98a0d152e 100644 --- a/basis/ui/gadgets/sliders/sliders.factor +++ b/basis/ui/gadgets/sliders/sliders.factor @@ -9,11 +9,15 @@ IN: ui.gadgets.sliders TUPLE: slider < track elevator thumb saved line ; -: slider-value ( gadget -- n ) model>> range-value >fixnum ; +: slider-value ( gadget -- n ) model>> range-value ; : slider-page ( gadget -- n ) model>> range-page-value ; +: slider-min ( gadget -- n ) model>> range-min-value ; : slider-max ( gadget -- n ) model>> range-max-value ; : slider-max* ( gadget -- n ) model>> range-max-value* ; +: slider-length ( gadget -- n ) [ slider-max ] [ slider-min ] bi - ; +: slider-length* ( gadget -- n ) [ slider-max* ] [ slider-min ] bi - ; + : slide-by ( amount slider -- ) model>> move-by ; : slide-by-page ( amount slider -- ) model>> move-by-page ; @@ -34,7 +38,9 @@ CONSTANT: elevator-padding 4 CONSTANT: min-thumb-dim 30 : visible-portion ( slider -- n ) - [ slider-page ] [ slider-max 1 max ] bi / 1 min ; + [ slider-page ] + [ slider-length 1 max ] + bi / 1 min ; : thumb-dim ( slider -- h ) [ @@ -48,7 +54,7 @@ CONSTANT: min-thumb-dim 30 #! x*n is the screen position of the thumb, and conversely #! for x/n. The '1 max' calls avoid division by zero. [ [ elevator-length ] [ thumb-dim ] bi - 1 max ] - [ slider-max* 1 max ] + [ slider-length* 1 max ] bi / ; : slider>screen ( m slider -- n ) slider-scale * ; @@ -131,7 +137,9 @@ elevator H{ swap >>orientation ; : thumb-loc ( slider -- loc ) - [ slider-value ] keep slider>screen elevator-padding + ; + [ slider-value ] + [ slider-min - ] + [ slider>screen elevator-padding + ] tri ; : layout-thumb-loc ( thumb slider -- ) [ thumb-loc ] [ orientation>> ] bi n*v @@ -235,4 +243,5 @@ PRIVATE> [ f track-add ] [ f track-add ] [ drop { 1 1 } >>dim f track-add ] - } cleave ; \ No newline at end of file + } cleave ; + diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index aee19279a4..37ec4f35b1 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -198,7 +198,7 @@ PRIVATE> windows get empty? not ; : ?attributes ( gadget title/attributes -- attributes ) - dup string? [ world-attributes new swap >>title ] when + dup string? [ world-attributes new swap >>title ] [ clone ] if swap [ [ [ 1array ] [ f ] if* ] curry unless* ] curry change-gadgets ; PRIVATE> diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 3670b10d3c..0fce78dd68 100755 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -1,4 +1,5 @@ -USING: kernel help.markup help.syntax sequences quotations assocs ; +USING: assocs hashtables help.markup help.syntax kernel +quotations sequences ; IN: sets ARTICLE: "sets" "Set-theoretic operations on sequences" @@ -125,3 +126,4 @@ HELP: gather { "seq" sequence } { "quot" quotation } { "newseq" sequence } } { $description "Maps a quotation onto a sequence, concatenates the results of the mapping, and removes duplicates." } ; + diff --git a/core/sets/sets-tests.factor b/core/sets/sets-tests.factor old mode 100644 new mode 100755 index 838a0a82b8..f9f8ba9e65 --- a/core/sets/sets-tests.factor +++ b/core/sets/sets-tests.factor @@ -29,3 +29,4 @@ IN: sets.tests [ f ] [ { } { 1 } intersects? ] unit-test [ f ] [ { 1 } { } intersects? ] unit-test + diff --git a/extra/color-picker/color-picker.factor b/extra/color-picker/color-picker.factor index d7919aafd1..56a60d6fc8 100755 --- a/extra/color-picker/color-picker.factor +++ b/extra/color-picker/color-picker.factor @@ -26,7 +26,7 @@ M: color-preview model-changed horizontal 1 >>line ; : ( -- gadget model ) - 3 [ 0 0 0 255 ] replicate + 3 [ 0 0 0 255 1 ] replicate [ { 5 5 } >>gap [ add-gadget ] reduce ] [ [ range-model ] map ] bi ; diff --git a/extra/game-worlds/game-worlds.factor b/extra/game-worlds/game-worlds.factor index 2fb115b5d0..542c48fbae 100644 --- a/extra/game-worlds/game-worlds.factor +++ b/extra/game-worlds/game-worlds.factor @@ -1,5 +1,5 @@ USING: accessors game-input game-loop kernel math ui.gadgets -ui.gadgets.worlds ui.gestures ; +ui.gadgets.worlds ui.gestures threads ; IN: game-worlds TUPLE: game-world < world @@ -9,7 +9,7 @@ TUPLE: game-world < world GENERIC: tick-length ( world -- millis ) M: game-world draw* - swap >>tick-slice draw-world ; + swap >>tick-slice relayout-1 yield ; M: game-world begin-world open-game-input diff --git a/extra/histogram/histogram-docs.factor b/extra/histogram/histogram-docs.factor new file mode 100755 index 0000000000..0c4059fa59 --- /dev/null +++ b/extra/histogram/histogram-docs.factor @@ -0,0 +1,83 @@ +IN: histogram +USING: help.markup help.syntax sequences hashtables quotations assocs ; + +HELP: histogram +{ $values + { "seq" sequence } + { "hashtable" hashtable } +} +{ $examples + { $example "! Count the number of times an element appears in a sequence." + "USING: prettyprint histogram ;" + "\"aaabc\" histogram ." + "H{ { 97 3 } { 98 1 } { 99 1 } }" + } +} +{ $description "Returns a hashtable where the keys are the elements of the sequence and the values are the number of times they appeared in that sequence." } ; + +HELP: histogram* +{ $values + { "hashtable" hashtable } { "seq" sequence } + { "hashtable" hashtable } +} +{ $examples + { $example "! Count the number of times the elements of two sequences appear." + "USING: prettyprint histogram ;" + "\"aaabc\" histogram \"aaaaaabc\" histogram* ." + "H{ { 97 9 } { 98 2 } { 99 2 } }" + } +} +{ $description "Takes an existing hashtable and uses " { $link histogram } " to continue counting the number of occurences of each element." } ; + +HELP: sequence>assoc +{ $values + { "seq" sequence } { "quot" quotation } { "exemplar" "an exemplar assoc" } + { "assoc" assoc } +} +{ $examples + { $example "! Iterate over a sequence and increment the count at each element" + "USING: assocs prettyprint histogram ;" + "\"aaabc\" [ inc-at ] H{ } sequence>assoc ." + "H{ { 97 3 } { 98 1 } { 99 1 } }" + } +} +{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } " according to the passed quotation." } ; + +HELP: sequence>assoc* +{ $values + { "assoc" assoc } { "seq" sequence } { "quot" quotation } + { "assoc" assoc } +} +{ $examples + { $example "! Iterate over a sequence and add the counts to an existing assoc" + "USING: assocs prettyprint histogram kernel ;" + "H{ { 97 2 } { 98 1 } } clone \"aaabc\" [ inc-at ] sequence>assoc* ." + "H{ { 97 5 } { 98 2 } { 99 1 } }" + } +} +{ $description "Iterates over a sequence, allowing elements of the sequence to be added to an existing " { $snippet "assoc" } " according to the passed quotation." } ; + +HELP: sequence>hashtable +{ $values + { "seq" sequence } { "quot" quotation } + { "hashtable" hashtable } +} +{ $examples + { $example "! Count the number of times an element occurs in a sequence" + "USING: assocs prettyprint histogram ;" + "\"aaabc\" [ inc-at ] sequence>hashtable ." + "H{ { 97 3 } { 98 1 } { 99 1 } }" + } +} +{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a hashtable according to the passed quotation." } ; + +ARTICLE: "histogram" "Computing histograms" +"Counting elements in a sequence:" +{ $subsection histogram } +{ $subsection histogram* } +"Combinators for implementing histogram:" +{ $subsection sequence>assoc } +{ $subsection sequence>assoc* } +{ $subsection sequence>hashtable } ; + +ABOUT: "histogram" diff --git a/extra/histogram/histogram-tests.factor b/extra/histogram/histogram-tests.factor new file mode 100755 index 0000000000..f0e7b3e80e --- /dev/null +++ b/extra/histogram/histogram-tests.factor @@ -0,0 +1,12 @@ +IN: histogram.tests +USING: help.markup help.syntax tools.test histogram ; + +[ + H{ + { 97 2 } + { 98 2 } + { 99 2 } + } +] [ + "aabbcc" histogram +] unit-test diff --git a/extra/histogram/histogram.factor b/extra/histogram/histogram.factor new file mode 100755 index 0000000000..70ddfd3af5 --- /dev/null +++ b/extra/histogram/histogram.factor @@ -0,0 +1,26 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel sequences assocs ; +IN: histogram + +assoc) ( seq quot assoc -- assoc ) + [ swap curry each ] keep ; inline + +PRIVATE> + +: sequence>assoc* ( assoc seq quot: ( obj assoc -- ) -- assoc ) + rot (sequence>assoc) ; inline + +: sequence>assoc ( seq quot: ( obj assoc -- ) exemplar -- assoc ) + clone (sequence>assoc) ; inline + +: sequence>hashtable ( seq quot: ( obj hashtable -- ) -- hashtable ) + H{ } sequence>assoc ; inline + +: histogram* ( hashtable seq -- hashtable ) + [ inc-at ] sequence>assoc* ; + +: histogram ( seq -- hashtable ) + [ inc-at ] sequence>hashtable ; diff --git a/extra/robots/robots.factor b/extra/robots/robots.factor index 3c0eb045f7..af039ef8c4 100644 --- a/extra/robots/robots.factor +++ b/extra/robots/robots.factor @@ -1,15 +1,18 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors http.client kernel unicode.categories -sequences urls splitting combinators splitting.monotonic -combinators.short-circuit assocs unicode.case arrays -math.parser calendar.format make fry present globs -multiline regexp.combinators regexp ; +USING: accessors arrays assocs calendar.format combinators +combinators.short-circuit fry globs http.client kernel make +math.parser multiline namespaces present regexp +regexp.combinators sequences sets splitting splitting.monotonic +unicode.case unicode.categories urls ; IN: robots ! visit-time is GMT, request-rate is pages/second ! crawl-rate is seconds +SYMBOL: robot-identities +robot-identities [ { "FactorSpider" } ] initialize + TUPLE: robots site sitemap rules rules-quot ; : ( site sitemap rules -- robots ) @@ -80,6 +83,13 @@ visit-time request-rate crawl-delay unknowns ; derive-urls [ ] map ] bi 2array '[ _ matches? ] ; +: relevant-rules ( robots -- rules ) + [ + user-agents>> [ + robot-identities get [ swap glob-matches? ] with any? + ] any? + ] filter ; + PRIVATE> : parse-robots.txt ( string -- sitemaps rules-seq ) diff --git a/extra/tokyo/abstractdb/abstractdb.factor b/extra/tokyo/abstractdb/abstractdb.factor new file mode 100644 index 0000000000..ea6d20fc2d --- /dev/null +++ b/extra/tokyo/abstractdb/abstractdb.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel tokyo.alien.tcadb tokyo.assoc-functor ; +IN: tokyo.abstractdb + +<< "tcadb" "abstractdb" define-tokyo-assoc-api >> + +: ( name -- tokyo-abstractdb ) + tcadbnew [ swap tcadbopen drop ] keep + tokyo-abstractdb new [ (>>handle) ] keep ; diff --git a/extra/tokyo/abstractdb/authors.txt b/extra/tokyo/abstractdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/abstractdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/abstractdb/summary.txt b/extra/tokyo/abstractdb/summary.txt new file mode 100644 index 0000000000..a2a21dbe6e --- /dev/null +++ b/extra/tokyo/abstractdb/summary.txt @@ -0,0 +1 @@ +Higher level API for Tokyo Cabinet's Abstract database API. Implements the associative protocol. diff --git a/extra/tokyo/alien/tcadb/authors.txt b/extra/tokyo/alien/tcadb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tcadb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tcadb/summary.txt b/extra/tokyo/alien/tcadb/summary.txt new file mode 100644 index 0000000000..1827298b35 --- /dev/null +++ b/extra/tokyo/alien/tcadb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's Abstract database API diff --git a/extra/tokyo/alien/tcadb/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor new file mode 100644 index 0000000000..efba5f0374 --- /dev/null +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -0,0 +1,69 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil +tokyo.alien.tcbdb tokyo.alien.tcfdb tokyo.alien.tctdb ; +IN: tokyo.alien.tcadb + +LIBRARY: tokyocabinet + +TYPEDEF: void* TCADB + +C-ENUM: + ADBOVOID + ADBOMDB + ADBONDB + ADBOHDB + ADBOBDB + ADBOFDB + ADBOTDB + ADBOSKEL ; + +FUNCTION: TCADB* tcadbnew ( ) ; +FUNCTION: void tcadbdel ( TCADB* adb ) ; +FUNCTION: bool tcadbopen ( TCADB* adb, char* name ) ; +FUNCTION: bool tcadbclose ( TCADB* adb ) ; +FUNCTION: bool tcadbput ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcadbput2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbputkeep ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcadbputkeep2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbputcat ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcadbputcat2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbout ( TCADB* adb, void* kbuf, int ksiz ) ; +FUNCTION: bool tcadbout2 ( TCADB* adb, char* kstr ) ; +FUNCTION: void* tcadbget ( TCADB* adb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tcadbget2 ( TCADB* adb, char* kstr ) ; +FUNCTION: int tcadbvsiz ( TCADB* adb, void* kbuf, int ksiz ) ; +FUNCTION: int tcadbvsiz2 ( TCADB* adb, char* kstr ) ; +FUNCTION: bool tcadbiterinit ( TCADB* adb ) ; +FUNCTION: void* tcadbiternext ( TCADB* adb, int* sp ) ; +FUNCTION: char* tcadbiternext2 ( TCADB* adb ) ; +FUNCTION: TCLIST* tcadbfwmkeys ( TCADB* adb, void* pbuf, int psiz, int max ) ; +FUNCTION: TCLIST* tcadbfwmkeys2 ( TCADB* adb, char* pstr, int max ) ; +FUNCTION: int tcadbaddint ( TCADB* adb, void* kbuf, int ksiz, int num ) ; +FUNCTION: double tcadbadddouble ( TCADB* adb, void* kbuf, int ksiz, double num ) ; +FUNCTION: bool tcadbsync ( TCADB* adb ) ; +FUNCTION: bool tcadboptimize ( TCADB* adb, char* params ) ; +FUNCTION: bool tcadbvanish ( TCADB* adb ) ; +FUNCTION: bool tcadbcopy ( TCADB* adb, char* path ) ; +FUNCTION: bool tcadbtranbegin ( TCADB* adb ) ; +FUNCTION: bool tcadbtrancommit ( TCADB* adb ) ; +FUNCTION: bool tcadbtranabort ( TCADB* adb ) ; +FUNCTION: char* tcadbpath ( TCADB* adb ) ; +FUNCTION: ulonglong tcadbrnum ( TCADB* adb ) ; +FUNCTION: ulonglong tcadbsize ( TCADB* adb ) ; +FUNCTION: TCLIST* tcadbmisc ( TCADB* adb, char* name, TCLIST* args ) ; + +! ----- + +TYPEDEF: void* ADBSKEL + +TYPEDEF: void* ADBMAPPROC + +FUNCTION: bool tcadbsetskel ( TCADB* adb, ADBSKEL* skel ) ; +FUNCTION: int tcadbomode ( TCADB* adb ) ; +FUNCTION: void* tcadbreveal ( TCADB* adb ) ; +FUNCTION: bool tcadbputproc ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; +FUNCTION: bool tcadbforeach ( TCADB* adb, TCITER iter, void* op ) ; +FUNCTION: bool tcadbmapbdb ( TCADB* adb, TCLIST* keys, TCBDB* bdb, ADBMAPPROC proc, void* op, longlong csiz ) ; +FUNCTION: bool tcadbmapbdbemit ( void* map, char* kbuf, int ksiz, char* vbuf, int vsiz ) ; diff --git a/extra/tokyo/alien/tcbdb/authors.txt b/extra/tokyo/alien/tcbdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tcbdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tcbdb/summary.txt b/extra/tokyo/alien/tcbdb/summary.txt new file mode 100644 index 0000000000..bc208423cf --- /dev/null +++ b/extra/tokyo/alien/tcbdb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's B+ Tree database API diff --git a/extra/tokyo/alien/tcbdb/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor new file mode 100755 index 0000000000..8739e04608 --- /dev/null +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -0,0 +1,132 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil ; +IN: tokyo.alien.tcbdb + +LIBRARY: tokyocabinet + +TYPEDEF: void* TCBDB + +CONSTANT: BDBFOPEN HDBFOPEN +CONSTANT: BDBFFATAL HDBFFATAL + +CONSTANT: BDBTLARGE 1 +CONSTANT: BDBTDEFLATE 2 +CONSTANT: BDBTBZIP 4 +CONSTANT: BDBTTCBS 8 +CONSTANT: BDBTEXCODEC 16 + +CONSTANT: BDBOREADER 1 +CONSTANT: BDBOWRITER 2 +CONSTANT: BDBOCREAT 4 +CONSTANT: BDBOTRUNC 8 +CONSTANT: BDBONOLCK 16 +CONSTANT: BDBOLCKNB 32 +CONSTANT: BDBOTSYNC 64 + +TYPEDEF: void* BDBCUR + +C-ENUM: + BDBCPCURRENT + BDBCPBEFORE + BDBCPAFTER ; + +FUNCTION: char* tcbdberrmsg ( int ecode ) ; +FUNCTION: TCBDB* tcbdbnew ( ) ; +FUNCTION: void tcbdbdel ( TCBDB* bdb ) ; +FUNCTION: int tcbdbecode ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbsetmutex ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbsetcmpfunc ( TCBDB* bdb, TCCMP cmp, void* cmpop ) ; +FUNCTION: bool tcbdbtune ( TCBDB* bdb, int lmemb, int nmemb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tcbdbsetcache ( TCBDB* bdb, int lcnum, int ncnum ) ; +FUNCTION: bool tcbdbsetxmsiz ( TCBDB* bdb, longlong xmsiz ) ; +FUNCTION: bool tcbdbopen ( TCBDB* bdb, char* path, int omode ) ; +FUNCTION: bool tcbdbclose ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbput ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcbdbput2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputkeep ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcbdbputkeep2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputcat ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcbdbputcat2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputdup ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcbdbputdup2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputdup3 ( TCBDB* bdb, void* kbuf, int ksiz, TCLIST* vals ) ; +FUNCTION: bool tcbdbout ( TCBDB* bdb, void* kbuf, int ksiz ) ; +FUNCTION: bool tcbdbout2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: bool tcbdbout3 ( TCBDB* bdb, void* kbuf, int ksiz ) ; +FUNCTION: void* tcbdbget ( TCBDB* bdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tcbdbget2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: void* tcbdbget3 ( TCBDB* bdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: TCLIST* tcbdbget4 ( TCBDB* bdb, void* kbuf, int ksiz ) ; +FUNCTION: int tcbdbvnum ( TCBDB* bdb, void* kbuf, int ksiz ) ; +FUNCTION: int tcbdbvnum2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: int tcbdbvsiz ( TCBDB* bdb, void* kbuf, int ksiz ) ; +FUNCTION: int tcbdbvsiz2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: TCLIST* tcbdbrange ( TCBDB* bdb, void* bkbuf, int bksiz, bool binc, void* ekbuf, int eksiz, bool einc, int max ) ; +FUNCTION: TCLIST* tcbdbrange2 ( TCBDB* bdb, char* bkstr, bool binc, char* ekstr, bool einc, int max ) ; +FUNCTION: TCLIST* tcbdbfwmkeys ( TCBDB* bdb, void* pbuf, int psiz, int max ) ; +FUNCTION: TCLIST* tcbdbfwmkeys2 ( TCBDB* bdb, char* pstr, int max ) ; +FUNCTION: int tcbdbaddint ( TCBDB* bdb, void* kbuf, int ksiz, int num ) ; +FUNCTION: double tcbdbadddouble ( TCBDB* bdb, void* kbuf, int ksiz, double num ) ; +FUNCTION: bool tcbdbsync ( TCBDB* bdb ) ; +FUNCTION: bool tcbdboptimize ( TCBDB* bdb, int lmemb, int nmemb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tcbdbvanish ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbcopy ( TCBDB* bdb, char* path ) ; +FUNCTION: bool tcbdbtranbegin ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbtrancommit ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbtranabort ( TCBDB* bdb ) ; +FUNCTION: char* tcbdbpath ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbrnum ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbfsiz ( TCBDB* bdb ) ; +FUNCTION: BDBCUR* tcbdbcurnew ( TCBDB* bdb ) ; +FUNCTION: void tcbdbcurdel ( BDBCUR* cur ) ; +FUNCTION: bool tcbdbcurfirst ( BDBCUR* cur ) ; +FUNCTION: bool tcbdbcurlast ( BDBCUR* cur ) ; +FUNCTION: bool tcbdbcurjump ( BDBCUR* cur, void* kbuf, int ksiz ) ; +FUNCTION: bool tcbdbcurjump2 ( BDBCUR* cur, char* kstr ) ; +FUNCTION: bool tcbdbcurprev ( BDBCUR* cur ) ; +FUNCTION: bool tcbdbcurnext ( BDBCUR* cur ) ; +FUNCTION: bool tcbdbcurput ( BDBCUR* cur, void* vbuf, int vsiz, int cpmode ) ; +FUNCTION: bool tcbdbcurput2 ( BDBCUR* cur, char* vstr, int cpmode ) ; +FUNCTION: bool tcbdbcurout ( BDBCUR* cur ) ; +FUNCTION: void* tcbdbcurkey ( BDBCUR* cur, int* sp ) ; +FUNCTION: char* tcbdbcurkey2 ( BDBCUR* cur ) ; +FUNCTION: void* tcbdbcurkey3 ( BDBCUR* cur, int* sp ) ; +FUNCTION: void* tcbdbcurval ( BDBCUR* cur, int* sp ) ; +FUNCTION: char* tcbdbcurval2 ( BDBCUR* cur ) ; +FUNCTION: void* tcbdbcurval3 ( BDBCUR* cur, int* sp ) ; +FUNCTION: bool tcbdbcurrec ( BDBCUR* cur, TCXSTR* kxstr, TCXSTR* vxstr ) ; + +! ----------- + +FUNCTION: void tcbdbsetecode ( TCBDB* bdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tcbdbsetdbgfd ( TCBDB* bdb, int fd ) ; +FUNCTION: int tcbdbdbgfd ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbhasmutex ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbmemsync ( TCBDB* bdb, bool phys ) ; +FUNCTION: bool tcbdbcacheclear ( TCBDB* bdb ) ; +FUNCTION: TCCMP tcbdbcmpfunc ( TCBDB* bdb ) ; +FUNCTION: void* tcbdbcmpop ( TCBDB* bdb ) ; +FUNCTION: uint tcbdblmemb ( TCBDB* bdb ) ; +FUNCTION: uint tcbdbnmemb ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdblnum ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbnnum ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbbnum ( TCBDB* bdb ) ; +FUNCTION: uint tcbdbalign ( TCBDB* bdb ) ; +FUNCTION: uint tcbdbfbpmax ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbinode ( TCBDB* bdb ) ; +FUNCTION: tokyo_time_t tcbdbmtime ( TCBDB* bdb ) ; +FUNCTION: uchar tcbdbflags ( TCBDB* bdb ) ; +FUNCTION: uchar tcbdbopts ( TCBDB* bdb ) ; +FUNCTION: char* tcbdbopaque ( TCBDB* bdb ) ; +FUNCTION: ulonglong tcbdbbnumused ( TCBDB* bdb ) ; +FUNCTION: bool tcbdbsetlsmax ( TCBDB* bdb, uint lsmax ) ; +FUNCTION: bool tcbdbsetcapnum ( TCBDB* bdb, ulonglong capnum ) ; +FUNCTION: bool tcbdbsetcodecfunc ( TCBDB* bdb, TCCODEC enc, void* encop, TCCODEC dec, void* decop ) ; +FUNCTION: bool tcbdbputdupback ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcbdbputdupback2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputproc ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; +FUNCTION: bool tcbdbcurjumpback ( BDBCUR* cur, void* kbuf, int ksiz ) ; +FUNCTION: bool tcbdbcurjumpback2 ( BDBCUR* cur, char* kstr ) ; +FUNCTION: bool tcbdbforeach ( TCBDB* bdb, TCITER iter, void* op ) ; diff --git a/extra/tokyo/alien/tcfdb/authors.txt b/extra/tokyo/alien/tcfdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tcfdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tcfdb/summary.txt b/extra/tokyo/alien/tcfdb/summary.txt new file mode 100644 index 0000000000..44e056e5d1 --- /dev/null +++ b/extra/tokyo/alien/tcfdb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's Fixed Length database API diff --git a/extra/tokyo/alien/tcfdb/tcfdb.factor b/extra/tokyo/alien/tcfdb/tcfdb.factor new file mode 100755 index 0000000000..91400aaf4e --- /dev/null +++ b/extra/tokyo/alien/tcfdb/tcfdb.factor @@ -0,0 +1,94 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel tokyo.alien.tcutil ; +IN: tokyo.alien.tcfdb + +TYPEDEF: void* TCFDB + +CONSTANT: FDBFOPEN 1 +CONSTANT: FDBFFATAL 2 + +CONSTANT: FDBOREADER 1 +CONSTANT: FDBOWRITER 2 +CONSTANT: FDBOCREAT 4 +CONSTANT: FDBOTRUNC 8 +CONSTANT: FDBONOLCK 16 +CONSTANT: FDBOLCKNB 32 +CONSTANT: FDBOTSYNC 64 + +CONSTANT: FDBIDMIN -1 +CONSTANT: FDBIDPREV -2 +CONSTANT: FDBIDMAX -3 +CONSTANT: FDBIDNEXT -4 + +FUNCTION: char* tcfdberrmsg ( int ecode ) ; +FUNCTION: TCFDB* tcfdbnew ( ) ; +FUNCTION: void tcfdbdel ( TCFDB* fdb ) ; +FUNCTION: int tcfdbecode ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbsetmutex ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbtune ( TCFDB* fdb, int width, longlong limsiz ) ; +FUNCTION: bool tcfdbopen ( TCFDB* fdb, char* path, int omode ) ; +FUNCTION: bool tcfdbclose ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbput ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbput2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbput3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbputkeep ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbputkeep2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbputkeep3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbputcat ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbputcat2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcfdbputcat3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbout ( TCFDB* fdb, longlong id ) ; +FUNCTION: bool tcfdbout2 ( TCFDB* fdb, void* kbuf, int ksiz ) ; +FUNCTION: bool tcfdbout3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: void* tcfdbget ( TCFDB* fdb, longlong id, int* sp ) ; +FUNCTION: void* tcfdbget2 ( TCFDB* fdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tcfdbget3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: int tcfdbget4 ( TCFDB* fdb, longlong id, void* vbuf, int max ) ; +FUNCTION: int tcfdbvsiz ( TCFDB* fdb, longlong id ) ; +FUNCTION: int tcfdbvsiz2 ( TCFDB* fdb, void* kbuf, int ksiz ) ; +FUNCTION: int tcfdbvsiz3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: bool tcfdbiterinit ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdbiternext ( TCFDB* fdb ) ; +FUNCTION: void* tcfdbiternext2 ( TCFDB* fdb, int* sp ) ; +FUNCTION: char* tcfdbiternext3 ( TCFDB* fdb ) ; +FUNCTION: ulonglong* tcfdbrange ( TCFDB* fdb, longlong lower, longlong upper, int max, int* np ) ; +FUNCTION: TCLIST* tcfdbrange2 ( TCFDB* fdb, void* lbuf, int lsiz, void* ubuf, int usiz, int max ) ; +FUNCTION: TCLIST* tcfdbrange3 ( TCFDB* fdb, char* lstr, char* ustr, int max ) ; +FUNCTION: TCLIST* tcfdbrange4 ( TCFDB* fdb, void* ibuf, int isiz, int max ) ; +FUNCTION: TCLIST* tcfdbrange5 ( TCFDB* fdb, void* istr, int max ) ; +FUNCTION: int tcfdbaddint ( TCFDB* fdb, longlong id, int num ) ; +FUNCTION: double tcfdbadddouble ( TCFDB* fdb, longlong id, double num ) ; +FUNCTION: bool tcfdbsync ( TCFDB* fdb ) ; +FUNCTION: bool tcfdboptimize ( TCFDB* fdb, int width, longlong limsiz ) ; +FUNCTION: bool tcfdbvanish ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbcopy ( TCFDB* fdb, char* path ) ; +FUNCTION: bool tcfdbtranbegin ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbtrancommit ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbtranabort ( TCFDB* fdb ) ; +FUNCTION: char* tcfdbpath ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdbrnum ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdbfsiz ( TCFDB* fdb ) ; + +! -------- + +FUNCTION: void tcfdbsetecode ( TCFDB* fdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tcfdbsetdbgfd ( TCFDB* fdb, int fd ) ; +FUNCTION: int tcfdbdbgfd ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbhasmutex ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbmemsync ( TCFDB* fdb, bool phys ) ; +FUNCTION: ulonglong tcfdbmin ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdbmax ( TCFDB* fdb ) ; +FUNCTION: uint tcfdbwidth ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdblimsiz ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdblimid ( TCFDB* fdb ) ; +FUNCTION: ulonglong tcfdbinode ( TCFDB* fdb ) ; +FUNCTION: tokyo_time_t tcfdbmtime ( TCFDB* fdb ) ; +FUNCTION: int tcfdbomode ( TCFDB* fdb ) ; +FUNCTION: uchar tcfdbtype ( TCFDB* fdb ) ; +FUNCTION: uchar tcfdbflags ( TCFDB* fdb ) ; +FUNCTION: char* tcfdbopaque ( TCFDB* fdb ) ; +FUNCTION: bool tcfdbputproc ( TCFDB* fdb, longlong id, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; +FUNCTION: bool tcfdbforeach ( TCFDB* fdb, TCITER iter, void* op ) ; +FUNCTION: longlong tcfdbkeytoid ( char* kbuf, int ksiz ) ; diff --git a/extra/tokyo/alien/tchdb/authors.txt b/extra/tokyo/alien/tchdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tchdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tchdb/summary.txt b/extra/tokyo/alien/tchdb/summary.txt new file mode 100644 index 0000000000..d057f5729f --- /dev/null +++ b/extra/tokyo/alien/tchdb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's Hash database API diff --git a/extra/tokyo/alien/tchdb/tchdb.factor b/extra/tokyo/alien/tchdb/tchdb.factor new file mode 100755 index 0000000000..3793846050 --- /dev/null +++ b/extra/tokyo/alien/tchdb/tchdb.factor @@ -0,0 +1,100 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel tokyo.alien.tcutil ; +IN: tokyo.alien.tchdb + +LIBRARY: tokyocabinet + +TYPEDEF: void* TCHDB* + +CONSTANT: HDBFOPEN 1 +CONSTANT: HDBFFATAL 2 + +CONSTANT: HDBTLARGE 1 +CONSTANT: HDBTDEFLATE 2 +CONSTANT: HDBTBZIP 4 +CONSTANT: HDBTTCBS 8 +CONSTANT: HDBTEXCODEC 16 + +CONSTANT: HDBOREADER 1 +CONSTANT: HDBOWRITER 2 +CONSTANT: HDBOCREAT 4 +CONSTANT: HDBOTRUNC 8 +CONSTANT: HDBONOLCK 16 +CONSTANT: HDBOLCKNB 32 +CONSTANT: HDBOTSYNC 64 + +FUNCTION: char* tchdberrmsg ( int ecode ) ; +FUNCTION: TCHDB* tchdbnew ( ) ; +FUNCTION: void tchdbdel ( TCHDB* hdb ) ; +FUNCTION: int tchdbecode ( TCHDB* hdb ) ; +FUNCTION: bool tchdbsetmutex ( TCHDB* hdb ) ; +FUNCTION: bool tchdbtune ( TCHDB* hdb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tchdbsetcache ( TCHDB* hdb, int rcnum ) ; +FUNCTION: bool tchdbsetxmsiz ( TCHDB* hdb, longlong xmsiz ) ; +FUNCTION: bool tchdbopen ( TCHDB* hdb, char* path, int omode ) ; +FUNCTION: bool tchdbclose ( TCHDB* hdb ) ; +FUNCTION: bool tchdbput ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tchdbput2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputkeep ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tchdbputkeep2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputcat ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tchdbputcat2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputasync ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tchdbputasync2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbout ( TCHDB* hdb, void* kbuf, int ksiz ) ; +FUNCTION: bool tchdbout2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: void* tchdbget ( TCHDB* hdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tchdbget2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: int tchdbget3 ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int max ) ; +FUNCTION: int tchdbvsiz ( TCHDB* hdb, void* kbuf, int ksiz ) ; +FUNCTION: int tchdbvsiz2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: bool tchdbiterinit ( TCHDB* hdb ) ; +FUNCTION: void* tchdbiternext ( TCHDB* hdb, int* sp ) ; +FUNCTION: char* tchdbiternext2 ( TCHDB* hdb ) ; +FUNCTION: bool tchdbiternext3 ( TCHDB* hdb, TCXSTR* kxstr, TCXSTR* vxstr ) ; +FUNCTION: TCLIST* tchdbfwmkeys ( TCHDB* hdb, void* pbuf, int psiz, int max ) ; +FUNCTION: TCLIST* tchdbfwmkeys2 ( TCHDB* hdb, char* pstr, int max ) ; +FUNCTION: int tchdbaddint ( TCHDB* hdb, void* kbuf, int ksiz, int num ) ; +FUNCTION: double tchdbadddouble ( TCHDB* hdb, void* kbuf, int ksiz, double num ) ; +FUNCTION: bool tchdbsync ( TCHDB* hdb ) ; +FUNCTION: bool tchdboptimize ( TCHDB* hdb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tchdbvanish ( TCHDB* hdb ) ; +FUNCTION: bool tchdbcopy ( TCHDB* hdb, char* path ) ; +FUNCTION: bool tchdbtranbegin ( TCHDB* hdb ) ; +FUNCTION: bool tchdbtrancommit ( TCHDB* hdb ) ; +FUNCTION: bool tchdbtranabort ( TCHDB* hdb ) ; +FUNCTION: char* tchdbpath ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbrnum ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbfsiz ( TCHDB* hdb ) ; + +! -------- + +FUNCTION: void tchdbsetecode ( TCHDB* hdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tchdbsettype ( TCHDB* hdb, uchar type ) ; +FUNCTION: void tchdbsetdbgfd ( TCHDB* hdb, int fd ) ; +FUNCTION: int tchdbdbgfd ( TCHDB* hdb ) ; +FUNCTION: bool tchdbhasmutex ( TCHDB* hdb ) ; +FUNCTION: bool tchdbmemsync ( TCHDB* hdb, bool phys ) ; +FUNCTION: bool tchdbcacheclear ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbbnum ( TCHDB* hdb ) ; +FUNCTION: uint tchdbalign ( TCHDB* hdb ) ; +FUNCTION: uint tchdbfbpmax ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbxmsiz ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbinode ( TCHDB* hdb ) ; +FUNCTION: tokyo_time_t tchdbmtime ( TCHDB* hdb ) ; +FUNCTION: int tchdbomode ( TCHDB* hdb ) ; +FUNCTION: uchar tchdbtype ( TCHDB* hdb ) ; +FUNCTION: uchar tchdbflags ( TCHDB* hdb ) ; +FUNCTION: uchar tchdbopts ( TCHDB* hdb ) ; +FUNCTION: char* tchdbopaque ( TCHDB* hdb ) ; +FUNCTION: ulonglong tchdbbnumused ( TCHDB* hdb ) ; +FUNCTION: bool tchdbsetcodecfunc ( TCHDB* hdb, TCCODEC enc, void* encop, TCCODEC dec, void* decop ) ; +FUNCTION: void tchdbcodecfunc ( TCHDB* hdb, TCCODEC* ep, void* *eop, TCCODEC* dp, void* *dop ) ; +FUNCTION: bool tchdbputproc ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; +FUNCTION: void* tchdbgetnext ( TCHDB* hdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tchdbgetnext2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: char* tchdbgetnext3 ( TCHDB* hdb, char* kbuf, int ksiz, int* sp, char* *vbp, int* vsp ) ; +FUNCTION: bool tchdbforeach ( TCHDB* hdb, TCITER iter, void* op ) ; +FUNCTION: bool tchdbtranvoid ( TCHDB* hdb ) ; diff --git a/extra/tokyo/alien/tcrdb/authors.txt b/extra/tokyo/alien/tcrdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tcrdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tcrdb/summary.txt b/extra/tokyo/alien/tcrdb/summary.txt new file mode 100644 index 0000000000..9e08bdac0a --- /dev/null +++ b/extra/tokyo/alien/tcrdb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Tyrant's Remote database API diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor new file mode 100755 index 0000000000..3ff3bc6428 --- /dev/null +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -0,0 +1,144 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel system tokyo.alien.tchdb tokyo.alien.tcutil +tokyo.alien.tctdb ; +IN: tokyo.alien.tcrdb + +<< "tokyotyrant" { + { [ os macosx? ] [ "/opt/local/lib/libtokyotyrant.dylib" ] } + { [ os unix? ] [ "libtokyotyrant.so" ] } + { [ os windows? ] [ "tokyotyrant.dll" ] } +} cond "cdecl" add-library >> + +LIBRARY: tokyotyrant + +TYPEDEF: void* TCRDB* +! C-STRUCT: TCRDB +! { "pthread_mutex_t" mmtx } +! { "pthread_key_t" eckey } +! { "char*" host } +! { "int" port } +! { "char*" expr } +! { "int" fd } +! { "TTSOCK*" sock } +! { "double" timeout } +! { "int" opts } ; + +C-ENUM: + TTESUCCESS + TTEINVALID + TTENOHOST + TTEREFUSED + TTESEND + TTERECV + TTEKEEP + TTENOREC ; +CONSTANT: TTEMISC 9999 + +CONSTANT: RDBTRECON 1 +CONSTANT: RDBXOLCKREC 1 +CONSTANT: RDBXOLCKGLB 2 +CONSTANT: RDBROCHKCON 1 +CONSTANT: RDBMONOULOG 1 + +FUNCTION: char* tcrdberrmsg ( int ecode ) ; +FUNCTION: TCRDB* tcrdbnew ( ) ; +FUNCTION: void tcrdbdel ( TCRDB* rdb ) ; +FUNCTION: int tcrdbecode ( TCRDB* rdb ) ; +FUNCTION: bool tcrdbtune ( TCRDB* rdb, double timeout, int opts ) ; +FUNCTION: bool tcrdbopen ( TCRDB* rdb, char* host, int port ) ; +FUNCTION: bool tcrdbopen2 ( TCRDB* rdb, char* expr ) ; +FUNCTION: bool tcrdbclose ( TCRDB* rdb ) ; +FUNCTION: bool tcrdbput ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcrdbput2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputkeep ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcrdbputkeep2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputcat ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcrdbputcat2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputshl ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz, int width ) ; +FUNCTION: bool tcrdbputshl2 ( TCRDB* rdb, char* kstr, char* vstr, int width ) ; +FUNCTION: bool tcrdbputnr ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; +FUNCTION: bool tcrdbputnr2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbout ( TCRDB* rdb, void* kbuf, int ksiz ) ; +FUNCTION: bool tcrdbout2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: void* tcrdbget ( TCRDB* rdb, void* kbuf, int ksiz, int* sp ) ; +FUNCTION: char* tcrdbget2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: bool tcrdbget3 ( TCRDB* rdb, TCMAP* recs ) ; +FUNCTION: int tcrdbvsiz ( TCRDB* rdb, void* kbuf, int ksiz ) ; +FUNCTION: int tcrdbvsiz2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: bool tcrdbiterinit ( TCRDB* rdb ) ; +FUNCTION: void* tcrdbiternext ( TCRDB* rdb, int* sp ) ; +FUNCTION: char* tcrdbiternext2 ( TCRDB* rdb ) ; +FUNCTION: TCLIST* tcrdbfwmkeys ( TCRDB* rdb, void* pbuf, int psiz, int max ) ; +FUNCTION: TCLIST* tcrdbfwmkeys2 ( TCRDB* rdb, char* pstr, int max ) ; +FUNCTION: int tcrdbaddint ( TCRDB* rdb, void* kbuf, int ksiz, int num ) ; +FUNCTION: double tcrdbadddouble ( TCRDB* rdb, void* kbuf, int ksiz, double num ) ; +FUNCTION: void* tcrdbext ( TCRDB* rdb, char* name, int opts, void* kbuf, int ksiz, void* vbuf, int vsiz, int* sp ) ; +FUNCTION: char* tcrdbext2 ( TCRDB* rdb, char* name, int opts, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbsync ( TCRDB* rdb ) ; +FUNCTION: bool tcrdboptimize ( TCRDB* rdb, char* params ) ; +FUNCTION: bool tcrdbvanish ( TCRDB* rdb ) ; +FUNCTION: bool tcrdbcopy ( TCRDB* rdb, char* path ) ; +FUNCTION: bool tcrdbrestore ( TCRDB* rdb, char* path, ulonglong ts, int opts ) ; +FUNCTION: bool tcrdbsetmst ( TCRDB* rdb, char* host, int port, int opts ) ; +FUNCTION: bool tcrdbsetmst2 ( TCRDB* rdb, char* expr, int opts ) ; +FUNCTION: char* tcrdbexpr ( TCRDB* rdb ) ; +FUNCTION: ulonglong tcrdbrnum ( TCRDB* rdb ) ; +FUNCTION: ulonglong tcrdbsize ( TCRDB* rdb ) ; +FUNCTION: char* tcrdbstat ( TCRDB* rdb ) ; +FUNCTION: TCLIST* tcrdbmisc ( TCRDB* rdb, char* name, int opts, TCLIST* args ) ; + +CONSTANT: RDBITLEXICAL TDBITLEXICAL +CONSTANT: RDBITDECIMAL TDBITDECIMAL +CONSTANT: RDBITOPT TDBITOPT +CONSTANT: RDBITVOID TDBITVOID +CONSTANT: RDBITKEEP TDBITKEEP + +TYPEDEF: void* RDBQRY* +! C-STRUCT: RDBQRY +! { "TCRDB*" rdb } +! { "TCLIST*" args } ; + +CONSTANT: RDBQCSTREQ TDBQCSTREQ +CONSTANT: RDBQCSTRINC TDBQCSTRINC +CONSTANT: RDBQCSTRBW TDBQCSTRBW +CONSTANT: RDBQCSTREW TDBQCSTREW +CONSTANT: RDBQCSTRAND TDBQCSTRAND +CONSTANT: RDBQCSTROR TDBQCSTROR +CONSTANT: RDBQCSTROREQ TDBQCSTROREQ +CONSTANT: RDBQCSTRRX TDBQCSTRRX +CONSTANT: RDBQCNUMEQ TDBQCNUMEQ +CONSTANT: RDBQCNUMGT TDBQCNUMGT +CONSTANT: RDBQCNUMGE TDBQCNUMGE +CONSTANT: RDBQCNUMLT TDBQCNUMLT +CONSTANT: RDBQCNUMLE TDBQCNUMLE +CONSTANT: RDBQCNUMBT TDBQCNUMBT +CONSTANT: RDBQCNUMOREQ TDBQCNUMOREQ +CONSTANT: RDBQCNEGATE TDBQCNEGATE +CONSTANT: RDBQCNOIDX TDBQCNOIDX + +CONSTANT: RDBQOSTRASC TDBQOSTRASC +CONSTANT: RDBQOSTRDESC TDBQOSTRDESC +CONSTANT: RDBQONUMASC TDBQONUMASC +CONSTANT: RDBQONUMDESC TDBQONUMDESC + +FUNCTION: bool tcrdbtblput ( TCRDB* rdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblputkeep ( TCRDB* rdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblputcat ( TCRDB* rdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblout ( TCRDB* rdb, void* pkbuf, int pksiz ) ; +FUNCTION: TCMAP* tcrdbtblget ( TCRDB* rdb, void* pkbuf, int pksiz ) ; +FUNCTION: bool tcrdbtblsetindex ( TCRDB* rdb, char* name, int type ) ; +FUNCTION: longlong tcrdbtblgenuid ( TCRDB* rdb ) ; +FUNCTION: RDBQRY* tcrdbqrynew ( TCRDB* rdb ) ; +FUNCTION: void tcrdbqrydel ( RDBQRY* qry ) ; +FUNCTION: void tcrdbqryaddcond ( RDBQRY* qry, char* name, int op, char* expr ) ; +FUNCTION: void tcrdbqrysetorder ( RDBQRY* qry, char* name, int type ) ; +FUNCTION: void tcrdbqrysetlimit ( RDBQRY* qry, int max, int skip ) ; +FUNCTION: TCLIST* tcrdbqrysearch ( RDBQRY* qry ) ; +FUNCTION: bool tcrdbqrysearchout ( RDBQRY* qry ) ; +FUNCTION: TCLIST* tcrdbqrysearchget ( RDBQRY* qry ) ; +FUNCTION: TCMAP* tcrdbqryrescols ( TCLIST* res, int index ) ; +FUNCTION: int tcrdbqrysearchcount ( RDBQRY* qry ) ; + +FUNCTION: void tcrdbsetecode ( TCRDB* rdb, int ecode ) ; diff --git a/extra/tokyo/alien/tctdb/authors.txt b/extra/tokyo/alien/tctdb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tctdb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tctdb/summary.txt b/extra/tokyo/alien/tctdb/summary.txt new file mode 100644 index 0000000000..b492e95ee8 --- /dev/null +++ b/extra/tokyo/alien/tctdb/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's Table database API diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor new file mode 100755 index 0000000000..bb65acb2f6 --- /dev/null +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -0,0 +1,155 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil ; +IN: tokyo.alien.tctdb + +LIBRARY: tokyocabinet + +TYPEDEF: void* TDBIDX* +TYPEDEF: void* TCTDB* + +CONSTANT: TDBFOPEN HDBFOPEN +CONSTANT: TDBFFATAL HDBFFATAL + +CONSTANT: TDBTLARGE 1 +CONSTANT: TDBTDEFLATE 2 +CONSTANT: TDBTBZIP 4 +CONSTANT: TDBTTCBS 8 +CONSTANT: TDBTEXCODEC 16 + +CONSTANT: TDBOREADER 1 +CONSTANT: TDBOWRITER 2 +CONSTANT: TDBOCREAT 4 +CONSTANT: TDBOTRUNC 8 +CONSTANT: TDBONOLCK 16 +CONSTANT: TDBOLCKNB 32 +CONSTANT: TDBOTSYNC 64 + +C-ENUM: + TDBITLEXICAL + TDBITDECIMAL ; + +CONSTANT: TDBITOPT 9998 +CONSTANT: TDBITVOID 9999 +CONSTANT: TDBITKEEP 16777216 + +TYPEDEF: void* TDBCOND* +TYPEDEF: void* TDBQRY* + +C-ENUM: + TDBQCSTREQ + TDBQCSTRINC + TDBQCSTRBW + TDBQCSTREW + TDBQCSTRAND + TDBQCSTROR + TDBQCSTROREQ + TDBQCSTRRX + TDBQCNUMEQ + TDBQCNUMGT + TDBQCNUMGE + TDBQCNUMLT + TDBQCNUMLE + TDBQCNUMBT + TDBQCNUMOREQ ; + +CONSTANT: TDBQCNEGATE 16777216 +CONSTANT: TDBQCNOIDX 33554432 + +C-ENUM: + TDBQOSTRASC + TDBQOSTRDESC + TDBQONUMASC + TDBQONUMDESC ; + +CONSTANT: TDBQPPUT 1 +CONSTANT: TDBQPOUT 2 +CONSTANT: TDBQPSTOP 16777216 + +! int (*)(const void *pkbuf, int pksiz, TCMAP *cols, void *op); +TYPEDEF: void* TDBQRYPROC + +FUNCTION: char* tctdberrmsg ( int ecode ) ; +FUNCTION: TCTDB* tctdbnew ( ) ; +FUNCTION: void tctdbdel ( TCTDB* tdb ) ; +FUNCTION: int tctdbecode ( TCTDB* tdb ) ; +FUNCTION: bool tctdbsetmutex ( TCTDB* tdb ) ; +FUNCTION: bool tctdbtune ( TCTDB* tdb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tctdbsetcache ( TCTDB* tdb, int32_t rcnum, int32_t lcnum, int32_t ncnum ) ; +FUNCTION: bool tctdbsetxmsiz ( TCTDB* tdb, longlong xmsiz ) ; +FUNCTION: bool tctdbopen ( TCTDB* tdb, char* path, int omode ) ; +FUNCTION: bool tctdbclose ( TCTDB* tdb ) ; +FUNCTION: bool tctdbput ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tctdbput2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; +FUNCTION: bool tctdbput3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbputkeep ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tctdbputkeep2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; +FUNCTION: bool tctdbputkeep3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbputcat ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tctdbputcat2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; +FUNCTION: bool tctdbputcat3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbout ( TCTDB* tdb, void* pkbuf, int pksiz ) ; +FUNCTION: bool tctdbout2 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: TCMAP* tctdbget ( TCTDB* tdb, void* pkbuf, int pksiz ) ; +FUNCTION: char* tctdbget2 ( TCTDB* tdb, void* pkbuf, int pksiz, int* sp ) ; +FUNCTION: char* tctdbget3 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: int tctdbvsiz ( TCTDB* tdb, void* pkbuf, int pksiz ) ; +FUNCTION: int tctdbvsiz2 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: bool tctdbiterinit ( TCTDB* tdb ) ; +FUNCTION: void* tctdbiternext ( TCTDB* tdb, int* sp ) ; +FUNCTION: char* tctdbiternext2 ( TCTDB* tdb ) ; +FUNCTION: TCLIST* tctdbfwmkeys ( TCTDB* tdb, void* pbuf, int psiz, int max ) ; +FUNCTION: TCLIST* tctdbfwmkeys2 ( TCTDB* tdb, char* pstr, int max ) ; +FUNCTION: int tctdbaddint ( TCTDB* tdb, void* pkbuf, int pksiz, int num ) ; +FUNCTION: double tctdbadddouble ( TCTDB* tdb, void* pkbuf, int pksiz, double num ) ; +FUNCTION: bool tctdbsync ( TCTDB* tdb ) ; +FUNCTION: bool tctdboptimize ( TCTDB* tdb, longlong bnum, char apow, char fpow, uchar opts ) ; +FUNCTION: bool tctdbvanish ( TCTDB* tdb ) ; +FUNCTION: bool tctdbcopy ( TCTDB* tdb, char* path ) ; +FUNCTION: bool tctdbtranbegin ( TCTDB* tdb ) ; +FUNCTION: bool tctdbtrancommit ( TCTDB* tdb ) ; +FUNCTION: bool tctdbtranabort ( TCTDB* tdb ) ; +FUNCTION: char* tctdbpath ( TCTDB* tdb ) ; +FUNCTION: ulonglong tctdbrnum ( TCTDB* tdb ) ; +FUNCTION: ulonglong tctdbfsiz ( TCTDB* tdb ) ; +FUNCTION: bool tctdbsetindex ( TCTDB* tdb, char* name, int type ) ; +FUNCTION: longlong tctdbgenuid ( TCTDB* tdb ) ; +FUNCTION: TDBQRY* tctdbqrynew ( TCTDB* tdb ) ; +FUNCTION: void tctdbqrydel ( TDBQRY* qry ) ; +FUNCTION: void tctdbqryaddcond ( TDBQRY* qry, char* name, int op, char* expr ) ; +FUNCTION: void tctdbqrysetorder ( TDBQRY* qry, char* name, int type ) ; +FUNCTION: void tctdbqrysetlimit ( TDBQRY* qry, int max, int skip ) ; +FUNCTION: TCLIST* tctdbqrysearch ( TDBQRY* qry ) ; +FUNCTION: bool tctdbqrysearchout ( TDBQRY* qry ) ; +FUNCTION: bool tctdbqryproc ( TDBQRY* qry, TDBQRYPROC proc, void* op ) ; +FUNCTION: char* tctdbqryhint ( TDBQRY* qry ) ; + +! ======= + +FUNCTION: void tctdbsetecode ( TCTDB* tdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tctdbsetdbgfd ( TCTDB* tdb, int fd ) ; +FUNCTION: int tctdbdbgfd ( TCTDB* tdb ) ; +FUNCTION: bool tctdbhasmutex ( TCTDB* tdb ) ; +FUNCTION: bool tctdbmemsync ( TCTDB* tdb, bool phys ) ; +FUNCTION: ulonglong tctdbbnum ( TCTDB* tdb ) ; +FUNCTION: uint tctdbalign ( TCTDB* tdb ) ; +FUNCTION: uint tctdbfbpmax ( TCTDB* tdb ) ; +FUNCTION: ulonglong tctdbinode ( TCTDB* tdb ) ; +FUNCTION: tokyo_time_t tctdbmtime ( TCTDB* tdb ) ; +FUNCTION: uchar tctdbflags ( TCTDB* tdb ) ; +FUNCTION: uchar tctdbopts ( TCTDB* tdb ) ; +FUNCTION: char* tctdbopaque ( TCTDB* tdb ) ; +FUNCTION: ulonglong tctdbbnumused ( TCTDB* tdb ) ; +FUNCTION: int tctdbinum ( TCTDB* tdb ) ; +FUNCTION: longlong tctdbuidseed ( TCTDB* tdb ) ; +FUNCTION: bool tctdbsetuidseed ( TCTDB* tdb, longlong seed ) ; +FUNCTION: bool tctdbsetcodecfunc ( TCTDB* tdb, TCCODEC enc, void* encop, TCCODEC dec, void* decop ) ; +FUNCTION: bool tctdbputproc ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz, TCPDPROC proc, void* op ) ; +FUNCTION: bool tctdbforeach ( TCTDB* tdb, TCITER iter, void* op ) ; +FUNCTION: bool tctdbqryproc2 ( TDBQRY* qry, TDBQRYPROC proc, void* op ) ; +FUNCTION: bool tctdbqrysearchout2 ( TDBQRY* qry ) ; +FUNCTION: int tctdbstrtoindextype ( char* str ) ; +FUNCTION: int tctdbqrycount ( TDBQRY* qry ) ; +FUNCTION: int tctdbqrystrtocondop ( char* str ) ; +FUNCTION: int tctdbqrystrtoordertype ( char* str ) ; diff --git a/extra/tokyo/alien/tcutil/authors.txt b/extra/tokyo/alien/tcutil/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/alien/tcutil/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/alien/tcutil/summary.txt b/extra/tokyo/alien/tcutil/summary.txt new file mode 100644 index 0000000000..7a01d13ef5 --- /dev/null +++ b/extra/tokyo/alien/tcutil/summary.txt @@ -0,0 +1 @@ +Bindings for Tokyo Cabinet's Utils API diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor new file mode 100755 index 0000000000..ac6e242be2 --- /dev/null +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -0,0 +1,39 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.libraries alien.syntax +combinators kernel system ; +IN: tokyo.alien.tcutil + +<< "tokyocabinet" { + { [ os macosx? ] [ "/opt/local/lib/libtokyocabinet.dylib" ] } + { [ os unix? ] [ "libtokyocabinet.so" ] } + { [ os windows? ] [ "tokyocabinet.dll" ] } +} cond "cdecl" add-library >> + +LIBRARY: tokyocabinet + +C-ENUM: + TCDBTHASH + TCDBTBTREE + TCDBTFIXED + TCDBTTABLE ; + +! FIXME: on windows 64bits this isn't correct, because long is 32bits there, and time_t is int64 +TYPEDEF: long tokyo_time_t + +TYPEDEF: void* TCLIST* + +FUNCTION: TCLIST* tclistnew ( ) ; +FUNCTION: TCLIST* tclistnew2 ( int anum ) ; +FUNCTION: void tclistdel ( TCLIST* list ) ; +FUNCTION: int tclistnum ( TCLIST* list ) ; +FUNCTION: void* tclistval ( TCLIST* list, int index, int* sp ) ; +FUNCTION: char* tclistval2 ( TCLIST* list, int index ) ; +FUNCTION: void tclistpush ( TCLIST* list, void* ptr, int size ) ; +FUNCTION: void tclistpush2 ( TCLIST* list, char* str ) ; +FUNCTION: void tcfree ( void* ptr ) ; + +TYPEDEF: void* TCCMP +TYPEDEF: void* TCCODEC +TYPEDEF: void* TCPDPROC +TYPEDEF: void* TCITER diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor new file mode 100644 index 0000000000..1df1325eef --- /dev/null +++ b/extra/tokyo/assoc-functor/assoc-functor.factor @@ -0,0 +1,59 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types arrays assocs destructors fry functors +kernel locals sequences serialize tokyo.alien.tcutil tokyo.utils vectors ; +IN: tokyo.assoc-functor + +FUNCTOR: define-tokyo-assoc-api ( T N -- ) + +DBGET IS ${T}get +DBPUT IS ${T}put +DBOUT IS ${T}out +DBDEL IS ${T}del +DBRNUM IS ${T}rnum +DBITERINIT IS ${T}iterinit +DBITERNEXT IS ${T}iternext +DBVANISH IS ${T}vanish + +DBKEYS DEFINES tokyo-${N}-keys + +TYPE DEFINES-CLASS tokyo-${N} + +WHERE + +TUPLE: TYPE handle disposed ; + +INSTANCE: TYPE assoc + +M: TYPE dispose* [ DBDEL f ] change-handle drop ; + +M: TYPE at* ( key db -- value/f ? ) + handle>> swap object>bytes dup length 0 + DBGET [ [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ; + +M: TYPE assoc-size ( db -- size ) handle>> DBRNUM ; + +: DBKEYS ( db -- keys ) + [ assoc-size ] [ handle>> ] bi + dup DBITERINIT drop 0 + [ 2dup DBITERNEXT dup ] [ + [ memory>object ] [ tcfree ] bi + [ pick ] dip swap push + ] while 3drop ; + +M: TYPE >alist ( db -- alist ) + [ DBKEYS dup ] keep '[ dup _ at 2array ] change-each ; + +M: TYPE set-at ( value key db -- ) + handle>> spin [ object>bytes dup length ] bi@ DBPUT drop ; + +M: TYPE delete-at ( key db -- ) + handle>> swap object>bytes dup length DBOUT drop ; + +M: TYPE clear-assoc ( db -- ) handle>> DBVANISH drop ; + +M: TYPE equal? assoc= ; + +M: TYPE hashcode* assoc-hashcode ; + +;FUNCTOR \ No newline at end of file diff --git a/extra/tokyo/assoc-functor/authors.txt b/extra/tokyo/assoc-functor/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/assoc-functor/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/assoc-functor/summary.txt b/extra/tokyo/assoc-functor/summary.txt new file mode 100644 index 0000000000..f38bdbd824 --- /dev/null +++ b/extra/tokyo/assoc-functor/summary.txt @@ -0,0 +1 @@ +Functor used to implement the assoc protocol on the different db apis in Tokyo diff --git a/extra/tokyo/remotedb/authors.txt b/extra/tokyo/remotedb/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/remotedb/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/remotedb/remotedb.factor b/extra/tokyo/remotedb/remotedb.factor new file mode 100644 index 0000000000..c8761e16f3 --- /dev/null +++ b/extra/tokyo/remotedb/remotedb.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel tokyo.alien.tcrdb tokyo.assoc-functor ; +IN: tokyo.remotedb + +<< "tcrdb" "remotedb" define-tokyo-assoc-api >> + +: ( host port -- tokyo-remotedb ) + [ tcrdbnew dup ] 2dip tcrdbopen drop + tokyo-remotedb new [ (>>handle) ] keep ; diff --git a/extra/tokyo/remotedb/summary.txt b/extra/tokyo/remotedb/summary.txt new file mode 100644 index 0000000000..ef5b9af089 --- /dev/null +++ b/extra/tokyo/remotedb/summary.txt @@ -0,0 +1 @@ +Higher level API for Tokyo Tyrant's Remote database API. Implements the associative protocol. diff --git a/extra/tokyo/utils/authors.txt b/extra/tokyo/utils/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/utils/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari diff --git a/extra/tokyo/utils/summary.txt b/extra/tokyo/utils/summary.txt new file mode 100644 index 0000000000..5e3ec0e86b --- /dev/null +++ b/extra/tokyo/utils/summary.txt @@ -0,0 +1 @@ +Some utility words used by the tokyo vocabs diff --git a/extra/tokyo/utils/utils.factor b/extra/tokyo/utils/utils.factor new file mode 100644 index 0000000000..2b589e4a4b --- /dev/null +++ b/extra/tokyo/utils/utils.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: io io.streams.memory serialize kernel ; +IN: tokyo.utils + +: with-memory-reader ( memory quot -- ) + [ ] dip with-input-stream* ; inline + +: memory>object ( memory -- object ) + [ deserialize ] with-memory-reader ;