Skip to content

Commit

Permalink
update auto-generated code to GLib 2.76 and GTK 4.10 (#39)
Browse files Browse the repository at this point in the history
The sporadic segfaults that have been happening lately appear to involve dialogs being finalized after their parent window. Running garbage collection so that the dialog is finalized before the window prevents the crash for me locally. This does not solve the underlying issue, which seems like some reference counting bug, since it seems like GtkDialog should hold a reference to the window that would prevent it from being destroyed too early. Are we unreferencing it too many times?

Also remove docstrings pulled from XML.
  • Loading branch information
jwahlstrand authored Sep 9, 2023
1 parent d624598 commit 3dd0f52
Show file tree
Hide file tree
Showing 31 changed files with 3,038 additions and 1,294 deletions.
30 changes: 26 additions & 4 deletions GI/src/gidocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ end

function doc_add_link(docstring, l)
# FIXME: should escape the string in the square brackets because the underscores mess up the markdown formatting
"$docstring\n \nDetails can be found in the [GTK docs]($l)."
if docstring != ""
dc = "$docstring\n \n"
else
dc = ""
end
dc*"See the [GTK docs]($l)."
end

_name_match(n, name)=n["name"]==String(name)
Expand Down Expand Up @@ -49,44 +54,61 @@ for (item, xmlitem) in [
end
end

function append_const_docs!(exprs, ns, d, c)
# Pulling the docstrings from the XML is disabled by default due to licensing concerns.

function append_const_docs!(exprs, ns, d, c; incl_text=false)
for x in c
dc = GI.doc_const(d,x)
if dc !== nothing
if !incl_text
dc = ""
end
dc = GI.doc_const_add_link(dc, x, ns)
GI.append_doc!(exprs, dc, x)
end
end
for x in c
dc = GI.doc_enum(d,x)
if dc !== nothing
if !incl_text
dc = ""
end
dc = GI.doc_enum_add_link(dc, x, ns)
GI.append_doc!(exprs, dc, x)
end
end
for x in c
dc = GI.doc_flags(d,x)
if dc !== nothing
if !incl_text
dc = ""
end
dc = GI.doc_flags_add_link(dc, x, ns)
GI.append_doc!(exprs, dc, x)
end
end
end

function append_struc_docs!(exprs, ns, d, c, gins)
function append_struc_docs!(exprs, ns, d, c, gins; incl_text=false)
for x in c
dc = GI.doc_struc(d,x)
if dc !== nothing
if !incl_text
dc = ""
end
dc = GI.doc_struc_add_link(dc, x, ns)
GI.append_doc!(exprs, dc, get_full_name(gins[x]))
end
end
end

function append_object_docs!(exprs, ns, d, c, gins)
function append_object_docs!(exprs, ns, d, c, gins; incl_text=false)
for x in c
dc = GI.doc_object(d,x)
if dc !== nothing
if !incl_text
dc = ""
end
dc = GI.doc_object_add_link(dc, x, ns)
GI.append_doc!(exprs, dc, get_full_name(gins[x]))
end
Expand Down
44 changes: 22 additions & 22 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function struct_cache_expr!(exprs)
push!(exprs,unblock(gboxed_types_list))
end

function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,excludelist=[],constructor_skiplist=[],import_as_opaque=[],output_cache_init=true,only_opaque=false)
function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,excludelist=[],constructor_skiplist=[],import_as_opaque=[],output_cache_init=true,only_opaque=false,exclude_deprecated=true)
struct_skiplist=excludelist

if structs === nothing
s=get_all(ns,GIStructInfo)
s=get_all(ns,GIStructInfo,exclude_deprecated)
structinfos=filter(p->(get_name(p),struct_skiplist),s)
structs = get_name.(structinfos)
end
Expand Down Expand Up @@ -95,7 +95,7 @@ function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,exclu

for ss in structs
ssi=gi_find_by_name(ns,ss)
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist)
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist, exclude_deprecated=exclude_deprecated)
if !isempty(constructors)
append!(exprs,constructors)
end
Expand All @@ -108,11 +108,11 @@ function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,exclu
struct_skiplist
end

function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],constructor_skiplist=[],import_as_opaque=Symbol[],output_cache_init=true,only_opaque=false)
function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],constructor_skiplist=[],import_as_opaque=Symbol[],output_cache_init=true,only_opaque=false,exclude_deprecated=true)
struct_skiplist=excludelist
loaded=Symbol[]

s=get_all(ns,GIStructInfo)
s=get_all(ns,GIStructInfo,exclude_deprecated)
ss=filter(p->(get_name(p),struct_skiplist),s)
imported=length(ss)
for ssi in ss
Expand Down Expand Up @@ -148,7 +148,7 @@ function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],co


for ssi in ss
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist)
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist, exclude_deprecated=exclude_deprecated)
isempty(constructors) || append!(exprs,constructors)
end

Expand Down Expand Up @@ -176,8 +176,8 @@ function all_callbacks!(exprs, exports, ns)
nothing
end

function all_struct_methods!(exprs,ns;print_summary=true,print_detailed=false,skiplist=Symbol[], struct_skiplist=Symbol[], liboverride=nothing)
structs=get_structs(ns)
function all_struct_methods!(exprs,ns;print_summary=true,print_detailed=false,skiplist=Symbol[], struct_skiplist=Symbol[], liboverride=nothing,exclude_deprecated=true)
structs=get_structs(ns,exclude_deprecated)
handled_symbols=Symbol[]

not_implemented=0
Expand All @@ -199,7 +199,7 @@ function all_struct_methods!(exprs,ns;print_summary=true,print_detailed=false,sk
if get_flags(m) & (GIFunction.IS_CONSTRUCTOR | GIFunction.IS_METHOD) == 0
continue
end
is_deprecated(m) && continue
(exclude_deprecated && is_deprecated(m)) && continue
print_detailed && println(get_name(m))
try
fun=create_method(m, liboverride)
Expand Down Expand Up @@ -229,8 +229,8 @@ function all_struct_methods!(exprs,ns;print_summary=true,print_detailed=false,sk
handled_symbols
end

function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skiplist=Symbol[],constructor_skiplist=[],output_cache_define=true,output_cache_init=true)
objects=get_all(ns,GIObjectInfo)
function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skiplist=Symbol[],constructor_skiplist=[],output_cache_define=true,output_cache_init=true, exclude_deprecated=true)
objects=get_all(ns,GIObjectInfo,exclude_deprecated)

imported=length(objects)
loaded=Symbol[]
Expand Down Expand Up @@ -270,7 +270,7 @@ function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skipl
end
for o in objects
in(get_name(o), skiplist) && continue
constructors = get_constructors(o;skiplist=constructor_skiplist, struct_skiplist=skiplist)
constructors = get_constructors(o;skiplist=constructor_skiplist, struct_skiplist=skiplist, exclude_deprecated=exclude_deprecated)
isempty(constructors) || append!(exprs,constructors)
end
if print_summary
Expand All @@ -279,11 +279,11 @@ function all_objects!(exprs,exports,ns;print_summary=true,handled=Symbol[],skipl
loaded
end

function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[], liboverride=nothing)
function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[], liboverride=nothing, exclude_deprecated=true)
not_implemented=0
skipped=0
created=0
objects=get_all(ns,GIObjectInfo)
objects=get_all(ns,GIObjectInfo,exclude_deprecated)
for o in objects
name=get_name(o)
methods=get_methods(o)
Expand All @@ -296,7 +296,7 @@ function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[]
skipped+=1
continue
end
is_deprecated(m) && continue
(exclude_deprecated && is_deprecated(m)) && continue
try
fun=create_method(m, liboverride)
push!(exprs, fun)
Expand All @@ -314,8 +314,8 @@ function all_object_methods!(exprs,ns;skiplist=Symbol[],object_skiplist=Symbol[]
end
end

function all_interfaces!(exprs,exports,ns;print_summary=true,skiplist=Symbol[])
interfaces=get_all(ns,GIInterfaceInfo)
function all_interfaces!(exprs,exports,ns;print_summary=true,skiplist=Symbol[],exclude_deprecated=true)
interfaces=get_all(ns,GIInterfaceInfo,exclude_deprecated)

imported=length(interfaces)
for i in interfaces
Expand All @@ -337,11 +337,11 @@ function all_interfaces!(exprs,exports,ns;print_summary=true,skiplist=Symbol[])
skiplist
end

function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Symbol[], liboverride=nothing)
function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Symbol[], liboverride=nothing,exclude_deprecated=true)
not_implemented=0
skipped=0
created=0
interfaces=get_all(ns,GIInterfaceInfo)
interfaces=get_all(ns,GIInterfaceInfo,exclude_deprecated)
for i in interfaces
name=get_name(i)
methods=get_methods(i)
Expand All @@ -354,7 +354,7 @@ function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Sy
skipped+=1
continue
end
is_deprecated(m) && continue
(exclude_deprecated && is_deprecated(m)) && continue
try
fun=create_method(m, liboverride)
push!(exprs, fun)
Expand All @@ -371,11 +371,11 @@ function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Sy
end
end

function all_functions!(exprs,ns;print_summary=true,skiplist=Symbol[],symbol_skiplist=Symbol[], liboverride=nothing)
function all_functions!(exprs,ns;print_summary=true,skiplist=Symbol[],symbol_skiplist=Symbol[], liboverride=nothing,exclude_deprecated=true)
j=0
skipped=0
not_implemented=0
for i in get_all(ns,GIFunctionInfo)
for i in get_all(ns,GIFunctionInfo,exclude_deprecated)
if in(get_name(i),skiplist) || occursin("cclosure",string(get_name(i)))
skipped+=1
continue
Expand Down
24 changes: 14 additions & 10 deletions GI/src/giimport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,16 @@ function decl(interfaceinfo::GIInterfaceInfo)
end

function get_closure(callbackinfo::GICallbackInfo)
closure = -1
for arg in get_args(callbackinfo)
if get_closure(arg) > -1
closure = get_closure(arg)
end
args = get_args(callbackinfo)
if length(args) == 0
return -1
end
# this seems very wrong, but they removed the "closure" annotation for callbacks with gobject-introspection 1.76
if endswith(string(get_name(args[end])),"data") == true
return length(args)-1
else
return -1
end
return closure
end

