Skip to content

Commit fadffb4

Browse files
committed
Merge branch 'main' into jw/newcanvas
2 parents daa9273 + aa66dca commit fadffb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3429
-1712
lines changed

GI/Project.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
99
Glib_jll = "7746bdde-850d-59dc-9ae8-88ece973131d"
1010
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1111
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
12-
gobject_introspection_jll = "6306888c-5478-5f78-9aeb-34cb5688c579"
1312

1413
[compat]
15-
julia = "1.6"
14+
julia = "1.10"
1615
BitFlags = "0.1.5"
1716
CEnum = "0.4, 0.5"
1817
EzXML = "1"
19-
Glib_jll = "2.74.0"
20-
Libdl = "1.6"
18+
Glib_jll = "2.82.0"
19+
Libdl = "1.10"
2120
MacroTools = "0.5"
22-
gobject_introspection_jll = "1.74"
21+

GI/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GI.jl
22
======
33

4-
Julia bindings using libgobject-introspection.
4+
Julia bindings using GObject introspection.
55

66
This builds on https://github.com/bfredl/GI.jl
77

@@ -15,7 +15,7 @@ As new functionality is added to libraries, you just have to run GI.jl again and
1515
The advantage over using Clang to generate wrappers is the fact that annotations provide important information, like whether outputs are "owned" or not, which arguments are closures or array lengths, and so on.
1616
Disadvantages: the current implementation only extracts GI information on Linux, leading to potential bugs on other platforms.
1717

18-
This package is unregistered and it only works on Linux because it uses [gobject_introspection_jll](https://github.com/JuliaPackaging/Yggdrasil/tree/master/G/gobject_introspection), which is currently only available for Linux. However, most generated code works on other platforms.
18+
This package is unregistered. It has only been tested and run on Linux. However, most generated code works on other platforms.
1919

2020
## Status
2121

GI/src/GI.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
module GI
2-
using Glib_jll, gobject_introspection_jll
2+
using Glib_jll
33
using MacroTools, CEnum, BitFlags, EzXML
44

5-
@static gobject_introspection_jll.is_available() || error("gobject_introspection_jll is not available on this platform")
6-
75
include("GLibBase/GLibBase.jl")
86

97
import .GLibBase as GLib
@@ -23,16 +21,18 @@ module GI
2321
export const_expr
2422
export extract_type
2523

26-
libgi = gobject_introspection_jll.libgirepository
27-
28-
global const libgi_version = VersionNumber(
29-
ccall((:gi_get_major_version, libgi), Cint, ()),
30-
ccall((:gi_get_minor_version, libgi), Cint, ()),
31-
ccall((:gi_get_micro_version, libgi), Cint, ()))
32-
24+
const libgi = Glib_jll.libgirepository
25+
mutable struct GIRepository
26+
handle::Ptr{GIRepository}
27+
end
3328

29+
global repo::GIRepository
3430
include("girepo.jl")
3531
include("giimport.jl")
3632
include("giexport.jl")
3733
include("gidocs.jl")
34+
35+
function __init__()
36+
global repo = GIRepository()
37+
end
3838
end

GI/src/GLibBase/GLibBase.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ export GList, _GSList, _GList
2020
const AbstractStringLike = Union{AbstractString, Symbol}
2121
bytestring(s) = String(s)
2222
bytestring(s::Symbol) = s
23-
bytestring(s::Ptr{UInt8}) = s == C_NULL ? nothing : unsafe_string(s)
23+
function bytestring(s::Union{Cstring,Ptr{UInt8}}, own::Bool=false)
24+
str=unsafe_string(s)
25+
if own
26+
g_free(s)
27+
end
28+
str
29+
end
30+
2431
# bytestring(s::Ptr{UInt8}, own::Bool=false) = unsafe_string(s)
2532

2633
g_free(p::Ptr) = ccall((:g_free, libglib), Nothing, (Ptr{Nothing},), p)

GI/src/giexport.jl

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function _enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports,
1111
end
1212
end
1313

14-
function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_typeinit=true,skiplist=Symbol[], export_constants = true)
14+
function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_typeinit=true,skiplist=Symbol[], export_constants = true, exclude_deprecated = true)
1515
loaded=Symbol[]
16-
c = get_consts(ns)
16+
c = get_consts(ns, exclude_deprecated)
1717

