Exemplo n.º 1
0
 def value_type(type):
     """returns reference to boost::shared_ptr value type"""
     if not smart_pointer_traits.is_smart_pointer(type):
         raise TypeError(
             'Type "%s" is not instantiation of boost::shared_ptr' %
             type.decl_string)
     type = remove_alias(type)
     cls = remove_cv(type)
     cls = remove_declarated(type)
     if isinstance(cls, class_declaration.class_t):
         return remove_declarated(
             cls.typedef("value_type", recursive=False).type)
     elif not isinstance(cls, (class_declaration.class_declaration_t,
                               class_declaration.class_t)):
         raise RuntimeError(
             "Unable to find out shared_ptr value type. shared_ptr class is: %s"
             % cls.decl_string)
     else:
         value_type_str = templates.args(cls.name)[0]
         ref = impl_details.find_value_type(cls.top_parent, value_type_str)
         if None is ref:
             raise RuntimeError(
                 "Unable to find out shared_ptr value type. shared_ptr class is: %s"
                 % cls.decl_string)
         return ref
Exemplo n.º 2
0
 def element_type( self, type ):
     """returns reference to the class value\\mapped type declaration"""
     cls = self.class_declaration( type )
     if isinstance( cls, class_declaration.class_t ):
         value_type = cls.typedef( self.element_type_typedef, recursive=False ).type
         return type_traits.remove_declarated( value_type )
     else:
         value_type_str = templates.args( cls.name )[self.element_type_index]
         ref = type_traits.impl_details.find_value_type( cls.top_parent, value_type_str )
         if None is ref:
             raise RuntimeError( "Unable to find out %s '%s' value type."
                                 % ( self.name, cls.decl_string ) )
         return ref
Exemplo n.º 3
0
 def __find_xxx_type( self, type, xxx_index, xxx_typedef, cache_property_name ):
     cls = self.class_declaration( type )
     result = getattr( cls.cache, cache_property_name )
     if not result:            
         if isinstance( cls, class_declaration.class_t ):
             xxx_type = cls.typedef( xxx_typedef, recursive=False ).type
             result = type_traits.remove_declarated( xxx_type )
         else:
             xxx_type_str = templates.args( cls.name )[xxx_index]
             result = type_traits.impl_details.find_value_type( cls.top_parent, xxx_type_str )
             if None is result:
                 raise RuntimeError( "Unable to find out %s '%s' key\\value type."
                                     % ( self.name(), cls.decl_string ) )
         setattr( cls.cache, cache_property_name, result )
     return result
Exemplo n.º 4
0
 def element_type(self, type):
     """returns reference to the class value\\mapped type declaration"""
     cls = self.class_declaration(type)
     if isinstance(cls, class_declaration.class_t):
         value_type = cls.typedef(self.element_type_typedef,
                                  recursive=False).type
         return type_traits.remove_declarated(value_type)
     else:
         value_type_str = templates.args(cls.name)[self.element_type_index]
         ref = type_traits.impl_details.find_value_type(
             cls.top_parent, value_type_str)
         if None is ref:
             raise RuntimeError("Unable to find out %s '%s' value type." %
                                (self.name, cls.decl_string))
         return ref
Exemplo n.º 5
0
 def __find_xxx_type( self, type, xxx_index, xxx_typedef, cache_property_name ):
     cls = self.class_declaration( type )
     result = getattr( cls.cache, cache_property_name )
     if not result:
         if isinstance( cls, class_declaration.class_t ):
             xxx_type = cls.typedef( xxx_typedef, recursive=False ).type
             result = type_traits.remove_declarated( xxx_type )
         else:
             xxx_type_str = templates.args( cls.name )[xxx_index]
             result = type_traits.impl_details.find_value_type( cls.top_parent, xxx_type_str )
             if None is result:
                 raise RuntimeError( "Unable to find out %s '%s' key\\value type."
                                     % ( self.name(), cls.decl_string ) )
         setattr( cls.cache, cache_property_name, result )
     return result
Exemplo n.º 6
0
 def get_by_name( type_, name ):
     if class_traits.is_my_case( type_ ):
         cls = class_traits.declaration_class( type_ )
         return remove_declarated( cls.typedef( name, recursive=False ).type )
     elif class_declaration_traits.is_my_case( type_ ):
         cls = class_declaration_traits.get_declaration( type_ )
         value_type_str = templates.args( cls.name )[0]
         ref = impl_details.find_value_type( cls.top_parent, value_type_str )
         if ref:
             return ref
         else:
             raise RuntimeError( "Unable to find reference to internal type '%s' in type '%s'."
                                 % ( name, cls.decl_string ) )
     else:
         raise RuntimeError( "Unable to find reference to internal type '%s' in type '%s'."
                             % ( name, type_.decl_string ) )
Exemplo n.º 7
0
 def get_by_name( type_, name ):
     if class_traits.is_my_case( type_ ):
         cls = class_traits.declaration_class( type_ )
         return remove_declarated( cls.typedef( name, recursive=False ).type )
     elif class_declaration_traits.is_my_case( type_ ):
         cls = class_declaration_traits.get_declaration( type_ )
         value_type_str = templates.args( cls.name )[0]
         ref = impl_details.find_value_type( cls.top_parent, value_type_str )
         if ref:
             return ref
         else:
             raise RuntimeError( "Unable to find reference to internal type '%s' in type '%s'."
                                 % ( name, cls.decl_string ) )
     else:
         raise RuntimeError( "Unable to find reference to internal type '%s' in type '%s'."
                             % ( name, type_.decl_string ) )
Exemplo n.º 8
0
 def value_type( type ):
     """returns reference to boost::shared_ptr value type"""
     if not smart_pointer_traits.is_smart_pointer( type ):
         raise TypeError( 'Type "%s" is not instantiation of boost::shared_ptr' % type.decl_string )
     type = remove_alias( type )
     cls = remove_cv( type )
     cls = remove_declarated( type )
     if isinstance( cls, class_declaration.class_t ):
         return remove_declarated( cls.typedef( "value_type", recursive=False ).type )
     elif not isinstance( cls, ( class_declaration.class_declaration_t, class_declaration.class_t ) ):
         raise RuntimeError( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls.decl_string )
     else:
         value_type_str = templates.args( cls.name )[0]
         ref = impl_details.find_value_type( cls.top_parent, value_type_str )
         if None is ref:
             raise RuntimeError( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls.decl_string )
         return ref