def _treat_indexing_suite(self):
        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
            return code_creators.custom_text_t(msg, False)

        def create_cls_cc(cls):
            if isinstance(cls, declarations.class_t):
                return code_creators.class_t(class_inst=cls)
            else:
                return code_creators.class_declaration_t(class_inst=cls)

        if not self.__types_db.used_containers:
            return

        creators = []
        created_value_traits = set()
        for cls in self.__get_exposed_containers():
            self.__print_readme(cls)

            cls_creator = create_cls_cc(cls)
            self.__dependencies_manager.add_exported(cls)
            creators.append(cls_creator)
            try:
                element_type = cls.indexing_suite.element_type
            except:
                element_type = None

            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 ):
                    cls_creator.adopt_creator(create_explanation(cls))
                cls_creator.adopt_creator(code_creators.indexing_suite1_t(cls))
            else:
                class_traits = declarations.class_traits
                if not (None is element_type) and class_traits.is_my_case(
                        element_type):
                    value_cls = class_traits.get_declaration(element_type)
                    has_prerequisits = value_cls.less_than_comparable \
                                       and value_cls.equality_comparable
                    if (not has_prerequisits) and (
                            value_cls not in created_value_traits):
                        created_value_traits.add(value_cls)
                        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))

            scfo = self.__std_containers_free_operators
            if cls in scfo:
                for operator in scfo[cls]:
                    self.__dependencies_manager.add_exported(operator)
                    cls_creator.adopt_creator(
                        code_creators.operator_t(operator=operator))

        creators.reverse()
        self.__module_body.adopt_creators(creators, 0)
Exemple #2
0
    def _treat_indexing_suite( self ):
        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
            return code_creators.custom_text_t( msg, False )

        def create_cls_cc( cls ):
            if isinstance( cls, declarations.class_t ):
                return code_creators.class_t( class_inst=cls )
            else:
                return code_creators.class_declaration_t( class_inst=cls )

        if not self.__types_db.used_containers:
            return

        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:
            self.__print_readme( cls )

            if cls.already_exposed:
                continue

            cls_creator = create_cls_cc( cls )
            self.__dependencies_manager.add_exported( cls )
            creators.append( cls_creator )
            try:
                element_type = cls.indexing_suite.element_type
            except:
                element_type = None

            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 ):
                    cls_creator.adopt_creator( create_explanation( cls ) )
                cls_creator.adopt_creator( code_creators.indexing_suite1_t(cls) )
            else:
                class_traits = declarations.class_traits
                if not ( None is element_type ) and class_traits.is_my_case( element_type ):
                    value_cls = class_traits.get_declaration( element_type )
                    has_prerequisits = value_cls.less_than_comparable \
                                       and value_cls.equality_comparable                    
                    if ( not has_prerequisits ) and ( value_cls not in created_value_traits ):
                        created_value_traits.add( value_cls )
                        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) )

        creators.reverse()
        self.__module_body.adopt_creators( creators, 0 )
Exemple #3
0
    def _treat_indexing_suite(self):
        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
            return code_creators.custom_text_t(msg, False)

        def create_cls_cc(cls):
            if isinstance(cls, declarations.class_t):
                return code_creators.class_t(class_inst=cls)
            else:
                return code_creators.class_declaration_t(class_inst=cls)

        if not self.__types_db.used_containers:
            return

        creators = []
        created_value_traits = set()
        for cls in self.__get_exposed_containers():
            self.__print_readme(cls)

            cls_creator = create_cls_cc(cls)
            self.__dependencies_manager.add_exported(cls)
            creators.append(cls_creator)
            try:
                element_type = cls.indexing_suite.element_type
            except:
                element_type = None

            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)
                ):
                    cls_creator.adopt_creator(create_explanation(cls))
                cls_creator.adopt_creator(code_creators.indexing_suite1_t(cls))
            else:
                class_traits = declarations.class_traits
                if not (None is element_type) and class_traits.is_my_case(element_type):
                    value_cls = class_traits.get_declaration(element_type)
                    has_prerequisits = value_cls.less_than_comparable and value_cls.equality_comparable
                    if (not has_prerequisits) and (value_cls not in created_value_traits):
                        created_value_traits.add(value_cls)
                        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))

            scfo = self.__std_containers_free_operators
            if cls in scfo:
                for operator in scfo[cls]:
                    self.__dependencies_manager.add_exported(operator)
                    cls_creator.adopt_creator(code_creators.operator_t(operator=operator))

        creators.reverse()
        self.__module_body.adopt_creators(creators, 0)