Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

Fix remaining deprecations

Open tknopp opened this issue 7 years ago • 7 comments

Gtk master now passes test on Julia 0.7 but there are remaining things:

  • the current_module deprecations cannot be replaced by @__MODULE__ since it says that Gtk is not defined

  • the remaining cfunction replacements do not work, because the depend on local scope

@vtjnash: I definitely need help on the remaining cfunction deprecations. Would be wonderful if you could have a look.

tknopp avatar Aug 09 '18 00:08 tknopp

I fixed the cfunction issue by using a direct call into libjulia:

cfunction_(f, r, a::Tuple) = cfunction_(f, r, Tuple{a...})
@noinline function cfunction_(f, r, a)
    @nospecialize(f, r, a)
    return ccall((:jl_function_ptr,:libjulia), Ptr{Cvoid}, (Any, Any, Any), f, r, a)
end

Is that ok for now @vtjnash? Otherwise we need a fix for @cfunction in local scope.

The module thing has been worked around by

curr_module() = ccall((:jl_get_current_module,:libjulia), Ref{Module}, ())

That certainly is not ok, since that function is not present in 1.0 anymore. @vtjnash or @JeffBezanson: I would be very thankful for a fix. I don't fully get the interaction between GLib and Gtk and this is your code @vtjnash. When this is done Gtk should be deprecation free and work on 1.0. This is important for depending packages.

tknopp avatar Aug 10 '18 10:08 tknopp

No, this function is supposed to be deleted. That function call usages should be replaced with a macro to create the function pointer of the correct type at each use site.

vtjnash avatar Aug 10 '18 10:08 vtjnash

Then I need you help. The @cfunctiondepends on local scope: https://github.com/JuliaGraphics/Gtk.jl/blob/master/src/GLib/signals.jl#L11 cb is local scope.

tknopp avatar Aug 10 '18 10:08 tknopp

The other ones are here: https://github.com/JuliaGraphics/Gtk.jl/blob/9e7b9da67bef8905eb9311b4683a78404428e562/src/events.jl#L90

So its these 3 cfunctions that I was not able to replace by @cfunction

tknopp avatar Aug 10 '18 10:08 tknopp

Yes, signal_connect should also be made a macro, so it can access the types for the cfunction method signature at compile time.

vtjnash avatar Aug 10 '18 10:08 vtjnash

Those other ones can just be deleted (optionally keep the Ref version, or delete those too). It's a primitive implementation of FunctionWrappers.jl (from long before that existed), but it is not really necessary.

vtjnash avatar Aug 10 '18 10:08 vtjnash

No, this function is supposed to be deleted.

Are the deleted in Julia 1.0? Or not. If it is still there my "hotfix" is probably ok and we can redesign signal_connect in the second step?

Yes, signal_connect should also be made a macro, so it can access the types for the cfunction method signature at compile time.

I understand this, but doesn't this mean that one cannot apply closures anymore to the function? What about all those on_* functions, these in turn all need to go right? I actually don't know how to redesign the file https://github.com/JuliaGraphics/Gtk.jl/blob/master/src/events.jl then.

What is with the simple signal_connect that is used in do expressions: https://github.com/JuliaGraphics/Gtk.jl/blob/master/src/GLib/signals.jl#L26 This is ok, since it does not compile a cfunction?!

So in summary, we will have @signal_connect for the compiled version and signal_connect for the runtime version, is this correct Jameson? And I don't know what we do with events.jl

tknopp avatar Aug 10 '18 19:08 tknopp