@@ -12,44 +12,61 @@ cpdef inline {{ render_method_signature(spec, m) }}:
1212 raise NotImplementedError # TODO
1313{% else %}
1414{# Return type #}
15- {% if m .return_type .is_nil %}
16- {% elif m .return_type .is_scalar %}
15+ {% if m .return_type .is_nil %}
16+ {% elif m .return_type .is_scalar %}
1717 cdef {{ m.return_type.cy_type }} ret = 0
18- {% elif m .return_type .is_builtin %}
18+ {% elif m .return_type .is_builtin %}
1919 # Call to __new__ bypasses __init__ constructor
2020 cdef {{ m.return_type.cy_type }} ret = {{ m.return_type.cy_type }}.__new__({{ m.return_type.cy_type }})
21- {% endif %}
21+ {% elif m .return_type .is_object or m .return_type .is_variant %}
22+ cdef {{ m.return_type.c_type }} ret
23+ {% else %}
24+ <crash !!!! > # {{ m.return_type }} Unsupported type, crash the compilation !
25+ {% endif %}
2226{# Arguments #}
23- {% if (m .arguments | length ) != 0 %}
27+ {% if (m .arguments | length ) != 0 %}
2428 cdef GDNativeTypePtr[{{ m.arguments | length }}] args = [
25- {% for arg in m .arguments %}
26- {% if arg .type .is_scalar %}
29+ {% for arg in m .arguments %}
30+ {% if arg .type .is_scalar %}
2731 & {{ arg.name }},
28- {% else %}
32+ {% elif arg . type . is_builtin %}
2933 & {{ arg.name }}._gd_data,
30- {% endif %}
31- {% endfor %}
34+ {% elif arg .type .is_object %}
35+ & {{ arg.name }}._gd_ptr,
36+ {% else %}
37+ <crash !!!! > # {{ arg.type }} Unsupported type, crash the compilation !
38+ {% endif %}
39+ {% endfor %}
3240 ]
33- {% endif %}
41+ {% endif %}
3442{# Actual call ! #}
3543 __{{ spec.name }}_meth_{{ m.name }}(
3644{# GDNativeTypePtr p_base #}
3745 &self._gd_data,
3846{# const GDNativeTypePtr *p_args #}
3947 {{ "NULL" if (m.arguments | length) == 0 else "args" }},
4048{# GDNativeTypePtr r_return #}
41- {% if m .return_type .is_nil %}
49+ {% if m .return_type .is_nil %}
4250 NULL,
43- {% elif m .return_type .is_scalar %}
51+ {% elif m .return_type .is_scalar %}
4452 &ret,
45- {% elif m .return_type .is_builtin %}
53+ {% elif m .return_type .is_builtin %}
4654 &ret._gd_data,
47- {% endif %}
55+ {% endif %}
4856{# int p_argument_count #}
4957 {{ m.arguments | length }},
5058 )
51- {% if not m .return_type .is_nil %}
59+ {% if not m .return_type .is_nil %}
60+ {% if m .return_type .is_object %}
61+ return GDObject.cast_from_variant(ret)
62+ {% elif m .return_type .is_variant %}
63+ try:
64+ return gdvariant_to_pyobject(&ret)
65+ finally:
66+ gd_variant_del(&ret)
67+ {% else %}
5268 return ret
53- {% endif %}
69+ {% endif %}
70+ {% endif %}
5471{% endif %}
5572{% endmacro %}
0 commit comments