@@ -1770,6 +1770,16 @@ def spelling(self):
1770
1770
1771
1771
return self ._spelling
1772
1772
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
+
1773
1783
@property
1774
1784
def displayname (self ):
1775
1785
"""
@@ -3685,6 +3695,72 @@ def write_main_file_to_stdout(self):
3685
3695
conf .lib .clang_CXRewriter_writeMainFileToStdOut (self )
3686
3696
3687
3697
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
+
3688
3764
# Now comes the plumbing to hook up the C library.
3689
3765
3690
3766
# Register callback types
@@ -3787,6 +3863,8 @@ def write_main_file_to_stdout(self):
3787
3863
("clang_getCursorExtent" , [Cursor ], SourceRange ),
3788
3864
("clang_getCursorLexicalParent" , [Cursor ], Cursor ),
3789
3865
("clang_getCursorLocation" , [Cursor ], SourceLocation ),
3866
+ ("clang_getCursorPrettyPrinted" , [Cursor , PrintingPolicy ], _CXString ),
3867
+ ("clang_getCursorPrintingPolicy" , [Cursor ], c_object_p ),
3790
3868
("clang_getCursorReferenced" , [Cursor ], Cursor ),
3791
3869
("clang_getCursorReferenceNameRange" , [Cursor , c_uint , c_uint ], SourceRange ),
3792
3870
("clang_getCursorResultType" , [Cursor ], Type ),
@@ -3909,6 +3987,9 @@ def write_main_file_to_stdout(self):
3909
3987
("clang_Cursor_getRawCommentText" , [Cursor ], _CXString ),
3910
3988
("clang_Cursor_getOffsetOfField" , [Cursor ], c_longlong ),
3911
3989
("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 ]),
3912
3993
("clang_Type_getAlignOf" , [Type ], c_longlong ),
3913
3994
("clang_Type_getClassType" , [Type ], Type ),
3914
3995
("clang_Type_getNumTemplateArguments" , [Type ], c_int ),
@@ -4089,6 +4170,8 @@ def function_exists(self, name: str) -> bool:
4089
4170
"FixIt" ,
4090
4171
"Index" ,
4091
4172
"LinkageKind" ,
4173
+ "PrintingPolicy" ,
4174
+ "PrintingPolicyProperty" ,
4092
4175
"RefQualifierKind" ,
4093
4176
"SourceLocation" ,
4094
4177
"SourceRange" ,
0 commit comments