Skip to content

Commit 418d2f3

Browse files
authored
Add generator files. Wrap latest 1.9 release. (#24)
1 parent dfb262a commit 418d2f3

7 files changed

Lines changed: 316 additions & 208 deletions

File tree

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LibSpatialIndex"
22
uuid = "f19c2e90-9d16-5f2d-a2a7-af3fb29e4907"
33
license = "MIT"
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
@@ -10,7 +10,7 @@ LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"
1010
[compat]
1111
Aqua = "0.7"
1212
GeoInterface = "1"
13-
LibSpatialIndex_jll = "1.8"
13+
LibSpatialIndex_jll = "1.9"
1414
julia = "1.6"
1515

1616
[extras]

gen/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
3+
LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"

gen/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
LibSpatialIndex.jl generation documentation
2+
================================
3+
4+
### Run the wrapping scripts
5+
1. Run `julia --project` in this directory and `pkg> instantiate` the dependencies.
6+
2. Run `include("generator.jl")` to generate the wrapping.

gen/generator.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Clang
2+
using Clang.Generators
3+
using LibSpatialIndex_jll
4+
5+
# several functions for building docstrings
6+
includedir = joinpath(LibSpatialIndex_jll.artifact_dir, "include/spatialindex/capi")
7+
headerfiles = joinpath.(includedir, ["sidx_api.h", "sidx_config.h"])
8+
for headerfile in headerfiles
9+
if !isfile(headerfile)
10+
error("Header file missing `($headerfile)")
11+
end
12+
end
13+
14+
options = load_options(joinpath(@__DIR__, "generator.toml"))
15+
16+
# add compiler flags, e.g. "-DXXXXXXXXX"
17+
args = get_default_args()
18+
push!(args, "-I$includedir")
19+
20+
# create context
21+
ctx = create_context(headerfiles, args, options)
22+
23+
# run generator
24+
build!(ctx)

gen/generator.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[general]
2+
library_name = "libspatialindex_c"
3+
output_api_file_path = "../src/include/sidx_api.jl"
4+
output_common_file_path = "../src/include/sidx_config.jl"
5+
print_using_CEnum = true
6+
use_julia_native_enum_type = true
7+
output_ignorelist = ["SIDX_C_API", "SIDX_THREAD", "STRDUP"]
8+
use_deterministic_symbol = true
9+
smart_de_anonymize = true
10+
extract_c_comment_style = "doxygen"
11+
fold_single_line_comment = true
12+
struct_field_comment_style = "outofline"
13+
enumerator_comment_style = "outofline"
14+
show_c_function_prototype = false
15+
16+
[codegen]
17+
use_ccall_macro = true
18+
is_function_strictly_typed = false
19+
use_julia_bool = true
20+
always_NUL_terminated_string = true
21+
opaque_func_arg_as_PtrCvoid = false
22+
opaque_as_mutable_struct = false
23+
24+
[codegen.macro]
25+
macro_mode = "basic"
26+
add_comment_for_skipped_macro = true
27+
ignore_header_guards = true
28+
ignore_header_guards_with_suffixes = []
29+
ignore_pure_definition = true

src/include/sidx_api.jl

Lines changed: 211 additions & 198 deletions
Large diffs are not rendered by default.

src/include/sidx_config.jl

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
1-
@enum RTError::Int32 RT_None = 0 RT_Debug = 1 RT_Warning = 2 RT_Failure = 3 RT_Fatal = 4
2-
@enum RTIndexType::Int32 RT_RTree = 0 RT_MVRTree = 1 RT_TPRTree = 2 RT_InvalidIndexType = -99
3-
@enum RTStorageType::Int32 RT_Memory = 0 RT_Disk = 1 RT_Custom = 2 RT_InvalidStorageType = -99
4-
@enum RTIndexVariant::Int32 RT_Linear = 0 RT_Quadratic = 1 RT_Star = 2 RT_InvalidIndexVariant = -99
5-
6-
IndexH = Ptr{Nothing}
7-
IndexItemH = Ptr{Nothing}
8-
IndexPropertyH = Ptr{Nothing}
1+
const Tools_PropertySet = Cvoid
2+
3+
const IndexPropertyH = Ptr{Tools_PropertySet}
4+
5+
const IndexS = Cvoid
6+
7+
const IndexH = Ptr{IndexS}
8+
9+
@enum RTError::UInt32 begin
10+
RT_None = 0
11+
RT_Debug = 1
12+
RT_Warning = 2
13+
RT_Failure = 3
14+
RT_Fatal = 4
15+
end
16+
17+
const SpatialIndex_IData = Cvoid
18+
19+
const IndexItemH = Ptr{SpatialIndex_IData}
20+
21+
@enum RTIndexType::Int32 begin
22+
RT_RTree = 0
23+
RT_MVRTree = 1
24+
RT_TPRTree = 2
25+
RT_InvalidIndexType = -99
26+
end
27+
28+
@enum RTIndexVariant::Int32 begin
29+
RT_Linear = 0
30+
RT_Quadratic = 1
31+
RT_Star = 2
32+
RT_InvalidIndexVariant = -99
33+
end
34+
35+
@enum RTStorageType::Int32 begin
36+
RT_Memory = 0
37+
RT_Disk = 1
38+
RT_Custom = 2
39+
RT_InvalidStorageType = -99
40+
end
41+

0 commit comments

Comments
 (0)