예제 #1
0
 def test( self ):                
     self.global_ns.free_fun( 'hello_sum' )
     self.global_ns.free_fun( 'hello_print' )
     declarations.print_declarations( self.global_ns )
     f = self.global_ns.free_fun( 'do_smth' )
     for arg in f.arguments:
         print arg.type.decl_string
 def __test_correctness_impl(self, file_name):
     prj_reader = parser.project_reader_t(self.config)
     prj_decls = prj_reader.read_files(
         [file_name] * 2,
         compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
     src_reader = parser.source_reader_t(self.config)
     src_decls = src_reader.read_file(file_name)
     if src_decls != prj_decls:
         s = src_decls[0]
         p = prj_decls[0]
         sr = file(
             os.path.join(autoconfig.build_directory,
                          file_name + '.sr.txt'), 'w+')
         pr = file(
             os.path.join(autoconfig.build_directory,
                          file_name + '.pr.txt'), 'w+')
         declarations.print_declarations(
             s, writer=lambda l: sr.write(l + os.linesep))
         declarations.print_declarations(
             p, writer=lambda l: pr.write(l + os.linesep))
         sr.close()
         pr.close()
         self.fail(
             "There is a difference between declarations in file %s." %
             file_name)
 def __test_correctness_impl(self, file_name):
     prj_reader = parser.project_reader_t(self.config)
     prj_decls = prj_reader.read_files(
         [file_name] * 2,
         compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
     src_reader = parser.source_reader_t(self.config)
     src_decls = src_reader.read_file(file_name)
     if src_decls != prj_decls:
         s = src_decls[0]
         p = prj_decls[0]
         sr = open(
             os.path.join(
                 autoconfig.build_directory, file_name + '.sr.txt'), 'w+')
         pr = open(
             os.path.join(
                 autoconfig.build_directory, file_name + '.pr.txt'), 'w+')
         declarations.print_declarations(
             s, writer=lambda l: sr.write(l + os.linesep))
         declarations.print_declarations(
             p, writer=lambda l: pr.write(l + os.linesep))
         sr.close()
         pr.close()
         self.fail(
             "There is a difference between declarations in file %s." %
             file_name)
예제 #4
0
 def test(self):
     self.global_ns.free_fun('hello_sum')
     self.global_ns.free_fun('hello_print')
     declarations.print_declarations(self.global_ns)
     f = self.global_ns.free_fun('do_smth')
     for arg in f.arguments:
         print arg.type.decl_string
    def test(self):
        module_builder.set_logger_level( logging.CRITICAL )
        messages.disable( *messages.all_warning_msgs )

        xml_file = parser.create_gccxml_fc( os.path.join( autoconfig.data_directory, 'particleuniverse.xml' ) )

        mb = module_builder.module_builder_t(
                [ xml_file ]
                , gccxml_path=autoconfig.gccxml.executable
                , indexing_suite_version=2
                , compiler=pygccxml.utils.native_compiler.get_gccxml_compiler())

        mb.global_ns.exclude()
        mb.namespace('ParticleUniverse').include()
        mb.namespace('Ogre').include()
        mb.namespace('Ogre').classes().already_exposed = True

        target_dir = os.path.join( autoconfig.build_directory, 'particle_universe' )
        #~ if os.path.exists( target_dir ):
            #~ shutil.rmtree( target_dir )
        #~ os.mkdir( target_dir )
        psp = mb.class_( '::ParticleUniverse::ParticleScriptParser' )
        declarations.print_declarations( psp )
        mb.build_code_creator( 'PU' )
        mb.split_module( target_dir )
예제 #6
0
 def test_pdbs( self ):
     for f in filter( lambda f: f.endswith( 'pdb' ), os.listdir( r'E:\pdbs' ) ):
         try:
             reader = mspdb.decl_loader_t( f )
             reader.read()
             f = file( d + '.txt', 'w+' )
             declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
             f.close()
         except Exception, error:
             print 'unable to load pdb file ', f, ' Error: ', str(error)
예제 #7
0
 def test_pdbs(self):
     for f in filter(lambda f: f.endswith('pdb'), os.listdir(r'E:\pdbs')):
         try:
             reader = pdb.decl_loader_t(f)
             reader.read()
             f = file(d + '.txt', 'w+')
             declarations.print_declarations(
                 reader.global_ns, writer=lambda line: f.write(line + '\n'))
             f.close()
         except Exception, error:
             print 'unable to load pdb file ', f, ' Error: ', str(error)
 def show_declarations( self, file_configuration, compiler_config ):
     try:
         reader = parser.project_reader_t( config=compiler_config )
         decls = reader.read_files( [file_configuration] )
         global_ns = declarations.get_global_namespace( decls )
         tmp = []
         declarations.print_declarations( decls, verbose=False, writer=lambda x: tmp.append( x.rstrip() ) )
         return os.linesep.join( tmp ), ''
     except Exception, error:
         user_msg = [ 'Error occured during code generation process!' ]
         user_msg.append( 'Error:' )
         user_msg.append( str( error ) )
         return '', '\n'.join( user_msg )
예제 #9
0
    def test_create_nss(self):
        reader = mspdb.decl_loader_t( self.pdb_file )
        print reader.symbols_table.name
        reader.read()
        f = file( 'decls.cpp', 'w+' )
        declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
        f.close()

        f = file( 'symbols.txt', 'w+')
        for smbl in reader.symbols.itervalues():
            f.write( smbl.uname )
            f.write( os.linesep )
            f.write( '\t' + str(smbl.name) )
        f.close()
예제 #10
0
    def test_create_nss(self):
        reader = pdb.decl_loader_t(self.pdb_file)
        print reader.symbols_table.name
        reader.read()
        f = file('decls.cpp', 'w+')
        declarations.print_declarations(
            reader.global_ns, writer=lambda line: f.write(line + '\n'))
        f.close()

        f = file('symbols.txt', 'w+')
        for smbl in reader.symbols.itervalues():
            f.write(smbl.uname)
            f.write(os.linesep)
            f.write('\t' + str(smbl.name))
        f.close()
예제 #11
0
    def test_printer(self):

        # Redirect sys.stdout to a class with a writer doing nothing
        # This greatly reduces the size of the test output and makes
        # test log files readable.
        # Note: flush needs to be defined; because if not this will
        # result in an AttributeError on call.
        class DontPrint(object):
            def write(*args):
                pass

            def flush(*args):
                pass
        sys.stdout = DontPrint()

        declarations.print_declarations(self.decls, writer=None)
예제 #12
0
    def test_printer(self):

        # Redirect sys.stdout to a class with a writer doing nothing
        # This greatly reduces the size of the test output and makes
        # test log files readable.
        # Note: flush needs to be defined; because if not this will
        # result in an AttributeError on call.
        class DontPrint(object):
            def write(*args):
                pass

            def flush(*args):
                pass

        sys.stdout = DontPrint()

        declarations.print_declarations(self.decls, writer=None)
예제 #13
0
def pygccxml_parser(filename):
    """
    Implementation of pygccxml parser
    """
    generator_path, generator_name = utils.find_xml_generator()

    # Configure the xml generator
    xml_generator_config = parser.xml_generator_configuration_t(
        xml_generator_path=generator_path, xml_generator=generator_name)
    filename = filename
    decls = parser.parse([filename], xml_generator_config)

    global_namespace = declarations.get_global_namespace(decls)
    ns = global_namespace.namespace("sample_namespace")
    return declarations.print_declarations(ns)
pprint.pprint( public_smbls )

#~ for smbl in reader.symbols.itervalues():
    #~ if not smbl.classParent:
        #~ continue
    #~ undecorated_name = smbl.get_undecoratedNameEx(opt)
    #~ if not undecorated_name:
        #~ continue
    #~ undecorated_name = undecorated_name.strip()
    #~ if undecorated_name not in public_smbls:
        #~ continue
    #~ print '--------------------------------------'
    #~ print 'mem fun: ', undecorated_name
    #~ if smbl.classParent:
        #~ print 'parent class: ', smbl.classParent.name
    #~ else:
        #~ print 'no parent'
    #~ print '======================================'
reader.read()
f = file( 'decls.cpp', 'w+' )
declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
f.close()

#~ f = file( 'symbols.txt', 'w+')
#~ for smbl in reader.symbols.itervalues():
    #~ f.write( smbl.uname )
    #~ f.write( os.linesep )
    #~ f.write( '\t' + str(smbl.name) )
#~ f.close()

예제 #15
0
 def test_printer(self):
     writer = lambda decl: None
     declarations.print_declarations(self.decls, writer=writer)
예제 #16
0
# Configure the xml generator
config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name,
    compiler="gcc")

# Parsing source file
decls = parser.parse([this_module_dir_path + '/example.hpp'], config)
global_ns = declarations.get_global_namespace(decls)

# Get object that describes unittests namespace
unittests = global_ns.namespace('unittests')

print('"unittests" declarations: \n')
declarations.print_declarations(unittests)

# Print all base and derived class names
for class_ in unittests.classes():
    print('class "%s" hierarchy information:' % class_.name)
    print('\tbase classes   : ',
          repr([base.related_class.name for base in class_.bases]))
    print('\tderived classes: ',
          repr([derive.related_class.name for derive in class_.derived]))
    print('\n')

# Pygccxml has very powerfull query api:

# Select multiple declarations
run_functions = unittests.member_functions('run')
print('the namespace contains %d "run" member functions' % len(run_functions))
예제 #17
0
from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
import pygccxml
import sys

# Find the location of the xml generator (castxml or gccxml)
generator_path, generator_name = utils.find_xml_generator()

# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name,
    include_paths=[str(x[2:]) for x in sys.argv[2:]],
    cflags=' '.join(str(x) for x in sys.argv[2:]))

