From 5eeae5e6ba99519d7622aa94bbcb5ec8d70fb385 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 2 Jun 2023 12:08:05 +0200 Subject: [PATCH] Added templates for the new variant types. --- .../builtins_templates/projection.tmpl.pxi | 36 +++++ generation/builtins_templates/rect2i.tmpl.pxi | 46 +++++++ .../builtins_templates/string_name.tmpl.pxi | 45 +++++++ .../builtins_templates/vector2.tmpl.pxi | 7 +- .../builtins_templates/vector2i.tmpl.pxi | 77 +++++++++++ .../builtins_templates/vector3i.tmpl.pxi | 105 +++++++++++++++ .../builtins_templates/vector4.tmpl.pxi | 125 ++++++++++++++++++ .../builtins_templates/vector4i.tmpl.pxi | 96 ++++++++++++++ generation/generate_builtins.py | 21 ++- 9 files changed, 552 insertions(+), 6 deletions(-) create mode 100644 generation/builtins_templates/projection.tmpl.pxi create mode 100644 generation/builtins_templates/rect2i.tmpl.pxi create mode 100644 generation/builtins_templates/string_name.tmpl.pxi create mode 100644 generation/builtins_templates/vector2i.tmpl.pxi create mode 100644 generation/builtins_templates/vector3i.tmpl.pxi create mode 100644 generation/builtins_templates/vector4.tmpl.pxi create mode 100644 generation/builtins_templates/vector4i.tmpl.pxi diff --git a/generation/builtins_templates/projection.tmpl.pxi b/generation/builtins_templates/projection.tmpl.pxi new file mode 100644 index 0000000..1fefdee --- /dev/null +++ b/generation/builtins_templates/projection.tmpl.pxi @@ -0,0 +1,36 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +{% endblock -%} + + +@cython.final +cdef class Projection: +{% block cdef_attributes %} + cdef pandemonium_projection _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, x_axis=None, y_axis=None, z_axis=None, w_axis=None): + if x_axis is None and y_axis is None and z_axis is None and w_axis is None: + {{ force_mark_rendered("pandemonium_projection_new_identity") }} + gdapi10.pandemonium_projection_new_identity(&self._gd_data) + else: + {{ force_mark_rendered("pandemonium_projection_new_vector4s") }} + gdapi10.pandemonium_projection_new_vector4s( + &self._gd_data, + &(x_axis)._gd_data, + &(y_axis)._gd_data, + &(z_axis)._gd_data, + &(origin)._gd_data, + ) + + def __repr__(Projection self): + return f"" + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} + IDENTITY = Projection(Vector4(1, 0, 0, 0), Vector4(0, 1, 0, 0), Vector4(0, 0, 1, 0), Vector4(0, 0, 0, 1)) +{% endblock %} diff --git a/generation/builtins_templates/rect2i.tmpl.pxi b/generation/builtins_templates/rect2i.tmpl.pxi new file mode 100644 index 0000000..fa3fa60 --- /dev/null +++ b/generation/builtins_templates/rect2i.tmpl.pxi @@ -0,0 +1,46 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +{% endblock -%} + + +@cython.final +cdef class Rect2i: +{% block cdef_attributes %} + cdef pandemonium_rect2i _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, pandemonium_real x=0.0, pandemonium_real y=0.0, pandemonium_real width=0.0, pandemonium_real height=0.0): + {{ force_mark_rendered("pandemonium_rect2i_new") }} + gdapi10.pandemonium_rect2i_new(&self._gd_data, x, y, width, height) + + @staticmethod + def from_pos_size(Vector2 position not None, Vector2 size not None): + {{ force_mark_rendered("pandemonium_rect2i_new_with_position_and_size") }} + cdef Rect2i ret = Rect2i.__new__(Rect2i) + gdapi10.pandemonium_rect2i_new_with_position_and_size(&ret._gd_data, &position._gd_data, &size._gd_data) + return ret + + def __repr__(Rect2i self): + return f"" + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + + {{ render_property("size", getter="get_size", setter="set_size") | indent }} + {{ render_property("position", getter="get_position", setter="set_position") | indent }} + + @property + def end(Rect2i self) -> Vector2: + cdef pandemonium_vector2i position = gdapi10.pandemonium_rect2i_get_position(&self._gd_data) + cdef pandemonium_vector2i size = gdapi10.pandemonium_rect2i_get_size(&self._gd_data) + cdef Vector2 ret = Vector2.__new__(Vector2) + ret._gd_data = gdapi10.pandemonium_vector2i_operator_add(&position, &size) + return ret + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} +{% endblock %} diff --git a/generation/builtins_templates/string_name.tmpl.pxi b/generation/builtins_templates/string_name.tmpl.pxi new file mode 100644 index 0000000..cb7ea3d --- /dev/null +++ b/generation/builtins_templates/string_name.tmpl.pxi @@ -0,0 +1,45 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +{% endblock -%} + +@cython.final +cdef class StringName: +{% block cdef_attributes %} + cdef pandemonium_string_name _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, from_): + {{ force_mark_rendered("pandemonium_string_name_new") }} + cdef pandemonium_string gd_from + try: + gdapi10.pandemonium_string_name_new(&self._gd_data, &(from_)._gd_data) + except TypeError: + if not isinstance(from_, str): + raise TypeError("`from_` must be str or GDString") + pyobj_to_pandemonium_string(from_, &gd_from) + gdapi10.pandemonium_string_name_new(&self._gd_data, &gd_from) + gdapi10.pandemonium_string_destroy(&gd_from) + + def __dealloc__(StringName self): + {{ force_mark_rendered("pandemonium_string_name_destroy") }} + # /!\ if `__init__` is skipped, `_gd_data` must be initialized by + # hand otherwise we will get a segfault here + gdapi10.pandemonium_string_name_destroy(&self._gd_data) + + def __repr__(StringName self): + return f"" + + def __str__(StringName self): + return str(self.as_string()) + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + + {{ render_method("destroy") | indent }} + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} +{% endblock %} diff --git a/generation/builtins_templates/vector2.tmpl.pxi b/generation/builtins_templates/vector2.tmpl.pxi index b00ae55..bdadb33 100644 --- a/generation/builtins_templates/vector2.tmpl.pxi +++ b/generation/builtins_templates/vector2.tmpl.pxi @@ -1,6 +1,7 @@ {%- block pxd_header %} {% endblock -%} {%- block pyx_header %} +from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector2_axis import math cdef inline Vector2 Vector2_multiply_vector(Vector2 self, Vector2 b): @@ -110,8 +111,10 @@ cdef class Vector2: {% endblock %} {%- block python_consts %} - AXIS_X = 0 - AXIS_Y = 0 + AXIS = IntEnum("AXIS", { + "X": pandemonium_vector2_axis.PANDEMONIUM_VECTOR2_AXIS_X, + "Y": pandemonium_vector2_axis.PANDEMONIUM_VECTOR2_AXIS_Y, + }) ZERO = Vector2(0, 0) ONE = Vector2(1, 1) diff --git a/generation/builtins_templates/vector2i.tmpl.pxi b/generation/builtins_templates/vector2i.tmpl.pxi new file mode 100644 index 0000000..116336d --- /dev/null +++ b/generation/builtins_templates/vector2i.tmpl.pxi @@ -0,0 +1,77 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector2i_axis +{% endblock -%} + + +@cython.final +cdef class Vector2i: +{% block cdef_attributes %} + cdef pandemonium_vector2i _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, pandemonium_int x=0, pandemonium_int y=0): + {{ force_mark_rendered("pandemonium_vector2i_new") }} + gdapi10.pandemonium_vector2i_new(&self._gd_data, x, y) + + def __repr__(Vector2i self): + return f"" + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + {{ render_operator_lt() | indent }} + + {{ render_method("operator_neg", py_name="__neg__") | indent }} + + def __pos__(Vector2i self): + return self + + {{ render_method("operator_add", py_name="__add__") | indent }} + {{ render_method("operator_subtract", py_name="__sub__") | indent }} + + def __mul__(Vector2i self, val): + cdef Vector2i _val + try: + _val = val + except TypeError: + return Vector2i_multiply_scalar(self, val) + else: + return Vector2i_multiply_vector(self, _val) + + def __truediv__(Vector2i self, val): + cdef Vector2i _val + try: + _val = val + except TypeError: + if val is 0: + raise ZeroDivisionError() + return Vector2i_divide_scalar(self, val) + else: + if _val.x == 0 or _val.y == 0: + raise ZeroDivisionError() + return Vector2i_divide_vector(self, _val) + + {{ render_property("x", "get_x", "set_x") | indent }} + {{ render_property("y", "get_y", "set_y") | indent }} + {{ render_property("width", "get_x", "set_x") | indent }} + {{ render_property("height", "get_y", "set_y") | indent }} + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} + AXIS = IntEnum("AXIS", { + "X": pandemonium_vector2i_axis.PANDEMONIUM_VECTOR2I_AXIS_X, + "Y": pandemonium_vector2i_axis.PANDEMONIUM_VECTOR2I_AXIS_Y, + }) + + ZERO = Vector2i(0, 0) + ONE = Vector2i(1, 1) + INF = Vector2i(math.inf, math.inf) + LEFT = Vector2i(-1, 0) + RIGHT = Vector2i(1, 0) + UP = Vector2i(0, -1) + DOWN = Vector2i(0, 1) +{% endblock %} diff --git a/generation/builtins_templates/vector3i.tmpl.pxi b/generation/builtins_templates/vector3i.tmpl.pxi new file mode 100644 index 0000000..14b8abf --- /dev/null +++ b/generation/builtins_templates/vector3i.tmpl.pxi @@ -0,0 +1,105 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector3i_axis +{% endblock -%} + + +@cython.final +cdef class Vector3i: +{% block cdef_attributes %} + cdef pandemonium_vector3i _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, pandemonium_int x=0, pandemonium_int y=0, pandemonium_int z=0): + {{ force_mark_rendered("pandemonium_vector3i_new") }} + gdapi10.pandemonium_vector3i_new(&self._gd_data, x, y, z) + + def __repr__(self): + return f"" + + @property + def x(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector3i_get_axis") }} + return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X) + + @x.setter + def x(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector3i_set_axis") }} + gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X, val) + + @property + def y(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector3i_get_axis") }} + return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y) + + @y.setter + def y(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector3i_set_axis") }} + gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y, val) + + @property + def z(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector3i_get_axis") }} + return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z) + + @z.setter + def z(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector3i_set_axis") }} + gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z, val) + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + {{ render_operator_lt() | indent }} + + {{ render_method("operator_neg", py_name="__neg__") | indent }} + + def __pos__(Vector3i self): + return self + + {{ render_method("operator_add", py_name="__add__") | indent }} + {{ render_method("operator_subtract", py_name="__sub__") | indent }} + + def __mul__(Vector3i self, val): + cdef Vector3i _val + try: + _val = val + except TypeError: + return Vector3i_multiply_scalar(self, val) + else: + return Vector3i_multiply_vector(self, _val) + + def __truediv__(Vector3i self, val): + cdef Vector3i _val + try: + _val = val + except TypeError: + if val is 0: + raise ZeroDivisionError() + return Vector3i_divide_scalar(self, val) + else: + if _val.x == 0 or _val.y == 0 or _val.z == 0: + raise ZeroDivisionError() + return Vector3i_divide_vector(self, _val) + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} + AXIS = IntEnum("AXIS", { + "X": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X, + "Y": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y, + "Z": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z, + }) + + ZERO = Vector3i(0, 0, 0) # Zero vector. + ONE = Vector3i(1, 1, 1) # One vector. + INF = Vector3i(math.inf, math.inf, math.inf) # Infinite vector. + LEFT = Vector3i(-1, 0, 0) # Left unit vector. + RIGHT = Vector3i(1, 0, 0) # Right unit vector. + UP = Vector3i(0, 1, 0) # Up unit vector. + DOWN = Vector3i(0, -1, 0) # Down unit vector. + FORWARD = Vector3i(0, 0, -1) # Forward unit vector. + BACK = Vector3i(0, 0, 1) # Back unit vector. +{% endblock %} diff --git a/generation/builtins_templates/vector4.tmpl.pxi b/generation/builtins_templates/vector4.tmpl.pxi new file mode 100644 index 0000000..45ae9e6 --- /dev/null +++ b/generation/builtins_templates/vector4.tmpl.pxi @@ -0,0 +1,125 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector4_axis + +import math +from enum import IntEnum + + +cdef inline Vector4_multiply_vector(Vector4 self, Vector4 b): + cdef Vector4 ret = Vector4.__new__(Vector4) + {{ force_mark_rendered("pandemonium_vector4_operator_multiply_vector") }} + ret._gd_data = gdapi10.pandemonium_vector4_operator_multiply_vector(&self._gd_data, &b._gd_data) + return ret + +cdef inline Vector4_multiply_scalar(Vector4 self, pandemonium_real b): + cdef Vector4 ret = Vector4.__new__(Vector4) + {{ force_mark_rendered("pandemonium_vector4_operator_multiply_scalar") }} + ret._gd_data = gdapi10.pandemonium_vector4_operator_multiply_scalar(&self._gd_data, b) + return ret + +cdef inline Vector4_divide_vector(Vector4 self, Vector4 b): + cdef Vector4 ret = Vector4.__new__(Vector4) + {{ force_mark_rendered("pandemonium_vector4_operator_divide_vector") }} + ret._gd_data = gdapi10.pandemonium_vector4_operator_divide_vector(&self._gd_data, &b._gd_data) + return ret + +cdef inline Vector4_divide_scalar(Vector4 self, pandemonium_real b): + cdef Vector4 ret = Vector4.__new__(Vector4) + {{ force_mark_rendered("pandemonium_vector4_operator_divide_scalar") }} + ret._gd_data = gdapi10.pandemonium_vector4_operator_divide_scalar(&self._gd_data, b) + return ret + +{% endblock -%} + + +@cython.final +cdef class Vector4: +{% block cdef_attributes %} + cdef pandemonium_vector4 _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, pandemonium_real x=0.0, pandemonium_real y=0.0, pandemonium_real z=0.0, pandemonium_real w=0.0): + {{ force_mark_rendered("pandemonium_vector4_new") }} + gdapi10.pandemonium_vector4_new(&self._gd_data, x, y, z, w) + + def __repr__(self): + return f"" + + @property + def x(self) -> pandemonium_real: + {{ force_mark_rendered("pandemonium_vector4_get_axis") }} + return gdapi10.pandemonium_vector4_get_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_X) + + @x.setter + def x(self, pandemonium_real val) -> None: + {{ force_mark_rendered("pandemonium_vector4_set_axis") }} + gdapi10.pandemonium_vector4_set_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_X, val) + + @property + def y(self) -> pandemonium_real: + {{ force_mark_rendered("pandemonium_vector4_get_axis") }} + return gdapi10.pandemonium_vector4_get_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Y) + + @y.setter + def y(self, pandemonium_real val) -> None: + {{ force_mark_rendered("pandemonium_vector4_set_axis") }} + gdapi10.pandemonium_vector4_set_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Y, val) + + @property + def z(self) -> pandemonium_real: + {{ force_mark_rendered("pandemonium_vector4_get_axis") }} + return gdapi10.pandemonium_vector4_get_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Z) + + @z.setter + def z(self, pandemonium_real val) -> None: + {{ force_mark_rendered("pandemonium_vector4_set_axis") }} + gdapi10.pandemonium_vector4_set_axis(&self._gd_data, pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Z, val) + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + {{ render_operator_lt() | indent }} + + {{ render_method("operator_neg", py_name="__neg__") | indent }} + + def __pos__(Vector4 self): + return self + + {{ render_method("operator_add", py_name="__add__") | indent }} + {{ render_method("operator_subtract", py_name="__sub__") | indent }} + + def __mul__(Vector4 self, val): + cdef Vector4 _val + try: + _val = val + except TypeError: + return Vector4_multiply_scalar(self, val) + else: + return Vector4_multiply_vector(self, _val) + + def __truediv__(Vector4 self, val): + cdef Vector4 _val + try: + _val = val + except TypeError: + if val is 0: + raise ZeroDivisionError() + return Vector4_divide_scalar(self, val) + else: + if _val.x == 0 or _val.y == 0 or _val.z == 0: + raise ZeroDivisionError() + return Vector4_divide_vector(self, _val) + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} + AXIS = IntEnum("AXIS", { + "X": pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_X, + "Y": pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Y, + "Z": pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_Z, + "W": pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_W, + }) +{% endblock %} diff --git a/generation/builtins_templates/vector4i.tmpl.pxi b/generation/builtins_templates/vector4i.tmpl.pxi new file mode 100644 index 0000000..bff3abc --- /dev/null +++ b/generation/builtins_templates/vector4i.tmpl.pxi @@ -0,0 +1,96 @@ +{%- block pxd_header %} +{% endblock -%} +{%- block pyx_header %} +from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector4i_axis +{% endblock -%} + + +@cython.final +cdef class Vector4i: +{% block cdef_attributes %} + cdef pandemonium_vector4i _gd_data +{% endblock %} + +{% block python_defs %} + def __init__(self, pandemonium_int x=0, pandemonium_int y=0, pandemonium_int z=0, pandemonium_int w=0): + {{ force_mark_rendered("pandemonium_vector4i_new") }} + gdapi10.pandemonium_vector4i_new(&self._gd_data, x, y, z, w) + + def __repr__(self): + return f"" + + @property + def x(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector4i_get_axis") }} + return gdapi10.pandemonium_vector4i_get_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_X) + + @x.setter + def x(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector4i_set_axis") }} + gdapi10.pandemonium_vector4i_set_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_X, val) + + @property + def y(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector4i_get_axis") }} + return gdapi10.pandemonium_vector4i_get_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Y) + + @y.setter + def y(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector4i_set_axis") }} + gdapi10.pandemonium_vector4i_set_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Y, val) + + @property + def z(self) -> pandemonium_int: + {{ force_mark_rendered("pandemonium_vector4i_get_axis") }} + return gdapi10.pandemonium_vector4i_get_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Z) + + @z.setter + def z(self, pandemonium_int val) -> None: + {{ force_mark_rendered("pandemonium_vector4i_set_axis") }} + gdapi10.pandemonium_vector4i_set_axis(&self._gd_data, pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Z, val) + + {{ render_operator_eq() | indent }} + {{ render_operator_ne() | indent }} + {{ render_operator_lt() | indent }} + + {{ render_method("operator_neg", py_name="__neg__") | indent }} + + def __pos__(Vector4i self): + return self + + {{ render_method("operator_add", py_name="__add__") | indent }} + {{ render_method("operator_subtract", py_name="__sub__") | indent }} + + def __mul__(Vector4i self, val): + cdef Vector4i _val + try: + _val = val + except TypeError: + return Vector4i_multiply_scalar(self, val) + else: + return Vector4i_multiply_vector(self, _val) + + def __truediv__(Vector4i self, val): + cdef Vector4i _val + try: + _val = val + except TypeError: + if val is 0: + raise ZeroDivisionError() + return Vector4i_divide_scalar(self, val) + else: + if _val.x == 0 or _val.y == 0 or _val.z == 0: + raise ZeroDivisionError() + return Vector4i_divide_vector(self, _val) + + {{ render_method("as_string") | indent }} +{% endblock %} + +{%- block python_consts %} + AXIS = IntEnum("AXIS", { + "X": pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_X, + "Y": pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Y, + "Z": pandemonium_vector4i_axis.PANDEMONIUM_VECTOR4I_AXIS_Z, + "W": pandemonium_vector4_axis.PANDEMONIUM_VECTOR4_AXIS_W, + }) +{% endblock %} diff --git a/generation/generate_builtins.py b/generation/generate_builtins.py index 458f9a9..c767c21 100644 --- a/generation/generate_builtins.py +++ b/generation/generate_builtins.py @@ -29,6 +29,13 @@ from type_specs import ( TYPE_NODEPATH, TYPE_DICTIONARY, TYPE_ARRAY, + TYPE_STRING_NAME, + TYPE_RECT2I, + TYPE_PROJECTION, + TYPE_VECTOR2I, + TYPE_VECTOR3I, + TYPE_VECTOR4, + TYPE_VECTOR4I, ) @@ -107,9 +114,9 @@ ALL_TYPES = [ is_builtin=True, ), TypeSpec( - gdapi_type="pandemonium_string_name", - c_type="pandemonium_string_name", - cy_type="pandemonium_string_name", + gdapi_type="pandemonium_char_16_string", + c_type="pandemonium_char_16_string", + cy_type="pandemonium_char_16_string", py_type="str", is_builtin=True, ), @@ -142,9 +149,15 @@ TARGET_TO_TYPE_SPEC = { "node_path": TYPE_NODEPATH, "dictionary": TYPE_DICTIONARY, "array": TYPE_ARRAY, + "string_name": TYPE_STRING_NAME, + "rect2i": TYPE_RECT2I, + "projection": TYPE_PROJECTION, + "vector2i": TYPE_VECTOR2I, + "vector3i": TYPE_VECTOR3I, + "vector4": TYPE_VECTOR4, + "vector4i": TYPE_VECTOR4I, } - @dataclass class ArgumentSpec: name: str