Skip to content

Commit e7264a9

Browse files
authored
Clang.jl generated bindings and internal refactor (#296)
* Refactor 1. Use Clang.jl to generate C bindings automatically 2. Use JuliaFormatter.jl to format all the code 3. Use WeakKeyDict to record prepared statements of a DB 4. Upgrade Julia version requirement to 1.6 * Recover SQlite.isready for statemaent * Remove extra return * Bump Clang.jl version and regenerate bindings
1 parent a4e4da3 commit e7264a9

File tree

12 files changed

+3350
-1353
lines changed

12 files changed

+3350
-1353
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- '1.3'
18+
- '1.6'
1919
- '1' # automatically expands to the latest stable 1.x release of Julia
2020
- 'nightly'
2121
os:

Project.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ version = "1.4.2"
55

66
[deps]
77
DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965"
8-
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
9-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
108
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
119
SQLite_jll = "76ed43ae-9a5d-5a62-8c75-30186b810ce8"
1210
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1311
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
14-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1512
WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
1613

1714
[compat]
1815
DBInterface = "2.5"
1916
SQLite_jll = "3"
2017
Tables = "1"
2118
WeakRefStrings = "0.4,0.5,0.6,1"
22-
julia = "1.3"
19+
julia = "1.6"

gen/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
3+
SQLite_jll = "76ed43ae-9a5d-5a62-8c75-30186b810ce8"
4+
5+
[compat]
6+
Clang = "0.16"
7+
SQLite_jll = "3"

gen/generate_wrapper.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Clang.Generators
2+
using SQLite_jll
3+
4+
cd(@__DIR__)
5+
6+
include_dir = normpath(SQLite_jll.artifact_dir, "include")
7+
8+
options = load_options(joinpath(@__DIR__, "generator.toml"))
9+
10+
args = get_default_args()
11+
12+
headers = [joinpath(include_dir, "sqlite3.h")]
13+
14+
# create context
15+
ctx = create_context(headers, args, options)
16+
17+
# run generator
18+
build!(ctx)

gen/generator.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[general]
2+
library_name = "libsqlite"
3+
output_file_path = "../src/capi.jl"
4+
module_name = "C"
5+
jll_pkg_name = "SQLite_jll"
6+
print_using_CEnum = false
7+
output_ignorelist = [
8+
"SQLITE_STDCALL"
9+
]
10+
11+
[codegen]
12+
use_julia_bool = true
13+
use_ccall_macro = true
14+
opaque_func_arg_as_PtrCvoid = true

0 commit comments

Comments
 (0)