def __cmp_traits(self, typedef, expected, partial_name, key_type=None):
        if utils.is_str(typedef):
            typedef = self.global_ns.typedef(typedef)
        traits = declarations.find_container_traits(typedef)
        self.assertTrue(traits,
                        'container traits for "%s" not found' % str(typedef))
        self.assertTrue(
            traits is expected,
            'container "%s", expected %s_traits, got %s_traits' %
            (str(typedef), expected.name(), traits.name()))
        cls = declarations.remove_declarated(typedef)
        self.assertTrue(declarations.find_container_traits(cls) is expected)
        self.assertTrue(cls.partial_name == partial_name)
        cls = traits.class_declaration(cls)

        self.assertTrue(traits.element_type(typedef))
        self.assertTrue(cls.cache.container_element_type,
                        "For some reason cache was not updated")

        if key_type:
            self.assertTrue(traits.is_mapping(typedef))
            real_key_type = traits.key_type(typedef)
            self.assertTrue(
                real_key_type.decl_string == key_type,
                'Error extracting key type.  Expected type "%s", got "%s"' %
                (key_type, real_key_type.decl_string))
            self.assertTrue(cls.cache.container_key_type,
                            "For some reason cache was not updated")
        else:
            self.assertTrue(traits.is_sequence(typedef))
 def test_from_ogre():
     x = ('map<std::string, bool (*)(std::string&, ' +
          'Ogre::MaterialScriptContext&), std::less<std::string>, ' +
          'std::allocator<std::pair<std::string const, bool (*)' +
          '(std::string&, Ogre::MaterialScriptContext&)> > >')
     ct = declarations.find_container_traits(x)
     ct.remove_defaults(x)
 def __cmp_traits( self, typedef, expected, partial_name, key_type=None):
     if isinstance( typedef, str ):
         typedef = self.global_ns.typedef( typedef )
     traits = declarations.find_container_traits( typedef )
     self.failUnless( traits, 'container traits for "%s" not found' % str( typedef ) )
     self.failUnless( traits is expected
                      , 'container "%s", expected %s_traits, got %s_traits' 
                        % ( str(typedef), expected.name(), traits.name() ) )
     cls = declarations.remove_declarated( typedef )                                        
     self.failUnless( cls.container_traits is expected )
     self.failUnless( cls.partial_name == partial_name )
     cls = traits.class_declaration( cls )
     
     self.failUnless( traits.element_type( typedef ) )
     self.failUnless( cls.cache.container_element_type, "For some reason cache was not updated" )
     
     if key_type:
         self.failUnless( traits.is_mapping( typedef ) )
         real_key_type = traits.key_type( typedef )
         self.failUnless( real_key_type.decl_string == key_type
                          , 'Error extracting key type.  Expected type "%s", got "%s"'
                            % ( key_type, real_key_type.decl_string ) )
         self.failUnless( cls.cache.container_key_type, "For some reason cache was not updated" )                               
     else:
         self.failUnless( traits.is_sequence( typedef ) )
 def test_from_ogre(self):
     x = (
         'map<std::string, bool (*)(std::string&, ' +
         'Ogre::MaterialScriptContext&), std::less<std::string>, ' +
         'std::allocator<std::pair<std::string const, bool (*)' +
         '(std::string&, Ogre::MaterialScriptContext&)> > >')
     ct = declarations.find_container_traits(x)
     ct.remove_defaults(x)
 def test_remove_defaults_partial_name_namespace( self ):
     f2 = self.global_ns.free_fun( 'f2' )
     type_info = f2.return_type
     traits = declarations.find_container_traits( type_info )
     cls = traits .class_declaration( type_info )
     decl_string = cls.partial_decl_string #traits.remove_defaults(type_info)
     key_type_string = traits.key_type(type_info).partial_decl_string
     self.assert_(decl_string.startswith('::std::'), "declaration string %r doesn't start with 'std::'" % decl_string)
     self.assert_(key_type_string.startswith('::std::'), "key type string %r doesn't start with 'std::'" % key_type_string)
 def test_declaration(self):
     cnt = (
         'std::vector<std::basic_string<char, std::char_traits<char>, ' +
         'std::allocator<char> >,std::allocator<std::basic_string<char, ' +
         'std::char_traits<char>, std::allocator<char> > > >' +
         '@::std::vector<std::basic_string<char, std::char_traits<char>, ' +
         'std::allocator<char> >,std::allocator<std::basic_string<char, ' +
         'std::char_traits<char>, std::allocator<char> > > >')
     traits = declarations.find_container_traits(cnt)
     self.failUnless(declarations.vector_traits is traits)
