Skip to content

Commit

Permalink
Add deprecations and set version to 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
barche committed Aug 24, 2023
1 parent d31802e commit 0de5fbc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CxxWrap"
uuid = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
authors = ["Bart Janssens <[email protected]>"]
version = "0.13.4"
version = "0.14.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down
18 changes: 17 additions & 1 deletion src/CxxWrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ function wrapfunctions(jlmod)
wrap_functions(module_functions, jlmod)
end

function readmodule(so_path::String, funcname, m::Module, flags)
Base.depwarn("Calling `@readmodule` with the path of the library to load is deprecated. Pass the name of a function returning the path instead, e.g. use `libfoo_jll.get_libfoo_path` instead of `libfoo_jll.libfoo`.", :readmodule; force=true)
readmodule(() -> so_path, funcname, m, flags)
end

function readmodule(so_path_cb::Function, funcname, m::Module, flags)
if isdefined(m, :__cxxwrap_methodkeys)
return
Expand All @@ -744,6 +749,11 @@ function readmodule(so_path_cb::Function, funcname, m::Module, flags)
include_dependency(so_path)
end

function wrapmodule(so_path::String, funcname, m::Module, flags)
Base.depwarn("Calling `@wrapmodule` with the path of the library to load is deprecated. Pass the name of a function returning the path instead, e.g. use `libfoo_jll.get_libfoo_path` instead of `libfoo_jll.libfoo`.", :wrapmodule; force=true)
wrapmodule(() -> so_path, funcname, m, flags)
end

function wrapmodule(so_path_cb::Function, funcname, m::Module, flags)
readmodule(so_path_cb, funcname, m, flags)
wraptypes(m)
Expand All @@ -756,6 +766,10 @@ end
Place the functions and types from the C++ lib into the module enclosing this macro call
Calls an entry point named `define_julia_module`, unless another name is specified as
the second argument.
`libraryfile_cb` is a
function that returns the shared library file to load as a string. In case of a JLL exporting `libfoo.so`
it is possible to use `foo_jll.get_libfoo_path()`
"""
macro wrapmodule(libraryfile_cb, register_func=:(:define_julia_module), flags=:(nothing))
return :(wrapmodule($(esc(libraryfile_cb)), $(esc(register_func)), $__module__, $(esc(flags))))
Expand All @@ -764,7 +778,9 @@ end
"""
@readmodule libraryfile_cb [functionname]
Read a C++ module and associate it with the Julia module enclosing the macro call.
Read a C++ module and associate it with the Julia module enclosing the macro call. `libraryfile_cb` is a
function that returns the shared library file to load as a string. In case of a JLL exporting `libfoo.so`
it is possible to use `foo_jll.get_libfoo_path()`
"""
macro readmodule(libraryfile_cb, register_func=:(:define_julia_module), flags=:(nothing))
return :(readmodule($(esc(libraryfile_cb)), $(esc(register_func)), $__module__, $(esc(flags))))
Expand Down

0 comments on commit 0de5fbc

Please sign in to comment.