parent
6ab0d00c2f
commit
f597b691f7
@ -2307,6 +2307,9 @@ class CxxParser:
|
|||||||
|
|
||||||
cmods.validate(var_ok=False, meth_ok=False, msg="parsing conversion operator")
|
cmods.validate(var_ok=False, meth_ok=False, msg="parsing conversion operator")
|
||||||
|
|
||||||
|
# Check for any cv decorations for the type
|
||||||
|
rtype = self._parse_cv_ptr(ctype)
|
||||||
|
|
||||||
# then this must be a method
|
# then this must be a method
|
||||||
self._next_token_must_be("(")
|
self._next_token_must_be("(")
|
||||||
|
|
||||||
@ -2317,7 +2320,7 @@ class CxxParser:
|
|||||||
|
|
||||||
if self._parse_function(
|
if self._parse_function(
|
||||||
mods,
|
mods,
|
||||||
ctype,
|
rtype,
|
||||||
pqname,
|
pqname,
|
||||||
op,
|
op,
|
||||||
template,
|
template,
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
from cxxheaderparser.types import (
|
from cxxheaderparser.types import (
|
||||||
ClassDecl,
|
ClassDecl,
|
||||||
FundamentalSpecifier,
|
FundamentalSpecifier,
|
||||||
|
MoveReference,
|
||||||
NameSpecifier,
|
NameSpecifier,
|
||||||
Operator,
|
Operator,
|
||||||
|
Pointer,
|
||||||
PQName,
|
PQName,
|
||||||
Parameter,
|
Parameter,
|
||||||
Reference,
|
Reference,
|
||||||
@ -617,3 +619,75 @@ def test_conversion_operators() -> None:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_conversion_operators_decorated() -> None:
|
||||||
|
content = """
|
||||||
|
struct S {
|
||||||
|
operator const native_handle_t*() const;
|
||||||
|
operator const native_handle_t&() const;
|
||||||
|
operator const native_handle_t&&() const;
|
||||||
|
};
|
||||||
|
"""
|
||||||
|
data = parse_string(content, cleandoc=True)
|
||||||
|
|
||||||
|
assert data == ParsedData(
|
||||||
|
namespace=NamespaceScope(
|
||||||
|
classes=[
|
||||||
|
ClassScope(
|
||||||
|
class_decl=ClassDecl(
|
||||||
|
typename=PQName(
|
||||||
|
segments=[NameSpecifier(name="S")], classkey="struct"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
methods=[
|
||||||
|
Operator(
|
||||||
|
return_type=Pointer(
|
||||||
|
ptr_to=Type(
|
||||||
|
typename=PQName(
|
||||||
|
segments=[NameSpecifier(name="native_handle_t")]
|
||||||
|
),
|
||||||
|
const=True,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
name=PQName(segments=[NameSpecifier(name="operator")]),
|
||||||
|
parameters=[],
|
||||||
|
access="public",
|
||||||
|
const=True,
|
||||||
|
operator="conversion",
|
||||||
|
),
|
||||||
|
Operator(
|
||||||
|
return_type=Reference(
|
||||||
|
ref_to=Type(
|
||||||
|
typename=PQName(
|
||||||
|
segments=[NameSpecifier(name="native_handle_t")]
|
||||||
|
),
|
||||||
|
const=True,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
name=PQName(segments=[NameSpecifier(name="operator")]),
|
||||||
|
parameters=[],
|
||||||
|
access="public",
|
||||||
|
const=True,
|
||||||
|
operator="conversion",
|
||||||
|
),
|
||||||
|
Operator(
|
||||||
|
return_type=MoveReference(
|
||||||
|
moveref_to=Type(
|
||||||
|
typename=PQName(
|
||||||
|
segments=[NameSpecifier(name="native_handle_t")]
|
||||||
|
),
|
||||||
|
const=True,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
name=PQName(segments=[NameSpecifier(name="operator")]),
|
||||||
|
parameters=[],
|
||||||
|
access="public",
|
||||||
|
const=True,
|
||||||
|
operator="conversion",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user