Example #1
0
 def test(self):
     mb = module_builder.module_builder_t(
         [ module_builder.create_text_fc( self.CODE )]
         , gccxml_path=autoconfig.gccxml.executable )
     d = mb.class_( 'derived' )
     f = d.mem_fun( 'f' )
     self.failUnless( f.create_with_signature == True )
    def test(self):

        code = """
            namespace xyz{
                struct Y;

                struct X{
                    X();
                    X( const X& );
                    X( Y* );
                };
            }
        """

        mb = module_builder.module_builder_t(
            [module_builder.create_text_fc(code)],
            xml_generator_config=autoconfig.xml_generator_config)

        x = mb.class_('X')
        x.include()
        x.constructors().body = '    //all constructors body'
        x.null_constructor_body = '    //null constructor body'
        x.copy_constructor_body = '    //copy constructor body'

        mb.build_code_creator('XXX')
        code = mb.code_creator.create()
        tmp = code.split(x.null_constructor_body)
        self.assertTrue(len(tmp) == 2)
        tmp = code.split(x.copy_constructor_body)
        self.assertTrue(len(tmp) == 2)
        tmp = code.split('    //all constructors body')
        self.assertTrue(len(tmp) == 2)
    def test(self):

        code = """
            namespace xyz{

                struct good{};

                typedef void (*ff1)( int, int );

                void f_bad( ff1 );

            }
        """

        mb = module_builder.module_builder_t(
            [module_builder.create_text_fc(code)],
            xml_generator_config=autoconfig.xml_generator_config)

        xyz = mb.namespace(name='xyz')
        xyz.include()

        xyz.exclude(compilation_errors=True)

        self.assertTrue(xyz.ignore == False)
        self.assertTrue(xyz.class_('good').ignore == False)
        self.assertTrue(xyz.free_function('f_bad').ignore == True)
Example #4
0
 def test(self):
     
     code = """
         namespace xyz{
         
             struct good{};
             
             typedef void (*ff1)( int, int );
             
             void f_bad( ff1 );
             
         }
     """
     
     mb = module_builder.module_builder_t( 
             [ module_builder.create_text_fc( code ) ]
             , gccxml_path=autoconfig.gccxml.executable )
     
     xyz = mb.namespace( name='xyz' )
     xyz.include()
     
     xyz.exclude(compilation_errors=True)
     
     self.failUnless( xyz.ignore == False )
     self.failUnless( xyz.class_( 'good' ).ignore == False )
     self.failUnless( xyz.free_fun( 'f_bad' ).ignore == True )
 def test(self):
     mb = module_builder.module_builder_t(
         [module_builder.create_text_fc(self.CODE)],
         xml_generator_config=autoconfig.xml_generator_config)
     d = mb.class_('derived')
     f = d.member_function('f')
     self.assertTrue(f.create_with_signature == True)
Example #6
0
 def test(self):
     
     code = """
         namespace xyz{
             struct Y;
             
             struct X{
                 X();
                 X( const X& );       
                 X( Y* );
             };
         }
     """
     
     mb = module_builder.module_builder_t( 
             [ module_builder.create_text_fc( code ) ]
             , gccxml_path=autoconfig.gccxml.executable )
     
     x = mb.class_( 'X' )
     x.include()
     x.constructors().body = '    //all constructors body'
     x.null_constructor_body = '    //null constructor body'
     x.copy_constructor_body = '    //copy constructor body'
     
     mb.build_code_creator( 'XXX' )
     code = mb.code_creator.create()
     tmp = code.split( x.null_constructor_body )
     self.failUnless( len( tmp ) == 2 )
     tmp = code.split( x.copy_constructor_body )
     self.failUnless( len( tmp ) == 2 )
     tmp = code.split( '    //all constructors body' )
     self.failUnless( len( tmp ) == 2 )
Example #7
0
 def test(self):
     mb = module_builder.module_builder_t(
             [ module_builder.create_text_fc( 'namespace enums{ enum { OK=1 }; }' ) ]
             , gccxml_path=autoconfig.gccxml.executable )
     mb.namespace( name='::enums' ).include()
     mb.build_code_creator('dummy')
     flatten = code_creators.make_flatten(mb.code_creator.creators)
     self.failUnless( filter( lambda inst: isinstance( inst, code_creators.unnamed_enum_t ), flatten ) )
