Skip to content

Commit 577b924

Browse files
committed
Put gdapi pxd stuff in src/godot/hazmat/gdapi_pyx/
1 parent 5ec2af8 commit 577b924

File tree

4 files changed

+34
-33
lines changed

4 files changed

+34
-33
lines changed

src/godot/hazmat/gdapi.pyx.j2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
{% from 'gdapi_pyx/ptrs.pyx.j2' import render_all_ptrs with context %}
12
from .gdnative_interface cimport *
23
from ..builtins cimport *
34
from ..classes cimport GDObject
45

56

6-
{% include 'gdapi.conversion.pyx.j2' %}
7-
8-
9-
{% include 'gdapi.ptrs.pyx.j2' %}
7+
{% include 'gdapi_pyx/conversion.pyx.j2' %}
8+
{{ render_all_ptrs() }}
Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
##############################################################################
2-
# Builtins #
3-
##############################################################################
4-
{% for spec in api["builtins"] if not spec.is_scalar %}
5-
6-
##############################################################################
7-
#{{ "{:^76}".format(spec.name) }}#
8-
##############################################################################
9-
1+
{% macro render_builtin_ptrs(spec) %}
102
{% for c in spec.constructors %}
113
cdef GDNativePtrConstructor __{{ spec.name }}_constructor_{{ c.index }} = pythonscript_gdapi.variant_get_ptr_constructor(
124
{{ spec.variant_type_name }}, {{ c.index }}
@@ -37,33 +29,43 @@ cdef GDNativePtrSetter __{{ spec.name }}_get_{{ m.name }} = pythonscript_gdapi.v
3729
cdef GDNativePtrGetter __{{ spec.name }}_set_{{ m.name }} = pythonscript_gdapi.variant_get_ptr_getter({{ spec.variant_type_name }}, "{{ m.name }}")
3830
{% endif %}
3931
{% endfor %}
40-
{% endfor %}
32+
{% endmacro %}
33+
34+
35+
{% macro render_all_builtins_ptrs() %}
36+
{% for spec in api["builtins"] if not spec.is_scalar %}
37+
38+
#{{ spec.name }}
39+
40+
{{ render_builtin_ptrs(spec) }}
41+
{% endfor %}
42+
{% endmacro %}
4143

4244

43-
##############################################################################
44-
# Variant conversion #
45-
##############################################################################
46-
{% for spec in api["builtins"] %}
45+
{% macro render_variant_conversions_ptrs() %}
46+
{% for spec in api["builtins"] %}
4747
cdef GDNativeTypeFromVariantConstructorFunc __{{ spec.name }}_from_variant = pythonscript_gdapi.get_variant_to_type_constructor({{ spec.variant_type_name }})
4848
cdef GDNativeVariantFromTypeConstructorFunc __{{ spec.name }}_to_variant = pythonscript_gdapi.get_variant_from_type_constructor({{ spec.variant_type_name }})
49-
{% endfor %}
49+
{% endfor %}
5050
cdef GDNativeTypeFromVariantConstructorFunc __GDObject_from_variant = pythonscript_gdapi.get_variant_to_type_constructor(GDNATIVE_VARIANT_TYPE_OBJECT)
5151
cdef GDNativeVariantFromTypeConstructorFunc __GDObject_to_variant = pythonscript_gdapi.get_variant_from_type_constructor(GDNATIVE_VARIANT_TYPE_OBJECT)
52+
{% endmacro %}
5253

5354

54-
##############################################################################
55-
# Utility functions #
56-
##############################################################################
57-
58-
{% for spec in api["utility_functions"] %}
55+
{% macro render_utility_function_ptrs() %}
56+
{% for spec in api["utility_functions"] %}
5957
# {{ spec.name }}
6058
cdef GDNativePtrUtilityFunction __utility_{{ spec.name }} = pythonscript_gdapi.variant_get_ptr_utility_function("{{ spec.original_name }}", {{ spec.hash }})
61-
{% endfor %}
59+
{% endfor %}
60+
{% endmacro %}
6261

63-
##############################################################################
64-
# Classes #
65-
##############################################################################
66-
{# TODO: do lazy function pointer initialization ? #}
67-
{% for spec in api["classes"] %}
6862

69-
{% endfor %}
63+
{% macro render_all_ptrs() %}
64+
{{ render_all_builtins_ptrs() }}
65+
66+
{{ render_variant_conversions_ptrs() }}
67+
68+
{{ render_utility_function_ptrs() }}
69+
70+
{# TODO: do lazy function pointer initialization ? #}
71+
{% endmacro %}

src/godot/hazmat/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pyx_gdapi = custom_target(
4949
generate_tmpl_base_input,
5050
files(
5151
'gdapi.pyx.j2',
52-
'gdapi.ptrs.pyx.j2',
53-
'gdapi.conversion.pyx.j2',
52+
'gdapi_pyx/ptrs.pyx.j2',
53+
'gdapi_pyx/conversion.pyx.j2',
5454
),
5555
],
5656
command: generate_tmpl_cmd,

0 commit comments

Comments
 (0)