@@ -76,20 +76,26 @@ def __init__(self, cursor):
7676 self .return_type : Type = Type (cursor .type .get_result ())
7777 self .arguments : List [FunctionArgument ] = []
7878 self .annotations : List [str ] = _get_annotations (cursor )
79+ self .is_constexpr : bool = "constexpr" in [t .spelling for t in cursor .get_tokens ()]
7980
8081 for t , n in zip (argument_types , arguments , strict = False ):
8182 self .arguments .append (FunctionArgument (t , n ))
8283
83- def __repr__ (self ) -> str :
84+ def __str__ (self ) -> str :
8485 r = "{} {}({})" .format (
8586 self .return_type .name ,
8687 str (self .name ),
8788 ", " .join ([a .type .name for a in self .arguments ]),
8889 )
90+ if self .is_constexpr :
91+ r = "constexpr " + r
8992 if self .is_noexcept :
9093 r = r + " noexcept"
9194 return r
9295
96+ def __repr__ (self ) -> str :
97+ return self .__str__ ()
98+
9399
94100class Function (_Function ):
95101 def __init__ (self , cursor , namespaces : list [str ] | None = None ):
@@ -100,10 +106,13 @@ def __init__(self, cursor, namespaces: list[str] | None = None):
100106 if self .namespace :
101107 self .qualified_name = "::" .join ([self .namespace , self .name ])
102108
103- def __repr__ (self ) -> str :
104- s = _Function .__repr__ (self )
109+ def __str__ (self ) -> str :
110+ s = _Function .__str__ (self )
105111 return "<xyz.cppmodel.Function {}>" .format (s )
106112
113+ def __repr__ (self ) -> str :
114+ return self .__str__ ()
115+
107116 def __eq__ (self , f ) -> bool :
108117 if self .name != f .name :
109118 return False
@@ -125,8 +134,8 @@ def __init__(self, cursor):
125134 self .is_pure_virtual : bool = cursor .is_pure_virtual_method ()
126135 self .is_public : bool = cursor .access_specifier == AccessSpecifier .PUBLIC
127136
128- def __repr__ (self ) -> str :
129- s = _Function .__repr__ (self )
137+ def __str__ (self ) -> str :
138+ s = _Function .__str__ (self )
130139 if self .is_const :
131140 s = "{} const" .format (s )
132141 if self .is_pure_virtual :
@@ -135,6 +144,9 @@ def __repr__(self) -> str:
135144 s = "virtual {}" .format (s )
136145 return "<xyz.cppmodel.Method {}>" .format (s )
137146
147+ def __repr__ (self ) -> str :
148+ return self .__str__ ()
149+
138150
139151class Class :
140152 def __init__ (self , cursor : Cursor , namespaces : List [str ]):
0 commit comments