1818
for (name,val) in c
1919
in(name, skiplist) && continue
@@ -24,14 +24,14 @@ function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_t
2424
printstyled("Generated ",length(c)," constants\n";color=:green)
2525
end
2626

27-
es=get_all(ns,GIEnumInfo)
27+
es=get_all(ns,GIEnumInfo,exclude_deprecated)
2828
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded, export_constants)
2929

3030
if print_summary && length(es)>0
3131
printstyled("Generated ",length(es)," enums\n";color=:green)
3232
end
3333

34-
es=get_all(ns,GIFlagsInfo)
34+
es=get_all(ns,GIFlagsInfo,exclude_deprecated)
3535
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded, export_constants)
3636

3737
if print_summary && length(es)>0
@@ -40,12 +40,12 @@ function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_t
4040
loaded
4141
end
4242

43-
function export_consts!(ns,path,prefix,skiplist = Symbol[]; doc_prefix = prefix, doc_xml = nothing, export_constants = true)
43+
function export_consts!(ns,path,prefix,skiplist = Symbol[]; doc_prefix = prefix, doc_xml = nothing, export_constants = true, exclude_deprecated = true)
4444
toplevel, exprs, exports = GI.output_exprs()
4545

4646
const_mod = Expr(:block)
4747

48-
c = all_const_exprs!(const_mod, exports, ns; skiplist= skiplist, export_constants)
48+
c = all_const_exprs!(const_mod, exports, ns; skiplist= skiplist, export_constants, exclude_deprecated)
4949
if doc_xml !== nothing
5050
GI.append_const_docs!(const_mod.args, doc_prefix, doc_xml, c)
5151
end
@@ -134,13 +134,10 @@ end
134134

135135
function struct_constructor_exprs!(exprs,ns;constructor_skiplist=[], struct_skiplist=[], exclude_deprecated=true,first_list=[])
136136
s=get_non_skipped(ns,GIStructInfo,struct_skiplist,exclude_deprecated)
137-
structs = get_name.(s)
138-
for ss in vcat(first_list, structs)
137+
for ss in vcat(first_list, get_name.(s))
139138
ssi=gi_find_by_name(ns,ss)
140139
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist, exclude_deprecated=exclude_deprecated)
141-
if !isempty(constructors)
142-
append!(exprs,constructors)
143-
end
140+
append!(exprs,constructors)
144141
end
145142
end
146143

@@ -191,18 +188,17 @@ function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],co
191188
struct_skiplist, loaded
192189
end
193190

