[pygccxml-commit] SF.net SVN: pygccxml: [973] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-04-09 19:22:52
|
Revision: 973 http://svn.sourceforge.net/pygccxml/?rev=973&view=rev Author: roman_yakovenko Date: 2007-04-09 12:22:53 -0700 (Mon, 09 Apr 2007) Log Message: ----------- small refactoring before implementing better control over included files Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py pyplusplus_dev/pyplusplus/module_creator/creator.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-04-05 18:55:54 UTC (rev 972) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-04-09 19:22:53 UTC (rev 973) @@ -12,10 +12,16 @@ #proxy. This can be disabled by supplying true in the NoProxy template parameter. #We want to disable NoProxy when we deal with immutable objects. +containers = { + 'vector' : "boost/python/suite/indexing/vector_indexing_suite.hpp" + , 'map' : "boost/python/suite/indexing/map_indexing_suite.hpp" +} + + class indexing_suite1_t( object ): """ - This class helps user to export STD containers, using Boost.Python - indexing suite V2. + This class helps user to export STD containers, using built-in Boost.Python + indexing suite. """ def __init__( self, container_class, container_traits, no_proxy=None, derived_policies=None ): @@ -24,6 +30,7 @@ self.__derived_policies = derived_policies self.__container_class = container_class self.__container_traits = container_traits + self.__include_files = None def _get_container_class( self ): return self.__container_class @@ -55,3 +62,14 @@ derived_policies = property( _get_derived_policies, _set_derived_policies , doc="This proprty contains DerivedPolicies string. " +"It will be added as is to the generated code.") + + @property + def include_files( self ): + """Return list of header files to be included in generated code""" + if self.__include_files is None: + name = self.container_class.name.split( '<' )[0] + if name not in containers: + self.__include_files = [] #not supported + else: + self.__include_files = [containers[ name ]] + return self.__include_files Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2007-04-05 18:55:54 UTC (rev 972) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2007-04-09 19:22:53 UTC (rev 973) @@ -33,6 +33,18 @@ """ +containers = { + 'vector' : "boost/python/suite/indexing/vector.hpp" + , 'deque' : "boost/python/suite/indexing/deque.hpp" + , 'list' : "boost/python/suite/indexing/list.hpp" + , 'map' : "boost/python/suite/indexing/map.hpp" + , 'multimap' : "boost/python/suite/indexing/multimap.hpp" + , 'hash_map' : "boost/python/suite/indexing/map.hpp" + , 'set' : "boost/python/suite/indexing/set.hpp" + , 'hash_set' : "boost/python/suite/indexing/set.hpp" + #TODO: queue, priority, stack, multimap, hash_multimap, multiset, hash_multiset +} + class indexing_suite2_t( object ): """ This class helps user to export STD containers, using Boost.Python @@ -63,6 +75,7 @@ self._disabled_groups = set() self._default_applied = False self._use_container_suite = False + self.__include_files = None def get_use_container_suite( self ): return self._use_container_suite @@ -153,3 +166,16 @@ return self._disabled_groups disabled_methods_groups = property( _get_disabled_methods_groups , doc="list of all disabled methods group") + + @property + def include_files( self ): + """Return list of header files to be included in generated code""" + if self.__include_files is None: + name = self.container_class.name.split( '<' )[0] + if name not in containers: + self.__include_files = [] #not supported + else: + #impl details: the order of header files is IMPORTANT + self.__include_files = [ "boost/python/suite/indexing/container_suite.hpp" + , containers[ name ] ] + return self.__include_files Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-04-05 18:55:54 UTC (rev 972) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-04-09 19:22:53 UTC (rev 973) @@ -31,25 +31,6 @@ # }; # }; -INDEXING_SUITE_1_CONTAINERS = { - 'vector<' : "boost/python/suite/indexing/vector_indexing_suite.hpp" - , 'map<' : "boost/python/suite/indexing/map_indexing_suite.hpp" -} - -INDEXING_SUITE_2_CONTAINERS = { - 'vector<' : "boost/python/suite/indexing/vector.hpp" - , 'deque<' : "boost/python/suite/indexing/deque.hpp" - , 'list<' : "boost/python/suite/indexing/list.hpp" - , 'map<' : "boost/python/suite/indexing/map.hpp" - , 'multimap<' : "boost/python/suite/indexing/multimap.hpp" - , 'hash_map<' : "boost/python/suite/indexing/map.hpp" - , 'set<' : "boost/python/suite/indexing/set.hpp" - , 'hash_set<' : "boost/python/suite/indexing/set.hpp" - #TODO: queue, priority, stack, multimap, hash_multimap, multiset, hash_multiset -} - -INDEXING_SUITE_2_MAIN_HEADER = "boost/python/suite/indexing/container_suite.hpp" - class creator_t( declarations.decl_visitor_t ): """Creating code creators. @@ -267,10 +248,6 @@ cls_creator.associated_decl_creators.extend( uc_creators ) def _treat_indexing_suite( self ): - global INDEXING_SUITE_1_CONTAINERS - global INDEXING_SUITE_2_CONTAINERS - global INDEXING_SUITE_2_MAIN_HEADER - def create_explanation(cls): msg = '//WARNING: the next line of code will not compile, because "%s" does not have operator== !' msg = msg % cls.indexing_suite.element_type.decl_string @@ -285,33 +262,21 @@ if not self.__types_db.used_containers: return - used_headers = set() - creators = [] created_value_traits = set() cmp_by_name = lambda cls1, cls2: cmp( cls1.decl_string, cls2.decl_string ) used_containers = list( self.__types_db.used_containers ) + used_containers = filter( lambda cls: cls.indexing_suite.include_files + , used_containers ) used_containers.sort( cmp_by_name ) for cls in used_containers: - container_name = cls.name.split( '<' )[0] + '<' - - if isinstance( cls.indexing_suite, decl_wrappers.indexing_suite1_t ): - isuite = INDEXING_SUITE_1_CONTAINERS - else: - isuite = INDEXING_SUITE_2_CONTAINERS - - if not isuite.has_key( container_name ): - continue #not supported - + map( lambda header: self.__header_files_manager.include(header, system=True) + , cls.indexing_suite.include_files ) + for msg in cls.readme(): self.decl_logger.warn( "%s;%s" % ( cls, msg ) ) - if isuite is INDEXING_SUITE_2_CONTAINERS: - used_headers.add( INDEXING_SUITE_2_MAIN_HEADER ) - - used_headers.add( isuite[ container_name ] ) - cls_creator = create_cls_cc( cls ) self.__dependencies_manager.add_exported( cls ) creators.append( cls_creator ) @@ -319,7 +284,8 @@ element_type = cls.indexing_suite.element_type except: element_type = None - if isuite is INDEXING_SUITE_1_CONTAINERS: + + if isinstance( cls.indexing_suite, decl_wrappers.indexing_suite1_t ): if not ( None is element_type ) \ and declarations.is_class( element_type ) \ and not declarations.has_public_equal( element_type ): @@ -334,17 +300,7 @@ element_type_cc = code_creators.value_traits_t( value_cls ) self.__extmodule.adopt_declaration_creator( element_type_cc ) cls_creator.adopt_creator( code_creators.indexing_suite2_t(cls) ) - - if INDEXING_SUITE_2_MAIN_HEADER in used_headers: - #I want this header to be the first one. - used_headers.remove( INDEXING_SUITE_2_MAIN_HEADER ) - self.__extmodule.add_system_header( INDEXING_SUITE_2_MAIN_HEADER ) - self.__extmodule.add_include( INDEXING_SUITE_2_MAIN_HEADER ) - - for header in used_headers: - self.__extmodule.add_system_header( header ) - self.__extmodule.add_include( header ) - + creators.reverse() self.__module_body.adopt_creators( creators, 0 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |