当前位置: 首页>>代码示例>>Python>>正文


Python codesink.FileCodeSink方法代码示例

本文整理汇总了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() 
开发者ID:KTH,项目名称:royal-chaos,代码行数:22,代码来源:module.py

示例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) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:51,代码来源:ns3modulescan-modular.py

示例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) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:50,代码来源:ns3modulescan-modular.py


注:本文中的pybindgen.typehandlers.codesink.FileCodeSink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。