From b9243646feb45f699508bf7dc7bdc5d7c562f7fd Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 2 Jun 2023 13:36:48 +0200 Subject: [PATCH] More work on the new variant types. --- .../builtins_templates/builtins.tmpl.pxd | 46 ++++++++++++------- .../builtins_templates/builtins.tmpl.pyi | 16 ++++++- .../builtins_templates/builtins.tmpl.pyx | 20 +++++++- .../{quat.tmpl.pxi => quaternion.tmpl.pxi} | 0 generation/generate_bindings.py | 42 ++++++++++++++++- generation/generate_builtins.py | 2 +- generation/generate_pool_arrays.py | 32 +++++++++++++ generation/type_specs.py | 2 +- 8 files changed, 138 insertions(+), 22 deletions(-) rename generation/builtins_templates/{quat.tmpl.pxi => quaternion.tmpl.pxi} (100%) diff --git a/generation/builtins_templates/builtins.tmpl.pxd b/generation/builtins_templates/builtins.tmpl.pxd index 5715273..99053be 100644 --- a/generation/builtins_templates/builtins.tmpl.pxd +++ b/generation/builtins_templates/builtins.tmpl.pxd @@ -15,32 +15,46 @@ from pandemonium.pool_arrays cimport ( ) {% set render_target = "rid" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "vector3" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "vector2" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} +{% set render_target = "vector2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector3i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4i" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "aabb" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "basis" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "color" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "gdstring" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "rect2" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} +{% set render_target = "rect2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "projection" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "transform2d" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "plane" %} -{% include 'render.tmpl.pxd' with context %} -{% set render_target = "quat" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} +{% set render_target = "quaternion" %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "transform" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "node_path" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} +{% set render_target = "string_name" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "dictionary" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} {% set render_target = "array" %} -{% include 'render.tmpl.pxd' with context %} +{% include 'render.tmpl.pyi' with context %} diff --git a/generation/builtins_templates/builtins.tmpl.pyi b/generation/builtins_templates/builtins.tmpl.pyi index 49c36d6..120c135 100644 --- a/generation/builtins_templates/builtins.tmpl.pyi +++ b/generation/builtins_templates/builtins.tmpl.pyi @@ -9,6 +9,14 @@ from typing import Union {% include 'render.tmpl.pyi' with context %} {% set render_target = "vector2" %} {% include 'render.tmpl.pyi' with context %} +{% set render_target = "vector2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector3i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4i" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "aabb" %} {% include 'render.tmpl.pyi' with context %} {% set render_target = "basis" %} @@ -19,16 +27,22 @@ from typing import Union {% include 'render.tmpl.pyi' with context %} {% set render_target = "rect2" %} {% include 'render.tmpl.pyi' with context %} +{% set render_target = "rect2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "projection" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "transform2d" %} {% include 'render.tmpl.pyi' with context %} {% set render_target = "plane" %} {% include 'render.tmpl.pyi' with context %} -{% set render_target = "quat" %} +{% set render_target = "quaternion" %} {% include 'render.tmpl.pyi' with context %} {% set render_target = "transform" %} {% include 'render.tmpl.pyi' with context %} {% set render_target = "node_path" %} {% include 'render.tmpl.pyi' with context %} +{% set render_target = "string_name" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "dictionary" %} {% include 'render.tmpl.pyi' with context %} {% set render_target = "array" %} diff --git a/generation/builtins_templates/builtins.tmpl.pyx b/generation/builtins_templates/builtins.tmpl.pyx index 2802b1b..b2eed6e 100644 --- a/generation/builtins_templates/builtins.tmpl.pyx +++ b/generation/builtins_templates/builtins.tmpl.pyx @@ -17,7 +17,11 @@ from pandemonium.pool_arrays cimport ( PoolRealArray, PoolByteArray, PoolVector2Array, + PoolVector2iArray, PoolVector3Array, + PoolVector3iArray, + PoolVector4Array, + PoolVector4iArray, PoolColorArray, PoolStringArray, ) @@ -28,6 +32,14 @@ from pandemonium.pool_arrays cimport ( {% include 'render.tmpl.pyx' with context %} {% set render_target = "vector2" %} {% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector3i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "vector4i" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "aabb" %} {% include 'render.tmpl.pyx' with context %} {% set render_target = "basis" %} @@ -38,16 +50,22 @@ from pandemonium.pool_arrays cimport ( {% include 'render.tmpl.pyx' with context %} {% set render_target = "rect2" %} {% include 'render.tmpl.pyx' with context %} +{% set render_target = "rect2i" %} +{% include 'render.tmpl.pyx' with context %} +{% set render_target = "projection" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "transform2d" %} {% include 'render.tmpl.pyx' with context %} {% set render_target = "plane" %} {% include 'render.tmpl.pyx' with context %} -{% set render_target = "quat" %} +{% set render_target = "quaternion" %} {% include 'render.tmpl.pyx' with context %} {% set render_target = "transform" %} {% include 'render.tmpl.pyx' with context %} {% set render_target = "node_path" %} {% include 'render.tmpl.pyx' with context %} +{% set render_target = "string_name" %} +{% include 'render.tmpl.pyx' with context %} {% set render_target = "dictionary" %} {% include 'render.tmpl.pyx' with context %} {% set render_target = "array" %} diff --git a/generation/builtins_templates/quat.tmpl.pxi b/generation/builtins_templates/quaternion.tmpl.pxi similarity index 100% rename from generation/builtins_templates/quat.tmpl.pxi rename to generation/builtins_templates/quaternion.tmpl.pxi diff --git a/generation/generate_bindings.py b/generation/generate_bindings.py index a53ad4a..a6f818e 100644 --- a/generation/generate_bindings.py +++ b/generation/generate_bindings.py @@ -196,20 +196,31 @@ SUPPORTED_TYPES = { "pandemonium_color", "pandemonium_dictionary", "pandemonium_node_path", + "pandemonium_string_name", "pandemonium_plane", - "pandemonium_quat", + "pandemonium_quaternion", "pandemonium_rect2", + "pandemonium_rect2i", "pandemonium_rid", "pandemonium_transform", "pandemonium_transform2d", + "pandemonium_projection", "pandemonium_vector2", + "pandemonium_vector2i", "pandemonium_vector3", + "pandemonium_vector3i", + "pandemonium_vector4", + "pandemonium_vector4i", "pandemonium_pool_byte_array", "pandemonium_pool_int_array", "pandemonium_pool_real_array", "pandemonium_pool_string_array", "pandemonium_pool_vector2_array", + "pandemonium_pool_vector2i_array", "pandemonium_pool_vector3_array", + "pandemonium_pool_vector3i_array", + "pandemonium_pool_vector4_array", + "pandemonium_pool_vector4i_array", "pandemonium_pool_color_array", } @@ -399,22 +410,41 @@ def cook_data(data): return value elif type == "pandemonium_string": return f'"{value}"' + elif type == "pandemonium_node_path": + return f'"{value}"' + elif type == "pandemonium_string_name": + return f'"{value}"' elif type == "pandemonium_object" and value in ("[Object:null]", "Null"): return "None" elif type == "pandemonium_dictionary" and value == "{}": return "Dictionary()" elif type == "pandemonium_vector2": return f"Vector2{value}" + elif type == "pandemonium_vector2i": + return f"Vector2i{value}" elif type == "pandemonium_rect2": return f"Rect2{value}" + elif type == "pandemonium_rect2i": + return f"Rect2i{value}" elif type == "pandemonium_vector3": return f"Vector3{value}" - elif type == "pandemonium_transform" and value == "1, 0, 0, 0, 1, 0, 0, 0, 1 - 0, 0, 0": + elif type == "pandemonium_vector3i": + return f"Vector3i{value}" + elif type == "pandemonium_vector4": + return f"Vector4{value}" + elif type == "pandemonium_vector4i": + return f"Vector4i{value}" + elif type == "pandemonium_transform" and value == "1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0": + # TODO return ( "Transform(Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(0, 0, 1), Vector3(0, 0, 0))" ) elif type == "pandemonium_transform2d" and value == "((1, 0), (0, 1), (0, 0))": + # TODO return "Transform2D(Vector2(1, 0), Vector2(0, 1), Vector2(0, 0))" + elif type == "pandemonium_projection": + # TODO + return "Projection()" elif value == "[RID]": return "RID()" elif type == "pandemonium_color": @@ -425,8 +455,16 @@ def cook_data(data): return f"Array()" elif type == "pandemonium_pool_vector2_array" and value == "[]": return f"PoolVector2Array()" + elif type == "pandemonium_pool_vector2i_array" and value == "[]": + return f"PoolVector2iArray()" elif type == "pandemonium_pool_vector3_array" and value == "[]": return f"PoolVector3Array()" + elif type == "pandemonium_pool_vector3i_array" and value == "[]": + return f"PoolVector3iArray()" + elif type == "pandemonium_pool_vector4_array" and value == "[]": + return f"PoolVector4Array()" + elif type == "pandemonium_pool_vector4i_array" and value == "[]": + return f"PoolVector4iArray()" elif type == "pandemonium_pool_int_array" and value == "[]": return f"PoolIntArray()" elif type == "pandemonium_pool_real_array" and value == "[]": diff --git a/generation/generate_builtins.py b/generation/generate_builtins.py index c767c21..4462b50 100644 --- a/generation/generate_builtins.py +++ b/generation/generate_builtins.py @@ -144,7 +144,7 @@ TARGET_TO_TYPE_SPEC = { "rect2": TYPE_RECT2, "transform2d": TYPE_TRANSFORM2D, "plane": TYPE_PLANE, - "quat": TYPE_QUATERNION, + "quaternion": TYPE_QUATERNION, "transform": TYPE_TRANSFORM, "node_path": TYPE_NODEPATH, "dictionary": TYPE_DICTIONARY, diff --git a/generation/generate_pool_arrays.py b/generation/generate_pool_arrays.py index 6c052aa..55897d5 100644 --- a/generation/generate_pool_arrays.py +++ b/generation/generate_pool_arrays.py @@ -55,6 +55,14 @@ TYPES = [ is_base_type=False, is_stack_only=True, ), + TypeItem( + gd_pool=f"pandemonium_pool_vector2i_array", + py_pool=f"PoolVector2iArray", + gd_value=f"pandemonium_vector2i", + py_value=f"Vector2i", + is_base_type=False, + is_stack_only=True, + ), TypeItem( gd_pool=f"pandemonium_pool_vector3_array", py_pool=f"PoolVector3Array", @@ -63,6 +71,30 @@ TYPES = [ is_base_type=False, is_stack_only=True, ), + TypeItem( + gd_pool=f"pandemonium_pool_vector3i_array", + py_pool=f"PoolVector3iArray", + gd_value=f"pandemonium_vector3i", + py_value=f"Vector3i", + is_base_type=False, + is_stack_only=True, + ), + TypeItem( + gd_pool=f"pandemonium_pool_vector4_array", + py_pool=f"PoolVector4Array", + gd_value=f"pandemonium_vector4", + py_value=f"Vector4", + is_base_type=False, + is_stack_only=True, + ), + TypeItem( + gd_pool=f"pandemonium_pool_vector4i_array", + py_pool=f"PoolVector4iArray", + gd_value=f"pandemonium_vector4i", + py_value=f"Vector4i", + is_base_type=False, + is_stack_only=True, + ), TypeItem( gd_pool=f"pandemonium_pool_color_array", py_pool=f"PoolColorArray", diff --git a/generation/type_specs.py b/generation/type_specs.py index 50b31e7..558261d 100644 --- a/generation/type_specs.py +++ b/generation/type_specs.py @@ -205,7 +205,7 @@ TYPE_PLANE = TypeSpec( gdapi_type="Plane", c_type="pandemonium_plane", cy_type="Plane", is_builtin=True, is_stack_only=True ) TYPE_QUATERNION = TypeSpec( - gdapi_type="Quaternion", c_type="pandemonium_quat", cy_type="Quaternion", is_builtin=True, is_stack_only=True + gdapi_type="Quaternion", c_type="pandemonium_quaternion", cy_type="Quaternion", is_builtin=True, is_stack_only=True ) TYPE_RECT2 = TypeSpec( gdapi_type="Rect2", c_type="pandemonium_rect2", cy_type="Rect2", is_builtin=True, is_stack_only=True