Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add access property to 'using' CppVariable #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CppHeaderParser/CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/test_CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4015,6 +4015,7 @@ def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
"""
template <class D> class P {
using A = typename f::TP<D>::A;
public:
using State = typename f::TP<D>::S;
P(State st);
Expand All @@ -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<D >::S")
self.assertEqual(state["type"], "typename TP<D >::S")
self.assertEqual(state["access"], "public")
private = c["using"]["A"]
self.assertEqual(private["raw_type"], "typename f::TP<D >::A")
self.assertEqual(private["type"], "typename TP<D >::A")
self.assertEqual(private["access"], "private")

m = c["methods"]["public"][0]
self.assertEqual(m["name"], "P")
Expand Down