本文整理汇总了Python中pygccxml.parser.source_reader_t函数的典型用法代码示例。如果您正苦于以下问题:Python source_reader_t函数的具体用法?Python source_reader_t怎么用?Python source_reader_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了source_reader_t函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:15,代码来源:cache_enums_tester.py
示例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]>'))
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:25,代码来源:gccxml10185_tester.py
示例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&)')
开发者ID:programmdesign,项目名称:pygccxml,代码行数:7,代码来源:gccxml10183_tester.py
示例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 )
开发者ID:programmdesign,项目名称:pygccxml,代码行数:35,代码来源:xmlfile_reader_tester.py
示例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)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:25,代码来源:project_reader_correctness_tester.py
示例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 ))
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:28,代码来源:code_generator.py
示例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)
开发者ID:MarkOates,项目名称:pygccxml,代码行数:30,代码来源:test_va_list_tag_removal.py
示例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)
开发者ID:MarkOates,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py
示例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
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:9,代码来源:patcher_tester.py
示例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)
开发者ID:MarkOates,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py
示例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)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py
示例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
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:10,代码来源:patcher_tester.py
示例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
开发者ID:gccxml,项目名称:pygccxml,代码行数:10,代码来源:patcher_tester.py
示例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 )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:11,代码来源:hierarchy_traveling.py
示例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)
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:12,代码来源:hierarchy_traveling.py
示例16: test
def test(self):
src_reader = parser.source_reader_t(self.config)
global_ns = declarations.get_global_namespace(
src_reader.read_string(code))
# TODO: demangled attribute does not existe for castxml
# and will not be added. Remove this test once gccxml
# support is dropped.
if 'GCCXML' in utils.xml_generator:
global_ns.decl('A<int>')
f = global_ns.free_fun('f')
self.assertTrue(f.demangled == 'void f<int>(A<int> const&)')
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:12,代码来源:gccxml10183_tester.py
示例17: setUp
def setUp(self):
reader = parser.source_reader_t( self.config )
decls = None
if 32 == self.architecture:
decls = reader.read_file( self.header )
else:
original_get_architecture = utils.get_architecture
utils.get_architecture = lambda: 64
decls = reader.read_xml_file(
os.path.join( autoconfig.data_directory, 'demangled_tester_64bit.xml' ) )
utils.get_architecture = original_get_architecture
self.global_ns = declarations.get_global_namespace( decls )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:12,代码来源:demangled_tester.py
示例18: test_keep_va_list_tag
def test_keep_va_list_tag(self):
if "gccxml" in self.config.xml_generator or \
platform.system() == 'Windows':
return True
self.config.flags = ["f1"]
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.assertTrue(tag in [class_.name for class_ in classes])
self.assertTrue("a" in [class_.name for class_ in classes])
if len(classes) == 2:
for c in self.known_classes:
self.assertTrue(c in [cl.name for cl in classes])
elif len(classes) == 3:
for c in self.known_classes_llvm39:
# This is for llvm 3.9
self.assertTrue(c in [cl.name for cl in classes])
self.assertTrue(len(typedefs) == 4 or len(typedefs) == 5)
if len(typedefs) == 5:
# This is for llvm 3.9. The class __va_list_tag struct is still
# there but the typedef is gone
for t in self.known_typedefs_llvm39:
self.assertTrue(t in [ty.name for ty in typedefs])
self.assertTrue(
"__NSConstantString_tag" in
[class_.name for class_ in classes])
self.assertTrue(
"__NSConstantString" in [ty.name for ty in typedefs])
else:
for t in self.known_typedefs:
self.assertTrue(t in [ty.name for ty in typedefs])
self.assertTrue(
tag in [var.decl_string.split("::")[1] for var in variables])
# 4 variables in __va_list_tag, and 4 more in __NSConstantString_tag
# for llvm 3.9
self.assertTrue(len(variables) == 4 or len(variables) == 8)
开发者ID:gccxml,项目名称:pygccxml,代码行数:52,代码来源:test_va_list_tag_removal.py
示例19: 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 = [
inst for inst in decls if isinstance(
inst,
declarations.class_t)]
for class_ in classes:
self.failUnless(class_.name in self.__recursive_derived)
all_derived = class_.recursive_derived
control_derived = self.__recursive_derived[class_.name]
self.failUnless(len(control_derived) == len(all_derived))
all_derived_names = [hi.related_class.name for hi in all_derived]
self.failUnless(set(all_derived_names) == control_derived)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:14,代码来源:hierarchy_traveling.py
示例20: test
def test(self):
prj_reader = parser.project_reader_t( self.config )
prj_decls = prj_reader.read_files( self.__files
, compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
src_reader = parser.source_reader_t( self.config )
src_decls = src_reader.read_file( 'separate_compilation/all.h' )
declarations.dump_declarations( src_decls
, os.path.join( autoconfig.build_directory, 'separate_compilation.sr.txt' ) )
declarations.dump_declarations( prj_decls
, os.path.join( autoconfig.build_directory, 'separate_compilation.pr.txt' ) )
self.failUnless( src_decls == prj_decls, "There is a difference between declarations" )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:14,代码来源:project_reader_correctness_tester.py
注:本文中的pygccxml.parser.source_reader_t函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论