@@ -272,9 +272,6 @@ class FunctionType:
272272 return_type : "DecoratedType"
273273 parameters : typing .List ["Parameter" ]
274274
275- #: If a member function pointer
276- # TODO classname: typing.Optional[PQName]
277-
278275 #: Set to True if ends with ``...``
279276 vararg : bool = False
280277
@@ -293,6 +290,9 @@ class FunctionType:
293290 #: calling convention
294291 msvc_convention : typing .Optional [str ] = None
295292
293+ #: If a member function pointer, the class that owns the member function.
294+ classname : typing .Optional [PQName ] = None
295+
296296 def format (self ) -> str :
297297 vararg = "..." if self .vararg else ""
298298 params = ", " .join (p .format () for p in self .parameters )
@@ -379,7 +379,9 @@ def format(self) -> str:
379379 v = " volatile" if self .volatile else ""
380380 r = " __restrict__" if self .restrict else ""
381381 ptr_to = self .ptr_to
382- if isinstance (ptr_to , (Array , FunctionType )):
382+ if isinstance (ptr_to , FunctionType ) and ptr_to .classname :
383+ return ptr_to .format_decl (f"({ ptr_to .classname .format ()} ::*{ r } { c } { v } )" )
384+ elif isinstance (ptr_to , (Array , FunctionType )):
383385 return ptr_to .format_decl (f"(*{ r } { c } { v } )" )
384386 else :
385387 return f"{ ptr_to .format ()} *{ r } { c } { v } "
@@ -390,7 +392,11 @@ def format_decl(self, name: str):
390392 v = " volatile" if self .volatile else ""
391393 r = " __restrict__" if self .restrict else ""
392394 ptr_to = self .ptr_to
393- if isinstance (ptr_to , (Array , FunctionType )):
395+ if isinstance (ptr_to , FunctionType ) and ptr_to .classname :
396+ return ptr_to .format_decl (
397+ f"({ ptr_to .classname .format ()} ::*{ r } { c } { v } { name } )"
398+ )
399+ elif isinstance (ptr_to , (Array , FunctionType )):
394400 return ptr_to .format_decl (f"(*{ r } { c } { v } { name } )" )
395401 else :
396402 return f"{ ptr_to .format ()} *{ r } { c } { v } { name } "
0 commit comments