當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。