Skip to content

Avoid Closure cfunctions #95

@eschnett

Description

@eschnett

Gtk4.jl uses Closure cfunctions internally. These do not work on all architectures, e.g. they don't work on ARM, i.e. modern Apple laptops.

I see that there are two uses for closure cfunctions in the code:

gtype.jl:411:        deref = cfunction_(gc_unref_weak, Nothing, (Ref{typeof(x)},))
signals.jl:15:    callback = cfunction_(cb, RT, tuple(Ptr{GObject}, param_types..., Ref{CT}))

The first (in gtype.jl) always calls gc_unref_weak and thus doesn't need to be a closure at all, a regular cfunction would do.

The second (in signals.jl) does not need to be a closure either. The API has an additional argument data (see https://docs.gtk.org/gobject/func.signal_connect_data.html) that can be used to pass in additional information.

If changed, the exported function cfunction_, which always creates a closure cfunction, could be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions