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


Python Parameter.new方法代码示例

本文整理汇总了Python中pybindgen.Parameter.new方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.new方法的具体用法?Python Parameter.new怎么用?Python Parameter.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybindgen.Parameter的用法示例。


在下文中一共展示了Parameter.new方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_std_ofstream

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def add_std_ofstream(module):
    module.add_include('<fstream>')
    ostream = module.add_class('ostream', foreign_cpp_namespace='::std')
    ostream.set_cannot_be_constructed("abstract base class")
    ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream)
    ofstream.add_enum('openmode', [
            ('app', 'std::ios_base::app'),
            ('ate', 'std::ios_base::ate'),
            ('binary', 'std::ios_base::binary'),
            ('in', 'std::ios_base::in'),
            ('out', 'std::ios_base::out'),
            ('trunc', 'std::ios_base::trunc'),
            ])
    ofstream.add_constructor([Parameter.new("const char *", 'filename'),
                              Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")])
    ofstream.add_method('close', None, [])
    
    add_std_ios_openmode(module) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:20,代码来源:ns3modulegen_core_customizations.py

示例2: add_std_ofstream

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def add_std_ofstream(module):
    module.add_include('<fstream>')
    ostream = module.add_class('ostream', foreign_cpp_namespace='::std')
    ostream.set_cannot_be_constructed("abstract base class")
    ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream)
    ofstream.add_enum('openmode', [
            ('app', 'std::ios_base::app'),
            ('ate', 'std::ios_base::ate'),
            ('binary', 'std::ios_base::binary'),
            ('in', 'std::ios_base::in'),
            ('out', 'std::ios_base::out'),
            ('trunc', 'std::ios_base::trunc'),
            ])
    ofstream.add_constructor([Parameter.new("const char *", 'filename'),
                              Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")])
    ofstream.add_method('close', None, [])

    import pybindgen.typehandlers.base
    for alias in "std::_Ios_Openmode", "std::ios::openmode":
        pybindgen.typehandlers.base.param_type_matcher.add_type_alias(alias, "int")

    for flag in 'in', 'out', 'ate', 'app', 'trunc', 'binary':
        module.after_init.write_code('PyModule_AddIntConstant(m, (char *) "STD_IOS_%s", std::ios::%s);'
                                     % (flag.upper(), flag)) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:26,代码来源:modulegen_customizations.py

示例3: add_std_ofstream

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def add_std_ofstream(module):
    module.add_include('<fstream>')
    ostream = module.add_class('ostream', foreign_cpp_namespace='::std')
    ostream.set_cannot_be_constructed("abstract base class")
    ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream)
    ofstream.add_enum('openmode', [
            ('app', 'std::ios_base::app'),
            ('ate', 'std::ios_base::ate'),
            ('binary', 'std::ios_base::binary'),
            ('in', 'std::ios_base::in'),
            ('out', 'std::ios_base::out'),
            ('trunc', 'std::ios_base::trunc'),
            ])
    ofstream.add_constructor([Parameter.new("const char *", 'filename'),
                              Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")])
    ofstream.add_method('close', None, [])

    add_std_ios_openmode(module) 
开发者ID:imec-idlab,项目名称:IEEE-802.11ah-ns-3,代码行数:20,代码来源:ns3modulegen_core_customizations.py

示例4: my_module_gen

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def my_module_gen(out_file):

    mod = Module('c')
    mod.add_include('"c.h"')

    mod.header.writeln("""void _wrap_Visit(int value, void *data);""")
    mod.body.writeln("""
void _wrap_Visit(int value, void *data)
{
    PyObject *callback = (PyObject*) data;
    PyObject_CallFunction(callback, (char*) "i", value);
}
""")

    mod.add_function("visit", None, [Parameter.new("Visitor", "visitor")]
                     # the 'data' parameter is inserted automatically
                     # by the custom callback type handler
                     )

    mod.generate(FileCodeSink(out_file)) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:22,代码来源:modulegen.py

示例5: my_module_gen

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def my_module_gen(out_file):

    mod = Module('b')
    mod.add_include('"b.h"')

    B = mod.add_class('B')
    B.add_constructor([])
    B.add_copy_constructor()
    B.add_instance_attribute('b_a', ReturnValue.new('uint32_t'))
    B.add_instance_attribute('b_b', ReturnValue.new('uint32_t'))

    mod.add_function('BDoA', None, [Parameter.new('B', 'b')])
    mod.add_function('BDoB', ReturnValue.new('B'), [])

    mod.generate(FileCodeSink(out_file) ) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:17,代码来源:modulegen.py

示例6: my_module_gen

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def my_module_gen(out_file):

    mod = Module('c')
    mod.add_include('"c.h"')

    C = mod.add_class('C')
    C.add_constructor([])
    C.add_constructor([Parameter.new('uint32_t', 'c')])
    C.add_method('DoA', None, [], is_static=True)
    C.add_method('DoB', None, [])
    C.add_method('DoC', None, [Parameter.new('uint32_t', 'c')])
    C.add_method('DoD', ReturnValue.new('uint32_t'), [])
    C.add_method('DoE', None, [], is_virtual=True)

    mod.generate(FileCodeSink(out_file) ) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:17,代码来源:modulegen.py

示例7: my_module_gen

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def my_module_gen(out_file):

    mod = Module('d')
    mod.add_include('"d.h"')

    D = mod.add_class('D', memory_policy=cppclass.FreeFunctionPolicy('DDestroy'))
    D.add_instance_attribute('d', ReturnValue.new('bool'))
    D.add_function_as_constructor("DCreate", ReturnValue.new("D*", caller_owns_return=True), [])
    mod.add_function('DDoA', None, [Parameter.new('D*', 'd', transfer_ownership=False)])
    mod.add_function('DDoB', None, [Parameter.new('D&', 'd', direction=Parameter.DIRECTION_IN)])
    mod.add_function('DDoC', None, [Parameter.new('const D&', 'd',
                                                  direction=Parameter.DIRECTION_IN)])


    mod.generate(FileCodeSink(out_file) ) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:17,代码来源:modulegen.py

示例8: my_module_gen

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def my_module_gen(out_file):

    mod = Module('a')
    mod.add_include('"a.h"')

    mod.add_function('ADoA', None, [])
    mod.add_function('ADoB', None, [Parameter.new('uint32_t', 'b')])
    mod.add_function('ADoC', ReturnValue.new('uint32_t'), [])

    mod.generate(FileCodeSink(out_file) ) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:12,代码来源:modulegen.py

示例9: Object_customizations

# 需要导入模块: from pybindgen import Parameter [as 别名]
# 或者: from pybindgen.Parameter import new [as 别名]
def Object_customizations(module):
    ## ---------------------------------------------------------------------
    ## Here we generate custom constructor code for all classes that
    ## derive from ns3::Object.  The custom constructors are needed in
    ## order to support kwargs only and to translate kwargs into ns3
    ## attributes, etc.
    ## ---------------------------------------------------------------------
    try:
        Object = module['ns3::Object']
    except KeyError:
        return

    ## add a GetTypeId method to all generatd helper classes
    def helper_class_hook(helper_class):
        decl = """
static ns3::TypeId GetTypeId (void)
{
  static ns3::TypeId tid = ns3::TypeId ("%s")
    .SetParent< %s > ()
    ;
  return tid;
}"""  % (helper_class.name, helper_class.class_.full_name)

        helper_class.add_custom_method(decl)
        helper_class.add_post_generation_code(
            "NS_OBJECT_ENSURE_REGISTERED (%s);" % helper_class.name)
    Object.add_helper_class_hook(helper_class_hook)

    def ns3_object_instance_creation_function(cpp_class, code_block, lvalue,
                                              parameters, construct_type_name):
        assert lvalue
        assert not lvalue.startswith('None')
        if cpp_class.cannot_be_constructed:
            raise CodeGenerationError("%s cannot be constructed (%s)"
                                      % cpp_class.full_name)
        if cpp_class.incomplete_type:
            raise CodeGenerationError("%s cannot be constructed (incomplete type)"
                                      % cpp_class.full_name)
        code_block.write_code("%s = new %s(%s);" % (lvalue, construct_type_name, parameters))
        code_block.write_code("%s->Ref ();" % (lvalue))

    def ns3_object_post_instance_creation_function(cpp_class, code_block, lvalue,
                                                   parameters, construct_type_name):
        code_block.write_code("ns3::CompleteConstruct(%s);" % (lvalue, ))

    Object.set_instance_creation_function(ns3_object_instance_creation_function)
    Object.set_post_instance_creation_function(ns3_object_post_instance_creation_function) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:49,代码来源:ns3modulegen_core_customizations.py


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