Commit b8c3446b authored by Stefan Behnel's avatar Stefan Behnel

Refactor coercion predicate function to make it clearer what happens for the...

Refactor coercion predicate function to make it clearer what happens for the template based conversions and for the non-template string conversions.
parent a8476ba0
...@@ -3424,13 +3424,17 @@ class CppClassType(CType): ...@@ -3424,13 +3424,17 @@ class CppClassType(CType):
return '' return ''
def can_coerce_from_pyobject(self, env): def can_coerce_from_pyobject(self, env):
if self.cname in builtin_cpp_conversions or self.cname in cpp_string_conversions: if self.cname in builtin_cpp_conversions:
template_count = builtin_cpp_conversions[self.cname]
for ix, T in enumerate(self.templates or []): for ix, T in enumerate(self.templates or []):
if ix >= builtin_cpp_conversions[self.cname]: if ix >= template_count:
break break
if T.is_pyobject or not T.can_coerce_from_pyobject(env): if T.is_pyobject or not T.can_coerce_from_pyobject(env):
return False return False
return True return True
elif self.cname in cpp_string_conversions:
return True
return False
def create_from_py_utility_code(self, env): def create_from_py_utility_code(self, env):
if self.from_py_function is not None: if self.from_py_function is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment