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

gio: manually implement content_type_guess #1591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidmhewitt
Copy link
Contributor

@davidmhewitt davidmhewitt commented Dec 7, 2024

Related: #1257

In C, g_content_type_guess supports passing NULL to the data parameter which makes it guess the content type based on the filename only.

So, add a manually written content_type_guess allowing Option for the data parameter. This is a stopgap until gir can generate the optional parameter for these cases.

This is an API break in some cases, but should continue to compile in most cases.

@davidmhewitt davidmhewitt force-pushed the add_content_type_guess_for_filename branch 2 times, most recently from 8ecd700 to 7a18f52 Compare December 7, 2024 07:12
@sdroege
Copy link
Member

sdroege commented Dec 7, 2024

Not sure if it wouldn't be better to implement the other function manually and have it take an Option<&[u8]> as parameter.

@bilelmoussaoui do you have a preference?

@sdroege
Copy link
Member

sdroege commented Dec 7, 2024

Alternatives would include changing the generation of the content_type_guess to allow passing Option<&[u8]> but this would be an API break.

If you make it impl Into<Option<&[u8]>> then (almost all?) existing code will continue to compile, but it's technically still API breakage of course.

@bilelmoussaoui
Copy link
Member

The actual solution is to fix gir so that all the broken functions are generated properly.

Adding a function deviates further from such fix, at worst implement it manually to fix the behaviour despite the API break and you can call into ffi manually on your app/lib side until we do a breaking api release

@sdroege
Copy link
Member

sdroege commented Dec 7, 2024

until we do a breaking api release

We also decided that we don't consider nullability fixes as unacceptable breaking changes

at worst implement it manually

So let's manually implement this function for the time being until someone has the time and motivation to fix gir :)

@davidmhewitt davidmhewitt force-pushed the add_content_type_guess_for_filename branch from 7a18f52 to 5830056 Compare December 8, 2024 05:52
@davidmhewitt davidmhewitt changed the title gio: add content_type_guess_for_filename helper gio: manually implement content_type_guess Dec 8, 2024
@davidmhewitt
Copy link
Contributor Author

I've updated this PR to replace the generated content_type_guess function with a manually written one that allows using an Option for the data parameter.

This can be a stopgap until gir generation for these types is fixed.

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 this pull request may close these issues.

3 participants