## Callback output
Expand Down Expand Up @@ -660,8 +663,9 @@ function convert_to_c(name::Symbol, info::GIArgInfo, ti::TypeDesc{T}) where {T<:
retctyp=extract_type(rettyp).ctype
# get arg types
argctypes_arr=[]
for (i,arg) in enumerate(get_args(callbackinfo))
if i-1 == cclosure
args = get_args(callbackinfo)
for (i,arg) in enumerate(args)
if i == length(args) # we already know there is a closure, and it has to be the last argument
push!(argctypes_arr,:(Ref{Function}))
else
argtyp=get_type(arg)
Expand Down Expand Up @@ -906,7 +910,7 @@ function make_ccall(libs::AbstractArray, id, rtype, args)
make_ccall(slib, id, rtype, args)
end

function get_constructors(info::Union{GIStructInfo,GIObjectInfo};skiplist=Symbol[],struct_skiplist=Symbol[])
function get_constructors(info::Union{GIStructInfo,GIObjectInfo};skiplist=Symbol[],struct_skiplist=Symbol[],exclude_deprecated=true)
methods=get_methods(info)
name=get_name(info)
nsstring=get_namespace(info)
Expand All @@ -916,7 +920,7 @@ function get_constructors(info::Union{GIStructInfo,GIObjectInfo};skiplist=Symbol
gskiplist=[Symbol(nsstring,i) for i in struct_skiplist]
ugskiplist=[Symbol("_",nsstring,i) for i in struct_skiplist]
for minfo in methods
if is_deprecated(minfo) || get_name(minfo) in skiplist
if (exclude_deprecated && is_deprecated(minfo)) || get_name(minfo) in skiplist
continue
end
if get_flags(minfo) & GIFunction.IS_CONSTRUCTOR != 0
Expand Down
2 changes: 1 addition & 1 deletion gen/gen_gdk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ toplevel, exprs, exports = GI.output_exprs()

# These are marked as "disguised" and what this means is not documented AFAICT.
disguised = Symbol[]
struct_skiplist=vcat(disguised, [:ToplevelSize])
struct_skiplist=vcat(disguised, [:ToplevelSize,:TextureDownloader])

GI.struct_cache_expr!(exprs)
struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist,import_as_opaque=[:TimeCoord])
Expand Down
13 changes: 8 additions & 5 deletions gen/gen_gio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ toplevel, exprs, exports = GI.output_exprs()
disguised = GI.read_disguised(d)
struct_skiplist=vcat(disguised, [:ActionEntry,:DBusAnnotationInfo,:DBusArgInfo,:DBusInterfaceInfo,
:DBusInterfaceVTable,:DBusMethodInfo,:DBusPropertyInfo,:DBusSignalInfo,:DBusSubtreeVTable,
:DBusNodeInfo,:InputMessage,:OutputMessage,:StaticResource,:UnixMountEntry,:UnixMountPoint])
:DBusNodeInfo,:InputMessage,:OutputMessage,:StaticResource,:UnixMountEntry,:UnixMountPoint,
:XdpDocumentsProxy,:XdpDocumentsSkeleton,:XdpOpenURISkeleton,:XdpDocumentsProxyClass,
:XdpDocumentsSkeletonClass,:XdpOpenURIProxy,:XdpOpenURIProxyClass,:XdpOpenURISkeletonClass,
:XdpProxyResolverProxy,:XdpProxyResolverProxyClass,:XdpProxyResolverSkeleton,:XdpProxyResolverSkeletonClass,:XdpTrashProxy,:XdpTrashProxyClass,:XdpTrashSkeleton,:XdpTrashSkeletonClass,:_FreedesktopDBusProxyClass,:_FreedesktopDBusSkeletonClass])

struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist,output_cache_init=false)
GI.append_struc_docs!(exprs, "gio", d, c, ns)

## objects

obj_skiplist=[:UnixMountMonitor,:UnixOutputStream,:UnixInputStream,:UnixFDList,:UnixFDMessage,:UnixSocketAddress,:DebugControllerDBus]
GI.all_interfaces!(exprs,exports,ns;skiplist=[])
GI.all_interfaces!(exprs,exports,ns;skiplist=[:XdpProxyResolverIface])
c = GI.all_objects!(exprs,exports,ns;skiplist=obj_skiplist,constructor_skiplist=[:new_for_bus_sync,:new_sync,:new_with_fd_list,:new_for_address_finish,:new_for_bus_finish,:new_for_bus_finish,:new_from_filename,:new_loopback,:new_section,:new_with_default_fallbacks,:new_from_file_with_password],output_cache_define=false,output_cache_init=false)
GI.append_object_docs!(exprs, "gio", d, c, ns)
GI.all_callbacks!(exprs, exports, ns)
Expand All @@ -43,13 +46,13 @@ GI.all_struct_methods!(exprs,ns,struct_skiplist=struct_skiplist)

