[pygccxml-commit] SF.net SVN: pygccxml: [304] pygccxml_dev/unittests/data
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-07-12 19:06:53
|
Revision: 304 Author: roman_yakovenko Date: 2006-07-12 12:06:37 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=304&view=rev Log Message: ----------- improving indexing suite Modified Paths: -------------- pygccxml_dev/unittests/data/core_cache.hpp pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/pyplusplus/module_creator/types_database.py pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2006-07-12 17:56:21 UTC (rev 303) +++ pygccxml_dev/unittests/data/core_cache.hpp 2006-07-12 19:06:37 UTC (rev 304) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//touch//touch//touch//touch \ No newline at end of file +//touch//touch//touch//touch//touch \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2006-07-12 17:56:21 UTC (rev 303) +++ pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2006-07-12 19:06:37 UTC (rev 304) @@ -31,15 +31,16 @@ def _create_suite_declaration( self ): suite_identifier = algorithm.create_identifier( self, self.guess_suite_name() ) args = [ self.container.decl_string ] + try: + no_proxy = str( self.configuration.no_proxy ).lower() + except: + no_proxy = 'false' if self.configuration.derived_policies: - if self.configuration.no_proxy: - args.append( 'true' ) - else: - args.append( 'false' ) + args.append( no_proxy ) args.append( self.configuration.derived_policies ) else: - if self.configuration.no_proxy: - args.append( 'true' ) + if 'true' == no_proxy: + args.append( no_proxy) return declarations.templates.join( suite_identifier, args ) def _create_impl(self): Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-12 17:56:21 UTC (rev 303) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-12 19:06:37 UTC (rev 304) @@ -26,7 +26,25 @@ # }; #}; +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" + , '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. @@ -376,6 +394,10 @@ pass 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 @@ -390,27 +412,10 @@ if not self.__types_db.used_containers: return - #supported container : [ header file, is already used ] - used_headers = set() - isuite1 = { - 'vector<' : "boost/python/suite/indexing/vector_indexing_suite.hpp" - , 'map<' : "boost/python/suite/indexing/map_indexing_suite.hpp" - } - isuite2 = { - '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" - , '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 - } + creators = [] - container_suite_header = "boost/python/suite/indexing/container_suite.hpp" - cmp_by_name = lambda cls1, cls2: cmp( cls1.decl_string, cls2.decl_string ) used_containers = list( self.__types_db.used_containers ) used_containers.sort( cmp_by_name ) @@ -418,43 +423,61 @@ container_name = cls.name.split( '<' )[0] + '<' if isinstance( cls.indexing_suite, decl_wrappers.indexing_suite1_t ): - isuite = isuite1 + isuite = INDEXING_SUITE_1_CONTAINERS else: - isuite = isuite2 + isuite = INDEXING_SUITE_2_CONTAINERS if not isuite.has_key( container_name ): continue #not supported - if isuite is isuite2: - used_headers.add( container_suite_header ) + 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 ) - element_type = cls.indexing_suite.element_type - if isuite is isuite1: - if declarations.is_class( element_type ) and not declarations.has_public_equal( element_type ): + creators.append( cls_creator ) + try: + element_type = cls.indexing_suite.element_type + except: + element_type = None + if isuite is INDEXING_SUITE_1_CONTAINERS: + if not ( None is element_type ) \ + and declarations.is_class( element_type ) \ + and not declarations.has_public_equal( element_type ): cls_creator.adopt_creator( create_explanation( cls ) ) cls_creator.adopt_creator( code_creators.indexing_suite1_t(cls) ) else: class_traits = declarations.class_traits - if class_traits.is_my_case( element_type ): + if not ( None is element_type ) \ + and class_traits.is_my_case( element_type ): value_cls = class_traits.get_declaration( element_type ) element_type_cc = code_creators.value_traits_t( value_cls ) self.__extmodule.adopt_creator( element_type_cc, self.__extmodule.creators.index( self.__module_body ) ) cls_creator.adopt_creator( code_creators.indexing_suite2_t(cls) ) - self.__module_body.adopt_creator( cls_creator ) - if container_suite_header in used_headers: + if INDEXING_SUITE_2_MAIN_HEADER in used_headers: #I want this header to be the first one. - used_headers.remove( container_suite_header ) - self.__extmodule.add_system_header( container_suite_header ) - self.__extmodule.add_include( container_suite_header ) + 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 ) - + + #I am going tp find last class registration and to add all container creators + #after it. + last_cls_index = -1 + for i in range( len( self.__module_body.creators ) - 1, -1, -1 ): + if isinstance( self.__module_body.creators[i], code_creators.class_t ): + last_cls_index = i + break + insert_position = last_cls_index + 1 + creators.reverse() + for creator in creators: + self.__module_body.adopt_creator( creator, insert_position ) + def create(self, decl_headers=None): """Create and return the module for the extension. Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-12 17:56:21 UTC (rev 303) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-12 19:06:37 UTC (rev 304) @@ -73,11 +73,12 @@ try: check_extraction = container_cls.indexing_suite.element_type except RuntimeError, error: - msg = 'pyplusplus found "%s" instantiation declaration, ' % container_cls.name - msg = msg + 'but can not find out value type!' - msg = msg + os.linesep + 'This class will not be exported!' - _logging_.loggers.declarations.warn( msg ) - return False + msg = [] + msg.append( 'pyplusplus found class "%s" - instantiation declaration, not definition.' % container_cls.name ) + msg.append( 'pyplusplus can not find out container value_type( mapped_type )!' ) + msg.append( 'This class will be exported, but there is a posiblity, that generated code will not compile.' ) + msg.append( 'The solution to the problem is to create a variable of the class.' ) + _logging_.loggers.declarations.warn( os.linesep.join( msg ) ) self.__containers.add( container_cls ) return True Modified: pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp 2006-07-12 17:56:21 UTC (rev 303) +++ pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp 2006-07-12 19:06:37 UTC (rev 304) @@ -7,8 +7,13 @@ #define __indexing_suites2_to_be_exported_hpp__ #include <vector> +#include <string> namespace indexing_suites2 { + +typedef std::vector< std::string > strings_t; + +inline void do_nothing( const strings_t& ){} struct item_t{ item_t() : value( -1 ){} Modified: pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp 2006-07-12 17:56:21 UTC (rev 303) +++ pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp 2006-07-12 19:06:37 UTC (rev 304) @@ -7,8 +7,13 @@ #define __indexing_suites_to_be_exported_hpp__ #include <vector> +#include <string> namespace indexing_suites { + +typedef std::vector< std::string > strings_t; + +inline void do_nothing( const strings_t& ){} struct item_t{ item_t() : value( -1 ){} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |