@@ -56,36 +56,14 @@ def {{ name_prefix }}{{ m.name }}(self, {{ m.type.cy_type }} val):
5656
5757
5858{% macro render_member (spec , m ) %}
59-
6059{% if not m .is_in_struct %}
6160{# Property unrelated to the builtin internal structure, must use Godot API method to access it #}
62-
63- {% if m .type .is_scalar %}
64-
65- {# Scalar type accessed by property (unused in extension_api.json afaik) #}
66- @property
67- def {{ m.name }}(self) -> {{ m.type.py_type }}:
68- cdef {{ m.type.c_type }} r_value
69- __{{ spec.name }}_get_{{ m.name }}(&self._gd_data, &r_value)
70- return r_value
71- @{{ m.name }}.setter
72- def {{ m.name }}(self, {{ m.type.cy_type }} val):
73- __{{ spec.name }}_set_{{ m.name }}(&self._gd_data, &val)
74-
75- {% else %}
76-
77- {# Builtin type in the C structure (i.e. `Rect2i.end`) #}
7861@property
79- def {{ m.name }}(self) -> {{ m.type.py_type }}:
80- # Call to __new__ bypasses __init__ constructor
81- cdef {{ m.type.cy_type }} ret = {{ m.type.cy_type }}.__new__({{ m.type.cy_type }})
82- __{{ spec.name }}_get_{{ m.name }}(&self._gd_data, &ret._gd_data)
83- return ret
62+ def {{ m.name }}(self):
63+ return {{ spec.name }}.get_{{ m.name }}(self)
8464@{{ m.name }}.setter
85- def {{ m.name }}(self, {{ m.type.cy_type }} val):
86- __{{ spec.name }}_set_{{ m.name }}(&self._gd_data, &val._gd_data)
87- {% endif %}
88-
65+ def {{ m.name }}(self, {{ m.type.cy_type }} val{{ "" if m.type.is_scalar else " not None"}}):
66+ {{ spec.name }}.set_{{ m.name }}(self, val)
8967{% else %}
9068{# Property that is contains in the builtin C structure #}
9169
@@ -104,7 +82,7 @@ def {{ m.name }}(self, {{ m.type.cy_type }} val):
10482
10583{# Also expose the member, but as a functions so it's clearer this works on copies #}
10684{% for subm in m .type .builtin_spec .c_struct_members %}
107- def get_{{ m.name }}(self) -> {{ m.type.py_type }} :
85+ def get_{{ m.name }}(self):
10886{# Transparent builtins are guaranteed to have `is_stack_only == True` #}
10987 # Call to __new__ bypasses __init__ constructor
11088 cdef {{ m.type.cy_type }} ret = {{ m.type.cy_type }}.__new__({{ m.type.cy_type }})
0 commit comments