diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-25 13:23:11 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-25 13:23:11 +0300 |
commit | c64e9c6ae239adf0be09599cd9ea56522d43a42b (patch) | |
tree | 63e6dda91e89dd3bdc127e603b097f9d1c312022 /source/blender/makesrna/intern/rna_object.c | |
parent | 4949dd54eb4576442050690f44b2c6ec7366e011 (diff) |
Cleanup: Add more const'ness to RNA API.
This commit makes PointerRNA passed to RNA path API const.
Main change was in the `path` callback for RNA structs, and indirectly
the `getlength` callback of properties.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 98fc6633f78..b192a385546 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1320,12 +1320,17 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index) return PROP_EDITABLE; } -static int rna_MaterialSlot_index(PointerRNA *ptr) +static int rna_MaterialSlot_index(const PointerRNA *ptr) { /* There is an offset, so that `ptr->data` is not null and unique across IDs. */ return (uintptr_t)ptr->data - (uintptr_t)ptr->owner_id; } +static int rna_MaterialSlot_index_get(PointerRNA *ptr) +{ + return rna_MaterialSlot_index(ptr); +} + static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Object *ob = (Object *)ptr->owner_id; @@ -1451,7 +1456,7 @@ static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr) DEG_relations_tag_update(bmain); } -static char *rna_MaterialSlot_path(PointerRNA *ptr) +static char *rna_MaterialSlot_path(const PointerRNA *ptr) { int index = rna_MaterialSlot_index(ptr); return BLI_sprintfN("material_slots[%d]", index); @@ -1504,7 +1509,7 @@ static PointerRNA rna_Object_display_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_ObjectDisplay, ptr->data); } -static char *rna_ObjectDisplay_path(PointerRNA *UNUSED(ptr)) +static char *rna_ObjectDisplay_path(const PointerRNA *UNUSED(ptr)) { return BLI_strdup("display"); } @@ -2484,7 +2489,7 @@ static void rna_def_material_slot(BlenderRNA *brna) prop = RNA_def_property(srna, "slot_index", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_MaterialSlot_index", NULL, NULL); + RNA_def_property_int_funcs(prop, "rna_MaterialSlot_index_get", NULL, NULL); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs( |