Helper functions for IDRemapper.
Adds helper functions to debug IDRemapper data structure. `BKE_id_remapper_result_string` converst a given IDRemapperApplyResult to a readable form for logging purposes. `BKE_id_remapper_print` prints out the rules inside a IDRemapper struct.
This commit is contained in:
parent
f691d4553b
commit
811cbb6c0a
|
@ -204,6 +204,11 @@ void BKE_id_remapper_iter(const struct IDRemapper *id_remapper,
|
|||
IDRemapperIterFunction func,
|
||||
void *user_data);
|
||||
|
||||
/** Returns a readable string for the given result. Can be used for debugging purposes. */
|
||||
const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result);
|
||||
/** Prints out the rules inside the given id_remapper. Can be used for debugging purposes. */
|
||||
void BKE_id_remapper_print(const struct IDRemapper *id_remapper);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -157,4 +157,36 @@ void BKE_id_remapper_iter(const struct IDRemapper *id_remapper,
|
|||
const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper);
|
||||
remapper->iter(func, user_data);
|
||||
}
|
||||
|
||||
const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result)
|
||||
{
|
||||
switch (result) {
|
||||
case ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE:
|
||||
return "not_mappable";
|
||||
case ID_REMAP_RESULT_SOURCE_UNAVAILABLE:
|
||||
return "unavailable";
|
||||
case ID_REMAP_RESULT_SOURCE_UNASSIGNED:
|
||||
return "unassigned";
|
||||
case ID_REMAP_RESULT_SOURCE_REMAPPED:
|
||||
return "remapped";
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static void id_remapper_print_item_cb(ID *old_id, ID *new_id, void *UNUSED(user_data))
|
||||
{
|
||||
if (old_id != nullptr && new_id != nullptr) {
|
||||
printf("Remap %s(%p) to %s(%p)\n", old_id->name, old_id, new_id->name, new_id);
|
||||
}
|
||||
if (old_id != nullptr && new_id == nullptr) {
|
||||
printf("Unassign %s(%p)\n", old_id->name, old_id);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_id_remapper_print(const struct IDRemapper *id_remapper)
|
||||
{
|
||||
BKE_id_remapper_iter(id_remapper, id_remapper_print_item_cb, nullptr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue