From 28750bcf7e8b73d9da015898a3c0f21ef5d761f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2022 20:52:28 +1000 Subject: Cleanup: replace NULL with nullptr for C++ files --- source/blender/makesrna/intern/rna_path.cc | 151 +++++++++++++++-------------- 1 file changed, 76 insertions(+), 75 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc index 99cb456027f..72416401344 100644 --- a/source/blender/makesrna/intern/rna_path.cc +++ b/source/blender/makesrna/intern/rna_path.cc @@ -48,7 +48,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen) /* Empty, return. */ if (UNLIKELY(len == 0)) { - return NULL; + return nullptr; } /* Try to use fixed buffer if possible. */ @@ -83,11 +83,11 @@ static char *rna_path_token_in_brackets(const char **path, int len = 0; bool quoted = false; - BLI_assert(r_quoted != NULL); + BLI_assert(r_quoted != nullptr); /* Get data between `[]`, check escaping quotes and back-slashes with #BLI_str_unescape. */ if (UNLIKELY(**path != '[')) { - return NULL; + return nullptr; } (*path)++; @@ -99,9 +99,9 @@ static char *rna_path_token_in_brackets(const char **path, (*path)++; p = *path; const char *p_end = BLI_str_escape_find_quote(p); - if (p_end == NULL) { + if (p_end == nullptr) { /* No Matching quote. */ - return NULL; + return nullptr; } /* Exclude the last quote from the length. */ len += (p_end - p); @@ -120,12 +120,12 @@ static char *rna_path_token_in_brackets(const char **path, } if (UNLIKELY(*p != ']')) { - return NULL; + return nullptr; } /* Empty, return. */ if (UNLIKELY(len == 0)) { - return NULL; + return nullptr; } /* Try to use fixed buffer if possible. */ @@ -194,7 +194,7 @@ static bool rna_path_parse_collection_key(const char **path, found = true; } else { - r_nextptr->data = NULL; + r_nextptr->data = nullptr; } } else { @@ -207,7 +207,7 @@ static bool rna_path_parse_collection_key(const char **path, found = true; } else { - r_nextptr->data = NULL; + r_nextptr->data = nullptr; } } @@ -221,7 +221,7 @@ static bool rna_path_parse_collection_key(const char **path, } else { /* ensure we quit on invalid values */ - r_nextptr->data = NULL; + r_nextptr->data = nullptr; } } @@ -255,7 +255,7 @@ static bool rna_path_parse_array_index(const char **path, bool quoted; token = rna_path_token_in_brackets(path, fixedbuf, sizeof(fixedbuf), "ed); - if (token == NULL) { + if (token == nullptr) { /* invalid syntax blah[] */ return false; } @@ -279,7 +279,7 @@ static bool rna_path_parse_array_index(const char **path, else if (dim == 1) { /* location.x || scale.X, single dimension arrays only */ token = rna_path_token(path, fixedbuf, sizeof(fixedbuf)); - if (token == NULL) { + if (token == nullptr) { /* invalid syntax blah. */ return false; } @@ -354,23 +354,23 @@ static bool rna_path_parse(const PointerRNA *ptr, ListBase *r_elements, const bool eval_pointer) { - BLI_assert(r_item_ptr == NULL || !eval_pointer); + BLI_assert(r_item_ptr == nullptr || !eval_pointer); PropertyRNA *prop; PointerRNA curptr, nextptr; - PropertyElemRNA *prop_elem = NULL; + PropertyElemRNA *prop_elem = nullptr; int index = -1; char fixedbuf[256]; int type; - const bool do_item_ptr = r_item_ptr != NULL && !eval_pointer; + const bool do_item_ptr = r_item_ptr != nullptr && !eval_pointer; if (do_item_ptr) { RNA_POINTER_INVALIDATE(&nextptr); } - prop = NULL; + prop = nullptr; curptr = *ptr; - if (path == NULL || *path == '\0') { + if (path == nullptr || *path == '\0') { return false; } @@ -395,7 +395,7 @@ static bool rna_path_parse(const PointerRNA *ptr, return false; } - prop = NULL; + prop = nullptr; if (use_id_prop) { /* look up property name in current struct */ IDProperty *group = RNA_struct_idprops(&curptr, 0); if (group && quoted) { @@ -438,7 +438,7 @@ static bool rna_path_parse(const PointerRNA *ptr, if (eval_pointer || *path != '\0') { curptr = nextptr; - prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */ + prop = nullptr; /* now we have a PointerRNA, the prop is our parent so forget it */ index = -1; } break; @@ -455,7 +455,7 @@ static bool rna_path_parse(const PointerRNA *ptr, if (eval_pointer || *path != '\0') { curptr = nextptr; - prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */ + prop = nullptr; /* now we have a PointerRNA, the prop is our parent so forget it */ index = -1; } } @@ -505,27 +505,27 @@ bool RNA_path_resolve(const PointerRNA *ptr, PointerRNA *r_ptr, PropertyRNA **r_prop) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, true)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, nullptr, nullptr, nullptr, true)) { return false; } - return r_ptr->data != NULL; + return r_ptr->data != nullptr; } bool RNA_path_resolve_full( const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, nullptr, nullptr, true)) { return false; } - return r_ptr->data != NULL; + return r_ptr->data != nullptr; } bool RNA_path_resolve_full_maybe_null( const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { - return rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true); + return rna_path_parse(ptr, path, r_ptr, r_prop, r_index, nullptr, nullptr, true); } bool RNA_path_resolve_property(const PointerRNA *ptr, @@ -533,21 +533,21 @@ bool RNA_path_resolve_property(const PointerRNA *ptr, PointerRNA *r_ptr, PropertyRNA **r_prop) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, false)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, nullptr, nullptr, nullptr, false)) { return false; } - return r_ptr->data != NULL && *r_prop != NULL; + return r_ptr->data != nullptr && *r_prop != nullptr; } bool RNA_path_resolve_property_full( const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, false)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, nullptr, nullptr, false)) { return false; } - return r_ptr->data != NULL && *r_prop != NULL; + return r_ptr->data != nullptr && *r_prop != nullptr; } bool RNA_path_resolve_property_and_item_pointer(const PointerRNA *ptr, @@ -556,11 +556,11 @@ bool RNA_path_resolve_property_and_item_pointer(const PointerRNA *ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, r_item_ptr, NULL, false)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, nullptr, r_item_ptr, nullptr, false)) { return false; } - return r_ptr->data != NULL && *r_prop != NULL; + return r_ptr->data != nullptr && *r_prop != nullptr; } bool RNA_path_resolve_property_and_item_pointer_full(const PointerRNA *ptr, @@ -570,15 +570,15 @@ bool RNA_path_resolve_property_and_item_pointer_full(const PointerRNA *ptr, int *r_index, PointerRNA *r_item_ptr) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, r_item_ptr, NULL, false)) { + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, r_item_ptr, nullptr, false)) { return false; } - return r_ptr->data != NULL && *r_prop != NULL; + return r_ptr->data != nullptr && *r_prop != nullptr; } bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, ListBase *r_elements) { - return rna_path_parse(ptr, path, NULL, NULL, NULL, NULL, r_elements, false); + return rna_path_parse(ptr, path, nullptr, nullptr, nullptr, nullptr, r_elements, false); } char *RNA_path_append(const char *path, @@ -640,10 +640,10 @@ static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path) int i; if (!path) { - return NULL; + return nullptr; } - previous = NULL; + previous = nullptr; current = path; /* parse token by token until the end, then we back up to the previous @@ -654,7 +654,7 @@ static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path) token = rna_path_token(¤t, fixedbuf, sizeof(fixedbuf)); if (!token) { - return NULL; + return nullptr; } if (token != fixedbuf) { MEM_freeN(token); @@ -675,7 +675,7 @@ static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path) } if (!previous) { - return NULL; + return nullptr; } /* copy and strip off last token */ @@ -692,27 +692,27 @@ static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path) const char *RNA_path_array_index_token_find(const char *rna_path, const PropertyRNA *array_prop) { - if (array_prop != NULL) { + if (array_prop != nullptr) { if (!ELEM(array_prop->type, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { BLI_assert(array_prop->arraydimension == 0); - return NULL; + return nullptr; } if (array_prop->arraydimension == 0) { - return NULL; + return nullptr; } } /* Valid 'array part' of a rna path can only have '[', ']' and digit characters. * It may have more than one of those (e.g. `[12][1]`) in case of multi-dimensional arrays. */ if (UNLIKELY(rna_path[0] == '\0')) { - return NULL; + return nullptr; } size_t rna_path_len = (size_t)strlen(rna_path) - 1; if (rna_path[rna_path_len] != ']') { - return NULL; + return nullptr; } - const char *last_valid_index_token_start = NULL; + const char *last_valid_index_token_start = nullptr; while (rna_path_len--) { switch (rna_path[rna_path_len]) { case '[': @@ -761,7 +761,7 @@ static char *rna_idp_path_create(IDP_Chain *child_link) /* reverse the list */ IDP_Chain *link_prev; - link_prev = NULL; + link_prev = nullptr; while (link) { IDP_Chain *link_next = link->up; link->up = link_prev; @@ -787,7 +787,7 @@ static char *rna_idp_path_create(IDP_Chain *child_link) if (*path == '\0') { MEM_freeN(path); - path = NULL; + path = nullptr; } return path; @@ -798,7 +798,7 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *needle, IDP_Chain *parent_link) { - char *path = NULL; + char *path = nullptr; IDP_Chain link; IDProperty *iter; @@ -808,7 +808,7 @@ static char *rna_idp_path(PointerRNA *ptr, link.up = parent_link; /* Always set both name and index, else a stale value might get used. */ - link.name = NULL; + link.name = nullptr; link.index = -1; for (i = 0, iter = static_cast(haystack->data.group.first); iter; @@ -835,7 +835,7 @@ static char *rna_idp_path(PointerRNA *ptr, * * See T84091. */ PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name); - if (prop == NULL || (prop->flag & PROP_IDPROPERTY) == 0) { + if (prop == nullptr || (prop->flag & PROP_IDPROPERTY) == 0) { continue; } @@ -895,16 +895,16 @@ char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle) IDProperty *haystack = RNA_struct_idprops(ptr, false); if (haystack) { /* can fail when called on bones */ - return rna_idp_path(ptr, haystack, needle, NULL); + return rna_idp_path(ptr, haystack, needle, nullptr); } - return NULL; + return nullptr; } static char *rna_path_from_ID_to_idpgroup(const PointerRNA *ptr) { PointerRNA id_ptr; - BLI_assert(ptr->owner_id != NULL); + BLI_assert(ptr->owner_id != nullptr); /* TODO: Support Bones/PoseBones. no pointers stored to the bones from here, only the ID. * See example in T25746. @@ -922,7 +922,7 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path) *r_path = ""; } - if ((id == NULL) || (id->flag & LIB_EMBEDDED_DATA) == 0) { + if ((id == nullptr) || (id->flag & LIB_EMBEDDED_DATA) == 0) { return id; } @@ -940,7 +940,7 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path) } } - if (id_type->owner_get == NULL) { + if (id_type->owner_get == nullptr) { BLI_assert_msg(0, "Missing handling of embedded id type."); return id; } @@ -949,19 +949,19 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path) static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real_id) { - if (r_real_id != NULL) { - *r_real_id = NULL; + if (r_real_id != nullptr) { + *r_real_id = nullptr; } const char *prefix; ID *real_id = RNA_find_real_ID_and_path(bmain, id, &prefix); - if (r_real_id != NULL) { + if (r_real_id != nullptr) { *r_real_id = real_id; } - if (path != NULL) { - char *new_path = NULL; + if (path != nullptr) { + char *new_path = nullptr; if (real_id) { if (prefix[0]) { @@ -975,15 +975,15 @@ static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_re MEM_freeN(path); return new_path; } - return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL; + return prefix[0] != '\0' ? BLI_strdup(prefix) : nullptr; } char *RNA_path_from_ID_to_struct(const PointerRNA *ptr) { - char *ptrpath = NULL; + char *ptrpath = nullptr; if (!ptr->owner_id || !ptr->data) { - return NULL; + return nullptr; } if (!RNA_struct_is_ID(ptr->type)) { @@ -1005,7 +1005,7 @@ char *RNA_path_from_ID_to_struct(const PointerRNA *ptr) ptrpath = BLI_strdup(RNA_property_identifier(userprop)); } else { - return NULL; /* can't do anything about this case yet... */ + return nullptr; /* can't do anything about this case yet... */ } } else if (RNA_struct_is_a(ptr->type, &RNA_PropertyGroup)) { @@ -1013,7 +1013,7 @@ char *RNA_path_from_ID_to_struct(const PointerRNA *ptr) return rna_path_from_ID_to_idpgroup(ptr); } else { - return NULL; + return nullptr; } } @@ -1078,7 +1078,7 @@ char *RNA_path_from_ID_to_property_index(const PointerRNA *ptr, char *ptrpath, *path; if (!ptr->owner_id || !ptr->data) { - return NULL; + return nullptr; } /* path from ID to the struct holding this property */ @@ -1118,7 +1118,7 @@ char *RNA_path_from_ID_to_property_index(const PointerRNA *ptr, } } else { - path = NULL; + path = nullptr; } return path; @@ -1140,7 +1140,8 @@ char *RNA_path_from_real_ID_to_property_index(Main *bmain, /* NULL path is always an error here, in that case do not return the 'fake ID from real ID' part * of the path either. */ - return path != NULL ? rna_prepend_real_ID_path(bmain, ptr->owner_id, path, r_real_id) : NULL; + return path != nullptr ? rna_prepend_real_ID_path(bmain, ptr->owner_id, path, r_real_id) : + nullptr; } char *RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, @@ -1150,12 +1151,12 @@ char *RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, /* Try to recursively find an "type"'d ancestor, * to handle situations where path from ID is not enough. */ PointerRNA idptr; - ListBase path_elems = {NULL}; - char *path = NULL; + ListBase path_elems = {nullptr}; + char *path = nullptr; char *full_path = RNA_path_from_ID_to_property(ptr, prop); - if (full_path == NULL) { - return NULL; + if (full_path == nullptr) { + return nullptr; } RNA_id_pointer_create(ptr->owner_id, &idptr); @@ -1222,7 +1223,7 @@ char *RNA_path_full_struct_py(Main *bmain, const PointerRNA *ptr) char *ret; if (!ptr->owner_id) { - return NULL; + return nullptr; } /* never fails */ @@ -1253,7 +1254,7 @@ char *RNA_path_full_property_py_ex( char *ret; if (!ptr->owner_id) { - return NULL; + return nullptr; } /* never fails */ @@ -1302,12 +1303,12 @@ char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index) char *ret; if (!ptr->owner_id) { - return NULL; + return nullptr; } data_path = RNA_path_from_ID_to_property(ptr, prop); - if (data_path == NULL) { + if (data_path == nullptr) { /* This may not be an ID at all, check for simple when pointer owns property. * TODO: more complex nested case. */ if (!RNA_struct_is_ID(ptr->type)) { -- cgit v1.2.3