Skip to content

Commit

Permalink
GI: clean up struct/object/interface generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Apr 1, 2024
1 parent acfdabc commit 9c4c420
Show file tree
Hide file tree
Showing 19 changed files with 749 additions and 868 deletions.
32 changes: 32 additions & 0 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,38 @@ function all_callbacks!(exprs, exports, ns)
nothing
end

function export_struct_exprs!(ns,path,prefix, struct_skiplist, import_as_opaque; doc_xml = nothing, doc_prefix = prefix, constructor_skiplist = [], first_list = [], output_boxed_cache_init = true, output_object_cache_init = true, output_object_cache_define = true, object_skiplist = [], object_constructor_skiplist = [], interface_skiplist = [], signal_skiplist = [], expr_init = nothing, output_gtype_wrapper_cache_def = false, output_boxed_types_def = true, output_callbacks = true, exclude_deprecated = true, doc_skiplist = [])
toplevel, exprs, exports = GI.output_exprs()

if output_boxed_types_def
struct_cache_expr!(exprs)
end

if !isempty(first_list)
GI.struct_exprs!(exprs,exports,ns,first_list)
struct_skiplist = vcat(struct_skiplist,first_list)
end
struct_skiplist, c = all_struct_exprs!(exprs,exports,ns;constructor_skiplist=constructor_skiplist,excludelist=struct_skiplist,import_as_opaque=import_as_opaque, output_cache_init = output_boxed_cache_init, exclude_deprecated=exclude_deprecated)
if doc_xml !== nothing
append_struc_docs!(exprs, doc_prefix, doc_xml, c, ns)
end
all_interfaces!(exprs,exports,ns; skiplist = interface_skiplist, exclude_deprecated = exclude_deprecated)
c = all_objects!(exprs,exports,ns;handled=[:Object],skiplist=object_skiplist,output_cache_init = output_object_cache_init, output_cache_define = output_object_cache_define, constructor_skiplist = object_constructor_skiplist,exclude_deprecated=exclude_deprecated)
if doc_xml !== nothing
append_object_docs!(exprs, doc_prefix, doc_xml, c, ns; skiplist = doc_skiplist)
end
if expr_init !== nothing
push!(exprs,expr_init)
end
all_object_signals!(exprs, ns;skiplist=signal_skiplist,object_skiplist=object_skiplist, exclude_deprecated = exclude_deprecated)
if output_callbacks
all_callbacks!(exprs, exports, ns)
end
push!(exprs,exports)
write_to_file(path,"$(prefix)_structs",toplevel)
struct_skiplist
end

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[]
Expand Down
12 changes: 1 addition & 11 deletions gen/gen_cairo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ ns = GINamespace(:cairo,"1.0")
path="../src/gen"

GI.export_consts!(ns, path, "cairo"; doc_xml = d, export_constants = false)

## structs

toplevel, exprs, exports = GI.output_exprs()

struct_skiplist=Symbol[]
GI.struct_cache_expr!(exprs)
struct_skiplist = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist)
push!(exprs,exports)

GI.write_to_file(path,"cairo_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "cairo", struct_skiplist, [])

## functions

Expand Down
16 changes: 1 addition & 15 deletions gen/gen_gdk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,9 @@ toplevel, exprs, exports = GI.output_exprs()
disguised = Symbol[]
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])
GI.append_struc_docs!(exprs, "gdk4", d, c, ns)

## objects

object_skiplist=Symbol[]

c = GI.all_objects!(exprs,exports,ns,skiplist=object_skiplist;print_summary=true,constructor_skiplist=[:new_from_resource])
GI.append_object_docs!(exprs, "gdk4", d, c, ns)
GI.all_interfaces!(exprs,exports,ns)
GI.all_callbacks!(exprs, exports, ns)
GI.all_object_signals!(exprs,ns;skiplist=skiplist,object_skiplist=object_skiplist)

push!(exprs,exports)

GI.write_to_file(path,"gdk4_structs",toplevel)
GI.export_struct_exprs!(ns,path, "gdk4", struct_skiplist, [:TimeCoord]; object_constructor_skiplist=[:new_from_resource],doc_xml = d)

## struct methods

