From da346a5e566feb3af0dd9f254d0144bec317956d Mon Sep 17 00:00:00 2001 From: David Caron Date: Wed, 4 Aug 2021 15:13:55 -0400 Subject: [PATCH 1/2] add access property to 'using' CppVariable --- CppHeaderParser/CppHeaderParser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index 9796cea..f142278 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -1204,6 +1204,7 @@ class CppVariable(_CppVariable): * ``extern`` - True if its an extern, False if not * ``parent`` - If not None, either the class this is a property of, or the method this variable is a parameter in + * ``access`` - Anything in supportedAccessSpecifier """ Vars = [] @@ -1320,6 +1321,7 @@ def __str__(self): "desc", "line_number", "extern", + "access", ] cpy = dict((k, v) for (k, v) in list(self.items()) if k in keys_white_list) if "array_size" in self: @@ -3382,6 +3384,7 @@ def _evaluate_stack(self, token=None): else: atype["raw_type"] = ns + atype["type"] + atype["access"] = self.curAccessSpecifier if self.curClass: klass = self.classes[self.curClass] klass["using"][alias] = atype From 2dc5df5c8fd2234f47d462de6bd1e8e5034febca Mon Sep 17 00:00:00 2001 From: David Caron Date: Thu, 5 Aug 2021 10:00:23 -0400 Subject: [PATCH 2/2] add test for access property on 'using' --- test/test_CppHeaderParser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index 514cc48..c454a32 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -4015,6 +4015,7 @@ def setUp(self): self.cppHeader = CppHeaderParser.CppHeader( """ template class P { +using A = typename f::TP::A; public: using State = typename f::TP::S; P(State st); @@ -4026,9 +4027,15 @@ def setUp(self): def test_fn(self): c = self.cppHeader.classes["P"] self.assertEqual("P", c["name"]) + self.assertEqual(len(c["using"]), 2) state = c["using"]["State"] self.assertEqual(state["raw_type"], "typename f::TP::S") self.assertEqual(state["type"], "typename TP::S") + self.assertEqual(state["access"], "public") + private = c["using"]["A"] + self.assertEqual(private["raw_type"], "typename f::TP::A") + self.assertEqual(private["type"], "typename TP::A") + self.assertEqual(private["access"], "private") m = c["methods"]["public"][0] self.assertEqual(m["name"], "P")