@@ -1770,6 +1770,16 @@ def spelling(self):
17701770
17711771 return self ._spelling
17721772
1773+ def pretty_printed (self , policy ):
1774+ """
1775+ Pretty print declarations.
1776+ Parameters:
1777+ policy -- The policy to control the entities being printed.
1778+ """
1779+ return _CXString .from_result (
1780+ conf .lib .clang_getCursorPrettyPrinted (self , policy )
1781+ )
1782+
17731783 @property
17741784 def displayname (self ):
17751785 """
@@ -3685,6 +3695,72 @@ def write_main_file_to_stdout(self):
36853695 conf .lib .clang_CXRewriter_writeMainFileToStdOut (self )
36863696
36873697
3698+ class PrintingPolicyProperty (BaseEnumeration ):
3699+
3700+ """
3701+ A PrintingPolicyProperty identifies a property of a PrintingPolicy.
3702+ """
3703+
3704+ Indentation = 0
3705+ SuppressSpecifiers = 1
3706+ SuppressTagKeyword = 2
3707+ IncludeTagDefinition = 3
3708+ SuppressScope = 4
3709+ SuppressUnwrittenScope = 5
3710+ SuppressInitializers = 6
3711+ ConstantArraySizeAsWritten = 7
3712+ AnonymousTagLocations = 8
3713+ SuppressStrongLifetime = 9
3714+ SuppressLifetimeQualifiers = 10
3715+ SuppressTemplateArgsInCXXConstructors = 11
3716+ Bool = 12
3717+ Restrict = 13
3718+ Alignof = 14
3719+ UnderscoreAlignof = 15
3720+ UseVoidForZeroParams = 16
3721+ TerseOutput = 17
3722+ PolishForDeclaration = 18
3723+ Half = 19
3724+ MSWChar = 20
3725+ IncludeNewlines = 21
3726+ MSVCFormatting = 22
3727+ ConstantsAsWritten = 23
3728+ SuppressImplicitBase = 24
3729+ FullyQualifiedName = 25
3730+
3731+
3732+ class PrintingPolicy (ClangObject ):
3733+ """
3734+ The PrintingPolicy is a wrapper class around clang::PrintingPolicy
3735+
3736+ It allows specifying how declarations, expressions, and types should be
3737+ pretty-printed.
3738+ """
3739+
3740+ @staticmethod
3741+ def create (cursor ):
3742+ """
3743+ Creates a new PrintingPolicy
3744+ Parameters:
3745+ cursor -- Any cursor for a translation unit.
3746+ """
3747+ return PrintingPolicy (conf .lib .clang_getCursorPrintingPolicy (cursor ))
3748+
3749+ def __init__ (self , ptr ):
3750+ ClangObject .__init__ (self , ptr )
3751+
3752+ def __del__ (self ):
3753+ conf .lib .clang_PrintingPolicy_dispose (self )
3754+
3755+ def get_property (self , property ):
3756+ """Get a property value for the given printing policy."""
3757+ return conf .lib .clang_PrintingPolicy_getProperty (self , property .value )
3758+
3759+ def set_property (self , property , value ):
3760+ """Set a property value for the given printing policy."""
3761+ conf .lib .clang_PrintingPolicy_setProperty (self , property .value , value )
3762+
3763+
36883764# Now comes the plumbing to hook up the C library.
36893765
36903766# Register callback types
@@ -3787,6 +3863,8 @@ def write_main_file_to_stdout(self):
37873863 ("clang_getCursorExtent" , [Cursor ], SourceRange ),
37883864 ("clang_getCursorLexicalParent" , [Cursor ], Cursor ),
37893865 ("clang_getCursorLocation" , [Cursor ], SourceLocation ),
3866+ ("clang_getCursorPrettyPrinted" , [Cursor , PrintingPolicy ], _CXString ),
3867+ ("clang_getCursorPrintingPolicy" , [Cursor ], c_object_p ),
37903868 ("clang_getCursorReferenced" , [Cursor ], Cursor ),
37913869 ("clang_getCursorReferenceNameRange" , [Cursor , c_uint , c_uint ], SourceRange ),
37923870 ("clang_getCursorResultType" , [Cursor ], Type ),
@@ -3909,6 +3987,9 @@ def write_main_file_to_stdout(self):
39093987 ("clang_Cursor_getRawCommentText" , [Cursor ], _CXString ),
39103988 ("clang_Cursor_getOffsetOfField" , [Cursor ], c_longlong ),
39113989 ("clang_Location_isInSystemHeader" , [SourceLocation ], bool ),
3990+ ("clang_PrintingPolicy_dispose" , [PrintingPolicy ]),
3991+ ("clang_PrintingPolicy_getProperty" , [PrintingPolicy , c_int ], c_uint ),
3992+ ("clang_PrintingPolicy_setProperty" , [PrintingPolicy , c_int , c_uint ]),
39123993 ("clang_Type_getAlignOf" , [Type ], c_longlong ),
39133994 ("clang_Type_getClassType" , [Type ], Type ),
39143995 ("clang_Type_getNumTemplateArguments" , [Type ], c_int ),
@@ -4089,6 +4170,8 @@ def function_exists(self, name: str) -> bool:
40894170 "FixIt" ,
40904171 "Index" ,
40914172 "LinkageKind" ,
4173+ "PrintingPolicy" ,
4174+ "PrintingPolicyProperty" ,
40924175 "RefQualifierKind" ,
40934176 "SourceLocation" ,
40944177 "SourceRange" ,
0 commit comments