Ejemplo n.º 1
0
 def _set_name( self, name ):
     self.__name = name
     if not self.__name:
         self.__opt_is_tmpl_inst = None
         self.__opt_tmpl_name = None
         self.__opt_is_full_name = None
         self.__decl_name_only = None
     else:
         self.__opt_is_tmpl_inst = templates.is_instantiation( self.__name )
         self.__opt_tmpl_name = templates.name( self.__name )
         if self.__opt_is_tmpl_inst:
             if '::' in self.__opt_tmpl_name:
                 self.__opt_is_full_name = True
                 self.__decl_name_only = self.__opt_tmpl_name.split('::')[-1]
             else:
                 self.__opt_is_full_name = False
                 self.__decl_name_only = self.__opt_tmpl_name
             self.__name = templates.normalize( name )            
         else:
             if '::' in self.__name:
                 self.__opt_is_full_name = True
                 self.__decl_name_only = self.__name.split('::')[-1]
             else:
                 self.__opt_is_full_name = False
                 self.__decl_name_only = self.__name
Ejemplo n.º 2
0
 def _set_name(self, name):
     self.__name = name
     if not self.__name:
         self.__opt_is_tmpl_inst = None
         self.__opt_tmpl_name = None
         self.__opt_is_full_name = None
         self.__decl_name_only = None
     else:
         self.__opt_is_tmpl_inst = templates.is_instantiation(self.__name)
         self.__opt_tmpl_name = templates.name(self.__name)
         if self.__opt_is_tmpl_inst:
             if '::' in self.__opt_tmpl_name:
                 self.__opt_is_full_name = True
                 self.__decl_name_only = self.__opt_tmpl_name.split(
                     '::')[-1]
             else:
                 self.__opt_is_full_name = False
                 self.__decl_name_only = self.__opt_tmpl_name
             self.__name = templates.normalize(name)
         else:
             if '::' in self.__name:
                 self.__opt_is_full_name = True
                 self.__decl_name_only = self.__name.split('::')[-1]
             else:
                 self.__opt_is_full_name = False
                 self.__decl_name_only = self.__name
Ejemplo n.º 3
0
    def __findout_range(self, name, decl_type, recursive):
        """implementation details"""
        if not self._optimized:
            self._logger.debug(
                'running non optimized query - optimization has not been done')
            decls = self.declarations
            if recursive:
                decls = algorithm.make_flatten(self.declarations)
            if decl_type:
                decls = filter(lambda d: isinstance(d, decl_type), decls)
            return decls

        if name and templates.is_instantiation(name):
            #templates has tricky mode to compare them, so lets check the whole
            #range
            name = None

        if name and decl_type:
            matcher = scopedef_t._impl_matchers[scopedef_t.decl](name=name)
            if matcher.is_full_name():
                name = matcher.decl_name_only
            if recursive:
                self._logger.debug('query has been optimized on type and name')
                if self._type2name2decls[decl_type].has_key(name):
                    return self._type2name2decls[decl_type][name]
                else:
                    return []
            else:
                self._logger.debug(
                    'non recursive query has been optimized on type and name')
                if self._type2name2decls_nr[decl_type].has_key(name):
                    return self._type2name2decls_nr[decl_type][name]
                else:
                    return []
        elif decl_type:
            if recursive:
                self._logger.debug('query has been optimized on type')
                return self._type2decls[decl_type]
            else:
                self._logger.debug(
                    'non recursive query has been optimized on type')
                return self._type2decls_nr[decl_type]
        else:
            if recursive:
                self._logger.debug(
                    'query has not been optimized ( hint: query does not contain type and/or name )'
                )
                return self._all_decls
            else:
                self._logger.debug(
                    'non recursive query has not been optimized ( hint: query does not contain type and/or name )'
                )
                return self._all_decls_not_recursive
Ejemplo n.º 4
0
def get_partial_name(name):
    import templates
    import container_traits  #prevent cyclic dependencies
    ct = container_traits.find_container_traits(name)
    if ct:
        return ct.remove_defaults(name)
    elif templates.is_instantiation(name):
        tmpl_name, args = templates.split(name)
        for i, arg_name in enumerate(args):
            args[i] = get_partial_name(arg_name.strip())
        return templates.join(tmpl_name, args)
    else:
        return name
Ejemplo n.º 5
0
def get_partial_name( name ):
    import templates
    import container_traits #prevent cyclic dependencies
    ct = container_traits.find_container_traits( name )
    if ct:
        return ct.remove_defaults( name )
    elif templates.is_instantiation( name ):
        tmpl_name, args = templates.split( name )
        for i, arg_name in enumerate( args ):
            args[i] = get_partial_name( arg_name.strip() )
        return templates.join( tmpl_name, args )
    else:
        return name
Ejemplo n.º 6
0
def find_container_traits( cls_or_string ):
    if isinstance( cls_or_string, types.StringTypes ):
        if not templates.is_instantiation( cls_or_string ):
            return None
        name = templates.name( cls_or_string )
        if name.startswith( 'std::' ):
            name = name[ len( 'std::' ): ]
        for cls_traits in container_traits:
            if cls_traits.name() == name:
                return cls_traits
    else:
        for cls_traits in container_traits:
            if cls_traits.is_my_case( cls_or_string ):
                return cls_traits
Ejemplo n.º 7
0
def find_container_traits(cls_or_string):
    if isinstance(cls_or_string, types.StringTypes):
        if not templates.is_instantiation(cls_or_string):
            return None
        name = templates.name(cls_or_string)
        if name.startswith('std::'):
            name = name[len('std::'):]
        for cls_traits in container_traits:
            if cls_traits.name() == name:
                return cls_traits
    else:
        for cls_traits in container_traits:
            if cls_traits.is_my_case(cls_or_string):
                return cls_traits
Ejemplo n.º 8
0
    def __findout_range( self, name, decl_type, recursive ):
        """implementation details"""
        if not self._optimized:
            self._logger.debug( 'running non optimized query - optimization has not been done' )
            decls = self.declarations
            if recursive:
                decls = algorithm.make_flatten( self.declarations )
            if decl_type:
                decls = filter( lambda d: isinstance( d, decl_type ), decls )
            return decls

        if name and templates.is_instantiation( name ):
            #templates has tricky mode to compare them, so lets check the whole
            #range
            name = None
        
        if name and decl_type:
            matcher = scopedef_t._impl_matchers[ scopedef_t.decl ]( name=name )
            if matcher.is_full_name():
                name = matcher.decl_name_only
            if recursive:
                self._logger.debug( 'query has been optimized on type and name' )
                if self._type2name2decls[decl_type].has_key( name ):
                    return self._type2name2decls[decl_type][name]
                else:
                    return []
            else:
                self._logger.debug( 'non recursive query has been optimized on type and name' )
                if self._type2name2decls_nr[decl_type].has_key( name ):
                    return self._type2name2decls_nr[decl_type][name]
                else:
                    return []
        elif decl_type:
            if recursive:
                self._logger.debug( 'query has been optimized on type' )
                return self._type2decls[ decl_type ]
            else:
                self._logger.debug( 'non recursive query has been optimized on type' )
                return self._type2decls_nr[ decl_type ]
        else:
            if recursive:
                self._logger.debug( 'query has not been optimized ( hint: query does not contain type and/or name )' )
                return self._all_decls
            else:
                self._logger.debug( 'non recursive query has not been optimized ( hint: query does not contain type and/or name )' )
                return self._all_decls_not_recursive