Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def profile_project():
include_std_header = os.path.join(
autoconfig.data_directory,
'include_std.hpp')
reader = parser.project_reader_t(
parser.xml_generator_configuration_t(
xml_generator_path=autoconfig.generator_path))
reader.read_files([include_std_header])
def test_on_windows_dot_h():
he = r"2003\Vc7\PlatformSDK\Include\windows.h"
windows_header = r"D:\Program Files\Microsoft Visual Studio .NET " + he
clock_prev = timeit.default_timer()
dcache = parser.file_cache_t(dcache_file_name)
reader = parser.source_reader_t(
parser.xml_generator_configuration_t(
xml_generator_path=autoconfig.generator_path),
dcache)
reader.read_file(windows_header)
dcache.flush()
clock_now = timeit.default_timer()
print('without cache: %f seconds' % (clock_now - clock_prev))
clock_prev = timeit.default_timer()
dcache = parser.file_cache_t(dcache_file_name)
reader = parser.source_reader_t(
parser.xml_generator_configuration_t(
xml_generator_path=autoconfig.generator_path),
dcache)
reader.read_file(windows_header)
clock_now = timeit.default_timer()
print('with cache : %f seconds' % (clock_now - clock_prev))
if options is None:
options = {}
else:
options = dict(options)
generator_path, generator_name = find_xml_generator()
options['xml_generator_path'] = generator_path
options['xml_generator'] = generator_name
if include_paths is not None:
assert isinstance(include_paths, list)
warnings.warn("Parameter include_paths is deprecated, use castxml_options instead", DeprecationWarning,
stacklevel=2)
options['include_paths'] = include_paths
logger.debug("castxml options: %r", options)
self.castxml_config = parser.xml_generator_configuration_t(**options)
self.declarations = parser.parse(header_files, self.castxml_config)
self.global_ns = declarations.get_global_namespace(self.declarations)
if self.module_namespace_name == '::':
self.module_namespace = self.global_ns
else:
self.module_namespace = self.global_ns.namespace(self.module_namespace_name)
self.module = Module(self.module_name,
cpp_namespace=self.module_namespace.decl_string)
for inc in includes:
self.module.add_include(inc)
for pygen_sink in self._get_all_pygen_sinks():
pygen_sink.writeln("from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers")
caster = 'castxml'
except Exception as e:
logger.info("caster_path=%s" % casterpath)
logger.info(str(e))
raise Exception("Problems determine castxml binary")
settings.includesPaths.insert(0, os.path.abspath(extraIncludes))
logger.info("caster_path=%s" % casterpath)
logger.info("working_directory=%s" % settings.gimli_path)
logger.info("include_paths=%s" % settings.includesPaths)
logger.info("define_symbols=%s" % defines)
logger.info("indexing_suite_version=2")
xml_generator_config = parser.xml_generator_configuration_t(
xml_generator=caster,
xml_generator_path=casterpath,
working_directory=settings.gimli_path,
include_paths=settings.includesPaths,
define_symbols=defines,
ignore_gccxml_output=False,
cflags="",
compiler_path=compiler_path)
mb = module_builder.module_builder_t(
[xml_cached_fc],
indexing_suite_version=2,
xml_generator_config=xml_generator_config
)
logger.info("Reading of c++ sources done.")
from pygccxml import declarations
from pygccxml import parser
import os
import sys
import warnings
warnings.simplefilter("error", Warning)
# Find out the file location within the sources tree
this_module_dir_path = os.path.abspath(
os.path.dirname(sys.modules[__name__].__file__))
# Find out the c++ 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)
# The c++ file we want to parse
filename = "example.hpp"
filename = this_module_dir_path + "/" + filename
decls = parser.parse([filename], xml_generator_config)
global_namespace = declarations.get_global_namespace(decls)
ns = global_namespace.namespace("ns")
# We have just one declaration in ns, which is our Test class:
classTest = ns.declarations[0]
print(classTest.name, type(classTest))
# > 'Test',
from pygccxml import declarations
from pygccxml import parser
import os
import sys
import warnings
warnings.simplefilter("error", Warning)
# Find out the file location within the sources tree
this_module_dir_path = os.path.abspath(
os.path.dirname(sys.modules[__name__].__file__))
# Find out the c++ 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)
# The c++ file we want to parse
filename = "example.hpp"
filename = this_module_dir_path + "/" + filename
decls = parser.parse([filename], xml_generator_config)
global_namespace = declarations.get_global_namespace(decls)
ns = global_namespace.namespace("ns")
# Use the free_functions method to find our function
func = ns.free_function(name="myFunction")
# There are two arguments:
print(len(func.arguments))
except Exception as e:
logger.info("caster_path=%s" % casterpath)
logger.info(str(e))
raise Exception("Problems determine castxml binary")
settings.includesPaths.insert(0, os.path.abspath(extraIncludes))
logger.info("caster_path=%s" % casterpath)
logger.info("working_directory=%s" % settings.gimli_path)
logger.info("include_paths=%s" % settings.includesPaths)
logger.info("define_symbols=%s" % defines)
logger.info("compiler_path=%s" % compiler_path)
logger.info("indexing_suite_version=2")
xml_generator_config = parser.xml_generator_configuration_t(
xml_generator=caster,
xml_generator_path=casterpath,
working_directory=settings.gimli_path,
include_paths=settings.includesPaths,
define_symbols=defines,
ignore_gccxml_output=False,
cflags="",
compiler_path=compiler_path)
mb = module_builder.module_builder_t(
[xml_cached_fc],
indexing_suite_version=2,
xml_generator_config=xml_generator_config
)
logger.info("Reading of c++ sources done.")
from pygccxml import declarations
from pygccxml import parser
import os
import sys
import warnings
warnings.simplefilter("error", Warning)
# Find out the file location within the sources tree
this_module_dir_path = os.path.abspath(
os.path.dirname(sys.modules[__name__].__file__))
# Find out the c++ 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)
# The c++ file we want to parse
filename = "example.hpp"
filename = this_module_dir_path + "/" + filename
decls = parser.parse([filename], xml_generator_config)
global_namespace = declarations.get_global_namespace(decls)
ns = global_namespace.namespace("ns")
class_t_decl = []
for d in ns.declarations:
if isinstance(d, declarations.class_declaration_t):
class_declaration_t = d
if isinstance(d, declarations.class_t):