@@ -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
"""
@@ -3699,6 +3709,72 @@ def write_main_file_to_stdout(self):
3699
3709
conf .lib .clang_CXRewriter_writeMainFileToStdOut (self )
3700
3710
3701
3711
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
+
3702
3778
# Now comes the plumbing to hook up the C library.
3703
3779
3704
3780
# Register callback types
@@ -3801,6 +3877,8 @@ def write_main_file_to_stdout(self):
3801
3877
("clang_getCursorExtent" , [Cursor ], SourceRange ),
3802
3878
("clang_getCursorLexicalParent" , [Cursor ], Cursor ),
3803
3879
("clang_getCursorLocation" , [Cursor ], SourceLocation ),
3880
+ ("clang_getCursorPrettyPrinted" , [Cursor , PrintingPolicy ], _CXString ),
3881
+ ("clang_getCursorPrintingPolicy" , [Cursor ], c_object_p ),
3804
3882
("clang_getCursorReferenced" , [Cursor ], Cursor ),
3805
3883
("clang_getCursorReferenceNameRange" , [Cursor , c_uint , c_uint ], SourceRange ),
3806
3884
("clang_getCursorResultType" , [Cursor ], Type ),
@@ -3924,6 +4002,9 @@ def write_main_file_to_stdout(self):
3924
4002
("clang_Cursor_isAnonymousRecordDecl" , [Cursor ], bool ),
3925
4003
("clang_Cursor_isBitField" , [Cursor ], bool ),
3926
4004
("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 ]),
3927
4008
("clang_Type_getAlignOf" , [Type ], c_longlong ),
3928
4009
("clang_Type_getClassType" , [Type ], Type ),
3929
4010
("clang_Type_getNumTemplateArguments" , [Type ], c_int ),
@@ -4104,6 +4185,8 @@ def function_exists(self, name: str) -> bool:
4104
4185
"FixIt" ,
4105
4186
"Index" ,
4106
4187
"LinkageKind" ,
4188
+ "PrintingPolicy" ,
4189
+ "PrintingPolicyProperty" ,
4107
4190
"RefQualifierKind" ,
4108
4191
"SourceLocation" ,
4109
4192
"SourceRange" ,
0 commit comments