Skip to content

Commit

Permalink
fix methods that return non-opaque structs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Nov 9, 2024
1 parent 03c55fc commit de1f0f0
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 0 deletions.
1 change: 1 addition & 0 deletions GI/src/giimport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function decl(structinfo::GIStructInfo,force_opaque=false)
unsafe_convert(::Type{Ptr{$ustructname}}, box::$gstructname) = convert(Ptr{$ustructname}, box.handle)
convert(::Type{$gstructname}, p::Ptr{$ustructname}, owns = false) = $gstructname(p, owns)
const $structlike = Union{Ref{$ustructname},$gstructname}
convert(::Type{$structlike}, p, owns) = convert($gstructname, p, owns)
end
else
conv = quote
Expand Down
6 changes: 6 additions & 0 deletions src/gen/cairo_structs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ $(Expr(:toplevel, quote
cairoRectangle(p, owns)
end
const cairoRectangleLike = Union{Ref{_cairoRectangle}, cairoRectangle}
convert(::Type{cairoRectangleLike}, p, owns) = begin
convert(cairoRectangle, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -249,6 +252,9 @@ $(Expr(:toplevel, quote
cairoRectangleInt(p, owns)
end
const cairoRectangleIntLike = Union{Ref{_cairoRectangleInt}, cairoRectangleInt}
convert(::Type{cairoRectangleIntLike}, p, owns) = begin
convert(cairoRectangleInt, p, owns)
end
end
end
gboxed_cache_init() = begin
Expand Down
9 changes: 9 additions & 0 deletions src/gen/gdk4_structs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ $(Expr(:toplevel, quote
GdkKeymapKey(p, owns)
end
const GdkKeymapKeyLike = Union{Ref{_GdkKeymapKey}, GdkKeymapKey}
convert(::Type{GdkKeymapKeyLike}, p, owns) = begin
convert(GdkKeymapKey, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -206,6 +209,9 @@ $(Expr(:toplevel, quote
GdkRGBA(p, owns)
end
const GdkRGBALike = Union{Ref{_GdkRGBA}, GdkRGBA}
convert(::Type{GdkRGBALike}, p, owns) = begin
convert(GdkRGBA, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -241,6 +247,9 @@ $(Expr(:toplevel, quote
GdkRectangle(p, owns)
end
const GdkRectangleLike = Union{Ref{_GdkRectangle}, GdkRectangle}
convert(::Type{GdkRectangleLike}, p, owns) = begin
convert(GdkRectangle, p, owns)
end
end
end
begin
Expand Down
6 changes: 6 additions & 0 deletions src/gen/gdkpixbuf_structs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $(Expr(:toplevel, quote
GdkPixbufModulePattern(p, owns)
end
const GdkPixbufModulePatternLike = Union{Ref{_GdkPixbufModulePattern}, GdkPixbufModulePattern}
convert(::Type{GdkPixbufModulePatternLike}, p, owns) = begin
convert(GdkPixbufModulePattern, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -58,6 +61,9 @@ $(Expr(:toplevel, quote
GdkPixbufFormat(p, owns)
end
const GdkPixbufFormatLike = Union{Ref{_GdkPixbufFormat}, GdkPixbufFormat}
convert(::Type{GdkPixbufFormatLike}, p, owns) = begin
convert(GdkPixbufFormat, p, owns)
end
end
end
gboxed_cache_init() = begin
Expand Down
15 changes: 15 additions & 0 deletions src/gen/gio_structs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ $(Expr(:toplevel, quote
GDBusErrorEntry(p, owns)
end
const GDBusErrorEntryLike = Union{Ref{_GDBusErrorEntry}, GDBusErrorEntry}
convert(::Type{GDBusErrorEntryLike}, p, owns) = begin
convert(GDBusErrorEntry, p, owns)
end
end
end
begin
Expand All @@ -35,6 +38,9 @@ $(Expr(:toplevel, quote
GFileAttributeInfo(p, owns)
end
const GFileAttributeInfoLike = Union{Ref{_GFileAttributeInfo}, GFileAttributeInfo}
convert(::Type{GFileAttributeInfoLike}, p, owns) = begin
convert(GFileAttributeInfo, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -68,6 +74,9 @@ $(Expr(:toplevel, quote
GFileAttributeInfoList(p, owns)
end
const GFileAttributeInfoListLike = Union{Ref{_GFileAttributeInfoList}, GFileAttributeInfoList}
convert(::Type{GFileAttributeInfoListLike}, p, owns) = begin
convert(GFileAttributeInfoList, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -107,6 +116,9 @@ $(Expr(:toplevel, quote
GInputVector(p, owns)
end
const GInputVectorLike = Union{Ref{_GInputVector}, GInputVector}
convert(::Type{GInputVectorLike}, p, owns) = begin
convert(GInputVector, p, owns)
end
end
end
begin
Expand All @@ -125,6 +137,9 @@ $(Expr(:toplevel, quote
GOutputVector(p, owns)
end
const GOutputVectorLike = Union{Ref{_GOutputVector}, GOutputVector}
convert(::Type{GOutputVectorLike}, p, owns) = begin
convert(GOutputVector, p, owns)
end
end
end
begin
Expand Down
24 changes: 24 additions & 0 deletions src/gen/glib_structs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ $(Expr(:toplevel, quote
GDebugKey(p, owns)
end
const GDebugKeyLike = Union{Ref{_GDebugKey}, GDebugKey}
convert(::Type{GDebugKeyLike}, p, owns) = begin
convert(GDebugKey, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -204,6 +207,9 @@ $(Expr(:toplevel, quote
GLogField(p, owns)
end
const GLogFieldLike = Union{Ref{_GLogField}, GLogField}
convert(::Type{GLogFieldLike}, p, owns) = begin
convert(GLogField, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -332,6 +338,9 @@ $(Expr(:toplevel, quote
GOptionEntry(p, owns)
end
const GOptionEntryLike = Union{Ref{_GOptionEntry}, GOptionEntry}
convert(::Type{GOptionEntryLike}, p, owns) = begin
convert(GOptionEntry, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -438,6 +447,9 @@ $(Expr(:toplevel, quote
GScannerConfig(p, owns)
end
const GScannerConfigLike = Union{Ref{_GScannerConfig}, GScannerConfig}
convert(::Type{GScannerConfigLike}, p, owns) = begin
convert(GScannerConfig, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -479,6 +491,9 @@ $(Expr(:toplevel, quote
GSourceCallbackFuncs(p, owns)
end
const GSourceCallbackFuncsLike = Union{Ref{_GSourceCallbackFuncs}, GSourceCallbackFuncs}
convert(::Type{GSourceCallbackFuncsLike}, p, owns) = begin
convert(GSourceCallbackFuncs, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -513,6 +528,9 @@ $(Expr(:toplevel, quote
GString(p, owns)
end
const GStringLike = Union{Ref{_GString}, GString}
convert(::Type{GStringLike}, p, owns) = begin
convert(GString, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -556,6 +574,9 @@ $(Expr(:toplevel, quote
GTestConfig(p, owns)
end
const GTestConfigLike = Union{Ref{_GTestConfig}, GTestConfig}
convert(::Type{GTestConfigLike}, p, owns) = begin
convert(GTestConfig, p, owns)
end
end
end
begin
Expand Down Expand Up @@ -594,6 +615,9 @@ $(Expr(:toplevel, quote
GUnixPipe(p, owns)
end
const GUnixPipeLike = Union{Ref{_GUnixPipe}, GUnixPipe}
convert(::Type{GUnixPipeLike}, p, owns) = begin
convert(GUnixPipe, p, owns)
end
end
end
begin
Expand Down
45 changes: 45 additions & 0 deletions src/gen/gobject_structs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ $(Expr(:toplevel, quote
GEnumValue(p, owns)
end
const GEnumValueLike = Union{Ref{_GEnumValue}, GEnumValue}
convert(::Type{GEnumValueLike}, p, owns) = begin
convert(GEnumValue, p, owns)
end
end
end
begin
Expand All @@ -34,6 +37,9 @@ $(Expr(:toplevel, quote
GTypeClass(p, owns)
end
const GTypeClassLike = Union{Ref{_GTypeClass}, GTypeClass}
convert(::Type{GTypeClassLike}, p, owns) = begin
convert(GTypeClass, p, owns)
end
end
end
begin
Expand All @@ -52,6 +58,9 @@ $(Expr(:toplevel, quote
GTypeInterface(p, owns)
end
const GTypeInterfaceLike = Union{Ref{_GTypeInterface}, GTypeInterface}
convert(::Type{GTypeInterfaceLike}, p, owns) = begin
convert(GTypeInterface, p, owns)
end
end
end
begin
Expand All @@ -71,6 +80,9 @@ $(Expr(:toplevel, quote
GFlagsValue(p, owns)
end
const GFlagsValueLike = Union{Ref{_GFlagsValue}, GFlagsValue}
convert(::Type{GFlagsValueLike}, p, owns) = begin
convert(GFlagsValue, p, owns)
end
end
end
begin
Expand All @@ -95,6 +107,9 @@ $(Expr(:toplevel, quote
GTypeValueTable(p, owns)
end
const GTypeValueTableLike = Union{Ref{_GTypeValueTable}, GTypeValueTable}
convert(::Type{GTypeValueTableLike}, p, owns) = begin
convert(GTypeValueTable, p, owns)
end
end
end
begin
Expand All @@ -116,6 +131,9 @@ $(Expr(:toplevel, quote
GEnumClass(p, owns)
end
const GEnumClassLike = Union{Ref{_GEnumClass}, GEnumClass}
convert(::Type{GEnumClassLike}, p, owns) = begin
convert(GEnumClass, p, owns)
end
end
end
begin
Expand All @@ -136,6 +154,9 @@ $(Expr(:toplevel, quote
GFlagsClass(p, owns)
end
const GFlagsClassLike = Union{Ref{_GFlagsClass}, GFlagsClass}
convert(::Type{GFlagsClassLike}, p, owns) = begin
convert(GFlagsClass, p, owns)
end
end
end
begin
Expand All @@ -155,6 +176,9 @@ $(Expr(:toplevel, quote
GInterfaceInfo(p, owns)
end
const GInterfaceInfoLike = Union{Ref{_GInterfaceInfo}, GInterfaceInfo}
convert(::Type{GInterfaceInfoLike}, p, owns) = begin
convert(GInterfaceInfo, p, owns)
end
end
end
begin
Expand All @@ -179,6 +203,9 @@ $(Expr(:toplevel, quote
GParamSpecTypeInfo(p, owns)
end
const GParamSpecTypeInfoLike = Union{Ref{_GParamSpecTypeInfo}, GParamSpecTypeInfo}
convert(::Type{GParamSpecTypeInfoLike}, p, owns) = begin
convert(GParamSpecTypeInfo, p, owns)
end
end
end
begin
Expand All @@ -198,6 +225,9 @@ $(Expr(:toplevel, quote
GSignalInvocationHint(p, owns)
end
const GSignalInvocationHintLike = Union{Ref{_GSignalInvocationHint}, GSignalInvocationHint}
convert(::Type{GSignalInvocationHintLike}, p, owns) = begin
convert(GSignalInvocationHint, p, owns)
end
end
end
begin
Expand All @@ -221,6 +251,9 @@ $(Expr(:toplevel, quote
GSignalQuery(p, owns)
end
const GSignalQueryLike = Union{Ref{_GSignalQuery}, GSignalQuery}
convert(::Type{GSignalQueryLike}, p, owns) = begin
convert(GSignalQuery, p, owns)
end
end
end
begin
Expand All @@ -238,6 +271,9 @@ $(Expr(:toplevel, quote
GTypeFundamentalInfo(p, owns)
end
const GTypeFundamentalInfoLike = Union{Ref{_GTypeFundamentalInfo}, GTypeFundamentalInfo}
convert(::Type{GTypeFundamentalInfoLike}, p, owns) = begin
convert(GTypeFundamentalInfo, p, owns)
end
end
end
begin
Expand All @@ -264,6 +300,9 @@ $(Expr(:toplevel, quote
GTypeInfo(p, owns)
end
const GTypeInfoLike = Union{Ref{_GTypeInfo}, GTypeInfo}
convert(::Type{GTypeInfoLike}, p, owns) = begin
convert(GTypeInfo, p, owns)
end
end
end
begin
Expand All @@ -285,6 +324,9 @@ $(Expr(:toplevel, quote
GTypePluginClass(p, owns)
end
const GTypePluginClassLike = Union{Ref{_GTypePluginClass}, GTypePluginClass}
convert(::Type{GTypePluginClassLike}, p, owns) = begin
convert(GTypePluginClass, p, owns)
end
end
end
begin
Expand All @@ -305,6 +347,9 @@ $(Expr(:toplevel, quote
GTypeQuery(p, owns)
end
const GTypeQueryLike = Union{Ref{_GTypeQuery}, GTypeQuery}
convert(::Type{GTypeQueryLike}, p, owns) = begin
convert(GTypeQuery, p, owns)
end
end
end
@doc "See the [GTK docs](https://docs.gtk.org/gobject/struct.EnumClass.html)." GEnumClass
Expand Down
Loading

0 comments on commit de1f0f0

Please sign in to comment.