8000 Merge pull request #42 from robotpy/fix-41 · PBCOnGit/robotpy-cppheaderparser@9a6a36e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a6a36e

Browse files
authored
Merge pull request robotpy#42 from robotpy/fix-41
Fix typedef thing
2 parents dd564dd + f19ca93 commit 9a6a36e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ def finalize_vars(self):
16851685

16861686
elif nestedTypedef:
16871687
var["fundamental"] = is_fundamental(nestedTypedef)
1688-
if not var["fundamental"]:
1688+
if not var["fundamental"] and "method" in var:
16891689
var["raw_type"] = var["method"]["path"] + "::" + tag
16901690

16911691
else:

test/test_CppHeaderParser.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,5 +3838,35 @@ def test_fn(self):
38383838
)
38393839

38403840

3841+
class NestedTypedef(unittest.TestCase):
3842+
def setUp(self):
3843+
self.cppHeader = CppHeaderParser.CppHeader(
3844+
"""
3845+
template <class SomeType> class A {
3846+
public:
3847+
typedef B <SomeType> C;
3848+
3849+
A();
3850+
3851+
protected:
3852+
C aCInstance;
3853+
};
3854+
""",
3855+
"string",
3856+
)
3857+
3858+
def test_fn(self):
3859+
c = self.cppHeader.classes["A"]
3860+
self.assertEqual("A", c["name"])
3861+
3862+
self.assertEqual(0, len(c["properties"]["public"]))
3863+
self.assertEqual(1, len(c["properties"]["protected"]))
3864+
self.assertEqual(0, len(c["properties"]["private"]))
3865+
3866+
c = c["properties"]["protected"][0]
3867+
self.assertEqual(c["name"], "aCInstance")
3868+
self.assertEqual(c["type"], "C")
3869+
3870+
38413871
if __name__ == "__main__":
38423872
unittest.main()

0 commit comments

Comments
 (0)
0