Error When parsing an enum containing other enum value

Bug #1315708 reported by LIBERADO
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyclibrary
New
Undecided
Unassigned

Bug Description

Hello !
Thanks for this simple parser, that help me to create quickly documentation on enums used as errcode and parameter id. I do believe that I'll be able to make a simple multiplatform tool.

Whith the following header content to parse :
//------------------------
typedef enum
{
 one,
 two,
 lastFromType1
} type1 ;
typedef enum
{
 three = lastFromType1,
 four,
 five
} type1 ;
//------------------------

I've got a KeyError on 'lastFromType1', four and five is not parsed.

Analysis : in function "def processEnum(self, s, l, t)"
...
if v.valueName != '':
                            i = enum[v.valueName]
...

The problem is that the search is done within the current enum values only.

Solution : catch the KeyError exception to search in file global values.
Implementation suggestion :
I added "def getValueDef('values', v.valueName)" based on "addDef"

Modify the processEnum line with :
                    if v.valueName != '':
                        try:
                            i = enum[v.valueName]
                        except KeyError:
                            # the value may come from another enum
                            i = self.getValueDef('values', v.valueName)

I'll try to send a patch soonely.
Thanks.

Revision history for this message
LIBERADO (business-man-fr) wrote :

OK I bzr made quickly the patch for me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.