From e5e8db73df86ee04260c5f2bd2c61dfa8eb7943f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 29 Nov 2021 14:20:58 +0100 Subject: 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 --- source/blender/blenkernel/BKE_idtype.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenkernel/BKE_idtype.h') diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h index 05441f06eb8..7a7f32fe838 100644 --- a/source/blender/blenkernel/BKE_idtype.h +++ b/source/blender/blenkernel/BKE_idtype.h @@ -35,6 +35,7 @@ struct BlendDataReader; struct BlendExpander; struct BlendLibReader; struct BlendWriter; +struct BPathForeachPathData; struct ID; struct LibraryForeachIDData; struct Main; @@ -100,6 +101,8 @@ typedef void (*IDTypeForeachCacheFunction)(struct ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data); +typedef void (*IDTypeForeachPathFunction)(struct ID *id, struct BPathForeachPathData *bpath_data); + typedef struct ID *(*IDTypeEmbeddedOwnerGetFunction)(struct Main *bmain, struct ID *id); typedef void (*IDTypeBlendWriteFunction)(struct BlendWriter *writer, @@ -189,6 +192,11 @@ typedef struct IDTypeInfo { */ IDTypeForeachCacheFunction foreach_cache; + /** + * Iterator over all file paths of given ID. + */ + IDTypeForeachPathFunction foreach_path; + /** * For embedded IDs, return their owner ID. */ -- cgit v1.2.3