本文整理汇总了Python中pygccxml.parser.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parseIncludeFile
def parseIncludeFile(f, define = [], includes = [], ps = 4):
global ptr_size
ptr_size = ps
gccxmlexe = os.getenv("GCCXML", "gccxml")
config = parser.config_t(gccxml_path = gccxmlexe, define_symbols = define, include_paths = includes)
functions = {}
if isinstance(f, list):
global_ns = parser.parse(f, config)
else:
global_ns = parser.parse([f], config)
all_decls = declarations.make_flatten(global_ns)
all_functions = filter(lambda decl: isinstance(decl, declarations.free_function_t), \
all_decls)
for f in all_functions:
if not f.name.startswith("__"):
# if f.name == "ReadFileEx":
functions[f.name] = parseFunction(f)
return functions
开发者ID:cigitalabires,项目名称:processtap,代码行数:25,代码来源:parser.py
示例2: test_directory_cache_twice
def test_directory_cache_twice(self):
"""
Setup two caches in a row.
The second run will reload the same cache directory.
"""
cache = parser.directory_cache_t(directory=self.cache_dir)
parser.parse([self.header], self.config, cache=cache)
cache = parser.directory_cache_t(directory=self.cache_dir)
parser.parse([self.header], self.config, cache=cache)
开发者ID:gccxml,项目名称:pygccxml,代码行数:10,代码来源:test_directory_cache.py
示例3: test_directory_cache_without_compression
def test_directory_cache_without_compression(self):
"""
Test the directory cache without compression
"""
# Test with compression OFF
cache = parser.directory_cache_t(directory=self.cache_dir)
# Generate a cache on first read
parser.parse([self.header], self.config, cache=cache)
# Read from the cache the second time
parser.parse([self.header], self.config, cache=cache)
开发者ID:gccxml,项目名称:pygccxml,代码行数:11,代码来源:test_directory_cache.py
示例4: test_attributes
def test_attributes(self):
decls = parser.parse([self.header], self.config)
Test.global_ns = declarations.get_global_namespace(decls)
Test.global_ns.init_optimizer()
numeric = self.global_ns.class_('numeric_t')
do_nothing = numeric.member_function('do_nothing')
arg = do_nothing.arguments[0]
generator = self.config.xml_generator_from_xml_file
if generator.is_castxml1 or \
(generator.is_castxml and
float(generator.xml_output_version) >= 1.137):
# This works since:
# https://github.com/CastXML/CastXML/issues/25
# https://github.com/CastXML/CastXML/pull/26
# https://github.com/CastXML/CastXML/pull/27
# The version bump to 1.137 came way later but this is the
# only way to make sure the test is running correctly
self.assertTrue("annotate(sealed)" == numeric.attributes)
self.assertTrue("annotate(no throw)" == do_nothing.attributes)
self.assertTrue("annotate(out)" == arg.attributes)
self.assertTrue(
numeric.member_operators(name="=")[0].attributes is None)
else:
self.assertTrue("gccxml(no throw)" == do_nothing.attributes)
self.assertTrue("gccxml(out)" == arg.attributes)
开发者ID:gccxml,项目名称:pygccxml,代码行数:28,代码来源:attributes_tester.py
示例5: setUp
def setUp(self):
if not tester_t.global_ns:
decls = parser.parse([self.header], self.config)
tester_t.global_ns = declarations.get_global_namespace(decls)
tester_t.global_ns.init_optimizer()
process = subprocess.Popen(
args='scons msvc_compiler=%s' %
autoconfig.cxx_parsers_cfg.gccxml.compiler,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=self.binary_parsers_dir)
process.stdin.close()
while process.poll() is None:
line = process.stdout.readline()
print(line.rstrip())
for line in process.stdout.readlines():
print(line.rstrip())
if process.returncode:
raise RuntimeError(
("unable to compile binary parser module. " +
"See output for the errors."))
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:25,代码来源:undname_creator_tester.py
示例6: setUp
def setUp(self):
if not Test.declarations:
Test.declarations = parser.parse([self.header], self.config)
Test.xml_generator_from_xml_file = \
self.config.xml_generator_from_xml_file
self.declarations = Test.declarations
self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file
开发者ID:gccxml,项目名称:pygccxml,代码行数:7,代码来源:type_traits_tester.py
示例7: test_map_gcc5
def test_map_gcc5(self):
"""
The code in test_map_gcc5.hpp was breaking pygccxml.
Test that case (gcc5 + castxml + c++11).
See issue #45 and #55
"""
if self.config.xml_generator == "gccxml":
return
decls = parser.parse([self.header], self.config)
global_ns = declarations.get_global_namespace(decls)
# This calldef is defined with gcc > 4.9 (maybe earlier, not tested)
# and -std=c++11. Calling create_decl_string is failing with gcc.
# With clang the calldef does not exist so the matcher
# will just return an empty list, letting the test pass.
# See the test_argument_without_name.py for an equivalent test,
# which is not depending on the presence of the _M_clone_node
# method in the stl_tree.h file.
criteria = declarations.calldef_matcher(name="_M_clone_node")
free_funcs = declarations.matcher.find(criteria, global_ns)
for free_funcs in free_funcs:
free_funcs.create_decl_string(with_defaults=False)
开发者ID:gccxml,项目名称:pygccxml,代码行数:27,代码来源:test_map_gcc5.py
示例8: test_dir_compatibility
def test_dir_compatibility(self):
"""
For retro-compatibility, test if the dir argument is still working
This test can be removed in v2.0.0.
"""
# Do not clutter the tests with warnings
warnings.simplefilter("ignore", DeprecationWarning)
cache = parser.directory_cache_t(dir=self.cache_dir, compression=True)
parser.parse([self.header], self.config, cache=cache)
# Reset this warning to always
warnings.simplefilter("error", DeprecationWarning)
开发者ID:gccxml,项目名称:pygccxml,代码行数:16,代码来源:test_directory_cache.py
示例9: setUp
def setUp(self):
if not self.declarations:
self.declarations = parser.parse(
['typedefs1.hpp',
'typedefs2.hpp'],
self.config,
self.COMPILATION_MODE)
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:7,代码来源:typedefs_tester.py
示例10: test_attributes_thiscall
def test_attributes_thiscall(self):
"""
Test attributes with the "f2" flag
"""
if self.config.compiler != "msvc":
return
self.config.flags = ["f2"]
decls = parser.parse([self.header], self.config)
Test.global_ns = declarations.get_global_namespace(decls)
Test.global_ns.init_optimizer()
numeric = self.global_ns.class_('numeric_t')
do_nothing = numeric.member_function('do_nothing')
arg = do_nothing.arguments[0]
generator = self.config.xml_generator_from_xml_file
if generator.is_castxml1 or (
generator.is_castxml and
float(generator.xml_output_version) >= 1.137):
self.assertTrue("annotate(sealed)" == numeric.attributes)
self.assertTrue("annotate(out)" == arg.attributes)
self.assertTrue(
"__thiscall__ annotate(no throw)" == do_nothing.attributes)
self.assertTrue(
numeric.member_operators(name="=")[0].attributes ==
"__thiscall__")
开发者ID:gccxml,项目名称:pygccxml,代码行数:30,代码来源:attributes_tester.py
示例11: setUp
def setUp(self):
if not self.declarations:
self.declarations = parser.parse( [self.header], self.config )
self.global_ns = declarations.find_declaration( self.declarations
, type=declarations.namespace_t
, name='::' )
self.global_ns.init_optimizer()
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:7,代码来源:typedefs_tester.py
示例12: global_namespace
def global_namespace():
#configure GCC-XML parser
config = parser.config_t( gccxml_path= "c:/Progra~1/GCC_XML/bin/gccxml.exe",\
include_paths= ["e:/starteam/docplatform/nextrelease/code/common"] )
#parsing source file
decls = parser.parse( ['interf.h'], config )
return declarations.get_global_namespace( decls )
开发者ID:Rogaven,项目名称:jagpdf,代码行数:7,代码来源:sig.py
示例13: test_function_pointer
def test_function_pointer(self):
"""
Test working with pointers and function pointers.
"""
decls = parser.parse([self.header], self.config)
global_ns = declarations.get_global_namespace(decls)
# Test on a function pointer
criteria = declarations.variable_matcher(name="func1")
variables = declarations.matcher.find(criteria, global_ns)
self.assertTrue(variables[0].name == "func1")
self.assertTrue(
isinstance(variables[0].decl_type, declarations.pointer_t))
self.assertTrue(
str(variables[0].decl_type) == "void (*)( int,double )")
self.assertTrue(
declarations.is_calldef_pointer(variables[0].decl_type))
self.assertTrue(
isinstance(declarations.remove_pointer(variables[0].decl_type),
declarations.free_function_type_t))
# Get the function (free_function_type_t) and test the return and
# argument types
function = variables[0].decl_type.base
self.assertTrue(isinstance(function.return_type, declarations.void_t))
self.assertTrue(
isinstance(function.arguments_types[0], declarations.int_t))
self.assertTrue(
isinstance(function.arguments_types[1], declarations.double_t))
# Test on a normal pointer
criteria = declarations.variable_matcher(name="myPointer")
variables = declarations.matcher.find(criteria, global_ns)
self.assertTrue(variables[0].name == "myPointer")
self.assertTrue(
isinstance(variables[0].decl_type, declarations.pointer_t))
self.assertFalse(
declarations.is_calldef_pointer(variables[0].decl_type))
self.assertTrue(
isinstance(declarations.remove_pointer(variables[0].decl_type),
declarations.volatile_t))
# Test on function pointer in struct (x8)
for d in global_ns.declarations:
if d.name == "x8":
self.assertTrue(
isinstance(d.decl_type, declarations.pointer_t))
self.assertTrue(declarations.is_calldef_pointer(d.decl_type))
self.assertTrue(
isinstance(
declarations.remove_pointer(d.decl_type),
declarations.member_function_type_t))
self.assertTrue(
str(declarations.remove_pointer(d.decl_type)) ==
"void ( ::some_struct_t::* )( )")
开发者ID:gccxml,项目名称:pygccxml,代码行数:59,代码来源:test_function_pointer.py
示例14: setUp
def setUp(self):
if not self.global_ns:
decls = parser.parse([self.header], self.config)
self.global_ns = declarations.get_global_namespace(decls)
self.global_ns.init_optimizer()
Test.xml_generator_from_xml_file = \
self.config.xml_generator_from_xml_file
self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file
开发者ID:gccxml,项目名称:pygccxml,代码行数:8,代码来源:non_copyable_classes_tester.py
示例15: setUp
def setUp(self):
if not gccxml_declarations_t.global_ns:
decls = parser.parse(
self.test_files,
self.config,
self.COMPILATION_MODE)
gccxml_declarations_t.global_ns = \
declarations.get_global_namespace(decls)
if not self.global_ns:
self.global_ns = gccxml_declarations_t.global_ns
开发者ID:iMichka,项目名称:pygccxml,代码行数:10,代码来源:declarations_tester.py
示例16: setUp
def setUp(self):
if not core_t.global_ns:
decls = parser.parse(
self.test_files,
self.config,
self.COMPILATION_MODE)
core_t.global_ns = pygccxml.declarations.get_global_namespace(
decls)
if self.INIT_OPTIMIZER:
core_t.global_ns.init_optimizer()
self.global_ns = core_t.global_ns
开发者ID:programmdesign,项目名称:pygccxml,代码行数:11,代码来源:core_tester.py
示例17: global_namespace
def global_namespace(options):
config = setup_pygccxml(options)
gcccache = options["gccxml-cache"]
if not gcccache:
gcccache = "gcccache"
cache = parser.directory_cache.directory_cache_t(dir=gcccache, md5_sigs=False)
# normalize input files so that cache can match them
# mixed slashes does not play well with the cache
in_files = [os.path.abspath(p) for p in options["infiles"]]
decls = parser.parse(in_files, config, cache=cache)
return declarations.get_global_namespace(decls)
开发者ID:mkawserm,项目名称:jagpdf,代码行数:11,代码来源:introspect.py
示例18: test_comparison_from_reverse
def test_comparison_from_reverse(self):
parsed = parser.parse([self.header], self.config)
copied = copy.deepcopy(parsed)
parsed.sort()
copied.reverse()
copied.sort()
x = parsed[4:6]
x.sort()
y = copied[4:6]
y.sort()
self.failUnless(
parsed == copied,
"__lt__ and/or __qe__ does not working properly")
开发者ID:iMichka,项目名称:pygccxml,代码行数:13,代码来源:declarations_comparison_tester.py
示例19: test_map_gcc5
def test_map_gcc5(self):
"""
The code in test_map_gcc5.hpp was breaking pygccxml.
Test that case (gcc5 + castxml + c++11). See issue #45
"""
if self.config.xml_generator == "gccxml":
return
decls = parser.parse([self.header], self.config)
self.global_ns = declarations.get_global_namespace(decls)
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:13,代码来源:test_map_gcc5.py
示例20: test_template_split_std_vector
def test_template_split_std_vector(self):
"""
Demonstrate error in pattern parser, see #60
"""
if self.config.xml_generator == "gccxml":
return
decls = parser.parse([self.header], self.config)
for decl in declarations.make_flatten(decls):
if "myClass" in decl.name:
_ = decl.partial_name
开发者ID:gccxml,项目名称:pygccxml,代码行数:14,代码来源:test_pattern_parser.py
注:本文中的pygccxml.parser.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论