8000 Fix base classes with namespaces by virtuald · Pull Request #40 · robotpy/robotpy-cppheaderparser · GitHub
[go: up one dir, main page]

Skip to content

Fix base classes with namespaces #40

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 1 commit into from
Mar 4, 2020
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
13 changes: 10 additions & 3 deletions CppHeaderParser/CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def _fix_classname(self):
if self["..."]:
s += "..."

self["class"] = s
return s


def _consume_parens(stack):
Expand Down Expand Up @@ -564,7 +564,14 @@ def _parse_cpp_base(stack, default_access):
continue

if require_ending:
raise CppParseError("expected comma, found '%s'" % t)
if t == "::":
if "decl_params" in base:
base["decl_name"] = base._fix_classname()
del base["decl_params"]
base["..."]
require_ending = False
else:
raise CppParseError("expected comma, found '%s'" % t)

if t == "(":
s = stack[i:]
Expand All @@ -585,7 +592,7 @@ def _parse_cpp_base(stack, default_access):
# backwards compat
inherits.append(base)
for base in inherits:
base._fix_classname()
base["class"] = base._fix_classname()

return inherits

Expand Down
29 changes: 29 additions & 0 deletions test/test_CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,7 @@ def test_fn(self):
self.assertEqual(props[0]["name"], "x")
self.assertEqual(props[1]["name"], "y")


class Deleted_TestCase(unittest.TestCase):
def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
Expand All @@ -3809,5 +3810,33 @@ def test_fn(self):
self.assertEqual(m["constructor"], True)
self.assertEqual(m["deleted"], True)


class BaseTemplateNs_TestCase(unittest.TestCase):
def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
"""
class A : public B<int, int>::C {};
""",
"string",
)

def test_fn(self):
c = self.cppHeader.classes["A"]
self.assertEqual("A", c["name"])
self.assertEqual(
[
{
"access": "public",
"class": "B<int,int>::C",
"decl_name": "B<int,int>::C",
"virtual": False,
"...": False,
"decltype": False,
}
],
c["inherits"],
)


if __name__ == "__main__":
unittest.main()
0