File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 22{% - from 'builtins_pyx/conversion.pyx.j2' import render_all_conversions with context -%}
33cimport cython
44from libc.math cimport INFINITY as inf # Needed by some constants
5+ from libc.string cimport memset # Needed to create zeroized builtins used in `__bool__`
56
67# Forward declarations
78{% for builtin in api .builtins %}
Original file line number Diff line number Diff line change @@ -46,9 +46,18 @@ def __eq__(self, object other):
4646{# Note `__bool__` is not needed if `__len__` is defined #}
4747def __len__(self):
4848 return self.size()
49+ {% elif builtin .is_transparent_builtin %}
50+ def __bool__(self):
51+ return (
52+ {% for member in builtin .all_nested_scalar_members %}
53+ {% if not loop .first %} or {% endif %} self.{{ member }} != 0
54+ {% endfor %}
55+ )
4956{% else %}
5057def __bool__(self):
51- return gdptrs.gdptr_variant_booleanize(&self._gd_data)
58+ cdef {{ builtin.c_type }} zero
59+ memset(&zero, 0, cython.sizeof({{ builtin.c_type }}))
60+ return not gdapi.gd_{{ builtin.snake_name }}_op_equal_{{ builtin.snake_name }}(&self._gd_data, &zero)
5261{% endif %}
5362
5463{% if builtin .original_name == "Array" or builtin .is_packed_array %}
You can’t perform that action at this time.
0 commit comments