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/DELETE66
# - prepare_v2 / step / finalize + column accessors for SELECT77
#8-
# Strings are passed inline into SQL; bind_text would also work but9-
# requires the SQLITE_TRANSIENT destructor sentinel which the Spinel FFI10-
# can't construct as a `:ptr` value yet. For string columns we escape11-
# single quotes ourselves (`Sql.q`).8+
# Strings are passed inline into SQL: `Sql.q` doubles single quotes9+
# to handle the demo's well-known inputs. `bind_text` is also10+
# supported — pass `-1` as the destructor argument for11+
# `SQLITE_TRANSIENT` (`((sqlite3_destructor_type)-1)`), the same12+
# wire-shape ruby-ffi exposes via `FFI::Pointer.new(-1)`. See13+
# test/ffi_ptr_int_literal.rb for the underlying primitive.1214
module SQL1315
ffi_lib "sqlite3"1416
@@ -21,6 +23,7 @@
2123
ffi_func :sqlite3_close, [:ptr], :int2224
ffi_func :sqlite3_exec, [:ptr, :str, :ptr, :ptr, :ptr], :int2325
ffi_func :sqlite3_prepare_v2, [:ptr, :str, :int, :ptr, :ptr], :int26+
ffi_func :sqlite3_bind_text, [:ptr, :int, :str, :int, :ptr], :int2427
ffi_func :sqlite3_step, [:ptr], :int2528
ffi_func :sqlite3_finalize, [:ptr], :int2629
ffi_func :sqlite3_column_int, [:ptr, :int], :inttest/ffi_ptr_int_literal.rbaddedView file
Loading diff…
test/ffi_ptr_int_literal.rb.expectedaddedView file
Loading diff…