本文整理汇总了Python中pybindgen.typehandlers.codesink.FileCodeSink方法的典型用法代码示例。如果您正苦于以下问题:Python codesink.FileCodeSink方法的具体用法?Python codesink.FileCodeSink怎么用?Python codesink.FileCodeSink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybindgen.typehandlers.codesink
的用法示例。
在下文中一共展示了codesink.FileCodeSink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from pybindgen.typehandlers import codesink [as 别名]
# 或者: from pybindgen.typehandlers.codesink import FileCodeSink [as 别名]
def generate(self, out, module_file_base_name=None):
"""Generates the module
:type out: a file object, L{FileCodeSink}, or L{MultiSectionFactory}
:param module_file_base_name: base name of the module file.
This is useful when we want to produce a _foo module that will
be imported into a foo module, to avoid making all types
docstrings contain _foo.Xpto instead of foo.Xpto.
"""
if hasattr(out, 'write'):
out = FileCodeSink(out)
if isinstance(out, CodeSink):
sink_manager = _MonolithicSinkManager(out)
elif isinstance(out, MultiSectionFactory):
sink_manager = _MultiSectionSinkManager(out)
else:
raise TypeError
self.do_generate(sink_manager, module_file_base_name)
sink_manager.close()
示例2: ns3_module_scan
# 需要导入模块: from pybindgen.typehandlers import codesink [as 别名]
# 或者: from pybindgen.typehandlers.codesink import FileCodeSink [as 别名]
def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflags):
module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3')
module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name))
#module_parser.add_post_scan_hook(post_scan_hook)
gccxml_options = dict(
include_paths=[top_builddir],
define_symbols={
#'NS3_ASSERT_ENABLE': None,
#'NS3_LOG_ENABLE': None,
},
cflags=('--gccxml-cxxflags "%s -DPYTHON_SCAN"' % cflags)
)
try:
os.unlink(output_file_name)
except OSError:
pass
try:
os.makedirs(os.path.dirname(output_file_name))
except OSError:
pass
output_file = open(output_file_name, "wt")
output_sink = FileCodeSink(output_file)
# if there exists a scan-header.h file in src/<module>/bindings,
# scan it, otherwise scan ns3/xxxx-module.h.
scan_header = os.path.join(os.path.dirname(output_file_name), "scan-header.h")
if not os.path.exists(scan_header):
scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % module_name)
module_parser.parse_init([scan_header],
None, whitelist_paths=[top_builddir],
#includes=['"ns3/everything.h"'],
pygen_sink=output_sink,
gccxml_options=gccxml_options)
module_parser.scan_types()
callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt")
scan_callback_classes(module_parser, callback_classes_file)
callback_classes_file.close()
module_parser.scan_methods()
module_parser.scan_functions()
module_parser.parse_finalize()
output_file.close()
os.chmod(output_file_name, 0400)
示例3: ns3_module_scan
# 需要导入模块: from pybindgen.typehandlers import codesink [as 别名]
# 或者: from pybindgen.typehandlers.codesink import FileCodeSink [as 别名]
def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflags):
module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3')
module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name))
#module_parser.add_post_scan_hook(post_scan_hook)
castxml_options = dict(
include_paths=[top_builddir],
define_symbols={
#'NS3_ASSERT_ENABLE': None,
#'NS3_LOG_ENABLE': None,
},
cflags=('-std=c++14 %s' % cflags)
)
try:
os.unlink(output_file_name)
except OSError:
pass
try:
os.makedirs(os.path.dirname(output_file_name))
except OSError:
pass
output_file = open(output_file_name, "wt")
output_sink = FileCodeSink(output_file)
# if there exists a scan-header.h file in src/<module>/bindings,
# scan it, otherwise scan ns3/xxxx-module.h.
scan_header = os.path.join(os.path.dirname(output_file_name), "scan-header.h")
if not os.path.exists(scan_header):
scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % module_name)
module_parser.parse_init([scan_header],
None, whitelist_paths=[top_builddir],
pygen_sink=output_sink,
castxml_options=castxml_options)
module_parser.scan_types()
callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt")
scan_callback_classes(module_parser, callback_classes_file)
callback_classes_file.close()
module_parser.scan_methods()
module_parser.scan_functions()
module_parser.parse_finalize()
output_file.close()
os.chmod(output_file_name, 0400)