Cleanup: Move BKE_blendfile headers to CPP.

This commit is contained in:
Bastien Montagne
2023-12-13 12:36:45 +01:00
parent fb8bf8b0c8
commit f01bc93bcf
25 changed files with 104 additions and 132 deletions

View File

@@ -8,7 +8,7 @@
#include <string>
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BLI_path_util.h"

View File

@@ -7,10 +7,7 @@
* \ingroup bke
*/
#ifdef __cplusplus
extern "C" {
#endif
struct bContext;
struct BlendFileData;
struct BlendFileReadParams;
struct BlendFileReadReport;
@@ -20,7 +17,7 @@ struct Main;
struct MemFile;
struct ReportList;
struct UserDef;
struct bContext;
struct WorkspaceConfigFileData;
/**
* Check whether given path ends with a blend file compatible extension
@@ -63,38 +60,38 @@ bool BKE_blendfile_is_readable(const char *path, struct ReportList *reports);
* This is done in a separate step so the caller may perform actions after it is known the file
* loaded correctly but before the file replaces the existing blend file contents.
*/
void BKE_blendfile_read_setup_readfile(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
struct BlendFileReadWMSetupData *wm_setup_data,
struct BlendFileReadReport *reports,
void BKE_blendfile_read_setup_readfile(bContext *C,
BlendFileData *bfd,
const BlendFileReadParams *params,
BlendFileReadWMSetupData *wm_setup_data,
BlendFileReadReport *reports,
bool startup_update_defaults,
const char *startup_app_template);
/**
* Simpler version of #BKE_blendfile_read_setup_readfile used when reading undo steps from
* memfile. */
void BKE_blendfile_read_setup_undo(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
struct BlendFileReadReport *reports);
void BKE_blendfile_read_setup_undo(bContext *C,
BlendFileData *bfd,
const BlendFileReadParams *params,
BlendFileReadReport *reports);
/**
* \return Blend file data, this must be passed to
* #BKE_blendfile_read_setup_readfile/#BKE_blendfile_read_setup_undo when non-NULL.
*/
struct BlendFileData *BKE_blendfile_read(const char *filepath,
const struct BlendFileReadParams *params,
struct BlendFileReadReport *reports);
BlendFileData *BKE_blendfile_read(const char *filepath,
const BlendFileReadParams *params,
BlendFileReadReport *reports);
/**
* \return Blend file data, this must be passed to
* #BKE_blendfile_read_setup_readfile/#BKE_blendfile_read_setup_undo when non-NULL.
*/
struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
int filelength,
const struct BlendFileReadParams *params,
struct ReportList *reports);
BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
int filelength,
const BlendFileReadParams *params,
ReportList *reports);
/**
* \return Blend file data, this must be passed to
@@ -102,30 +99,30 @@ struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
*
* \note `memfile` is the undo buffer.
*/
struct BlendFileData *BKE_blendfile_read_from_memfile(struct Main *bmain,
struct MemFile *memfile,
const struct BlendFileReadParams *params,
struct ReportList *reports);
BlendFileData *BKE_blendfile_read_from_memfile(Main *bmain,
MemFile *memfile,
const BlendFileReadParams *params,
ReportList *reports);
/**
* Utility to make a file 'empty' used for startup to optionally give an empty file.
* Handy for tests.
*/
void BKE_blendfile_read_make_empty(struct bContext *C);
void BKE_blendfile_read_make_empty(bContext *C);
/**
* Only read the #UserDef from a .blend.
*/
struct UserDef *BKE_blendfile_userdef_read(const char *filepath, struct ReportList *reports);
struct UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
int filelength,
struct ReportList *reports);
struct UserDef *BKE_blendfile_userdef_from_defaults(void);
UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports);
UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
int filelength,
ReportList *reports);
UserDef *BKE_blendfile_userdef_from_defaults(void);
/**
* Only write the #UserDef in a `.blend`.
* \return success.
*/
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports);
/**
* Only write the #UserDef in a `.blend`, merging with the existing blend file.
* \return success.
@@ -133,34 +130,25 @@ bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *report
* \note In the future we should re-evaluate user preferences,
* possibly splitting out system/hardware specific preferences.
*/
bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *reports);
bool BKE_blendfile_userdef_write_all(struct ReportList *reports);
bool BKE_blendfile_userdef_write_all(ReportList *reports);
struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath,
const void *filebuf,
int filelength,
struct ReportList *reports);
bool BKE_blendfile_workspace_config_write(struct Main *bmain,
const char *filepath,
struct ReportList *reports);
void BKE_blendfile_workspace_config_data_free(struct WorkspaceConfigFileData *workspace_config);
WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath,
const void *filebuf,
int filelength,
ReportList *reports);
bool BKE_blendfile_workspace_config_write(Main *bmain, const char *filepath, ReportList *reports);
void BKE_blendfile_workspace_config_data_free(WorkspaceConfigFileData *workspace_config);
/* Partial blend file writing. */
void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set);
void BKE_blendfile_write_partial_begin(struct Main *bmain_src);
void BKE_blendfile_write_partial_tag_ID(ID *id, bool set);
void BKE_blendfile_write_partial_begin(Main *bmain_src);
/**
* \param remap_mode: Choose the kind of path remapping or none #eBLO_WritePathRemap.
* \return Success.
*/
bool BKE_blendfile_write_partial(struct Main *bmain_src,
const char *filepath,
int write_flags,
int remap_mode,
struct ReportList *reports);
void BKE_blendfile_write_partial_end(struct Main *bmain_src);
#ifdef __cplusplus
}
#endif
bool BKE_blendfile_write_partial(
Main *bmain_src, const char *filepath, int write_flags, int remap_mode, ReportList *reports);
void BKE_blendfile_write_partial_end(Main *bmain_src);

