After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679424 - Fix some function's prototypes
Fix some function's prototypes
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks: 707756
 
 
Reported: 2012-07-04 23:05 UTC by Sébastien Wilmet
Modified: 2016-10-14 18:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix some function's prototypes (3.56 KB, patch)
2012-07-04 23:05 UTC, Sébastien Wilmet
none Details | Review
Redifining two times the same type with typedef is not allowed in C. (3.66 KB, patch)
2012-08-13 23:29 UTC, Sébastien Wilmet
none Details | Review
Better parameter type for _gtk_source_completion_context_new() (1.49 KB, patch)
2012-08-13 23:30 UTC, Sébastien Wilmet
none Details | Review
Direct include of completioncontext.h (910 bytes, patch)
2012-08-13 23:30 UTC, Sébastien Wilmet
none Details | Review
Better parameter type for gtk_source_completion_context_add_proposals() (2.89 KB, patch)
2012-08-13 23:30 UTC, Sébastien Wilmet
none Details | Review
CompletionContext: reformat the prototypes (2.22 KB, patch)
2012-08-13 23:30 UTC, Sébastien Wilmet
none Details | Review
Fix inclusion of private .h in public headers (5.42 KB, patch)
2012-08-15 21:57 UTC, Sébastien Wilmet
none Details | Review
Fix inclusion of private .h in public headers (5.13 KB, patch)
2012-08-16 19:09 UTC, Sébastien Wilmet
none Details | Review
Now it should be OK. I've moved all the main types (not the *Class or *Private types). (30.61 KB, patch)
2012-08-17 18:01 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
0001-SourceStyle-Use-the-expected-typedef-for-GtkSourceSt.patch (1.76 KB, patch)
2013-09-09 19:05 UTC, Murray Cumming
accepted-commit_now Details | Review

Description Sébastien Wilmet 2012-07-04 23:05:57 UTC
I think this doesn't break the API, since the same types are used, but just with another form.
Comment 1 Sébastien Wilmet 2012-07-04 23:05:58 UTC
Created attachment 218060 [details] [review]
Fix some function's prototypes
Comment 2 Sébastien Wilmet 2012-08-13 23:29:54 UTC
Created attachment 221060 [details] [review]
Redifining two times the same type with typedef is not allowed in C.

So here is another solution, that places some typedef in the gtksourcecompletion-private.h file.
Comment 3 Sébastien Wilmet 2012-08-13 23:30:12 UTC
Created attachment 221061 [details] [review]
Better parameter type for _gtk_source_completion_context_new()

It is not strictly useful since the function is private, but since it's
easy to do, why not.
Comment 4 Sébastien Wilmet 2012-08-13 23:30:16 UTC
Created attachment 221062 [details] [review]
Direct include of completioncontext.h

Instead of an indirect include via completionprovider.h.
Comment 5 Sébastien Wilmet 2012-08-13 23:30:21 UTC
Created attachment 221063 [details] [review]
Better parameter type for gtk_source_completion_context_add_proposals()

Here the cycle was between completionprovider.h and completioncontext.h.
Comment 6 Sébastien Wilmet 2012-08-13 23:30:26 UTC
Created attachment 221064 [details] [review]
CompletionContext: reformat the prototypes
Comment 7 Paolo Borelli 2012-08-14 06:51:57 UTC
The patch series looks good, please push. Thanks!
Comment 8 Sébastien Wilmet 2012-08-14 22:09:47 UTC
Thank you for the review. The commits are pushed.
Comment 9 Ignacio Casal Quinteiro (nacho) 2012-08-15 12:09:12 UTC
Reopening as gedit is not able to compile against gtksourceview anymore. This is due to the fact that gtksourceview-private shouldn't be in gtksourceview.h
Comment 10 Sébastien Wilmet 2012-08-15 21:57:24 UTC
Created attachment 221323 [details] [review]
Fix inclusion of private .h in public headers

The solution is to put the problematic typedefs in a new .h file, called
gtksourcecompletiontypedefs.h.

(Sorry for the inconvenience)
Comment 11 Sébastien Wilmet 2012-08-15 22:07:49 UTC
It's the kind of things that I don't pay attention to, as I don't have a lot of experience in library development.

Maybe there is a better name for gtksourcecompletiontypedefs.h? I don't know how these issues are generally resolved. (or maybe they are not generally resolved ;)

PS: last week and the following weeks I don't have an access to IRC (or I should learn irssi or something similar, but I'm not often connected to internet, anyway).
Comment 12 Paolo Borelli 2012-08-16 07:20:43 UTC
The way in which gtk solves it is by having an header for all types.

I propose to byte the bullet and just do gtksourcetypes.h
Comment 13 Sébastien Wilmet 2012-08-16 19:09:58 UTC
Created attachment 221450 [details] [review]
Fix inclusion of private .h in public headers

The solution is to put the problematic typedefs in a new .h file, called
gtksourcetypes.h, like it is done in GTK+.

(Sorry for the inconvenience)
Comment 14 Paolo Borelli 2012-08-16 19:30:17 UTC
Well, I would like to move all the types there, not just completion :)
Comment 15 Sébastien Wilmet 2012-08-17 18:01:25 UTC
Created attachment 221656 [details] [review]
Now it should be OK. I've moved all the main types (not the *Class or *Private types).

But some .h files were included for having the type that is now in gtksourcetypes.h. So some headers clean-up should be done, ideally. But it takes far more time to do (and it is boring...), unless a script exists.

----

Move all the main types in gtksourcetypes.h

This avoids the problem of .h inclusions cycles.
Comment 16 Paolo Borelli 2012-08-17 18:42:10 UTC
Review of attachment 221656 [details] [review]:

Looks good!

Please commit so that we unbreak things. We can worry about the include cleanup later
Comment 17 Paolo Borelli 2012-08-18 10:43:06 UTC
I committed this since it was kind of urgent
Comment 18 Murray Cumming 2013-09-09 19:05:35 UTC
Created attachment 254511 [details] [review]
0001-SourceStyle-Use-the-expected-typedef-for-GtkSourceSt.patch

This has created a slight build problem with gtksourceviewmm (C++). This patch fixes it. May I push it?
Comment 19 Ignacio Casal Quinteiro (nacho) 2013-09-09 19:07:11 UTC
Review of attachment 254511 [details] [review]:

Fair enough.
Comment 20 Sébastien Wilmet 2016-10-14 18:28:35 UTC
(In reply to Paolo Borelli from comment #12)
> The way in which gtk solves it is by having an header for all types.
> 
> I propose to byte the bullet and just do gtksourcetypes.h

So gtksourcetypes.h has been created to avoid cycles in header inclusions, when header A needs the type B and header B needs the type A.

At:
https://wiki.gnome.org/Projects/GLib/CompilerRequirements

> (C11) support for type redefinition
>
> /!\ This requirement has been temporarily suspended (on account of OpenBSD
> carrying an old version of gcc) but it will probably return in the future.
>
> Your compiler must allow "a typedef name [to] be redefined to denote the same
> type as it currently does", as per C11 §6.7, item 3.

With that C11 feature, it is possible to solve the above problem by redefining the type. If GLib uses again this feature, we can consider using it in GtkSourceView too.

Not sure it is something we want to do, but it's better to have self-contained *.{c,h}, instead of needing to look at other places. A self-contained *.{c,h} (or a group of related *.{c,h}) can then be copied in another project, or even forked (to quickly experiment something in an application or a higher-level library).