Support __declspec (and other attributes) when parsing a name
- Sometimes this will lead to accepting invalid code, but "dont do that" - Fixes #12
This commit is contained in:
@@ -5,8 +5,10 @@ from cxxheaderparser.types import (
|
||||
EnumDecl,
|
||||
Enumerator,
|
||||
Field,
|
||||
FriendDecl,
|
||||
Function,
|
||||
FundamentalSpecifier,
|
||||
Method,
|
||||
NameSpecifier,
|
||||
PQName,
|
||||
Pointer,
|
||||
@@ -146,3 +148,56 @@ def test_attributes_gcc_enum_packed():
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_friendly_declspec():
|
||||
content = """
|
||||
struct D {
|
||||
friend __declspec(dllexport) void my_friend();
|
||||
static __declspec(dllexport) void static_declspec();
|
||||
};
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
classes=[
|
||||
ClassScope(
|
||||
class_decl=ClassDecl(
|
||||
typename=PQName(
|
||||
segments=[NameSpecifier(name="D")], classkey="struct"
|
||||
)
|
||||
),
|
||||
friends=[
|
||||
FriendDecl(
|
||||
fn=Method(
|
||||
return_type=Type(
|
||||
typename=PQName(
|
||||
segments=[FundamentalSpecifier(name="void")]
|
||||
)
|
||||
),
|
||||
name=PQName(segments=[NameSpecifier(name="my_friend")]),
|
||||
parameters=[],
|
||||
access="public",
|
||||
)
|
||||
)
|
||||
],
|
||||
methods=[
|
||||
Method(
|
||||
return_type=Type(
|
||||
typename=PQName(
|
||||
segments=[FundamentalSpecifier(name="void")]
|
||||
)
|
||||
),
|
||||
name=PQName(
|
||||
segments=[NameSpecifier(name="static_declspec")]
|
||||
),
|
||||
parameters=[],
|
||||
static=True,
|
||||
access="public",
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user