Skip to content

Fix use declarations when generating code for glib. #537

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from Feb 7, 2018
Merged

Fix use declarations when generating code for glib. #537

merged 1 commit into from Feb 7, 2018

Conversation

ghost
Copy link

@ghost ghost commented Feb 7, 2018

Fix for gtk-rs/glib#290.

It seems we are missing some layer of abstraction, or general consistency in
generated code. I thinking about all checks of the form: * == namespaces::MAIN.
It shouldn't really be necessary.

@sdroege
Copy link
Member

sdroege commented Feb 7, 2018

This is fixing gtk-rs/glib#290 ? Elsewhere we check if the namespace is GLib, and only then do the special paths.

@ghost
Copy link
Author

ghost commented Feb 7, 2018

Yes, this was intended as a fix for gtk-rs/glib#290, as
I have mentioned in the description. Did you have any further issues with it?

Regarding names, I though we could do something like use crate as glib or
use super as glib, and then use exactly the same qualified name.
Unfortunately this is not yet implemented: rust-lang/rust#37156 (comment)

@sdroege
Copy link
Member

sdroege commented Feb 7, 2018

I would prefer if we consistently did the special casing for the glib crate the same way everywhere, apart from that the changes look good to me. Thanks :)

@ghost
Copy link
Author

ghost commented Feb 7, 2018

Could you point me to one such example? When I look for code that solves
analogous problem in codegen, the solution looks like above. So it is not
readily apparent to me what else this is supposed to be consistent with.

@sdroege
Copy link
Member

sdroege commented Feb 7, 2018

        if env.namespaces.glib_ns_id != namespaces::MAIN {
            return;
        }

in imports.rs for example

@sdroege
Copy link
Member

sdroege commented Feb 7, 2018

Ah I missed that the first part of the commit is in such a block, the second also is. Nevermind then

@EPashkin
Copy link
Member

EPashkin commented Feb 7, 2018

@tmiasko Thanks.

@EPashkin EPashkin merged commit 81a781f into gtk-rs:master Feb 7, 2018
@EPashkin
Copy link
Member

EPashkin commented Feb 7, 2018

@tmiasko About checks for namespaces::MAIN:
I don't worry about it.
Most checks needed as we have different logic of "foreign" types,
only exceptions is is we generating glib? check that also needed, as it source for most base types.
But if you have some good idea I welcome it.

vhdirk pushed a commit to vhdirk/gir that referenced this pull request Jul 6, 2018
Fix use declarations when generating code for glib.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants