! Copyright (C) 2008 Chris Double, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types arrays assocs kernel math math.parser
+USING: alien.c-types alien.data arrays assocs kernel math math.parser
namespaces sequences db.sqlite.ffi db combinators
continuations db.types calendar.format serialize
io.streams.byte-array byte-arrays io.encodings.binary
io.backend db.errors present urls io.encodings.utf8
-io.encodings.string accessors shuffle ;
+io.encodings.string accessors shuffle io db.private ;
IN: db.sqlite.lib
ERROR: sqlite-error < db-error n string ;
: sqlite-statement-error ( -- * )
SQLITE_ERROR
- db get handle>> sqlite3_errmsg sqlite-sql-error ;
+ db-connection get handle>> sqlite3_errmsg sqlite-sql-error ;
: sqlite-check-result ( n -- )
{
: 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 ;