Example #8
0
 def test(self):
     mb = module_builder.module_builder_t(
         [ module_builder.create_text_fc( 'namespace arr{ struct x{ x( int arr[3][3], int ){} x( const x arr[3][3], int ){} }; }' )]
         , gccxml_path=autoconfig.gccxml.executable )
     arr = mb.namespace( name='arr' )
     mem_funs = arr.calldefs( 'x', arg_types=[None,None] )
     for x in mem_funs:
         self.failUnless( x.exportable == False )
    def test(self):
        mb = module_builder.module_builder_t(
                        [ module_builder.create_text_fc( 'struct x{};' ) ]
                        , xml_generator_config=autoconfig.xml_generator_config
                        , encoding='UTF-8')

        mb.build_code_creator( module_name='unicode_bug' )
        mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
        mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) )
Example #10
0
 def test(self):
     mb = module_builder.module_builder_t(
         [ module_builder.create_text_fc( self.CODE )]
         , gccxml_path=autoconfig.gccxml.executable )
     xxx = mb.namespace( name='xxx' )
     fun = xxx.calldef( 'do_smth' )
     self.failUnless( fun.readme() == [] )
     minus_minus = xxx.operator( symbol='--' )
     self.failUnless( 1 == len( minus_minus.readme() ), os.linesep.join( minus_minus.readme() ) )
Example #11
0
 def test(self):
     mb = module_builder.module_builder_t(
             [ module_builder.create_text_fc( 'namespace enums{ enum { OK=1 }; }' ) ]
             , gccxml_path=autoconfig.gccxml.executable
             , compiler=pygccxml.utils.native_compiler.get_gccxml_compiler() )
     mb.namespace( name='::enums' ).include()
     mb.build_code_creator('dummy')
     flatten = code_creators.make_flatten(mb.code_creator.creators)
     self.failUnless( [inst for inst in flatten if isinstance( inst, code_creators.unnamed_enum_t )] )
 def test(self):
     mb = module_builder.module_builder_t(
         [module_builder.create_text_fc(self.CODE)],
         xml_generator_config=autoconfig.xml_generator_config)
     xxx = mb.namespace(name='xxx')
     fun = xxx.calldef('do_smth')
     self.assertTrue(fun.readme() == [])
     minus_minus = xxx.operator(symbol='--')
     self.assertTrue(1 == len(minus_minus.readme()),
                     os.linesep.join(minus_minus.readme()))
Example #13
0
    def test(self):
        mb = module_builder.module_builder_t(
                        [ module_builder.create_text_fc( 'struct x{};' ) ]
                        , gccxml_path=autoconfig.gccxml.executable
                        , encoding='UTF-8'
                        , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler)

        mb.build_code_creator( module_name='unicode_bug' )
        mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
        mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) )
Example #14
0
    def test(self):
        mb = module_builder.module_builder_t(
                        [ module_builder.create_text_fc( 'struct x{};' ) ]
                        , gccxml_path=autoconfig.gccxml.executable
                        , encoding='UTF-8'
                        , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler)

        mb.build_code_creator( module_name='unicode_bug' )
        mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
        mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) )
