Skip to content

Commit

Permalink
Merge pull request #106 from robotpy/delete-anything
Browse files Browse the repository at this point in the history
Any function can be deleted, support that
  • Loading branch information
virtuald authored Sep 28, 2024
2 parents d8f8bd0 + 476e989 commit 5ed4baf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cxxheaderparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,11 @@ def _parse_fn_end(self, fn: Function) -> None:
if self.lex.token_if("{"):
self._discard_contents("{", "}")
fn.has_body = True
elif self.lex.token_if("="):
if self.lex.token_if_val("delete"):
fn.deleted = True
else:
raise self._parse_error(None, "expected 'delete")

def _parse_method_end(self, method: Method) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion cxxheaderparser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ class Function:
extern: typing.Union[bool, str] = False
static: bool = False
inline: bool = False
deleted: bool = False

#: If true, the body of the function is present
has_body: bool = False
Expand Down Expand Up @@ -764,7 +765,6 @@ class Method(Function):
constructor: bool = False
explicit: bool = False
default: bool = False
deleted: bool = False

destructor: bool = False

Expand Down
22 changes: 22 additions & 0 deletions tests/test_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,3 +1313,25 @@ def test_msvc_inline() -> None:
]
)
)


def test_deleted_function() -> None:
content = """
void trim() = delete;
"""
data = parse_string(content, cleandoc=True)

assert data == ParsedData(
namespace=NamespaceScope(
functions=[
Function(
return_type=Type(
typename=PQName(segments=[FundamentalSpecifier(name="void")])
),
name=PQName(segments=[NameSpecifier(name="trim")]),
parameters=[],
deleted=True,
)
]
)
)

0 comments on commit 5ed4baf

Please sign in to comment.