Add support for parsing method implementations outside of a class
- Fixes #10
This commit is contained in:
@@ -1909,8 +1909,8 @@ def test_class_fn_inline_impl() -> None:
|
||||
],
|
||||
)
|
||||
],
|
||||
functions=[
|
||||
Function(
|
||||
method_impls=[
|
||||
Method(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="void")])
|
||||
),
|
||||
@@ -2109,8 +2109,8 @@ def test_class_fn_return_class() -> None:
|
||||
],
|
||||
),
|
||||
],
|
||||
functions=[
|
||||
Function(
|
||||
method_impls=[
|
||||
Method(
|
||||
return_type=Pointer(
|
||||
ptr_to=Type(
|
||||
typename=PQName(
|
||||
@@ -2198,8 +2198,8 @@ def test_class_fn_template_impl() -> None:
|
||||
],
|
||||
)
|
||||
],
|
||||
functions=[
|
||||
Function(
|
||||
method_impls=[
|
||||
Method(
|
||||
return_type=Pointer(
|
||||
ptr_to=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="int")])
|
||||
@@ -2265,8 +2265,8 @@ def test_class_fn_inline_template_impl() -> None:
|
||||
],
|
||||
)
|
||||
],
|
||||
functions=[
|
||||
Function(
|
||||
method_impls=[
|
||||
Method(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[NameSpecifier(name="T")])
|
||||
),
|
||||
@@ -3212,3 +3212,27 @@ def test_class_ref_qualifiers() -> None:
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_method_outside_class() -> None:
|
||||
content = """
|
||||
int foo::bar() { return 1; }
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
method_impls=[
|
||||
Method(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="int")])
|
||||
),
|
||||
name=PQName(
|
||||
segments=[NameSpecifier(name="foo"), NameSpecifier(name="bar")]
|
||||
),
|
||||
parameters=[],
|
||||
has_body=True,
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user