skiplist=[:new_for_bus,:export,:add_option_group,:make_pollfd,:get_info,
:new_for_bus_sync,:new_sync,:writev,:writev_all,:flatten_tree,:changed_tree,:receive_messages,:send_message,:send_message_with_timeout,:send_messages,
:get_channel_binding_data,:lookup_certificates_issued_by,:get_default,:get_unix_fd_list,:set_unix_fd_list]
:get_channel_binding_data,:lookup_certificates_issued_by,:get_default,:get_unix_fd_list,:set_unix_fd_list,:get_attribute_file_path,:set_attribute_file_path,:get_timeout,:set_timeout]

# skips are to avoid method name collisions
GI.all_object_methods!(exprs,ns;skiplist=skiplist,object_skiplist=vcat(obj_skiplist,[:AppInfoMonitor,:DBusConnection,:DBusMenuModel,:DBusProxy,:DBusMethodInvocation,:IOModule,:SimpleProxyResolver,:UnixMountMonitor,:Task]))

skiplist=[:add_action_entries,:get_info,:receive_messages,:send_messages,
:writev_nonblocking,:dup_default]
:writev_nonblocking,:dup_default,:remove_action_entries,:new_build_filenamev]
# skips are to avoid method name collisions
GI.all_interface_methods!(exprs,ns;skiplist=skiplist,interface_skiplist=[:App,:AppInfo,:DBusObjectManager,:Drive,:Icon,:Mount,:NetworkMonitor,:PollableOutputStream,:ProxyResolver,:SocketConnectable,:TlsBackend,:TlsClientConnection,:Volume,:DtlsServerConnection])

Expand All @@ -62,7 +65,7 @@ toplevel, exprs, exports = GI.output_exprs()
skiplist=[:bus_own_name_on_connection,:bus_own_name,:bus_watch_name_on_connection,:bus_watch_name,:dbus_annotation_info_lookup,:dbus_error_encode_gerror,:dbus_error_get_remote_error,:dbus_error_is_remote_error,:dbus_error_new_for_dbus_error,
:dbus_error_strip_remote_error,:dbus_error_register_error_domain,:io_modules_load_all_in_directory_with_scope,:io_modules_scan_all_in_directory_with_scope,:dbus_gvariant_to_gvalue,:unix_mount_at,:unix_mount_copy,:unix_mount_compare,:unix_mount_for,:unix_mount_free,
:unix_mount_get_device_path,:unix_mount_get_fs_type,:unix_mount_get_mount_path,:unix_mount_get_options,:unix_mount_get_root_path,:unix_mount_guess_can_eject,:unix_mount_guess_icon,:unix_mount_guess_name,:unix_mount_guess_should_display,:unix_mount_guess_symbolic_icon,
:unix_mount_is_readonly,:unix_mount_is_system_internal,:unix_mount_point_at,:unix_mount_points_changed_since,:unix_mount_points_get,:unix_mounts_get]
:unix_mount_is_readonly,:unix_mount_is_system_internal,:unix_mount_point_at,:unix_mount_points_changed_since,:unix_mount_points_get,:unix_mounts_get,:file_new_build_filenamev]

GI.all_functions!(exprs,ns,skiplist=skiplist)

Expand Down
2 changes: 1 addition & 1 deletion gen/gen_glib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import_as_opaque = [:Date,:Source]
# These include callbacks or are otherwise currently problematic
struct_skiplist=vcat(disguised, special, [:Cond,:HashTableIter,:Hook,
:HookList,:IOChannel,:IOFuncs,
:MarkupParser,:MemVTable,:Node,:Once,:OptionGroup,:PollFD,:Private,:Queue,:RWLock,
:MarkupParser,:MemVTable,:Node,:Once,:OptionGroup,:PathBuf,:PollFD,:Private,:Queue,:RWLock,
:RecMutex,:Scanner,
:TestLogBuffer,:TestLogMsg,:Thread,:ThreadPool,:Tree,:UriParamsIter])

Expand Down
Loading

0 comments on commit 3dd0f52

Please sign in to comment.