예제 #1
0
    def test(self):
        db = pypp_utils.exposed_decls_db_t()
        config = parser.config_t(
            gccxml_path=autoconfig.gccxml.executable,
            compiler=pygccxml.utils.native_compiler.get_gccxml_compiler())

        reader = parser.project_reader_t(config, None,
                                         decl_wrappers.dwfactory_t())
        decls = reader.read_files([parser.create_text_fc(self.CODE)])

        global_ns = declarations.get_global_namespace(decls)
        ns = global_ns.namespace('ns')
        ns_skip = global_ns.namespace('ns_skip')

        global_ns.exclude()
        ns.include()

        db.register_decls(global_ns, [])

        for x in ns.decls(recursive=True):
            self.failUnless(db.is_exposed(x) == True)

        for x in ns_skip.decls(recursive=True):
            self.failUnless(db.is_exposed(x) == False)

        db.save(os.path.join(autoconfig.build_dir, 'exposed.db.pypp'))

        db2 = pypp_utils.exposed_decls_db_t()
        db2.load(os.path.join(autoconfig.build_dir, 'exposed.db.pypp'))
        for x in ns.decls(recursive=True):
            self.failUnless(db.is_exposed(x) == True)

        ns_skip = global_ns.namespace('ns_skip')
        for x in ns_skip.decls(recursive=True):
            self.failUnless(db.is_exposed(x) == False)
    def test(self):
        db = pypp_utils.exposed_decls_db_t()
        config = parser.config_t( gccxml_path=autoconfig.gccxml.executable )

        reader = parser.project_reader_t( config, None, decl_wrappers.dwfactory_t() )
        decls = reader.read_files( [parser.create_text_fc(self.CODE)] )
    
        global_ns = declarations.get_global_namespace( decls )
        ns = global_ns.namespace( 'ns' )
        ns_skip = global_ns.namespace( 'ns_skip' )

        global_ns.exclude()        
        ns.include()
        
        db.register_decls( global_ns, [] )
                    
        for x in ns.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == True )
            
        for x in ns_skip.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == False )

        db.save( os.path.join( autoconfig.build_dir, 'exposed.db.pypp' ) )

        db2 = pypp_utils.exposed_decls_db_t()
        db2.load( os.path.join( autoconfig.build_dir, 'exposed.db.pypp' ) )
        for x in ns.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == True )

        ns_skip = global_ns.namespace( 'ns_skip' )
        for x in ns_skip.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == False )
예제 #3
0
    def customize( self, mb ):
        mb.global_ns.exclude()

        nm_t = declarations.remove_declarated( mb.global_ns.typedef( 'naive_matrix_t' ).type )
        nm_t.include()

        exposed_db = utils.exposed_decls_db_t()

        exposed_db.register_decls( mb.global_ns, [] )
        exposed_db.save( autoconfig.build_dir )
        mb.register_module_dependency( autoconfig.build_dir )

        sm = mb.global_ns.namespace( name='split_module' )
        sm.include()
        sm.class_( 'op_struct' ).exclude()

        mb.free_function( 'check_overload' ).add_declaration_code( '//hello check_overload' )
        mb.free_function( 'get_opaque' ).add_declaration_code( '//hello get_opaque' )

        mb.calldefs( 'check_overload' ).use_overload_macro = True
        mb.calldefs( 'get_opaque' ).call_policies \
          = call_policies.return_value_policy( call_policies.return_opaque_pointer )

        mb.class_( 'op_struct' ).exclude()
        item = mb.class_( 'item_t' )
        item.add_declaration_code( '//hello world' )
        nested = item.class_( 'nested_t' )
        nested.add_declaration_code( '//hello nested decl' )
        nested.add_registration_code( '//hello nested reg', False )
        mb.free_fun( 'create_empty_mapping' ).include()
