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 import os 7 import custom 8 import license 9 import include 10 import namespace 11 import compound 12 import algorithm 13 import module_body 14 import declaration_based 15 import include_directories 16 from pygccxml import utils19 """This class represents the source code for the entire extension module. 20 21 The root of the code creator tree is always a module_t object. 22 """184 185 @utils.cached24 """Constructor. 25 """ 26 compound.compound_t.__init__(self) 27 self.__body = None 28 self.__global_ns = global_ns29 30 @property 3436 include_dirs = algorithm.creator_finder.find_by_class_instance( 37 what=include_directories.include_directories_t 38 , where=self.creators 39 , recursive=False) 40 if 0 == len( include_dirs ): 41 include_dirs = include_directories.include_directories_t() 42 if self.license: 43 self.adopt_creator( include_dirs, 1 ) 44 else: 45 self.adopt_creator( include_dirs, 0 ) 46 return include_dirs 47 elif 1 == len( include_dirs ): 48 return include_dirs[0] 49 else: 50 assert not "only single instance of include_directories_t should exist"51 55 std_directories = property( _get_std_directories ) 56 60 user_defined_directories = property( _get_user_defined_directories ) 61 62 @property64 """Return reference to L{module_body_t} code creator""" 65 if None is self.__body: 66 found = algorithm.creator_finder.find_by_class_instance( what=module_body.module_body_t 67 , where=self.creators 68 , recursive=False ) 69 if found: 70 self.__body = found[0] 71 return self.__body72 7779 if not isinstance( license_text, license.license_t ): 80 license_inst = license.license_t( license_text ) 81 if isinstance( self.creators[0], license.license_t ): 82 self.remove_creator( self.creators[0] ) 83 self.adopt_creator( license_inst, 0 )84 license = property( _get_license, _set_license, 85 doc="""License text. 86 87 The license text will always be the first children node. 88 @type: str or L{license_t}""") 8991 """Return the children index of the last L{include_t} object. 92 93 An exception is raised when there is no include_t object among 94 the children creators. 95 96 @returns: Children index 97 @rtype: int 98 """ 99 for i in range( len(self.creators) - 1, -1, -1 ): 100 if isinstance( self.creators[i], include.include_t ): 101 return i 102 else: 103 return 0104106 to_be_removed = [] 107 for creator in self.creators: 108 if isinstance( creator, include.include_t ): 109 to_be_removed.append( creator ) 110 elif isinstance( creator, module_body.module_body_t ): 111 break 112 113 for creator in to_be_removed: 114 if creator.is_system: 115 if not leave_system_headers: 116 self.remove_creator( creator ) 117 elif creator.is_user_defined: 118 pass 119 else: 120 self.remove_creator( creator ) 121 map( lambda header: self.adopt_include( include.include_t( header=header ) ) 122 , headers )123125 """Insert an L{include_t} object. 126 127 The include creator is inserted right after the last include file. 128 129 @param include_creator: Include creator object 130 @type include_creator: L{include_t} 131 """ 132 lii = self.last_include_index() 133 if lii == 0: 134 if not self.creators: 135 lii = -1 136 elif not isinstance( self.creators[0], include.include_t ): 137 lii = -1 138 else: 139 pass 140 self.adopt_creator( include_creator, lii + 1 )141143 include_dirs = self._get_include_dirs() 144 includes = filter( lambda creator: isinstance( creator, include.include_t ) 145 , self.creators ) 146 for include_creator in includes: 147 include_creator.include_dirs_optimization = include_dirs148 151153 self.do_include_dirs_optimization() 154 index = 0 155 includes = [] 156 for index in range( len( self.creators ) ): 157 if not isinstance( self.creators[index], include.include_t ): 158 break 159 else: 160 includes.append( self.creators[index].create() ) 161 code = compound.compound_t.create_internal_code( self.creators[index:] ) 162 code = self.unindent(code) 163 return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep164166 creator = include.include_t( header=header, user_defined=user_defined, system=system ) 167 self.adopt_include( creator )168170 self.adopt_creator( namespace.namespace_using_t( namespace_name ) 171 , self.last_include_index() + 1 )172174 self.adopt_creator( namespace.namespace_alias_t( 175 alias=alias 176 , full_namespace_name=full_namespace_name ) 177 , self.last_include_index() + 1 )178 181 183 self.adopt_declaration_creator( custom.custom_text_t( code ) )187 """list of exposed declarations, which were not ``included``, but still 188 were exposed. For example, std containers. 189 """ 190 decls = set() 191 #select all declaration based code creators 192 ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t ) 193 , algorithm.make_flatten_list( self ) ) 194 #leave only "ignored" 195 ccs = filter( lambda cc: cc.declaration.ignore == True, ccs ) 196 197 decls = map( lambda cc: cc.declaration, ccs ) 198 199 return set( decls )200
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 20 08:51:39 2008 | http://epydoc.sourceforge.net |