-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect handling of TypedefFunction #454
Comments
did the generator produce clang compilation errors? |
No, the generator does not run until completion. @Assert ptr_ref[] != C_NULL is triggered (Line 13 in token.jl). I tested this on Cairo_jll as well, and the same issue there. After fixing the bug, it almost works to generate working code for Cairo_jll (only small manual fixes of the generated code needed). The issue is that clang_getCursorExtent(c) does not always return what you expect. |
@stensmo is this library Linux only? I run the script and get the following compile errors:
|
still missing glib when I switched to
|
you need to config glib's include dirs so clang can find where the |
|
Still get this compile error but it's about the dependency library glib and we are only attempting to generate symbols from pango, so it probably doesn't affect the output.
These warnings means that those symbols are used in the headers of pango, but they are not a part of pango, they are actually defined in its dependencies. So, the generated code is not ready to use, you need to either manually define those symbols in Julia or export them from a wrapper package like |
Sorry for the late reply. A patched version of Clang.jl worked fine. I can submit the (super simple) patch if you want to. The patched version generated (as a test) all of the Cairo library (a small amount of code restructuring was needed, since some structs came out in the wrong order). I think Clang.jl is great, but the last bugs need to be ironed out. |
Any feedback would be highly appreciated. |
Started to use the Clang.jl generator, and at least on Windows, there are bugs in TypedefFunction (Clang.CLTypedefDecl). At line 75 in https://github.com/JuliaInterop/Clang.jl/tree/master/src/generator
/print.jl there is a call to tokenize which often fail (@Assert ptr_ref[] != C_NULL is triggered)
Tested on Windows and Julia 1.9.2.
Returning early from the method above (return on line 72), solves the issue (but does not include the typedefs defined). Uncommenting line 75-77 solves the issue for this case. Best solution is to check source_range = clang_getCursorExtent(node.cursor) and if the range is null, don't run line 75-77
Example to trigger the bug can be found below.
using Clang.Generators
using Pango_jll # replace this with your jll package
cd(@DIR)
show(Pango_jll.artifact_dir)
include_dir = normpath(Pango_jll.artifact_dir, "include/pango-1.0/")
clang_dir = joinpath(include_dir, "pango")
options = load_options(joinpath(@DIR, "generator.toml"))
# add compiler flags, e.g. "-DXXXXXXXXX"
args = get_default_args() # Note you must call this function firstly and then append your own flags
push!(args, "-I$include_dir")
headers = [joinpath(clang_dir, "pango.h")]
#headers = [joinpath(clang_dir, header) for header in readdir(clang_dir) if endswith(header, ".h")]
# there is also an experimental
detect_headers
function for auto-detecting top-level headers in the directory#headers = detect_headers(clang_dir, args)
# create context
ctx = create_context(headers, args, options)
# run generator
build!(ctx)
[general]
library_name = "Pango"
output_file_path = "./Pango.jl"
module_name = "LibPango"
jll_pkg_name = "Pango_jll"
export_symbol_prefixes = ["pango"]
The text was updated successfully, but these errors were encountered: