| Trees | Indices | Help |
|
|---|
|
|
1 # Copyright 2004-2008 Roman Yakovenko. 2 # Distributed under the Boost Software License, Version 1.0. (See 3 # accompanying file LICENSE_1_0.txt or copy at 4 # http://www.boost.org/LICENSE_1_0.txt) 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 messages14 """code generator declaration configuration base class 15 16 This class contains configuration that could be applied to all declarations. 17 """ 18 19 SPECIAL_TYPEDEF_PICK_ANY = True 206722 object.__init__(self) 23 self._alias = None 24 self._ignore = False 25 self._already_exposed = False 26 self._exportable = None 27 self._exportable_reason = None 28 self._documentation = None 29 self.__msgs_to_ignore = set() 30 self._include_files = []31 32 @property 3640 self._documentation = value41 documentation = property( _get_documentation, _set_documentation 42 , doc="exposed declaration Python documentation string" ) 43 48 50 if not isinstance( self, declarations.class_types ): 51 return [] 52 typedefs = list( set( filter( lambda typedef: typedef.is_directive, self.aliases ) ) ) 53 if decl_wrapper_t.SPECIAL_TYPEDEF_PICK_ANY: 54 if typedefs and be_smart: 55 longest_name_len = 0 56 longest_typedef = None 57 for typedef in typedefs: 58 typedef_name_len = len( typedef.name ) 59 if longest_name_len < typedef_name_len: 60 longest_name_len = typedef_name_len 61 longest_typedef = typedef 62 return [longest_typedef] 63 else: 64 return typedefs 65 else: 66 return typedefs69 if not self._alias: 70 directives = self.__select_alias_directives(be_smart=True) 71 if 1 == len( directives ): 72 self._alias = directives[0].name 73 else: 74 if declarations.templates.is_instantiation( self.name ): 75 container_aliases = [ 'value_type', 'key_type', 'mapped_type' ] 76 if isinstance( self, declarations.class_t ) \ 77 and 1 == len( set( map( lambda typedef: typedef.name, self.aliases ) ) ) \ 78 and self.aliases[0].name not in container_aliases: 79 self._alias = self.aliases[0].name 80 else: 81 self._alias = algorithm.create_valid_name( self.partial_name ) 82 else: 83 if declarations.is_class( self ) or declarations.is_class_declaration( self ): 84 self._alias = algorithm.create_valid_name( self.partial_name ) 85 else: 86 self._alias = self.partial_name 87 return self._alias89 self._alias = alias90 alias = property( _get_alias, _set_alias 91 , doc="the name under which, Python will know the declaration" ) 9294 """give new name to the declaration, under which Python will know the declaration""" 95 self.alias = new_name96100 self._ignore = value101 ignore = property( _get_ignore, _set_ignore 102 , doc="boolean flag, which says whether to export declaration to Python or not" ) 103