Merge pull request #70 from robotpy/fwd-template-method
Allow forward declared template methods
This commit is contained in:
commit
0280e8d7e1
@ -1864,7 +1864,8 @@ class CxxParser:
|
|||||||
self.visitor.on_class_method(state, method)
|
self.visitor.on_class_method(state, method)
|
||||||
else:
|
else:
|
||||||
assert isinstance(state, (ExternBlockState, NamespaceBlockState))
|
assert isinstance(state, (ExternBlockState, NamespaceBlockState))
|
||||||
if not method.has_body:
|
# only template specializations can be declared without a body here
|
||||||
|
if not method.has_body and not method.template:
|
||||||
raise self._parse_error(None, expected="Method body")
|
raise self._parse_error(None, expected="Method body")
|
||||||
self.visitor.on_method_impl(state, method)
|
self.visitor.on_method_impl(state, method)
|
||||||
|
|
||||||
|
@ -1987,3 +1987,43 @@ def test_extern_template() -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fwd_declared_method() -> None:
|
||||||
|
content = """
|
||||||
|
// forward declaration for specialized template function
|
||||||
|
template <> Clazz<A>::Clazz();
|
||||||
|
"""
|
||||||
|
data = parse_string(content, cleandoc=True)
|
||||||
|
|
||||||
|
assert data == ParsedData(
|
||||||
|
namespace=NamespaceScope(
|
||||||
|
method_impls=[
|
||||||
|
Method(
|
||||||
|
return_type=None,
|
||||||
|
name=PQName(
|
||||||
|
segments=[
|
||||||
|
NameSpecifier(
|
||||||
|
name="Clazz",
|
||||||
|
specialization=TemplateSpecialization(
|
||||||
|
args=[
|
||||||
|
TemplateArgument(
|
||||||
|
arg=Type(
|
||||||
|
typename=PQName(
|
||||||
|
segments=[NameSpecifier(name="A")]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
NameSpecifier(name="Clazz"),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
parameters=[],
|
||||||
|
template=TemplateDecl(),
|
||||||
|
constructor=True,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user