194-
function all_callbacks!(exprs, exports, ns; callback_skiplist = [])
195-
callbacks=get_all(ns,GICallbackInfo)
196-
for c in callbacks
191+
function all_callbacks!(exprs, exports, ns; callback_skiplist = [], exclude_deprecated = true)
192+
for c in get_all(ns,GICallbackInfo,exclude_deprecated)
197193
get_name(c) in callback_skiplist && continue
198194
try
199-
push!(exprs, decl(c))
200-
catch e
201-
if isa(e, NotImplementedError)
202-
continue
203-
else
204-
rethrow(e)
205-
end
195+
push!(exprs, decl(c))
196+
catch e
197+
if isa(e, NotImplementedError)
198+
continue
199+
else
200+
rethrow(e)
201+
end
206202
end
207203
push!(exports.args, get_full_name(c))
208204
end
@@ -235,7 +231,7 @@ function export_struct_exprs!(ns,path,prefix, struct_skiplist, import_as_opaque;
235231
end
236232
all_object_signals!(exprs, ns;skiplist=signal_skiplist,object_skiplist=object_skiplist, exclude_deprecated = exclude_deprecated)
237233
if output_callbacks
238-
all_callbacks!(exprs, exports, ns; callback_skiplist)
234+
all_callbacks!(exprs, exports, ns; callback_skiplist, exclude_deprecated)
239235
end
240236
push!(exprs,exports)
241237
write_to_file(path,"$(prefix)_structs",toplevel)
@@ -268,8 +264,7 @@ function all_struct_methods!(exprs,ns;print_summary=true,print_detailed=false,sk
268264
(exclude_deprecated && is_deprecated(m)) && continue
269265
print_detailed && println(get_name(m))
270266
try
271-
fun=create_method(m, liboverride)
272-
push!(exprs, fun)
267+
create_method(exprs, m, liboverride)
273268
push!(handled_symbols,get_symbol(m))
274269
created+=1
275270
catch e
@@ -314,7 +309,7 @@ function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skipl
314309
imported -= 1
315310
continue
316311
end
317-
if get_type_init(o)==:intern # GParamSpec and children output this
312+
if get_type_init_function_name(o)==:intern # GParamSpec and children output this
318313
continue
319314
end
320315
obj_decl!(exprs,o,ns,handled)
@@ -332,7 +327,7 @@ function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skipl
332327
end
333328
for o in objects
334329
constructors = get_constructors(o;skiplist=constructor_skiplist, struct_skiplist=skiplist, exclude_deprecated=exclude_deprecated)
335-
isempty(constructors) || append!(exprs,constructors)
330+
append!(exprs,constructors)
336331
end
337332
if print_summary
338333
printstyled("Created ",imported," objects out of ",length(objects),"\n";color=:green)
@@ -344,8 +339,7 @@ function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[]
344339
not_implemented=0
345340
skipped=0
346341
created=0
347-
objects=get_non_skipped(ns,GIObjectInfo,object_skiplist,exclude_deprecated)
348-
for o in objects
342+
for o in get_non_skipped(ns,GIObjectInfo,object_skiplist,exclude_deprecated)
349343
name=get_name(o)
350344
methods=get_methods(o)
351345
for m in methods
@@ -355,8 +349,7 @@ function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[]
355349
end
356350
(exclude_deprecated && is_deprecated(m)) && continue
357351
try
358-
fun=create_method(m, liboverride)
359-
push!(exprs, fun)
352+
create_method(exprs, m, liboverride)
360353
created+=1
361354
catch e
362355
if isa(e, NotImplementedError)
@@ -383,8 +376,7 @@ end
383376

384377
function all_object_signals!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[], liboverride=nothing, exclude_deprecated=true)
385378
not_implemented=0
386-
objects=get_non_skipped(ns,GIObjectInfo,object_skiplist,exclude_deprecated)
387-
for o in objects
379+
for o in get_non_skipped(ns,GIObjectInfo,object_skiplist,exclude_deprecated)
388380
signals = get_all_signals(o)
389381
for s in signals
390382
(exclude_deprecated && is_deprecated(s)) && continue
@@ -423,8 +415,7 @@ function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Sy
423415
end
424416
(exclude_deprecated && is_deprecated(m)) && continue
425417
try
426-
fun=create_method(m, liboverride)
427-
push!(exprs, fun)
418+
create_method(exprs, m, liboverride)
428419
created+=1
429420
catch e
430421
if isa(e, NotImplementedError)
@@ -462,11 +453,11 @@ function all_functions!(exprs,ns;print_summary=true,skiplist=Symbol[],symbol_ski
462453
unsupported = false # whatever we happen to unsupport
463454
for arg in get_args(i)
464455
try
465-
bt = get_base_type(get_type(arg))
456+
bt = get_base_type(get_type_info(arg))
466457
if isa(bt,Ptr{GIArrayType}) || isa(bt,Ptr{GIArrayType{3}})
467458
unsupported = true; break
468459
end
469-
if (isa(get_base_type(get_type(arg)), Nothing))
460+
if (isa(get_base_type(get_type_info(arg)), Nothing))
470461
unsupported = true; break
471462
end
472463
catch e
@@ -496,8 +487,7 @@ function all_functions!(exprs,ns;print_summary=true,skiplist=Symbol[],symbol_ski
496487
name = get_name(i)
497488
name = Symbol("$name")
498489
try
499-
fun=create_method(i, liboverride)
500-
push!(exprs, fun)
490+
create_method(exprs, i, liboverride)
501491
j+=1
502492
catch e
503493
if isa(e, NotImplementedError)

0 commit comments

Comments
 (0)