Skip to content

Commit

Permalink
fix some methods that return enum or flags types
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Nov 23, 2024
1 parent de1f0f0 commit 13157b6
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Adwaita/src/gen/adw_consts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ $(Expr(:toplevel, quote
begin
const DURATION_INFINITE = 0xffffffff
const MAJOR_VERSION = 1
const MICRO_VERSION = 4
const MICRO_VERSION = 5
const MINOR_VERSION = 5
const VERSION_S = "1.5.4"
const VERSION_S = "1.5.5"
begin
@cenum AnimationState::Int32 AnimationState_IDLE = 0 AnimationState_PAUSED = 1 AnimationState_PLAYING = 2 AnimationState_FINISHED = 3
(GLib.g_type(::Type{T}) where T <: AnimationState) = begin
Expand Down
18 changes: 9 additions & 9 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# functions that output expressions for a library in bulk

## Constants, enums, and flags
function _enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded)
function _enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded, export_constants = true)
for e in es
name = Symbol(get_name(e))
in(name, skiplist) && continue
push!(const_mod.args, unblock(decl(e,incl_typeinit)))
push!(const_exports.args, name)
export_constants && push!(const_exports.args, name)
push!(loaded,name)
end
end

function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_typeinit=true,skiplist=Symbol[])
function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_typeinit=true,skiplist=Symbol[], export_constants = true)
loaded=Symbol[]
c = get_consts(ns)

Expand All @@ -25,14 +25,14 @@ function all_const_exprs!(const_mod, const_exports, ns;print_summary=true,incl_t
end

es=get_all(ns,GIEnumInfo)
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded)
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded, export_constants)

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

es=get_all(ns,GIFlagsInfo)
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded)
_enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded, export_constants)

