Skip to content

Commit

Permalink
SourceForge bug 61
Browse files Browse the repository at this point in the history
Add support for C++11 enum type specification with "enum <enum_name> : <type> ..."
  • Loading branch information
senex committed Sep 6, 2016
1 parent c6f9039 commit c47efae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CppHeaderParser/CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,12 @@ def __init__(self, nameStack):
preBraceStack = nameStack[:nameStack.index("{")]
postBraceStack = nameStack[nameStack.index("}") + 1:]
self["typedef"] = False
if (len(preBraceStack) == 2 and "typedef" not in nameStack):
if (len(preBraceStack) == 4 and ":" in nameStack and "typedef" not in nameStack):
# C++11 specify enum type with "enum <enum_name> : <type> ..." syntax
self["name"] = preBraceStack[1]
self["type"] = preBraceStack[3]
elif (len(preBraceStack) == 2 and "typedef" not in nameStack):
# enum "enum <enum_name> ..." syntax
self["name"] = preBraceStack[1]
elif len(postBraceStack) and "typedef" in nameStack:
self["name"] = " ".join(postBraceStack)
Expand Down
12 changes: 11 additions & 1 deletion CppHeaderParser/test/TestSampleClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,4 +743,14 @@ typedef struct Fig {
// BitBucket bug 27
union olive {
int x;
};
};

// Sourceforge bug 61
typedef struct
{
enum BeetEnum : int
{
FAIL = 0,
PASS = 1
};
} BeetStruct;
12 changes: 12 additions & 0 deletions CppHeaderParser/test/test_CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,18 @@ def test_Olive_exists(self):
def test_union_member_x(self):
cmp_values = {'constant': 0, 'name': 'x', 'reference': 0, 'type': 'int', 'static': 0, 'pointer': 0}
self.assertEqual(filter_dict_keys(self.cppHeader.classes["union olive"]["members"][0], cmp_values.keys()), cmp_values)

# BitBucket bug 61
class Beet_TestCase(unittest.TestCase):

def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader("TestSampleClass.h")

def test_Beet_exists(self):
self.assertEqual(self.cppHeader.classes.has_key("BeetStruct"), True)

def test_BeetEnum_exists(self):
self.assertEqual(self.cppHeader.classes["BeetStruct"]["enums"]["public"][0]["name"], "BeetEnum")



Expand Down

0 comments on commit c47efae

Please sign in to comment.