Skip to content

Commit 420f80d

Browse files
authored
Merge pull request #134 from robotpy/ns-attr
Support attributes on namespaces
2 parents 3abac6d + 9db92ec commit 420f80d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

.github/workflows/dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
matrix:
8686
os:
8787
- windows-latest
88-
- macos-13
88+
- macos-15-intel
8989
- ubuntu-22.04
9090
python_version:
9191
- 3.7
@@ -97,7 +97,7 @@ jobs:
9797
- "3.13"
9898
architecture: [x86, x64]
9999
exclude:
100-
- os: macos-13
100+
- os: macos-15-intel
101101
architecture: x86
102102
- os: ubuntu-22.04
103103
architecture: x86

cxxheaderparser/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ def _parse_namespace(
446446

447447
while True:
448448
names.append(tok.value)
449+
450+
atok = self.lex.token_if_in_set(self._attribute_start_tokens)
451+
if atok:
452+
self._consume_attribute(atok)
453+
449454
tok = self._next_token_must_be("DBL_COLON", endtok)
450455
if tok.type == endtok:
451456
break

tests/test_namespaces.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,14 @@ def test_ns_alias_global() -> None:
195195
ns_alias=[NamespaceAlias(alias="ANS", names=["::", "my", "ns"])]
196196
)
197197
)
198+
199+
200+
def test_ns_attr() -> None:
201+
content = """
202+
namespace n __attribute__((visibility("hidden"))) {}
203+
"""
204+
data = parse_string(content, cleandoc=True)
205+
206+
assert data == ParsedData(
207+
namespace=NamespaceScope(namespaces={"n": NamespaceScope(name="n")})
208+
)

0 commit comments

Comments
 (0)