From 64312e57fa0fd5e12d724e6960ee24475963098a Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Mon, 18 Apr 2022 22:44:11 -0400 Subject: [PATCH] maybe run with cffi on PUC Lua? Untested --- diet-sqlite/codes.lua | 7 ++----- diet-sqlite/ffi.lua | 5 +++++ diet-sqlite/init.fnl | 2 +- diet-sqlite/sqlite3_ffi.lua | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 diet-sqlite/ffi.lua diff --git a/diet-sqlite/codes.lua b/diet-sqlite/codes.lua index e0221c9..4a15cac 100644 --- a/diet-sqlite/codes.lua +++ b/diet-sqlite/codes.lua @@ -1,8 +1,5 @@ ---This file is generated by running the ---gencodes.lua ---script. If you want to alter this file, it is best ---to make the changes in that script and run it again. -local ffi = require "ffi" +-- works with luajit ffi or https://github.com/q66/cffi-lua +local ffi = require "diet-sqlite.ffi" return { SQLITE_TRANSIENT = ffi.cast('void(*)(void*)', -1); diff --git a/diet-sqlite/ffi.lua b/diet-sqlite/ffi.lua new file mode 100644 index 0000000..8368ca0 --- /dev/null +++ b/diet-sqlite/ffi.lua @@ -0,0 +1,5 @@ +-- works with luajit ffi or https://github.com/q66/cffi-lua +local ok, ffi = pcall(require, "ffi") +if not ok then ffi = require "cffi" end + +return ffi diff --git a/diet-sqlite/init.fnl b/diet-sqlite/init.fnl index 7074a25..55f1379 100644 --- a/diet-sqlite/init.fnl +++ b/diet-sqlite/init.fnl @@ -2,7 +2,7 @@ ; It is meant to be an _extremely_ thin wrapper around the SQLite API. (local sqlffi (require :diet-sqlite.sqlite3_ffi)) -(local ffi (require :ffi)) +(local ffi (require :diet-sqlite.ffi)) (local util (require :lib.util)) (local {: SQLITE_OK : SQLITE_INTEGER : SQLITE_FLOAT : SQLITE_NULL : SQLITE_BLOB : SQLITE_TEXT : SQLITE_TRANSIENT} (require :diet-sqlite.codes)) diff --git a/diet-sqlite/sqlite3_ffi.lua b/diet-sqlite/sqlite3_ffi.lua index 896030e..dd1cfd7 100644 --- a/diet-sqlite/sqlite3_ffi.lua +++ b/diet-sqlite/sqlite3_ffi.lua @@ -10,8 +10,7 @@ ** --]] - -local ffi = require "ffi" +local ffi = require "diet-sqlite.ffi" --[[ Created from this version: