Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0610a69

Browse files
committed
Improve support for Julia v1.10+, drop support for Julia v1.5
1 parentbe0be8f commit0610a69

File tree

6 files changed

+43
-32
lines changed

6 files changed

+43
-32
lines changed

‎.github/workflows/CI.yml‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
fail-fast:false
1111
matrix:
1212
version:
13-
-'1.5'
1413
-'1.6'
1514
-'1.7'
1615
-'1.8'
@@ -25,10 +24,12 @@ jobs:
2524
# - windows-latest
2625
arch:
2726
-x64
28-
# - x86
29-
exclude:
30-
-os:macos-latest
31-
version:'1.5'
27+
# - aarch64
28+
# exclude:
29+
# - os: ubuntu-latest
30+
# arch: aarch64
31+
# - os: macos-latest
32+
# arch: x64
3233
steps:
3334
-uses:actions/checkout@v3
3435
-uses:julia-actions/setup-julia@latest

‎Project.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name ="CBinding"
22
uuid ="d43a6710-96b8-4a2d-833c-c424785e5374"
33
authors = ["Keith Rutkowski <keith@analytech-solutions.com>"]
4-
version ="1.0.12"
4+
version ="1.1.0"
55

66
[deps]
77
Clang_jll ="0ee61d77-7f21-5576-8119-9fcc46b10100"
@@ -12,4 +12,4 @@ Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1212
[compat]
1313
Clang_jll ="^9, ^11, ^12, ^13, ^14, ^15, ^16, ^18"
1414
Scratch ="^1"
15-
julia ="^1.5"
15+
julia ="^1.6"

‎src/CBinding.jl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ module CBinding
9292

9393
bitstype(::Type{T}; raise::Bool=true)where {T}=isbitstype(T)? T: raise?error("Failure to obtain a bits-type"):nothing
9494
bitstype(::Type{CQ}; kwargs...)where {CQ<:Cqualifier}=bitstype(unqualifiedtype(CQ); kwargs...)
95-
bitstype(::Type{CA}; kwargs...)where {T, N, CA<:Carray{T, N}}=bitstype(T; kwargs...)===nothing?nothing:Carray{bitstype(T), N,sizeof(bitstype(T))*N}
95+
bitstype(::Type{CA}; kwargs...)where {T, N, CA<:Carray{T, N}}= Carray{bitstype(T), N,sizeof(bitstype(T))*N}
9696

97-
values(::Type{CE})where {CE<:Cenum}=bitstype(CE; raise=false)===nothing? ():values(bitstype(CE))
97+
values(::Type{CE})where {CE<:Cenum}=values(bitstype(CE))
9898

99-
fields(::Type{CA})where {CA<:Caggregate}=bitstype(CA; raise=false)===nothing? ():fields(bitstype(CA))
99+
fields(::Type{CA})where {CA<:Caggregate}=isnothing(bitstype(CA; raise=false))? ():fields(bitstype(CA))
100100

101101

102102
include("longdouble.jl")

‎src/context.jl‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ end
124124

125125

126126

127-
getexprs(ctx::Context)=getexprs(ctx,clang_getTranslationUnitCursor(ctx.tu[]))
127+
getexprs(ctx::Context)=getexprs(ctx,clang_getTranslationUnitCursor(ctx.tu[]); path= CXCursor[])
128128

129129
functiongetexprs(ctx::Context, syms, blocks...)
130130
expr=filter(!isnothing,collect(blocks))
@@ -156,7 +156,7 @@ end
156156

157157

158158

159-
functiongetexprs_tu(ctx::Context, cursor::CXCursor)
159+
functiongetexprs_tu(ctx::Context, cursor::CXCursor; path::Vector{CXCursor})
160160
exprs= []
161161

162162
for childinchildren(cursor)
@@ -168,7 +168,7 @@ function getexprs_tu(ctx::Context, cursor::CXCursor)
168168
first(range).file!=header(ctx)||first(range).line> ctx.line||continue
169169
end
170170

171-
append!(exprs,filter(!isnothing,getexprs(ctx, child)))
171+
append!(exprs,filter(!isnothing,getexprs(ctx, child; path= path)))
172172
end
173173

174174
return exprs
@@ -400,7 +400,8 @@ function wrap!(ctx::Context)
400400
end
401401
close(file)
402402

403-
libclang.Clang_jll.clang()do bin
403+
withenv()do
404+
bin= libclang.Clang_jll.clang()
404405
run(`$(bin)$(ctx.args[5:7]) -w -O2 -fPIC -shared -o$(getlib(ctx).value)$(path)$(ctx.args[8:end])`)#TODO: add -rpath for all ctx.libs?
405406
end
406407
end

‎src/context_c.jl‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,15 @@ function gettype(ctx::Type{Context{:c}}, type::CXType; kwargs...)
322322
end
323323

324324

325-
326-
functiongetexprs(ctx::Context{:c}, cursor::CXCursor)
325+
functiongetexprs(ctx::Context{:c}, cursor::CXCursor; path::Vector{CXCursor})
326+
next=push!(copy(path), cursor)
327327
exprs= []
328328

329329
getblock(ctx).flags.skip&&return exprs
330330
getblock(ctx).flags.defer&&return exprs
331331

332332
if cursor.kind== CXCursor_TranslationUnit
333-
append!(exprs,getexprs_tu(ctx, cursor))
333+
append!(exprs,getexprs_tu(ctx, cursor; path= next))
334334

335335
for (_, child)in ctx.macros
336336
append!(exprs,getexprs_macro(ctx, child))
@@ -342,31 +342,39 @@ function getexprs(ctx::Context{:c}, cursor::CXCursor)
342342
CXCursor_UnionDecl,
343343
CXCursor_EnumDecl,
344344
)
345+
# anonymous opaque-type function parameters appear as type definitions twice it seems, so skip if it's the 2nd occurrence
346+
isanon=Bool(clang_Cursor_isAnonymous(cursor))
347+
if!(isanon&&length(path)>=1&& path[end].kind== CXCursor_ParmDecl)
348+
for childinchildren(cursor)
349+
if child.kindin (
350+
CXCursor_StructDecl,
351+
CXCursor_UnionDecl,
352+
CXCursor_EnumDecl,
353+
CXCursor_TypedefDecl,
354+
)
355+
append!(exprs,getexprs(ctx, child; path= next))
356+
end
357+
end
358+
359+
append!(exprs,getexprs_opaque(ctx, cursor))
360+
end
361+
elseif cursor.kind== CXCursor_VarDecl
345362
for childinchildren(cursor)
346363
if child.kindin (
347-
CXCursor_StructDecl,
348-
CXCursor_UnionDecl,
349-
CXCursor_EnumDecl,
350364
CXCursor_TypedefDecl,
351365
)
352-
append!(exprs,getexprs(ctx, child))
366+
append!(exprs,getexprs(ctx, child; path= next))
353367
end
354368
end
355369

356-
append!(exprs,getexprs_opaque(ctx, cursor))
357-
elseif cursor.kindin (
358-
CXCursor_VarDecl,
359-
CXCursor_FunctionDecl,
360-
)
370+
append!(exprs,getexprs_binding(ctx, cursor))
371+
elseif cursor.kind== CXCursor_FunctionDecl
361372
for childinchildren(cursor)
362373
if child.kindin (
363-
CXCursor_StructDecl,
364-
CXCursor_UnionDecl,
365-
CXCursor_EnumDecl,
366374
CXCursor_TypedefDecl,
367375
CXCursor_ParmDecl,
368376
)
369-
append!(exprs,getexprs(ctx, child))
377+
append!(exprs,getexprs(ctx, child; path= next))
370378
end
371379
end
372380

@@ -379,7 +387,7 @@ function getexprs(ctx::Context{:c}, cursor::CXCursor)
379387
CXCursor_EnumDecl,
380388
CXCursor_TypedefDecl,
381389
)
382-
append!(exprs,getexprs(ctx, child))
390+
append!(exprs,getexprs(ctx, child; path= next))
383391
end
384392
end
385393
elseif cursor.kind== CXCursor_InclusionDirective

‎test/layout-tests.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ function checkC(expr, val)
8585
}
8686
"""
8787

88-
return CBinding.libclang.Clang_jll.clang()do bin
88+
returnwithenv()do
89+
bin= CBinding.libclang.Clang_jll.clang()
8990
tmp=tempname()
9091
open(f->write(f, code), tmp*".c","w+")
9192
run(`gcc -Wno-overflow -Wno-constant-conversion -Wno-address-of-packed-member -std=c99 -o$(tmp)$(tmp).c`)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp