本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)