From 6f773b1a4f8a21d8b3d36769f148d88e9a4eebcb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 9 May 2022 16:18:55 +0200 Subject: Cleanup: typo in variable name. --- source/blender/python/intern/bpy_utils_units.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c index 3e0698caa50..e0e8ef5fe07 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.c @@ -35,7 +35,7 @@ static const char *bpyunits_usystem_items[] = { NULL, }; -static const char *bpyunits_ucategorie_items[] = { +static const char *bpyunits_ucategories_items[] = { "NONE", "LENGTH", "AREA", @@ -56,7 +56,7 @@ static const char *bpyunits_ucategorie_items[] = { * to keep all systems/categories definition stuff in `BKE_unit.h`. */ static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)]; -static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)]; +static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategories_items)]; static PyStructSequence_Desc bpyunits_systems_desc = { "bpy.utils.units.systems", /* name */ @@ -114,7 +114,7 @@ static bool bpyunits_validate(const char *usys_str, const char *ucat_str, int *r return false; } - *r_ucat = BLI_str_index_in_array(ucat_str, bpyunits_ucategorie_items); + *r_ucat = BLI_str_index_in_array(ucat_str, bpyunits_ucategories_items); if (*r_ucat < 0) { PyErr_Format(PyExc_ValueError, "Unknown unit category specified: %.200s.", ucat_str); return false; @@ -356,7 +356,7 @@ PyObject *BPY_utils_units(void) /* bpy.utils.units.categories */ item = py_structseq_from_strings( - &BPyUnitsCategoriesType, &bpyunits_categories_desc, bpyunits_ucategorie_items); + &BPyUnitsCategoriesType, &bpyunits_categories_desc, bpyunits_ucategories_items); PyModule_AddObject(submodule, "categories", item); /* steals ref */ return submodule; -- cgit v1.2.3 From 43e31d26a955034882035d2e0ec320dfab8f1375 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 9 May 2022 16:32:09 +0200 Subject: Fix T97927: bpy.utils.units.to_string uses wrong units for velocity, acceleration, lens length, and power `TEMPERATURE` type was also missing, not only the new-ish `TIME_ABSOLUTE` one... Added a static assert on the size of the `bpyunits_ucategories_items` array, and a comment on anonymous enum of `B_UNIT_`, in the hope this won't happen again in the future. --- source/blender/blenkernel/BKE_unit.h | 2 +- source/blender/python/intern/bpy_utils_units.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index d6de95a19b7..823d32f83ba 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -91,7 +91,7 @@ const char *BKE_unit_identifier_get(const void *usys_pt, int index); double BKE_unit_scalar_get(const void *usys_pt, int index); bool BKE_unit_is_suppressed(const void *usys_pt, int index); -/** Aligned with #PropertyUnit. */ +/** Aligned with #PropertyUnit and `bpyunits_ucategories_items` in `bpy_utils_units.c`. */ enum { B_UNIT_NONE = 0, B_UNIT_LENGTH = 1, diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c index e0e8ef5fe07..1e5856a3285 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.c @@ -43,13 +43,19 @@ static const char *bpyunits_ucategories_items[] = { "MASS", "ROTATION", "TIME", + "TIME_ABSOLUTE", "VELOCITY", "ACCELERATION", "CAMERA", "POWER", + "TEMPERATURE", NULL, }; +BLI_STATIC_ASSERT( + ARRAY_SIZE(bpyunits_ucategories_items) == B_UNIT_TYPE_TOT + 1, + "`bpyunits_ucategories_items` should match `B_UNIT_` enum items in `BKE_units.h`") + /** * These fields are just empty placeholders, actual values get set in initializations functions. * This allows us to avoid many handwriting, and above all, -- cgit v1.2.3