]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/db/sqlite/lib/lib.factor
Updating code to use with-out-parameters
[factor.git] / basis / db / sqlite / lib / lib.factor
index 53034d148ab5aa194429655b8b5ad8182bd48b4e..58033a281e8a5bb117eccee0c2371546e588df49 100644 (file)
@@ -11,17 +11,12 @@ IN: db.sqlite.lib
 ERROR: sqlite-error < db-error n string ;
 ERROR: sqlite-sql-error < sql-error n string ;
 
-: <sqlite-sql-error> ( n string -- error )
-    \ sqlite-sql-error new
-        swap >>string
-        swap >>n ;
-
 : throw-sqlite-error ( n -- * )
     dup sqlite-error-messages nth sqlite-error ;
 
 : sqlite-statement-error ( -- * )
     SQLITE_ERROR
-    db-connection get handle>> sqlite3_errmsg <sqlite-sql-error> throw ;
+    db-connection get handle>> sqlite3_errmsg sqlite-sql-error ;
 
 : sqlite-check-result ( n -- )
     {
@@ -32,16 +27,17 @@ ERROR: sqlite-sql-error < sql-error n string ;
 
 : sqlite-open ( path -- db )
     normalize-path
-    void* <c-object>
-    [ sqlite3_open sqlite-check-result ] keep *void* ;
+    { void* } [ sqlite3_open sqlite-check-result ] [ ]
+    with-out-parameters ;
 
 : sqlite-close ( db -- )
     sqlite3_close sqlite-check-result ;
 
 : sqlite-prepare ( db sql -- handle )
-    utf8 encode dup length void* <c-object> void* <c-object>
-    [ sqlite3_prepare_v2 sqlite-check-result ] 2keep
-    drop *void* ;
+    utf8 encode dup length
+    { void* void* }
+    [ sqlite3_prepare_v2 sqlite-check-result ] [ drop ]
+    with-out-parameters ;
 
 : sqlite-bind-parameter-index ( handle name -- index )
     sqlite3_bind_parameter_index ;