Commit 506a8b5e

506a8b5ed648Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

Merge pull request #576 from rubys/ffi-ptr-int-literal

test(ffi): regression test for integer literal in :ptr arg slot

Details

Commit
506a8b5ed648
Parent
f0063046556d
Merge parent
062f94b3d40f

examples/ffi/sqlite/sqlite3_lib.rbmodifiedView file

@@ -5,10 +5,12 @@
55 # - exec for DDL + INSERT/UPDATE/DELETE
66 # - prepare_v2 / step / finalize + column accessors for SELECT
77 #
8-# Strings are passed inline into SQL; bind_text would also work but
9-# requires the SQLITE_TRANSIENT destructor sentinel which the Spinel FFI
10-# can't construct as a `:ptr` value yet. For string columns we escape
11-# single quotes ourselves (`Sql.q`).
8+# Strings are passed inline into SQL: `Sql.q` doubles single quotes
9+# to handle the demo's well-known inputs. `bind_text` is also
10+# supported — pass `-1` as the destructor argument for
11+# `SQLITE_TRANSIENT` (`((sqlite3_destructor_type)-1)`), the same
12+# wire-shape ruby-ffi exposes via `FFI::Pointer.new(-1)`. See
13+# test/ffi_ptr_int_literal.rb for the underlying primitive.
1214 module SQL
1315 ffi_lib "sqlite3"
1416
@@ -21,6 +23,7 @@
2123 ffi_func :sqlite3_close, [:ptr], :int
2224 ffi_func :sqlite3_exec, [:ptr, :str, :ptr, :ptr, :ptr], :int
2325 ffi_func :sqlite3_prepare_v2, [:ptr, :str, :int, :ptr, :ptr], :int
26+ ffi_func :sqlite3_bind_text, [:ptr, :int, :str, :int, :ptr], :int
2427 ffi_func :sqlite3_step, [:ptr], :int
2528 ffi_func :sqlite3_finalize, [:ptr], :int
2629 ffi_func :sqlite3_column_int, [:ptr, :int], :int