Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Problem with generating enums/flags where the get_type() function was added later #839

Closed
sdroege opened this issue Sep 13, 2019 · 7 comments · Fixed by #930
Closed

Problem with generating enums/flags where the get_type() function was added later #839

sdroege opened this issue Sep 13, 2019 · 7 comments · Fixed by #930

Comments

@sdroege
Copy link
Member

sdroege commented Sep 13, 2019

E.g. https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/blob/master/gstreamer-video-sys/src/lib.rs#L2332

This get_type() function was added in 1.16, the corresponding flags type exists since much longer.

There are two problems here
a) In GStreamer this function needs to be marked as Since: 1.16
b) We need to generate the #[cfg()] thing for it in the -sys crate
c) We need to figure out how to handle that conditional compilation in the non-sys crate

Thoughts?

@EPashkin
Copy link
Member

"a" and "b" IMHO fixing by changing GstVideo-1.0.gir,
for "c" IMHO if there any value that custom gtk_align_get_type can return without broke all,
then simpler just add manual function to sys crate with inverse condition,
so no changes will needed in non-syses

@EPashkin
Copy link
Member

Alternative also needed fixes for "a" and "b" anyway.
We can compare versions for "get_type" and "enum" and if get_type added later not generate "StaticType" and "*Value"* traits for enum.

@sdroege
Copy link
Member Author

sdroege commented Sep 13, 2019

"a" and "b" IMHO fixing by changing GstVideo-1.0.gir,

Probably, but would we even generate the b) for the -sys crate?

for "c" IMHO if there any value that custom gtk_align_get_type can return without broke all,
then simpler just add manual function to sys crate with inverse condition,
so no changes will needed in non-syses

We can't implement our own get_type function. We'd have to put the whole StaticType and GValuer traits impls into #[cfg]

@EPashkin
Copy link
Member

About "b": IMHO get_type is normal function so "[cfg]" will be generated with right .gir file.

You right that instead not generating we can add "[cfg]" to trait "StaticType" etc.

"Breaking change" alternative just increase enum version to match get_type's.

@EPashkin
Copy link
Member

About "b" if you meant "inverse function" then seems we can't generate it 😢

@sdroege
Copy link
Member Author

sdroege commented Sep 13, 2019

"Breaking change" alternative just increase enum version to match get_type's.

That's not an option for GStreamer unfortunately :)

@sdroege
Copy link
Member Author

sdroege commented Sep 13, 2019

Ok, so we have a plan I guess.

sdroege added a commit to sdroege/gir that referenced this issue Jun 9, 2020
…) functions in sys mode

We shouldn't look for the full get_type function name but for the name
without the namespace and type name prefix.

Once we have that, make use of the ignore and version configuration in
addition to the general #[cfg] handling. This allows us to ignore
get_type() functions and override their version, for example if the
get_type() function was added after the type like in Pango.

First part of gtk-rs#839
sdroege added a commit to sdroege/gir that referenced this issue Jun 9, 2020
…) functions in sys mode

We shouldn't look for the full get_type function name but for the name
without the namespace and type name prefix.

Once we have that, make use of the ignore and version configuration in
addition to the general #[cfg] handling. This allows us to ignore
get_type() functions and override their version, for example if the
get_type() function was added after the type like in Pango.

First part of gtk-rs#839
sdroege added a commit to sdroege/gir that referenced this issue Jun 10, 2020
…) functions in sys mode

We shouldn't look for the full get_type function name but simply for
"get_type". As there is only the associated C function name we simply
define "get_type" as the name to look for in the configuration.

Once we have that, make use of the ignore and version configuration in
addition to the general #[cfg] handling. This allows us to ignore
get_type() functions and override their version, for example if the
get_type() function was added after the type like in Pango.

First part of gtk-rs#839
sdroege added a commit to sdroege/gir that referenced this issue Jun 11, 2020
And only make use of the functions conditionally if they're newer than
the type itself.

This only applies to records (boxed/shared), enums and flags. GObject
types always need a get_type function and won't work without, so there
will never be the case that the function is added later.

Fixes gtk-rs#839
sdroege added a commit to sdroege/gir that referenced this issue Jun 11, 2020
And only make use of the functions conditionally if they're newer than
the type itself.

This only applies to records (boxed/shared), enums and flags. GObject
types always need a get_type function and won't work without, so there
will never be the case that the function is added later.

Fixes gtk-rs#839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants