From 0fb4eff2c4e2e4a6769b717665b1fccdc59c9d4e Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Mon, 27 May 2024 23:44:02 -0400 Subject: [PATCH 1/2] Add support for 'using enum' - Fixes #93 --- cxxheaderparser/parser.py | 4 ++- tests/test_using.py | 61 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/cxxheaderparser/parser.py b/cxxheaderparser/parser.py index 5bef044..90a7d75 100644 --- a/cxxheaderparser/parser.py +++ b/cxxheaderparser/parser.py @@ -1041,7 +1041,9 @@ def _parse_using( ) -> None: self.state.location = tok.location - tok = self._next_token_must_be("NAME", "DBL_COLON", "namespace", "typename") + tok = self._next_token_must_be( + "NAME", "DBL_COLON", "namespace", "typename", "enum" + ) if tok.type == "namespace": if template: diff --git a/tests/test_using.py b/tests/test_using.py index 06a355f..de25763 100644 --- a/tests/test_using.py +++ b/tests/test_using.py @@ -716,3 +716,64 @@ def test_using_typename_in_class() -> None: ] ) ) + + +def test_using_enum_global() -> None: + content = """ + namespace A { + using enum B::C; + } + """ + data = parse_string(content, cleandoc=True) + + assert data == ParsedData( + namespace=NamespaceScope( + namespaces={ + "A": NamespaceScope( + name="A", + using=[ + UsingDecl( + typename=PQName( + segments=[ + NameSpecifier(name="B"), + NameSpecifier(name="C"), + ], + classkey="enum", + ) + ) + ], + ) + } + ) + ) + + +def test_using_enum_in_struct() -> None: + content = """ + struct S { + using enum fruit; + }; + """ + data = parse_string(content, cleandoc=True) + + assert data == ParsedData( + namespace=NamespaceScope( + classes=[ + ClassScope( + class_decl=ClassDecl( + typename=PQName( + segments=[NameSpecifier(name="S")], classkey="struct" + ) + ), + using=[ + UsingDecl( + typename=PQName( + segments=[NameSpecifier(name="fruit")], classkey="enum" + ), + access="public", + ) + ], + ) + ] + ) + ) From 4d1f1847de244e5d79d90684b805b61659594c40 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Mon, 27 May 2024 23:45:57 -0400 Subject: [PATCH 2/2] Fix github actions --- .github/workflows/dist.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 33c3749..175b6e2 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -83,11 +83,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-20.04] + os: [windows-latest, macos-13, ubuntu-20.04] python_version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] architecture: [x86, x64] exclude: - - os: macos-latest + - os: macos-13 architecture: x86 - os: ubuntu-20.04 architecture: x86