]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/gdbm/gdbm.factor
use radix literals
[factor.git] / extra / gdbm / gdbm.factor
index 54980cb309b4f49a10d72d3c0143ea6b391b162a..a69809f4e3dc97aaa4eaeb9df05f3db153273a13 100644 (file)
@@ -14,7 +14,7 @@ TUPLE: gdbm
     { role initial: wrcreat }
     { sync boolean }
     { nolock boolean }
-    { mode integer initial: OCT: 644 } ;
+    { mode integer initial: 0o644 } ;
 
 : <gdbm> ( -- gdbm ) gdbm new ;
 
@@ -76,7 +76,8 @@ DESTRUCTOR: gdbm-close
 
 : gdbm-store ( key content flag -- )
     [
-        { [ dbf ] [ object>datum ] [ object>datum ] [ ] } spread
+        [ dbf ] 3dip
+        [ object>datum ] [ object>datum ] [ ] tri*
         gdbm_store check-error
     ] with-destructors ;
 
@@ -148,3 +149,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
+