Example #7
0
 def test_declaration(self):
     cnt = (
         'std::vector<std::basic_string<char, std::char_traits<char>, ' +
         'std::allocator<char> >,std::allocator<std::basic_string<char, ' +
         'std::char_traits<char>, std::allocator<char> > > >' +
         '@::std::vector<std::basic_string<char, std::char_traits<char>, ' +
         'std::allocator<char> >,std::allocator<std::basic_string<char, ' +
         'std::char_traits<char>, std::allocator<char> > > >')
     traits = declarations.find_container_traits(cnt)
     self.assertTrue(declarations.vector_traits is traits)
 def __cmp_traits( self, typedef, expected, partial_name ):
     if isinstance( typedef, str ):
         typedef = self.global_ns.typedef( typedef )
     traits = declarations.find_container_traits( typedef )
     self.failUnless( traits, 'container traits for "%s" not found' % str( typedef ) )
     self.failUnless( traits is expected
                      , 'container "%s", expected %s, got %s' 
                        % ( str(typedef), expected.__name__, traits.__name__ ) )
     cls = declarations.remove_declarated( typedef )                                        
     self.failUnless( cls.container_traits is expected )
     self.failUnless( cls.partial_name == partial_name )
    def indexing_suite( self ):
        """reference to indexing suite configuration class.

        If the class is not STD container, this property will contain None"
        """
        if self._indexing_suite is None:
            if declarations.find_container_traits(self):
                if self._isuite_version == 1:
                    self._indexing_suite = isuite1.indexing_suite1_t( self )
                else:
                    self._indexing_suite = isuite2.indexing_suite2_t( self )
        return self._indexing_suite
Example #10
0
    def indexing_suite( self ):
        """reference to indexing suite configuration class.

        If the class is not STD container, this property will contain None"
        """
        if self._indexing_suite is None:
            if declarations.find_container_traits(self):
                if self._isuite_version == 1:
                    self._indexing_suite = isuite1.indexing_suite1_t( self )
                else:
                    self._indexing_suite = isuite2.indexing_suite2_t( self )
        return self._indexing_suite
 def test_remove_defaults_partial_name_namespace(self):
     f2 = self.global_ns.free_fun('f2')
     type_info = f2.return_type
     traits = declarations.find_container_traits(type_info)
     cls = traits.class_declaration(type_info)
     decl_string = cls.partial_decl_string  #traits.remove_defaults(type_info)
     key_type_string = traits.key_type(type_info).partial_decl_string
     self.assert_(
         decl_string.startswith('::std::'),
         "declaration string %r doesn't start with 'std::'" % decl_string)
     self.assert_(
         key_type_string.startswith('::std::'),
         "key type string %r doesn't start with 'std::'" % key_type_string)
Example #12
0
 def test_declaration( self ):
     cnt = 'std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >@::std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >'
     traits = declarations.find_container_traits( cnt )
     self.failUnless( declarations.vector_traits is traits)
 def test_infinite_loop(self):
     rt = self.global_ns.free_fun('test_infinite_loop').return_type
     map_traits = declarations.find_container_traits(rt)
     self.assertTrue(map_traits is declarations.map_traits)
     elem = map_traits.element_type(rt)
     self.assertTrue(elem.decl_string == 'int')
 def test_multimap(self):
     m = self.global_ns.class_(
         lambda decl: decl.name.startswith('multimap'))
     declarations.find_container_traits(m)
     self.assertTrue(m.partial_name == 'multimap< int, int >')
 def test_infinite_loop(self):
     rt = self.global_ns.free_fun('test_infinite_loop').return_type
     map_traits = declarations.find_container_traits(rt)
     self.failUnless(map_traits is declarations.map_traits)
     elem = map_traits.element_type(rt)
     self.failUnless(elem.decl_string == 'int')
 def element_type(self):
     """reference to container value_type( mapped_type ) type"""
     if self.__element_type is None:
         self.__element_type = declarations.find_container_traits(self.container_class).element_type( self.container_class )
     return self.__element_type
 def test_multimap(self):
     m = self.global_ns.class_(
         lambda decl: decl.name.startswith('multimap'))
     declarations.find_container_traits(m)
     self.failUnless(m.partial_name == 'multimap< int, int >')
 def container_traits( self ):
     "reference to container traits. See pygccxml documentation for more information."
     return declarations.find_container_traits(self.container_class)
 def test_multimap( self ):
     mm = self.global_ns.classes( lambda decl: decl.name.startswith( 'multimap' ) )
     for m in mm:
         traits = declarations.find_container_traits( m )
         print m.partial_name
 def container_traits( self ):
     "reference to container traits. See pygccxml documentation for more information."
     return declarations.find_container_traits(self.container_class)