Expand Down
20 changes: 2 additions & 18 deletions gen/gen_gdkpixbuf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@ GI.export_consts!(ns, path, "gdkpixbuf", [:PixbufFormatFlags]; doc_prefix = "gdk

## structs

toplevel, exprs, exports = GI.output_exprs()

disguised = GI.read_disguised(d)
struct_skiplist=vcat(disguised,[:PixbufModule])

first_list=[:PixbufModulePattern]

GI.struct_cache_expr!(exprs)
GI.struct_exprs!(exprs,exports,ns,first_list;excludelist=struct_skiplist)

struct_skiplist=vcat(first_list,struct_skiplist)

struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist)
GI.append_struc_docs!(exprs, "gdk-pixbuf", d, c, ns)

## objects

c = GI.all_objects!(exprs,exports,ns;constructor_skiplist=[:new_from_resource,:new_with_mime_type,:new_from_resource_at_scale])
GI.append_object_docs!(exprs, "gdk-pixbuf", d, c, ns)
GI.all_callbacks!(exprs, exports, ns)
GI.all_object_signals!(exprs,ns)
push!(exprs,exports)
obj_constructor_skiplist=[:new_from_resource,:new_with_mime_type,:new_from_resource_at_scale]

GI.write_to_file(path,"gdkpixbuf_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "gdkpixbuf", struct_skiplist, []; doc_xml = d, expr_init = :(gboxed_types = Any[]), object_skiplist = obj_skiplist, object_constructor_skiplist = obj_constructor_skiplist, interface_skiplist = [:XdpProxyResolverIface], first_list = first_list, doc_prefix = "gdk-pixbuf")

## struct methods

Expand Down
16 changes: 4 additions & 12 deletions gen/gen_gio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ d = GI.read_gir(gobject_introspection_jll, ns)

## structs

toplevel, exprs, exports = GI.output_exprs()

disguised = GI.read_disguised(d)
struct_skiplist=vcat(disguised, [:ActionEntry,:DBusAnnotationInfo,:DBusArgInfo,:DBusInterfaceInfo,
:DBusInterfaceVTable,:DBusMethodInfo,:DBusPropertyInfo,:DBusSignalInfo,:DBusSubtreeVTable,
Expand All @@ -21,21 +19,15 @@ struct_skiplist=vcat(disguised, [:ActionEntry,:DBusAnnotationInfo,:DBusArgInfo,:
: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=[: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)
GI.all_object_signals!(exprs,ns;object_skiplist=vcat(obj_skiplist,[:AppInfoMonitor,:DBusConnection,:DBusMenuModel,:DBusProxy,:DBusMethodInvocation,:IOModule,:SimpleProxyResolver,:UnixMountMonitor,:Task]))

push!(exprs,exports)
obj_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]

#GI.all_object_signals!(exprs,ns;object_skiplist=vcat(obj_skiplist,[:AppInfoMonitor,:DBusConnection,:DBusMenuModel,:DBusProxy,:DBusMethodInvocation,:IOModule,:SimpleProxyResolver,:UnixMountMonitor,:Task]))

GI.write_to_file(path,"gio_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "gio", struct_skiplist, import_as_opaque; doc_xml = d, output_boxed_cache_init = false, output_object_cache_init = false, object_skiplist = obj_skiplist, object_constructor_skiplist = obj_constructor_skiplist, interface_skiplist = [:XdpProxyResolverIface], output_object_cache_define = false, output_boxed_types_def = false)

## struct methods

Expand Down
9 changes: 1 addition & 8 deletions gen/gen_glib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ printstyled("Generating code for GLib\n";bold=true)

## structs

toplevel, exprs, exports = GI.output_exprs()

# Some structs are marked as "disguised" in the XML and what this means is not clear to me,
# but they look like they are of no use to us.
disguised = GI.read_disguised(dglib)
Expand All @@ -66,12 +64,7 @@ struct_skiplist=vcat(disguised, special, [:Cond,:HashTableIter,:Hook,

constructor_skiplist=[:new,:new_take,:new_from_unix_utc,:new_now_utc,:new_utc,:new_maybe]

_, c = GI.all_struct_exprs!(exprs,exports,ns;constructor_skiplist=constructor_skiplist,excludelist=struct_skiplist,import_as_opaque=import_as_opaque)
GI.append_struc_docs!(exprs, "glib", dglib, c, ns)
GI.all_callbacks!(exprs, exports, ns)

push!(exprs,exports)
GI.write_to_file(path,"glib_structs",toplevel)
GI.export_struct_exprs!(ns,path, "glib", struct_skiplist, import_as_opaque; doc_xml = dglib, constructor_skiplist = constructor_skiplist, output_object_cache_init = false, output_object_cache_define = false, output_boxed_types_def = false)

## struct methods

Expand Down
22 changes: 2 additions & 20 deletions gen/gen_gobject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ using GI

printstyled("Generating code for GObject\n";bold=true)

toplevel, exprs, exports = GI.output_exprs()

path="../src/gen"

ns = GINamespace(:GObject,"2.0")
Expand All @@ -20,25 +18,9 @@ struct_skiplist=vcat(disguised, special, [:CClosure,:Closure,:ClosureNotifyData,

# these struct types are members in other structs, so we export them first
first_list=[:EnumValue,:TypeClass,:TypeInterface,:FlagsValue,:TypeValueTable]
GI.struct_exprs!(exprs,exports,ns,first_list)

struct_skiplist=vcat(struct_skiplist,first_list)

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

## objects and interfaces

c = GI.all_objects!(exprs,exports,ns;handled=[:Object],skiplist=[:SignalGroup])
GI.append_object_docs!(exprs, "gobject", d, c, ns)
push!(exprs,:(gtype_wrapper_cache[:GObject] = GObjectLeaf))
GI.all_interfaces!(exprs,exports,ns)
GI.all_callbacks!(exprs, exports, ns)
GI.all_object_signals!(exprs, ns;skiplist=skiplist,object_skiplist=[:BindingGroup,:SignalGroup,:Object])

push!(exprs,exports)
expr_init = :(gtype_wrapper_cache[:GObject] = GObjectLeaf)

GI.write_to_file(path,"gobject_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "gobject", struct_skiplist, import_as_opaque; doc_xml = d, output_boxed_cache_init = false, expr_init = expr_init, object_skiplist = [:BindingGroup,:SignalGroup,:Object], first_list = first_list, output_boxed_types_def = false)

## struct methods

Expand Down
19 changes: 1 addition & 18 deletions gen/gen_graphene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,11 @@ GI.export_consts!(ns, path, "graphene"; export_constants = false)

## structs

toplevel, exprs, exports = GI.output_exprs()

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

first_list=[:Simd4F,:Vec3,:Simd4X4F,:Size]
GI.struct_cache_expr!(exprs)
GI.struct_exprs!(exprs,exports,ns,first_list)

struct_skiplist=vcat(struct_skiplist,first_list)

struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist,import_as_opaque=[:Frustum,:Quad])

## objects

GI.all_objects!(exprs,exports,ns)
GI.all_interfaces!(exprs,exports,ns)

push!(exprs,exports)

GI.write_to_file(path,"graphene_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "graphene", struct_skiplist, [:Frustum,:Quad]; first_list = first_list)

## struct methods

Expand Down
19 changes: 1 addition & 18 deletions gen/gen_gsk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,11 @@ d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")

GI.export_consts!(ns, path, "gsk4"; doc_xml = d, export_constants = false)

## structs

toplevel, exprs, exports = GI.output_exprs()

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

GI.struct_cache_expr!(exprs)
struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist,import_as_opaque=[:RoundedRect],output_cache_init=false)
GI.append_struc_docs!(exprs, "gsk4", d, c, ns)

## objects

c = GI.all_objects!(exprs,exports,ns,output_cache_define=false,output_cache_init=false)
GI.append_object_docs!(exprs, "gsk4", d, c, ns)
GI.all_interfaces!(exprs,exports,ns)
GI.all_object_signals!(exprs,ns)

push!(exprs,exports)

GI.write_to_file(path,"gsk4_structs",toplevel)
GI.export_struct_exprs!(ns,path, "gsk4", struct_skiplist, [:RoundedRect]; doc_xml = d, output_boxed_cache_init = false, output_object_cache_define = false, output_object_cache_init = false, output_callbacks = false)

# struct methods

Expand Down
22 changes: 2 additions & 20 deletions gen/gen_gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,14 @@ d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")

GI.export_consts!(ns, path, "gtk4", [:CssParserError,:CssParserWarning]; doc_xml = d)

## structs

toplevel, exprs, exports = GI.output_exprs()

# These are marked as "disguised" and what this means is not documentated AFAICT.
disguised = Symbol[]
struct_skiplist=vcat(disguised, [:PageRange,:TreeRowReference])
constructor_skiplist=[:new_first]

GI.struct_cache_expr!(exprs)
struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=struct_skiplist,constructor_skiplist=constructor_skiplist,import_as_opaque=[:BitsetIter,:BuildableParser],output_cache_init=false, exclude_deprecated=false)
GI.append_struc_docs!(exprs, "gtk4", d, c, ns)

## objects

object_skiplist=[:CClosureExpression,:ClosureExpression,:ParamSpecExpression,:PrintUnixDialog,:PageSetupUnixDialog]
obj_constructor_skiplist=[:new_from_resource,:new_with_mnemonic,:new_with_text,:new_with_entry,:new_with_model_and_entry,:new_for_resource,:new_from_icon_name]

GI.all_interfaces!(exprs,exports,ns;exclude_deprecated=false)
c = GI.all_objects!(exprs,exports,ns,exclude_deprecated=false,skiplist=object_skiplist,constructor_skiplist=[:new_from_resource,:new_with_mnemonic,:new_with_text,:new_with_entry,:new_with_model_and_entry,:new_for_resource,:new_from_icon_name],output_cache_define=false,output_cache_init=false)
GI.append_object_docs!(exprs, "gtk4", d, c, ns; skiplist=[:Builder])
GI.all_callbacks!(exprs, exports, ns)
GI.all_object_signals!(exprs,ns;skiplist=skiplist,object_skiplist=object_skiplist,exclude_deprecated=false)

push!(exprs,exports)

GI.write_to_file(path,"gtk4_structs",toplevel)
GI.export_struct_exprs!(ns,path, "gtk4", struct_skiplist, [:BitsetIter,:BuildableParser]; doc_xml = d, object_skiplist = object_skiplist, constructor_skiplist = constructor_skiplist, output_boxed_cache_init = false, output_object_cache_define = false, output_object_cache_init = false, object_constructor_skiplist = obj_constructor_skiplist, doc_skiplist = [:Builder], exclude_deprecated = false)

## struct methods

Expand Down
18 changes: 2 additions & 16 deletions gen/gen_pango.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,10 @@ GI.export_consts!(ns, path, "pango"; export_constants = false)
toplevel, exprs, exports = GI.output_exprs()

first_list=[:Language,:Color,:AttrClass,:Rectangle,:FontDescription,:Attribute,:Analysis,:Item,:GlyphVisAttr,:GlyphGeometry,:GlyphInfo,:GlyphString,:GlyphItem]
GI.struct_cache_expr!(exprs)
GI.struct_exprs!(exprs,exports,ns,first_list)

struct_skiplist,c = GI.all_struct_exprs!(exprs,exports,ns;excludelist=first_list)
struct_skiplist = []

# we want the methods from first_list
struct_skiplist=Symbol[]

## objects

GI.all_objects!(exprs,exports,ns)
GI.all_interfaces!(exprs,exports,ns)
GI.all_callbacks!(exprs, exports, ns)
GI.all_object_signals!(exprs,ns)

push!(exprs,exports)

GI.write_to_file(path,"pango_structs",toplevel)
GI.export_struct_exprs!(ns,path, "pango", [], []; first_list = first_list)

## struct methods

Expand Down
7 changes: 1 addition & 6 deletions gen/gen_pangocairo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ using GI
ns = GINamespace(:PangoCairo,"1.0")
path="../src/gen"

toplevel, exprs, exports = GI.output_exprs()
GI.all_interfaces!(exprs,exports,ns)

push!(exprs,exports)

GI.write_to_file(path,"pangocairo_structs",toplevel)
struct_skiplist = GI.export_struct_exprs!(ns,path, "pangocairo", struct_skiplist, []; output_boxed_types_def = false, output_boxed_cache_init = false, output_object_cache_define = false, output_object_cache_init = false)

toplevel, exprs, exports = GI.output_exprs()

Expand Down
Loading

0 comments on commit 9c4c420

Please sign in to comment.