예제 #4
0
 def __test_already_exposed( self, mb ):
     exposed_db = utils.exposed_decls_db_t()
     exposed_db.load( autoconfig.build_dir )
     irrelevant_decl_types = ( declarations.typedef_t
                               , declarations.namespace_t
                               , declarations.free_operator_t )
     specially_exposed_decls = mb.code_creator.specially_exposed_decls
     for d in mb.decls():
         if not d.exportable:
             continue
         elif isinstance( d, declarations.free_operator_t ):
             continue
         elif d.ignore:
             if d in specially_exposed_decls:
                 continue
             if exposed_db.is_exposed( d ):
                 i = 0
             self.failUnless( not exposed_db.is_exposed( d )
                              , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.'''
                                % str( d ) )
         elif d.parent \
              and isinstance( d.parent, declarations.class_t ) \
              and d.parent.indexing_suite:
             continue
         else:
             self.failUnless( exposed_db.is_exposed( d )
                              , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.'''
                                % str( d ) )
 def __test_already_exposed( self, mb ):
     exposed_db = utils.exposed_decls_db_t()
     exposed_db.load( autoconfig.build_dir )
     irrelevant_decl_types = ( declarations.typedef_t
                               , declarations.namespace_t
                               , declarations.free_operator_t )
     for d in mb.decls():            
         if not d.exportable:
             continue
         elif isinstance( d, declarations.free_operator_t ):
             continue
         elif d.ignore:
             if exposed_db.is_exposed( d ):
                 i = 0
             self.failUnless( not exposed_db.is_exposed( d )
                              , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.'''
                                % str( d ) )
         #if d.ignore or not d.exportable or isinstance( d, irrelevant_decl_types ):
             #continue
         #if d.parent and not d.parent.name:                
             #continue #unnamed classes
         else:
             self.failUnless( exposed_db.is_exposed( d )
                              , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.'''
                                % str( d ) )
예제 #6
0
 def __init__(self, extmodule, files_sum_repository=None, encoding='ascii'):
     object.__init__(self)
     self.__extmodule = extmodule
     self.__files_sum_repository = files_sum_repository
     self.__encoding=encoding
     if None is files_sum_repository:
         self.__files_sum_repository = md5sum_repository.dummy_repository_t()
     self.__exposed_decls_db = utils.exposed_decls_db_t()
     self.__exposed_decls_db.register_decls( extmodule.global_ns )
예제 #7
0
 def __init__(self, extmodule, files_sum_repository=None, encoding='ascii'):
     object.__init__(self)
     self.__extmodule = extmodule
     self.__files_sum_repository = files_sum_repository
     self.__encoding=encoding
     if None is files_sum_repository:
         self.__files_sum_repository = md5sum_repository.dummy_repository_t()
     self.__exposed_decls_db = utils.exposed_decls_db_t()
     self.__exposed_decls_db.register_decls( extmodule.global_ns
                                             , extmodule.specially_exposed_decls )
예제 #8
0
    def register_module_dependency( self, other_module_generated_code_dir ):
        """``already_exposed`` solution is pretty good when you mix hand-written
        modules with Py++ generated. It doesn't work/scale for "true"
        multi-module development. This is exactly the reason why ``Py++``_
        offers "semi automatic" solution.

        For every exposed module, ``Py++``_ generates "exposed_decl.pypp.txt" file.
        This file contains the list of all parsed declarations and whether they
        were included or excluded. Later, when you work on another module, you
        can tell ``Py++``_ that the current module depends on the previously
        generated one. ``Py++``_ will load "exposed_decl.pypp.txt" file and
        update the declarations.
        """

        db = utils.exposed_decls_db_t()
        db.load( other_module_generated_code_dir )
        db.update_decls( self.global_ns )
    def test(self):
        exposed_db = utils.exposed_decls_db_t()
        
        fpath = os.path.join( autoconfig.data_directory, 'already_exposed_to_be_exported.hpp' )
        mb = module_builder.module_builder_t( [module_builder.create_source_fc( fpath )]
                                              , gccxml_path=autoconfig.gccxml.executable )
        
        mb.global_ns.exclude()
        mb.namespace( 'already_exposed' ).include()
        exposed_db.register_decls( mb.global_ns )
        exposed_db.save( autoconfig.build_dir )
        mb.register_module_dependency( autoconfig.build_dir )
        mb.class_( 'ae_derived' ).include()

        mb.build_code_creator( 'xxx' )
        
        body = mb.code_creator.body
        self.failUnless( 1 == len( body.creators ) )
        ae_derived_code = body.creators[0].create()
        self.failUnless( mb.class_( 'ae_base' ).decl_string in ae_derived_code )