1
2
3
4
5
6 """defines base class for all code generator configuration classes"""
7
8 import algorithm
9 from pyplusplus import _logging_
10 from pygccxml import declarations
11 from pyplusplus import messages
67
90 alias = property( _get_alias, _set_alias
91 , doc="the name under which, Python will know the declaration" )
92
94 """give new name to the declaration, under which Python will know the declaration"""
95 self.alias = new_name
96
101 ignore = property( _get_ignore, _set_ignore
102 , doc="boolean flag, which says whether to export declaration to Python or not" )
103
105 return self._already_exposed
107 self._already_exposed = value
108 already_exposed = property( get_already_exposed, set_already_exposed
109 , doc="boolean flag, which says whether the declaration is already exposed or not" )
110
111 - def exclude( self, compilation_errors=False ):
112 """exclude "self" and child declarations from being exposed.
113
114 If compile_time_errors is True, than only declarations, which will cause
115 compilation error will be excluded
116 """
117 self.ignore = True
118
119 - def include( self, already_exposed=False ):
123
125 """return the reason( string ) that explains why this declaration could not be exported
126
127 If declaration could be exported, than method will return None
128 """
129 if None is self._exportable_reason:
130 self.get_exportable()
131 return self._exportable_reason
132
135
151 """change "exportable" status
152
153 This function should be use in case Py++ made a mistake and signed the
154 declaration as unexportable."""
155 self._exportable = exportable
156
157 exportable = property( get_exportable, set_exportable
158 , doc="Returns True if declaration could be exported to Python, otherwise False" )
159
162
163 - def readme( self, skip_ignored=True ):
164 """return important information( hints/tips/warning message ) Py++ has about
165 this declaration.
166
167 skip_ignored argument allows you to control the information reported to you.
168 For more information please read: http://www.language-binding.net/pyplusplus/documentation/warnings.html
169 """
170 msgs = []
171 if not self.exportable:
172 msgs.append( self.why_not_exportable() )
173
174 if declarations.templates.is_instantiation( self.name ) \
175 and self.alias == self._generate_valid_name():
176 msgs.append( messages.W1043 % self.alias )
177
178 directives = self.__select_alias_directives(be_smart=False)
179 if 1 < len( directives ):
180 msgs.append( messages.W1048
181 % ( self.alias, ', '.join( map( lambda typedef: typedef.name, directives ) ) ) )
182
183 msgs.extend( self._readme_impl() )
184
185 return messages.filter_disabled_msgs( msgs, self.__msgs_to_ignore )
186
187 @property
189 """list of messages to ignore"""
190 return self.__msgs_to_ignore
191 disabled_messaged = disabled_messages
192
194 """set messages, which should not be reported to you
195
196 Usage example: decl.disable_messages( messages.W1001, messages.W1040 )
197 """
198 for msg in args:
199 msg_id = messages.find_out_message_id( msg )
200 if not msg_id:
201 raise RuntimeError( "Unable to find out message id. The message is: " + msg )
202 self.__msgs_to_ignore.add( msg )
203 disable_warnings = disable_messages
204
205 @property
207 """list of header files, to be included from the file, the generated code will be placed-in"""
208 return self._include_files
209