本文整理匯總了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)