Ejemplo n.º 1
0
    def customize(self, mb):
        try:
            find = code_creators.creator_finder.find_by_declaration_single
            matcher = declarations.match_declaration_t(
                name='year', type=declarations.member_function_t)
            found = find(matcher, mb.code_creator.body.creators)
            self.failUnless(found)
            self.failUnless(found.is_finalizable())
            found.finalize()
            #from now should be only one instances that references year function
            found = find(matcher, mb.code_creator.creators)
            self.failUnless(found)
            self.failUnless(not found.is_finalizable())

            matcher = declarations.match_declaration_t(
                name='whole_class_t', type=declarations.class_t)
            found = find(matcher, mb.code_creator.body.creators)
            self.failUnless(found)
            self.failUnless(found.is_finalizable())
            found.finalize()
            #from now should be only one instances that references whole_class_t class
            found = find(matcher, mb.code_creator.creators)
            self.failUnless(found)
            self.failUnless(not found.is_finalizable())
        except:
            pass
Ejemplo n.º 2
0
 def customize(self, mb ):
     try:
         find = code_creators.creator_finder.find_by_declaration_single
         matcher = declarations.match_declaration_t( name='year'
                                                     , type=declarations.member_function_t)
         found = find( matcher, mb.module_creator.body.creators )
         self.failUnless( found )
         self.failUnless( found.is_finalizable() )
         found.finalize()
         #from now should be only one instances that references year function
         found = find( matcher, mb.module_creator.creators )
         self.failUnless( found )
         self.failUnless( not found.is_finalizable() )
         
         matcher = declarations.match_declaration_t( name='whole_class_t'
                                                     , type=declarations.class_t)
         found = find( matcher, mb.module_creator.body.creators )
         self.failUnless( found )
         self.failUnless( found.is_finalizable() )
         found.finalize()
         #from now should be only one instances that references whole_class_t class
         found = find( matcher, mb.module_creator.creators )
         self.failUnless( found )
         self.failUnless( not found.is_finalizable() )
     except:
         pass
Ejemplo n.º 3
0
 def customize(self, mb ):
     mb.build_code_creator( 'hierarchy3' )
     find = code_creators.creator_finder.find_by_declaration_single
     matcher = declarations.match_declaration_t( name='son_t'
                                                 , type=declarations.class_t)
     found = find( matcher, mb.code_creator.body.creators )
     self.failUnless( found )
     self.failUnless( found.wrapper )
Ejemplo n.º 4
0
 def customize(self, mb):
     mb.build_code_creator('hierarchy3')
     find = code_creators.creator_finder.find_by_declaration_single
     matcher = declarations.match_declaration_t(name='son_t',
                                                type=declarations.class_t)
     found = find(matcher, mb.code_creator.body.creators)
     self.failUnless(found)
     self.failUnless(found.wrapper)
Ejemplo n.º 5
0
    def customize( self, mb ):
        matcher = ~declarations.namespace_matcher_t()
        matcher = matcher & declarations.regex_matcher_t( '.*skip.*' )

        decls = mb.decls( matcher )
        decls.ignore = True
        
        mb.build_code_creator( self.EXTENSION_NAME )

        matcher = declarations.match_declaration_t( name='skip_a' )        
        found = code_creators.creator_finder.find_by_declaration( matcher
                                                                  , mb.code_creator.creators )
        self.failUnless( not found, "'skip_a' declaration should not be exported" )
        
        matcher = declarations.match_declaration_t( name='skip_b' )        
        found = code_creators.creator_finder.find_by_declaration( matcher
                                                                  , mb.code_creator.creators )
        self.failUnless( not found, "'skip_b' declaration should not be exported" )                                                          
Ejemplo n.º 6
0
    def customize(self, mb ):
        mb.build_code_creator( self.EXTENSION_NAME )
        extmodule = mb.code_creator
        matcher = declarations.match_declaration_t( name='item', type=declarations.class_t )
        item_creator = code_creators.creator_finder.find_by_declaration( matcher, extmodule.body.creators )[0]
        extmodule.body.remove_creator(item_creator)
        #This will add item creator to be last exported class
        extmodule.body.adopt_creator(item_creator)

        mb.calldefs().use_keywords = False
Ejemplo n.º 7
0
 def test_find_by_declaration(self):
     mb = module_builder.module_builder_t(
         [ module_builder.create_text_fc( 'namespace enums{ enum color{ red = 1}; }' )]
         , gccxml_path=autoconfig.gccxml.executable )
     mb.namespace( name='::enums' ).include()
     enum_matcher = declarations.match_declaration_t( name='color' )
     mb.build_code_creator( 'dummy' )
     enum_found = code_creators.creator_finder.find_by_declaration(
                     enum_matcher
                     , mb.code_creator.creators )
     self.failUnless( enum_found )
Ejemplo n.º 8
0
    def customize(self, mb):
        matcher = ~declarations.namespace_matcher_t()
        matcher = matcher & declarations.regex_matcher_t('.*skip.*')

        decls = mb.decls(matcher)
        decls.ignore = True

        mb.build_code_creator(self.EXTENSION_NAME)

        matcher = declarations.match_declaration_t(name='skip_a')
        found = code_creators.creator_finder.find_by_declaration(
            matcher, mb.code_creator.creators)
        self.failUnless(not found,
                        "'skip_a' declaration should not be exported")

        matcher = declarations.match_declaration_t(name='skip_b')
        found = code_creators.creator_finder.find_by_declaration(
            matcher, mb.code_creator.creators)
        self.failUnless(not found,
                        "'skip_b' declaration should not be exported")
Ejemplo n.º 9
0
    def customize(self, mb):
        mb.build_code_creator(self.EXTENSION_NAME)
        extmodule = mb.code_creator
        matcher = declarations.match_declaration_t(name='item',
                                                   type=declarations.class_t)
        item_creator = code_creators.creator_finder.find_by_declaration(
            matcher, extmodule.body.creators)[0]
        extmodule.body.remove_creator(item_creator)
        #This will add item creator to be last exported class
        extmodule.body.adopt_creator(item_creator)

        mb.calldefs().use_keywords = False
 def test_find_by_declaration(self):
     mb = module_builder.module_builder_t(
         [
             module_builder.create_text_fc(
                 'namespace enums{ enum color{ red = 1}; }')
         ],
         xml_generator_config=autoconfig.xml_generator_config)
     mb.namespace(name='::enums').include()
     enum_matcher = declarations.match_declaration_t(name='color')
     mb.build_code_creator('dummy')
     enum_found = code_creators.creator_finder.find_by_declaration(
         enum_matcher, mb.code_creator.creators)
     self.assertTrue(enum_found)