Example #15
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 )
Example #16
0
 def test_find_by_class_instance(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()
     mb.build_code_creator('dummy')
     enum_found = code_creators.creator_finder.find_by_class_instance(
         code_creators.enum_t
         , mb.code_creator.creators
         , recursive=True)
     self.failUnless( enum_found )
 def test_find_by_class_instance(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()
     mb.build_code_creator('dummy')
     enum_found = code_creators.creator_finder.find_by_class_instance(
         code_creators.enum_t, mb.code_creator.creators, recursive=True)
     self.assertTrue(enum_found)
 def test(self):
     mb = module_builder.module_builder_t([
         module_builder.create_text_fc(
             'namespace arr{ struct x{ x( int arr[3][3], int ){} x( const x arr[3][3], int ){} }; }'
         )
     ],
                                          xml_generator_config=autoconfig.
                                          xml_generator_config)
     arr = mb.namespace(name='arr')
     mem_funs = arr.calldefs('x', arg_types=[None, None])
     for x in mem_funs:
         self.assertTrue(x.exportable == False)
 def test(self):
     mb = module_builder.module_builder_t([
         module_builder.create_text_fc('namespace enums{ enum { OK=1 }; }')
     ],
                                          xml_generator_config=autoconfig.
                                          xml_generator_config)
     mb.namespace(name='::enums').include()
     mb.build_code_creator('dummy')
     flatten = code_creators.make_flatten(mb.code_creator.creators)
     self.assertTrue([
         inst for inst in flatten
         if isinstance(inst, code_creators.unnamed_enum_t)
     ])
 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)
Example #21
0
 def test(self):
     
     code = """
         namespace xyz{
             void do_smth( int, ... );
         }
     """
     
     mb = module_builder.module_builder_t( 
             [ module_builder.create_text_fc( code ) ]
             , gccxml_path=autoconfig.gccxml.executable )
     
     do_smth = mb.free_fun( 'do_smth' )
     
     self.failUnless( do_smth.exportable == False )
     print do_smth.why_not_exportable()
    def test(self):

        code = """
            namespace xyz{
                void do_smth( int, ... );
            }
        """

        mb = module_builder.module_builder_t(
            [module_builder.create_text_fc(code)],
            xml_generator_config=autoconfig.xml_generator_config)

        do_smth = mb.free_function('do_smth')

        self.assertTrue(do_smth.exportable == False)
        print(do_smth.why_not_exportable())
 def test(self):
     mb = module_builder.module_builder_t(
         [module_builder.create_text_fc(self.CLASS_DEF)],
         xml_generator_config=autoconfig.xml_generator_config)
     mb.namespace(name='::tester').include()
     x = mb.class_('x')
     x.add_registration_code('//hello world reg')
     x.add_declaration_code('//hello world decl')
     nested = x.class_('x_nested')
     nested.add_declaration_code('//hello nested decl')
     nested.add_registration_code('//hello nested reg', False)
     mb.calldefs('check_overload').use_overload_macro = True
     mb.calldefs( 'get_opaque' ).call_policies \
       = module_builder.call_policies.return_value_policy( module_builder.call_policies.return_opaque_pointer )
     mb.class_('op_struct').exclude()
     mb.member_function( 'get_rate' ).call_policies \
         = module_builder.call_policies.return_value_policy( module_builder.call_policies.return_pointee_value )
     mb.member_function('get_size').add_transformation(ft.output(0))
     mb.build_code_creator('x_class_multi')
     mb.split_module(autoconfig.build_dir, [mb.class_('::tester::x')],
                     on_unused_file_found=lambda fpath: fpath,
                     use_files_sum_repository=True)
Example #24
0
 def test(self):
     mb = module_builder.module_builder_t(
             [ module_builder.create_text_fc( self.CLASS_DEF ) ]
             , gccxml_path=autoconfig.gccxml.executable )
     mb.namespace( name='::tester' ).include()
     x = mb.class_( 'x' )
     x.add_registration_code( '//hello world reg' )
     x.add_declaration_code( '//hello world decl' )
     nested = x.class_( 'x_nested' )
     nested.add_declaration_code( '//hello nested decl' )
     nested.add_registration_code( '//hello nested reg', False )
     mb.calldefs( 'check_overload' ).use_overload_macro = True
     mb.calldefs( 'get_opaque' ).call_policies \
       = module_builder.call_policies.return_value_policy( module_builder.call_policies.return_opaque_pointer )
     mb.class_( 'op_struct' ).exclude()
     mb.mem_fun( 'get_rate' ).call_policies \
         = module_builder.call_policies.return_value_policy( module_builder.call_policies.return_pointee_value )
     mb.mem_fun( 'get_size' ).add_transformation( ft.output(0) )
     mb.build_code_creator('x_class_multi')
     mb.split_module( autoconfig.build_dir
                     , [ mb.class_( '::tester::x' ) ]
                     , on_unused_file_found=lambda fpath: fpath
                     , use_files_sum_repository=True)
Example #25
0
# -*- coding: UTF-8 -*-

import os
import unittest
import autoconfig
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import code_creators
from pyplusplus import module_creator
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft


mb = module_builder.module_builder_t(
    [module_builder.create_text_fc("struct x{};")], gccxml_path=autoconfig.gccxml.executable, encoding="UTF-8"
)

mb.build_code_creator(module_name="unicode_bug")
mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
mb.write_module(os.path.join(autoconfig.build_dir, "unicode_bug.cpp"))
Example #26
0
# -*- coding: UTF-8 -*-

import os
import unittest
import autoconfig
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import code_creators
from pyplusplus import module_creator
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft


mb = module_builder.module_builder_t( 
                [ module_builder.create_text_fc( 'struct x{};' ) ]
                , gccxml_path=autoconfig.gccxml.executable 
                , encoding='UTF-8')

mb.build_code_creator( module_name='unicode_bug' )
mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) )