Skip to content

Commit c49b1e5

Browse files
committed
Add missing typedef
1 parent c729db0 commit c49b1e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cxxheaderparser/types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,16 @@ class Reference:
367367
"""
368368

369369
ref_to: typing.Union[Array, FunctionType, Pointer, Type]
370+
restrict: bool = False
370371

371372
def format(self) -> str:
372373
ref_to = self.ref_to
374+
373375
if isinstance(ref_to, Array):
374376
return ref_to.format_decl("(&)")
375377
else:
376-
return f"{ref_to.format()}&"
378+
r = " __restrict__" if self.restrict else ""
379+
return f"{ref_to.format()}& {r}"
377380

378381
def format_decl(self, name: str):
379382
"""Format as a named declaration"""
@@ -382,7 +385,8 @@ def format_decl(self, name: str):
382385
if isinstance(ref_to, Array):
383386
return ref_to.format_decl(f"(& {name})")
384387
else:
385-
return f"{ref_to.format()}& {name}"
388+
r = " __restrict__" if self.restrict else ""
389+
return f"{ref_to.format()}& {r} {name}"
386390

387391

388392
@dataclass

0 commit comments

Comments
 (0)