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


Python base.ForwardWrapperBase方法代码示例

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


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

示例1: convert_python_to_c

# 需要导入模块: from pybindgen.typehandlers import base [as 别名]
# 或者: from pybindgen.typehandlers.base import ForwardWrapperBase [as 别名]
def convert_python_to_c(self, wrapper):
                "parses python args to get C++ value"
                assert isinstance(wrapper, typehandlers.ForwardWrapperBase)

                if self.default_value is None:
                    py_callback = wrapper.declarations.declare_variable('PyObject*', self.name)
                    wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name)
                    wrapper.before_call.write_error_check(
                        '!PyCallable_Check(%s)' % py_callback,
                        'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name)
                    callback_impl = wrapper.declarations.declare_variable(
                        'ns3::Ptr<%s>' % self.PYTHON_CALLBACK_IMPL_NAME,
                        '%s_cb_impl' % self.name)
                    wrapper.before_call.write_code("%s = ns3::Create<%s> (%s);"
                                                   % (callback_impl, self.PYTHON_CALLBACK_IMPL_NAME, py_callback))
                    wrapper.call_params.append(
                        'ns3::Callback<%s> (%s)' % (', '.join(self.TEMPLATE_ARGS), callback_impl))
                else:
                    py_callback = wrapper.declarations.declare_variable('PyObject*', self.name, 'NULL')
                    wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name, optional=True)
                    value = wrapper.declarations.declare_variable(
                        'ns3::Callback<%s>' % ', '.join(self.TEMPLATE_ARGS),
                        self.name+'_value',
                        self.default_value)

                    wrapper.before_call.write_code("if (%s) {" % (py_callback,))
                    wrapper.before_call.indent()

                    wrapper.before_call.write_error_check(
                        '!PyCallable_Check(%s)' % py_callback,
                        'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name)

                    wrapper.before_call.write_code("%s = ns3::Callback<%s> (ns3::Create<%s> (%s));"
                                                   % (value, ', '.join(self.TEMPLATE_ARGS),
                                                      self.PYTHON_CALLBACK_IMPL_NAME, py_callback))

                    wrapper.before_call.unindent()
                    wrapper.before_call.write_code("}") # closes: if (py_callback) {
                                        
                    wrapper.call_params.append(value) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:42,代码来源:ns3modulegen_core_customizations.py

示例2: convert_python_to_c

# 需要导入模块: from pybindgen.typehandlers import base [as 别名]
# 或者: from pybindgen.typehandlers.base import ForwardWrapperBase [as 别名]
def convert_python_to_c(self, wrapper):
        assert isinstance(wrapper, ForwardWrapperBase)
        name = wrapper.declarations.declare_variable("std::ios::openmode", self.name, self.default_value)
        wrapper.parse_params.add_parameter('i', ['&'+name], self.name, optional=bool(self.default_value))
        wrapper.call_params.append(name) 
开发者ID:imec-idlab,项目名称:IEEE-802.11ah-ns-3,代码行数:7,代码来源:ns3modulegen_core_customizations.py

示例3: convert_python_to_c

# 需要导入模块: from pybindgen.typehandlers import base [as 别名]
# 或者: from pybindgen.typehandlers.base import ForwardWrapperBase [as 别名]
def convert_python_to_c(self, wrapper):
        assert isinstance(wrapper, ForwardWrapperBase)

        py_cb = wrapper.declarations.declare_variable("PyObject*", self.name)
        wrapper.parse_params.add_parameter('O', ['&'+py_cb], self.name)

        wrapper.before_call.write_error_check("!PyCallable_Check(%s)" % py_cb,
                                              """PyErr_SetString(PyExc_TypeError, "visitor parameter must be callable");""")
        wrapper.call_params.append("_wrap_Visit")
        wrapper.before_call.write_code("Py_INCREF(%s);" % py_cb)
        wrapper.before_call.add_cleanup_code("Py_DECREF(%s);" % py_cb)
        wrapper.call_params.append(py_cb) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:14,代码来源:modulegen.py

示例4: convert_python_to_c

# 需要导入模块: from pybindgen.typehandlers import base [as 别名]
# 或者: from pybindgen.typehandlers.base import ForwardWrapperBase [as 别名]
def convert_python_to_c(self, wrapper):
        assert isinstance(wrapper, typehandlers.ForwardWrapperBase)
        name = wrapper.declarations.declare_variable(self.ctype, self.name)
        wrapper.parse_params.add_parameter('i', ['&'+name], self.name)
        wrapper.call_params.append(name) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:7,代码来源:test.py

示例5: convert_python_to_c

# 需要导入模块: from pybindgen.typehandlers import base [as 别名]
# 或者: from pybindgen.typehandlers.base import ForwardWrapperBase [as 别名]
def convert_python_to_c(self, wrapper):
        assert isinstance(wrapper, ForwardWrapperBase)
        name = wrapper.declarations.declare_variable("std::ios_base::openmode", self.name, self.default_value)
        wrapper.parse_params.add_parameter('i', ['&'+name], self.name, optional=bool(self.default_value))
        wrapper.call_params.append(name) 
开发者ID:wigig-tools,项目名称:ns3-802.11ad,代码行数:7,代码来源:ns3modulegen_core_customizations.py


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