From 8134ecccedd05518e826e74d84a1f6bed44d877e Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Fri, 12 Jun 2009 14:25:01 -0300 Subject: [PATCH 01/26] tokyo.alien: Initial works on tokyo bindings (incomplete, not working, not tested) --- extra/tokyo/alien/tcrdb/tcrdb.factor | 136 ++++++++++++++++++++++ extra/tokyo/alien/tctdb/tctdb.factor | 152 +++++++++++++++++++++++++ extra/tokyo/alien/tcutil/tcutil.factor | 24 ++++ 3 files changed, 312 insertions(+) create mode 100644 extra/tokyo/alien/tcrdb/tcrdb.factor create mode 100644 extra/tokyo/alien/tctdb/tctdb.factor create mode 100644 extra/tokyo/alien/tcutil/tcutil.factor diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor new file mode 100644 index 0000000000..7919c92698 --- /dev/null +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -0,0 +1,136 @@ +USING: kernel alien combinators alien.syntax + alien.c-types + alien.libraries tokyo.alien.tcutil tokyo.alien.tctdb ; +IN: tokyo.alient.tcrdb + +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, const void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblputkeep ( TCRDB* rdb, const void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblputcat ( TCRDB* rdb, const void* pkbuf, int pksiz, TCMAP* cols ) ; +FUNCTION: bool tcrdbtblout ( TCRDB* rdb, const void* pkbuf, int pksiz ) ; +FUNCTION: TCMAP* tcrdbtblget ( TCRDB* rdb, const void* pkbuf, int pksiz ) ; +FUNCTION: bool tcrdbtblsetindex ( TCRDB* rdb, const char* name, int type ) ; +FUNCTION: longlong tcrdbtblgenuid ( TCRDB* rdb ) ; +FUNCTION: RDBQRY* tcrdbqrynew ( TCRDB* rdb ) ; +FUNCTION: void tcrdbqrydel ( RDBQRY* qry ) ; +FUNCTION: void tcrdbqryaddcond ( RDBQRY* qry, const char* name, int op, const char* expr ) ; +FUNCTION: void tcrdbqrysetorder ( RDBQRY* qry, const 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/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor new file mode 100644 index 0000000000..35bc16e003 --- /dev/null +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -0,0 +1,152 @@ +USING: kernel alien combinators alien.syntax + alien.c-types + alien.libraries tokyo.alien.tcutil ; +IN: tokyo.alient.tctdb + +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 ( void ) ; +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 ) ; diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor new file mode 100644 index 0000000000..df1b66bc31 --- /dev/null +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -0,0 +1,24 @@ +USING: kernel alien combinators alien.syntax + alien.c-types + alien.libraries ; +IN: tokyo.alient.tcutil + +C-ENUM: + TCDBTHASH + TCDBTBTREE + TCDBTFIXED + TCDBTTABLE ; + +! FIXME: time_t varies from system to system, right? +TYPEDEF: longlong 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 ) ; From 5678c18bda7b02f6a3c18c17451f487d0c702307 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Fri, 12 Jun 2009 15:14:14 -0300 Subject: [PATCH 02/26] tokyo.alien: Use long for time_t --- extra/tokyo/alien/tcutil/tcutil.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index df1b66bc31..aac300a3c1 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -9,8 +9,8 @@ C-ENUM: TCDBTFIXED TCDBTTABLE ; -! FIXME: time_t varies from system to system, right? -TYPEDEF: longlong time_t +! long seems safe enough +TYPEDEF: long time_t TYPEDEF: void* TCLIST* From 2f15931b3c320a0b67d50b397dcc053c3eec8282 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Fri, 12 Jun 2009 15:19:18 -0300 Subject: [PATCH 03/26] tokyo.alien: Make time_t a long, needs fix for 64bits windows --- extra/tokyo/alien/tcutil/tcutil.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index aac300a3c1..41de2c9407 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -9,7 +9,7 @@ C-ENUM: TCDBTFIXED TCDBTTABLE ; -! long seems safe enough +! 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* From 6ebdd525229be064a231748880bc6ee1dd7d15cd Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Fri, 12 Jun 2009 22:58:53 -0300 Subject: [PATCH 04/26] tokyo.alien: Fixes, add tchdb, loads now. --- extra/tokyo/alien/tchdb/authors.txt | 1 + extra/tokyo/alien/tchdb/tchdb.factor | 98 ++++++++++++++++++++++++++ extra/tokyo/alien/tcrdb/authors.txt | 1 + extra/tokyo/alien/tcrdb/tcrdb.factor | 26 +++---- extra/tokyo/alien/tctdb/authors.txt | 1 + extra/tokyo/alien/tctdb/tctdb.factor | 12 ++-- extra/tokyo/alien/tcutil/authors.txt | 1 + extra/tokyo/alien/tcutil/tcutil.factor | 14 ++-- 8 files changed, 133 insertions(+), 21 deletions(-) create mode 100644 extra/tokyo/alien/tchdb/authors.txt create mode 100644 extra/tokyo/alien/tchdb/tchdb.factor create mode 100644 extra/tokyo/alien/tcrdb/authors.txt create mode 100644 extra/tokyo/alien/tctdb/authors.txt create mode 100644 extra/tokyo/alien/tcutil/authors.txt 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/tchdb.factor b/extra/tokyo/alien/tchdb/tchdb.factor new file mode 100644 index 0000000000..89ca081627 --- /dev/null +++ b/extra/tokyo/alien/tchdb/tchdb.factor @@ -0,0 +1,98 @@ +! 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 + +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 ) ; 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/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index 7919c92698..087b303d9b 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -1,7 +1,9 @@ -USING: kernel alien combinators alien.syntax - alien.c-types - alien.libraries tokyo.alien.tcutil tokyo.alien.tctdb ; -IN: tokyo.alient.tcrdb +! 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.tctdb ; +IN: tokyo.alien.tcrdb TYPEDEF: void* TCRDB* ! C-STRUCT: TCRDB @@ -115,17 +117,17 @@ CONSTANT: RDBQOSTRDESC TDBQOSTRDESC CONSTANT: RDBQONUMASC TDBQONUMASC CONSTANT: RDBQONUMDESC TDBQONUMDESC -FUNCTION: bool tcrdbtblput ( TCRDB* rdb, const void* pkbuf, int pksiz, TCMAP* cols ) ; -FUNCTION: bool tcrdbtblputkeep ( TCRDB* rdb, const void* pkbuf, int pksiz, TCMAP* cols ) ; -FUNCTION: bool tcrdbtblputcat ( TCRDB* rdb, const void* pkbuf, int pksiz, TCMAP* cols ) ; -FUNCTION: bool tcrdbtblout ( TCRDB* rdb, const void* pkbuf, int pksiz ) ; -FUNCTION: TCMAP* tcrdbtblget ( TCRDB* rdb, const void* pkbuf, int pksiz ) ; -FUNCTION: bool tcrdbtblsetindex ( TCRDB* rdb, const char* name, int type ) ; +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, const char* name, int op, const char* expr ) ; -FUNCTION: void tcrdbqrysetorder ( RDBQRY* qry, const char* name, int type ) ; +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 ) ; 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/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index 35bc16e003..90ede6c7b7 100644 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -1,7 +1,9 @@ -USING: kernel alien combinators alien.syntax - alien.c-types - alien.libraries tokyo.alien.tcutil ; -IN: tokyo.alient.tctdb +! 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.tchdb ; +IN: tokyo.alien.tctdb TYPEDEF: void* TDBIDX* TYPEDEF: void* TCTDB* @@ -68,7 +70,7 @@ CONSTANT: TDBQPSTOP 16777216 TYPEDEF: void* TDBQRYPROC FUNCTION: char* tctdberrmsg ( int ecode ) ; -FUNCTION: TCTDB* tctdbnew ( void ) ; +FUNCTION: TCTDB* tctdbnew ( ) ; FUNCTION: void tctdbdel ( TCTDB* tdb ) ; FUNCTION: int tctdbecode ( TCTDB* tdb ) ; FUNCTION: bool tctdbsetmutex ( TCTDB* tdb ) ; 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/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index 41de2c9407..328fd01d3e 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -1,7 +1,8 @@ -USING: kernel alien combinators alien.syntax - alien.c-types - alien.libraries ; -IN: tokyo.alient.tcutil +! 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 ; +IN: tokyo.alien.tcutil C-ENUM: TCDBTHASH @@ -22,3 +23,8 @@ 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 ) ; + +TYPEDEF: void* TCCMP +TYPEDEF: void* TCCODEC +TYPEDEF: void* TCPDPROC +TYPEDEF: voud* TCITER From d61efa6b287fdc39b356f8725b8d9a9af7603583 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 01:24:22 -0300 Subject: [PATCH 05/26] tokyo.alien: Add tcbdb --- extra/tokyo/alien/tcbdb/authors.txt | 1 + extra/tokyo/alien/tcbdb/tcbdb.factor | 131 +++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 extra/tokyo/alien/tcbdb/authors.txt create mode 100644 extra/tokyo/alien/tcbdb/tcbdb.factor 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/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor new file mode 100644 index 0000000000..9e539e7036 --- /dev/null +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -0,0 +1,131 @@ +! 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.tchdb ; +IN: tokyo.alien.tcbdb + +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 ) ; From 12ac159f6d009c230afcf66d06fe348570d9a692 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 01:41:15 -0300 Subject: [PATCH 06/26] tokyo.alien: Add tcfdb --- extra/tokyo/alien/tcfdb/authors.txt | 1 + extra/tokyo/alien/tcfdb/tcfdb.factor | 94 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 extra/tokyo/alien/tcfdb/authors.txt create mode 100644 extra/tokyo/alien/tcfdb/tcfdb.factor 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/tcfdb.factor b/extra/tokyo/alien/tcfdb/tcfdb.factor new file mode 100644 index 0000000000..c624f86f40 --- /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: 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 ) ; From f585ba4ba31fb3090889825c4cc98bd4151d7fa2 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 01:49:07 -0300 Subject: [PATCH 07/26] tokyo.alien: Add tcadb --- extra/tokyo/alien/tcadb/authors.txt | 1 + extra/tokyo/alien/tcadb/tcadb.factor | 67 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 extra/tokyo/alien/tcadb/authors.txt create mode 100644 extra/tokyo/alien/tcadb/tcadb.factor 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/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor new file mode 100644 index 0000000000..203a0b8cbb --- /dev/null +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -0,0 +1,67 @@ +! 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.tcrdb + +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: uint64_t tcadbrnum ( TCADB* adb ) ; +FUNCTION: uint64_t 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, int64_t csiz ) ; +FUNCTION: bool tcadbmapbdbemit ( void* map, char* kbuf, int ksiz, char* vbuf, int vsiz ) ; From cb300e3a8401ae4bc81cb35009c82cf18079dcf7 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 20:13:53 -0300 Subject: [PATCH 08/26] tokyo.alien: Add code that loads the dlls (not working right now for me) --- extra/tokyo/alien/tcadb/tcadb.factor | 8 +++++--- extra/tokyo/alien/tcbdb/tcbdb.factor | 2 ++ extra/tokyo/alien/tchdb/tchdb.factor | 2 ++ extra/tokyo/alien/tcrdb/tcrdb.factor | 10 +++++++++- extra/tokyo/alien/tctdb/tctdb.factor | 2 ++ extra/tokyo/alien/tcutil/tcutil.factor | 10 +++++++++- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/extra/tokyo/alien/tcadb/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor index 203a0b8cbb..4e8ca56531 100644 --- a/extra/tokyo/alien/tcadb/tcadb.factor +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -5,6 +5,8 @@ combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil tokyo.alien.tcbdb tokyo.alien.tcfdb tokyo.alien.tctdb ; IN: tokyo.alien.tcrdb +LIBRARY: tokyocabinet + TYPEDEF: void* TCADB C-ENUM: @@ -48,8 +50,8 @@ FUNCTION: bool tcadbtranbegin ( TCADB* adb ) ; FUNCTION: bool tcadbtrancommit ( TCADB* adb ) ; FUNCTION: bool tcadbtranabort ( TCADB* adb ) ; FUNCTION: char* tcadbpath ( TCADB* adb ) ; -FUNCTION: uint64_t tcadbrnum ( TCADB* adb ) ; -FUNCTION: uint64_t tcadbsize ( TCADB* adb ) ; +FUNCTION: ulonglong tcadbrnum ( TCADB* adb ) ; +FUNCTION: ulonglong tcadbsize ( TCADB* adb ) ; FUNCTION: TCLIST* tcadbmisc ( TCADB* adb, char* name, TCLIST* args ) ; ! ----- @@ -63,5 +65,5 @@ 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, int64_t csiz ) ; +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/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor index 9e539e7036..ad359762e8 100644 --- a/extra/tokyo/alien/tcbdb/tcbdb.factor +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -5,6 +5,8 @@ combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil tokyo.alien.tchdb ; IN: tokyo.alien.tcbdb +LIBRARY: tokyocabinet + TYPEDEF: void* TCBDB CONSTANT: BDBFOPEN HDBFOPEN diff --git a/extra/tokyo/alien/tchdb/tchdb.factor b/extra/tokyo/alien/tchdb/tchdb.factor index 89ca081627..f143e9b304 100644 --- a/extra/tokyo/alien/tchdb/tchdb.factor +++ b/extra/tokyo/alien/tchdb/tchdb.factor @@ -4,6 +4,8 @@ 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 diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index 087b303d9b..c64b12a4a1 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -1,10 +1,18 @@ ! 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 +combinators kernel system tokyo.alien.tchdb tokyo.alien.tcutil tokyo.alien.tctdb ; IN: tokyo.alien.tcrdb +<< "tokyotyrant" { + { [ os macosx? ] [ "libtokyotyrant.3.dylib" ] } + { [ os unix? ] [ "libtokyotyrant.3.so" ] } + { [ os windows? ] [ "tokyotyrant.dll" ] } +} cond "cdecl" add-library >> + +LIBRARY: tokyotyrant + TYPEDEF: void* TCRDB* ! C-STRUCT: TCRDB ! { "pthread_mutex_t" mmtx } diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index 90ede6c7b7..b3379b4455 100644 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -5,6 +5,8 @@ combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil tokyo.alien.tchdb ; IN: tokyo.alien.tctdb +LIBRARY: tokyocabinet + TYPEDEF: void* TDBIDX* TYPEDEF: void* TCTDB* diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index 328fd01d3e..ae6f6ed963 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -1,9 +1,17 @@ ! 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 ; +combinators kernel system ; IN: tokyo.alien.tcutil +<< "tokyocabinet" { + { [ os macosx? ] [ "libtokyocabinet.dylib" ] } + { [ os unix? ] [ "libtokyocabinet.so" ] } + { [ os windows? ] [ "tokyocabinet.dll" ] } +} cond "cdecl" add-library >> + +LIBRARY: tokyocabinet + C-ENUM: TCDBTHASH TCDBTBTREE From 56bd08596230db63026ac7786a55f679f4ccf5ff Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 20:41:41 -0300 Subject: [PATCH 09/26] tokyo.alien: Add full paths to libraries on osx --- extra/tokyo/alien/tcrdb/tcrdb.factor | 4 ++-- extra/tokyo/alien/tcutil/tcutil.factor | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index c64b12a4a1..5b7be38461 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -6,8 +6,8 @@ tokyo.alien.tctdb ; IN: tokyo.alien.tcrdb << "tokyotyrant" { - { [ os macosx? ] [ "libtokyotyrant.3.dylib" ] } - { [ os unix? ] [ "libtokyotyrant.3.so" ] } + { [ os macosx? ] [ "/opt/local/lib/libtokyotyrant.dylib" ] } + { [ os unix? ] [ "libtokyotyrant.so" ] } { [ os windows? ] [ "tokyotyrant.dll" ] } } cond "cdecl" add-library >> diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index ae6f6ed963..910f14e67d 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -5,7 +5,7 @@ combinators kernel system ; IN: tokyo.alien.tcutil << "tokyocabinet" { - { [ os macosx? ] [ "libtokyocabinet.dylib" ] } + { [ os macosx? ] [ "/opt/local/lib/libtokyocabinet.dylib" ] } { [ os unix? ] [ "libtokyocabinet.so" ] } { [ os windows? ] [ "tokyocabinet.dll" ] } } cond "cdecl" add-library >> From 142f12b5bc6cc9a7cb266095be73cf0bfd08d062 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Sat, 13 Jun 2009 22:16:29 -0300 Subject: [PATCH 10/26] tokyo.alien: Fix typo --- extra/tokyo/alien/tcadb/tcadb.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/tokyo/alien/tcadb/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor index 4e8ca56531..efba5f0374 100644 --- a/extra/tokyo/alien/tcadb/tcadb.factor +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -3,7 +3,7 @@ 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.tcrdb +IN: tokyo.alien.tcadb LIBRARY: tokyocabinet From ce47a54562d269bef489f5aa9b25c05b46cb4439 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Tue, 16 Jun 2009 23:29:09 -0300 Subject: [PATCH 11/26] tokyo.cabinet.abstract: Assoc protocol implementation for Tokyo Cabinet abstract db api --- extra/tokyo/cabinet/abstract/abstract.factor | 51 ++++++++++++++++++++ extra/tokyo/cabinet/abstract/authors.txt | 1 + 2 files changed, 52 insertions(+) create mode 100644 extra/tokyo/cabinet/abstract/abstract.factor create mode 100644 extra/tokyo/cabinet/abstract/authors.txt diff --git a/extra/tokyo/cabinet/abstract/abstract.factor b/extra/tokyo/cabinet/abstract/abstract.factor new file mode 100644 index 0000000000..6f3c5768b8 --- /dev/null +++ b/extra/tokyo/cabinet/abstract/abstract.factor @@ -0,0 +1,51 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types assocs destructors kernel libc locals +sequences serialize tokyo.alien.tcadb ; +IN: tokyo.cabinet.abstract + +TUPLE: tokyo-abstractdb handle disposed ; + +INSTANCE: tokyo-abstractdb assoc + +: ( name -- tokyo-abstractdb ) + tcadbnew [ swap tcadbopen drop ] keep + tokyo-abstractdb new [ (>>handle) ] keep ; + +M: tokyo-abstractdb dispose* [ tcadbdel f ] change-handle drop ; + +M:: tokyo-abstractdb at* ( key db -- value/f ? ) + 0 :> sizeout + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + handle kbytes key-size sizeout tcadbget :> output + output [ + [ sizeout *int memory>byte-array bytes>object t ] [ drop ] bi + ] [ f f ] if* ; + +M: tokyo-abstractdb assoc-size ( db -- size ) handle>> tcadbrnum ; + +! FIXME: implement +! M: tokyo-abstractdb >alist ( db -- alist ) +! handle>> ; + +M:: tokyo-abstractdb set-at ( value key db -- ) + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + value object>bytes :> vbytes + vbytes length :> value-size + handle kbytes key-size vbytes value-size tcadbput drop ; + +M:: tokyo-abstractdb delete-at ( key db -- ) + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + handle kbytes key-size tcadbout drop ; + +M: tokyo-abstractdb clear-assoc ( db -- ) handle>> tcadbvanish drop ; + +M: tokyo-abstractdb equal? assoc= ; + +M: tokyo-abstractdb hashcode* assoc-hashcode ; diff --git a/extra/tokyo/cabinet/abstract/authors.txt b/extra/tokyo/cabinet/abstract/authors.txt new file mode 100644 index 0000000000..f4a8cb1dc2 --- /dev/null +++ b/extra/tokyo/cabinet/abstract/authors.txt @@ -0,0 +1 @@ +Bruno Deferrari From c331807cff44b8ccf4a675252a03748f93b18dc2 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 08:45:47 -0300 Subject: [PATCH 12/26] tokyo: Add summary.txt files --- extra/tokyo/alien/tcadb/summary.txt | 1 + extra/tokyo/alien/tcbdb/summary.txt | 1 + extra/tokyo/alien/tcfdb/summary.txt | 1 + extra/tokyo/alien/tchdb/summary.txt | 1 + extra/tokyo/alien/tcrdb/summary.txt | 1 + extra/tokyo/alien/tctdb/summary.txt | 1 + extra/tokyo/alien/tcutil/summary.txt | 1 + extra/tokyo/cabinet/abstract/summary.txt | 1 + 8 files changed, 8 insertions(+) create mode 100644 extra/tokyo/alien/tcadb/summary.txt create mode 100644 extra/tokyo/alien/tcbdb/summary.txt create mode 100644 extra/tokyo/alien/tcfdb/summary.txt create mode 100644 extra/tokyo/alien/tchdb/summary.txt create mode 100644 extra/tokyo/alien/tcrdb/summary.txt create mode 100644 extra/tokyo/alien/tctdb/summary.txt create mode 100644 extra/tokyo/alien/tcutil/summary.txt create mode 100644 extra/tokyo/cabinet/abstract/summary.txt 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/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/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/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/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/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/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/cabinet/abstract/summary.txt b/extra/tokyo/cabinet/abstract/summary.txt new file mode 100644 index 0000000000..a2a21dbe6e --- /dev/null +++ b/extra/tokyo/cabinet/abstract/summary.txt @@ -0,0 +1 @@ +Higher level API for Tokyo Cabinet's Abstract database API. Implements the associative protocol. From 5b58a7814e9c1fabc95fb3394b63c0a7e919d7d6 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 09:15:53 -0300 Subject: [PATCH 13/26] tokyo.cabinet.abstract: Implement >alist, and correctly free memory returned by tokyo cabinet --- extra/tokyo/alien/tcutil/tcutil.factor | 1 + extra/tokyo/cabinet/abstract/abstract.factor | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index 910f14e67d..25df54d013 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -31,6 +31,7 @@ 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 diff --git a/extra/tokyo/cabinet/abstract/abstract.factor b/extra/tokyo/cabinet/abstract/abstract.factor index 6f3c5768b8..a6ce2408d9 100644 --- a/extra/tokyo/cabinet/abstract/abstract.factor +++ b/extra/tokyo/cabinet/abstract/abstract.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types assocs destructors kernel libc locals -sequences serialize tokyo.alien.tcadb ; +USING: accessors alien.c-types arrays assocs destructors kernel libc locals +sequences serialize tokyo.alien.tcadb tokyo.alien.tcutil vectors ; IN: tokyo.cabinet.abstract TUPLE: tokyo-abstractdb handle disposed ; @@ -21,14 +21,22 @@ M:: tokyo-abstractdb at* ( key db -- value/f ? ) kbytes length :> key-size handle kbytes key-size sizeout tcadbget :> output output [ - [ sizeout *int memory>byte-array bytes>object t ] [ drop ] bi + [ sizeout *int memory>byte-array ] [ tcfree ] bi bytes>object t ] [ f f ] if* ; M: tokyo-abstractdb assoc-size ( db -- size ) handle>> tcadbrnum ; -! FIXME: implement -! M: tokyo-abstractdb >alist ( db -- alist ) -! handle>> ; +! FIXME: make this nicer +M:: tokyo-abstractdb >alist ( db -- alist ) + db handle>> :> handle + 0 :> size-out + db assoc-size :> keys + handle tcadbiterinit drop + [ handle size-out tcadbiternext dup ] [ + [ size-out *int memory>byte-array ] [ tcfree ] bi + bytes>object keys push + ] while drop + keys [ dup db at 2array ] { } map-as ; M:: tokyo-abstractdb set-at ( value key db -- ) db handle>> :> handle From 0b68f70cccd7de212173c6288344ba71049f43e1 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 12:13:59 -0300 Subject: [PATCH 14/26] tokyo.cabinet.abstract: Optimization, deserialize objects directly from memory, without the intermediate bytes-array --- extra/tokyo/cabinet/abstract/abstract.factor | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/extra/tokyo/cabinet/abstract/abstract.factor b/extra/tokyo/cabinet/abstract/abstract.factor index a6ce2408d9..245267f488 100644 --- a/extra/tokyo/cabinet/abstract/abstract.factor +++ b/extra/tokyo/cabinet/abstract/abstract.factor @@ -1,11 +1,20 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs destructors kernel libc locals +USING: accessors alien.c-types arrays assocs destructors +io io.streams.memory kernel libc locals sequences serialize tokyo.alien.tcadb tokyo.alien.tcutil vectors ; IN: tokyo.cabinet.abstract TUPLE: tokyo-abstractdb handle disposed ; + ] dip with-input-stream* ; inline + +: memory>object ( memory -- object ) + [ deserialize ] with-memory-reader ; +PRIVATE> + INSTANCE: tokyo-abstractdb assoc : ( name -- tokyo-abstractdb ) @@ -21,7 +30,7 @@ M:: tokyo-abstractdb at* ( key db -- value/f ? ) kbytes length :> key-size handle kbytes key-size sizeout tcadbget :> output output [ - [ sizeout *int memory>byte-array ] [ tcfree ] bi bytes>object t + [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ; M: tokyo-abstractdb assoc-size ( db -- size ) handle>> tcadbrnum ; @@ -33,8 +42,8 @@ M:: tokyo-abstractdb >alist ( db -- alist ) db assoc-size :> keys handle tcadbiterinit drop [ handle size-out tcadbiternext dup ] [ - [ size-out *int memory>byte-array ] [ tcfree ] bi - bytes>object keys push + [ memory>object ] [ tcfree ] bi + keys push ] while drop keys [ dup db at 2array ] { } map-as ; From 4fcb37987052470a7571598b51b9456df6c40e5a Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 16:33:37 -0300 Subject: [PATCH 15/26] tokyo.alien: Fix USING: lines --- extra/tokyo/alien/tcbdb/tcbdb.factor | 3 +-- extra/tokyo/alien/tctdb/tctdb.factor | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/extra/tokyo/alien/tcbdb/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor index ad359762e8..730423c169 100644 --- a/extra/tokyo/alien/tcbdb/tcbdb.factor +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -1,8 +1,7 @@ ! 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.tchdb ; +combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil ; IN: tokyo.alien.tcbdb LIBRARY: tokyocabinet diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index b3379b4455..7bcb0f278d 100644 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -1,8 +1,7 @@ ! 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.tchdb ; +combinators kernel tokyo.alien.tchdb tokyo.alien.tcutil ; IN: tokyo.alien.tctdb LIBRARY: tokyocabinet From e8c9805ee138e76dd6f7314023579b918511fc49 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 20:23:39 -0300 Subject: [PATCH 16/26] tokyo.abstractdb: Renamed vocab, refactored memory streams to tokyo.utils vocab --- .../abstractdb.factor} | 14 +++----------- .../{cabinet/abstract => abstractdb}/authors.txt | 0 .../{cabinet/abstract => abstractdb}/summary.txt | 0 extra/tokyo/utils/authors.txt | 1 + extra/tokyo/utils/summary.txt | 1 + extra/tokyo/utils/utils.factor | 10 ++++++++++ 6 files changed, 15 insertions(+), 11 deletions(-) rename extra/tokyo/{cabinet/abstract/abstract.factor => abstractdb/abstractdb.factor} (84%) rename extra/tokyo/{cabinet/abstract => abstractdb}/authors.txt (100%) rename extra/tokyo/{cabinet/abstract => abstractdb}/summary.txt (100%) create mode 100644 extra/tokyo/utils/authors.txt create mode 100644 extra/tokyo/utils/summary.txt create mode 100644 extra/tokyo/utils/utils.factor diff --git a/extra/tokyo/cabinet/abstract/abstract.factor b/extra/tokyo/abstractdb/abstractdb.factor similarity index 84% rename from extra/tokyo/cabinet/abstract/abstract.factor rename to extra/tokyo/abstractdb/abstractdb.factor index 245267f488..1433c275e1 100644 --- a/extra/tokyo/cabinet/abstract/abstract.factor +++ b/extra/tokyo/abstractdb/abstractdb.factor @@ -1,20 +1,12 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types arrays assocs destructors -io io.streams.memory kernel libc locals -sequences serialize tokyo.alien.tcadb tokyo.alien.tcutil vectors ; -IN: tokyo.cabinet.abstract +kernel locals sequences serialize vectors +tokyo.alien.tcadb tokyo.alien.tcutil tokyo.utils ; +IN: tokyo.abstractdb TUPLE: tokyo-abstractdb handle disposed ; - ] dip with-input-stream* ; inline - -: memory>object ( memory -- object ) - [ deserialize ] with-memory-reader ; -PRIVATE> - INSTANCE: tokyo-abstractdb assoc : ( name -- tokyo-abstractdb ) diff --git a/extra/tokyo/cabinet/abstract/authors.txt b/extra/tokyo/abstractdb/authors.txt similarity index 100% rename from extra/tokyo/cabinet/abstract/authors.txt rename to extra/tokyo/abstractdb/authors.txt diff --git a/extra/tokyo/cabinet/abstract/summary.txt b/extra/tokyo/abstractdb/summary.txt similarity index 100% rename from extra/tokyo/cabinet/abstract/summary.txt rename to extra/tokyo/abstractdb/summary.txt 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 ; From 9d515140fed3b74e18c16cc606b5435f717e9b46 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 17 Jun 2009 20:24:04 -0300 Subject: [PATCH 17/26] tokyo.remotedb: Remote database using Tokyo Tyrant --- extra/tokyo/remotedb/authors.txt | 1 + extra/tokyo/remotedb/remotedb.factor | 60 ++++++++++++++++++++++++++++ extra/tokyo/remotedb/summary.txt | 1 + 3 files changed, 62 insertions(+) create mode 100644 extra/tokyo/remotedb/authors.txt create mode 100644 extra/tokyo/remotedb/remotedb.factor create mode 100644 extra/tokyo/remotedb/summary.txt 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..2ccf41a901 --- /dev/null +++ b/extra/tokyo/remotedb/remotedb.factor @@ -0,0 +1,60 @@ +! Copyright (C) 2009 Bruno Deferrari +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types arrays assocs destructors +kernel locals sequences serialize vectors +tokyo.alien.tcrdb tokyo.alien.tcutil tokyo.utils ; +IN: tokyo.remotedb + +TUPLE: tokyo-remotedb handle disposed ; + +INSTANCE: tokyo-remotedb assoc + +: ( host port -- tokyo-remotedb ) + [ tcrdbnew dup ] 2dip tcrdbopen drop + tokyo-remotedb new [ (>>handle) ] keep ; + +M: tokyo-remotedb dispose* [ tcrdbdel f ] change-handle drop ; + +M:: tokyo-remotedb at* ( key db -- value/f ? ) + 0 :> sizeout + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + handle kbytes key-size sizeout tcrdbget :> output + output [ + [ memory>object ] [ tcfree ] bi t + ] [ f f ] if* ; + +M: tokyo-remotedb assoc-size ( db -- size ) handle>> tcrdbrnum ; + +! FIXME: make this nicer +M:: tokyo-remotedb >alist ( db -- alist ) + db handle>> :> handle + 0 :> size-out + db assoc-size :> keys + handle tcrdbiterinit drop + [ handle size-out tcrdbiternext dup ] [ + [ memory>object ] [ tcfree ] bi + keys push + ] while drop + keys [ dup db at 2array ] { } map-as ; + +M:: tokyo-remotedb set-at ( value key db -- ) + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + value object>bytes :> vbytes + vbytes length :> value-size + handle kbytes key-size vbytes value-size tcrdbput drop ; + +M:: tokyo-remotedb delete-at ( key db -- ) + db handle>> :> handle + key object>bytes :> kbytes + kbytes length :> key-size + handle kbytes key-size tcrdbout drop ; + +M: tokyo-remotedb clear-assoc ( db -- ) handle>> tcrdbvanish drop ; + +M: tokyo-remotedb equal? assoc= ; + +M: tokyo-remotedb hashcode* assoc-hashcode ; 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. From 10ab07224fdc819bf3c1364c26eed27048863f59 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 18 Jun 2009 15:09:03 -0500 Subject: [PATCH 18/26] make windows without titlebars on win32 actually not have titlebars --- basis/ui/backend/windows/windows.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index a63837a0da..3b174c5e8d 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 flags 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{ From f18655fd55d4d4c615db69760cacf322a8bbd38d Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Thu, 18 Jun 2009 18:55:26 -0300 Subject: [PATCH 19/26] tokyo: Reimplement assoc protocols for remote and abstract db using a functor --- extra/tokyo/abstractdb/abstractdb.factor | 54 +---------------- .../tokyo/assoc-functor/assoc-functor.factor | 59 +++++++++++++++++++ extra/tokyo/assoc-functor/authors.txt | 1 + extra/tokyo/assoc-functor/summary.txt | 1 + extra/tokyo/remotedb/remotedb.factor | 54 +---------------- 5 files changed, 65 insertions(+), 104 deletions(-) create mode 100644 extra/tokyo/assoc-functor/assoc-functor.factor create mode 100644 extra/tokyo/assoc-functor/authors.txt create mode 100644 extra/tokyo/assoc-functor/summary.txt diff --git a/extra/tokyo/abstractdb/abstractdb.factor b/extra/tokyo/abstractdb/abstractdb.factor index 1433c275e1..ea6d20fc2d 100644 --- a/extra/tokyo/abstractdb/abstractdb.factor +++ b/extra/tokyo/abstractdb/abstractdb.factor @@ -1,60 +1,10 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs destructors -kernel locals sequences serialize vectors -tokyo.alien.tcadb tokyo.alien.tcutil tokyo.utils ; +USING: accessors kernel tokyo.alien.tcadb tokyo.assoc-functor ; IN: tokyo.abstractdb -TUPLE: tokyo-abstractdb handle disposed ; - -INSTANCE: tokyo-abstractdb assoc +<< "tcadb" "abstractdb" define-tokyo-assoc-api >> : ( name -- tokyo-abstractdb ) tcadbnew [ swap tcadbopen drop ] keep tokyo-abstractdb new [ (>>handle) ] keep ; - -M: tokyo-abstractdb dispose* [ tcadbdel f ] change-handle drop ; - -M:: tokyo-abstractdb at* ( key db -- value/f ? ) - 0 :> sizeout - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - handle kbytes key-size sizeout tcadbget :> output - output [ - [ memory>object ] [ tcfree ] bi t - ] [ f f ] if* ; - -M: tokyo-abstractdb assoc-size ( db -- size ) handle>> tcadbrnum ; - -! FIXME: make this nicer -M:: tokyo-abstractdb >alist ( db -- alist ) - db handle>> :> handle - 0 :> size-out - db assoc-size :> keys - handle tcadbiterinit drop - [ handle size-out tcadbiternext dup ] [ - [ memory>object ] [ tcfree ] bi - keys push - ] while drop - keys [ dup db at 2array ] { } map-as ; - -M:: tokyo-abstractdb set-at ( value key db -- ) - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - value object>bytes :> vbytes - vbytes length :> value-size - handle kbytes key-size vbytes value-size tcadbput drop ; - -M:: tokyo-abstractdb delete-at ( key db -- ) - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - handle kbytes key-size tcadbout drop ; - -M: tokyo-abstractdb clear-assoc ( db -- ) handle>> tcadbvanish drop ; - -M: tokyo-abstractdb equal? assoc= ; - -M: tokyo-abstractdb hashcode* assoc-hashcode ; diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor new file mode 100644 index 0000000000..cc9a64fbe9 --- /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 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>> [ object>bytes dup length ] dip 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 ) + dup DBKEYS [ over at 2array ] with nip ; + +M: TYPE set-at ( value key db -- ) + handle>> spin [ object>bytes dup length ] bi@ DBPUT drop ; + +M: TYPE delete-at ( key db -- ) + handle>> [ 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/remotedb.factor b/extra/tokyo/remotedb/remotedb.factor index 2ccf41a901..c8761e16f3 100644 --- a/extra/tokyo/remotedb/remotedb.factor +++ b/extra/tokyo/remotedb/remotedb.factor @@ -1,60 +1,10 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs destructors -kernel locals sequences serialize vectors -tokyo.alien.tcrdb tokyo.alien.tcutil tokyo.utils ; +USING: accessors kernel tokyo.alien.tcrdb tokyo.assoc-functor ; IN: tokyo.remotedb -TUPLE: tokyo-remotedb handle disposed ; - -INSTANCE: tokyo-remotedb assoc +<< "tcrdb" "remotedb" define-tokyo-assoc-api >> : ( host port -- tokyo-remotedb ) [ tcrdbnew dup ] 2dip tcrdbopen drop tokyo-remotedb new [ (>>handle) ] keep ; - -M: tokyo-remotedb dispose* [ tcrdbdel f ] change-handle drop ; - -M:: tokyo-remotedb at* ( key db -- value/f ? ) - 0 :> sizeout - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - handle kbytes key-size sizeout tcrdbget :> output - output [ - [ memory>object ] [ tcfree ] bi t - ] [ f f ] if* ; - -M: tokyo-remotedb assoc-size ( db -- size ) handle>> tcrdbrnum ; - -! FIXME: make this nicer -M:: tokyo-remotedb >alist ( db -- alist ) - db handle>> :> handle - 0 :> size-out - db assoc-size :> keys - handle tcrdbiterinit drop - [ handle size-out tcrdbiternext dup ] [ - [ memory>object ] [ tcfree ] bi - keys push - ] while drop - keys [ dup db at 2array ] { } map-as ; - -M:: tokyo-remotedb set-at ( value key db -- ) - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - value object>bytes :> vbytes - vbytes length :> value-size - handle kbytes key-size vbytes value-size tcrdbput drop ; - -M:: tokyo-remotedb delete-at ( key db -- ) - db handle>> :> handle - key object>bytes :> kbytes - kbytes length :> key-size - handle kbytes key-size tcrdbout drop ; - -M: tokyo-remotedb clear-assoc ( db -- ) handle>> tcrdbvanish drop ; - -M: tokyo-remotedb equal? assoc= ; - -M: tokyo-remotedb hashcode* assoc-hashcode ; From 97f0a24e45e5c20a94586fe51de9c430257ae8c1 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 18 Jun 2009 17:29:41 -0500 Subject: [PATCH 20/26] add histogram and sequence>assoc to sets --- core/sets/sets-docs.factor | 80 ++++++++++++++++++++++++++++++++++++- core/sets/sets-tests.factor | 10 +++++ core/sets/sets.factor | 22 ++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 3670b10d3c..1e4ceb5680 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" @@ -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 "! Count the number of times the elements of two sequences appear." + "USING: 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 "! Count the number of times the elements of two sequences appear." + "USING: prettyprint sets ;" + "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 the elements of two sequences appear." + "USING: 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." } ; diff --git a/core/sets/sets-tests.factor b/core/sets/sets-tests.factor index 838a0a82b8..be195a62cd 100644 --- a/core/sets/sets-tests.factor +++ b/core/sets/sets-tests.factor @@ -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 diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 062b624e8f..421d43bb3d 100755 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -54,3 +54,25 @@ PRIVATE> : set= ( seq1 seq2 -- ? ) [ unique ] bi@ = ; + +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 ; From 801366df9854f52bec059ffd73d380e668c1c024 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 18 Jun 2009 17:32:10 -0500 Subject: [PATCH 21/26] minor cleanup --- basis/roman/roman.factor | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) 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: + From cd4203f00e18c198b1f878e6d3dddd298afc135a Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Thu, 18 Jun 2009 20:35:38 -0300 Subject: [PATCH 22/26] tokyo.assoc-functor: Fix at* --- extra/tokyo/assoc-functor/assoc-functor.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor index cc9a64fbe9..30debfc934 100644 --- a/extra/tokyo/assoc-functor/assoc-functor.factor +++ b/extra/tokyo/assoc-functor/assoc-functor.factor @@ -28,7 +28,7 @@ INSTANCE: TYPE assoc M: TYPE dispose* [ DBDEL f ] change-handle drop ; M: TYPE at* ( key db -- value/f ? ) - handle>> [ object>bytes dup length ] dip 0 + handle>> swap object>bytes dup length 0 DBGET [ [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ; M: TYPE assoc-size ( db -- size ) handle>> DBRNUM ; From da2a94a1994fd8e0e5deeaecc026e678b0d27566 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Thu, 18 Jun 2009 21:02:29 -0300 Subject: [PATCH 23/26] tokyo.assoc-functor: Fix >alist and delete-at --- extra/tokyo/assoc-functor/assoc-functor.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor index 30debfc934..1df1325eef 100644 --- a/extra/tokyo/assoc-functor/assoc-functor.factor +++ b/extra/tokyo/assoc-functor/assoc-functor.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs destructors functors +USING: accessors alien.c-types arrays assocs destructors fry functors kernel locals sequences serialize tokyo.alien.tcutil tokyo.utils vectors ; IN: tokyo.assoc-functor @@ -42,13 +42,13 @@ M: TYPE assoc-size ( db -- size ) handle>> DBRNUM ; ] while 3drop ; M: TYPE >alist ( db -- alist ) - dup DBKEYS [ over at 2array ] with nip ; + [ 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>> [ object>bytes dup length ] DBOUT drop ; + handle>> swap object>bytes dup length DBOUT drop ; M: TYPE clear-assoc ( db -- ) handle>> DBVANISH drop ; From 03b8e1b7561ddf53c9e035df46eb7169a786743e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 18 Jun 2009 19:29:10 -0500 Subject: [PATCH 24/26] don't write docs with auto-use enabled --- core/sets/sets-docs.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 1e4ceb5680..298fcbeeae 100755 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -168,8 +168,8 @@ HELP: sequence>assoc { "assoc" assoc } } { $examples - { $example "! Count the number of times the elements of two sequences appear." - "USING: prettyprint sets ;" + { $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 } }" } @@ -182,8 +182,8 @@ HELP: sequence>assoc* { "assoc" assoc } } { $examples - { $example "! Count the number of times the elements of two sequences appear." - "USING: prettyprint sets ;" + { $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 } }" } @@ -196,8 +196,8 @@ HELP: sequence>hashtable { "hashtable" hashtable } } { $examples - { $example "! Count the number of times the elements of two sequences appear." - "USING: prettyprint sets ;" + { $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 } }" } From a99f8f5741c80129c8e4dec42ed61fc288b11dfd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Jun 2009 19:30:17 -0500 Subject: [PATCH 25/26] Fix hang when loading ui.backend.windows --- basis/ui/backend/windows/windows.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 3b174c5e8d..03a86fe25f 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -253,7 +253,7 @@ CONSTANT: window-control>ex-style window-controls>> [ window-control>style symbols>flags ] [ needs-sysmenu? [ WS_SYSMENU bitor ] when ] - [ has-titlebar? [ WS_POPUP flags bitor ] unless ] tri ; + [ has-titlebar? [ WS_POPUP bitor ] unless ] tri ; : world>ex-style ( world -- n ) window-controls>> window-control>ex-style symbols>flags ; From f1bf5db9ed8c63563bab56b1583e097f8860fc97 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 18 Jun 2009 19:34:56 -0500 Subject: [PATCH 26/26] turn off auto-use when using help-lint --- basis/help/lint/lint.factor | 1 + 1 file changed, 1 insertion(+) 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