當前位置: 首頁>>代碼示例>>Python>>正文


Python base.TypeConfigurationError方法代碼示例

本文整理匯總了Python中pybindgen.typehandlers.base.TypeConfigurationError方法的典型用法代碼示例。如果您正苦於以下問題:Python base.TypeConfigurationError方法的具體用法?Python base.TypeConfigurationError怎麽用?Python base.TypeConfigurationError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybindgen.typehandlers.base的用法示例。


在下文中一共展示了base.TypeConfigurationError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_py_method_def

# 需要導入模塊: from pybindgen.typehandlers import base [as 別名]
# 或者: from pybindgen.typehandlers.base import TypeConfigurationError [as 別名]
def get_py_method_def(self, name):
        """
        Returns an array element to use in a PyMethodDef table.
        Should only be called after code generation.

        name -- python wrapper/method name
        """
        if len(self.all_wrappers) == 1 \
                and not getattr(self.all_wrappers[0], 'NEEDS_OVERLOADING_INTERFACE', False):
            return self.all_wrappers[0].get_py_method_def(name)
        else:
            self._normalize_py_method_flags()
            flags = self.all_wrappers[0].get_py_method_def_flags()
            ## detect inconsistencies in flags; they must all be the same
            if __debug__:
                for func in self.all_wrappers:
                    try:
                        assert set(func.get_py_method_def_flags()) == set(flags),\
                            ("Expected PyMethodDef flags %r, got %r"
                             % (flags, func.get_py_method_def_flags()))
                    except (TypeConfigurationError,
                            CodeGenerationError,
                            NotSupportedError):
                        pass
            # check available docstrings for the overloads
            docstrings_set = set()
            for wrap in self.all_wrappers:
                if wrap.docstring is not None:
                    docstrings_set.add(wrap.docstring)
            docstring = None
            if len(docstrings_set) is 1:
                docstring = docstrings_set.pop()
            elif len(docstrings_set) > 1:
                raise CodeGenerationError("Overloaded '%s' has conflicting docstrings" % self.wrapper_name)

            assert isinstance(self.wrapper_return, string_types)
            assert isinstance(self.wrapper_actual_name, string_types)
            assert isinstance(self.wrapper_args, list)

            return "{(char *) \"%s\", (PyCFunction) %s, %s, %s }," % \
                (name, self.wrapper_actual_name, '|'.join(flags),
                 (docstring is None and "NULL" or ('"'+docstring+'"'))) 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:44,代碼來源:overloading.py


注:本文中的pybindgen.typehandlers.base.TypeConfigurationError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。