# Parse the c++ file
decls = parser.parse([sys.argv[1]], xml_generator_config)
declarations.print_declarations(decls)
예제 #18
0
 def test_printer(self):
     writer = lambda decl: None
     declarations.print_declarations( self.decls, writer=writer )
예제 #19
0
파일: example.py 프로젝트: gccxml/pygccxml
# Configure the xml generator
config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name,
    compiler="gcc")

# Parsing source file
decls = parser.parse([this_module_dir_path + '/example.hpp'], config)
global_ns = declarations.get_global_namespace(decls)

# Get object that describes unittests namespace
unittests = global_ns.namespace('unittests')

print('"unittests" declarations: \n')
declarations.print_declarations(unittests)

# Print all base and derived class names
for class_ in unittests.classes():
    print('class "%s" hierarchy information:' % class_.name)
    print('\tbase classes   : ', repr([
        base.related_class.name for base in class_.bases]))
    print('\tderived classes: ', repr([
        derive.related_class.name for derive in class_.derived]))
    print('\n')

# Pygccxml has very powerfull query api:

# Select multiple declarations
run_functions = unittests.member_functions('run')
print('the namespace contains %d "run" member functions' % len(run_functions))
예제 #20
0
# Copyright 2004 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import sys
sys.path.append('../..') #adding pygccxml to the path

from pygccxml import parser
from pygccxml import declarations

#configure GCC-XML parser
config = parser.config_t( gccxml_path='/home/roman/gccxml-build/bin/gccxml' )

#parsing source file
decls = parser.parse( ['example.hpp'], config )
global_ns = declarations.get_global_namespace( decls )

#printing all declarations found in file and its includes
declarations.print_declarations( global_ns )

#print all base and derived class names
for class_ in global_ns.classes():
    print class_.name
    print '\tbases: ', `[base.related_class.name for base in class_.bases]`
    print '\tderived: ', `[derive.related_class.name for derive in class_.derived]`