Skip to content

Commit

Permalink
Add generator files. Wrap latest 1.9 release. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion authored Oct 15, 2023
1 parent dfb262a commit 418d2f3
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 208 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LibSpatialIndex"
uuid = "f19c2e90-9d16-5f2d-a2a7-af3fb29e4907"
license = "MIT"
version = "0.2.0"
version = "0.2.1"

[deps]
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
Expand All @@ -10,7 +10,7 @@ LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"
[compat]
Aqua = "0.7"
GeoInterface = "1"
LibSpatialIndex_jll = "1.8"
LibSpatialIndex_jll = "1.9"
julia = "1.6"

[extras]
Expand Down
3 changes: 3 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"
6 changes: 6 additions & 0 deletions gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LibSpatialIndex.jl generation documentation
================================

### Run the wrapping scripts
1. Run `julia --project` in this directory and `pkg> instantiate` the dependencies.
2. Run `include("generator.jl")` to generate the wrapping.
24 changes: 24 additions & 0 deletions gen/generator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Clang
using Clang.Generators
using LibSpatialIndex_jll

# several functions for building docstrings
includedir = joinpath(LibSpatialIndex_jll.artifact_dir, "include/spatialindex/capi")
headerfiles = joinpath.(includedir, ["sidx_api.h", "sidx_config.h"])
for headerfile in headerfiles
if !isfile(headerfile)
error("Header file missing `($headerfile)")
end
end

options = load_options(joinpath(@__DIR__, "generator.toml"))

# add compiler flags, e.g. "-DXXXXXXXXX"
args = get_default_args()
push!(args, "-I$includedir")

# create context
ctx = create_context(headerfiles, args, options)

# run generator
build!(ctx)
29 changes: 29 additions & 0 deletions gen/generator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[general]
library_name = "libspatialindex_c"
output_api_file_path = "../src/include/sidx_api.jl"
output_common_file_path = "../src/include/sidx_config.jl"
print_using_CEnum = true
use_julia_native_enum_type = true
output_ignorelist = ["SIDX_C_API", "SIDX_THREAD", "STRDUP"]
use_deterministic_symbol = true
smart_de_anonymize = true
extract_c_comment_style = "doxygen"
fold_single_line_comment = true
struct_field_comment_style = "outofline"
enumerator_comment_style = "outofline"
show_c_function_prototype = false

[codegen]
use_ccall_macro = true
is_function_strictly_typed = false
use_julia_bool = true
always_NUL_terminated_string = true
opaque_func_arg_as_PtrCvoid = false
opaque_as_mutable_struct = false

[codegen.macro]
macro_mode = "basic"
add_comment_for_skipped_macro = true
ignore_header_guards = true
ignore_header_guards_with_suffixes = []
ignore_pure_definition = true
409 changes: 211 additions & 198 deletions src/include/sidx_api.jl

Large diffs are not rendered by default.

49 changes: 41 additions & 8 deletions src/include/sidx_config.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
@enum RTError::Int32 RT_None = 0 RT_Debug = 1 RT_Warning = 2 RT_Failure = 3 RT_Fatal = 4
@enum RTIndexType::Int32 RT_RTree = 0 RT_MVRTree = 1 RT_TPRTree = 2 RT_InvalidIndexType = -99
@enum RTStorageType::Int32 RT_Memory = 0 RT_Disk = 1 RT_Custom = 2 RT_InvalidStorageType = -99
@enum RTIndexVariant::Int32 RT_Linear = 0 RT_Quadratic = 1 RT_Star = 2 RT_InvalidIndexVariant = -99

IndexH = Ptr{Nothing}
IndexItemH = Ptr{Nothing}
IndexPropertyH = Ptr{Nothing}
const Tools_PropertySet = Cvoid

const IndexPropertyH = Ptr{Tools_PropertySet}

const IndexS = Cvoid

const IndexH = Ptr{IndexS}

@enum RTError::UInt32 begin
RT_None = 0
RT_Debug = 1
RT_Warning = 2
RT_Failure = 3
RT_Fatal = 4
end

const SpatialIndex_IData = Cvoid

const IndexItemH = Ptr{SpatialIndex_IData}

@enum RTIndexType::Int32 begin
RT_RTree = 0
RT_MVRTree = 1
RT_TPRTree = 2
RT_InvalidIndexType = -99
end

@enum RTIndexVariant::Int32 begin
RT_Linear = 0
RT_Quadratic = 1
RT_Star = 2
RT_InvalidIndexVariant = -99
end

@enum RTStorageType::Int32 begin
RT_Memory = 0
RT_Disk = 1
RT_Custom = 2
RT_InvalidStorageType = -99
end

2 comments on commit 418d2f3

@evetion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115500

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 418d2f32ee764014b60ca5639906e2f3f77d3b31
git push origin v0.2.1

Please sign in to comment.