Merge branch 'master' of git://factorcode.org/git/factor
						commit
						ff742a7d81
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
<PRIVATE
 | 
			
		||||
| 
						 | 
				
			
			@ -17,23 +16,18 @@ CONSTANT: roman-values
 | 
			
		|||
 | 
			
		||||
ERROR: roman-range-error n ;
 | 
			
		||||
 | 
			
		||||
: roman-range-check ( n -- )
 | 
			
		||||
    dup 1 3999 between? [ drop ] [ roman-range-error ] if ;
 | 
			
		||||
: roman-range-check ( n -- n )
 | 
			
		||||
    dup 1 3999 between? [ roman-range-error ] unless ;
 | 
			
		||||
 | 
			
		||||
: roman-digit-index ( ch -- n )
 | 
			
		||||
    1string roman-digits index ; inline
 | 
			
		||||
 | 
			
		||||
: roman<= ( ch1 ch2 -- ? )
 | 
			
		||||
: 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 <repetition> 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 <repetition> 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 ;
 | 
			
		||||
 | 
			
		||||
<PRIVATE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -57,11 +54,13 @@ MACRO: binary-roman-op ( quot -- quot' )
 | 
			
		|||
PRIVATE>
 | 
			
		||||
 | 
			
		||||
<<
 | 
			
		||||
 | 
			
		||||
SYNTAX: ROMAN-OP:
 | 
			
		||||
    scan-word [ name>> "roman" prepend create-in ] keep
 | 
			
		||||
    1quotation '[ _ binary-roman-op ]
 | 
			
		||||
    dup infer [ in>> ] [ out>> ] bi
 | 
			
		||||
    [ "string" <repetition> ] bi@ <effect> define-declared ;
 | 
			
		||||
 | 
			
		||||
>>
 | 
			
		||||
 | 
			
		||||
ROMAN-OP: +
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +20,13 @@ $nl
 | 
			
		|||
{ $subsection set= }
 | 
			
		||||
"A word used to implement the above:"
 | 
			
		||||
{ $subsection unique }
 | 
			
		||||
"Counting elements in a sequence:"
 | 
			
		||||
{ $subsection histogram }
 | 
			
		||||
{ $subsection histogram* }
 | 
			
		||||
"Combinators for implementing histogram:"
 | 
			
		||||
{ $subsection sequence>assoc }
 | 
			
		||||
{ $subsection sequence>assoc* }
 | 
			
		||||
{ $subsection sequence>hashtable }
 | 
			
		||||
"Adding elements to sets:"
 | 
			
		||||
{ $subsection adjoin }
 | 
			
		||||
{ $subsection conjoin }
 | 
			
		||||
| 
						 | 
				
			
			@ -125,3 +133,73 @@ HELP: gather
 | 
			
		|||
     { "seq" sequence } { "quot" quotation }
 | 
			
		||||
     { "newseq" sequence } }
 | 
			
		||||
{ $description "Maps a quotation onto a sequence, concatenates the results of the mapping, and removes duplicates." } ;
 | 
			
		||||
 | 
			
		||||
HELP: histogram
 | 
			
		||||
{ $values
 | 
			
		||||
    { "seq" sequence }
 | 
			
		||||
    { "hashtable" hashtable }
 | 
			
		||||
}
 | 
			
		||||
{ $examples 
 | 
			
		||||
    { $example "! Count the number of times an element appears in a sequence."
 | 
			
		||||
               "USING: prettyprint sets ;"
 | 
			
		||||
               "\"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 sets ;"
 | 
			
		||||
               "\"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 sets ;"
 | 
			
		||||
               "\"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 sets 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 sets ;"
 | 
			
		||||
               "\"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." } ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,3 +29,13 @@ IN: sets.tests
 | 
			
		|||
[ f ] [ { } { 1 } intersects? ] unit-test
 | 
			
		||||
 | 
			
		||||
[ f ] [ { 1 } { } intersects? ] unit-test
 | 
			
		||||
 | 
			
		||||
[
 | 
			
		||||
    H{
 | 
			
		||||
        { 97 2 }
 | 
			
		||||
        { 98 2 }
 | 
			
		||||
        { 99 2 }
 | 
			
		||||
    }
 | 
			
		||||
] [
 | 
			
		||||
    "aabbcc" histogram
 | 
			
		||||
] unit-test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,3 +54,25 @@ PRIVATE>
 | 
			
		|||
 | 
			
		||||
: set= ( seq1 seq2 -- ? )
 | 
			
		||||
    [ unique ] bi@ = ;
 | 
			
		||||
 | 
			
		||||
<PRIVATE
 | 
			
		||||
 | 
			
		||||
: (sequence>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 ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 >>
 | 
			
		||||
 | 
			
		||||
: <tokyo-abstractdb> ( name -- tokyo-abstractdb )
 | 
			
		||||
    tcadbnew [ swap tcadbopen drop ] keep
 | 
			
		||||
    tokyo-abstractdb new [ (>>handle) ] keep ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Higher level API for Tokyo Cabinet's Abstract database API. Implements the associative protocol.
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's Abstract database API
 | 
			
		||||
| 
						 | 
				
			
			@ -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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's B+ Tree database API
 | 
			
		||||
| 
						 | 
				
			
			@ -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: 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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's Fixed Length database API
 | 
			
		||||
| 
						 | 
				
			
			@ -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: 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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's Hash database API
 | 
			
		||||
| 
						 | 
				
			
			@ -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: 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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Tyrant's Remote database API
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,146 @@
 | 
			
		|||
! 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
 | 
			
		||||
 | 
			
		||||
TYPEDEF: int bool
 | 
			
		||||
 | 
			
		||||
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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's Table database API
 | 
			
		||||
| 
						 | 
				
			
			@ -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: 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 ) ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bindings for Tokyo Cabinet's Utils API
 | 
			
		||||
| 
						 | 
				
			
			@ -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 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: voud* TCITER
 | 
			
		||||
| 
						 | 
				
			
			@ -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 <int>
 | 
			
		||||
    DBGET [ [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ;
 | 
			
		||||
 | 
			
		||||
M: TYPE assoc-size ( db -- size ) handle>> DBRNUM ;
 | 
			
		||||
 | 
			
		||||
: DBKEYS ( db -- keys )
 | 
			
		||||
    [ assoc-size <vector> ] [ handle>> ] bi
 | 
			
		||||
    dup DBITERINIT drop 0 <int>
 | 
			
		||||
    [ 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
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Functor used to implement the assoc protocol on the different db apis in Tokyo
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -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 >>
 | 
			
		||||
 | 
			
		||||
: <tokyo-remotedb> ( host port -- tokyo-remotedb )
 | 
			
		||||
    [ tcrdbnew dup ] 2dip tcrdbopen drop
 | 
			
		||||
    tokyo-remotedb new [ (>>handle) ] keep ;
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Higher level API for Tokyo Tyrant's Remote database API. Implements the associative protocol.
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Bruno Deferrari
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Some utility words used by the tokyo vocabs
 | 
			
		||||
| 
						 | 
				
			
			@ -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 -- )
 | 
			
		||||
    [ <memory-stream> ] dip with-input-stream* ; inline
 | 
			
		||||
 | 
			
		||||
: memory>object ( memory -- object )
 | 
			
		||||
    [ deserialize ] with-memory-reader ;
 | 
			
		||||
		Loading…
	
		Reference in New Issue