gdbm: add shorthands for common cases
parent
2446a59744
commit
18c93fa1bd
|
@ -25,7 +25,7 @@ CLEANUP
|
|||
[ ] [ [ "foo" 41 insert ] with-test.db ] unit-test
|
||||
|
||||
[
|
||||
[ "foo" 42 insert ] with-test.db
|
||||
db-path [ "foo" 42 insert ] with-gdbm-writer
|
||||
] [ gdbm-cannot-replace = ] must-fail-with
|
||||
|
||||
[ ]
|
||||
|
@ -37,7 +37,7 @@ CLEANUP
|
|||
] with-test.db
|
||||
] unit-test
|
||||
|
||||
[ 42 t ] [ [ "foo" fetch* ] with-test.db ] unit-test
|
||||
[ 42 t ] [ db-path [ "foo" fetch* ] with-gdbm-reader ] unit-test
|
||||
|
||||
[ f f ] [ [ "unknown" fetch* ] with-test.db ] unit-test
|
||||
|
||||
|
|
|
@ -148,3 +148,13 @@ PRIVATE>
|
|||
: with-gdbm ( gdbm quot -- )
|
||||
[ gdbm-open &gdbm-close current-dbf set ] prepose curry
|
||||
[ with-scope ] curry with-destructors ; inline
|
||||
|
||||
:: with-gdbm-role ( name role quot -- )
|
||||
<gdbm> name >>name role >>role quot with-gdbm ; inline
|
||||
|
||||
: with-gdbm-reader ( name quot -- )
|
||||
reader swap with-gdbm-role ; inline
|
||||
|
||||
: with-gdbm-writer ( name quot -- )
|
||||
writer swap with-gdbm-role ; inline
|
||||
|
||||
|
|
Loading…
Reference in New Issue