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 165425 - gtk-doc fails to parse unions
gtk-doc fails to parse unions
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
1.4
Other Linux
: Normal normal
: 1.14
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2005-01-27 17:48 UTC by Roger Leigh
Modified: 2009-12-24 22:07 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Patch for properly parsing unions (8.43 KB, patch)
2009-10-09 23:18 UTC, Philip Chimento
none Details | Review
Patch against git master (10.67 KB, patch)
2009-12-20 13:46 UTC, Philip Chimento
none Details | Review

Description Roger Leigh 2005-01-27 17:48:06 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
Comment 1 Damon Chaplin 2005-01-31 23:48:40 UTC
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.
Comment 2 Brent Smith (smitten) 2005-07-19 21:08:07 UTC
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.
Comment 3 Philip Chimento 2009-10-09 18:34:55 UTC
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.
Comment 4 Philip Chimento 2009-10-09 18:35:47 UTC
That was on gtk-doc 1.11 by the way.
Comment 5 Philip Chimento 2009-10-09 23:18:14 UTC
Created attachment 145188 [details] [review]
Patch for properly parsing unions

Here's a patch.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2009-12-19 20:40:16 UTC
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.
Comment 7 Philip Chimento 2009-12-19 22:52:37 UTC
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.
Comment 8 Philip Chimento 2009-12-20 13:46:01 UTC
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.
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2009-12-24 22:07:18 UTC
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)