本文整理汇总了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+'"')))