Refactor BKE_bpath module.

The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.

Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
   topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
  callback that belongs in `lib_id.c` user code.

NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).

NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13381
This commit is contained in:
Bastien Montagne
2021-11-29 14:20:58 +01:00
committed by Bastien Montagne
parent 6ae34bb071
commit e5e8db73df
49 changed files with 946 additions and 721 deletions

View File

@@ -160,7 +160,7 @@ TEST_F(BPathTest, list_backup_restore)
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
void *path_list_handle = BKE_bpath_list_backup(bmain, 0);
void *path_list_handle = BKE_bpath_list_backup(bmain, static_cast<eBPathForeachFlag>(0));
ListBase *path_list = reinterpret_cast<ListBase *>(path_list_handle);
EXPECT_EQ(BLI_listbase_count(path_list), 2);
@@ -169,7 +169,7 @@ TEST_F(BPathTest, list_backup_restore)
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
BKE_bpath_list_restore(bmain, 0, path_list_handle);
BKE_bpath_list_restore(bmain, static_cast<eBPathForeachFlag>(0), path_list_handle);
EXPECT_STREQ(text->filepath, TEXT_PATH_RELATIVE);
EXPECT_STREQ(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);