本文整理汇总了Python中pygccxml.parser.source_reader_t函数的典型用法代码示例。如果您正苦于以下问题:Python source_reader_t函数的具体用法?Python source_reader_t怎么用?Python source_reader_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了source_reader_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cache
def test_cache( self ):
cache = parser.file_cache_t( self.cache_file )
reader = parser.source_reader_t( self.config, cache )
decls1 = reader.read_file( self.header )
cache.flush()
cache = parser.file_cache_t( self.cache_file )
reader = parser.source_reader_t( self.config, cache )
decls2 = reader.read_file( self.header )
enum_matcher = declarations.declaration_matcher_t( name="EColor"
, decl_type=declarations.enumeration_t )
color1 = declarations.matcher.get_single( enum_matcher, decls1 )
color2 = declarations.matcher.get_single( enum_matcher, decls2 )
self.failUnless( color1.values == color2.values )
示例2: test
def test(self):
"""
The purpose of this test was to check if changes to GCCXML
would lead to changes in the outputted xml file (Meaning
the bug was fixed).
GCCXML wrongly outputted partial template specialization.
CastXML does not have this bug. In this case we check if
the template specialization can not be found; which is the
expected/wanted behaviour.
https://github.com/CastXML/CastXML/issues/20
"""
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
if 'GCCXML' in utils.xml_generator:
a = global_ns.class_('A<const char [N]>')
a.mem_fun('size')
elif 'CastXML' in utils.xml_generator:
self.assertRaises(
global_ns.declaration_not_found_t,
lambda: global_ns.class_('A<const char [N]>'))
示例3: test
def test(self):
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
global_ns.decl('A<int>')
f = global_ns.free_fun('f')
self.failUnless(f.demangled == 'void f<int>(A<int> const&)')
示例4: test
def test(self):
src_reader = parser.source_reader_t(self.config)
src_decls = src_reader.read_file(self.__fname)
xmlfile = src_reader.create_xml_file(self.__fname)
print(xmlfile)
try:
conf_t = parser.file_configuration_t
fconfig = conf_t(
data=xmlfile,
start_with_declarations=None,
content_type=conf_t.CONTENT_TYPE.GCCXML_GENERATED_FILE)
prj_reader = parser.project_reader_t(self.config)
prj_decls = prj_reader.read_files(
[fconfig],
compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
declarations.dump_declarations(
src_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.src.txt'))
declarations.dump_declarations(
prj_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.prj.txt'))
if src_decls != prj_decls:
self.fail(
"There is a difference between declarations in file %s." %
self.__fname)
finally:
pass # utils.remove_file_no_raise( xmlfile )
示例5: __test_correctness_impl
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)
示例6: gen_xml
def gen_xml(params, q_result, q_error):
'''
Generate XML code
@param params: List of parameters [gccxml,incPath,macros]
@param q_result: python queue to put result in
@param q_error: python queue to put error in
@return None (isn't evaluated)
'''
try:
config = parser.config_t( gccxml_path=params[0]
, include_paths=params[1]
, define_symbols=params[2])
header_file = params[3]
config.include_paths.append( os.path.split( header_file )[0] )
config.working_directory = os.path.split( header_file )[0]
reader = parser.source_reader_t( config=config )
xml_file = reader.create_xml_file( header_file )
xml_file_obj = file( xml_file )
q_result.put( xml_file_obj.read() )
xml_file_obj.close()
os.remove( xml_file )
#self._statistics.set_parse_time( parsed_time )
#self._statistics.set_code_generation_time( 0 )
except Exception, error:
q_result.put(str( error ))
q_error.put(str( error ))
示例7: test_remove_va_list_tag
def test_remove_va_list_tag(self):
if "gccxml" in self.config.xml_generator:
return True
self.config.flags = []
src_reader = parser.source_reader_t(self.config)
decls = declarations.make_flatten(src_reader.read_string(self.__code))
classes = [
i for i in decls if isinstance(i, declarations.class_t)]
typedefs = [
i for i in decls if isinstance(i, declarations.typedef_t)]
variables = [
i for i in decls if isinstance(i, declarations.variable_t)]
tag = "__va_list_tag"
self.assertFalse(tag in [class_.name for class_ in classes])
self.assertTrue("a" in [class_.name for class_ in classes])
self.assertTrue(len(classes) == 1)
self.assertFalse(tag in [ty.name for ty in typedefs])
self.assertTrue(len(typedefs) == 3)
self.assertFalse(
tag in [var.decl_string.split("::")[1] for var in variables])
self.assertTrue(len(variables) == 0)
示例8: test3
def test3(self):
code = 'int aaaa[2];'
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
aaaa_type = global_ns.variable('aaaa').type
self.assertTrue(
'int[2]' == aaaa_type.decl_string,
aaaa_type.decl_string)
示例9: setUp
def setUp( self ):
self.original_get_architecture = utils.get_architecture
utils.get_architecture = lambda: 64
if not tester_64_t.global_ns:
reader = parser.source_reader_t( self.config )
tester_64_t.global_ns = reader.read_xml_file(
os.path.join( autoconfig.data_directory, 'patcher_tester_64bit.xml' ) )[0].top_parent
self.global_ns = tester_64_t.global_ns
示例10: test4
def test4(self):
code = 'struct xyz{}; xyz aaaa[2][3];'
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
aaaa_type = global_ns.variable('aaaa').type
self.assertTrue(
'::xyz[2][3]' == aaaa_type.decl_string,
aaaa_type.decl_string)
示例11: test2
def test2(self):
code = 'int* aaaa[2][3][4][5];'
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
aaaa_type = global_ns.var('aaaa').type
self.failUnless(
'int *[2][3][4][5]' == aaaa_type.decl_string,
aaaa_type.decl_string)
示例12: setUp
def setUp( self ):
reader = parser.source_reader_t( self.config )
if 32 == self.architecture:
self.__decls = reader.read_file( 'patcher.hpp' )
else:
original_get_architecture = utils.get_architecture
utils.get_architecture = lambda: 64
self.__decls = reader.read_xml_file(
os.path.join( autoconfig.data_directory, 'patcher_tester_64bit.xml' ) )
utils.get_architecture = original_get_architecture
示例13: setUp
def setUp(self):
if not tester_32_t.global_ns:
reader = parser.source_reader_t(self.config)
tester_32_t.global_ns = reader.read_file(
"patcher.hpp")[0].top_parent
tester_32_t.xml_generator_from_xml_file = \
reader.xml_generator_from_xml_file
self.global_ns = tester_32_t.global_ns
self.xml_generator_from_xml_file = \
tester_32_t.xml_generator_from_xml_file
示例14: test_recursive_derived
def test_recursive_derived(self):
src_reader = parser.source_reader_t( self.config )
decls = declarations.make_flatten( src_reader.read_string( self.__code ) )
classes = filter( lambda inst: isinstance( inst, declarations.class_t ), decls )
for class_ in classes:
self.failUnless( self.__recursive_derived.has_key( class_.name ) )
all_derived = class_.recursive_derived
control_derived = self.__recursive_derived[ class_.name ]
self.failUnless( len(control_derived) == len( all_derived ) )
all_derived_names = map( lambda hi: hi.related_class.name, all_derived )
self.failUnless( set( all_derived_names ) == control_derived )
示例15: test_recursive_bases
def test_recursive_bases(self):
src_reader = parser.source_reader_t(self.config)
decls = declarations.make_flatten(src_reader.read_string(self.__code))
classes = [
inst for inst in decls if isinstance(inst, declarations.class_t)]
for class_ in classes:
self.assertTrue(class_.name in self.__recursive_bases)
all_bases = class_.recursive_bases
control_bases = self.__recursive_bases[class_.name]
self.assertTrue(len(control_bases) == len(all_bases))
all_bases_names = [hi.related_class.name for hi in all_bases]
self.assertTrue(set(all_bases_names) == control_bases)