if print_summary && length(es)>0
printstyled("Generated ",length(es)," flags\n";color=:green)
Expand All @@ -45,11 +45,11 @@ function export_consts!(ns,path,prefix,skiplist = Symbol[]; doc_prefix = prefix,

const_mod = Expr(:block)

c = all_const_exprs!(const_mod, exports, ns; skiplist= skiplist)
c = all_const_exprs!(const_mod, exports, ns; skiplist= skiplist, export_constants)
if doc_xml !== nothing
GI.append_const_docs!(const_mod.args, doc_prefix, doc_xml, c)
end
export_constants && push!(const_mod.args, exports)
isempty(exports.args) || push!(const_mod.args, exports)

push!(exprs, const_mod)

Expand Down Expand Up @@ -438,11 +438,11 @@ function all_interface_methods!(exprs,ns;skiplist=Symbol[],interface_skiplist=Sy
end
end

function export_methods!(ns,path,prefix;struct_method_skiplist = Symbol[], object_method_skiplist = Symbol[],interface_method_skiplist = Symbol[], struct_skiplist = Symbol[], interface_skiplist = Symbol[], object_skiplist = Symbol[], exclude_deprecated = true)
function export_methods!(ns,path,prefix;struct_method_skiplist = Symbol[], object_method_skiplist = Symbol[],interface_method_skiplist = Symbol[], struct_skiplist = Symbol[], interface_skiplist = Symbol[], object_skiplist = Symbol[], exclude_deprecated = true, interface_helpers = true)
toplevel, exprs, exports = GI.output_exprs()

all_struct_methods!(exprs,ns, struct_skiplist = struct_skiplist, skiplist = struct_method_skiplist, exclude_deprecated = exclude_deprecated)
all_object_methods!(exprs,ns; skiplist = object_method_skiplist, object_skiplist = object_skiplist, exclude_deprecated = exclude_deprecated)
all_object_methods!(exprs,ns; skiplist = object_method_skiplist, object_skiplist = object_skiplist, exclude_deprecated = exclude_deprecated, interface_helpers)
all_interface_methods!(exprs,ns; skiplist = interface_method_skiplist, interface_skiplist = interface_skiplist, exclude_deprecated = exclude_deprecated)

write_to_file(path,"$(prefix)_methods",toplevel)
Expand Down
2 changes: 1 addition & 1 deletion gen/gen_gio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct_skiplist = GI.export_struct_exprs!(ns,path, "gio", struct_skiplist, impor

object_method_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_attribute_file_path,:set_attribute_file_path,:get_timeout,:set_timeout]
: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]

object_skiplist=vcat(obj_skiplist,[:AppInfoMonitor,:DBusConnection,:DBusMenuModel,:DBusProxy,:DBusMethodInvocation,:IOModule,:SimpleProxyResolver,:UnixMountMonitor])

Expand Down
1 change: 1 addition & 0 deletions src/GLib/GLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module G_
using Glib_jll

using ..GLib
using ..GLib: BookmarkFileError, ChecksumType, ConvertError, DateDMY, DateMonth, DateWeekday, ErrorType, FileError, IOChannelError, IOError, IOStatus, KeyFileError, LogWriterOutput, MarkupError, NormalizeMode, NumberParserError, OnceStatus, OptionArg, OptionError, RegexError, SeekType, ShellError, SliceConfig, SpawnError, TestFileType, TestLogType, TestResult, ThreadError, TimeType, TokenType, TraverseType, UnicodeBreakType, UnicodeScript, UnicodeType, UnixPipeEnd, UriError, UserDirectory, VariantClass, VariantParseError, BusType, ConverterResult, CredentialsType, DBusError, DBusMessageByteOrder, DBusMessageHeaderField, DBusMessageType, DataStreamByteOrder, DataStreamNewlineType, DriveStartStopType, EmblemOrigin, FileAttributeStatus, FileAttributeType, FileMonitorEvent, FileType, FilesystemPreviewType, IOErrorEnum, IOModuleScopeFlags, MemoryMonitorWarningLevel, MountOperationResult, NetworkConnectivity, NotificationPriority, PasswordSave, PollableReturn, ResolverError, ResolverRecordType, ResourceError, SocketClientEvent, SocketFamily, SocketListenerEvent, SocketProtocol, SocketType, TlsAuthenticationMode, TlsCertificateRequestFlags, TlsChannelBindingError, TlsChannelBindingType, TlsDatabaseLookupFlags, TlsError, TlsInteractionResult, UnixSocketAddressType, ZlibCompressorFormat, AsciiType, FileSetContentsFlags, FileTest, FormatSizeFlags, HookFlagMask, IOCondition, IOFlags, KeyFileFlags, LogLevelFlags, MainContextFlags, MarkupCollectType, MarkupParseFlags, OptionFlags, RegexCompileFlags, RegexMatchFlags, SpawnFlags, TestSubprocessFlags, TraverseFlags, UriFlags, UriHideFlags, UriParamsFlags, BindingFlags, ConnectFlags, IOCondition, ParamFlags, SignalFlags, SignalMatchType, TypeFlags, TypeFundamentalFlags, AppInfoCreateFlags, ApplicationFlags, AskPasswordFlags, BusNameOwnerFlags, BusNameWatcherFlags, ConverterFlags, DBusCallFlags, DBusCapabilityFlags, DBusConnectionFlags, DBusInterfaceSkeletonFlags, DBusMessageFlags, DBusObjectManagerClientFlags, DBusPropertyInfoFlags, DBusProxyFlags, DBusSendMessageFlags, DBusServerFlags, DBusSignalFlags, DBusSubtreeFlags, DriveStartFlags, FileAttributeInfoFlags, FileCopyFlags, FileCreateFlags, FileMeasureFlags, FileMonitorFlags, FileQueryInfoFlags, IOStreamSpliceFlags, MountMountFlags, MountUnmountFlags, OutputStreamSpliceFlags, ResolverNameLookupFlags, ResourceFlags, ResourceLookupFlags, SettingsBindFlags, SocketMsgFlags, SubprocessFlags, TestDBusFlags, TlsCertificateFlags, TlsDatabaseVerifyFlags, TlsPasswordFlags

import Base: convert, copy, run

Expand Down
3 changes: 3 additions & 0 deletions src/Gdk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ end
function glib_unref(x::Ptr{GdkEvent})
ccall((:gdk_event_unref, libgtk4), Nothing, (Ptr{GdkEvent},), x)
end

Base.show(io::IO, t::GskTransform) = print(io,"GskTransform("*G_.to_string(t)*")")

1 change: 1 addition & 0 deletions src/GdkPixbufLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using gdk_pixbuf_jll

using ..GLib
using ..GdkPixbufLib
using ..GdkPixbufLib: Colorspace, InterpType, PixbufError, PixbufRotation

import Base: convert, copy

Expand Down
5 changes: 5 additions & 0 deletions src/Graphene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ eval(include("gen/graphene_methods"))
end

_GrapheneRect(x::Number,y::Number,w::Number,h::Number) = _GrapheneRect(_GraphenePoint(x,y),_GrapheneSize(w,h))
# this constructor returns a RefValue{_GrapheneRect}, which is GrapheneRectLike
# This seems to result in one less (Julia) allocation than constructing a Ptr{GrapheneRect} by calling "alloc", "init"
GrapheneRect(x::Number,y::Number,w::Number,h::Number) = Ref(_GrapheneRect(x,y,w,h))

GraphenePoint(x::Number, y::Number) = Ref(_GraphenePoint(x,y))

function __init__()
gtype_wrapper_cache_init()
Expand Down
2 changes: 2 additions & 0 deletions src/Gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ using ..Graphene
using ..GdkPixbufLib
using ..Gtk4

using ..Gtk4: BlendMode, Corner, FillRule, GLUniformType, LineCap, LineJoin, MaskMode, PathDirection, PathOperation, RenderNodeType, ScalingFilter, SerializationError, TransformCategory, PathForeachFlags, AxisUse, CrossingMode, DevicePadFeature, DeviceToolType, DmabufError, DragCancelReason, EventType, FullscreenMode, GLError, Gravity, InputSource, KeyMatch, MemoryFormat, NotifyType, ScrollDirection, ScrollUnit, SubpixelLayout, SurfaceEdge, TextureError, TitlebarGesture, TouchpadGesturePhase, VulkanError, AnchorHints, AxisFlags, DragAction, FrameClockPhase, GLAPI, ModifierType, PaintableFlags, SeatCapabilities, ToplevelState, AccessibleAnnouncementPriority, AccessibleAutocomplete, AccessibleInvalidState, AccessiblePlatformState, AccessibleProperty, AccessibleRelation, AccessibleRole, AccessibleSort, AccessibleState, AccessibleTextContentChange, AccessibleTextGranularity, AccessibleTristate, Align, ArrowType, AssistantPageType, BaselinePosition, BorderStyle, BuilderError, ButtonsType, CellRendererAccelMode, CellRendererMode, Collation, ConstraintAttribute, ConstraintRelation, ConstraintStrength, ConstraintVflParserError, ContentFit, CornerType, CssParserError, CssParserWarning, DeleteType, DialogError, DirectionType, EditableProperties, EntryIconPosition, EventSequenceState, FileChooserAction, FileChooserError, FilterChange, FilterMatch, FontLevel, GraphicsOffloadEnabled, IconSize, IconThemeError, IconViewDropPosition, ImageType, InputPurpose, InscriptionOverflow, Justification, LevelBarMode, License, ListTabBehavior, MessageType, MovementStep, NaturalWrapMode, NotebookTab, NumberUpLayout, Ordering, Orientation, Overflow, PackType, PadActionType, PageOrientation, PageSet, PanDirection, PolicyType, PositionType, PrintDuplex, PrintError, PrintOperationAction, PrintOperationResult, PrintPages, PrintQuality, PrintStatus, PropagationLimit, PropagationPhase, RecentManagerError, ResponseType, RevealerTransitionType, ScrollStep, ScrollType, ScrollablePolicy, SelectionMode, SensitivityType, ShortcutScope, ShortcutType, SizeGroupMode, SizeRequestMode, SortType, SorterChange, SorterOrder, SpinButtonUpdatePolicy, SpinType, StackTransitionType, StringFilterMatchMode, SymbolicColor, SystemSetting, TextDirection, TextExtendSelection, TextViewLayer, TextWindowType, TreeViewColumnSizing, TreeViewDropPosition, TreeViewGridLines, Unit, WrapMode, ApplicationInhibitFlags, BuilderClosureFlags, CellRendererState, DebugFlags, DialogFlags, EventControllerScrollFlags, FontChooserLevel, IconLookupFlags, InputHints, ListScrollFlags, PickFlags, PopoverMenuFlags, PrintCapabilities, ShortcutActionFlags, StateFlags, StyleContextPrintFlags, TextSearchFlags

eval(include("gen/gdk4_methods"))
eval(include("gen/gdk4_functions"))
eval(include("gen/gsk4_methods"))
Expand Down
1 change: 1 addition & 0 deletions src/Pango/Pango.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using Pango_jll, Glib_jll

using ..GLib
using ..Pango
using ..Pango: Alignment, AttrType, BaselineShift, CoverageLevel, Direction, EllipsizeMode, FontScale, Gravity, GravityHint, LayoutDeserializeError, Overline, RenderPart, Script, Stretch, Style, TabAlign, TextTransform, Underline, Variant, Weight, WrapMode, FontMask, LayoutDeserializeFlags, LayoutSerializeFlags, ShapeFlags, ShowFlags
using ..Pango.Cairo

eval(include("../gen/pango_methods"))
Expand Down
4 changes: 2 additions & 2 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ toplevel(w::GtkWidget) = G_.get_root(w)
Returns the allocated width of `w` in pixels.
Related GTK function: [`gtk_widget_get_allocated_width`()]($(gtkdoc_method_url("gtk4","Widget","get_allocated_width")))
Related GTK function: [`gtk_widget_get_width`()]($(gtkdoc_method_url("gtk4","Widget","get_width")))
""" width

@doc """
height(w::GtkWidget)
Returns the allocated height of `w` in pixels.
Related GTK function: [`gtk_widget_get_allocated_height`()]($(gtkdoc_method_url("gtk4","Widget","get_allocated_height")))
Related GTK function: [`gtk_widget_get_height`()]($(gtkdoc_method_url("gtk4","Widget","get_height")))
""" height

size(w::GtkWidget) = (width(w), height(w))
Expand Down
24 changes: 24 additions & 0 deletions src/gen/gio_methods
Original file line number Diff line number Diff line change
Expand Up @@ -4069,6 +4069,10 @@ $(Expr(:toplevel, quote
function to_string(instance::GProxyAddress)
to_string(GSocketConnectable(instance))
end
function get_timeout(instance::GResolver)
ret = ccall(("g_resolver_get_timeout", libgio), UInt32, (Ptr{GObject},), instance)
ret
end
function lookup_by_address(instance::GResolver, _address::GInetAddress, _cancellable::Maybe(GCancellable))
_cancellable_maybe = nothing_to_null(_cancellable)
err = err_buf()
Expand Down Expand Up @@ -4208,6 +4212,10 @@ $(Expr(:toplevel, quote
ret = ccall(("g_resolver_set_default", libgio), Nothing, (Ptr{GObject},), instance)
nothing
end
function set_timeout(instance::GResolver, _timeout_ms::Integer)
ret = ccall(("g_resolver_set_timeout", libgio), Nothing, (Ptr{GObject}, UInt32), instance, _timeout_ms)
nothing
end
function Settings_new(_schema_id::Union{AbstractString, Symbol})
ret = ccall(("g_settings_new", libgio), Ptr{GObject}, (Cstring,), _schema_id)
ret2 = GSettingsLeaf(ret, true)
Expand Down Expand Up @@ -4745,6 +4753,10 @@ $(Expr(:toplevel, quote
ret2 = SocketType(ret)
ret2
end
function get_timeout(instance::GSocket)
ret = ccall(("g_socket_get_timeout", libgio), UInt32, (Ptr{GObject},), instance)
ret
end
function get_ttl(instance::GSocket)
ret = ccall(("g_socket_get_ttl", libgio), UInt32, (Ptr{GObject},), instance)
ret
Expand Down Expand Up @@ -4938,6 +4950,10 @@ $(Expr(:toplevel, quote
ret2 = convert(Bool, ret)
ret2
end
function set_timeout(instance::GSocket, _timeout::Integer)
ret = ccall(("g_socket_set_timeout", libgio), Nothing, (Ptr{GObject}, UInt32), instance, _timeout)
nothing
end
function set_ttl(instance::GSocket, _ttl::Integer)
ret = ccall(("g_socket_set_ttl", libgio), Nothing, (Ptr{GObject}, UInt32), instance, _ttl)
nothing
Expand Down Expand Up @@ -5168,6 +5184,10 @@ $(Expr(:toplevel, quote
ret2 = SocketType(ret)
ret2
end
function get_timeout(instance::GSocketClient)
ret = ccall(("g_socket_client_get_timeout", libgio), UInt32, (Ptr{GObject},), instance)
ret
end
function get_tls(instance::GSocketClient)
ret = ccall(("g_socket_client_get_tls", libgio), Cint, (Ptr{GObject},), instance)
ret2 = convert(Bool, ret)
Expand Down Expand Up @@ -5199,6 +5219,10 @@ $(Expr(:toplevel, quote
ret = ccall(("g_socket_client_set_socket_type", libgio), Nothing, (Ptr{GObject}, UInt32), instance, _type)
nothing
end
function set_timeout(instance::GSocketClient, _timeout::Integer)
ret = ccall(("g_socket_client_set_timeout", libgio), Nothing, (Ptr{GObject}, UInt32), instance, _timeout)
nothing
end
function set_tls(instance::GSocketClient, _tls::Bool)
ret = ccall(("g_socket_client_set_tls", libgio), Nothing, (Ptr{GObject}, Cint), instance, _tls)
nothing
Expand Down
2 changes: 1 addition & 1 deletion src/lists.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function show(io::IO, sl::GtkStringList)
end
end
else
println(io, "0-element GtkStringList")
print(io, "0-element GtkStringList")
end
end
string(obj::GtkStringObject) = G_.get_string(obj)
Expand Down
2 changes: 2 additions & 0 deletions test/gdkpixbuf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pb[1:3,1:3]=x
pb[1,1]=colorant"blue"
@test pb[1,1] == GdkPixbufLib.RGB(0,0,0xff)

cs = GdkPixbufLib.G_.get_colorspace(pb)

end

@testset "Transparent pixbuf" begin
Expand Down

0 comments on commit 13157b6

Please sign in to comment.