GNOME Bugzilla – Bug 165425
gtk-doc fails to parse unions
Last modified: 2009-12-24 22:07:18 UTC
In my code, I have the following structure: typedef struct _UtermChar UtermChar; struct _UtermChar { unsigned int type : 4; /* Character type; selects union value. */ unsigned int status : 2; /* Character status. */ unsigned int pad : 2; /* Structure padding. */ union { wchar_t glyph; /* Character number (UCS id). */ UtermControl func; /* Terminal control function. */ UtermCodeTable *table; /* Switch to referenced table. */ UtermCodeTable **tableref; /* Switch to referenced table. */ } data; /* Union of possible glyph types. */ }; In the generated template, only @type @status @pad are emitted. The union and its members are skipped entirely. <!-- ##### STRUCT UtermChar ##### --> <para> </para> @type: Character type; selects union value. @status: Character status. @pad: Structure padding. Regards, Roger
Yes, it can't handle unions nested inside structs at present. The code that parses structs is in ParseStructDeclaration() in gtkdoc-common.pl.in. I'm not sure how difficult it would be to fix.
looks to be a unique bug. This is still an issue in CVS HEAD, marking version 1.4 and GNOME Version to 2.11/2.12.
Apparently it doesn't parse unions at all; I have the following structures in a source file (abbreviated to avoid obscuring the issue with needless details): typedef union gluniversal_union { ... blah blah blah ... } gluniversal_t; typedef struct gidispatch_function_struct { ... } gidispatch_function_t; typedef struct gidispatch_intconst_struct { ... } gidispatch_intconst_t; typedef union glk_objrock_union { ... } gidispatch_rock_t; Only gidispatch_function_t and gidispatch_intconst_t show up in the docs. gluniversal_t and gidispatch_rock_t are listed in the -undeclared.txt file.
That was on gtk-doc 1.11 by the way.
Created attachment 145188 [details] [review] Patch for properly parsing unions Here's a patch.
Sorry, missed the bug and patch. Will look at it in the comming days. If you could reattach a up-to-date patch against git master - that'd make my life easier.
I'll try to get to it tomorrow. Be warned though, I don't know anything about gtk-doc's internals and I only tested the patch on my own documentation, so I can't guarantee it doesn't break something else.
Created attachment 150107 [details] [review] Patch against git master Ok, this is a patch against git master, which I have tested on my own code's documentation.
Philup, thanks for the patch. I had to modify it a bit - "make check" was failing. commit 43c15f2b4e0ba34292902292f28deca82def1a76 Author: Philip Chimento <philip.chimento@gmail.com> Date: Fri Dec 25 00:02:01 2009 +0200 parsing: have simillar support for unions like we have for structs Improve the scanner to handle unions and mkdb to output better docbook fragments. commit 1883055b9203061c30f902cbc51a74e8e5f149ab Author: Stefan Kost <ensonic@users.sf.net> Date: Fri Dec 25 00:00:02 2009 +0200 tests: add tests for union parsing (#165425)