@@ -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 """
@@ -3699,6 +3709,72 @@ def write_main_file_to_stdout(self):
36993709 conf .lib .clang_CXRewriter_writeMainFileToStdOut (self )
37003710
37013711
3712+ class PrintingPolicyProperty (BaseEnumeration ):
3713+
3714+ """
3715+ A PrintingPolicyProperty identifies a property of a PrintingPolicy.
3716+ """
3717+
3718+ Indentation = 0
3719+ SuppressSpecifiers = 1
3720+ SuppressTagKeyword = 2
3721+ IncludeTagDefinition = 3
3722+ SuppressScope = 4
3723+ SuppressUnwrittenScope = 5
3724+ SuppressInitializers = 6
3725+ ConstantArraySizeAsWritten = 7
3726+ AnonymousTagLocations = 8
3727+ SuppressStrongLifetime = 9
3728+ SuppressLifetimeQualifiers = 10
3729+ SuppressTemplateArgsInCXXConstructors = 11
3730+ Bool = 12
3731+ Restrict = 13
3732+ Alignof = 14
3733+ UnderscoreAlignof = 15
3734+ UseVoidForZeroParams = 16
3735+ TerseOutput = 17
3736+ PolishForDeclaration = 18
3737+ Half = 19
3738+ MSWChar = 20
3739+ IncludeNewlines = 21
3740+ MSVCFormatting = 22
3741+ ConstantsAsWritten = 23
3742+ SuppressImplicitBase = 24
3743+ FullyQualifiedName = 25
3744+
3745+
3746+ class PrintingPolicy (ClangObject ):
3747+ """
3748+ The PrintingPolicy is a wrapper class around clang::PrintingPolicy
3749+
3750+ It allows specifying how declarations, expressions, and types should be
3751+ pretty-printed.
3752+ """
3753+
3754+ @staticmethod
3755+ def create (cursor ):
3756+ """
3757+ Creates a new PrintingPolicy
3758+ Parameters:
3759+ cursor -- Any cursor for a translation unit.
3760+ """
3761+ return PrintingPolicy (conf .lib .clang_getCursorPrintingPolicy (cursor ))
3762+
3763+ def __init__ (self , ptr ):
3764+ ClangObject .__init__ (self , ptr )
3765+
3766+ def __del__ (self ):
3767+ conf .lib .clang_PrintingPolicy_dispose (self )
3768+
3769+ def get_property (self , property ):
3770+ """Get a property value for the given printing policy."""
3771+ return conf .lib .clang_PrintingPolicy_getProperty (self , property .value )
3772+
3773+ def set_property (self , property , value ):
3774+ """Set a property value for the given printing policy."""
3775+ conf .lib .clang_PrintingPolicy_setProperty (self , property .value , value )
3776+
3777+
37023778# Now comes the plumbing to hook up the C library.
37033779
37043780# Register callback types
@@ -3801,6 +3877,8 @@ def write_main_file_to_stdout(self):
38013877 ("clang_getCursorExtent" , [Cursor ], SourceRange ),
38023878 ("clang_getCursorLexicalParent" , [Cursor ], Cursor ),
38033879 ("clang_getCursorLocation" , [Cursor ], SourceLocation ),
3880+ ("clang_getCursorPrettyPrinted" , [Cursor , PrintingPolicy ], _CXString ),
3881+ ("clang_getCursorPrintingPolicy" , [Cursor ], c_object_p ),
38043882 ("clang_getCursorReferenced" , [Cursor ], Cursor ),
38053883 ("clang_getCursorReferenceNameRange" , [Cursor , c_uint , c_uint ], SourceRange ),
38063884 ("clang_getCursorResultType" , [Cursor ], Type ),
@@ -3924,6 +4002,9 @@ def write_main_file_to_stdout(self):
39244002 ("clang_Cursor_isAnonymousRecordDecl" , [Cursor ], bool ),
39254003 ("clang_Cursor_isBitField" , [Cursor ], bool ),
39264004 ("clang_Location_isInSystemHeader" , [SourceLocation ], bool ),
4005+ ("clang_PrintingPolicy_dispose" , [PrintingPolicy ]),
4006+ ("clang_PrintingPolicy_getProperty" , [PrintingPolicy , c_int ], c_uint ),
4007+ ("clang_PrintingPolicy_setProperty" , [PrintingPolicy , c_int , c_uint ]),
39274008 ("clang_Type_getAlignOf" , [Type ], c_longlong ),
39284009 ("clang_Type_getClassType" , [Type ], Type ),
39294010 ("clang_Type_getNumTemplateArguments" , [Type ], c_int ),
@@ -4104,6 +4185,8 @@ def function_exists(self, name: str) -> bool:
41044185 "FixIt" ,
41054186 "Index" ,
41064187 "LinkageKind" ,
4188+ "PrintingPolicy" ,
4189+ "PrintingPolicyProperty" ,
41074190 "RefQualifierKind" ,
41084191 "SourceLocation" ,
41094192 "SourceRange" ,
0 commit comments