View File

@@ -7,10 +7,6 @@
* \ingroup bke
*/
#ifdef __cplusplus
extern "C" {
#endif
struct BlendHandle;
struct ID;
struct Library;
@@ -23,12 +19,11 @@ typedef struct BlendfileLinkAppendContextItem BlendfileLinkAppendContextItem;
/**
* Allocate and initialize a new context to link/append data-blocks.
*/
BlendfileLinkAppendContext *BKE_blendfile_link_append_context_new(
struct LibraryLink_Params *params);
BlendfileLinkAppendContext *BKE_blendfile_link_append_context_new(LibraryLink_Params *params);
/**
* Free a link/append context.
*/
void BKE_blendfile_link_append_context_free(struct BlendfileLinkAppendContext *lapp_context);
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context);
/**
* Set or clear flags in given \a lapp_context.
*
@@ -37,7 +32,7 @@ void BKE_blendfile_link_append_context_free(struct BlendfileLinkAppendContext *l
* - #eBLOLibLinkFlags * from `BLO_readfile.h`.
* \param do_set: Set the given \a flag if true, clear it otherwise.
*/
void BKE_blendfile_link_append_context_flag_set(struct BlendfileLinkAppendContext *lapp_context,
void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context,
int flag,
bool do_set);
@@ -48,12 +43,10 @@ void BKE_blendfile_link_append_context_flag_set(struct BlendfileLinkAppendContex
* cannot be linked in BKE code.
*/
void BKE_blendfile_link_append_context_embedded_blendfile_set(
struct BlendfileLinkAppendContext *lapp_context,
const void *blendfile_mem,
int blendfile_memsize);
BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize);
/** Clear reference to Blender's embedded startup file into the context. */
void BKE_blendfile_link_append_context_embedded_blendfile_clear(
struct BlendfileLinkAppendContext *lapp_context);
BlendfileLinkAppendContext *lapp_context);
/**
* Add a new source library to search for items to be linked to the given link/append context.
@@ -66,9 +59,9 @@ void BKE_blendfile_link_append_context_embedded_blendfile_clear(
* \note *Never* call #BKE_blendfile_link_append_context_library_add()
* after having added some items.
*/
void BKE_blendfile_link_append_context_library_add(struct BlendfileLinkAppendContext *lapp_context,
void BKE_blendfile_link_append_context_library_add(BlendfileLinkAppendContext *lapp_context,
const char *libname,
struct BlendHandle *blo_handle);
BlendHandle *blo_handle);
/**
* Add a new item (data-block name and `idcode`) to be searched and linked/appended from libraries
* associated to the given context.
@@ -79,11 +72,8 @@ void BKE_blendfile_link_append_context_library_add(struct BlendfileLinkAppendCon
* #BKE_blendfile_link_append_context_item_library_index_enable to enable the added item for all
* added library sources.
*/
struct BlendfileLinkAppendContextItem *BKE_blendfile_link_append_context_item_add(
struct BlendfileLinkAppendContext *lapp_context,
const char *idname,
short idcode,
void *userdata);
BlendfileLinkAppendContextItem *BKE_blendfile_link_append_context_item_add(
BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata);
#define BLENDFILE_LINK_APPEND_INVALID -1
/**
@@ -101,8 +91,8 @@ struct BlendfileLinkAppendContextItem *BKE_blendfile_link_append_context_item_ad
* it could not open the .blend file.
*/
int BKE_blendfile_link_append_context_item_idtypes_from_library_add(
struct BlendfileLinkAppendContext *lapp_context,
struct ReportList *reports,
BlendfileLinkAppendContext *lapp_context,
ReportList *reports,
uint64_t id_types_filter,
int library_index);
@@ -111,24 +101,24 @@ int BKE_blendfile_link_append_context_item_idtypes_from_library_add(
* context.
*/
void BKE_blendfile_link_append_context_item_library_index_enable(
struct BlendfileLinkAppendContext *lapp_context,
struct BlendfileLinkAppendContextItem *item,
BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContextItem *item,
int library_index);
/**
* Check if given link/append context is empty (has no items to process) or not.
*/
bool BKE_blendfile_link_append_context_is_empty(struct BlendfileLinkAppendContext *lapp_context);
bool BKE_blendfile_link_append_context_is_empty(BlendfileLinkAppendContext *lapp_context);
void *BKE_blendfile_link_append_context_item_userdata_get(
struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item);
struct ID *BKE_blendfile_link_append_context_item_newid_get(
struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item);
struct ID *BKE_blendfile_link_append_context_item_liboverrideid_get(
struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item);
short BKE_blendfile_link_append_context_item_idcode_get(
struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item);
void *BKE_blendfile_link_append_context_item_userdata_get(BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContextItem *item);
ID *BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContextItem *item);
ID *BKE_blendfile_link_append_context_item_liboverrideid_get(
BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item);
short BKE_blendfile_link_append_context_item_idcode_get(BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContextItem *item);
typedef enum eBlendfileLinkAppendForeachItemFlag {
enum eBlendfileLinkAppendForeachItemFlag {
/** Loop over directly linked items (i.e. those explicitly defined by user code). */
BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT = 1 << 0,
/** Loop over indirectly linked items (i.e. those defined by internal code, as dependencies of
@@ -137,7 +127,7 @@ typedef enum eBlendfileLinkAppendForeachItemFlag {
* IMPORTANT: Those 'indirect' items currently may not cover **all** indirectly linked data.
* See comments in #foreach_libblock_link_append_callback. */
BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT = 1 << 1,
} eBlendfileLinkAppendForeachItemFlag;
};
/**
* Callback called by #BKE_blendfile_link_append_context_item_foreach over each (or a subset of
* each) of the items in given #BlendfileLinkAppendContext.
@@ -147,8 +137,8 @@ typedef enum eBlendfileLinkAppendForeachItemFlag {
* \return `true` if iteration should continue, `false` otherwise.
*/
typedef bool (*BKE_BlendfileLinkAppendContexteItemFunction)(
struct BlendfileLinkAppendContext *lapp_context,
struct BlendfileLinkAppendContextItem *item,
BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContextItem *item,
void *userdata);
/**
* Iterate over all (or a subset) of the items listed in given #BlendfileLinkAppendContext,
@@ -159,7 +149,7 @@ typedef bool (*BKE_BlendfileLinkAppendContexteItemFunction)(
* \param userdata: An opaque void pointer passed to the `callback_function`.
*/
void BKE_blendfile_link_append_context_item_foreach(
struct BlendfileLinkAppendContext *lapp_context,
BlendfileLinkAppendContext *lapp_context,
BKE_BlendfileLinkAppendContexteItemFunction callback_function,
eBlendfileLinkAppendForeachItemFlag flag,
void *userdata);
@@ -171,18 +161,16 @@ void BKE_blendfile_link_append_context_item_foreach(
* The IDs processed by this functions are the one that have been linked by a previous call to
* #BKE_blendfile_link on the same `lapp_context`.
*/
void BKE_blendfile_append(struct BlendfileLinkAppendContext *lapp_context,
struct ReportList *reports);
void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
/**
* Perform linking operation on all items added to given `lapp_context`.
*/
void BKE_blendfile_link(struct BlendfileLinkAppendContext *lapp_context,
struct ReportList *reports);
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
/**
* Options controlling the behavior of liboverrides creation.
*/
typedef enum eBKELibLinkOverride {
enum eBKELibLinkOverride {
BKE_LIBLINK_OVERRIDE_INIT = 0,
/**
@@ -200,7 +188,7 @@ typedef enum eBKELibLinkOverride {
* their usages remain indirect.
*/
BKE_LIBLINK_OVERRIDE_CREATE_RUNTIME = 1 << 1,
} eBKELibLinkOverride;
};
/**
* Create (or find existing) liboverrides from linked data.
@@ -214,9 +202,9 @@ typedef enum eBKELibLinkOverride {
* of dependencies or hierarchies. It is not expected to be directly exposed to users in its
* current state, but rather as a helper for specific use-cases like 'presets assets' handling.
*/
void BKE_blendfile_override(struct BlendfileLinkAppendContext *lapp_context,
void BKE_blendfile_override(BlendfileLinkAppendContext *lapp_context,
const eBKELibLinkOverride flags,
struct ReportList *reports);
ReportList *reports);
/**
* Try to relocate all linked IDs added to `lapp_context`, belonging to the given `library`.
@@ -240,11 +228,7 @@ void BKE_blendfile_override(struct BlendfileLinkAppendContext *lapp_context,
* NOTE: content of `lapp_context` after execution of that function should not be assumed valid
* anymore, and should immediately be freed.
*/
void BKE_blendfile_library_relocate(struct BlendfileLinkAppendContext *lapp_context,
struct ReportList *reports,
struct Library *library,
void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context,
ReportList *reports,
Library *library,
bool do_reload);
#ifdef __cplusplus
}
#endif

View File

@@ -341,8 +341,8 @@ set(SRC
BKE_blender_undo.h
BKE_blender_user_menu.h
BKE_blender_version.h
BKE_blendfile.h
BKE_blendfile_link_append.h
BKE_blendfile.hh
BKE_blendfile_link_append.hh
BKE_boids.h
BKE_bpath.h
BKE_brush.hh

View File

@@ -25,7 +25,7 @@
#include "BKE_blender.h" /* own include */
#include "BKE_blender_user_menu.h"
#include "BKE_blender_version.h" /* own include */
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_brush.hh"
#include "BKE_cachefile.h"
#include "BKE_callbacks.h"

View File

@@ -25,8 +25,8 @@
#include "IMB_moviecache.h"
#include "BKE_blender_copybuffer.h" /* own include */
#include "BKE_blendfile.h"
#include "BKE_blendfile_link_append.h"
#include "BKE_blendfile.hh"
#include "BKE_blendfile_link_append.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_layer.h"

View File

@@ -32,7 +32,7 @@
#include "BKE_appdir.h"
#include "BKE_blender_undo.h" /* own include */
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_main.hh"

View File

@@ -34,7 +34,7 @@
#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_blender_version.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_bpath.h"
#include "BKE_colorband.h"
#include "BKE_context.hh"

View File

@@ -50,7 +50,7 @@
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "BKE_blendfile_link_append.h"
#include "BKE_blendfile_link_append.hh"
#include "BLO_readfile.h"
#include "BLO_writefile.hh"

View File

@@ -10,7 +10,7 @@
#include "AS_asset_representation.hh"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BLI_string.h"

View File

@@ -43,7 +43,7 @@
#include "BKE_action.h"
#include "BKE_blender_version.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_cachefile.h"
#include "BKE_colorband.h"
#include "BKE_colortools.h"

View File

@@ -15,7 +15,7 @@
#include "BLI_utildefines.h"
#include "BKE_appdir.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_lib_id.h"
#include "BKE_main.hh"

View File

@@ -25,7 +25,7 @@
#include "BIF_glutil.hh"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_report.h"

View File

@@ -12,7 +12,7 @@
#include "BLI_linklist.h"
#include "BKE_appdir.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_main.hh"

View File

@@ -11,7 +11,7 @@
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "ED_fileselect.hh"

View File

@@ -49,7 +49,7 @@
#endif
#include "BKE_asset.hh"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_icons.h"

View File

@@ -29,7 +29,7 @@
#include "BKE_appdir.h"
#include "BKE_blender_copybuffer.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_fcurve.h"
#include "BKE_lib_id.h"

View File

@@ -16,7 +16,7 @@
#include "BLT_translation.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_screen.hh"

View File

@@ -11,7 +11,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BLI_fileops.h"
#include "BLI_ghash.h"

View File

@@ -22,7 +22,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_blendfile_link_append.h"
#include "BKE_blendfile_link_append.hh"
#include "BKE_context.hh"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"

View File

@@ -18,7 +18,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_global.h"
#include "BKE_main.hh"
#include "BKE_report.h"

View File

@@ -66,7 +66,7 @@
#include "BKE_autoexec.h"
#include "BKE_blender.h"
#include "BKE_blender_version.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_callbacks.h"
#include "BKE_context.hh"
#include "BKE_global.h"

View File

@@ -37,8 +37,8 @@
#include "BLO_readfile.h"
#include "BKE_armature.hh"
#include "BKE_blendfile.h"
#include "BKE_blendfile_link_append.h"
#include "BKE_blendfile.hh"
#include "BKE_blendfile_link_append.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_key.h"

View File

@@ -34,7 +34,7 @@
#include "BLO_writefile.hh"
#include "BKE_blender.h"
#include "BKE_blendfile.h"
#include "BKE_blendfile.hh"
#include "BKE_callbacks.h"
#include "BKE_context.hh"
#include "BKE_global.h"

View File

@@ -34,7 +34,7 @@
# include "BKE_appdir.h"
# include "BKE_blender_version.h"
# include "BKE_blendfile.h"
# include "BKE_blendfile.hh"
# include "BKE_context.hh"
# include "BKE_global.h"